Self-Publishing / Uncategorized

Adventures in Formatting Part 1: The Basics

As you may have noticed I recently published a book. In the last few stages before publishing, after all the editing and polishing, I came to the beast that is formatting.  Luckily there were multiple guides out there that I could follow that helped me produce a product I was pleased with.

If you’re going to be formatting a book you’ll most likely want to create two entirely separate files. One for the Kindle (.mobi) and one for Smashwords (a word .doc file). You’ll do this for several reasons. Below we’ll explore the creation of an HTML file to use in .mobi creation.

You want to create an  html file for your .mobi book because it gives you much greater flexibility and in the end will make your ebook look much nicer across multiple devices. (Remember, people change the font size, screen sizes aren’t uniform, and several other variables shift or can be shifted across ereaders). Making your .mobi from an HTML file allows you to avoid all these potential pitfalls. Guido Henkel has a fantastic series of blog posts out that explain the process in detail, which you can find here; however, I find his guide to be a bit bloated for my tastes (I like things quick and to the point.) I’m going to do my best below to see if I can use my experience formatting my own book to create a bit of a streamlined process.

1. To begin you’ll want to download an html editing program, I personally suggest JEdit. It’s free and you can use it on Windows, Mac, or Linux. You can snag a copy here. This is the program that will allow you to create the html version of your book.

2. Open up your manuscript in your word processing program of choice (you’ll probably want to save a new file). Once it’s open you’ll want to pull up the search and replace function (usually ctrl + F). We’re going to replace a few symbols with their html counterparts so they display correctly in the book. Doing this is especially important if you want to ensure you get the proper curly quotes and apostrophes (and you should).

The symbols we’ll be replacing, and their html code components are as follows

Text Character

Code Component

“

”

’

…

—

©

©

&

 &

You can do this later on, but I found it easier to do at this stage of things.

3. Ok, so now we’ve got a manuscript full of html tags. Now we’re going to copy the entire manuscript, and paste it into JEdit. When you do this you should notice that all the nice neat paragraphs that used to exist in your manuscript are now long, single lines of text. Don’t panic.

Open up your code editor’s search and replace function (again usually ctrl + F). Take a look over the search and replace function for an option titled “regular expressions”, and flip that sucker on. Now we’re going to use a regular expression, I don’t understand how they work really, so I assume it’s some form of arcane magic that pre-dates computers. Enter ^(.+)$ as the search term and <p>$1</p>  as the replacement text. Pull the trigger and replace all. You should notice now that every paragraph-turned-line in your html document has a <p> at the start of the line and a </p> at the end of the line. If it didn’t work try using \1 instead of $1. If it still doesn’t work, go get yourself JEdit, because I know it works in that program.  Congratulations, you’ve just wrapped your paragraphs in paragraph tags!

4. Now we need to define some HTML styles, and that looks a little something like this. (Feel free to copy this and use it.)

<head>

<style type=”text/css”>

html, body, div, h1, h2, h3, h4, h5, h6, ul, ol, dl, li, dt, dd, p, pre, table, th, td, tr { margin: 0; padding: 0em; }

p

{

font-size: .75em;

text-indent: 2.5em;

margin-bottom: 0.2em;

}

</style>

</head>

The above is an example of part of the style section I used in my most recent book Mercury, Sulfur, & Salt. In the style section you’re basically setting the rules your formatting is going to follow. I’ll break down the important parts for you.

{ margin: 0; padding: 0em; }

Placing this at the beginning of the document removes all the preset margins and padding that a device may have in place. Without this line your margins may get all wonky and all the hard work you’ve done formatting could possibly go out the window.

 p

{

font-size: .75em;
text-indent: 2.5em;
margin-bottom: 0.2em;

}

We’ve created the <p> tag This bit defines a style tag in your document. Specifically the one we placed at the beginning and ends of your paragraph lines in the last step. Now let’s break down the individual lines: font-size: .75em; sets the size of your font. An ‘em’ is a measure of text size, it is based upon the size of a ‘M’ because that textual character takes up the most room of all characters used in English text. . The ‘em’ is the unit of measurement we will use throughout the entire html document. Knowing this, the other two lines should be pretty self explanatory. In the chance they are not…

text-indent: 2.5em; sets how large the indent at the beginning of your paragraph will be.

margin-bottom: 0.2em; sets a small margin at the bottom of your paragraph.

Once you’ve got all this added to your document go ahead and save it, but sure to save it as a .html file. As soon as you’ve got the file saved, find it on your computer and open it up to view the fruits of your labor thus far. You should be presented with a web page that contains none other than your book!

Tune in next week for part 2. We’ll be learning how to add a little bit of flair and personality to your book.

Advertisements

One thought on “Adventures in Formatting Part 1: The Basics

  1. Pingback: Publishing a Novel? Slow Down and Take Your Time | A World in Words

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