Saturday, 21 July 2012

How to format your project KF8 proof. BEFORE publishing.

This guide will focus on how to create a clean format before you publish your book to Amazon. When you're not sure why you need to use it, check out the original post: What is it and why do you need to?
You can use this guide when you have already published with Amazon and need to fix that file. Just go to STEP 8, this is how I originally cleaned my file(or check out the original post where I've put a link to a quick fix, but it assumes you know about html coding and everything).
You don't need to know a lot about html to use this guide. I'll be using plain terms to explain things and lots of pictures. PLUS I'll try to use any actual coding as little as possible.



------ REMEMBER -------
I will only cover the basics in this guide. I think that for about 90% of fiction writers this guide will be enough to create a good file to upload to the kindle. I will cover links (inside the book and outwards) for things like TOC's, allignments, slight formatting of texts like bold, italics or larger text. If you want more difficult stuff in your book you might still find this guide useful but you will have to do the research and testing yourself. I will only cover the easy basics.
--------------------------------

You'll need:
- full file of your book in .doc or any other file. I expect that the file already had the title page and copyright stuff according to the Amazon standard.
- Libre Office (which can be found here, and is free)
- Notepad ++ or any other source code editor (Notepad ++ can be found here, and is also free)

You might need:
- print copy of your book
- highlighters


For this guide I will be using my book Magical Roads, which can be found on the Kindle Store. The file I'm using for the pictures is the start of my own book in which you can see how most formatting works.
Soooo, let's see what my file looks like normally:

There are four different types of formatting going on in this example: large and bold text (below in yellow), centred text (green), links (pink), title (blue). To see this more clearly I coloured the parts in this picture.
These are the main things I will be focusing on in the guide as you can reproduce most of it later on yourself for other parts.


STEP 1 Saving the formatting
Colour all the parts which have special formatting: titles, links, centred, bold, etc. in your manuscript, this can be done on the computer or you print out the file and do this with markers. Also, don't forget to somehow make sure you don't forget where you had pagebreaks, these are important later on.
Since we will be stripping all formatting you need to do this before you go onto the other steps or you might miss something later on.
Save this file in a separate file from your base file. So that your manuscript looks as clean as always when you need it later. Name it something like: NameofStory-coloured or step1 or something like that.

STEP 2 Stripping all formatting
Open Notepad ++ and have it open as a normal text file.
Copy all the text from your original file (Ctrl+A and Ctrl+C or from the bar Select All and then copy). Then go the the open Notepad++ window and paste (Ctrl+V or edit-> paste) the file into it.
Your file will look different, all your formatting will be stripped and the lines will all be cut off at the return place. Don't worry that it looks slightly weird, this is fine. This is what my file now looks like:
Nice and clean, but really really boring. Don't save this or anything, just keep this window open.
Now you open an LibreOffice document. Select all the text from the Notepad++ file (like above) and copy this into the new page.
You can now close the Notepad++ page without saving. Don't close the LibreOffice file. You can save the LibreOffice file so you can always go back to it when something goes wrong, just let it save as the normal file format it asks for(.odt), to keep all the files apart you could add NoFormatting or Step2 to the name of the file, so you know which version of the file it is.

STEP 3 saving as decent HTML
LibreOffice creates nice and clean HTML pages, which is why we will be using this program to create the html file that we upload to Amazon to make our ebook from. This way when we get to the part where we really need to do some formatting in the actual HTML part of the text we don't need to do that much any more. By using LibreOffice is it like formatting your normal word document, which is something you're probably quite comfortable with anyway.
To make sure the Kindle understand the characters used in your document we need to change the character set that LibreOffice uses for HTML. You can find this option under Tools -> Options -> Load/Save -> HTML compatibility. In the lower right part there is Character set with a drop down menu next to it. Change this to Western Europe (ASCII/US).

Press OK and return to your page.
Now we'll save the file as HTML and get on with the real stuff. To save as HTML you go to File -> Save As. You fill out the name for the file and for the ease of using it add something like HTML or something to the name as this will also be your final file. Use the drop down menu to change the type to HTML document. Save this.
Now we're ready to get all the formatting back in.

STEP 4 Paging and outlining
Now we're gonna make the book pretty and useful again. Open the file you created in step 1 next to the HTML file so you can see both files at the same time (or easily switch between the two).
The first thing you'll have to decide on is what you might use to represent pagebreaks. Amazon does allow the regular pagebreaks that the program can create in the file but this shifts from guide to guide so we'll use their special tag later instead. You COULD use the regular pagebreaks and replace them later on, so that while formatting you're not distracted by the difference between the files. Or you could use a placeholder, like a row of signs to represent the pagebreak. For the ease of this guide I will be using this placeholder:  #Pagebreak#
Make sure that you use the same tag each time as that will make the replacement easier later on.
My file now looks like this:

Now we take out all extra returns we might have used. Go to View -> Nonprinting characters
A whole bunch of characters have started showing up.

This way you can see if there are any characters that shouldn't be there. There shouldn't be any more than one Enter after another. So you need to delete all the times that there is more than one enter. You can use one enter before and after a pagebreak if you like to and also after a title and between scenes in the story. But apart from that they will need to be cut. The Kindle will ignore most of them anyway.
To get the signs to disappear again go to View -> Nonprinting characters and they should be gone again.

STEP 5 Adding the formatting back in
First thing to do is changing the titles back into headings. To do this you select a title (apart from the title of the book on the first page) and change the formatting to heading 1. The title will become bigger. Don't do anything else with this. Don't go making it look like the way you would like to look on the kindle because that will all be deleted later on anyway. The only reason we do this is because it is important that the titles get the <h1> tag in the html file.
Now add all the bold, italics and underline to your text in the places you coloured in STEP 1. Don't add in anything that should be centred or outlined differently, we'll be using HTML to do that later.
Your book should look almost normal again now.



STEP 6 TOC and links
This is a lot easier than it sounds.
To create a Table Of Contents (TOC) you have to go through a couple of quite easy steps.
First, write out a Table Of Contents at the start or the end of the book. I advice the start when you deal with definite parts that have their own story like the different parts in omnibuses or in my case short stories. I advice the end of the book when you only have chapters in your book and you don't need the reader to see them before they start reading the book. This is important because Amazon expects there to be a TOC in the book and will give errors when there isn't.
So after you've finished the TOC itself you need to bookmark each title or each item you used Heading 1 on(as long as you want to have it in the TOC). To bookmark something you select the word and go to Insert -> Bookmark. Name the bookmark something that you will recognise, the easiest thing is to name it the same as the word(s) you selected.
Now, to make a link in the TOC clickable you go to the TOC and select one of the items from the list. You then go to Insert -> Hyperlink.
In the popup screen you click on Document. Click on the circle with a dot in it in the second row, this opens a new popup. Click on Bookmarks, select the bookmark that belongs with the item. Click apply and then apply in the other screen. Now your first item on the list is linked. Do this for all the items on your TOC.
 Amazon likes to know where the TOC is and where it needs to start the book, to point this out is quite easy. To show it where your TOC is you select Table of Contents (the words) and add a bookmark with the name TOC. To add where the start of the book is go to where you'd like the book to start, put the cursor at the beginning of the line and bookmark the place with the name Start.
To add any links to places outside your document you select a sentence or URL you want the link to be named, you go to Insert -> Hyperlink and instead of clicking on Document you click on Internet. In the line called Target you fill in the url of the website you want to link to. Click Apply and you've added a link to a place outside your document.
Now it's almost time for the final touches.

STEP 7 Time to check out the file
Now it's time to check what the file looks like. We've been working in LibreOffice which might show the file differently then it normally would. So make sure you save the file and keep it open, you might need to make changes later on. Go to the folder where you saved the file and double click to open it, it should now show in your browser (this is because html is actually a format used to create websites, so your browser recognizes it as something it can display).
Play around with the file, click on links to see if it goes to the place you want it to, check to see that there aren't any things you forgot. The space between parts of the story looks slightly weird at this moment but don't worry, we will fix that in the next step. When you're comfortable that you haven't forgotten anything that is discussed in the steps above, save one last time, close the file and go to the next step.

STEP 8 Fixing typesetting and other HTML stuff
Rightclick on the html file and click Edit with Notepad++. This will open the file in Notepad++. I know, it looks kind of daunting this text and all those colours but from here on out is really easy. To make sure you don't make too many errors, just keep the webpage open next to the HTML document, this way you can immediately see what you're doing. Because LibreOffice is pretty good with coding we only need to do a few things here like indents and centering text.
This is what my HTML file looks like in Notepad++:
So, what is in there that is important?
On line 5 it calls for a title, add your title here.
Line 6 tells the program the file is created in LibreOffice and the version, you can leave this.
Line 7 and 8 can be cut, these lines are not interesting to Amazon as they are only meaningful to LibreOffice.

To make things easier we're not going to use the part that is between <STYLE> and </STYLE> but not before we've cleared some stuff.
Look at the first of your <P> tags (Paragraph tags, these are your normal text), is there any text between the <p and the last > ? In the image above you can see this is true for my file, there is a STYLE="margin-bottom: 0cm" in it. This is text we don't need so we'll cut it. To quickly do this you go to Search -> Replace. In the top line you copy the full tag: <P STYLE="margin-bottom: 0cm"> and in the second line you put the tag you want: <P>. Click Replace all. That is one thing cleared up.
The next thing is to look for <H1> tags and see if there is anything but the tag in that. If there is you do the same as with the <P> tag. Search and Replace all but now with <H1> as the clean tag.
Now quickly look through a bit of your text, all the tags apart from the <A> tag should be clean tags. The <A> tag is a tag that deals with linking and bookmarks, leave this as it is. The quickest way to see this is to check if there are any red text left.
Okay, back to the <STYLE> tag. The way it stands now it loads css into the page and then uses css to format the styles, this is not needed and slightly confusing to fix. We're gonna cut it and replace it with this really easy piece of coding:
<STYLE>
p { text-indent:1.5em;}
.center { text-indent:0em; text-align:center; }
.noindent {text-indent:0em;}
</STYLE>
What you immediately can see is that I cut all the things that had to do with font type and size, this is because the new Kindle format (KF8) doesn't like you setting these things. Each kindle owner sets their own size and font type they would like to use on the kindle and adding those tags as a writer interferes with that and results in the small text size on some devices. Which, of course, we are trying to prevent.
This style has two parts. The p { text-indent:1.5em;} deals with regular text, in this case it indents the text 1.5em (em is a size that will depend on how large you have set the size on the Kindle). You can play around with this and make it larger or smaller, you can see for yourself what you like best by saving the html and then reloading your book in the webpage.
The other two things .center and .noindent are class tags, these you can apply to any tag and will do something with it. In this case .center takes the indent away and centers the text, you need to take the indent out first because otherwise the format will first indent the text and then centers that text making the centering look crooked. The other class simply takes out the indent, this is good for places like your Table of Contents and other places there shouldn't be an indent in the text.
As you can see, I have not specified anything for H1, this is because the regular H1 format is not to indent anything anyway. But you could, if you liked, use the center class to center the titles in H1.
Add these classes to the places needed: the title on the first page and the copyright page need to be centered and anything else you want or need.
Now we'll replace the #Pagebreak# with the actual pagebreak tag Amazon wants us to use: <mbp:pagebreak/>
Like the method above to clean the file of any formatting now you put the placeholder (#Pagebreak# in my case) into the top line and the pagebreak Amazon wants in the second:  <mbp:pagebreak/>
This is what my file now looks like:
And this is what my page now looks like in the webbrowser:

 Nice and pretty, right?
If you want to add a little bit more formatting you can check out this link in which Amazon explains what types of formatting are allowed: Formatting for kindle
When you're happy with what you see save one more time, make sure you can find it back easily later on.

STEP 9 DONE!
And then you're ready to upload to Amazon. Which is pretty straightforward so I won't write about how to do that here :)
Congratulations on finishing your ebook!
Now boil some water for some tea, open a beer, anything to get through the few hours Amazon takes to make your book go live.

See! It's not too hard, even if you're not that good with coding or scared of it you can still do this.

Write on!

Kia

For people that want to be knit-picky and point out that some of these things can be done differently or neater or anything, this guide is not meant for those who know how to do HTML this is meant for those who don't know how to create a full HTML file but still want to create a foolproof file to upload to Amazon.