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 LaTeX , 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 with the <md> tag; setting @number to yes on the <md> produces a numbered equation.
<!--********************************************************************
Copyright (C) 2019-2026 Robert A. Beezer
This file is part of PreTeXt.
PreTeXt is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 or version 3 of the
License (at your option).
PreTeXt is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************-->
<p>
<md>
\frac{d}{dx} \int_1^x \frac{1}{t}\, dt = \frac{1}{x}
</md>
<md number="yes">
\int_a^b f(x)\, dx = F(b) - F(a)
</md>
</p>
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>. Number equations by setting @number to yes on the <md> (or on individual <mrow> children).
<!--********************************************************************
Copyright (C) 2019-2026 Robert A. Beezer
This file is part of PreTeXt.
PreTeXt is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 or version 3 of the
License (at your option).
PreTeXt is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************-->
<p>
<md>
<mrow>x \amp = r\cos\theta</mrow>
<mrow>y \amp = r\sin\theta</mrow>
</md>
</p>
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.
