ToC Depth

My document has three headings Heading 1, (#), Heading 2(##) and Heading 3 (###).
How can I make sure that on generating the ebook the ToC includes all three headings?
(there correspond to Markdown, btw).

Is the first one a Heading 1 style or is it # at the beginning of a paragraph? (Very different things.) Using the latter requires a markdown compile.

Are you using the Pandoc ebook generator for this? If so, the setting you are looking for is in the ToC tab of compile overview (last tab on the right): Contents depth. The default is already to level 3 though, so I suspect you may be doing something different from this?

I’ve duplicated the Scrivener so that one file contains the crosshatches (#) and the other is styled Heading 1, 2 or 3.

What is your workflow in such a case? Scrivener=>Compile to ? =>Pandoc =>ePub?

I started out with a LaTeX file and tried to bring it into Scrivener (importing the .tex file is easy, but then you have to remove all the LaTeX commands). So I tried .tex =>Pandoc=>Markdown and html and Pandoc choked after 1/3rd of the file. I tried to troubleshoot it but couldn’t find the line that blocked the conversion. So Pandoc ultimately could only handle 1/3rd of the file, so I ended up with a file that was 1/3rd Markdown and 2/3rds LaTeX. (The Pandoc error was “unexpected end of document”.)

Not trusting Pandoc, I was hoping to compile directly from Scrivener to ePub.

Not trusting Pandoc, I was hoping to compile directly from Scrivener to ePub.

Well, I’d say for going from Markdown to ePub, it’s a fairly straightforward process, as opposed to LaTeX → anything. I wouldn’t shade my opinion of Pandoc based upon what is often a problematic conversion in general, and from one particular document that tripped it up, at that. Its ePub output is quite good, and extremely clean, which will make formatting it much easier.

As for “directly from Scrivener to ePub” with Markdown, there isn’t really a super solid way of doing that. Yes, it does have an MMD → RTF checkbox in the compiler, but it’s fairly simplistic, and the quality of the ePub HTML will be “dirtier” by default (and likely overall, even with considerable time spend researching and tweaking settings). Personally I’d rather get a super clean HTML structure to start with, and spend my time working on the CSS and design aspects exclusively, rather than dividing that between wrangling messy word processor style HTML conversion and the CSS.

That aside, to move back to the original question: with Scrivener native you’re going to have to break things up further and use binder titles more exclusively, rather than what it sounds like you’ve been doing so far, with styled text in the editor. There is no “Heading 3” that will end up in the ToC unless you actually have three levels of indent in your Draft folder.

So on this matter as well, there is more flexibility (and I would say, simplicity) here with the Markdown approach, since all that matters is the hashmarks in front of lines, however they got to be that way. Pandoc will be chopping up the book by hierarchical headings alone, and generating a ToC from them, to whatever depth you specify. That means you can have some headings generated from the Draft outline depth, and some from text typed in as hashes, and others from “Heading 3” styled text—don’t matter! One cohesive approach or a mess of different techniques both work equally well.

At any rate, for something this big and potentially influential, it makes sense to me to run some tests with some limited sample data, before making a decision and spending weeks going down a path. There will be challenges either way, but if you’re starting with Markdown text, to my mind it makes very little sense to push for using Scrivener’s ePub output from that. At the very least, make sure all of the Markdown elements you require actually work at all (block quotes and footnotes for example get completely lost—like I said, it’s a simplistic conversion).

Thank you for your thoughtful reply.
What is the compile option Pandoc-> ePub? What intermediate file does this create?
For Markdown I assume I would use compile=>Multimarkdown and then run Pandoc separately.

What is the compile option Pandoc-> ePub? What intermediate file does this create?

There are no intermediate files, or additional things you have to do. Just click on Compile for, and toward the very bottom of the list you should find a Pandoc → ePub entry. Explore the tabs to the right, some of which are unique to this format. We’ve built a little UI on top of this process for you, and automate all routine aspects of ePub creation to the point that, styling text aside, it should be no more of a learning process than using Scrivener’s native exporter.

I’d also recommend double-clicking on the “Basic Pandoc” compile Format in the left sidebar, and checking out the Pandoc Options pane. You will likely want to select ePub 3.0 if it isn’t already, and here is where you will be inserting the CSS you produce while designing the book.

As for designing the book itself, I prefer Sigil for that, as you get real-time results. You get a look you like, paste your CSS into this here in Scrivener, and once you get things refined, you shouldn’t have to do much other than click the Compile button.

You should be able to get a decent test done pretty quickly, by maybe dropping the parts of the draft folder out that aren’t cleaned of LaTeX code yet.

Does Scrivener call Pandoc? I compiled to Pandoc and the result was very, very good–better than expected, with a near-perfect ToC (I found some typos that are my fault).

Yes, if you select “Pandoc → ePub” as your compile method, then Scrivener is running Pandoc for you, as well as generating and gathering all of the materials you would ordinarily have to do by hand, like building an XML file for the ebook metadata.

2 posts were split to a new topic: Format indented list items as italic text

A post was split to a new topic: Creating lists of adjacent lines in Markdown

Uh yeah, I’d say since we started with “how to show level 3 in the ToC” and moved on to "How to format indented list items as italic, and are now onto “How to create a list of adjacent lines in Markdown”, this is maybe turning into a tech support buffet here that doesn’t really help people find answers to questions easily. :slight_smile:

1 Like

Sorry, I’ll start new threads then.

Oh no worries! I’ve already forked things off.