View Full Version : Syntax for toc.ncx Levels 1 and 2?


NewDay
10-23-2010, 10:16 PM
Is there a way to code the toc.ncx so that iBooks will display Level 1 AND Level 2, instead of putting everything at Level 1?

Here's a sample of some existing toc.ncx code:

<navPoint id="navpoint-5" playOrder="6"><navLabel><text>Breakfasts Plain and Fancy</text></navLabel><content src="CastIronCuisine-6.xhtml#toc-anchor"/></navPoint>
<navPoint id="navpoint-6" playOrder="7"><navLabel><text>Apple Fingers</text></navLabel><content src="CastIronCuisine-6.xhtml#toc-anchor-1"/></navPoint>
<navPoint id="navpoint-7" playOrder="8"><navLabel><text>Hummelgum</text></navLabel><content src="CastIronCuisine-6.xhtml#toc-anchor-2"/></navPoint>
<navPoint id="navpoint-8" playOrder="9"><navLabel><text>Breakfast Lasagna</text></navLabel><content src="CastIronCuisine-6.xhtml#toc-anchor-3"/></navPoint>

I want the text "Breakfasts Plain and Fancy" to visualize on the iPad as a Level 1 entry. Apple Fingers, Hummelgum, and Breakfast Lasagna are all recipes that need to appear as Level 2 entries.

Can I hand-code this directly? What should be the proper syntax?

Jellby
10-24-2010, 05:10 AM
The syntax is:

<navPoint> (Level 1)
</navPoint>
<navPoint> (Level 1)
<navPoint> (Level 2)
</navPoint>
<navPoint> (Level 2)
</navPoint>
</navPoint>

i.e. Just include the <navPoint>'s of the inner levels inside the parent <navPoint>. Whether or not iBooks will display this in tree form is unknown to me.

NewDay
10-24-2010, 11:27 AM
Jellby, thanks for the syntax. I'll report back whether iBooks honors it.

NewDay
10-26-2010, 01:02 PM
Jellby, I used the syntax you gave. Ran it by a syntax validator, came out clean. Sent it to epubcheck and it wouldn't validate. Removed the Level 1, Level 2 syntax and got validation. What now? I still feel it's important that Level 2 items be subsumed under Level 1 for visual clarity. But how to make that happen when somewhere my requests to InDesign get lost in transition?

charleski
10-26-2010, 01:26 PM
Here's the toc.ncx for a book (http://www.mobileread.com/forums/showthread.php?t=103098) I uploaded here. It has a 2-level ToC and validates perfectly in epubcheck 1.05.

Converting your code as you described would produce:
<navPoint id="navpoint-5" playOrder="6">
<navLabel>
<text>Breakfasts Plain and Fancy</text>
</navLabel>
<content src="CastIronCuisine-6.xhtml#toc-anchor"/>
<navPoint id="navpoint-6" playOrder="7">
<navLabel>
<text>Apple Fingers</text>
</navLabel>
<content src="CastIronCuisine-6.xhtml#toc-anchor-1"/>
</navPoint>
<navPoint id="navpoint-7" playOrder="8">
<navLabel>
<text>Hummelgum</text>
</navLabel>
<content src="CastIronCuisine-6.xhtml#toc-anchor-2"/>
</navPoint>
<navPoint id="navpoint-8" playOrder="9">
<navLabel>
<text>Breakfast Lasagna</text>
</navLabel>
<content src="CastIronCuisine-6.xhtml#toc-anchor-3"/>
</navPoint>
</navPoint>

NewDay
10-26-2010, 01:50 PM
Charleski, that is a very beautiful toc. Does it actually play at two levels in iBooks? There's my rub. iBooks seems to be acting strangely if I make my toc too long. Do you have that trouble?

Iznogood
04-04-2011, 03:47 AM
I know I'm answering an old thread, but just in case anybody else is looking for answer to this question: I tested this yesterday, and found that iBooks, the viewer in Calibre, Adobe Digital Editions and the Bluereader App both handles at least two levels TOC fine

Nigol
04-04-2011, 05:09 PM
I have found out that sometimes epubCheck will give out a lot of errors, that won't prevent your book from being read, so If the result i sacceptable and works with calibre & ADE I don't think there should be any problem.

On another note, try the app in my Sig, it will let you change the Levels of your book without manually editing the toc.ncx (Just drag and drop)