EBW Knowledge Base

Check the epub Table of Contents

Fixing mistakes

Sometimes mistakes can creep into your automated table of contents in InDesign, which then appear in your epub’s TOC. It’s sometimes easiest to fix the TOC in the epub rather than going back to change your InDesign document and export again.

Open toc.ncx (it’s usually in the OEBPS folder) in a code editor (e.g. Textpad). The ncx code is pretty daunting. If you need to make any changes more complex than the ones suggested here, read up about toc.ncx files before getting stuck in.

The TOC is made up of a chunk of code for each link that looks something like this:

 <navPoint id="navpoint" playOrder="1">
  <navLabel>
    <text>Title of chapter</text>
  </navLabel>
  <content src="chapter.xhtml"/>
 </navPoint>

Headings of subsections can also be nested within the navpoints to create sublevels in the TOC.

All you may need to do is correct mistakes in the titles of the chapters, which is the text between the <text> and </text> tags.

Special characters

Later, when you check your epub in an ereader, you may find that the TOC doesn’t include all TOC items, often just cutting off at some apparently random point. If this happens, you’ll be back to this section troubleshooting it!

Check toc.ncx for special characters (e.g. apostrophes/curly-quotes that have become other characters, or unusual glyphs). Due to a problem with character encoding in toc.ncx files, they can break the TOC. If you just remove or change the special characters, this usually fixes the problem (just deleting the problematic special character and retyping the correct or an alternative character should work).

NCX media type

This is a technical issue you may not have to worry about. In the manifest and in the toc.ncx file, the media-type for the ncx file should read media-type="application/x-dtbncx+xml". Some epub-creation software (we found this in CS3) gets this wrong.

So, the full item tag for the ncx file should read:

<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>

and NOT

<item id="ncx" href="toc.ncx" media-type="text/xml"/>

Fix it if you’re being thorough. It will validate in epubcheck either way. (See this note on the epubcheck issue list).

Leave a Reply