Skip to main content

The PreTeXt Guide

Section 47.13 pretext/pretext Capabilities

List 47.13.1. pretext/pretext Capabilities
Again, the command pretext -h will remind you of the various options for the script and is the most likely list to be correct and up-to-date. The following is a brief summary, in general terms, of what is possible.
Complete Conversions
With -c all and various choices of the format (-f) the script will execute a complete conversion. In some cases, this is a convenience compared with just using the xsltproc processor. In other cases the conversion is very complex and multiple (arcane) output files must be packaged up in very specific ways and no author would want to manage it all. Conversion to EPUB is one example ([provisional cross-reference: epub conversion]).
Graphics
has a variety of languages for specifying images, such as xypic, pgfplots, and TikZ. By including the necessary packages or setup commands in docinfo/latex-preamble, these can all be generated at once, in the manner of the example earlier.
Asymptote
Images described by the Asymptote language can be processed in a manner entirely similar to that for images described with graphics languages. By default an online server will be used for the image generation, or you may elect to use an asy executable on your system and locatable via the pretext.cfg configuration file.
Sage Plot
If you have a version of Sage installed on your system, you can specify the path to the executable and obtain images described by Sage code. See Subsubsection 4.14.3.4 for more information.
All Formats
If you desire images in a wide variety of formats, the option -f all will oblige.
YouTube Thumbnails
For each YouTube video (or itemized playlist) you specify, the script will go the YouTube site and grab a thumbnail image for that video (or first video from the itemized playlist). These get used in static formats, such as PDF.
Preview Images
Like a thumbnail for a YouTube video, other interactive content can benefit from a still image for use with static formats. Our strategy is to render the content with a “headless” web browser and capture an image automatically. For example, you might write some custom Javascript to allow a reader to interact with a graph, and you would like an image of the graph, along with its interactive sliders and checkboxes, to appear in the PDF version of your text. Recognize that this image will necessarily be the content at its initial start-up. Get a screenshot manually if you want something better.
Note that for all this to work, you need to properly serve your project’s HTML output with the interactive content. (A local server may be a possibility, but we have not tried. See Section 5.11. Or you can try a temporary public server, see Section 5.12). Then you need to announce the location of this hosted HTML, which is accomplished via a “base URL” in a publication file. Start at Subsection 29.1.5 for details on this publisher variable. Note that the chunk level in your publication file used in this process must match the chunk level used when you build your HTML output, and mismatches for other publisher variables could have some ill effects.
The automatic screenshots will then be managed by the Python playwright package, which you will need to have installed in your Python virtual environment (see Section C.3).
Mathematics Representations
Conversions to EPUB, braille, and other formats require creating conversions of mathematics elements locally as part of the conversion. This requires having MathJax installed locally, see Appendix F. Structured files of these representations can be obtained by setting the component with -c math. Possible formats (-f) are svg, mml (MathML), braille and speech.
WeBWorK
Various conversions of WeBWorK problems are facilitated through communication with a WeBWorK server. This server is specified as an argument to the -s option. See Chapter 7 for the details of this procedure.