Skip to main content

LaTeX 数学公式语法

· 4 min read
yinpo
Owner and Maintainer of here

通常 markdown 中显示数学符号使用的是 LaTeX 语言,渲染工具主要是 KaTeX 和 MathJax。

  • LaTeX 是排版系统和语言规范,支持复杂的数学公式、图表、参考文献等,LaTeX 是数学公式语法的基础。
  • KaTeX 是一个 JavaScript 的显示引擎,用于在网页上渲染 LaTeX 数学公式,是一个快速、高效的库。
  • MathJax 是一个 JavaScript 的显示引擎,用于在网页上高质量地呈现 LaTeX、MathML 和 AsciiMath 数学公式。

这里记录一下 LaTeX 系统中常见的数学符号语法。

Operators

$x + y$ x+yx + y

$x - y$ xyx - y

$x \times y$ x×yx \times y

$x \div y$ x÷yx \div y

$\dfrac{x}{y}$ xy\dfrac{x}{y}

$\sqrt{x}$ x\sqrt{x}

Symbols

$\pi \approx 3.14159$ π3.14159\pi \approx 3.14159

$\pm \, 0.2$ ±0.2\pm \, 0.2

$\dfrac{0}{1} \neq \infty$ 01\dfrac{0}{1} \neq \infty

$0 < x < 1$ 0<x<10 < x < 1

$0 \leq x \leq 1$ 0x10 \leq x \leq 1

$x \geq 10$ x10x \geq 10

$\forall \, x \in (1,2)$ x(1,2)\forall \, x \in (1,2)

$\exists \, x \notin [0,1]$ x[0,1]\exists \, x \notin [0,1]

$A \subset B$ ABA \subset B

$A \subseteq B$ ABA \subseteq B

$A \cup B$ ABA \cup B

$A \cap B$ ABA \cap B

$X \implies Y$ X    YX \implies Y

$X \impliedby Y$ X    YX \impliedby Y

$a \to b$ aba \to b

$a \Rightarrow b$ aba \Rightarrow b

$a \propto b$ aba \propto b

Greek Alphabets

SymbolSmall LetterCapital LetterSymbolSmall LetterCapital Letter
alphaα\alphaA\Alphamuμ\mu
betaβ\betaB\Betasigmaσ\sigmaΣ\Sigma
gammaγ\gammaΓ\Gammavarsigmaς\varsigma
deltaδ\deltaΔ\Deltaupsilonυ\upsilonΥ\Upsilon
epsilonϵ\epsilonE\Epsilonxiξ\xiΞ\Xi
kappaκ\kappaK\Kappanuν\nu
psiψ\psiΨ\Psivarphiφ\varphi
digammaϝ\digammaphiϕ\phiΦ\Phi
thetaθ\thetaΘ\Thetaomegaω\omegaΩ\Omega
varthetaϑ\varthetapiπ\piΠ\Pi
lambdaλ\lambdaΛ\Lambdaetaη\eta
varepsilonε\varepsilonzetaζ\zeta

Math Constructs

  1.   xX  yϵ\forall \; x \in X \quad \exists \; y \leq \epsilon

$\forall \; x \in X \quad \exists \; y \leq \epsilon$

  1. P(A=2|A2B>4)P \left( A=2 \, \middle| \, \dfrac{A^2}{B}>4 \right)

$P \left( A=2 \, \middle| \, \dfrac{A^2}{B}>4 \right)$

  1. f(x)=x2x1πf(x) = x^2 - x^\frac{1}{\pi}

$f(x) = x^2 - x^\frac{1}{\pi}$

  1. f(X,n)=Xn+Xn1f(X,n) = X_n + X_{n-1}

$f(X,n) = X_n + X_{n-1}$

  1. f(x)=2x3+x2f(x) = \sqrt[3]{2x} + \sqrt{x-2}

$f(x) = \sqrt[3]{2x} + \sqrt{x-2}$

  1. e=n=01n!\mathrm{e} = \sum_{n=0}^{\infty} \dfrac{1}{n!}

$\mathrm{e} = \sum_{n=0}^{\infty} \dfrac{1}{n!}$

  1. i=1nxi1\prod_{i=1}^{n} x_i - 1

$\prod_{i=1}^{n} x_i - 1$

  1. limx0+1x=\lim_{x \to 0^+} \dfrac{1}{x} = \infty

$\lim_{x \to 0^+} \dfrac{1}{x} = \infty$

  1. abydx\int_a^b y \: \mathrm{d}x

$\int_a^b y \: \mathrm{d}x$

  1. logab=1\log_a b = 1

$\log_a b = 1$

  1. n!k!(nk)!=(nk)\dfrac{n!}{k!(n-k)!} = \binom{n}{k}

$\dfrac{n!}{k!(n-k)!} = \binom{n}{k}$

Functions

f(x)={1/dijwhen dij1600otherwisef(x)= \begin{cases} 1/d_{ij} & \quad \text{when $d_{ij} \leq 160$}\\ 0 & \quad \text{otherwise} \end{cases}
$$
f(x)=
\begin{cases}
1/d_{ij} & \quad \text{when $d_{ij} \leq 160$}\\
0 & \quad \text{otherwise}
\end{cases}
$$

Matrices

123456789\begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix}
$$
\begin{matrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{matrix}
$$

M=[561605601605616]M = \begin{bmatrix} \frac{5}{6} & \frac{1}{6} & 0 \\[0.3em] \frac{5}{6} & 0 & \frac{1}{6} \\[0.3em] 0 & \frac{5}{6} & \frac{1}{6} \end{bmatrix}
$$
M =
\begin{bmatrix}
\frac{5}{6} & \frac{1}{6} & 0 \\[0.3em]
\frac{5}{6} & 0 & \frac{1}{6} \\[0.3em]
0 & \frac{5}{6} & \frac{1}{6}
\end{bmatrix}
$$

M=(561605601605616)M = \begin{pmatrix} \frac{5}{6} & \frac{1}{6} & 0 \\[0.3em] \frac{5}{6} & 0 & \frac{1}{6} \\[0.3em] 0 & \frac{5}{6} & \frac{1}{6} \end{pmatrix}
$$
M =
\begin{pmatrix}
\frac{5}{6} & \frac{1}{6} & 0 \\[0.3em]
\frac{5}{6} & 0 & \frac{1}{6} \\[0.3em]
0 & \frac{5}{6} & \frac{1}{6}
\end{pmatrix}
$$