How to add TOC to

I’m trying to work out how to correctly add a TOC to a paperback format (output to Word docx). This is what I tried:

  • Highlighted the headings in the binder
  • Copy special->Copy Documents as ToC
  • Added a TOC page to Paperback frontmatter and pasted the ToC
  • Compiled paperback format

This is what the raw TOC looked like:

toc_before

This is what it looked like in the compiled Word file.

Am I missing some configuration to get this working, or is there some issue with this function? FYI, for this test, I created a new project based on Novel with parts.

Thanks

One quick question: did you put any text into any of these documents? It looks to me like the ones that produce headings are linking up (though you may need to quickly run print preview in Word to resolve the page numbers), but those that do not produce headings (scenes) are not. If Scrivener detects no content to compile for a section, then it won’t be included in the output at all (this avoids adding redundant separators and other such issues), and thus the bookmarks pointing to these sections will be recognised as missing, and be removed.

In other words there may be a bit of a cart before horse problem here, with inserting a ToC into an empty project. It generally works best as one of the last things you do.

Hi AberV,

Thanks for checking it out. Yes, adding some content to the scenes made a difference, the XXX changed to a link but all of the links are question marks, not page numbers - I assumed the process would create a link and display the page numbers. Also, I still see <$rst_scene> - I searched for that and saw a comment from a couple of years ago that this hadn’t been implemented - not sure if that is still the case?
Also, another interesting oddity is if the document is compiled into a OneDrive folder, the links are fully qualified URLs pointing to https://d.docs.live.net or if on hard drive, fully qualified local links pointing to file/directory - these links, I think, should be internal to the document only, not external, similar to Word’s built in TOC generator.

Thanks

I’m not seeing anything precisely like that (in fact the “XXX” thing to me is unfamiliar as well). When I compile to RTF or DOCX and open in LibreOffice is a functional setup. So it might be something specific to the software you are using to open the compiled document? Does it support RTF, if so, I’d try that as it involves less complexity on Scrivener’s end. With .docx it has to use a third-party converter.

…these links, I think, should be internal to the document only, not external, similar to Word’s built in TOC generator.

I have no idea about that, but if a file saves one way in one folder and another way in another folder that has a bunch of automation running on it, I’d suspect the automation. Scrivener itself has no clue about any of that, it’s just saving the file where you put it.

Stylesheet-based Contents

That aside, as to the final point, no it actually uses a different mechanism than what you would get with a ToC in Word. It uses internal document bookmark links, such like you’d use to create a cross-reference. And that actually brings up a good secondary point: if you’re mainly just looking to get something into a word processor, then in my opinion the best route is to insert the ToC after you compile. That’s going to be a better result in just about every way. Our little list copy thing is better for quick proofing print-outs and such.

I’m attaching a tweaked version of the Paperback format for you to take a look at. You should just be able to import it into your project to test it.

styled-paperback-6x9.scrformat (73.5 KB)

Instructions

Here is how the format was created:

  1. Firstly I considered how many levels of heading depth I need. For a part-chapter type book that has no scene titles, that will be two. In the Styles compile format pane, I make sure there are “Heading 1” and “Heading 2” styles set up right.

    • Heading 1: set to match the formatting of the “Part Number Page” layout that we are using by default. TNR 24pt / 1.0 line height / centre-aligned.
    • Heading 2: matching the “Chapter Heading” layout. TNR 18pt / 1.0 line height with 6pt bottom padding // centre-aligned. (Actually the layout itself uses 20pt, but tragically, they forgot to add a way to set precise font sizes in the Styles pane!)
  2. In the Section Layouts pane, Formatting tab:

    1. Set the title for “Part Number Page” to use the “Heading 1” style.

    2. Set the title for “Chapter Heading” to use “Heading 2”.

      While you’re there, go into the Title Options tab and delete the <$rst_scene> token. Unless you intend to number your scenes, you don’t need it, and this avoids the known bug you spotted with links not filtering out that placeholder.

  3. Go ahead and save the modified compile Format and test compile. I went ahead and left a “Contents” page in the front matter, but left it empty. This way I have a convenient place to insert the ToC in the word processor.

So hopefully that helps if you want to modify any other Formats. It’s pretty straight-forward.

2 Likes

I have a question about this too. Some of my heading are just headings (= the section itself is empty). I have noticed, when compiling, that they disappear.
Should I just type the space bar once on the first line so as to make the section exist?
Is there a better solution?

No, I can’t think of a good reason to insert an empty line into a document like that, to force it with a space. If the item is meant to represent a heading in the output, why can it not be assigned to a Section Layout that prints it as a heading? That is considered content. The above statement is about items that would print nothing at all, such as an item with nothing in the text editor set to “As-Is”.

1 Like

I understand. I will change the section layout to “heading.”

As I am using the hierarchical numbering, I suppose that I just need to indicate Scrivener to use the same <$hn> marker as a title prefix as in my “subheading” and “headed section” layouts, right?

I don’t really understand. Shouldn’t I just select “structure-based” for all the chapters, headings, subheadings and sections, actually"?
Then it would detect the hierarchy by itself, no?
In that case, are the sections with no text going to be detected and included?