Pages

Friday, March 15, 2013

TABLES OF CONTENT

Kindle wants two versions of your table of contents. One is the html version, which shows up in the front of your book. The other is the "navigation" version, which only makes an appearance if you press a button at the top of the page.

The html version is pretty straightforward. It consists of some top matter, followed by a list of the chapters, given twice. The first time it's the name of the anchor you've used in the body of your novel. The second time is the way it will be displayed on the Table of Contents page.

Before we do that, however, it's time to get organized for Kindling your book. Create a new and dedicated folder on your hard drive.

Into this empty folder you will put the html version of your text and copies of any jpg images you want to appear in your e-book (chapter-start images, title page image, embedded cover image).

Plus three more files: the html toc, the navigation toc (called the ncx file), and a rather fussy and complicated little item called the opf file.

I'm going to print here a template of an html table of contents file you can copy and paste into Notepad++. Modify it by changing "your_book" to the name you've chosen. Now that I've done a few books, I call all of them "book.html" so I don't have to make any title related changes. Notepad++ gives the path so I don't get confused when I have several books open at the same time.

If your book file doesn't have the extension "html" you'll need to change that also. The only other choice is "htm." How do you know which version you've got? Open the book in Notepad++ and look at the tab at the top of the page. It will show the extension.

If your book has fewer chapters, delete the unneeded entries. If you need more, copy and paste an entry and modify to suit. If you don't want to use a title page, remove that line. If your copyright page has no acknowledgments, change the listing to follow your own personal reality. If you'd rather have your list say "Chapter One" instead of "Chapter 1" – here's your chance to fix that for all your chapters.

When you've made the appropriate changes, click File, select Save As, and navigate to your new book folder. Name the file "toc" (without the quotes). Click in the "Save as type" window and select "Hyper Text Markup Language file."

Okay, here's the text of the html toc:

<html>
<head>
<title>Table of Contents</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<h2>Table of Contents</h2>

<div id="toc">
<div><a href="your_book.html#title_page">Title Page</a></div>
<div><a href="your_book.html#copyright">Copyright Page</a></div>
<div><a href="your_book.html#chap_1">Chapter 1</a></div>
<div><a href="your_book.html#chap_2">Chapter 2</a></div>
<div><a href="your_book.html#chap_3">Chapter 3</a></div>
<div><a href="your_book.html#chap_4">Chapter 4</a></div>
<div><a href="your_book.html#chap_5">Chapter 5</a></div>
<div><a href="your_book.html#chap_6">Chapter 6</a></div>
<div><a href="your_book.html#chap_7">Chapter 7</a></div>
<div><a href="your_book.html#chap_8">Chapter 8</a></div>
<div><a href="your_book.html#chap_9">Chapter 9</a></div>
<div><a href="your_book.html#chap_10">Chapter 10</a></div>
<div><a href="your_book.html#chap_11">Chapter 11</a></div>
<div><a href="your_book.html#chap_12">Chapter 12</a></div>
<div><a href="your_book.html#chap_13">Chapter 13</a></div>
<div><a href="your_book.html#chap_14">Chapter 14</a></div>
<div><a href="your_book.html#chap_15">Chapter 15</a></div>
<div><a href="your_book.html#chap_16">Chapter 16</a></div>
<div><a href="your_book.html#about">About the Author</a></div>
</div>
</body>
</html>


The chapter list ends with an entry for an "About the Author" section. Delete if you don't need it. Or leave it there and add that item to your book just as if it were another chapter. Don't forget to create the appropriate anchor tag for the new section. Obviously, the names of all anchors in your book must match those listed in the "a ref=" part of the toc.

The navigation Table of Contents has a lot of boilerplate junk at the top, a few easy to modify variables (title, author), and a list of the items in your book (toc, copyright page, chapters, about the author).

It goes like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">

<ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/">

<head>
<meta name="dtb:uid" content="268a4670-ca8a-11e2-8b8b-0800200c9a66""/>
<meta name="dtb:depth" content="1"/>
<meta name="dtb:totalPageCount" content="0"/>
<meta name="dtb:maxPageNumber" content="0"/>
</head>

<docTitle>
<text>Your Title</text>
</docTitle>

<docAuthor>
<text>Lastname, Firstname</text>
</docAuthor>

<navMap>
             
<navPoint id="cp" playOrder="1">
<navLabel><text>Copyright Page</text></navLabel>
<content src="your_book.html#copyright"/>
</navPoint>   

<navPoint id="toc" playOrder="2">
<navLabel><text>Table of Contents</text></navLabel>
<content src="toc.html"/>
</navPoint>

<navPoint id="c1" playOrder="3">
<navLabel><text>Chapter 1</text></navLabel>
<content src="your_book.html#chap_1"/>
</navPoint>

<navPoint id="c2" playOrder="4">
<navLabel><text>Chapter 2</text></navLabel>
<content src="your_book.html#chap_2"/>
</navPoint>

<navPoint id="c3" playOrder="5">
<navLabel><text>Chapter 3</text></navLabel>
<content src="your_book.html#chap_3"/>
</navPoint>

<navPoint id="c4" playOrder="6">
<navLabel><text>Chapter 4</text></navLabel>
<content src="your_book.html#chap_4"/>
</navPoint>

<navPoint id="c5" playOrder="7">
<navLabel><text>Chapter 5</text></navLabel>
<content src="your_book.html#chap_5"/>
</navPoint>

<navPoint id="c6" playOrder="8">
<navLabel><text>Chapter 6</text></navLabel>
<content src="your_book.html#chap_6"/>
</navPoint>

<navPoint id="c7" playOrder="9">
<navLabel><text>Chapter 7</text></navLabel>
<content src="your_book.html#chap_7"/>
</navPoint>

<navPoint id="c8" playOrder="10">
<navLabel><text>Chapter 8</text></navLabel>
<content src="your_book.html#chap_8"/>
</navPoint>

<navPoint id="c9" playOrder="11">
<navLabel><text>Chapter 9</text></navLabel>
<content src="your_book.html#chap_9"/>
</navPoint>

<navPoint id="c10" playOrder="12">
<navLabel><text>Chapter 10</text></navLabel>
<content src="your_book.html#chap_10"/>
</navPoint>

<navPoint id="c11" playOrder="13">
<navLabel><text>Chapter 11</text></navLabel>
<content src="your_book.html#chap_11"/>
</navPoint>

<navPoint id="c12" playOrder="14">
<navLabel><text>Chapter 12</text></navLabel>
<content src="your_book.html#chap_12"/>
</navPoint>

<navPoint id="c13" playOrder="15">
<navLabel><text>Chapter 13</text></navLabel>
<content src="your_book.html#chap_13"/>
</navPoint>

<navPoint id="c14" playOrder="16">
<navLabel><text>Chapter 14</text></navLabel>
<content src="your_book.html#chap_14"/>
</navPoint>

<navPoint id="c15" playOrder="17">
<navLabel><text>Chapter 15</text></navLabel>
<content src="your_book.html#chap_15"/>
</navPoint>

<navPoint id="c16" playOrder="18">
<navLabel><text>Chapter 16</text></navLabel>
<content src="your_book.html#chap_16"/>
</navPoint>

<navPoint id="about" playOrder="19">
<navLabel><text>About the Author</text></navLabel>
<content src="your_book.html#about"/>
</navPoint>

</navMap>

</ncx>


Copy and paste into Notepad++. (As before, you'll lose the colored text. Keep the blog post open on your browser to remind you what parts to address.) Modify to suit your book, add or subtract entries, etc. Note the extension (html or htm) and so forth.

Make sure the "play order" number goes up one for each entry. I don't know what happens if you skip a number. (So I advise you not to.) The "navPoint id" doesn't have to be what I've used, but each one needs to be unique to the list. My advice, stick to what I've given here. It works.

Kindle's navigation feature (the line at the bottom of the page that shows where you are in relation to the whole book) was adapted from a format for something called the Digital Talking Book. That's where you get weird terms like "playOrder." Just play along and create your version of the file according to these specs.

The first line in the Head section reads:

     <meta name="dtb:uid" content="268a4670-ca8a-11e2-8b8b-0800200c9a66""/>

If you had an ISBN for your book, you could use it here. But ISBNs can be expensive—Bowker (the official source) wants hundreds of dollars for one, but heavily discounts if you buy in bulk. Others (slightly less official?) sell them for various prices. They're not needed for Kindle books because Amazon supplies a unique number when you publish on KDP.

The number I show here came from this site, which uses the time of day when you visit them and a code based on the hardware configuration of your computer to create a unique number. Just make sure you use the same number in the opf file.

Mobipocket Creator slapped together an opf file when you used it to make the html version of your novel. Assuming you saved the file when Mobipocket asked, you could retrieve the id number they created for you. It's just not as cool as the one from famkruithof.

More about the dreaded opf file in the next post.

No comments:

Post a Comment

Comments are welcome -- and moderated by me. Please be patient.