Table of Contents Scrivener 3

I created a page called CONTENTS, added this to the compile page for Ebook on the Table of Contents page, and checked create custom HTML table of contents.

I copied special for TOC, and pasted into the documents called CONTENTS. I formatted the text links, and inserted blank lines as suggested. The only thing I get after compile is the contents page WITHOUT FORMATTING. Suggestions please!

Ebook content pages are, as per ePub specifications, a bit bare bones, and if you do anything too crazy with them they can even break the book’s validation. There are a few simple rules you need to follow in order for them to be in compliance, which you will find in §22.2, Contents in Ebooks, in the user manual PDF. There isn’t much by way of formatting given to them by default.

That said, they are in essence just HTML, and thus can be styled with CSS. So long as the look you are going for is something that can be thought of as a universal design on the ToC, rather than individual lines being different from one another, you should be able to do that in the compile format designer, in the CSS pane.

  1. Double-click on the compile Format you are using, in the left sidebar of the compile overview area, and click on the CSS pane.
  2. In the left column you can add whatever formatting you want to the book.

For example, here is some CSS that makes the ToC look like this:

CSS for ToC...

The <nav> element is what ebooks use to describe the internal navigation of the book. And the whole ToC design will be within it. The .page-title class is something Scrivener adds to the heading on the page, by default, so since you’re doing something custom you may have a different style in use for it.

nav * {
	text-align: center;
	margin-left: 0rem;
	padding-left: 0rem;
	text-indent: 0rem;
}
nav {
	width: 85%;
	margin-left: auto;
	margin-right: auto;
	padding-bottom: 2rem;
	border-bottom: 1px solid #000;
}
nav .page-title {
	margin-top: 2rem;
	margin-bottom: 2rem;
	padding-bottom: 0.5rem;
	font-size: 1.5rem;
	border-bottom: 1px solid #000;
}
nav a {
	text-decoration: none;
}
nav li {
	margin: 0rem 0rem 0.65rem 0rem;
}

See also: Formatting TOC - #2 by AmberV

1 Like

CSS is a great idea. However, I am now using Scrivener 3 and there are videos that show how to create a custom TOC by creating a new text file, and copying the file structure into it using Edit / Copy Special / Copy for TOC, and paste. It works fine but does not compile. I think I must be missing something. Thanks for the great tip. I wish I could send a picture of the TOC - might help. I tried and got an error that I could not upload media into a post.

I suppose you’re not compiling the ToC document. If it’s not marked for Compile or it’s outside the Draft and not in Front Matter, it won’t compile.

Good point. I checked and the box for compile is checked. When I look over the documents after the compile, the contents is one of the pages. But it is not formatted like I have it. It is like it is being compiled but ignoring my formatting. I looked for a box to check that says leave as it is, but all I have found is a box that says N/A. There are options for heading, section, and a few others and then a box for N/A. I could not find any thing for leave as it is, as was in the previous version of Scrivener.

However, I am now using Scrivener 3 and there are videos that show how to create a custom TOC by creating a new text file, and copying the file structure into it using Edit / Copy Special / Copy for TOC, and paste.

Okay, it sounds like that video is either incorrect, or perhaps misleading, as that command you are referring to is not what you should be using for ebooks in the first place. You will note that it also copies page number placeholders—which don’t do anything in an ebook, and it makes use of tab stops to offset the page numbers, and tab stops don’t exist in ebook formatting either. So it’s all rather unsuitable to the medium.

The advice given in the user manual section I referred you to is the only correct way to make a ToC in an ebook. Basically the capability being granted for a custom ToC in ebooks is not to create a fancy design in the editor, but rather supply a different list of sections than the automatic generator would. That’s all it’s for.

I looked for a box to check that says leave as it is, but all I have found is a box that says N/A. There are options for heading, section, and a few others and then a box for N/A. I could not find any thing for leave as it is, as was in the previous version of Scrivener.

This is all a red herring. To rephrase what was said before in a more technical and direct way, there isn’t a way of formatting the ToC like you’re thinking of, because it’s not normal content. It’s a special piece of data that in part helps drive ebook reader software navigation, like when you use a button that advances to the next chapter.

That is why CSS is the only way to create custom, fancy ToC designs.

But that aside, to answer your question about as-is, there is an “As-Is” default layout that is always available in the Assign Section Layouts screen. For normal content that would pass-thru editor formatting through.1


1) Since it sounds like you’re looking for older conventions in the new software directly, at some point it might be helpful to check out the migration tutorial we’ve written, which among many other small changes, shows what happened to “as-is”, “page break before” and so on.

This is great information. Thank you for the help and valuable insight. I think scrivener 3 is fantastic. I think you are correct - I was misled by the video.

I hope you don’t mind if I ask one more question about this. Under the edit tab, there is a selection for COPY SPECIAL as TOC. And in the compile section, under the last tab is the section for TABLE OF CONTENTS where you can specify a file to hold the table of contents created from html. Can you please provide a brief explanation, or lead me to where I can an explanation of how these two work? It seems like scrivener 3 allows for the creation of a TOC, and this can be loaded into a file during compile - sorry, just a little bit of clarification. I would not want to miss a great feature like this. Thanks.

Chapter 22 in the (Mac) manual discusses Tables of Contents in detail, both for ebooks and other formats.

The capability being granted by this tool is to supply a different list of sections to the reader, than what the automatic generator would. Let’s say you have a book with section breaks down to level 4, but that makes too much of a ToC, many dozens of entries. You only want down to level 2, so chapters and sections within them. One possible way you could go about doing that efficiently:

  1. Click on the Draft folder and switch to Outliner mode.
  2. Use the View ▸ Outline ▸ Collapse All command.
  3. Select all of the items (those functioning as chapters, at level one in the draft), and press the Right Arrow once to expand them one level.
  4. Select everything again, now chapters + sections, and use the Edit ▸ Copy Special ▸ Copy Documents as Structure Link List to create an ebook friendly indented topic list as links.

Paste this into your “Contents” document in the front matter or draft folder, and now your ToC only extends to level 2, and more importantly this list also drives the software ToC, that many ebook readers use for quick navigation within the book (without having to visit the contents page itself), and as well the Next Section and Previous Section features.

(Note: there is a bug with indented link lists not created a nested ToC in the output, but the above description still suffices for flat lists, and will for indented lists once that is fixed.)

A table of contents, in an eBook, is the way readers get around. They expect it to look and operate the same way from book to book, so I’d leave it alone.