Skip to main content

The PreTeXt Guide

Chapter 13 Mathematics

Since PreTeXt was originally called MathBook XML, you will not be surprised to learn that it has robust support for mathematical formulas. Inside the tags that delimit math environments, your code is basically , with the caveat that you must be careful with < and & since they are special symbols for XML. When typing math in your PreTeXt code, use \lt for <, use \gt for > (not strictly necessary, but good for symmetry), and use \amp for &. In HTML, MathJax is used to render math, so PreTeXt generally supports the things that MathJax does “out of the box” (with the addition of amsmath) without the need for too many additional packages to be loaded.
For inline math, just wrap things in the <m> tag. For example, \(a^2 + b^2 = c^2\) is produced by <m>a^2 + b^2 = c^2</m>. We get displayed equations via the <me> and <men> tags; the latter produces a numbered equation.
    \frac{d}{dx} \int_1^x \frac{1}{t}\, dt = \frac{1}{x}
  <men xml:id="eqn-ftc">
    \int_a^b f(x)\, dx = F(b) - F(a)
Listing 13.0.1. Displayed equations
The code in Listing 13.0.1 produces the following output:
\begin{equation*} \frac{d}{dx} \int_1^x \frac{1}{t}\, dt = \frac{1}{x} \end{equation*}
\begin{equation} \int_a^b f(x)\, dx = F(b) - F(a)\tag{13.0.1} \end{equation}
For a collection of equations all aligned at a designated point, use <md> and <mrow>. (There’s also <mdn> for numbered equations.)
    <mrow>x \amp = r\cos\theta</mrow>
    <mrow>y \amp = r\sin\theta</mrow>
Listing 13.0.2. Aligned equations
The code in Listing 13.0.2 produces the following output:
\begin{align*} x \amp = r\cos\theta\\ y \amp = r\sin\theta \end{align*}
Because most of the early adopters of PreTeXt have been mathematicians, there are lots of additional features supported in terms of mathematics. See Section 4.9 for further details.