Kindle Formatting: The Complete Guide to Formatting Books for the Amazon Kindle

Home > Other > Kindle Formatting: The Complete Guide to Formatting Books for the Amazon Kindle > Page 7
Kindle Formatting: The Complete Guide to Formatting Books for the Amazon Kindle Page 7

by Joshua Tallent


  File Size

  Image file size is affected by most of the factors above. The biggest influence is the dimensions of the image, but color, resolution, and even file type are also contributors. If your book has a lot of images, you may want to play with these variables to reduce the image sizes. The DTP admin has stated that images larger than 64 kilobytes will be automatically reduced, but I have not been able to confirm that statement in my testing. Needless to say, your readers will not want to take up the majority of their memory with one book, so do take the image file size into consideration when preparing for publication.

  Rotation

  Most images will look fine on the Kindle just as they are, but there are times when rotating an image 90° is actually preferable, such as when you have a graph or chart that requires more width to be readable. If you do rotate an image, be sure to rotate it counterclockwise. The most natural way for most users to turn the device is clockwise, so rotating your image the opposite direction will make it show up properly. An example of this rotation can be seen in the chart on page 79.

  Handling Different Kinds of Images

  Following are some samples of how different kinds of images look on the Kindle. For a few of them I have included photos of both the Kindle 1 and Kindle 2 so you can see how the 16-level grayscale screen on the Kindle 2 affects some images.

  Figure 5.13: Chart on the Kindle 1.

  Figure 5.14: Graph on the Kindle 1.

  The Deniers by Lawrence Solomon. Image Courtesy of Richard Vigilante Books, http://richardvigilantebooks.com.

  Figure 5.15: Graph on the Kindle 2.

  The Deniers by Lawrence Solomon. Image Courtesy of Richard Vigilante Books, http://richardvigilantebooks.com.

  Figure 5.16: Map on the Kindle 1.

  The Rand McNally Road Atlas of Washington State. Image Courtesy of Rand McNally, http://randmcnally.com.

  Figure 5.17: Map on the Kindle 2.

  The Rand McNally Road Atlas of Washington State. Image Courtesy of Rand McNally, http://randmcnally.com.

  Figure 5.18: Photo of a person on the Kindle 1.

  Figure 5.19: Photo of a person on the Kindle 2.

  Figure 5.20: Photo of a landscape on the Kindle 1.

  Forsand, Norway.

  Figure 5.21: Photo of a landscape on the Kindle 2.

  Forsand, Norway.

  Inserting Images

  When your images are ready to go, you will need to create tags for them in your HTML. Inside that tag you will need to include the src and alt attributes. The src attribute contains the path to your image (the “source”). All of your images must be in the same directory as your HTML file, not in a subdirectory or somewhere else. Also, the Kindle does not allow images in books to be loaded from the Internet, even if Whispernet is turned on. The alt (alternate text) attribute contains a description of the image. The alt description is not actually required by the Kindle, but it is a good coding practice to include it.

  I suggest that you place large images in a centered paragraph that has had the first-line indent removed. For example:

 

  ..........

 

House in Norway



  Notice that the image tag has a closing forward slash at the end of it. This is used because, unlike most other tags, the image tag does not have a closing tag. It is a good coding practice to close your tags, and the “/” gives you that ability.

  If you add a caption below your image, you can also center it and add other effects like , , and .

 

Forsand, Norway is a beautiful vacation spot.



  Inserting images within the text of a paragraph is also possible. This is especially useful when you are inserting symbols that are not supported on the Kindle, such as math functions. For example:

 

Here, binomial coefficient is the binomial coefficient



  The align attribute in that tag gives the image a vertical alignment in relation to the surrounding text. The values that you can use in that attribute include:

  top — Aligns the top of the image with the top of the current line.

  middle — Centers the image vertically in the current line

  bottom — Aligns the bottom of the image with the bottom of the current line

  The default setting is bottom.

  Anchor Tags

  Anchor tags are used in HTML to create web and bookmark hyperlinks, and to mark bookmark anchors in the HTML file that can be linked to. You can create links to web pages in your Kindle book, and users who have Whispernet turned on will be taken to those web pages in the “Experimental” browser when they click on the links. For example:

  Kindle Formatting

  This feature opens up virtually endless possibilities. For instance, you could create a page with more information about the book on your website that the reader can easily visit. You could also create a survey on your website that the reader can fill out and submit directly from their Kindle in the web browser. Because the Kindle reads unencrypted Mobipocket books, you could even add links to samples of other books in Mobipocket format on your website, and readers can download those samples directly to their device.

  Special Links

  Speaking of samples, Amazon automatically generates a sample consisting of the first 10 percent of the book for all books uploaded through the DTP. These samples all have two unique links on their last page: one to the book’s product page and one to buy the book with one click. The product page that is shown with the first link is not the one you would see in the “Experimental” Web browser if you just went to the Amazon website. It is the same product page layout you see when you are browsing the Kindle Store on the device, which is much nicer and has easy-to-use buttons for purchasing the book directly from the Kindle.

  Well, you can use these links in your book, as well. For instance, you can create a listing of your other books that are for sale on the Kindle Store, with links to their product pages and links that allow users to buy the other books with one click.

  These links both require the Amazon ASIN for the Kindle book you are pointing to, which you can find on the book’s regular product page in the Product Details section. The links will not work properly for other items in the Amazon store.

  Product page link:

  https://www.amazon.com/gp/g7g/fws/anchor/detailPageEbook.xml?asin=xxxxxxxxxx

  Buy Now link:

  https://www.amazon.com/gp/g7g/fws/anchor/buyEbook.xml?asin=xxxxxxxxxx

  Bookmark Links

  Bookmarks can be defined in your book using the name attribute. For instance, you can mark all of your chapters with an anchor tag to make links in your Table of Contents.

 

Chapter 1



  To link to this anchor in your Table of Contents, just use a bookmark reference in the anchor tag by adding a hash symbol in front of the name you are linking to:

 

Chapter 1



  We will cover TOC mark-up in more detail on page 104.

  When you add named anchors within your book, it is a best practice to place them before any paragraph or heading tags, not after them. If you place them in after the tag, it is possible that the user will not see the formatting when the Kindle loads the content on the screen.

  Horizontal Rules

  While borders are not supported on the Kindle 1 and are only supported around tables on the Kindle 2, you can add a horizontal line in your text to break up the content using the
tag. I have used these in previous projects to indicate sidebars, to indicate a scene change in the text, and to bookend pull quotes. We will cover sidebar and pull quote markup with some examples on page 110.

  The Kindl
e formats the default horizontal rule as a gray line about 2 pixels high extending across almost the entire width of the viewable book area. You can assign a width of your own to the
tag using the width attribute. As in other places, the width attribute will accept units in pixels (width="100"), percent (width="50%"), em-units (width="30em"), or points (width="70pt"). The default display can be duplicated at a width of 475px, and you can extend the line to the edges of the book display area with a width="500". This is somewhat confusing when you consider the Kindle’s screen resolution and viewable book area (see page 74), but I have been unable to figure out the reason for this discrepancy.

  You can also assign a height (top margin) to your
tag, as described in the section on margins on page 68. Unfortunately, there is no way to make a
display flush left, but you can simulate a flush right style by placing the
inside one or more
tags. Examples of this can be seen on page 110.

  Unfortunately, the shading and vertical size of the
tag cannot be adjusted.

  Comments

  Many times it is helpful to place a comment in your HTML code so that anyone looking at the code later will have a description of what you were doing. They can also be useful for labeling parts of the book in your code or marking places you need to remember to work on as you are formatting your file. Comments in HTML are placed in a special tag like this:

 

  These are never seen by the reader, and should only be used to make behind the scenes notes in the code.

  Page Breaks

  There are times when you will want to force some content to start on a new screen (“page”) in your book. These page breaks are not hard to format, but they require a special tag that is not actually HTML: . The “mbp” actually stands for “Mobipocket,” since the Kindle eBook format is based on the Mobipocket eBook format. You should place one of these page break tags in front of each chapter in your book, and possibly in front of other items, like images, which may need to be forced to the next page.

 

 

Chapter 1



  ..........

 

 

House in Norway



 

Forsand, Norway is a beautiful vacation spot.



  Microsoft Word inserts a page break like this:

 


  The effectiveness of that tag is not guaranteed, however, so I suggest you replace it with the tag.

  Special Characters and Inserting Symbols

  The Kindle format supports a wide variety of Unicode characters, including most Latin characters, (Basic Latin; Latin-1; Latin Extended A and B; and Latin Extended Additional); all of the Greek characters and pre-composed Greek characters with diacriticals (Greek and Greek Extended); a variety of mathematical symbols; as well as some arrows, musical notations, and Dingbat symbols. A complete list of the supported character sets can be found on page 155.

  To ensure that these characters display properly, you will need to convert them into HTML entities. An entity is a code that tells the Kindle what character to display in the text. Entities all start with an ampersand (&) and end with a semicolon (;). The interior text can be a name (é), a decimal number (é) or a hexadecimal number (é), but the name is usually easiest to remember. For instance, if you have the word “résumé” in your book, it can be coded like this in the HTML:

  résumé

  I have included a chart in Appendix C that gives you the valid codes for many of the common characters in the Latin-1 character set. In the Book Tools download section of my website I have included a printable list of all of the characters in the entire Latin range, the Greek and Greek pre-composed characters, and a selection of other common symbols that are supported on the Kindle. In that download you will also find a Perl script that you can run on your HTML file to convert the common Latin-1 characters into entities automatically.

  To find the characters in the Latin-1 character set manually in Windows, you can do a search in your HTML document using this Regular Expression:

  [€-ÿ]

  (Note: Due to a bug, this does not work in Notepad++ yet.) Those are the first (€) and last (ÿ) characters in the Latin-1 character range. To type those characters into the find box in your HTML editor program, hold down the Alt key on your keyboard and type the 4-digit number for the character using the number pad on your keyboard (not the numbers above the main keys): 0128 and 0255. Alternatively, you can use the Character Map utility that comes with Windows to copy these characters. That can be found in the Start Menu, under Programs, Accessories.

  Macintosh users have similar options for inserting Latin-1 characters, and OS X comes with a built-in character map of its own. However, you may find that characters 0128 and 0255 on your Mac do not look the same as what you see printed here.

  If you insert any special characters into your book, it is best to make the encoding of the file UTF-8, not ASCII. This is usually an option in the Save As menu of your text editor. Also, to ensure the Kindle properly formats the entities, be sure to but the UTF-8 meta tag at the top of your HTML:

 

  Foreign Languages

  The Kindle supports the use of Greek text, including the full range of pre-composed characters with diacritics, but it does not support any other non-Latin foreign language characters.

  To insert other languages in your text, you will need to use images. A height of 14-16 pixels is usually good when you are taking screen shots or creating images of text. See the images section on page 89 for information on formatting inline images.

  Non-breaking Spaces

  During conversion to HTML, Microsoft Word inserts some non-breaking spaces ( ,  , U+00A0;) where there are tabs in the original file. It will also sometimes place a non-breaking space and a regular space between sentences. While sometimes these non-breaking spaces do not actually cause problems, they can become problematic when they have been placed at the beginning of a paragraph to create indentation. For example:

 

There were two or three things that I wanted to know. I do not care about a mystery. So I began to inquire.



 

            It took me two weeks to find out what women carry in dress suit cases. And then I began to ask why a mattress is made in two pieces....



  In general, it is best to remove the non-breaking spaces that Word inserts. I usually change all of the non-breaking spaces in a Kindle HTML file into regular spaces, and then do a search to find all of the places where two or more spaces occur. That allows me to fix any weird formatting problems, of which these extra spaces are usually a symptom.

  Hyphenated Words

  You are likely to find a character known as a soft hyphen (­, ­, U+00AD) at various places throughout your book. Publishers and book layout tools commonly add this character inside long words at syllable breaks to allow the word to break into two parts at the end of a line. In print books, this makes full justification much nicer because the flow of the text is not interrupted by large amounts of space on a line left by a long word wrapping to the next line. The Kindle does not support the soft-hyphen character; it actually displays it in the text, regardless of whether or not the word is breaking across a line break. You will need to remove all of these characters from your book.

  However, be careful when removing them because sometimes the soft hyphens are actually in places where a regular hyphen should be, such as between compound words with three or more pieces.

  Special Combination Letters

  In some books, especially those that start out as PDF files from a publisher, you will find that some combinations of letters have been replaced with entities for combined letters called ligatures. The most common of
these ligatures are:

  ff — ff

  fi — fi

  fl — fl

  ffi — ffi

  ffl — ffl

  These are inserted by some publishers to ensure proper display and printing of the character combinations in the font chosen for the print book. Replacing them can be a small chore, especially since the conversion process may add a space after the entity when there should not be one. So, the word “find” may look like “fi nd”. The replacement process can be automated a little bit by doing a find and replace on the most unique words in the book, and by using this regex, switching out the entity as needed:

  Find: ([a-z])(ff)([a-z])

  Replace: 1ff2

  Other than that, you will just have to take some time to look at all of these instances and determine if the space after the entity is needed or not.

  Conclusion

  The formatting information in this chapter will be some of the most important information you have available as you convert your book. Be sure to refer to the sections above as often as necessary. In the next chapter we will look at some real-world examples of eBook formatting.

 

‹ Prev