Skip to content

基本语法

行内公式用单个美元符号 $ 包裹

$E = mc^2$


独立公式用双美元符号 $$ 包裹

$$\int_a^b f(x)dx = F(b) - F(a)$$


常用数学符号

上下标

$x^2$ $x_1$ $x^{2y}$ $x_{i,j}$


分数

$\frac{a}{b}$ $\dfrac{a}{b}$(强制显示大小)

(强制显示大小)


根号

$\sqrt{x}$ $\sqrt[n]{x}$


希腊字母

$\alpha, \beta, \gamma, \Gamma, \pi, \Pi$


运算符

$\times, \div, \pm, \mp, \cdot$
$\sum, \prod, \int, \oint$


关系符号

$=, \neq, <, >, \leq, \geq, \approx, \sim$


箭头

$\to, \rightarrow, \leftarrow, \Rightarrow, \Leftarrow$

高级格式

矩阵

$$
\begin{matrix}
a & b\\\\
c & d
\end{matrix}
$$
$$
\begin{pmatrix}
a & b\\\\
c & d
\end{pmatrix}
$$
$$
\begin{bmatrix}
1 & 2\\\\
3 & 4
\end{bmatrix}
$$

多行公式

$$
\begin{align}
f(x) &= (x+1)^2\\\\
     &= x^2 + 2x + 1
\end{align}
$$

分段函数

$$
f(x) = 
\begin{cases}
x & \text{if } x \geq 0\\\\
-x & \text{if } x < 0
\end{cases}
$$

常用数学环境

方程组

$$
\begin{cases}
x + 2y = 7\\\\
3x - y = 1
\end{cases}
$$

对齐环境

$$
\begin{aligned}
f(x) &= (x+1)(x-1)\\\\\\
     &= x^2 - 1
\end{aligned}
$$

实用示例

二次方程求根公式

$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$


欧拉公式

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


积分示例

$$\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}$$

注意事项

  • 空格:使用 \,、\;、\quad、\qquad 添加不同宽度的空格
  • 文字:在公式中使用 \text{...} 来插入普通文字
  • 括号大小:使用 \left(\right) 让括号自适应高度
  • 字体:\mathbb{R}(实数集)、\mathcal{L}(花体)、\mathbf{x}(粗体)