Section 19.4 LaTeX-generated images
PreTeXt makes it straightforward to embed LaTeX code that produces images (such as TikZ) into your source files. The PreTeXt-CLI basically just dumps your code out to your LaTeX file so that it compiles nicely. However, for HTML display, you will need SVG graphic files. This is where the
pretext/pretext
script comes in. Running the pretext/pretext
script frequently requires patience, particularly on Windows, so settle in with an experienced user before attempting the steps in this section. See Chapter 47 for complete details. Our example here just illustrates using TikZ to make a simple figure (the Hasse diagram of a poset), but lots of other LaTeX graphics packages can be used. One step required is to put the following three lines in the
<docinfo>
tag of your main file. <latex-image-preamble>
is used to set up the preamble that should be used for making SVG images from your PreTeXt source. Macros that you wish to use more broadly should be put inside <macros>
inside <docinfo>
.<latex-image-preamble> \usepackage{tikz} </latex-image-preamble>
The code in Listing 19.4.1 produces the following output:
Well, that’s not 100% true for HTML. If you just run
pretext build web
, your terminal will display a few warnings about not generating assets such as images. To generate the assets, we have to use the -g
flag. To generate the assets before building, on the command line we run the following command (on a single line). (Omitting the web
target will, by default, use the first target) in the project.ptx
file.)pretext build web -g