Create custom spacing in ebook TOC

I’d like for my TOC to visually separate the chapter links from the front and back matter links, like this TOC does here:

However, I can’t seem to get any spacing, even if I manually add in a line break on my contents page. This is what the output looks like (it does this for both epub and mobi formats):

I’m using “Generate HTML Table of Contents” and I created my TOC page by selecting the desired documents, choosing “Copy Special”, then “Copy Documents as Structured Link List”. Any help to get that empty line before and after the chapters would be most appreciated!

HTML doesn’t allow empty lines (or so I hear), so try putting a space, maybe a non-breaking space, on the line you want to be blank.

Huh, weird. One space on the empty line doesn’t do anything, but if I do like 5 spaces I get a tiiiny gap:

If I do a whole bunch of spaces, or a tab, I get this weird “1.” showing up:

No idea what’s going on here. I’d like for the gap to be bigger, but the first screenshot above is better than nothing if there aren’t any better solutions.

It has to be a non-break space.

→ ←

As for the indent in the TOC, I don’t quite remember how to do it (if I ever knew), but looking in a compile format, the option seems to be absent for the Epub format.
It would otherwise have been in the “transformation” tab. (Or so I think.)

I wonder what gap you’re talking about.

Ah, the non-breaking space did it! Didn’t even know what that was; thank you so much for the help.

1 Like

A little late to the show, but in your HTML contents – instead of the toc with the <nav /> element in it – you can style everything the way you like.

So, create two styles in the Stylesheet, one for front and backmatter, one for your manuscript links.

An empty line is best created using


To indent text, use text-indent: 25px; or margin-left: 25px

Hope this Helps

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.