Create custom spacing in ebook TOC

Here is a post describing how the dedicated ToC page can designed, as @AntoniDol describes above.

Two things worth note:

  • Check your ebook’s validity. Inserting empty paragraphs with forced spaces in them is very likely creating an invalid book that will be rejected from most vendors. The ToC is a special page that has a few strict rules, described in the user manual, §22.3, Contents in Ebooks.

  • The method described for designing the page itself does not really address inserting spacing in between particular navigational line items. There are ways to do that with CSS. They are fairly static though and something you’d want to save for the end of the process because they would refer to internal HTML page names. Any re-ordering or additions to the ToC would require adjusting the CSS. The other downside is that I’m not sure how well supported this approach of attribute selection is in ebook readers (they would also need to not touch the links href contents, which some might do on the fly like Calibre Reader).

    But if you want to try it, the method would go something like this:

    nav li a[href="body4.xhtml"] {
    	display: inline-block;
    	margin-bottom: 1.4em;
    }
    

Of course there are ways to do this, don’t get me wrong. I’m just thinking it might be difficult if you adhere to a self-constraint of only using Scrivener to produce the ebook. The problem itself could be very easily solved in an ebook editor like Sigil, where one would locate the ToC entry that should have a spacer, and add:

<li class="toc-spacer"><a href="body4.xhtml">Map</a></li>

Here we add the class definition to the <li> element, which can then be safely added to the CSS compile format pane in Scrivener, as:

.toc-spacer {
	display: inline-block;
	margin-bottom: 1.4em;
}

Thus, adding the class declaration to the contents.xhtml file in Sigil would be the only post-compile step you need to take.