Perspectives of a Writer and Musician

Issues related to writing, publishing and playing jazz music: One man's muse.
by Al Stevens

My Photo
Name:
Location: Florida, United States

Friday, April 12, 2013

A Gearhead's Guide to E-book Publishing - Introduction

This is the first in a multi-article series that describes how to turn stories into e-books suitable for Kindle, iPad, and all the others. The series describes a bare-bones procedure that I arrived at after trying many ways that I contrived for myself or adapted from on-line advice of those who have done similar conversions.

Why not Mobipocket Creator and Calibre?

Conventional procedures involve the use of programs such as Mobipocket Creator and Calibre to make these conversions. That's how I used to do it, that's how most e-book tutorials instruct you to do it, and hundreds of thousands of e-books, including several of mine, have been published from files generated by these programs, which, in my opinion, burden the e-book with unnecessary CSS code from not only themselves but from the HTML that Word and other word processors emit when you export to HTML. They also can produce e-book files that flunk on-line validations.

Those are the procedures to be used by technically-challenged authors, whom I affectionately refer to as muggles, borrowing from J.K. Rowling.

The procedures in this tutorial eliminate the bloat and the validation failures. These procedures are for gearheads, authors who are not intimidated by the cryptic formats of files and who are willing to learn and apply a small amount of html and css.

Many other e-books have been built by e-book aggregator companies such as Smashwords and Draft2Digital, which will convert your Word document to e-book format. You generally give up your control over the appearance of the book's interior layout when you use these services (which are free, by the way) but, all is not lost. Both services accept an .epub book instead, and, if you wish to use their distribution services—which I have done—you might consider using procedures such as these to build your epub file and uploading an e-book that suits your preferences.

What You Need

These procedures assume you have a manuscript in almost any format written with almost any word processor. The WP must be able to export or save-as to raw text format. These procedures cover only the conversion of books with a cover image, chapters with chapter titles, narrative text, and the occasional italicized word or phrase. But they're not limited to that. As you get past this elementary approach you will be able to extend your knowledge to more advanced e-book format options. For now, we'll stick to the basics.

A smidgeon of knowledge of html and css would help, but it's not absolutely necessary. I tell you what code to add and where to add it as we proceed, and I try to explain it along the way.

For this procedure you need the free text editor named Notepad++ or any other editor that supports find and replace that include specification of the usual paragraph break characters. You can use Word to do this with a raw .txt file too, although the steps would be slightly different.

You can download Notepad++ here

I recommend that you ground yourself in the structure of an epub file. You don't need to know it all, but anything you learn will help along the way. I recommend EPUB Straight to the Point by Elizabeth Castro. It's a comprehensive treatment of the subject with a very few errors, and for the most part the best I've found.

What You can Expect
At the end of these procedures you'll have your book in epub and mobi formats, well-formed and ready to be uploaded. You will also have a fundamental understanding of what it takes to build such files.

So, good luck, and let's get started.



Table of Contents
Introduction
Lesson 1: HTML
Lesson 2: Content
Lesson 3: Frontmatter
Lesson 4: Chapters
Lesson 5: Opening Paragraphs
Lesson 6: The Cover
Lesson 7: TOC, Metadata
Lesson 8: Epub Validation
Lesson 9: The Mobi (Kindle) Format

A Gearhead's Guide to E-book Publishing - Lesson 9: The Mobi (Kindle) Format

This is the last lesson in the tutorial on building e-book files ready for publication. Lesson 8 discussed how you can validate your epub prior to submission. This lesson is about converting the epub to the mobi format, which is the format you upload to Kindle Direct Publishing to be included in Amazon's Kindle store and to be readable on all Kindle devices.

This last lesson might be the most important one for authors who wish to reach the largest reader base to find potential buyers for their e-books. Amazon has cornered the e-book market (as well as many others), and offers apps to run on most popular e-reader devices to read Kindle e-books. Owners of iPad, Nook, iPhone, Kobo, and other devices can read Kindle books that they purchase from Amazon once they've downloaded and installed the free Kindle reading apps.

Those apps are available here.

Conversion to Mobi

Begin by downloading and installing the free Kindlegen application. This lesson assumes that you installed it on your PC in c:\kindlegen. The procedures in this tutorial are for Windows. If you are running Linux or Mac, you will use different commands. The steps are similar, but they use commands for your specific platform.

You install Kindlegen from here.

Kindlegen is a command-line program, which means you run it from a DOS command line. Here's where you don your gearhead hat again. This procedure is not for muggles. Skip this section if getting down and dirty with the operating system troubles you.

The easiest way to run Kindlegen is from a batch command file, which you create with any text editor.

    1.   Open the folder where you keep your epub file.
    2.  Right-click in the folder
    3.   Choose New->Text Document

This action creates an empty text document.

    4.   Open the text document in your text editor
    5.   Type these lines of text into the document:

            c:\kindlegen\kindlegen bandit.epub
            pause

These statements are DOS command-line commands. The first statement instructs Kindlegen to convert the file named bandit.epub to bandit.mobi. You will, of course, use your own epub file name in this command. The second statement tells DOS to pause so you can read the results of the conversion. Without the Pause command, you won't know whether Kindlegen failed and, if so, why.

    6.   Save the text document
    7.   Rename the text document to makemobi.bat

When you try to rename the file extension of a file that Windows associates with an application— in this case from .txt to .bat—Windows warns you about it.

    8.   Click Yes to allow the rename
    9.   Double-click the new makemobi.bat file to run its commands in a DOS window

You will see the commands and their effects in a DOS window something like this one:


I know, that's more than you ever wanted to know about the mobi file, but it tells you that the conversion worked. If it did not, if, for example, an essential piece was missing from the epub file, which shouldn't happen since you validated it in Lesson 8, the DOS window will contain error messages from Kindlegen. In that case you must return to Sigil, repair whatever is wrong, make and validate a new epub file, and return here.

Conversion for Muggles

If the previous section intimidates you, you might prefer to take the easy way out. A program named Calibre can convert between most e-book file formats. Its user interface will be familiar to users of the GUIs (graphical user interfaces) of Windows, Linux, and Mac.

Calibre is well-supported and maintained. The mobi files it creates are somewhat larger than those from Kindlegen, but many authors and readers use the Calibre program to manage and convert their e-books. Calibre has many functions beyond file conversion, and I recommend that you install and learn it.

You can download Calibre from here.

Validating the Mobi E-book

As far as I can tell, there are no online or downloadable validators for the mobi format. Mobi is a private proprietary format owned by Amazon, so, if there is to be a validator, it will probably come from there.

The best validation then is to load your mobi file into as many of the different Kindle devices and apps that you can find and make a visual check of the e-book itself.

The first visual validation I use is the Kindle Previewer program shown here:



The Devices menu lets you select from simulated E-ink, Kindle Fire, and Kindle for IOS (iPad and iPhone) devices. Its renderings aren't always perfect, but they suffice to let you determine whether your mobi e-book looks okay.

You can download Kindle Previewer here.

Beyond that, you might ask your friends to let you borrow their devices and sideload your mobi e-book to each one to see how it renders.





Table of Contents
Introduction
Lesson 1: HTML
Lesson 2: Content
Lesson 3: Frontmatter
Lesson 4: Chapters
Lesson 5: Opening Paragraphs
Lesson 6: The Cover
Lesson 7: TOC, Metadata
Lesson 8: Epub Validation
Lesson 9: The Mobi (Kindle) Format

Wednesday, April 10, 2013

A Gearhead's Guide to E-book Publishing - Lesson 8: Epub Validation

Lesson 7 was about the table of contents and metadata. If everything went well, you now have your e-book in a proper epub format. But you want to be sure.

This lesson explains how to validate the epub file to ensure that it complies with industry standards. Your devices and applications might properly render a non-compliant epub file, but some online distribution sites might refuse to list it in their catalogs, so validation is an important step in building an epub for publication.

Sigil has two built-in validators, one named FlightCrew that validates the epub and another that uses the W3C validator to validate the styles that you added to Stylesheet.0001.

FlightCrew Validation

Flightcrew is an open-source epub validator. You can download it here if you wish to use it outside of Sigil. To use the version that Sigil integrates:

    1.   Load your epub file into Sigil
    2.   Select Tools->Validate EPUB with FlightCrew

With luck, this is what you see next at the bottom of the Sigil application:


Be patient. The bigger your epub, the longer it takes.

If the epub contains code that flunks the validator, the Validation Results dialog lists each problem it found with the line of code identified like this:


For this example I removed a </p> tag from the cover.xhtml file to force the epub to fail and demostrate what to do.

    3. Double-click the errant line of code in the Validation Results dialog to have Sigil open the file in question and highlight the line where it found the error.

 
In this example, line 12 is highlighted with a dim yellow background color.

Here's where you need to exercise your html chops. The validator does not always identify the statement with the real error. It identifies the line it was parsing when it realized something was amiss. It's up to you to go looking for the real culprit, which should be somewhere above the highlighted line. In this case line 12 is highlighted, but the error is on line 11, which is missing the </p> tag that terminates an html paragraph (because I deleted it to make this point).

It won't always be that close, but I cannot possibly predict which of the many errors you might have in your epub file. I can say, however, that if you stick to the procedures in this tutorial, you shouldn't have much in the way of validation errors. But, as you get more comfortable with the html/css level of abstraction that the epub architecture provides and as you hand-code more and more of your epub, you are likely to slip up from time to time. In that case, find a deep gearhead who is willing to bail you out. They are everywhere online, and nowadays most folks have a neighbor or nephew like that.

The W3C Validator

This validator, available from Tools->Validate Stylesheets with W3C, sends your css stylesheet to a website for validation. I've used it, but too many times, Sigil fails to launch the remote validation website. At this time, I cannot recommend its use. If you want to try it, do so, follow the onscreen instructions, and see how it goes.

EPub Validator

If you plan to submit the epub to Apple's iBookstore, you should ensure that it passes the validation tests at http://validator.idpf.org/. Save your epub file first. Then follow the onscreen instructions, and, if you get errors that you do not understand or cannot fix, call someone for help. Once again, it's not possible to anticipate here all the kinds of errors that might show up, but, also again, if you took care in the use of Sigil, you should be okay.

The site includes a forum where you can get help. In one case where the validator did not provide ample information, I sent the epub file as an attachment, and the good folks there located the problem for me. Then they updated the site to properly display that kind of error message.

You should know that the epubs produced by Calibre from html exported from Word, which is the muggle's preferred way of doing all this, contain errors that do not pass the validator. These errors are usually html statements that have been deprecated by the formal specifications.

Spell Check

Sigil includes a spell checker similar to that of many word processors. Use F4 to check the spelling of words one at a time and the Tools->Spellcheck menu to proceed. I doubt that you need much in the way of additional instructions about that.

As usual, save your work. Once everything passes the validators, you have an epub document ready for publication. Next you'll convert it to the .mobi format that the Kindle requires.





Table of Contents
Introduction
Lesson 1: HTML
Lesson 2: Content
Lesson 3: Frontmatter
Lesson 4: Chapters
Lesson 5: Opening Paragraphs
Lesson 6: The Cover
Lesson 7: TOC, Metadata
Lesson 8: Epub Validation
Lesson 9: The Mobi (Kindle) Format

Thursday, April 04, 2013

A Gearhead's Guide to E-book Publishing - Lesson 7: TOC, Metadata

Lesson 6 showed you how to add a cover image to your e-book. This lesson ties up some loose ends to make the epub-format e-book closer to being publishable.

Table of Contents

The typical e-book has two tables of contents. One is in an html file at the front of the book like just another chapter. The other is encoded in a file named toc.ndx. That second one is what many e-reader devices and programs use to display the TOC apart from the book's narrative.

If your book is a work of fiction, biography, or memoirs and has no chapter titles, you might wonder why your reader would need a table of contents. The reader probably doesn't, but if you hope to publish in Apple's iBookstore, you'll need one. Their criteria include a table of contents.

You will recall from Lesson 4 on Chapters that you assigned the H2 tag to your chapter headings. That assignment enables automatic generations of both tables of contents.

    1.    Open Sigil and load your epub file
    2.    Select Tools->Table of Contents->Generate Table of Contents...

This action opens the Generate Table of Contents dialog.


    3.    Ensure that all the chapter headings are listed and checked
    4.    Click OK

This action generates the toc.ndx file needed for the internal table of contents. Next you will generate the html table of contents file.

    5.   Select Tools->Table of Contents->Create HTML Table of Contents

This action creates the file named TOC.xhtml at the top of the Book Browser. You probably don't want it ahead of the cover and frontmatter.

    6.    Click on and drag the TOC.xhtml file to where you want the table of contents to display when the reader pages through the e-book.

Here's Sigil with both tables of contents displayed.

 
 
Metadata

Metadata are those data that describe the e-book to those who might be browsing it in an online bookstore or in their personal e-book library. You add metadata with the Metadata Editor.

    1.    Select Tools->Metadata Editor
    2.    Fill in the Title and Author
    3.    Change the Language if the default value of English is incorrect

Here's the Metadata editor filled out with the minimum data.


    4.    Click OK

Save your work.

Next time we'll discuss how to validate the epub file to ensure that it fits the standards.




Table of Contents
Introduction
Lesson 1: HTML
Lesson 2: Content
Lesson 3: Frontmatter
Lesson 4: Chapters
Lesson 5: Opening Paragraphs
Lesson 6: The Cover
Lesson 7: TOC, Metadata
Lesson 8: Epub Validation
Lesson 9: The Mobi (Kindle) Format


Wednesday, April 03, 2013

A Gearhead's Guide to E-book Publishing - Lesson 6: The Cover

Lesson 5 of this tutorial finishes up the narrative part of your e-book. This lesson adds a cover to your e-book so that folks can judge...oh, never mind. It seems that every discussion of self-publishing eventually gets around to that same beat-up old cliché.

I assume you have designed a cover and have an image file ready to add to your e-book. Most e-publishers want the e-book to have two cover files with the same image. One is embedded in the e-book itself, and the other you upload to distribution sites (Pubit, Kobo, etc.) when you publish the book. That second one is for their on-line listing.

An image file 600 pixles wide by 900 pixels high works for the e-book. The distribution site might specify a larger format image to display your cover in its online catalog.

Here's the cover image for this example:


Don't laugh. I cobbled it together for this series of tutorials. I assume (and hope) that either you are a better graphics artist than I am or that you know one.

To add the cover to the e-book:

    1.    Open your project in Sigil
    2.    Select the file named Section0001.xhtml in the Book Browser
    4.    Enter Code View (F2)

Here is what you should see:


    5.    Delete the line of code on line 11 that says:

         <p>&nbsp;</p>

This line of code would insert a blank page between your cover and the rest of the book.

    6.    Return to Page View (F2)
    7     Rename (Ctrl+Alt+R) the Section0001.xhtml file to cover.xhtml
    8     Click the Insert Images button (the one with the small computer monitor icon)

That action opens the Insert Images dialog shown here:


    9    Click the Other Images button
   10   Navigate to where you stored your cover image file
   11   Select your cover image file

Two things happen here. Sigil adds the image to the cover.xhtml file and also to the Images folder in the Book Browser. You can (almost) see it here.

 
Why two places? The Images folder is a list of image files available to be included somewhere in the e-book. The cover-xhtml file is one of the places in the e-book where an image—the cover image—is included. And we're not done yet. We have to tell the e-book that this particular image is indeed the cover for when it needs to display the cover somewhere—such as on the e-reader device.

   12.   Right-click the cover.xhtml file in the Book Browser
   13.   Select Add Semantics->Cover
   14.   Open the Images folder in the Book Browser
   15.   Right-click the image file name for the cover image
   16.   Select Add Semantics->Cover image

These actions add entries to the cryptic file named content.opf in the Book Browser to identify the cover image as being the cover of the e-book. You can look into that file if you want to see what's in it. Gearheads who hand-code their epub books with a text editor need to understand that file. But Sigil takes care of it for you.

Save your work. The next lesson ties up some loose ends to complete the e-book in its epub format. Later you'll convert it to .mobi, the format required for publishing on Kindle e-reader devices.




Table of Contents
Introduction
Lesson 1: HTML
Lesson 2: Content
Lesson 3: Frontmatter
Lesson 4: Chapters
Lesson 5: Opening Paragraphs
Lesson 6: The Cover
Lesson 7: TOC, Metadata
Lesson 8: Epub Validation
Lesson 9: The Mobi (Kindle) Format