Scissor LaTeX 中的 amsmath
amsmath 宏包在 Scissor LaTeX 中可用:align 和 gather 为每一行编号,\tag、\intertext、subequations、\numberwithin、\genfrac、split、cases、各种矩阵环境和 \DeclareMathOperator 都与 LaTeX 中一样可用。
宏包的作用
amsmath 是行间数学公式的标准工具箱。它增加了用于对齐和成组公式的环境、带括号的矩阵、公式中的 \text、更好的分数和二项式,以及用于引用公式的 \eqref。
在导言区用 \usepackage{amsmath} 加载它。在 Scissor LaTeX 中,即使没有这一行,它的大多数命令也能使用,但请保留它,这样你的文档在 TeX 发行版中也能编译。
这里可用的功能
| 命令或环境 | 在 Scissor LaTeX 中 | 说明 |
|---|---|---|
equation, equation* | 可用 | 一个编号,或没有编号。 |
align, align* | 可用 | |
gather, gather* | 可用 | |
multline, multline* | 可用 | |
flalign, alignat, eqnarray | 可用 | |
split, aligned, gathered | 可用 | 放在 equation 或 \[ ... \] 中。 |
cases | 可用 | |
matrix, pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix, smallmatrix | 可用 | |
\text{...}, \operatorname{...} | 可用 | |
\DeclareMathOperator, \DeclareMathOperator* | 可用 | 请写在导言区。 |
\dfrac, \tfrac, \cfrac, \binom, \dbinom, \genfrac | 可用 | |
\boxed, \substack, \overset, \underset, \smash | 可用 | |
\xrightarrow[...]{...}, \xleftarrow[...]{...} | 可用 | |
\eqref, \label | 可用 | |
\nonumber, \notag | 可用 | |
\tag{...}, \tag*{...} | 可用 | |
\numberwithin, subequations | 可用 | |
\intertext, \shortintertext | 可用 | |
\iint, \iiint | 可用 | \iiiint 和 \idotsint 会让公式显示为红色。 |
示例
在等号处对齐的公式,并引用该公式块:
带 \label 和 \eqref 的 align
\begin{align}
f(x) &= (x + 1)^2 \label{eq:square}\\
&= x^2 + 2x + 1
\end{align}
Expanding the square in \eqref{eq:square} gives three terms.用 cases 和 \text 写分段函数,并使用在导言区声明的运算符:
cases、\text 和 \DeclareMathOperator
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\sgn}{sgn}
\begin{document}
\[
\sgn(x) =
\begin{cases}
1 & \text{if } x > 0,\\
0 & \text{if } x = 0,\\
-1 & \text{otherwise.}
\end{cases}
\]
\end{document}不同括号的矩阵,以及用 split 拆分的长公式:
矩阵和 split
\[
A = \begin{pmatrix} 1 & 2 \\ 3 & 44 \end{pmatrix},\quad
B = \begin{bmatrix} a & b \\ c & d \end{bmatrix},\quad
\det A = \begin{vmatrix} 1 & 2 \\ 3 & 44 \end{vmatrix} = 38
\]
\begin{equation}
\begin{split}
(a + b)^3 &= (a + b)(a + b)^2 \\
&= a^3 + 3a^2 b + 3a b^2 + b^3
\end{split}
\end{equation}分数、二项式、方框和多行上下限:
\dfrac、\binom、\boxed 和 \substack
\boxed{\, \sum_{\substack{0 \le i \le n \\ i \text{ even}}} \binom{n}{i} = 2^{n-1} \,}
\qquad
\dfrac{1}{1 + \cfrac{1}{2 + \cfrac{1}{3}}}
\qquad
A \xrightarrow{\;f\;} B\intertext 会在 align 的各行之间插入一行文字:
两行之间的 \intertext
\begin{align}
x &= 44 \intertext{and therefore}
y &= 2x
\end{align}兼容性
- 从 TeX 发行版迁移到这里: 文档以相同的编号排版;只有上面标为不支持的少数命令会让公式显示为红色。
- 从这里迁移到 TeX 发行版: 文档无需修改即可在那里编译。
完整手册见 CTAN:ctan.org/pkg/amsmath。循序渐进的介绍请参阅公式、对齐和编号和矩阵。
常见问题
align 的每一行都有自己的编号吗?
是的,与 TeX 发行版中一样。在不需要编号的行上写 \nonumber 或 \notag。
能用 \tag 给公式设置自定义标签吗?
可以。\tag{A} 显示 (A) 而不是编号,引用其标签的 \eqref 也会输出 (A)。
支持 \DeclareMathOperator 吗?
支持。像在 TeX 发行版中一样在导言区声明运算符,然后像 \sin 一样使用它。带星号的形式会在行间公式中把上下限放在名称下方。
本页的每个示例都在构建网站时由 Scissor LaTeX 排版。 最后更新:2026-11-07