XHTML in an ebook

4 Ways to Create an Ebook

This is the second in my series of blog posts about ebook creation. It was originally posted on Joel Friedlander’s wonder resource site, TheBookDesigner.com.

Last time I talked about just what an ebook is — a website in a box. Ebooks come in a number of flavors, but for the purposes of this discussion I’m going to stick with the most common and most malleable format of ebook, the ePub file that is the basis of all of the major retailers’ ebook offerings.

There are four basic ways to create an ebook (that is, an ePub file):

  1. From scratch
  2. Saving from a word-processing or page-layout application into ePub format
  3. Using a conversion app or online service
  4. Hiring a designer

The trade-off among these methods involve quality, time, and price. As the old saying goes, you can generally pick two. In order to get all three, you’re going to need to become an ebook maven yourself, which will take a fair amount of time, but which will allow you to control all of the variables yourself. Let’s look at the options, and you can see whether that’s the road you want to take.

Option 1: Create the Ebook from Scratch

An ePub file, as I’ve said, is simply a website in a box. The box is nothing more than a ZIP archive that’s been given the file extension .epub. If you want to test this statement do this:

  1. Find an ePub file (it can’t have DRM — digital rights management — attached)
  2. Duplicate it so that you still have your original ebook to read and enjoy
  3. Change the extension (the last three or four letters in the file name after the last period) of the duplicate to .zip
  4. Double-click on the file

Voilà! You’ll have a folder containing all of the files that make up the ebook:

Creating an ebook from scratch

Those files and folders are Joseph Campbell’s Myths to Live By — unpacked.

Most of these files — the .xhtml files (a.k.a. web pages) and .css (a.k.a. stylesheet) file — are just what you’d find if you looked at the files building a fairly straightforward website.

The container.xml file serves one purpose: to tell the ereader where to look for the OPF file — that’s the one called content.opf here. That’s the heart of the ebook. It tells the ereader where to find all of the rest of the files in the ebook, what order to display them in, and what role each item serves (e.g. cover image, table of contents, etc.)

The toc.ncx file is a specialized navigation file; it contains the information that your ereader displays when you click on the contents or chapters button.

You can create all of this from scratch using text-editing software, or XML editing software, or a web-page editing app like Adobe Dreamweaver.

I don’t recommend it. The amount of labor involved is huge, and the places where you can make mistakes are many; computers are literal-minded, and a missing space or semi-colon that the human eye would fix without our even being aware of it will break an ebook.

However, it is possible to use those apps to edit an ebook after you created it using the techniques laid out below. There are even apps that allow you to do this without un-ZIPping the file, so that you can see the ebook as you edit it. Every day I use two open-source apps (Sigil and Calibre) to refine ebooks that I’ve generated.

What you see inside one of the xhtml files that make up the body of the ebook will look something like this:

XHTML in an ebook

That’s the title page of a book that I’m preparing for publication. If you’ve poked around web pages at all, that will all look fairly familiar — HTML tags, style attributes, image calls, a hyperlink or two. For what it’s worth, this is what the page looks like when it’s displayed by an ereader:

Title-page-sample

If all of that code looks scary to you — don’t worry. Though it’s essential to know some basic HTML if you want to get under the hood of your ePub file, there are other ways to create ebooks. And I’ll be talking some more about what all of that gobbledygook actually is in coming months. (If you’d like to jumpstart that process, I highly recommend Liz Castro’s excellent introduction, ePub Straight to the Point. It’s a few years old, but still does an great job of covering the basics.)

Option 2: Use an App That Exports ePub Files

So if you don’t want to go the DIY route, there are a number of applications that currently export directly to the ePub format:

  • Apache’s OpenOffice has a plug-in called Writer2ePub that allows you to save files as ebooks (open source office suite)
  • Scrivener (commercial writing app)
  • Apple’s Pages for OS X or iOS (commercial word-processing/page-layout app)
  • Adobe’s InDesign (high-end commercial page-layout app)
  • QuarkXpress (high-end commercial page-layout app)

 

The last two are particularly helpful if you are also preparing a book for print publication.

There are many more options — including add-ons and plug-ins to existing commercial and open-source apps.

All of these will create ePub files that work, and that should be accepted by most retailers.

What’s the downside? Well, there are a couple of things.

First of all, none of the files created by these apps will display quite the way that you expect them to in various ereaders, especially if you’ve got an ebook that’s got any complicated formatting such as drop-caps, tables, inset images, fancy typography, etc. The apps will try to reproduce on the screen what you were trying to create for the printed page, but often the style rules that the apps try to create make an incredible mess in one or more ereader. Everything may display as plain text on a Nook, while small images may fill the page on an old Kindle, while no images display at all on the Kindle app on your computer.

Here’s the same page displayed on different ereaders:

iBooks
iBooks example

Kindle
Kindle-for-mac-page-sample

Nook
Nook-page-sample

Adobe Digital Editions
ADE example

Note that on the Nook app, the captions (which are hyperlinks) display as blue rather than red. And notice that in Adobe Digital Editions, the image doesn’t display at all. (I was eventually able to get them to — by rewriting the stylesheet specifically for ADE and all of the apps based on it.)

Also, all of these programs have idiosyncrasies; most create ePub files that are very difficult to customize, since they treat any style change (italics, font size, indents, etc.) as a unique case, rather than applying a document-wide style. If you use the Styles formatting rules that all of these apps allow — apply a Body style to all body text paragraphs, for example, rather than formatting them as 12pt. Palatino and hitting the tab at the beginning of every paragraph — the results will be better, but inevitably the ePub file produced this way contain WAY too much code, enough to swell the file size. This is a problem when you upload the file to Amazon’s KDP, which will deduct a “transport fee” of $0.15 per megabyte of file size on each download from your royalty. (I’ll be speaking to all of these challenges more in coming months. I’ll also say why it’s probably not worth your time to create files in Apple’s wonderful iBooks Author.  iBooks Author is now more of an option than it was when I wrote this originally; still, not for the feint of heart.)

Option #3: Converting to ePub Using an App or Online Service

Most of us start with a manuscript — a Microsoft Word, ODF (OpenOffice Document File), or RTF (Rich Text Format) doc that we’re looking to turn into an ebook. Now, as I said last month, a Word doc isn’t an ebook. But you can format the text and even insert images, hyperlinks and the other paraphernalia that make up an ebook, and then use an app to convert the document into ePub format.

There are many, many such apps, both open-source and commercial, but I’ll only bother telling you about one that I’ve already mentioned: Calibre.

Calibre was created to convert between an impressive variety of ebook and manuscript formats, including HTML, RTF, DOCX, mobi, AZW3, and, of course, ePub. It has a number of controls that allow you to fine-tune the conversion — but if you’re document’s simple, the standard settings will probably do.

And of course, as I mentioned above, Calibre contains a WYSIWYG ebook editor that allows you to clean up your ePub file after the conversion.

There are also a number of ways to upload a Word document and get an ePub file. (Most of them fall under the paid conversion option, which comes below.) Many of the retailers allow you to upload a Word document directly.

Smashwords actually prefers Word docs — and will allow you to download your converted file in ePub format after they’ve run it through their famous “Meat Grinder” conversion tool (it’s actually a customized version of the software at the heart of Calibre). Amazon’s Kindle Direct Publishing does a pretty good job of converting simple Word files. Kobo’s Writing Life and Barnes and Nobles’ Nook Press have online ebook editing tools.

The downside here is the same as in Option #2 — the conversions are rarely perfect. And in most cases, there’s little that you can do about it, since the conversion is automated, and handled completely by the retailer.

If you go this route, it is essential that you check your ebook out, not just on the retailer’s “preview” or “Look Inside” widget, but on an actual ereader.

Option #4: Use an Ebook Designer or Company to Handle the Conversion

A quick disclaimer here: I’m an ebook designer, so I’m a bit biased toward this option.

Still, I know it’s not the option for everyone.

There are thousands of companies and individuals who create clean, attractive ebooks that will display properly across a variety of ereaders. Here are some reasons to use them:

  • You’ve got complex design elements (tables, lots of images, sidebars, endnotes, drop capitals, etc.) that will require special care.
  • You’re trying to create a fixed-format ebook (again, this is not a PDF.)
  • You want to add a read-aloud track, video, or other enhancements.
  • Your book contains non-Latin characters.
  • You’ve got complex chapter headers.
  • You want the ebook to look good, whatever device it’s read on, and you don’t want to spend the time learning how to make that happen.
  • The idea of looking at HTML makes you break out in hives.

Using a conversion expert or company obviously will involve some cost. It’s up to you to decide whether the expense is worth it.*

Next time, I’m going to talk about how to prepare your manuscript for conversion — whether by you or by someone else.


Please share your questions and comments below!

 

* NOTE: I had a couple of the readers of the original post grumble because I didn’t say how expensive it would be. Here’s what I told them:
There are a huge number of factors that go into the cost of a conversion, from the state of the book (digitized? format?) to its complexity (footnotes/endnotes? tables? number of images? relationship of images to text? sidebars?) to any desired enhancements (audio/read-aloud? video? animation? scripting/widgets?) that giving a range of costs would be a bit meaningless.
I’ve charged as little as $50 for a straightforward conversion to around $2,000 for a children’s picture book with animation, a read-aloud track (recorded by me) and a bunch of custom scripting. There are folks who charge more and some who charge less. I didn’t feel as if I could give a meaningful range.
If you’d like to get a sense of the costs involved, you could check out Joel’s site ebookconversiondirectory.com. Some of the entries are out of date, but it’ll give you a sense of the range of services and costs. And it’ll offer a few hundred possible services — including mine.

2 thoughts on “4 Ways to Create an Ebook”

  1. Pingback: 4 Ways to Create an Ebook - Democratsnewz

Leave a Reply — Please!

This site uses Akismet to reduce spam. Learn how your comment data is processed.