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
so 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/@coverthat points to the cover image (JPEG or PNG, 2048 pixels tall, 1280 pixels wide).
If you use the
pretext/pretext script, 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/pretext script, you must install a local version of MathJax (the CLI will try to do this for you). We provide a bash script in
scripts/mjsre that automates this process. See Section F.2 for instructions. As updates to the EPUB conversion are released, you may occasional 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>
@name can 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.