Posted on

Pandoc, Markdown, XeLaTeX, EPUB

EPUB documents are essentially a kind of html document as a collection of files which are zipped, and include html, css, and images. There are several ways of organizing these, but the most straightforward is one html document for each chapter (or section), a set of images organized in a subfolder, and a few metadata files regarding the collection. An epub document can be even simpler, and consist of a single html file, no images, and a few metadata files. Generating an EPUB can be as straightforward as editing html and the metadata files with a simple text editor, such as Atom. It is about this point that the simplicity ends.

Install XeLaTeX, Pandoc, Calibre, Atom, Kindlegen

These five tools provide the editing (Atom), typesetting (XeLaTeX, Pandoc), file generation (Pandoc, Kindlegen), and auditing (Calibre E-book Editor).

sudo apt-get install -y texlive-xetex
sudo apt-get install -y pandoc
sudo apt-get install -y calibre
sudo apt-get install -y atom

Note: Pandoc is ancient on the Debian distribution, best to install from Pandoc on Github, or better the Unofficial Nightly Builds. Install Amazon Kindlegen manually - See also the Amazon Kindle Publishing Guidelines

Elements of a Publication

There are several elements of a publication which recur from one publication to another. It is best to get organized. - Metadata: Title, Subtitle, BISAC code(s), pages, date of publication, date of revision, Author, etc. - There are two files for this in ebook generation: title.txt and metadata.xml - Cover image (this will be in several different sizes depending where it is used) - Title Page, Copyright, Dedication, Preface, Introduction, Content (Chapters), Acknowledgments, Glossary, Index - Note that the above sections can be one document, or several documents - Any fonts specifically used/embedded /fonts/ - Additional images (figures, tables) /images/ - Stylesheet stylesheet.css - Table of contents (should be generated) - Note that there are two tables of contents, one automatically created via the reader, and another in html (helpful for pdf files as well). - For a print edition, a full cover is needed, and one will want ISBN barcodes and perhaps a qrcode as well.

Edit, Transform, Publish

Editing all html by hand can be tedious, and certain markup can best be managed with markup tools such as Pandoc-flavored Markdown and XeLaTeX, and text transformation tools such as Pandoc. If no extended external font support is needed, markdown alone and some YAML/XML files are all that is needed. - Note that with XeLaTeX, one can do some extensive formatting, such as ShareLaTeX's nifty sample templates. - For more about Markdown, but sticking with Markdown Extra, which is generally suppored by Pandoc. Steps - Work out the document structure, list of files, get everything in place. - With all files or a set of example chapters, get the epub generation process and specific command line to use - Organize the final epub (and print pdf) into different marketplace versions, e.g., Apple iBooks (epub), Amazon Kindle (print, azw), Google Play Books (epub), Ingram (print, epub), Kobo (epub). For the Thai market, Meb and Okbee. Audio/Video - Create additional audiobook, spoken word, video directories (audiobooks via Findaway Voices), as well as spoken word audio and video distribution on all major channels via RouteNote. Note the shortform video opportunities (30-60 second Facebook, Instagram, Twitter). This is also where Blender creative content can come into play.