How Format MOBI Table-of-Contents?


Hope you can help…I’m beyond frustrated and very stumped. :cry:

Don’t know how to start or what to do.

Just finished a non-fiction manuscript intended for Amazon Kindle (.mobi).

While the formatting of the text is fine…the Table of Contents is one, long, UN-INDENTED hash which spans eight pages…without any sense of structure, chapters or parts.

Because the physical layout of a Table of Contents (specifically indenting) is such an important visual cue regarding the structure and organization of a non-fiction work…getting this right is vitally important.

Your suggestions? How can a .mobi file be generated from Scrivener which properly reflects the structure of the work as expressed in the “Outliner” (Navigation?) panel?

Thank you.

It’s difficult to say what the problem is without more information, but these are the basic steps you need for an indented Kindle contents page:

  1. You will need a text document set up as your table of contents with Scrivener links for the contents, all indented as you wish (using first line indents, and not tabs, seeing as tabs aren’t supported in HTML or Kindle files).

  2. Ensure you have “Compile As-Is” ticked for the contents document (or that the indented block has “Preserve Formatting” applied) and that it appears on its own page (“Page Break Before” is ticked").

  3. Ensure the name of the contents document is entered in the “Layout” pane of Compile.

That should be all you need. I just tested it myself and it came out fine.

KB (et al),

Thanks for the reply; regrets, I do not understand Step 1.

By “…need a text document…” do you mean I have to create :open_mouth: a Scrivener file?

By “…with Scrivener links…” do you mean I have to manually edit (then re-edit everytime a change is made to the file) the links? There are over 200 entries :exclamation: that I want in my TOC and, from time-to-time, I change them (e.g., polish a file’s Title; re-organize sequence of items within a Chapter or Part).

Hoping I’ve mis-understood, because generating an eBook (.mobi, and/or .epub) compatible TOC seems like it should be an essential part of Scrivener.

The screenshot illustrates the hash a reader sees in the currently generated TOC.

Hope you can help!


The chapter on creating a ToC in the user manual (starting on page 337) covers some of the tools you can use to make this job easy. In summary:

  • Yes, you need to create a new blank document in your Draft, wherever you want the actual ToC to appear in the eBook, calling it “Contents” in the Binder. This is just a normal text item in the outline.
  • To easiest way to generate a complete list of hyperlinked titles is to select the items in the Binder that you wish to have included in the ToC and use the [b]Edit/Copy Special/Copy Documents as Scrivener Links[/b] menu command. Now just paste that list into the blank file you’ve created.

By default, when Scrivener encounters a file called “Contents” in the draft output, it will disable the automatic HTML ToC generator and use whatever you’ve supplied instead.[size=80][1][/size] This is thus useful for custom formatting as well as culled lists that do not strictly include every actual section in the e-book.

So yes, if you change your book’s structure in such a way that the ToC will require revision, you can just repeat the select-and-copy procedure, but naturally you’ll probably want to reserve that step for closing in on the final production. In my opinion it would be best to rely upon the automatically generated ToC while working with proofs for this reason, and just not worry about the final ToC look & feel until the book structure has stabilised.

Automatically indented: I haven’t actually tested this, in theory it should be fine, but if you use the Copy Documents as ToC menu command instead, you’ll note that when you paste that in it will be pre-indented by outline structure. The only problem with this output is that it includes page numbers, which you would want to discard for an e-book. A simple solution would be to use [b]Cmd-F[/b] to activate the Find panel, hold down the Option key and press Tab in the “Find” field, to insert a tab, then type in “<$p>”. Now just Replace All with nothing to erase these numbering tokens. You should be left with an indented list of hyperlinks suitable for e-books. Be sure to tick the “Compile As-Is” checkbox for this document, if you use the compiler’s ability to reformat body text.


  1. The actual name can be changed if you also adjust the associated name that Scrivener looks for, in the Layout compile pane.


Thank you for offering a suggestion.

Regrets; NO JOY.

This is driving me crazy. :angry:

How do other eBook authors use Scrivener to create structured TOCs?

In the image below, the careful structure of the book is visible on the left.
In the center: the results of the COPY SPECIAL, paste and replace Tab <$p>. Looked promising at this point.
On the right: NO JOY! Another un-understandable vertical hash of un-indented meaningless, frustration and despair.

KEITH: PLEASE add functionality to Scrivener which will automatically generate an eBook (.mobi or .epub) TOC AND preserve the (indented) structure as it appears in Scrivener’s binder. :exclamation:

AMBERV: Any other suggestions? Is there a way to crack open a .mobi or .epub and edit the source HTML or CSS?

Because I’m way, way, way up a creek at this point–I hope someone can solve this problem.


Did you set the “Compile As-Is” flag for the Contents text file, using the Inspector? Indents should be roughly preserved if you do so (I have observed different e-readers handle indenting in various fashions, but you should be getting the basic idea across even if the precise measurements do not).

Absolutely, that is often the best way to handle fine-tuning as Scrivener can only really address broad assumptions with its e-book compilation process (to avoid becoming as complicated as a full-blown HTML based design program). I would recommend Sigil for nearly all such customisations. Sigil can operate on the .epub format natively, so there is no need to recompile or rebuild the file after you’ve edited it (though for Mobi you will need to open the epub file in Kindle Previewer to generate a Mobi document easily).

Sigil has a WYSIWYG editing interface as well as access to the underlying HTML/CSS. It in fact allows code level access to the entire ePub structure.

I would verify that As-Is is toggled on first, to avoid having to take that step after compiling, if you can.


Thanks again.

Compile As-is was checked (TRUE, or ON) for the compile with the images in the prior post.



Digging around on Google, I discovered “mobi_unpack” (a Python script). Using mobi_unpack, I unpacked the latest Scrivener generated mobi file and find that Scrivener seems to generate a TOC with HTML/CSS Class labels which could be used to style an indented TOC.


Is there a way to edit the CSS (e.g., style0002) and then REPACK the MOBI with the properly styled TOC?


  1. I used Scrivener to generate an EPUB…except that much of the styling that works so well in a MOBI gen (especially image handling and Compile-Formatting) didn’t make it into the EPUB.

  2. Later tonight, when I’m back at my workstation, I will try using Kindle Previewer to generate an EPUB then open it with Sigil, as you suggest.

Your assistance is valued & appreciated by this panicked author who is staring a deadline in the face.

Many thanks,

I forgot of one other tool that will be of use to you, and that is a power option in the KindleGen compile pane that will export the source files as well as the .mobi file. This will output a folder with XHTML and CSS files (as well as some XML glue files), and in short everything you would need to (a) manually edit the e-book content and style and (b) to reconstruct the folder of source files into a .mobi document. To do so, once you are finished editing the CSS in the source folder, use Kindle Previewer to select the OPF file in the source folder.

I’m not sure what mobi_unpack does, if it produces a re-constructable output, but if it includes an OPF file as well you could likely do the same thing, but why mess with extraction if you can get the source files up front from Scrivener?

Point of clarification: the workflow at that point would be to compile to ePub, edit in Sigil, and then use Kindle Previewer (or KindleGen if you are familiar with using command-line utilities, I just suggest Previewer as that has GUI and is straightforward) to open the ePub file that was fine-tuned in Sigil. Opening an ePub will convert and produce a Mobi file in the same folder. So, if ePub is damaging formatting in other areas that concern you, this particular workflow may not benefit you.

P.S. I’ve been doing some tests, confirming by theory with the Copy Documents as ToC method, and so far I have had success with the .mobi output, without any tweaking, using a “Contents” document set to As-Is. The native indents in that file are reproduced in Kindle Previewer across all device platforms. So in theory we should be able to get this to work.

P.P.S. If you’d like, we could take a look at your project for you and either recommend a course or send you a fix. If that’s okay with you, send it to our support e-mail address, ATTN Ioa with this thread URL so that whoever gets it can forward it to me post haste.

Dear AmberV,

Thank you very much for offering to help; greatly valued & much appreciated.

The screenshot below is from Kindle Reader for iPad, and shows the left-justified TOC.

Just sent an EMail to you via Scrivener’s support email address; thanks!