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.
| mode | command | example | preview |
|---|
| inline | $...$ | $X^2$ | X2 |
| block | $$...$$ | $$X^2$$ | X2 |
1.1 Plain Text
| command | preview |
|---|
\text{plain text} | plain text |
1.2 Greek Letter
| command | preview | command | preview | command | preview | command | preview |
|---|
A | A | \alpha | α | N | N | \nu | ν |
B | B | \beta | β | \Xi | Ξ | \xi | ξ |
\Gamma | Γ | \gamma | γ | O | O | \omicron | ο |
\Delta | Δ | \delta | δ | \Pi | Π | \pi | π |
E | E | \epsilon | ϵ | P | P | \rho | ρ |
Z | Z | \zeta | ζ | \Sigma | Σ | \sigma | σ |
H | H | \eta | η | T | T | \tau | τ |
\Theta | Θ | \theta | θ | \Upsilon | Υ | \upsilon | υ |
I | I | \iota | ι | \Phi | Φ | \phi | ϕ |
K | K | \kappa | κ | X | X | \chi | χ |
\Lambda | Λ | \lambda | λ | \Psi | Ψ | \psi | ψ |
M | M | \mu | μ | \Omega | Ω | \omega | ω |
1.3 Spacing
| command | preview | command | preview | command | preview |
|---|
a\qquad b | ab | a\quad b | ab | a\ b | a b |
1.4 Font
| command | preview | command | preview |
|---|
\mathsf{ABC123}+ | ABC123 | \mathrm{ABC123}+ | ABC123 |
\mathbf{ABC123}+ | ABC123 | \mathcal{ABC123}+ | ABC123 |
\mathtt{ABC123}+ | ABC123 | \mathscr{ABC123}+ | ABC123 |
\mathbb{ABC123}+ | ABC123 | \mathfrak{ABC123}+ | ABC123 |
\mathit{ABC123}+ | ABC123 | \boldsymbol{ABC123}+ | ABC123 |
1.5 Color
| command | preview | command | preview |
|---|
\color{black}{text}+ | text | \color{olive}{text}+ | text |
\color{gray}{text}+ | text | \color{green}{text}+ | text |
\color{silver}{text}+ | text | \color{teal}{text}+ | text |
\color{white}{text}+ | text | \color{aqua}{text}+ | text |
\color{maroon}{text}+ | text | \color{blue}{text}+ | text |
\color{red}{text}+ | text | \color{navy}{text}+ | text |
\color{yellow}{text}+ | text | \color{purple}{text}+ | text |
\color{lime}{text}+ | text | \color{fuchsia}{text}+ | text |
2. Operator
2.1 Subscript & Superscript
| command | preview | command | preview |
|---|
A^{x}+ | Ax | A_{x}+ | Ax |
\overline{x} | x | \overrightarrow{x} | x |
\overbrace{x_1 \dots x_n}^n | x1…xnn | \underbrace{x_1 \dots x_n}_n | nx1…xn |
2.2 Relational Operator
| command | preview | command | preview | command | preview |
|---|
> | > | < | < | = | = |
\le | ≤ | \ge | ≥ | \ne | = |
\ll | ≪ | \gg | ≫ | \equiv | ≡ |
: | : | \approx | ≈ | \mid | ∣ |
\subset | ⊂ | \supset | ⊃ | \in | ∈ |
\subseteq | ⊆ | \supseteq | ⊇ | \notin | ∈/ |
2.3 Arithmetic Operator
| command | preview | command | preview | command | preview |
|---|
+ | + | - | − | \pm | ± |
\cdot | ⋅ | \times | × | \div | ÷ |
\cup | ∪ | \vee | ∨ | \sqrt[n]{A} | nA |
\cap | ∩ | \wedge | ∧ | \frac{x}{y} | yx |
2.4 Accumulational Operator
| command | preview | command | preview | command | preview |
|---|
\sum | ∑ | \bigcup | ⋃ | \bigcap | ⋂ |
\prod | ∏ | \bigvee | ⋁ | \bigwedge | ⋀ |
\int | ∫ | \lim | lim | | |
2.5 Brackets
| command | preview | command | preview |
|---|
( x ) | (x) | \lvert x \rvert | ∣x∣ |
[ x ] | [x] | \lfloor x \rfloor | ⌊x⌋ |
\{ x\} | {x} | \lceil x \rceil | ⌈x⌉ |
\langle x\rangle | ⟨x⟩ | | |
3. Layout
3.1 Cases
● ● ●mathjaxabs(x) =
\begin{cases}
x & x > 0 \\
-x & x <= 0 \\
\end{cases}
abs(x)={x−xx>0x<=0
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}
n123left147center258right369
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:
| mode | preview | mode | preview | mode | preview |
|---|
matrix | 1001 | bmatrix | [1001] | vmatrix | 1001 |
pmatrix | (1001) | Bmatrix | {1001} | Vmatrix | 1001 |