E-book Formatting

Let’s talk about the formats themselves. In the e-book world, there are two major formats: Kindle and epub. Kindle e-books are often signified by a “.mobi” file extension. The epub form is signified, as you might guess, by the “.epub” file extension. Some experts say that epub has pulled ahead of Kindle in terms of its flexibility. I don’t want to get into this discussion, but from my experience, having formatted Rebecca Hamilton’s Forever Girl, I can say, in general, that epub readers seem to be better behaved than their Kindle counterparts. Whether this is the result of the epub format or just the device, who knows.

There are a number of programs which convert a word-processor document to either Kindle or epub format. For instance, on my Macbook, I have Apple’s Pages and Keith Blount’s wonderful Scrivener, both of which will generate e-book files. At Immortal Ink Publishing, however, we need to have tighter control. We need to assure that a book will display appropriately on the Kindle, Barnes & Noble’s Nook, and on Apple’s iPad (also, not everyone has a dedicate e-reader; they’ll be viewing our books on a number of devices from a PC to an iPhone). Our decision involves formatting the e-book basically by hand.

How does one go about doing so? Both the Kindle and epub formats are based on the HTML markup language. It would not be inaccurate to say that e-books utilize a stripped-down version of HTML. Not all tags are supported. Not all CSS (cascading style sheet) directives are supported. But I’m not going to get into the deep technical nuances of e-books.

Here is the basic process for converting a word-processing document to an e-book:

  1. Place codes in your DOC or RTF file to represent special formatting. For Rebecca’s book, we were concerned about italics only. You could very well, however, have a book that includes bold, subscript, superscript, etc.
  2. copy and paste your document into a text editor
  3. Apply special HTML formatting to your text editor. This includes paragraph tags, chapter headings, etc.
  4. Place the results into a special HTML document
  5. Add CSS directives
  6. Use the Calibre software to turn your HTML file into an epub and Kindle file

Thankfully, you don’t have to reinvent the wheel. Guido Henkel has been kind enough to provide us with some guidelines in his “Take pride in your eBook formatting” series. I have to warn non-techies out there that these articles are in-depth and bring with them a steep learning curve, but if you take your time and read the articles carefully, you should be able to professionally format an e-book. I won’t go into the steps involved, as you can read the articles yourself—moreover, I’ve kind of outlined them above.

I’ve developed what I think is a pretty solid method for e-book formatting, thanks to Guido’s awesome articles. I have a couple of departures from his suggestions, however.

1) He recommends encoding dashes as HTML entity for a dash. I won’t get into the coding geekery of it all, but Shana and I found that the encoded dash is almost the size of an em dash. This makes passages, at times, difficult to read. Thus we opted to represent the dash literally as “-”.
2) Guido also suggests using a global format for producing both Kindle and epub files. For instance, the iPad can’t seem to center content appropriately—unless you trick it into doing so by nesting HTML tags. From my experience, this nesting, while necessary for the iPad, can make the Kindle device choke and gag (sometimes content is centered, other times it isn’t). As a result, I’ve decided to separate the source HTML files. I use one named “kindle.html” and another named “epub.html.”
3) He also suggests placing a CSS directive for chapter headings in order to force page breaks. In some cases, this didn’t always work. A method I found that seems to be more full proof is to create a DIV tag to simulate page breaks.

Some Gotchas

If you’ve made it this far, I want to add some technical tips. Even so, I don’t want to frighten anyone with technical details. I am by profession a programmer and database administrator, so these details, to me, seem normal. I’m providing them here for reference purposes only.

1) Kindle is not as obedient with CSS directives as epub devices. In particular, Kindle seems to ignore the “margin-right” directive.
2) If you intend to sell your e-book through Apple, keep the following things in mind:

  • You cannot post books to Apple unless you have a Mac
  • The Apple validation engine is a bitch. It’s much stricter than Amazon or Barnes & Noble
  • There is a long delay while Apple checks the content. I’ve read this can be as long as three weeks

3) You will need a fairly advanced text editor. Sorry, but notepad simply will not cut it. You need something that can do some fairly advanced search and replace. I use the wonderful—and free—Text Wrangler for the Mac.
4) Simplicity is the key. Make your HTML templates as simple as possible.
5) Check your e-book on an actual reader device, if you have access to one. The software on your PC is great for reading e-books, but it does not accurately represent your e-book’s formatting on an actual e-reader.
6) DO NOT use spaces in filenames. Ever. If you do, good luck making it past Apple’s validation engine.
7) Prefix all external links with “http://”; if you do not, an epub validator may look for documents of said name instead of understanding that those are external links.
8) Use “title” attributes in all anchor tags and “alt” attributes in image tags.
9) Calibre is a great program, but takes some getting used to. If you’re a techno-geek who is familiar with PHP, Apache, PostgreSQL, EMACS, etc., then you should be right at home. Calibre is not what I would refer to as a friendly program. It’s quite functional, though.


12 responses

  • Pingback: E-book Formatting | Immortal Ink Publishing | My Blog

  • Thanks for the heads-up. I am surprised that you had trouble with things such as the page breaks or the centering the way I had recommended them. I’ve been using the methods I described in my blog tutorial in over 200 eBooks by now. I use them in my own and in my clients’ eBooks and never had a single problem with them, so I am not sure what went wrong on your end.

  • Guido,

    First off, thank you for all the hard you’ve done to help so many writers.

    The book in question has special formatting. It uses images as chapter headings. My Kindle gets them wrong intermittently. Of 32 chapters, probably 6-8 were not centered. I thought there was some issue in my code. For all I know, it’s strange behavior by the Kindle itself. Only when I removed the nested span tags did the problem go away. Now when I’d tested your method with text only, I didn’t notice this behavior.

  • I’ve noticed a lot of these same sorts of issues in my work on Kindle as well. It’s incredible to me the variety of hats a writer has to wear. Not just computer-wise, either. I mean, you have to actually get a construction license, put out a bid, get the contract, build the library, then physically take people to the library, teach the people how to read, feed them, clothe them, hold your work in front of the face, plus read it aloud for them. But as a writer, I wouldn’t have it any other way.

    • And don’t forget drinks. If you don’t buy those people dinner and drinks once in awhile, they tend to wave over the man in uniform, and tell him, “Officer, can you get this person away from us? I think he’s insane.”

  • I’ve not had any issues with eBooks I’ve created from Scrivener. Anything I want centered I had to create a special format tag for (I call it “Signage” because I usually use it to depict signs), but once you have everything in the Compile tab set up right it Just Works in my experience.

    If you use MacOSX or Linux, and aren’t frightened by the Unix command line, you don’t even need Calibre (which I use to keep my eBook library). Both ePUB and MOBI are, as you hint at, a collection of HTML files with some control files, wrapped up in a ZIP archive. I built an ePUB by hand to see how one of my work documents (a 700 page manual) would look — the HTML came out of a markup system with some cleanup scripts preparing it for use. Calibre did a fine job displaying the results, except for those complex tables that any eReader has trouble with.

    I do admit, I love this kind of hackery. If I ever do run into problems with Scrivener, I know I can get complete control.

    • I want to do some experiments with Scrivener and Pages in comparison to the manual system I use. I was convinced at first that the manual system I use gives better control–and it seems to. The whole snafu, though, is the inherent difficulty in doing updates. Basically the HTML source is embedded with character codes that make everything but the smallest updates a little tricky. The only way around this would be to regenerate a new file each time–or use Scrivener or Pages.

    • You see it’s quite simple. A lithographic magnate named Igor Von Schnitzelheimer invented this process…

      Still smiling & nodding aren’t you? Carry on, carry on :)

  • Just a nod and a note to this post. Because of the difficulties authors and smaller publishers have found when it comes time for the EPUB conversion process, we designed and have recently launched an online DIY tool. Based on feedback from the San Francisco Writers Conference this weekend, we’re on to something here and I hope you don’t mind if I share a bit about it.

    Not only does the Folium Book Studio properly convert from Word to EPUB, but it includes a WYSIWYG format editor that provides great control over all the layout elements—as well as enforcing uniformity throughout the entire work. Images can be placed directly within the text, resized, and captioned. The import process enables basic typographic conversion (optional, of course), and the export process delivers the complete EPUB package directly to the user. For tricky bits such as images, these are encoded in the package such that you receive maximum capability, depending on reader’s the chosen viewing device.

    We also offer free a ISBN, for those in need of one.

    Over time, we will improve the software and are very eager to continue conversations with authors and publishers about your needs. Please feel free to check out the tool or join one of the webinars. We hope to be of service to everyone who loves words and the process of writing.

  • Today, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a 30 foot drop, just so she can be a youtube sensation. My iPad is now broken and she has 83 views. I know this is totally off topic but I had to share it with someone!

  • Aw, this was a very nice post. Finding the time and actual effort to produce a good
    article… but what can I say… I procrastinate a lot
    and don’t manage to get anything done.


Leave a Reply