Tables of Contents for Kindle and ePub

Do any clear and simple instructions exist for creating the TOCs that generate for mobi and ePub books in the compile process?

In other words, is there a simple set of instructions anywhere that enables you to know exactly what will and will not be included in the generated TOCs in the compile process?

I feel that I am having to fend for myself hit-and-miss trying to get the TOCs to show what I want them to.

I think that a section or subchapter in the Scrivener User’s Manual on “How to Create the TOC You Want in Mobi or ePub During the Compile Process” would be just terrific!

Am I alone in this?

There should be nothing too mysterious here - anything that has a section break before it will appear in the table of contents. You can also create your own tables of contents using Scrivener links, but again, there must be a section break before a document (defined in “Separators” in Compile or using “Page Break Before”) for the section to be linkable in the ToC.

All the best,
Keith

1 Like

Hi Keith, What if I need a page break or section break in the ebook but I do NOT want it to show up in the TOC? Is there a way to do that? THanks

Is there actually a way to prevent a document set with a section break from appearing in the table of content ?
Thanks…

1 Like

Which ToC?

There’s a navigation “menu” generated by the reader software. We have no control over what appears there.

And there’s a ToC document, which can be either automatically or manually generated. If you generate it manually, you can include/exclude whatever you want. See the chapter on Tables of Contents in the manual for more information.

That’s not entirely true, of course. The e-reader doesn’t know about the contents of an e-book until it reads the toc.xhtml file containing the nav element.

Editing this document determines what appears in the e-reader menu. Calibre or Sigil can do that after the e-book has been compiled by Scrivener.

1 Like

Yes, forgot to mention that Calibre or Sigil can edit the file. But “we,” Scrivener, don’t.

1 Like

Actually, there is a way to hide sections from the ToC generated for ebooks on Scrivener.
Here it is:
it is called New Pages as Layout, not Structure
With those two methods aside, there is a somewhat more philosophical question worth thinking about: is the scene actually a part of the chapter it follows—is it in that chapter for all intents and purposes, like any other scene, and that’s why you don’t want it in the ToC? If so, any kind of section break here isn’t what you really truly want—and hiding the fact that it is a section from the ToC systems is just a bandaid approach to the problem.
What you want is a mere layout decision: to go to a new screen on the reader. And in that case, using CSS is the right answer, as that is the technology used for implementing layout decisions in ebooks:
Follow the first two steps in the instructions above, to create a new Layout. In this case I’ll call the new Layout, “New Page (No Break)”.
In the Separators compile format pane, make sure the new Layout only inserts “single return”. We’re taking this route specifically because this recipe isn’t a new section, after all. :slightly_smiling_face:
Click on the Settings tab, and give this section layout a CSS class name. I went with “new-page” (do not use spaces).
Select the CSS compile format pane. The left column, titled “Custom Stylesheet”, is a place where you can override or add CSS layout instructions to your book. As you can see we provide a lot of layout out of the box (much of it based on checkboxes and fields you use elsewhere). We need a new directive that handles the “new-page” class; copy and paste the following into the CSS pane:
.new-page { page-break-before: always; }
(The original write-up of this technique can be found in this forum thread, though it’s worth noting that is aimed at those that use Markdown in Scrivener, and make use of the Pandoc ePub generator when they compile. Much of the principles and steps involved will be similar however.)
There are other approaches as well, but unless you have strong objections to adopting any of the above, I wouldn’t say they have any inherent advantages over these.

Here is the original formatted version of that description.

I would say there are two techniques to think about. For some things, yes layout and using CSS properly is the right answer (stuff like “full screen” illustrations). For other things we might sometimes want formal sections, we just don’t want them to show up in the ToC.

There probably aren’t too many cases where that overlap exists, but I could see some certain types of works benefiting from it, such as recipe books. You want the soup sections listed, not each individual soup recipe, but you want each recipe to be a section, because it is. For something like that, the method referred to in the previous section of the linked post is best.

Thanks for your answer.
My case is in novels I write : I often have texts written from the POV of one specific character.
I want a page break before and after it, since it is a specific event in the book and I want it separate from the usual narrative, but it’s not a separate chapter, and I don’t want it to be visible in the ToC.
I would love a simple setting enabling me to check whether or not I want a specific section to appear in the ToC rather than Scrivener considering that each section break automatically means it should appear in the ToC…

1 Like

Could you describe what you are looking for that is different between the checkbox I referred you to, and “…a simple setting enabling me to check whether or not I want a specific section to appear in the ToC…”?

These things seem identical to me, so I am not understanding what you have in mind.

Well, with the method you referred me to, we have to:

  • create a specific section for these texts we don’t want appearing in the ToC
  • go to the css settings of the section and assign a custom name
  • then go to the css settings of the format
  • and use a bit of code.

It works, but it is not as user friendly as a simple box to check in the compiled list of documents, that just says « hide from ToC ».
Something that even people with absolutely no knowledge of CSS code and logic could use and understand on their own.

Scroll up from where the link takes you to, and refer to the steps in the “Omit from Visual HTML Table of Contents” section. What is described there is your single checkbox.

I should mention this is macOS-only at the moment, but given your posting history I think it is relevant. Sorry if I missed that you’re on Windows.

But it’s only possible for HTML ToC isn’t ?
I was talking about the « real » ToC generated for an ebook.

Ah, yeah unfortunately that setting does only pertain to the ToC people see in the page flow, so to speak (I’m not sure why it works that way, to be honest, as it seems rare you’d want one but not the other). The only way around that is the very first method I mention in that post, where you create a custom ToC page in your front matter that omits the sections that shouldn’t be listed. That does drive both what you see in the page flow and what gets used for the internal navigation metadata.

I’ll try this very first method asap to try and see the difference :slightly_smiling_face:
Right now I used the CSS one, which works for the novel content, but I couldn’t manage to get my Title Page out of the ToC with it :confused:

2 posts were split to a new topic: Achieving cosmetic-only page breaks in ebooks