Mathematical expressions
Contents
Typesetting math
You can do latex inline like this:
Euler's formula is remarkable: $e^{i\pi} + 1 = 0$.
Euler’s formula is remarkable: \(e^{i\pi} + 1 = 0\).
You can use $$
to make an equation block like this:
$$ \frac{\partial \rho}{\partial t} + \nabla \cdot \vec{j} = 0 \,. \label{eq:continuity} $$
\[ \frac{\partial \rho}{\partial t} + \nabla \cdot \vec{j} = 0 \,. \label{eq:continuity} \]
The latex equation environment can be used directly. Stokes’ theorem is pretty cool:
\begin{equation}
\int_{\partial\Omega} \omega = \int_{\Omega} \mathrm{d}\omega \,.
\label{eq:stokes}
\end{equation}
\[\begin{equation} \int_{\partial\Omega} \omega = \int_{\Omega} \mathrm{d}\omega \,. \label{eq:stokes} \end{equation}\]
You can also refer to labeled equations, such as eq. \(\eqref{eq:stokes}\), with the syntax:
... such as [@eq:stokes],
The align
environment can also be used. Maxwell’s equations, eq. \(\eqref{eq:maxwell}\), are also tough to beat:
\begin{align}
\nabla \cdot \vec{E} &= \rho \nonumber \\
\nabla \cdot \vec{B} &= 0 \nonumber \\
\nabla \times \vec{E} &= - \frac{\partial \vec{B}}{\partial t} \label{eq:maxwell} \\
\nabla \times \vec{B} &= \vec{j} + \frac{\partial \vec{E}}{\partial t} \nonumber \,.
\end{align}
\[\begin{align} \nabla \cdot \vec{E} &= \rho \nonumber \\ \nabla \cdot \vec{B} &= 0 \nonumber \\ \nabla \times \vec{E} &= - \frac{\partial \vec{B}}{\partial t} \label{eq:maxwell} \\ \nabla \times \vec{B} &= \vec{j} + \frac{\partial \vec{E}}{\partial t} \nonumber \,. \end{align}\]
Mathjax
When doing md \(\rightarrow\) tex \(\rightarrow\) pdf, LaTeX takes care of the math, but to render the math in html, we use MathJax. Our html template includes the following code to ask MathJax to render it and number the equations:
$if(mathjax)$
<!--- MathJax stuff -->
<script type="text/javascript" src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } });
</script>
$endif$
References
University of California, Santa Cruz / ryan.reece@gmail.com / http://rreece.github.io↩︎
Joe University, Joeville / jane@joe.edu / http://jane.joe.edu↩︎