../ Data Science
-rw-r--r--aguang8.0 KiB5 min read

modified

A Brief Introduction of MathJax

MathJax is a javascript display engine which can be easily integrated into web pages. In this article, I want to cover many common usage of MathJax.

1. Basic Grammar

There are two ways to insert a MathJax expression:

  • Insert a inline expression.
  • Insert a block expression.
modecommandexamplepreview
inline$...$$X^2$X2X^2
block$$...$$$$X^2$$X2X^2

1.1 Plain Text

commandpreview
\text{plain text}plain text\text{plain text}

1.2 Greek Letter

commandpreviewcommandpreviewcommandpreviewcommandpreview
A AA \alpha α\alpha N NN \nu ν\nu
B BB \beta β\beta \Xi Ξ\Xi \xi ξ\xi
\Gamma Γ\Gamma \gamma γ\gamma O OO \omicron ο\omicron
\Delta Δ\Delta \delta δ\delta \Pi Π\Pi \pi π\pi
E EE \epsilon ϵ\epsilonP PP \rho ρ\rho
Z ZZ \zeta ζ\zeta \Sigma Σ\Sigma \sigma σ\sigma
H HH \eta η\eta T TT \tau τ\tau
\Theta Θ\Theta \theta θ\theta \Upsilon Υ\Upsilon\upsilon υ\upsilon
I II \iota ι\iota \Phi Φ\Phi \phi ϕ\phi
K KK \kappa κ\kappa X XX \chi χ\chi
\Lambda Λ\Lambda \lambda λ\lambda \Psi Ψ\Psi \psi ψ\psi
M MM \mu μ\mu \Omega Ω\Omega \omega ω\omega

1.3 Spacing

commandpreviewcommandpreviewcommandpreview
a\qquad baba\qquad ba\quad baba\quad ba\ ba ba\ b

1.4 Font

commandpreviewcommandpreview
\mathsf{ABC123}+ ABC123 \mathsf{ABC123}\mathrm{ABC123}+ ABC123 \mathrm{ABC123}
\mathbf{ABC123}+ ABC123 \mathbf{ABC123}\mathcal{ABC123}+ ABC123 \mathcal{ABC123}
\mathtt{ABC123}+ ABC123 \mathtt{ABC123}\mathscr{ABC123}+ ABC123 \mathscr{ABC123}
\mathbb{ABC123}+ ABC123 \mathbb{ABC123}\mathfrak{ABC123}+ ABC123 \mathfrak{ABC123}
\mathit{ABC123}+ ABC123 \mathit{ABC123}\boldsymbol{ABC123}+ ABC123\boldsymbol{ABC123}

1.5 Color

commandpreviewcommandpreview
\color{black}{text}+ text \color{black}{text}\color{olive}{text}+ text \color{olive}{text}
\color{gray}{text}+ text \color{gray}{text}\color{green}{text}+ text \color{green}{text}
\color{silver}{text}+ text \color{silver}{text}\color{teal}{text}+ text \color{teal}{text}
\color{white}{text}+ text \color{white}{text}\color{aqua}{text}+ text \color{aqua}{text}
\color{maroon}{text}+ text \color{maroon}{text}\color{blue}{text}+ text \color{blue}{text}
\color{red}{text}+ text \color{red}{text}\color{navy}{text}+ text \color{navy}{text}
\color{yellow}{text}+ text \color{yellow}{text}\color{purple}{text}+ text \color{purple}{text}
\color{lime}{text}+ text \color{lime}{text}\color{fuchsia}{text}+ text\color{fuchsia}{text}

2. Operator

2.1 Subscript & Superscript

commandpreviewcommandpreview
A^{x}+ AxA^{x}A_{x}+ AxA_{x}
\overline{x}x‾\overline{x}\overrightarrow{x}x→\overrightarrow{x}
\overbrace{x_1 \dots x_n}^nx1…xn⏞n\overbrace{x_1 \dots x_n}^n\underbrace{x_1 \dots x_n}_nx1…xn⏟n\underbrace{x_1 \dots x_n}_n

2.2 Relational Operator

commandpreviewcommandpreviewcommandpreview
>>><<<===
\le≤\le\ge≥\ge\ne≠\ne
\ll≪\ll\gg≫\gg\equiv≡\equiv
:::\approx≈\approx\mid∣\mid
\subset⊂\subset\supset⊃\supset\in∈\in
\subseteq⊆\subseteq\supseteq⊇\supseteq\notin∉\notin

2.3 Arithmetic Operator

commandpreviewcommandpreviewcommandpreview
+++-−-\pm±\pm
\cdot⋅\cdot\times×\times\div÷\div
\cup∪\cup\vee∨\vee\sqrt[n]{A}An\sqrt[n]{A}
\cap∩\cap\wedge∧\wedge\frac{x}{y}xy\frac{x}{y}

2.4 Accumulational Operator

commandpreviewcommandpreviewcommandpreview
\sum∑ \sum\bigcup⋃ \bigcup\bigcap⋂ \bigcap
\prod∏ \prod\bigvee⋁ \bigvee\bigwedge⋀\bigwedge
\int∫ \int\limlim⁡ \lim

2.5 Brackets

commandpreviewcommandpreview
( x )(x)( x )\lvert x \rvert∣x∣\lvert x \rvert
[ x ][x][ x ]\lfloor x \rfloor⌊x⌋\lfloor x \rfloor
\{ x\}{x}\{ x\}\lceil x \rceil⌈x⌉\lceil x \rceil
\langle x\rangle⟨x⟩\langle x\rangle

3. Layout

3.1 Cases

mathjax
abs(x) =
  \begin{cases}
     x & x  > 0 \\
    -x & x <= 0 \\
  \end{cases}
abs(x)={xx>0−xx<=0abs(x) = \begin{cases} x & x > 0 \\ -x & x <= 0 \\ \end{cases}

3.2 Array

mathjax
\begin{array}
  {c|lcr}
  n & \text{Left} & \text{Center} & \text{Right} \\
  \hline
  1 & 1 & 2 & 3 \\
  2 & 4 & 5 & 6 \\
  3 & 7 & 8 & 9 \\
\end{array}
nleftcenterright112324563789\begin{array} {c|lcr} n & \text{left} & \text{center} & \text{right} \\ \hline 1 & 1 & 2 & 3 \\ 2 & 4 & 5 & 6 \\ 3 & 7 & 8 & 9 \\ \end{array}

3.3 Matrix

Here is the basic format of defining a matrix:

mathjax
\begin{matrix}
  1 & 0 \\
  0 & 1 \\
\end{matrix}

The command matrix can be replaced with pmatrix, bmatrix, Bmatrix, vmatrix and Vmatrix to change the brackets of the matrix:

modepreviewmodepreviewmodepreview
matrix1001\begin{matrix} 1 & 0 \\ 0 & 1 \\ \end{matrix}bmatrix[1001]\begin{bmatrix} 1 & 0 \\ 0 & 1 \\ \end{bmatrix}vmatrix∣1001∣\begin{vmatrix} 1 & 0 \\ 0 & 1 \\ \end{vmatrix}
pmatrix(1001)\begin{pmatrix} 1 & 0 \\ 0 & 1 \\ \end{pmatrix}Bmatrix{1001}\begin{Bmatrix} 1 & 0 \\ 0 & 1 \\ \end{Bmatrix}Vmatrix∥1001∥\begin{Vmatrix} 1 & 0 \\ 0 & 1 \\ \end{Vmatrix}

COMMAND INTERFACE

↑ ↓ navigate · Enter execute · Esc exit · try “whoami”

Loading filesystem…

:help aguang.xyz

A personal website disguised as an operating system.

Ctrl / Cmd + K
Command palette + full-text search
Tab / Shift + Tab
Move between links and controls
Enter
Open a focused link or search result
↑ / ↓ in search
Navigate search results
In a directory filter
Enter/Done or ↓ focuses a result; Esc clears the filter
Esc
Clear a search or close a window