ebook formatting tutorial

22
Ebook Formatting Tutorial The purpose of this tutorial is to teach users how to turn their word document or html file into an epub or mobipocket formatted ebook ready to read on the Amazon Kindle, Iphone/Ipad/Itouch, Nook, the Sony PRS, and other portable devices. This tutorial focuses on using Calibre as the conversion tool. The tutorial is for users with a moderate understanding of HTML and Microsoft Word applications. For the purpose of this guide the RTF format is used because it is not a proprietary format and will open in any Word program. Such as Open Office, Wordpad, Microsoft Office, and etc... This tutorial will focus on using Calibre to convert documents into ebook format. Please be aware that many of the pages use screencaps. Learn more about Ebook Formats Programs you will need before you start Learn how to add cover images and illustrations Learn how to create a Table of Contents Calibre's Look and Feel Options - CSS Cleanup Your RTF Step by Step Conversion Guide Finding Other Resources HTML Cheatsheet Ebook Formats Information Page The first thing a person should do is figure out what formats their device supports. To find out what file formats your device supports visit the Ebook Reader Matrix Wiki . Scroll down until you find your device and look under the row Supported Formats. For the purposes of this tutorial I will only focus on converting to epub and mobipocket formats, however please keep in mind that Calibre will also convert to many other file formats that are listed at the Ebook Reader Matrix Wiki . EPUB = Nook, Sony PRS, Ipad, and etc... MOBI/PRC = Amazon Kindle and the Cybook For more detailed information please visit Elf's post Ebook formats . It is currently hosted on the Dreamwidth community called Ebooks . Or you may visit the Mobile Read Ebook Formats wiki post. Programs You Will Need Conversion Software Calibre The first program you need to install before continuing and if you don't already have it is Calibre . Calibre is a ebook library management software that works on Windows, Linux,

Upload: zebmckay

Post on 01-Dec-2014

471 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: eBook Formatting Tutorial

Ebook Formatting TutorialThe purpose of this tutorial is to teach users how to turn their word document or html file into an epub or mobipocket formatted ebook ready to read on the Amazon Kindle, Iphone/Ipad/Itouch, Nook, the Sony PRS, and other portable devices.

This tutorial focuses on using Calibre as the conversion tool.

The tutorial is for users with a moderate understanding of HTML and Microsoft Word applications. For the purpose of this guide the RTF format is used because it is not a proprietary format and will open in any Word program. Such as Open Office, Wordpad, Microsoft Office, and etc...

This tutorial will focus on using Calibre to convert documents into ebook format. Please be aware that many of the pages use screencaps.

Learn more about Ebook Formats

Programs you will need before you start

Learn how to add cover images and illustrations

Learn how to create a Table of Contents

Calibre's Look and Feel Options - CSS

Cleanup Your RTF

Step by Step Conversion Guide

Finding Other Resources

HTML Cheatsheet

Ebook Formats Information PageThe first thing a person should do is figure out what formats their device supports. To find out what file formats your device supports visit the Ebook Reader Matrix Wiki. Scroll down until you find your device and look under the row Supported Formats.

For the purposes of this tutorial I will only focus on converting to epub and mobipocket formats, however please keep in mind that Calibre will also convert to many other file formats that are listed at the Ebook Reader Matrix Wiki.

EPUB = Nook, Sony PRS, Ipad, and etc...

MOBI/PRC = Amazon Kindle and the Cybook

For more detailed information please visit Elf's post Ebook formats. It is currently hosted on the Dreamwidth community called Ebooks. Or you may visit the Mobile Read Ebook Formats wiki post.

Programs You Will Need Conversion Software

Calibre

The first program you need to install before continuing and if you don't already have it is Calibre. Calibre is a ebook library management software that works on Windows, Linux,

Page 2: eBook Formatting Tutorial

and Macs. It also allows users to convert a variety of file formats into epub and mobipocket as well as a host of other file formats.

Word to HTML

In order to convert documents to epub or mobipocket you first need to find a program to convert your document into HTML. This is not as easy as it sounds, many programs add unnecessary code that will make editing the HTML much harder than necessary. It's important to find a good conversion program that fits your needs.

Corel WordPerfect X4

This is the program I use to convert all my Word documents and RTF (Rich Text Format) documents to HTML. There is a student version available. What puts this program on the top of my list is that there is a export to Plain HTML option and the program actually means Plain HTML. These html documents are easy to navigate because the program sticks to the basic html codes.

Microsoft Word 2007

If you go with Microsoft Word 2003 or 2007, it is highly recommend you choose the Filtered, HTML option off the drop down list. You may need to find a HTML cleaner to remove the extra code that Microsoft adds to the HTML. Notepad++ is free and has html tidy which may clear up the code for you to find your chapter headings.

The main reason I have not dumped MS 2007 is because 2007 has the ability to create Macros which I use to clean up my Word Docs before importing them into Corel WordPerfect X4 and exporting to HTML. Clean Up Your RTF has more information on what is needed to fix your RTF file before converting to HTML.

Adding ImagesCover Images

There are three methods of inserting a cover image onto your novel or document. Two are through Calibre and the other is directly through the HTML source code. However, only method 1 and 2 will show the covers on other device libraries or programs. Method 3 will display the cover when you open the ebook but no where else.

Method 1 - Convert E-books Button

When you hit the convert e-books button this dialogue box will open. In the Book Cover section you click on the button that is highlighted in the photo below.

Page 3: eBook Formatting Tutorial

Method 2 - Through the Edit Metadata Button

When you hit the edit metadata button in Calibre a box will open and it allows users to enter the ISBN number of the novel which will search automatically for a cover, or a user may manual select their own cover much the same way as method 1.

See picture below.

Page 4: eBook Formatting Tutorial

Method 3 - Manually insert HTML code into source code document.

<div style="text-align:center"> <img src="url to image goes here.jpg"> </div>

Inserting Illustrations and Images in the body of the story:

You technically only need to use this code to insert an image:

<img src="example.jpg">

However, if you'd like to insert and center the image this is the code that works in epub and mobipocket:

<div style="text-align:center"> <img src="example.jpg"> </div>

For some reason <center> does not work on images in epub. Neither does the override code: img {text-align: center;}

You can also set the width and height of the image.

<div style="text-align:center"> <img src="example.jpg" width="400" height="200"> </div>

If you want your image to start on a fresh page this is the code I manually insert before

Page 5: eBook Formatting Tutorial

the image.

<p style="page-break-after:always">&nbsp;</p>

One thing to keep in mind if you plan on having illustrations within the body of your converted story is that it's a good idea to have all the images and the HTML file in one folder before you upload to Calibre.

Creating a Table of ContentsInline Table of Contents (TOC)

Inline TOC's are where the chapters are directly listed on the HTML file at the beginning of the story.

Table of Contents

Chapter 1

Chapter 2

Chapter 3

If the inline table of contents was created correctly users can highlight and jump to the listed chapter. In order to insert a table of contents within the html source file users will have to create jump links and an anchor.

<p><a href="#chapter1">Chapter 1</a></p> (this goes at the top of your file where you are listing your TOC)

<a name="chapter1">Chapter 1</a> is the anchor.

You will need both elements inserted into your HTML source file for your inline TOC to work. Calibre should automatically detect the chapters and add them to the device's TOC.

This method will also add the listed Chapters to the device's TOC.

Here is an example of how the inline TOC looks like via Calibre Ebook Viewer. The TOC on the main big frame is what will show up within the story, the other TOC in the narrow sidebar TOC box is what will show up on the device TOC. It is always a good idea to check your document after conversion to make sure your TOC came out the way you expected.

Page 6: eBook Formatting Tutorial

The main disadvantage of using inline TOC is that many e-ink devices require a person to scroll through each Chapter one at a time. There is no way to start in the middle and work your way up or down the list. If the story has more than six chapters the inline TOC becomes less useful and a big waste of time and batteries. The faster method to navigate through 30 plus chapters is to access the device's TOC and navigate to the needed chapter via that method.

Now let's say you don't want to use up 2-3 pages for stories with over 40 chapters but you'd still like a TOC. The next section will explain how to create this effect.

Device Table of Contents Only

This type of Table of Contents is accessible via the menu on the ebook device, it will not insert the table of contents into the body of the document. You may use various computer software epub viewers to see the table of contents.

In your HTML source file you need to tag your chapters with <h2> or <h3>, for the sake of this tutorial <h2> is used for the following examples.

The next step is to tell Calibre to search for that tag and add it to the TOC.

There are two ways to set your TOC preferences in Calibre.

Page 7: eBook Formatting Tutorial

One is to use the convert story option, like in the following screencap.

When you click on that button a window will open on the Metadata. If you click the icon in the sidebar that says Table of Contents you'll get this menu and options.

In this screencap example //h:h2 is the expression used to tell Calibre to find all <h2> tags and add those to the TOC.

The Preferences menu offers another way to set your TOC preferences for all stories you convert.

Page 8: eBook Formatting Tutorial

TOC are a great way to navigate long documents and users do appreciate them.

Look and Feel - CSSHTML Cheatsheet

The Look and Feel section of Calibre is where you select the output format, font size, enter any extra CSS code, and etc.

Most of the settings in the Look and Feel section can be set in the main Preferenances, or they can be set on an individual basis.

Page 9: eBook Formatting Tutorial

Some basic knowledge of CSS is helpful if you plan on using the Extra CSS box. However, if you are unfamilar with css here are the basics codes I use and what each one does.

body { margin: 0; }p {margin-top: 0pt; margin-bottom: 0pt; padding: 0pt; text-indent: 15pt; text-align: justify;}h1 { text-align: center; }h2 {text-align: center; font-weight: 600; font-size: x-large; padding-bottom: 20pt; page-break-before: always;}h3 { text-align: center; padding-bottom: 20pt; font-weight: 600; font-size: xx-large }h4 { text-align: center; }h5 { text-align: center; }h6 { text-align: center; }img {text-align: center;}

body = <body> = this is where I set my body margin so on the device I don't have any margins.

p = <p> = paragraph tag. This is probably the most important tag if you want to specify how you want your paragraphs to look like. I always indent my paragraphs and remove any extra line space between them because it requires less pages on the device to flip through so the battery will last longer.

I have mine set to remove any margins before and after, no extra padding, a specific text-indent, and to always justify the text. The more css you know the more you can do with your paragraphs. However, since I'm mostly formatting for fiction reading I've kept it simple.

Page 10: eBook Formatting Tutorial

h2 = <h2> = Heading 2 - this is where I specify how I want my headers to look like. I do like my chapters to start on a fresh page so I added this code page-break-before: always; another important code is the padding-bottom: 20pt which adds some space after the Header. You can also adjust the font size and alignment.

Another code that I find useful is the page-break-before: always; this code forces a page break before each chapter heading so that the chapter header starts on a new page. It's not necessary, however it's aesthetically pleasing so I add it to my <h2> css code.

h3 = <h3> = Heading 3 - I use this for my Title and Author on the front page.

img = <img src=""> = Images and illustrations. This tag will only work for mobipocket to center your images.

The Extra CSS box is where you would add your embed font code if you had plans to embed fonts. (something I have not tested yet so cannot provide details on how it is done personally)

Tip: do not add page-break-before: always on multiple headers if you plan on using two headers on one page.

HTML Cheatsheet(I keep all these codes on a notepad so when I'm formatting I can refer back to it)

Insert a pagebreak into your document not just at chapter headers.

<p style="page-break-after:always">&nbsp;</p>

Prevent a Paragraph Indent

<p style="text-indent: 0pt"> </p>

Add a space between paragraphs

<p>&nbsp;</p>

Center your images

<div style="text-align:center"><img></div>

LRF/MOBI - Look and Feed CSS

body { margin: 0; }p {margin-top: 0pt; margin-bottom: 0pt; padding: 0pt; text-indent: 15pt; text-align: justify;}h1 { text-align: center; }h2 {text-align: center; font-size: larger; padding-bottom: 20pt; page-break-before: always;}h3 { text-align: center; padding-bottom: 20pt; }h4 { text-align: center; }h5 { text-align: center; }h6 { text-align: center; }

EPUB - Look and Feel CSS

Page 11: eBook Formatting Tutorial

body { margin: 0; }p {margin-top: 0pt; margin-bottom: 0pt; padding: 0pt; text-indent: 15pt; text-align: justify;}h1 { text-align: center; }h2 {text-align: center; font-weight: 600; font-size: x-large; padding-bottom: 20pt; page-break-before: always;}h3 { text-align: center; padding-bottom: 20pt; font-weight: 600; font-size: xx-large }h4 { text-align: center; }h5 { text-align: center; }h6 { text-align: center; }

HR elements (I do not use this one often. I normally use *** as a section seperator)

hr { width: 20%; text-align: center;padding-top: 2px;padding-bottom: 2px;border: 1px solid black; background-color: black; margin-left: 40%;}

Cleanup Your RTF or Word Doc for ConversionChange line breaks to paragraphs

Macros are your friend

Table of Contents

Change line breaks to paragraphsThis step is probably one of the most important steps in preparing your document to convert to HTML. This is where you find your chapters and make sure they are bolded or centered, center your images, and check for formatting errors.

The first thing I do when I open a document in Microsoft Word 2007 is hit the show hidden paragraph marks and other hidden symbols button.

This will reveal all the paragraph marks which should look like this: if your document does not display the paragraph mark then you may see something like this

instead. This is a line break mark. If your document has these instead of paragraphs

Page 12: eBook Formatting Tutorial

when you convert to HTML you will get <br> tags instead of <p> tags. This is not good since most css properties rely on the <p> tag to begin a new paragraph.

Calibre automatically indents <p> and more importantly recognizes the <p> tag.

Calibre's HTML2Epub will not recognize <br> tags, so you will not have line breaks or paragraphs if you are converting to EPUB and are using <br> tags instead of <p> tags. If you want paragraphs breaks and indents do not rely on <br>.

To fix this problem, you need to replace all the line marks for paragraph marks.

You can reach the replace all button on the Home Tab under Find or hit the buttons Control + F on the keyboard and select the replace tab.

In the Find what box enter ^l and in the replace with box enter ^p. This will tell the program to replace all line breaks with paragraph markers.

If you do nothing else in terms of formatting that is fine. Switching out the line breaks for paragraph tags is the important step in cleaning up your document for converstion to HTML.

Macros are your friendMacros can help speed up tasks in cleaning up your document as well as cleaning up the HTML after the file is converted to HTML.

If you are using Word 2007 locate the Developer's Tab.

You may have to go to Office Button then Word Options

Page 13: eBook Formatting Tutorial

-

Checkmark the box that says "Show Developer tab in the Ribbon.

Page 14: eBook Formatting Tutorial

Once you have enabled the show Developer Tab in ribbon you can navigate to the tab and find the Record Macro button.

To record a macro you you hit the Record Macro button.

This prompt should show up on your screen. Pick a name that makes sense to you and that is short like: Break2Paragraph or Lines2Paragraph or something that'll you'll easily recognize that's short.

Once you've named your Macro you can either hit okay or select a button for your macro. If you plan on adding your macro so the Quick Access Toolbar a button would help.

While the macro is recording you can use the Find and Replace function to replace all the ^l with ^p. After you have completed this step you can hit Stop Recording. Once you have done this hit Stop Recording in the Developer's Tab. Once you've hit stop recording your macros is ready for you to use on other documents.

Most of the macros I use are for cleaning up my HTML code but the one I use the most is the Lines2Paragraph to replace ^l with ^p.

You can create as many macros as needed.

Table of ContentsInline TOC

If you intend to create a inline Table of Contents you will need to take a few steps to set this up.

First, find your Chapters and apply the Heading 1 style to them.

Second, go to the location within your document where you want to insert your Table of Contents. Then go to the References Tab and hit the Table of Contents button. Scroll down until you select Insert Table of Contents. It should open with this box.

Page 15: eBook Formatting Tutorial

I unchecked the Show Page Numbers and removed the tab leader because on the ebook device the page numbers are not going to match up and the tab leader is too long for the smaller screens. If you only used Heading 1 to style your Chapter Headers then you only need to show 1 level. After you select your settings hit okay and all the chapter headers you applied Heading 1 style to should populate your Table of Contents.

Device Table of Contents Only

If you plan on only having a Device Table of Contents There are two ways to do this.

One way and the easiest way is to apply Heading 2 style to all your chapters and let the program automatically create the <h2> tags for your chapters.

If you are using a program that does not work well with applying styles to your chapter headers you can use a unique marker before and after your chapter: something like ##Chapter 1##

When your document is converted to HTML you can use the Find and Replace Function to search for ##Chapter and replace it with <h2>Chapter and then search for ## and replace that with </h2> The end result will give you the code <h2>Chapter 1</h2> which Calibre can then add to your device's table of contents.

The unique marker can be anything that's not normally in the body of the document.

Creating a macro to accomplish the Search and Replace isn't a bad idea if you plan on formatting many documents that share the same format.

Keep in mind <h2> is what I used as an example for this tutorial. You can use <h1> or <h3> for your chapter headers if you prefer. You also do not need to use the word chapter. Any text within the <h2> tags will be added to your Table of Contents.

Page 16: eBook Formatting Tutorial

Step-by-Step Conversion GuideFor the purpose of this guide the RTF format is used because it is not a proprietary format and will open in any Word program. Such as Open Office, Wordpad, Microsoft Office, and etc...

RTF to Epub/Mobipocket

Setting up Calibre for Conversion of HTML files

Preparing HTML for Conversion

RTF to Epub/MobipocketFor those that would like to convert straight from RTF to Epub/mobipocket here is what I found.

Starting off I make sure my RTF copy of the story has all the paragraphs indented and no extra line space between paragraphs. (Last time I tried with the extra line space back in version 4.7. Calibre did not remove the extra line space from the RTF like it will from HTML files. If it has changed please let me know.)

In your word processor program use the styles to turn your chapter headings into Heading 1 or Heading 2 (I use Heading 2) These will turn into your table of contents in Epub or mobipocket.

Set the font size to 12 or whichever font size you prefer.

At this point you can save and upload to Calibre.

Downsides, if you have image files within the RTF document they will not display on the epub/mobipocket version.

Upsides: For stories that don't have images this is a rather quick way to create your table of contents and get your story converted into Epub/mobipocket. You also only need Calibre and your choice of Word programs, Microsoft Word, Open Office, or Corel Wordperfect.

I do not use this method myself because html gives greater control over style elments in a story.

Setting up Calibre for Conversion of HTML filesThe first thing you'll need to do it enter your settings for Look & Feel.

Page 17: eBook Formatting Tutorial

Second is your Page Setup. This is where you select your device and set your page margins.

Page 18: eBook Formatting Tutorial

Third is Structure Detection which is where you enter your Table of Contents settings.

Page 19: eBook Formatting Tutorial

Preparing HTML for ConversionOnce you have your settings in place it's time to prepare your HTML file to convert to Epub or Mobipocket format.

The cleaner your HTML is the easier it'll be to convert your document and experience fewer problems.

After you have cleaned your Word Doc or RTF and you convert the file to HTML it is time to open your HTML in Wordpad or Notepad++ or Notepad, basically you'll need to use one of these programs to view the source code of your HTML document.

I prefer Wordpad to edit my HTML code so that's what I'm using in this tutorial.

Right click on the document and choose which program to open it in and select Wordpad.

Once your HTML file is opened it is time to add your chapter tags <h2> to everything you'd like added to your Table of Contents.

<h2>Chapter One</h2>

Page 20: eBook Formatting Tutorial

<h2>Author Notes:</h2>

and etc...

Calibre can detect and add those tagged chapters to the Table of Contents if you have gone through the steps and added //h:h2 to your chapter detection.

This is also when you would want to check to make sure your images embedded correctly.

If you plan on centering the images add this code you'll have to use. Epub won't recognize any other css code.

<div style="text-align:center"><img></div>

If your doc/rtf file was well made then you won't have to go through and search for <br> tags and replace those with <p>. Calibre automatically indents <p> tags. It does not indent <br>. Having said that it does not hurt to check for stray <br> tags or to clear out any other code that isn't <em>, <I>, <strong>, <b>, <p>, and ect...

Something to watch out for if you have multiple paragraphs using <strong> or <em> make sure the beginning of the paragraph starts with your <em> or <strong> tag. In web browsers if you forget to close a <em> tag all the rest of the text in the browser will remain <em> until it hits a closing </em> tag. That is not the case in Calibre. Calibre counts </p> as a closing tag for all formatting. Check to make sure your doc to html converting is adding your bold and italics tags at the beginning of your paragraphs.

Each conversion program has it's own coding that it adds and I use Microsoft Word Macros to fix/clean the HTML or to code my Chapter Headers with <h2>.

It is worth the time to explore Microsoft Word 2007 and learn how to create your own macros.

Once your HTML is ready, add it to Calibre.

Then highlight the story and click the button Convert E-Books:

You'll get a box like this and this is where you'd add the author name, title, novel summary, book cover, and etc...

Page 21: eBook Formatting Tutorial

After this go to Look and Feel:

Page 22: eBook Formatting Tutorial

This is where you can modify your Extra CSS or font size. Once you hit OK Calibre will convert your ebook for you.

From there you can download or transfer the file to your device.

I normally open it in Calibre Viewer to check my Table of Contents and scan through the ebook for obvious errors like from page 20-100 all the paragraphs are centered. If your HTML source file has an unenclosed center tag that would mess up the text. Or if your header tag isn't closed properly all the paragraphs afterwards will stay bolded.