Skip to content

1.4 MathJax

1. Modes

1.1 Inline Math Mode

This is an inline equation $e^{\pi i} + 1 = 0$, and it is inline with the text.

This is an inline equation , and it is inline with the text.

1.2 Block Math Mode

This is a block equation

$$
e^{\pi i} + 1 = 0
$$

2. Labeling Equations

$$
E = mc^2 \tag{1} \label{eq:energy}
$$
As shown in equation $Eq. \ref{eq:energy}$, energy is related to mass and the speed of light.

As shown in equation , energy is related to mass and the speed of light.

3. Multiline Equation

3.1 equation

$$
\begin{equation*}
v + w = 0\\
v + w = 0\\
\end{equation*}
$$

equation environment is designed for single-line equations. If you want to write multiple lines of equations, you should use environments like align, gather, or multline in LaTeX.

3.2 Multiline

$$
\begin{multline*}
p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3\\
- 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3
\end{multline*}
$$

The multline* environment in LaTeX (and in MathJax/KaTeX when used in MDX) is used to display a long equation that spans multiple lines. Unlike align* or gather*, which allow aligning equations or centering them, multline* splits a single long equation across several lines without alignment.

  • multline: This environment is used for splitting long equations into multiple lines with numbering.
  • multline*: The * version disables numbering.

How it works:

  • The first line of the equation is left-aligned.
  • The last line is right-aligned.
  • All other intermediate lines are centered.

Example:

\begin{multline*}
p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3\\
- 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3
\end{multline*}

In this case, the polynomial ( p(x) ) is too long to fit on one line, so it is broken into two lines:

  • The first part (p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3) is left-aligned.
  • The second part (- 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3) is right-aligned.

This ensures the equation looks clean when it’s too long for one line. If you remove the *, the equation would be automatically numbered.

3.3 Align

In LaTeX (and by extension, in KaTeX and MathJax when used with MDX), the align* environment is used to typeset aligned equations without numbering them. Here’s a breakdown:

  • align: This environment is used for multi-line aligned equations, where each equation or line is aligned at the & symbol. By default, equations are numbered.

  • align*: The * in align* makes it a variation of align that disables numbering, so the equations are aligned but not numbered.

Example of align*:

\begin{align*}
2x - 5y &= 8 \\
3x + 9y &= -12
\end{align*}

This will display two equations, aligned at the &, but without numbers.

  • The & symbol marks the alignment point (usually for the equals sign).
  • \\ is used to move to the next line.

If you use align without the *, the equations will be numbered.

If you want numbered equations:

\begin{align}
2x - 5y &= 8 \\
3x + 9y &= -12
\end{align}

This would automatically number both equations.

Manual Numbering

$$
\begin{align*}
v + w & = 0 &&\text{Given} \tag 1\\
-w & = -w + 0 && \text{additive identity} \tag 2\\
-w + 0 & = -w + (v + w) && \text{equations $(1)$ and $(2)$}
\end{align*}
$$

This is some text referring to the or

Another Example

$$
\begin{align*}
x&=y & w &=z & a&=b+c\\
2x&=-y & 3w&=\frac{1}{2}z & a&=b\\
-4 + 5x&=2+y & w+2&=-1+w & ab&=cb
\end{align*}
$$

3.4 Gather

$$
\begin{gather*}
2x - 5y = 8 \\
3x^2 + 9y = 3a + c
\end{gather*}
$$

3.5 Cases

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

4. Matrix / Tables

$$
\begin{matrix}
a & b \\
c & d
\end{matrix}
$$
$$
\begin{array}{c|lcr}
n & \text{Left} & \text{Center} & \text{Right} \\
\hline
1 & 0.24 & 1 & 125 \\
2 & -1 & 189 & -8 \\
3 & -20 & 2000 & 1+10i
\end{array}
$$

6. Misc

6.1 Crossing things out

$$
\begin{align*}
y+\cancel{x}\\
\cancel{y+x}\\
y+\bcancel{x}\\
y+\xcancel{x}\\
y+\cancelto{5}{x}\\
\frac{1\cancel9}{\cancel95} = \frac15\\
\end{align*}
$$

6.2 Delimeter Sizing

$$
\left(\LARGE{AB}\right)
$$
$$
\begin{align*}
\left( 23 \right)\\
\big( \bigl( \bigm( \bigr(\\
\Big( \Bigl( \Bigm( \Bigr( \\
\bigg( \biggl( \biggm( \biggr( \\
\Bigg( \Biggl( \Biggm( \Biggr( \\
\end{align*}
$$

6.2 Math Equations

$$
\begin{align*}
\left(A = \frac{\pi r^2}{2} \right)
\end{align*}
$$
$$
e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n
\qquad (1)
$$
$$
|x|, ||v|| \quad\longrightarrow\quad \lvert x\rvert, \lVert v\
$\Rightarrow$, $\Leftarrow$ and $\Leftrightarrow$
$$
$$
\begin{align*}
|x|, ||v|| \quad\longrightarrow\quad \lvert x\rvert, \lVert v\rVert\\
$\Rightarrow$, $\Leftarrow$ and $\Leftrightarrow$
\end{align*}
$$
$$
\begin{align*}
v + w & = 0 &&\text{Given} \tag 1\\
-w & = -w + 0 && \text{additive identity} \tag 2\\
-w + 0 & = -w + (v + w) && \text{equations $(1)$ and $(2)$}
\end{align*}
$$
$$
\begin{equation*} \label{eq1}
\begin{split}
A & = \frac{\pi r^2}{2} \\
& = \frac{1}{2} \pi r^2
\end{split}
\end{equation*}
$$

Misc

$$
\color{red}{\heartsuit} \color{red}{\diamondsuit}
$$

References

Ref: https://www.overleaf.com/learn/latex/Aligning_equations_with_amsmath

Latex Symbol from Drawings

https://detexify.kirelabs.org/classify.html

Mathjax Reference

https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference/15078#15078

KaTex Reference

https://katex.org/docs/supported