Contents
Menu

Math Tutorials and More
by George

Math Tutorials and More
by George

Making an EPUB File

We have discussed most of the types of files that occur in an EPUB document. The main content is contained in the HTML files. The appearance can be modified by using CSS style files. The other files are organizational. It is useful to have both an NCX table of contents and an HTML table of contents. The HTML table of contents contains links to the various sections of the document and can be seen as you page through the document. An example HTML table of contents is shown below.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>

<title>Table of Contents</title>

<style>

p {margin-bottom: 1em; text-align: left}

p.ind {margin-left: 2em;}

</style>

</head>

<body>

<p><a href="intro.php">Introduction</a></p>

<p><a href="chap1.php">Chapter 1</a></p>

<p><a href="chap2.php">Chapter 2</a></p>

<p class="ind"><a href="chap2.php#sect1"> Section 2.1</a></p>

<p class="ind"><a href="chap2.php#sect2"> Section 2.2</a></p>

<p><a href="chap3.php">Chapter 3</a></p>

<p><a href="chap4.php">Chapter 4</a></p>

<p><a href="chap5.php">Chapter 5</a></p>

<p><a href="refs.php">References </a></p>

</body>

</html>

This code will produce the following table of contents

Introduction

Chapter 1

Chapter 2

Section 2.1

Section 2.2

Chapter 3

Chapter 4

Chapter 5

References

You can also have an HTML cover page if you wish. This is a standard XHTML file with the cover image specified in the tag

<img src="…" alt="…" style="height: 100%;" />

Amazon requires cover images to be 600x800 pixels and NOOK requires them to be 547x730 pixels.

The final step in making an EPUB document is to zip the files into a file with extension .epub, e.g., MyBook.epub. There is one caveat. The file mimetype must be the first file added and it must be placed in the EPUB file uncompressed. Not all zip programs do this easily. One program that does this is the command line program zip.exe that can be downloaded from the site http://stahlworks.com/dev/index.php?tool=zipunzip. To add mimetype to the file MyBook.epub you would use the command

zip MyBook.epub -DX0 mimetype

To add the remaining files you would use

zip MyBook.epub -rDX9 META-INF OEBPS

At this point is a good idea to validate your epub file. You can do this online at validator.idpf.org or you can download a java command line validator at github.com/IDPF/epubcheck/releases/.

A good viewer for EPUB files is Adobe Digital Editions. It can be downloaded at http://www.adobe.com/products/digitaleditions.