Here is the Calibre window, with the icons at the top positioned nicely so you progress logically along from left to right. (After the first time you will usually be updating a book. You highlight the book in the list and click the Remove books icon at the top right. You may need to widen the window to allow the icon to show.)
Click on the down arrow to the right of the red Add books icon at the top left, and select “Add books from a single directory”. Navigate to the html file of the book concerned and select it (note the image files alongside it in the same folder in my example).
Next, click the down arrow to the right of the blue Edit metadata icon at the top left, and select “Edit metatdata individually”.
Almost everything is either already in place or you don’t need it, except for the author field at the top left (type in the first time or select subsequently). Then click the blue right arrow to the right of that field.
Click the Browse button just above and to the left of the centre of the screen to identify the cover. It should then show in the left sub-window, mercifully obliterating the unfortunately perspectived default book :-S; click OK at bottom right.
Click the down arrow to the right of the brown Convert books icon at the top left, and select “Convert individually”.
(Note: my cover in the picture is superimposed by a label showing its size, which is too small for Amazon covers! The real book had a bigger cover, but I wonder if Amazon might accept that smaller size anyway! Amazon though might reject the Reduced book for another reason: if you try to publish what they, and probably you, see as a “test” book, they’ll fix you with a stern smile and slowly shake their head 🙂 .)
Click Structure Detection in the middle of the left hand panel.
Go to the: “Detect chapters at: (XPath expression):” field near the top of the screen and click the down arrow to its right to show the options.
If you want Calibre to count just <h1> headings as announcing separate chapters, select this (or edit a similar one):
//*[((name()=’h1′) and re:test(., ‘\s*((chapter|book|section|part)\s+)|((prolog|prologue|epilogue)(\s+|$))’, ‘i’)) or @class = ‘chapter’]
(It looks like you could announce it specifically as ‘chapter’, but I didn’t.)
If for example you wanted all the first three heading levels to be treated as chapters, you’d have this:
//*[((name()=’h1′ or name()=’h2′ or name()=’h3′) and re:test(., ‘\s*((chapter|book|section|part)\s+)|((prolog|prologue|epilogue)(\s+|$))’, ‘i’)) or @class = ‘chapter’]
The only other place on that screen for me was the “Insert page breaks before: (XPath expression):” in the middle of the window.
Because I didn’t find out till late how to insert page breaks, I contrived to do it by using dummy <h2> headings, which only contained a blank space but threw a page, so here I selected or entered:
//*[name()=’h1′ or name()=’h2′]
You can see what other options are available.
[Check out this Mobileread discussion for more on how to force page breaks.]
DON’T CLICK OK YET! 🙂
Now select the next icon down on the left: “Table of contents”.
At the top, tick/check “Force use of auto-generated Table of Contents”, if you want one. (For some reason, this is only available if you are producing a .mobi file. Calibre can produce many other file types, but presumably the systems that use those other types can’t make use of a table of contents.)
The middle three fields: “Level1/2/3 TOC (XPath expression):” let you select the number of nested indented levels that appear in your table of contents. Because I was being peculiar with the heading levels to force page breaks, I only selected heading levels 1 and 3 here: //h:h1 , and //h:h3 .
DON’T CLICK OK YET! 🙂
Now click “MOBI Output” just ABOVE the red beetle.
The only box I used to tick on this page was “Put generated Table of Contents at start of book instead of end”.
However, when I ticked “Do not convert images to jpg”, it reduced the size of the book from just under 10MB to 5.5MB. Amazon accepted the book in the new format.
[Notice, you select the output file type at the top right of this window, but the default is MOBI. I’m using version 0.8.52, which has one or two extra output file types more than some later versions (see below), including zip, as shown at the bottom of the list in the illustration above. If you have access, for a bit of edutainment select that format and normal parameters on the creation run, use the ordinary output zip file produced (not the “.original.zip”), duplicate and unzip e.g. with Stuffit, and you can get at the html file after Calibre has digested it and before it inserts it into other formats. It allows you to extract the html for the table of contents Calibre produced. It’s interesting to see how you could have written the whole html initially, but it’s hard to extract any other way. That html can be fed right back in to the start of the process and it reduplicates at least the visual ebook, even though some of the exotic characters are codified differently.]
NOW YOU CAN CLICK OK at the bottom right 🙂 .
The run takes a minute for my full book of 100k words and 70-odd images. The output file for that is just under 10MB, or 5.5MB. For the Reduced version used here, it’s all a fraction of that. Calibre puts all the output in a folder called “Calibre Library” in your home directory.
A rather good tutorial for Windows users on producing Kindle ebooks through Calibre, is by Amalthia:
Here, Kovid, author of Calibre, directs us to its video tutorial:
At the foot of that webpage are links to other Book Creation Tutorials, featuring those by HarryT.