0

I write my books (ePUB 3.0) using Sigil. In principle, there's a simple function to automatically add a cover, which creates an XTML file called "cover.xhtml", which looks like this:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
  <title>Cover</title>
</head>
<body>
  <div style="text-align: center; padding: 0pt; margin: 0pt;">
    <svg xmlns="http://www.w3.org/2000/svg" height="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 1563 2500" width="100%" xmlns:xlink="http://www.w3.org/1999/xlink">
      <image width="1563" height="2500" xlink:href="../Images/COVER_FILE_NAME.jpg"/>
    </svg>
  </div>
</body>
</html>

This works in Sigil, meaning that the cover will show just fine in the ebook preview within Sigil itself. What happens with other e-readers is a different story. Calibre will ignore it altogether, for example, and if you use Calibre's cover tool, it will create a file with different code called "titlepage.xhtml" instead. Opening the ebook with Adobe Digital Editions will result in a thumbnail-sized cover. Sumatra PDF (which can read ePUBs), won't give a damn about anything that is not in the TOC, cover included, as well as a couple of styles in my CSS though that's a topic for another day.

What I expect from a cover is that:

  • it's the first thing of the ebook you see
  • it's centred and full-screen, and adapts to your screen's size
  • it doesn't change depending on what I use to read the ebook (this is wishful thinking, given that as far as I know, you won't find even two browsers that interpret HTML and CSS the same way), or at least, most modern e-readers won't each have their own wonky idea of what my cover should look like.

My questions are:

  • Is there a standard way to add a cover that does what I want?

  • Does it matter whether the cover file is called cover.xhtml, titlepage.xhtml, or whatever?

  • Should I include the cover, and all my xhtml files, in the TOC? Seems silly to include the cover, or the internal cover, but I just thought it might be a good idea when I saw that Sumatra PDF ignores anything outside the TOC.

I also want an internal cover, as you find in normal paper books, which is just a black and white version of the cover. I assume this shouldn't be done by simply creating another title page, as then your ebook reader might think you've got two title pages and god knows what might happen. So I did this:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title></title>
<link href="../Styles/mystyle.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<img id="internal-cover" src="../Images/internal-cover.png"/>
</body>
</html>

i.e., I basically created a page that has only one image in it, and I have CSS for the internal-cover id that just says width:100%. Again, this works in Sigil; open in it another reader, and the result is basically up to quantum mechanics. Mostly, the internal cover is huge and doesn't adapt to screen size.

How do I put a full-screen image that takes up the e-reader's screen and no more, and make sure it stays put regardless of the e-reader?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.