\begin{equation}
S=\sum\limits_{i=1}^{8}A_i
S=\sum\limits_{i=1}^{8}B_i
S=\sum\limits_{i=1}^{8}C_i
S=\sum\limits_{i=1}^{8}D_i
\end{equation}
考虑到上述代码,我非常感兴趣的是,如何才能打印这 4 个方程式,每行一个,而不是全部放在一行中。
答案1
该包amsmath
为方程式提供了许多环境,例如:
gather
默认为中心方程align
,允许垂直对齐
例子:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather}
S=\sum_{i=1}^{8}A_i\\
S=\sum_{i=1}^{8}B_i\\
S=\sum_{i=1}^{8}C_i\\
S=\sum_{i=1}^{8}D_i
\end{gather}
\begin{align}
S &= \sum_{i=1}^{8}A_i\\
S &= \sum_{i=1}^{8}B_i\\
S &= \sum_{i=1}^{8}C_i\\
S &= \sum_{i=1}^{8}D_i
\end{align}
\end{document}
最后一行的方程式编号
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather}
\nonumber S=\sum_{i=1}^{8}A_i\\
\nonumber S=\sum_{i=1}^{8}B_i\\
\nonumber S=\sum_{i=1}^{8}C_i\\
S=\sum_{i=1}^{8}D_i
\end{gather}
\begin{align}
\nonumber S &= \sum_{i=1}^{8}A_i\\
\nonumber S &= \sum_{i=1}^{8}B_i\\
\nonumber S &= \sum_{i=1}^{8}C_i\\
S &= \sum_{i=1}^{8}D_i
\end{align}
\end{document}
中间的方程式编号
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{gathered}
S=\sum_{i=1}^{8}A_i\\
S=\sum_{i=1}^{8}B_i\\
S=\sum_{i=1}^{8}C_i\\
S=\sum_{i=1}^{8}D_i
\end{gathered}
\end{equation}
\begin{equation}
\begin{aligned}
S &= \sum_{i=1}^{8}A_i\\
S &= \sum_{i=1}^{8}B_i\\
S &= \sum_{i=1}^{8}C_i\\
S &= \sum_{i=1}^{8}D_i
\end{aligned}
\end{equation}
\end{document}
附录:带案例的符号函数定义
\documentclass{article}
\usepackage{amsmath}
\usepackage{colonequals}
\DeclareMathOperator{\sgn}{sgn}
\begin{document}
\begin{equation}
\sgn(x) \colonequals
\begin{cases}
-1 & \text{if } x < 0 \\
0 & \text{if } x = 0 \\
1 & \text{if } x > 0
\end{cases}
\end{equation}
\end{document}
答案2
您还可以每行有多个对齐点。对于每个组一个数字,请使用嵌套环境:(如果您加载而不是,则gathered, aligned, multlined
使用后者)。您还可以使用环境(1a、1b 等):mathtools
amsmath
subnumbering
subequations
\documentclass{article}
\usepackage{mathtools}
\usepackage{showframe}
\begin{document}
\begin{align}
S &= \sum_{i=1}^{8}A_i &S &= \sum_{i=1}^{8}B_i\\
S &= \sum_{i=1}^{8}C_i & S &= \sum_{i=1}^{8}D_i
\end{align}
\begin{flalign}
S &= \sum_{i=1}^{8}A_i &S &= \sum_{i=1}^{8}B_i & S &= \sum_{i=1}^{8}C_i \\
S &= \sum_{i=1}^{8}D_i & S &= \sum_{i=1}^{8}D_i & S &= \sum_{i=1}^{8}F_i
\end{flalign}
\begin{align*}
S &= \sum_{i=1}^{8}A_i &S &= \sum_{i=1}^{8}B_i & S &= \sum_{i=1}^{8}C_i \\
S &= \sum_{i=1}^{8}D_i & S &= \sum_{i=1}^{8}D_i & S &= \sum_{i=1}^{8}F_i
\end{align*}
\begin{equation}\label{myeq}
\begin{aligned}
S &= \sum_{i=1}^{8}A_i &S &= \sum_{i=1}^{8}B_i\\
S &= \sum_{i=1}^{8}C_i & S &= \sum_{i=1}^{8}D_i
\end{aligned}
\end{equation}
\end{document}