Template for Writing an eBook
This is a new version of the classic template for eBooks.
Why using such a complex setup instead of just using a simpler tool like Word or Pages?
The primary motivation of this template is versioning. Being able to use plain text files as input for the book brings the possibility of versioning each change individually using Git, Subversion or any other similar tool. This also opens up the door to collaboration among team members when editing a document.
The second motivation is to separate the presentation and the layout of the final book from its contents. Other output file types could be added in the future.
This also brings the possibility of using any text editor in just about any operating system; files are just plain text files that can be edited with gEdit, Notepad, Emacs, Vim, TextEdit, or any other similar tool.
Markup languages like Markdown or Asciidoc (used in this template) are simpler and more readable than LaTeX or other SGML-like languages, making the files readable and lean even when edited in a text editor without any syntax highlighting or formatting support.
Finally, being able to streamline the creation of the three versions of the book in just one command-line operation allows the whole setup to be automatized.
The choice of Asciidoctor comes from the following features:
This toolkit started as a pure LaTeX workflow in 2009. In late 2011 the system moved to Markdown and it used Pandoc to generate the artifacts. In 2012 the choice was AsciiDoc, and in 2016 this new system was finally developed, using AsciiDoctor.
How To Use
master.asciidoc file at the root of this project provides the guiding
structure of the book. Chapters can be shuffled around, independently of their
contents or internal structure.
Individual chapters are stored in the
chapters folder, one file per chapter.
Images are stored as PNG files in the
images folder. Data files (XML, CSV,
etc,) are located in the
The Makefile creates a temporary
_build folder, copies all the different
elements in it (the master file, the chapters and the images) and commands the
execution of the whole toolchain in order to get the final result:
UML diagrams are generated by text through PlantUML.
makecommand. This will create the PDF, ePub and HTML versions of the book.
make kindleeach generate the specified version of the booklet.
make cleanremoves the
After the build process completes, the compiled eBooks will be available
Before using this template, make sure to have Homebrew and Rubygems installed, then run the following commands to install the required dependencies:
$ xcode-select --install # (required for nokogiri, itself a requirement for asciidoc-epub3) $ brew install plantuml glib gdk-pixbuf cairo pango cmake libxml2 $ gem install pygments.rb $ gem install kindlegen $ gem install asciimath $ gem install asciidoctor $ gem install asciidoctor-pdf --pre $ gem install asciidoctor-epub3 --pre $ gem install asciidoctor-diagram $ gem install asciidoctor-mathematical
Install the font dependencies for
cd ~/Library/Fonts curl -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmex10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmmi10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmr10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmsy10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/esint10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/eufm10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msam10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msbm10.ttf
If you experience compilation problems with
asciidoctor-mathematical you can
brew link gettext --force if needed. Follow the installation instructions from
the project in case of
See the LICENSE.md file.