Jupyter Book uses MathJax for typesetting math in your book. This allows you to have LaTeX-style mathematics in your online content. This page shows you a few ways to control this.
For more information about equation numbering, see the MathJax equation numbering documentation.
In-line math
To insert in-line math use the $
symbol within a Markdown cell.
For example, the text $this_{is}^{inline}$
will produce: thisinlineis.
Numbering equations
MathJax has built-in support for numbering equations. This makes it possible to easily reference equations throughout your page. To do so, add this tag to a block equation:
\tag{<number>}
The \tag
provides a number for the equation that will be inserted when you refer
to it in the text.
For example, the following code:
equation 1
$$
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\tag{1}
$$
equation 2
$$
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\tag{2}
$$
equation 999
$$
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\tag{999}
$$
Results in these math blocks:
equation 1 ∫∞0x3ex−1dx=π415
equation 2
∫∞0x3ex−1dx=π415equation 999
∫∞0x3ex−1dx=π415Automatic numbering
If you'd like all block equations to be numbered with MathJax, you can activate
this with the following configuration in your _config.yml
file:
In this case, all equations will have numbers. If you'd like to deactivate
an equation's number, include a \notag
with your equation, like so:
Linking to equations
Adding \label{mylabel}
to an equation allows you to refer to the equation elsewhere in the page. You
can define a human-friendly label and MathJax will insert an anchor with the following form:
If you use \label
in conjunction with \tag
, then you can insert references directly to an equation
by using the \ref
syntax. For example, here's an equation with a tag and label:
$$
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\label{mylabel1}\tag{24}
$$
$$
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\label{mylabel2}\tag{25}
$$
Now, we can refer to these math blocks with \ref
elements. For example,
we can mention Equation 24 using \ref{mylabel1}
and
Equation 25 with \ref{mylabel2}
.
Note that these equations also have anchors on them, which can be used to link to an equation from elsewhere, for example with this link text: