Math Typesetting Cheatsheet

These are my notes to myself. There are some particulars to mathjax in HUGO that were found after searching; so, I have recorded these here for easy access. In general, HUGO doesn’t behave well with mathjax and requires extra \ to escape \. This means whereever there is \\ you will need \\\\ for HUGO. This list is not at all trying to be comprehensive. It covers common syntax for High School Math. Use the links below for detailed documentation on MATHJAX and KATEX.

Common Notation: Algebra → Calculus

Superscripts

$x^2$
$x^{123}$

$x^2$
$x^{123}$


Subscripts

$x_1$
$x_{123}$

$x_1$
$x_{123}$


Parenthesis Sizes

$( \big( \Big( \bigg( \Bigg($

$( \big( \Big( \bigg( \Bigg($


Spacing

# \quad creates a 1 em space
$f(x)=3x^3-x^2-10x\quad$ and $\quad g(x)=-x^2+2x$ 

# \thinspace creates a ³∕₁₈ em space
$f(x)=3x^3-x^2-10x\thinspace$ and $\thinspace g(x)=-x^2+2x$

$f(x)=3x^3-x^2-10x\quad$ and $\quad g(x)=-x^2+2x$

$f(x)=3x^3-x^2-10x\thinspace$ and $\thinspace g(x)=-x^2+2x$


Fractions

$\frac{2}{x}$
$\dfrac{2}{x}$

$\left|\frac{x}{x+1}\right|$

$\frac{2}{x}$

$\dfrac{2}{x}$

$\left|\frac{x}{x+1}\right|$


Root(s)

$\sqrt{5}$
$\sqrt[4]{5}$

$\sqrt{5}$
$\sqrt[4]{5x+9}$


Common Symbols

$45^{\circ}$  //degrees
$\pi$
$\alpha$
$\theta$
$\pm$
$\not=$
$\approx$
$\infty$
$\in$
$\cap$
$\cup$
$\le$
$\ge$
$\to$
$A=\pi r^2$

$45^{\circ}$
$\pi$
$\alpha$
$\theta$
$\pm$
$\infty$
$\in$
$\not=$
$\approx$
$\cap$
$\cup$
$\le$
$\ge$
$\to$
$A=\pi r^2$


Domain

$\mathrm{D}_f:(-\infty,\infty)$

$\{\bigl(x,f(x)\bigr)\mid x\in A \}$

# HUGO-MARKDOWN - extra \
$\\{\bigl(x,f(x)\bigr)\mid x\in A \\}$

$\mathrm{D}_f:(-\infty,\infty)$

$\{\bigl(x,f(x)\bigr)\mid x\in A \}$


Color

$\{\,\bigl(\colorbox{yellow}{$x,f(x)$}\bigr)\mid x\in A \}$

$\{\,\bigl(\colorbox{yellow}{$x,f(x)$}\bigr)\mid x\in A \}$


Trigonometry


$\cos (2\theta) = \cos^2 \theta - \sin^2 \theta$

$\cos (2\theta) = \cos^2 \theta - \sin^2 \theta$


Logarithms

$\log_5{x}$
$\log_{2a}{x}$ 
$\ln{x}$

$\log_5{x}$
$\log_{2a}{x}$
$\ln{x}$


Piece-wise defined functions

# Note: put extra \\ for HUGO/MARKDOWN

$f(n) =
\begin{cases}
n/2,  & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}$

$f(n) = \begin{cases} n/2, & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd} \end{cases}$


Calculus


$\lim \limits_{x \to a^-} f(x)$
$\displaystyle{\lim \limits_{x \to a} \frac{f(x)-f(a)}{x-a}=f'(a)}$

$\left. \frac{dy}{dx} \right|_{x=1}$

$\int_a^b$  
$\int \limits_a^b$
$\displaystyle{\int_a^b}$

# displaystyle
$\displaystyle{\int \limits_{a}^{b}x^2 \,dx=\left\[\frac{x^3}{3}\right]_{a}^{b}=\frac{b^3}{3}-\frac{a^3}{3}}$

# NOT displaystyle
$\int \limits_{a}^{b}x^2 \,dx=\left\[\frac{x^3}{3}\right]_{a}^{b}=\frac{b^3}{3}-\frac{a^3}{3}$

$\displaystyle{\sum \limits_{n=1}^{\infty}ar^n=a+ar+ar^2+ \cdots +ar^n}$

$\displaystyle{\int_a^b f(x) \,dx=\lim \limits_{x \to \infty} \sum \limits_{k=1}^{n} f(x_k) \cdot \Delta x}$

$\vec{v}=v_1 \vec{i}+v_2 \vec{j}=\langle v_1, v_2 \rangle$

$\lim \limits_{x \to a^-} f(x)$

$\displaystyle{\lim \limits_{x \to a} \frac{f(x)-f(a)}{x-a}=f'(a)}$

$\left. \frac{dy}{dx} \right|_{x=1}$

$\int_a^b$ $\int \limits_a^b$ $\displaystyle{\int_a^b}$

$\displaystyle{\int \limits_{a}^{b}x^2\thinspace dx=\left[\frac{x^3}{3}\right]_{a}^{b}=\frac{b^3}{3}-\frac{a^3}{3}}$

$\int \limits_{a}^{b}x^2 \thinspace dx=\left[\frac{x^3}{3}\right]_{a}^{b}=\frac{b^3}{3}-\frac{a^3}{3}$

$\displaystyle{\sum \limits_{n=1}^{\infty}ar^n=a+ar+ar^2+ \cdots +ar^n}$

$\displaystyle{\int_a^b f(x) \thinspace dx=\lim \limits_{x \to \infty} \sum \limits_{k=1}^{n} f(x_k) \cdot \Delta x}$

$\vec{v}=v_1 \vec{i}+v_2 \vec{j}=\langle v_1, v_2 \rangle$


Aligned Equations


# This creates alignment between formulas at the equal sign. & at the point of alignment.
$\begin{align}
   (f\circ g)&=f(x)g(x) \\
   &=(x+4)(x^2-16) \\
   &=(x^3+4x^2-16x-64)
\end{align}$

# PARTICULAR TO HUGO SITE 
# The \\ is repeated to escape \\.
$\begin{align}
   (f\circ g)&=f(x)g(x) \\\\
   &=(x+4)(x^2-16) \\\\
   &=(x^3+4x^2-16x-64)
\end{align}$

#USING <p> HTML TAG YOU CAN SKIP EXTRA \\
<p>
$\begin{align}
\mathcal{M}(u_{h}) - \mathcal{M}(u)
& = \mathcal{M}(u_{h} - u)\\
& = a^{*}(z, u_{h} - u)\\
& = a(u_{h} - u, z)\\
& = a(u_{h}, z) - a(u, z)\\
& = a(u_{h}, z) - L(z)\\
& = r(z),
\end{align}$
</p>

$\begin{align} (f\circ g)&=f(x)g(x) \\
&=(x+4)(x^2-16) \\
&=(x^3+4x^2-16x-64) \end{align}$

$\begin{align} \mathcal{M}(u_{h}) - \mathcal{M}(u) & = \mathcal{M}(u_{h} - u)\\ & = a^{*}(z, u_{h} - u)\\ & = a(u_{h} - u, z)\\ & = a(u_{h}, z) - a(u, z)\\ & = a(u_{h}, z) - L(z)\\ & = r(z) \end{align}$