Formatting Books For Kindle

As I’ve mentioned before, getting a standard document into a format that the Kindle can use properly (note the use of the word properly there) can be a little cumbersome.  Look on Google and there are 101 guides on how to do it, and each does something different.  The bottom line is that the process I use works, but so do many others – unfortunately due to the way Amazon have developed their toolset it’s pretty much mandatory that the source file is HTML before running the KindleGen utility and that’s what causes some of the issues.

I would imagine most people write their manuscripts in Microsoft Word (or OpenOffice), and since that’s what I use as well I’m going to concentrate on that.  If you write in OpenOffice it’s easier than Word so bear that in mind but I confess I use Word since it’s what I use at work.  Having been through the pain of this conversion I may change what I use in future!   So what do you need once you have your brand new, shiny document that contains your pride and joy?  Well, the way I do it may use several (free) tools and might be seen as inelegant, but it works for me.

You’ll need

  • Your document
  • Something to convert your file to HTML.  I’ve played with a few but to be honest OpenOffice Writer does a good job, so I’m going to use that.  Don’t use MS Word for this (see later)
  • A cover (if you choose to include one – I use a JPG 600 wide by 800 high)
  • A copy of SIGIL, the free ebook editor (http://code.google.com/p/sigil/)
  • A copy of KindleGen which is Amazon’s converter for Kindle books (http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000234621)
  • About 3 cups/360 grams of patience (yes, I really did look up the rough calculation for converting cups to grams)

And some time.  Obviously.  Putting it into context the whole conversion process took 30 minutes, but bear in mind I was also uploading screen shots and tweaking this post during that time, if I hadn’t been it would have been no more than 15 minutes.

The cover is an interesting one, if you don’t include it you get the standard Amazon one which is basically the title of the book on a plain background.  Many people say that a fancy cover sells books, and they’re probably right, but it’s personal choice.  I knocked up a basic cover for my first book but the other option would be to go to a graphic designer and get them to do it, although I would imagine the cost for most people is prohibitive.

So. if you’ve got everything together let’s go on a voyage of discovery/frustration!

Formatting the source document

When I’m writing the drafts my book has a cover page that includes name, address, version etc and each page has a header.  This is obviously not something you want to include in an e-book.  The first step was to strip it down to the bare minimum which in my case was :

  • Title and author on the first page
  • Copyright notice on the second page
  • Dedication on the third page
  • Table of contents on page four (generated in Word or OpenOffice), you don’t need page numbers, just chapter titles.  For this to work each chapter in the book needs to have a heading which is an appropriate ‘style’, for example I use ‘Heading 4’.  If it’s plain text the TOC won’t be generated.  Using anything like Heading 1 isn’t advisable as it turns out huge in the e-book.
  • Chapters (obviously)
  • No headers or footers

Convert to HTML

This is where it gets a little convoluted dependent on what application you wrote your book in.  All of the utilities require that the source file is HTML, but while MS Word has the ability to output as HTML the results are less than brilliant.  Even loading a DOC file into OpenOffice and saving as HTML requires a lot of work to tidy it up.

Now if you originally wrote the document in OpenOffice, just save as HTML since OpenOffice produces reasonable HTML from its own native format.  If you used Word, save as an OpenDocument format (ODT).  I believe this is only available in later (2007 onwards) versions of MS Word though.  Once it’s saved in that format load it into OpenOffice and then save as HTML.

But what if you’re using an earlier version of Word?  I believe there is a free add in for earlier versions that allows you to save as ODT but I haven’t researched this.  You could save as HTML and sort out any issues in Sigil, but unfortunately there will be quite a few.

Loading into Sigil

Sigil is an e-book editor primarily designed for producing epub documents, but for us it’s how we’re going to generate the file that KindleGen uses.  Load your HTML document and the display will look something like this (you can click on the image to get a larger version)

So we have the book inserted now and a Table of Contents on the right hand side.  But there are no sections (chapters etc) listed on the left.

The easiest way to split the book is to go to each section, including the title, dedication, copyright, TOC, chapters and press CTRL-SHIFT-ENTER.  This will create a chapter marker.  When you’ve finished with the chapter markers press F6 and each one will be converted into a section on the left hand side.

Not very elegant that though, all those weird names.xhtml down the left.  It would be better if we named each one.  I tend to use the radical naming convention of

  • Title.xhtml
  • Copyright.xhtml
  • Dedication.xhtml
  • TOC.xhtml
  • Chapterxx.xhtml

To rename just right-click on whichever section you want to change on the left and click rename.  Double clicking will open the section up in a tab if you want to tweak the text or layout.  By the end of this process you should have a nice column in the left hand side where you can find anything.  There’s just one more thing we need to do here and that’s tell the e-book what the ‘special’ sections are.  When you right-click on a section (say TOC.xhtml) you’ll notice an ‘Add Semantics’ option and that opens out into a list.  For each section that’s not a chapter add the relevant semantic (CopyrightPage for example).

If you decided to use a cover you need to add that.  Find the Images section, right-click and select Add Existing Files.  Select your file and it will import it.  Open the images section on the left, right-click on the file you added, click Add Semantics and set it to the cover.

A couple of things before we finish, press F8 to open the MetaData Editor and fill in the book’s name and the author name (if you don’t do this KindleGen will refuse to create the ebook).  When that’s done click the ‘Generate TOC from headings’ on the right and make sure only the chapters are listed.  If you used headings for any of the other text (title for instance) it will be included by default in the TOC and we don’t want that.

That’s it for Sigil, select File, Save As and save the epub file.  Congratulations, you now have an e-book, just not in the right format for Amazon!

Converting to Mobi

The final step is to convert the epub document produced by Sigil into the format that Amazon uses which is a form of mobi.   To do this we need to use KindleGen. Open a command prompt in Windows and change to the directory your book is stored.  Assuming you copied the application to a directory called C:\Kindlegen the command you should enter would be

C:\Kindlegen\kindlegen nameofepubfile.epub

As you can see in the screenshot, the command has run and will have returned to the command line.  No errors are evident which is good.  We should now have a mobi file in the same directory as the epub file that we can test.

Testing the file

There are a couple of options for testing your e-book, either using a Kindle or the Kindle Previewer program that you can download from Amazon (http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000234621).  I generally use the Kindle Previewer since it’s easier than sending the file to the Kindle every time and also has the ability to emulate all available Kindle devices such as the Fire or previous Kindle’s.  If everything has gone to plan opening up the book in the Kindle Previewer will take you straight to chapter 1 of the book, but the buttons at the top for Cover and Table of Contents should take you to the relevant section.  Likewise the next and previous chapters should take you to, yes… the next and previous chapters.

And that’s it, one new shiny Kindle e-book ready to do what you want (although I assume if you’ve gone to these lengths you’re going to publish it!).  If during the course of reviewing the book you find formatting errors, or even just spelling mistakes simply load the epub back into Sigil, change it and then run KindleGen again.

Well, that’s it from me, hope you found it useful.

Advertisements

3 comments on “Formatting Books For Kindle

  1. Pingback: The End Is Nigh | W.Chaser

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 )

Google+ photo

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

Connecting to %s