3

Ideally, I'd like to not have a ToC. But I understand that without one, an epub won't validate. Is there any way to create a ToC with no content, including no ToC header?

  • Just to be clear, you're talking about he toc.ncx (which is required) and not an html TOC that you can optionally include as a page (or pages) in your epub, right? If so, then I'm curious as to why you would want to remove it when reader need never see it if they choose not to. – beaker May 18 '17 at 17:06
  • I'm assuming that you REALLY want to know if it is required to list all TOC entries because you want readers to "fly blind" when reading through the pages. See my answer below. – idiotprogrammer May 19 '17 at 17:11
  • @beaker: because when you convert from Quark you get an empty page titled, "Table of Contents" which is superfluous. – user26732 May 20 '17 at 2:00
1

I'm guessing that you are asking the question in the wrong way: you actually want to hide the HTML entries from the TOC so that the TOC doesn't spoil any surprises. I have good news. In epub3 you can create a navigation page and hide all the entries in that TOC.

Let me explain some basics. The terminology can be confusing because initially Kindle required a "logical TOC" (which was an HTML file linking to all the chapters) in addition to a TOC in toc.ncx The real TOC (which is machine-readable) was in toc.ncx for epub2 but inside the NAV element of the required navigation document in epub3.

In epub3 it is no longer necessary to have a toc.ncx file (and for future versions it will be deprecated). Instead you include a HTML navigation document (which you mark by using the NAV element in that file). For epub3, writers of the standards wised up; they realized that rather than requiring two different kinds of TOCs, why not just put everything in one navigation HTML document, with proper tagging and then forget about toc.ncx?

Fortunately, it is relatively easy to hide TOC entries inside the NAV element of the epub3 navigation document.

Here's how you do it in epub3. "The presence of the hidden attribute on the root indicates that the entire list is excluded from rendering in the content flow." (Source)

<div class="toc-title">Table of Contents</div>
    <nav epub:type="toc">
           <ol hidden="">
                <li><a href="editor-preface.xhtml">Preface</a></li>
                <li><a href="requiem.xhtml"> Requiem on the Rappahannock </a></li>
                <li><a href="version-history.xhtml">Version History</a></li>
            </ol>
    </nav>
</div>

I'm not 100% sure you can hide all the entries (I haven't tested that), but I'm pretty sure you can hide almost all the entries (maybe you are required to have at least 1 visible TOC item).

If you want to hide one or more entries in epub2, edit this in package.opf.

 <spine toc="ncx">
        <itemref idref="cover" linear="no"/>
        <itemref idref="htmltoc" linear="yes"/>
        <itemref idref="alternate-toc" linear="no"/> 
         ...

Linear="no" means to exclude it from the TOC entries for epub2 reading systems. Importantly, note that if you have an epub3 file, the reading system will probably obey the and ignore whatever you put in the package.opf file.

I am talking about epub and epub3. If I remember correctly, converting from epub3 to mobi produces the same effect.

The ability to hide TOC entries is important for certain kinds of books (the first thing that comes to mind are Choose-your-own adventure ebooks and other hypertexts).

  • I'm converting from Quark; pretty sure that it's epub2. I am not even familiar with any epub3 creation tools other than iBooks Author. I'm getting a page titled, "Table of Contents" with no entries. This page needs to go. What I want to do is suppress that page; so I'm not sure how this is asking "in the wrong way." – user26732 May 20 '17 at 1:59
  • you are speaking about a "logical TOC" then. You don't need to have a logical TOC for epub2 -- but Amazon strongly recommends that you have one. – idiotprogrammer May 20 '17 at 2:17
  • I typically edit the HTML files directly rather than using a conversion tool. It sounds hard, but it's actually much easier to do if you know what you're doing. Sometimes when you convert from Word/Quark, etc, you need to know what is going on the underlying HTML. – idiotprogrammer May 20 '17 at 2:23
  • Often conversion tools like Calibre auto-generate this TOC page by looking at the heading for each chapter. But if the styles are inconsistently applied, then this autogeneration process will fail. I bet if you go to your source and style each chapter title as "heading" or h1 (or whatever Quark has), the conversion process will auto-generate the links in this logical TOC correctly. – idiotprogrammer May 20 '17 at 2:27
  • Unfortunately, I don't know how to apply styles in Quark. I tried to futz with the underlying ePub html but am getting errors. I think those errors are beyond the scope of the original question, so I asked a new one here: ebooks.stackexchange.com/questions/7213/toc-errors-thrown – user26732 May 20 '17 at 4:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.