Wednesday, February 27, 2013

How to add a Table of Contents for Amazon using Word, html and Mobipocket


Recently, Amazon began insisting on a Table of Contents for their books.  They don't want just any table of contents, they want one that registers with the Kindle devices.

It's taken me two years to figure out how to do this, largely because I figured out a different system that worked well enough.

Note:  This tutorial is on how to make a working Table of Contents starting with Microsoft Word.  There are other ways of making it if you use other programs.  Also, if you are an expert at html, then I'd recommend using Sigil or some other way of editing your html document.  You'll probably get a much cleaner file.

However, if you're a self-taught self publisher like me who doesn't wish to break their brain, I'm making this about as simple as possible. :)


This is not how you do it with Smashwords.  They primarily take Word documents and they don't want Microsoft Word's pregenerated Table of Contents.  If you want to make one for them, I recommend using this tutorial:

Table of Contents in Microsoft Word.

Note:  I'm using Word 2010.

Okay, so the first thing you need to learn about is heading styles in Microsoft Word.  You need these to get the rest of it to work.  I'm going to show you how to add heading styles to your Title and Chapters.  If you already know how to do this and have it in your file, you can skip to the next section. :)

1.  Up at the top of your document, you'll see heading styles. (Image 1)  You'll want to modify your heading to your preferences.  I modify Heading Style 1 for the Title and Heading Style 2 for the Chapters.  If you don't have chapters, you can still do this for the beginning or any section breaks.  Usually, you need at least two points of reference.  I use "Beginning" and "Author Notes" if I don't have chapters as in this story.  (If you don't have author notes, I recommend adding them.  Tell the readers who you are and what other books you have for sale)

Image 1

 2.  Okay, so I have "Beginning" and "Author Notes" under Heading 2 style.  Now lets add the Table of contents.  If you go to your "References" tab, there's a section to create a Table of Contents.  Click on that and go to "Insert Table of Contents" near the bottom.  (Image 2)

Image 2

3.  In this next image, there's a lot going on.  At the bottom left, you'll see "Show levels:".  I only use 2 levels.  If you have a reason to use more do so, otherwise, switch it to 2.  We'll come back here in a minute.  For now, click on "Modify".  (Image 3)

Image 3

4.  This opens up the different styles for your Table of Contents.  You can check them each out, or you can click on "Modify" in the style box to modify the style of your selection.  In this one, you can center your table of contents, change the font, make it bold or many other things.  If you click "Format" at the bottom left corner, you can change the paragraph stylings, such as indentation and spacing before and after lines.  (Image 4)

Image 4

5.  Next, you want to click on "Options" (Image 3).  This will bring up "Table of Contents Options."  Here, I get rid of the "1" in Heading 1.  You don't want the Title in your table of Contents . . . unless you do, in which case you can leave it.

Image 5

6.  Okay, once you have everything set to the way you want it, click okay and go back to the Table of Contents (Image 3) and uncheck "Show page numbers".  Ebooks don't have page numbers, so you don't want them in there.  You do, however, want to make certain that the box on the right "Use hyperlinks instead of page numbers" is checked.  Click "OK" and you will have this:  (Image 6)

Image 6

7.  You'll find that if you hover over "Beginning" or "Author's Notes", you'll be able to ctrl-click to each section.  If you have chapters instead of "Beginning", they'll all be there.  On the line above that, I manually type in "Table of Contents".

8.  Next, you want to save your document as "Web Page Filtered".  (Image 7)

Image 7


9.  Now you want to go to the html version of your document and open it with notepad to edit it.  You'll get a page like this:  (Image 8)

Image 8

10.  The thing you want to add here is  <a name="toc"></a>  (You can just copy and paste that) before the line with Table of contents.  (Image 9).  You can do a ctrl-f to find the words.  What this does, is it tells the next program, and Amazon that this is where the Table of Contents is.  After you've done that, you want to save the file.

Image 9


Mobipocket  is the tool I use to convert the html file into an ebook that I can upload to Amazon.

11.  Open up Mobipocket and you'll get a screen that looks like this (Image 10)  Go to the section that says "Import from Existing file".  Choose "HTML document".  That will lead you to a page where you add your document.  In the section that says "Choose your file" click "Browse" and find the html version of your book. Once you've selected it, click "Import". 

Image 10

12.  Next you want to add a cover image.  Click on "Cover Image" and add the file (Image 11)  Then update. 

Image 11

13.  Next, you want to click on "Guide".  (Image 12)  Add a "New Guide Item".  Under "Type", click the drop down menu and select "toc".  Then, next to Filename, is another Browse button.  Click on that and find the document folder that Mobipocket has created.  Mine is under "Documents", "My Publications", "Phairyphant".  Then you go in there and select the new html version of your book that Mobipocket created.

Image 12

14.  Now you edit the section with the file.  Under "Filename" you want to go to the end of the filename and add #toc behind "html".  Then click "Update".   (Image 13)

Image 13
15.  Now you go to the little gears at the top where it says "Build".  Click on that and it'll put all of it together.  You'll have the option of "Open folder containing book".  You'll want to make sure that's checked.  There, you'll find your book.  (Image 14)

Image 14

16.  Next, you'll want to check it in the Kindle Previewer.  (Image 15)  At the top, click on "Go To".  Then you click on "Table of Contents".  If it takes you to the Table of Contents, then you've done it all right. :)  If it gives you an error message, then something went wrong along the way.

Image 15

17.  Upload that file to Amazon and hopefully sell lots of books. :)

I hope this helps.  If you have any questions, you can leave them in a comment and I'll do my best to answer.

All my best,

John H. Carroll


KM Telford said...

Awesome tutorial :)

The only thing I'd add to this is that if you're running IE9 you might want to uninstall this first, as this can cause JavaScript errors when adding guide items to the html file in MobiPocket.

I'd heard this problem had been fixed, but I just tested it and I still get the JavaScript error when I have IE9 installed. (Not that it matters much to me, I never use IE9 anyway so it's no big deal for me to lose it).

Also, Win7 doesn't make it simple to find and uninstall IE9. It's not listed in the uninstall programs list. You have to go look for it in the 'installed updates' list and remove it from there (which doesn't actually remove it, but reverts back to IE8).

Why can't anything in life be simple? lol

John H. Carroll said...

Thank you, KM. :)

I think my solution to that problem will be to not run IE9. :D Hee hee.