Table of Contents on PDF - Compile with Links and Bookmarks

So I’ve been using Scrivener for a while now, but this is really the first time I’ve had a need to compile/publish anything I’ve done with it.

I’m trying to get a Table of Contents for a PDF to produce properly. Upon compile I GET a table of contents with the correct page numbers on it, but the table is not linked in any way to the document as a whole…think a table of contents for a printed work. In other words, there is no way to use the table of contents to jump, in the electronic document, to a section of that document. In Compile I’m selecting “Compile For: PDF”

What I want: A PDF Formatted Electronic Document for which:

At Minimum (B Grade): Clicking a TOC Link (Page Number or TOC Title itself) will take me to the heading section of the document. Outstanding (A Grade): The PDF Rendered in such a way that the Sections of the PDF appear as bookmarks within the PDF, such that opening a PDF Reader and opening the “bookmarks” section of the PDF will give me the ability to jump to the various sections. Perfect (A+ Grade): Both: The TOC linked to the sections for jumping and the sections setup as bookmarks in the PDF. (e.g. The Scrivener Manual)

I’m aware I’m probably asking a lot here, but for instance Scrivener’s own manual (PDF Format) has both bookmarks AND the TOC Linked for clicking…so it’s got to be possible somehow.

Is there a section of the manual I’m missing for compile or somewhere else that guides me through creating a proper TOC for the PDF format? The compile section of the manual simply says to select/copy special/as TOC and the basic text seems to assume all works…and while it DOES create a TOC upon Compile that DOES have the correct page numbers in it, there are no links as the manual assumes there should be.

If anyone can point me at a guide or other resource for how to get a properly working TOC (Clickable) functional in a published PDF Format I would be grateful…and if there’s a way to include those sections as bookmarks within the PDF as well that would be phenomenal. Apologies if this has come up before, Google turns up way too many links about TOCs and EBook format and nothing related to PDFs.

(NOTE: A little more playing with this and it appears that at least SOME of the functionality works on Mac only? For instance the “PDF” sub-menu under compile doesn’t even come up under windows while it does show up on Mac. Compiling on mac creates some things but not a fully linked PDF TOC + Bookmarks…any ideas here?)

I do this, but with macOS version of Scrivener (if that makes a difference, but I doubt it) and use Scrivener’s template “General Non-Fiction (LaTeX)” which uses the features of a LaTeX compiler to do exactly what you are asking for. If of interest, in a new document based on that template is a well-written and concise summary of instructions of how to use the template.

See the “Sample PDF” created in a new document based on the template for the result. You can of course modify the compile settings to take further advantage of any LaTeX features you want.

Yes, means digging into LaTeX a tiny bit, but it does do what you are asking for and frankly, has stood the test of time for all my documents delivered to customers. They particularly like the clear formatting, TOC, and especially the index I always put in to the long deliverables.

For sure there are other techniques and tools to achieve as you want, but this is the way I do it. Have done for years.

Of course. Mutter

I just took the non-fiction template and utterly modified it for “guide” / “walkthough” writing…of course there’s a better template with more functionality that I didn’t choose…why wouldn’t there be.

How much “LaTeX” do I need to know to create / compile a document to PDF Format using the LaTeX format template?

1 Like

Impossible to answer as I don’t know your starting point! :wink:

I think not much as by recollection the first time I used this template I created a dummy document with some lorem ipsum and a structure, then just followed the instructions and … it worked. Before that first step I only knew of LaTex as word but also representing impressive and well-earned respect.

Yes, over the years, I did some more reading about LaTeX and then implemented some of the features into the Scrivener compile settings. I never make changes to the LaTeX *.tex file–only in Scrivener compile settings. Want to keep it all automated and not dependent on remembering, after initial “discovery”, much about LaTeX. Tinkering is allowed.

I’m very impressed with the high-quality, concise, and correct instructions for using this template.

Try it. Play with it.

1 Like

So the assumption here is that you’re publishing to .tex format via the LaTeX publishing setup and then using something like MiKTeX or TexLive to change that .tex format file into a PDF?

I have to admit it’s a little more effort than just clicking compile and getting a PDF Document out of it…but I will take a look. I admit if things like an index and TOC are “easy” with this method that does hold water.

Yes, not an “assumption” really, but how it works. I use “texmaker”. There are many others and people have their favorites.

Most of the time, just an extra “two” clicks of the mouse after Scrivener does its thing on buttons in the LaTeX compiler to create the PDF, then to re-create as the TOC links go in after the document is paginated. Trivial extra work compared to the writing to get that far and the manual work to make TOC if not using this method.

I think a key to keeping it simple is when tinkering with LaTeX commands set them in the compile settings (or the boilerplate documents included with the compile) and not rely on using the LaTeX editor.

If there are errors in the compile have to resolve. For me sometimes I forget to resize graphics to fit on the page, and the LaTeX compiler rightly complains.

“easy” in the eyes and experience of the user. For me, “easy”. Still have to mark words that you want in the index. TOC comes from the document structure.

I recommend you simply try it. Read the clear instructions at the top of the Binder for a document created by the template.

I’m sure there are other methods using other tools that work for this and others can chip in. I’m just sharing what I do, using methods provided by Scrivener.

1 Like

Did you check the “Generate PDF Outline” box in the PDF Settings pane of the Compile Format Editor?

Do the ToC items appear to be linked in the Scrivener Editor, and the links fail to pass through to the output document? Or are they not linked at all?

1 Like

@kewms

So the “Generate PDF Outline” box doesn’t appear in Windows, the entire PDF section doesn’t show up on Scrivener for Windows…unless it’s somewhere else. It DOES show up on Mac but not on windows.

The TOC items are linked in Scrivener’s interface after following the instructions for copy as TOC / Paste. Upon compile, however, they are no longer linked…just turn into flat text…so your first statement is exactly the behavior I’m seeing.

Upon doing the compile through Mac it does the second part of what I want…making PDF bookmarks for the various TOC/Breaks in the document, but the TOC still isn’t linked.

@rms Again, thank you very much for your information and support here. I did give the LaTeX template a try…copying my text into it caused it to fail spectacularly…apparently LaTeX thinks I’m using mathematics throughout the document and tries to insert math headers (which I’m most definitely not) and something about missing an end document as well. I should probably start smaller than the 123 pages I’ve got formatted and working through the non-fiction template I setup earlier (except the PDF stuff i’m posting about) and instead just take a subset of that and try to get it functional.

Well, that’s worthy of further discussion here with Scrivener’s gurus being involved as it is their template.

“Missing end document” is usually caused by something wrong further up. If in the LaTeX editor you go up into the document the line it has a problem with will be a clue for you. Googling that error will also help resolve.

Yes, try it with a simple test document first.

In the main Compile screen, under the gear icon, please make sure the “remove all hyperlinks” box is not checked.

In the Transformations pane of the Compile Format editor, make sure that hyperlinks are colored and/or underlined. The possibility exists that they are there, but not formatted as links. Do the same for internal links in the PDF Settings pane.

1 Like

Thanks. Learned something. Learning stuff all the time with an app is what keeps me using the app!

Yes, this simpler than going the LaTeX route, but does require remembering to update the TOC field manually–unless I’m missing something. No big deal.

As I said up top, there are other ways to make a linkable TOC.

I’m sticking with my LaTeX method as it’s all automated and puts out a format/style that I and my clients like without much tinkering by me. But doing this (for me) newly discoverable way will have a place in my bag of tricks!