-
Notifications
You must be signed in to change notification settings - Fork 79
Using LaTeX and MathJax
The source code for proofs and definitions in "The Book of Statistical Proofs" uses a combination of Markdown, MathJax and LaTeX. On this page, we collect a set of rules and recommendations for applying LaTeX markup to typeset formulas. For more information, see the suggested notation for the StatProofBook.
- Use
$...$for in-line math, e.g.
Let $X$ be an $n \times 1$ random vector.- Use
$$...$$for stand-alone equations, e.g.
$$
y = Ax + b \sim \mathcal{N}(A\mu + b, A \Sigma A^\mathrm{T}) \; .
$$- Use
$$ \begin{split} ...&... \\ ...&... \end{split} $$to write multi-line equations, e.g.
$$
\begin{split}
M_y(t) &= \exp \left[ t^\mathrm{T} b \right] \cdot M_x(At) \\
&= \exp \left[ t^\mathrm{T} b \right] \cdot \exp \left[ t^\mathrm{T} A \mu + \frac{1}{2} t^\mathrm{T} A \Sigma A^\mathrm{T} t \right] \\
&= \exp \left[ t^\mathrm{T} \left( A \mu + b \right) + \frac{1}{2} t^\mathrm{T} A \Sigma A^\mathrm{T} t \right] \; .
\end{split}
$$- Label each stand-alone equation (also splitted ones) using
\label{eq:XYZ}, e.g.
$$ \label{eq:mvn-pdf}
f_X(x) = \frac{1}{\sqrt{(2 \pi)^n |\Sigma|}} \cdot \exp \left[ -\frac{1}{2} (x-\mu)^\mathrm{T} \Sigma^{-1} (x-\mu) \right] \; .
$$- You can then reference them in in-line math or other equations using
\eqref{eq:XYZ}, e.g.
$$ \label{eq:y-mgf-s2}
\begin{split}
M_y(t) &\overset{\eqref{eq:y-mgf-s1}}{=} \exp \left[ t^\mathrm{T} b \right] \cdot M_x(At) \\
&\overset{\eqref{eq:mvn-mgf}}{=} \exp \left[ t^\mathrm{T} b \right] \cdot \exp \left[ t^\mathrm{T} A \mu + \frac{1}{2} t^\mathrm{T} A \Sigma A^\mathrm{T} t \right] \\
&= \exp \left[ t^\mathrm{T} \left( A \mu + b \right) + \frac{1}{2} t^\mathrm{T} A \Sigma A^\mathrm{T} t \right] \; .
\end{split}
$$-
Do not use a vertical bar (
|) in in-line math, because it will be interpreted as indicating a table (Markdown).Solution: Use
\vert,\lvert,\rvertor\mid, depending on your specific formula and context. -
Do not use double blackslash (
\\) in in-line math, because it will be converted to a single backslash (HTML).Solution: Use
\\\\or\atop, depending on your specific expression and requirements. -
Do not use two consecutive curly opening braces (
{{) in any equation, because it will cause a build error (Jekyll).Solution: Put a space between the two braces in order to avoid the build error:
{ {. -
Do not put anything after
$$ending a stand-alone equation, because the equation will be displayed incorrectly.Solution: Always leave an empty line after
$$. Put\; ,,\; ;or\; .into the equation. -
Sometimes, in-line equations containing
}_fail to render due to interactions of Markdown and MathJax.Solution: Replace
_by\_. For more information, see this Stackoverflow post.