Skip to content


Formatting eBooks

So. Formatting a document for ePublication. First and foremost, this stuff is EASY. It can take a bit of time, but it’s well within your grasp. Please, don’t pay anyone else to do it for you unless you’ve got money to throw around and really can’t be bothered.

The most useful tool in the eBook publishing fight is Calibre. It’s free, so go get it now :)
http://calibre-ebook.com/

Calibre will convert stuff for you to just about any format. Which is nice. To get your docs ready for it, prepare a Word file and save it as HTML. If you’re not using Word, the info below still applies, but I can’t vouch for how clean the html output will be from your word processor of choice.

Anway, specifically, prepare your book in one single Word document as follows:

  • Use fonts sized to 10, 12, 14 and 18 points only. 10pts equals the kindle’s default text size.
  • Left-align, with justification and hyphenation turned off.
  • In Tools / Options / General / Web Options / Encoding, set the encoding to UTF-8.
  • Strip all tabs, double spaces and multiple lines of blank space from the document. This really is important. Quick way: in the edit/replace pop-up, replace ^t with nothing, ^p^p with ^p, and two space characters with one space character. Alright, I admit it, the double spaces won’t screw the formatting up, but nowadays they make you look clueless.
  • If for some reason you’ve put in manual breaks at the end of each line of the page, I’m afraid you’re mad, and you definitely need to take them out again. Paragraph breaks at the end of each paragraph. Nothing else.
  • Set the line spacing to single and the paragraph before/after extra spacing to zero.
  • Put in CTRL-ENTER hard page breaks at the end of a chapter (as opposed to trusting it to a style definition).
  • Use word styles to define yourself chapter headings, indented body text, and all that other good book-style stuff. If you want blank lines before or after certain elements — or want stuff centered — now is the time to do it. For example, I have a style for those # # # spacer lines that has a 12pt gap both before and after the paragraph.
  • Make a note of the style name you use for the chapter headings. Don’t use it for anything else, and make sure no other style is called something that includes that name as a sub-string. So if you call it ‘chapter’, don’t have anything else called, say, ‘achapter’ or ‘chapter-small’, or what have you.
  • If you choose to not indent the first line of the paragraph after a break — and well done for choosing wisely — pick a separate style for first paras and put it in manually. Yes, it’s a pain. Sorry. You’ll need to remember the style name you picked and, crazily, actually give it a first line indent of, say, half an inch. This is the opposite of what you want, but it is because Word is stupid, and we’ll need to tweak it later.
  • If you want to know how it’ll look on a Kindle, change the text font to Trebuchet 10pt, which is a close comparison. Different Kindles have different screen sizes, so don’t worry too much about the size of a page as such. So long as you don’t have any 3″+ single words, you should be fine.
  • If you want people to see your title/author/dedication page as a default, put the first line — and only the first line — of that page in your chapter heading style.

OK, that’s all the formatting you need to do. Save it by selecting:
Save As / Web Page, Filtered (htm, html)

This option gets rid of most of the vile cruft Word tends to spatter HTML files with. It’ll give you the usual “SAVE YOUR FILE LIKE THIS AND CROCODILES WILL EAT YOU!” warning, but just go ahead.

For your next trick, if you do want your first paragraphs without indentation, we have to do some very simple HTML editing. You need a decent text editor though. Notepad++ is wonderful, and free. Go get it here: http://notepad-plus-plus.org/

Open up the .htm file Word exported, using Notepad++. In the <style> section at the top of the book, you’ll find <font definitions> — oh, those wretched font definitions — and then <style definitions>. Find the style you used for those first paragraphs. It will be a line starting p.THISISTHENAMEIUSEDFORMYSTYLE, li.THIS… &c

Inside the definitions for that style, beneath the curly bracket, there will be a line saying:

text-indent:_SOMETHING_;

where something could be, say, 28.3645pt or 0.5in, or what have you. Change that to 0pt. Zero points, if your browser makes that looks like a little o. Y’see, Word feels that a 0pt indent is the default, and thus doesn’t need saying; but plenty of e-Readers think that indented text is the default, and that 0pt does need saying.

Anyhow, don’t worry, that’s all the HTML editing you should need. Save the file.

Now you can import it into Calibre. Open up Calibre, Add Book, and select the .htm file. It’ll add it to your library, and say that it’s there as a ZIP, and probably call it something like New Book by Unknown.

Select the book, and click Edit Metadata. Put in the correct title and author, select browse in the area next to the blank cover to pick a cover image — for the Kindle, you want it to be 600×800 — and also put in any other info that you want: publisher, date, genre tags, &c &c. Then click OK.

Finally, to Kindle it, select the book and click Convert Books. In the top right corner, select the output format MOBI. You have plenty of other options for other eBook readers too, should you want.

You should have already sorted the Metadata and any cover that you want, and most of Calibre’s default settings are fine, so there’s not too much to do. So go to the table of contents tab. Make sure the “Number of Links to add to table of contents” value is at least one higher than your number of chapters.

Then click on the sparkly wand icon to the right of the blank line that reads Level 1 TOC (XPath expression). In the ‘having the attribute’ box, put “class” (without the quotes); In the ‘with value’ box, put the name of your chapter font. Then click OK at the bottom, and Calibre will create you a .mobi file.

If you have a Kindle yourself, Calibre can transfer the book to it for you, or you can just open up the Kindle in Windows Explorer and drop the file in the ‘documents’ folder. You’ll be able to use ‘go to’ to move to the Table of Contents — and from that through the chapters — or to the cover, or whatever. The book will open by default at the first of the entries in the Table of Contents (which is placed at the back, by the way). So, if you did put the first line of your title page in the Chapter style, it’ll open there. If you didn’t, it’ll open straight into the first chapter.

And that really is all there is to it. Easy.

One last thing to note is that if you have your own table of contents already built (in Word, say), I have no idea how to get the Kindle to recognise it. It is theoretically possible, using a ‘toc’ tag, and the web is full of ‘useful’ solutions to the problem, but I spent several days trying them exhaustively, and none of them were any use whatsoever. The only thing I found that worked was having Calibre auto-generate the TOC. So cut your losses, and let Calibre do it.

If you really insist on a self-made TOC, I gather it _does_ work using the TOC as a separate file, and creating the .mobi using MobiPocket Creator (also free, from http://www.mobipocket.com/en/downloadsoft/productdetailscreator.asp) but I am completely unable to help you with any of that!

Red Phone Box, a darkly magical story cycle written by myself, Warren Ellis and twenty-six other writers, and edited by the sublime Salomé Jones, is out now. I think you'll like it.

Posted in epub.


7 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Shaun says

    Thank for this. Lots of great info here. I’m having trouble generating a linked TOC when converting .htm to MOBI on Calibre. The TOC (generated in Word using styles) appears in the MOBI ebook, but I can’t figure our how to make the items in the TOC into links to the chapters in the MOBI ebooks. Are you able to advise?

    • Ghostwoods says

      Shaun, I feel your pain. I spent three days scouring the Internet for fixes to this problem, chasing down ghosts and shadows. I tried about thirty different things.

      None of it worked.

      Occasionally someone would post saying that something they’d tried had worked, but when I did the same thing, it failed.

      My advice — which I was very aggravated to have to take, myself — is to forget your nice, shiny, Word-generated TOC. Delete the TOC text (don’t worry about the tags at chapter starts) and let Calibre auto-generate it for you, as I describe above. Sorry.

  2. Shaun says

    I’ve tried to follow the instructions above for letting calibre generate the TOC, but I just don’t seem to be able to get it to work with those instructions. I don’t know what I am doing wrong. I have tried it with completely un-formatted text. I’ve tried putting hard page breaks before each chapter, and without. I have tried it with the chapter heads in “h1″ style, and without — both with and without hard page breaks. Nothing works. Calibre won’t generate the TOC.

    The only method I have had any “success” with so far is to set the chapter headings in “h1″ and then change Level 1 TOC (XPath expression) to “h1″. That’s it. I also leave the box “Force use of auto-generated Table of Contents” checked, which is the default setting. (I tried it unchecked, and got the same results.)

    The results: I get a linked TOC in the MOBI document, but it appears at the bottom of the document, rather than the top. What am I missing? Is there a place to indicate where you want the TOC to appear in the ebook?

    Thanks again for your help.

    • Ghostwoods says

      I’m no Calibre expert, I’m afraid. Not sure why the stuff that works for me wouldn’t work for you… But as far as the placing of the Table of Contents, I believe that no, Calibre doesn’t give you any choice, it just puts it at the back.

      • Shaun says

        So, using your method, where does the TOC appear, at the end of the book?

  3. trebots says

    Calibre seemed pretty primitive to me – eg doesn’t do tables. I get the impression not much development is taking place. I tried out Amazon’s Kindlegen, which claims to be multidevice, but didn’t get very far. This is only going to get better ;-)

    • trebots says

      What an absurd comment, he realises: if the HTML’s OK, so are the table.s