Contents of the highest Calibre

Calibre’s a great tool for testing and converting your book in different formats, but recently I encountered some trouble with sections of my book not showing up in the contents page. In this short guide I’ll tell you how to get around the problems I encountered, and offer a little insight on how Calibre works when converting your book.

Pre-requisites:

You can download Calibre from here. I cover how to create a contents page in Microsoft Word 2007 in this post. Couple of things to highlight:

1) Use “Heading 1” for all chapter headers or significant sections: Like your preface, acknowledgements, etc. When converting to the “Web-Page, Filtered” format Amazon accepts, any text specified as “Heading 1” is interpreted as the HTML tag <h1> which is what we’ll be looking for in Calibre.

Heading One

2) Use the Document Map to check your book’s structure: You can get to this by clicking on the “View” tab in Microsoft Word, and checking “Document Map” in the “Show/Hide” Section toward the middle. Anything “Heading 1” appears as main categories, “Heading 2” is indented under “Heading 1”, “Heading 3” is indented under “Heading 2”, and so on. This is your book’s outline, and can also be a decent way to detect stray formatting, or fix chapter headings that don’t show up. (I had a whole section of the text that was accidently being shown as a header which this map helped me to catch).

DocumentMap

 

3) Save your book as “Web Page, Filtered”

Creating Your Contents Page

1) Import your book: You can import a filtered web page by dragging and dropping the HTML file (.htm) into the Calibre window. Calibre will automatically detect any pictures as long as they are in the same folder as the .htm file.

2) Edit Metadata: Upload a cover, show publishing information, correct your authorship, etc.

EditMetadata

 

3) Click the “Convert” Button: Before clicking OK, there’s a couple of things we need to modify.

4) Click on the “Table Of Contents” Icon to the left: Two numbers are important to consider, the chapter threshold (your total number of chapters + other significant sections), and the total number of links to add to the contents page. If you want to include sub-categories you’ll want to set the links total high enough. For our purposes we’re just interested in a simple chapters only contents page. My book has six chapters, preface, acknowledgements, references, gallery, software, library and eReading Tips so I set the “Chapter Threshold” at 13.

TOC

 

5) Click on “Structure Detection”: Calibre creates a second contents page at the end of your book. This is what is used by both the “Table of Contents” link on eInk Readers, and also in the Kindle App on Android. While it is an extra set of links, it is more universally compatible across devices, but it doesn’t just copy the contents page you made in Word. It actually scans your document to determine what should and should not be in the contents page. Because of this we need to make sure it’s looking for the right things. By default it’s looking for a heading that says “Chapter”, and that doesn’t quite comply with what Amazon wants us to do.

IniStructure

 

6) Click the wand next to “Chapter Detection”: You’ll see a drop down list of options like the one below. For the moment all you need to do is select “h1” under “Match HTML tags with Tag Name” and click OK. This will create an XPath expression that will instruct Calibre how to scan your document.

Detect Chapters

 

For the programmers: As far as I can tell, Calibre treats eBook conversion a lot like applying XSL stylesheets, including support for XSL’s regular expression language XPath. My assumption is if you know how to write fully structured XPath expressions you can write more sophisticated chapter detection.

7) Clear the box under “Insert Page Breaks Before”: Calibre attempts to detect where it should insert additional page breaks. If you’ve been doing the job of formatting your book correctly, you don’t want Calibre to do this as it will only add additional formatting that may change the behavior of your book.

PageBreak

 

8) Click “OK” To Convert your Book: Once generation is complete you can click on the “MOBI” or “EPUB” format on your book to bring it up in Calibre’s eBook viewer. Calibre’s viewer isn’t particularly good for reading books, but if you click on the three lined button on the left you can see the Table of Contents Calibre generated to see if it’s correct. You can also test on your eReader.

Any questions\comments? Have a good weekend!

1 Comment

Filed under Books + Publishing, Internal Debate 42, Trube On Tech, Writing

One response to “Contents of the highest Calibre

  1. Jeff Peters

    Thanks! Bookmarked for whenever I attempt my first ebook.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s