Skip to main content
\( \newcommand{\lt}{<} \newcommand{\gt}{>} \newcommand{\amp}{&} \)

Section4.5Customizations, Thin XSL Stylesheets

Stringparams (Section 4.4) are an easy way to effect global changes in the presentation of your writing. But putting ten of them on every command-line gets old and cumbersome fast.

You may also wish to customize your output in some stylistic way. This might be especially true for /PDF/print output. For example, you might wish to have every chapter heading of your book in a nice shade of light blue, with the title flush right to the margin, countered by a thick solid rule extending all the way right, to the edge of the paper. Notice that this does not affect your content, it is strictly presentation.

We have done several things to encourage such customizations. We have tried to put as much stylistic information as possible in the preamble and keep as much as possible out of the body. (There is always room for improvement on this score, please be in touch if you have a need.) For small adjustments the latex.preamble.early and latex.preamble.late stringparam are possible vehicles, though all the code to make light blue, flush-right rules is going to be messy on the command-line.

Instead, you can make a small XSL file, to use as input to xsltproc. The first thing it should do is import the stock PreTeXt file for the type of output you want to create. You can use an absolute path to the PreTeXt distribution (which will not be very portable), or utilize the mathbook/user directory and a relative path from there. The easiest thing to put in this file is elements like

<xsl:param name="latex.font.size" select="'20pt'" />
which is functionally equivalent to our example in Section 4.4. Values given on the command-line supersede those given in an XSL file this way.

You can augment the preamble with as much code as you like in the following way.

<xsl:param name="latex.preamble.late">
    <xsl:text>% Proof environment with heading in small caps&#xa;</xsl:text>
    <xsl:text>\expandafter\let\expandafter\oldp\csname\string\proof\endcsname&#xa;</xsl:text>
    <xsl:text>\let\oldep\endproof&#xa;</xsl:text>
    <xsl:text>\renewenvironment{proof}[1][\proofname]{\oldp[\scshape #1]}{\oldep}&#xa;</xsl:text>
</xsl:param>

There are a variety of things you can do generally, by overriding the imported XSL templates to change behavior, but such modifications are beyond the scope of this guide.