Section 31.1 Prerequisites
There are a handful of prerequisites to build an EPUB version of a book.
- You must use either the PreTeXt-CLI or the
pretext/pretextscript, since creating an EPUB file is a multi-stage process; building with
xsltprocis not supported.
- You must have
npmmust be installed. See Section F.1 for more on
You must use a publication file (referred to below as
source/directories/@externalso that images can be located and bundled (these are included by default if you use
pretext initfor your project).To use a non-generic cover image, the publication file must also have
epub/cover/@frontattribute that points to the cover image (JPEG or PNG, 2048 pixels tall, 1280 pixels wide). Absent an image provided, there will be an attempt to create a simple, generic cover image. See Subsection 44.6.1 for details about specifying a cover image.
If you use the
pretext/pretextscript, you will need to generate any source-defined images in SVG format for standard EPUB, and PNG format for Kindle.
Finally, if you are using the
pretext/pretextscript, you must install a local version of MathJax (the CLI will try to do this for you). We provide a bash script in
scripts/mjsrethat automates this process. See Section F.2 for instructions. As updates to the EPUB conversion are released, you may occasionally want to update your local copy of MathJax. Simply use the script referenced above.
To use the CLI, you will need to create a new target in the project manifest (project.ptx). The target should look something like the following.
<target name="ebook"> <format>epub</format> <source>source/main.ptx</source> <publication>publication/publication.ptx</publication> <output-dir>output/epub</output-dir> </target>
@namecan be whatever you wish, but the
<format>must be epub or kindle. You won't be able to tell the output files apart, so if you want both an epub and a kindle, name the output directory differently for each.