Book Design
Ebook Formatting – Part 7 – Other Useful Stuff

Ebook Formatting – Part 7 – Other Useful Stuff

Before we jump to the Table of Contents, let’s see some other of the most common operations you might need to perform when you edit an ePub.

Add or Delete Files

It might happen sometimes that due to formatting problems in the original document, when you convert it you’d find unnecessary white pages or chapters split between two or more files, or for some other reason you might need to delete or add some text files. The task is very simple.

To delete a file select it from the column on the left and right click, then Delete… and Delete Marked Files.

To add a new file, place your mouse on the file under where you want to insert the new one and right click, then Add Blank HTML file. If you click Add Copy you’ll have a new file that’s the same as the one you selected.

If the new file appears in the wrong position, you can click it and drag it with you left mouse button to place it where you want. Remember that the order in which the xhtml files are is the order in which they will be shown on your reading device while flipping the pages.

Be sure that the <head> part of the new file is the same as the one of the others and links to the right stylesheet (if it’s not just copy and paste from another file).

Rename Files 

It can be useful, if you want a tidy ePub and don’t want to get lost in the default titles that don’t tell you what part of the text they contain, to rename the xhtml files with more understandable names, like Cover, Colophon, Dedication, Chapter1 etc. 

To do this just go to the file, right click and choose Rename… the file name will become editable. You will not be able to change the .xhtml extension for obvious reasons. If you have a series of progressively numbered chapters and you don’t want to repeat the operation 123 times, just select the first chapter, hold down the shift key and click on the last chapter to highlight all of them, then right click and choose Rename… again. This time it will ask you to Rename Files Starting At: and just type for example Chapter1 and it will name the next files Chapter2, Chapter3 etc.

Edit the Text

It is always a good idea to double-check the text after conversion and make sure that there are no missing parts or that they are not scattered in odd places, and that all alignments are done properly, bold and italics are in place, etc.

What can you do if parts are missing or if you need to correct mistakes?

You can do the same as in any word processor, edit, add, copy and paste what needs to be copied and pasted. The important thing is to always make sure that every paragraph is between the <p> </p> tags and the code is in order. 

Sigil, however, is a good boy, and if there is something wrong he will automatically correct it or warn you and allow you to fix it.

Believe me, it’s a great relief to know that if you realize you’ve made a typo, all you have to do is change one word and you don’t have to regenerate the whole document again.

Add Blank Spaces

To add spaces or blank lines within the document we usually use this code string:


Or this (they are equivalent):


This will tell the device to display a blank line in the text. If you need more than one line you’ll have to type (or copy) the code multiple times. But this is not always the optimal solution, in many cases it’s preferable to play with the spacing in the style sheet, as we will see in the next chapters.

Replace the Cover Image

If you generate the file with Writer2ePub and the default settings, it will automatically reduce the size of the cover image so that the ebook file size won’t be too big (and in some cases if the cover is a large file, it may give you an error message, so try generating the file without images). But in case you are not satisfied with the result, or in case you need to replace the image with another one, here is a quick and easy way to do it.

As I explained before, you just have to put the new image in the Images folder so that it’s embedded in your file. Then there are two other small changes you need to make in the code. First of all, go to the coverpage.xhtml file and replace the name of the cover file with the new one you inserted (it would be better if they had different names so you don’t get confused in the substitution). So, if the old cover was called cover.jpg and the new one cover2.jpg you have to locate this piece of code in the <img /> tag:


and change it to:


But there is another change you need to make, because the cover is not just any image, and it is important to tell the reading device that one is the cover of your book, so you need to do something in the content.opf file as well (this will be the only time I will ask you to do this because I know how terrifying opening that file can be).

Look for where this code is:

<meta name=”cover” content=”cover.jpg”/>

and change it to: 

<meta name=”cover” content=”cover2.jpg”/>

(Even if you had “content” first and then “name”, nothing would change, tag attributes have no fixed order). 

If you can’t find this code string (it may happen if you deleted the old cover before inserting the new one, or if you converted the ebook without the cover), you can simply reinsert it manually with the updated file name, placing it before the closing </metadata> tag.

Save and you are done. Now you will see that your new image will appear in the cover page.

If you haven’t already done so, remember to delete the old image because it is no longer needed and is no longer linked to any part of the document, or you will get an error when you go to validate the file. Just right click on it and select Delete… as we did with the other files.

Alternatively, there is a special command to insert a cover, but it is better to use it when the cover is not already there, while in our case it is faster to make these three modifications by hand.

To insert a new cover page when you don’t have it already, just click on the menu Tools > Add Cover… and then on the right side click on Other Files… from there the usual window will open to make you choose the image from your computer.

Once you have given the OK you will see that a new file called cover.xhtml will appear on the left column. The code is slightly different from the one generated with Writer2ePub, but it should work the same way. In case of problems you can modify and replace the code as you like. 

And finally…

The Table of Contents (TOC)

The TOC is no other than the table of contents/summary of your book, but in an ePub there are two types of TOCs, one is the one that is automatically generated thanks to the chapter headings and is contained in the toc.ncx file. This TOC is not immediately visible to those who open the ebook, but can be reached and shown only by clicking on a particular icon or menu – which is different for each device. 

The other type of TOC is the HTML one, always clickable and visible, which should be placed at the beginning of the book so that the reader can physically see it while browsing through the pages.

So if you haven’t already generated an index page when you generated the file, you can do it now with a special command.

Note: do it only when you have already fixed the whole file and made sure that all the headings are in place.

Go to the Tools menu > Table of Contents > Create HTML Table of Contents.

This will add the new TOC.xhtml file, with its own stylesheet, to the beginning of the document. However, in order for it not to be the first thing one sees when opening the ebook, even before the cover, grab it by holding down the left mouse button and drag it to the desired position (usually after the colophon).

It should already be ok as it is, but if you are not satisfied with the layout you can always modify the code based on what we have seen so far. Sigil also automatically creates a new style sheet dedicated only to that file.

As for the hidden TOC I mentioned at the beginning, sometimes it can have errors, especially if you have modified the file in the meantime. In this case it is better to regenerate it from scratch by going to Tools > Table of Contents > Generate Table of Contents. You can preview it immediately from the right column.

But what if it still doesn’t look right? Or if you want to add or remove items? This is also editable, again from the Tools menu > Table of Contents > Edit Table of Contents

Here you can add or delete entries, decide the structure of titles and subtitles using the arrows to add or remove indentation, whatever you want. To edit an entry just double click it and fill it in manually. Always remember to write in full the path of the file you want to link, which should be something like text/filename.xhtml. If you write it wrong, obviously the link won’t work and you’ll get an error message during validation.

I think we are done with the general HTML things. In the next part we’ll finally jump into the Stylesheet!

Leave a Reply

Your email address will not be published.