Multi-line Equation Layout: align and split Environments

Aug. 18, 2022

align environment

1
2
3
4
5
\left\{
\begin{align}
\dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\label{eq1}\\
\dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\label{eq2}\\
\end{align}\right.
\[\left\{ \begin{align} \dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\label{eq1}\\ \dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\label{eq2}\\ \end{align}\right.\]

align 环境可以给多行公式添加编号,并且可以分别引用:公式 $\eqref{eq1}$ 和公式 $\eqref{eq2}$。

如果不想添加编号,那么可以使用 \notag 命令:

1
2
3
4
5
\left\{
\begin{align}
\dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\notag\\
\dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\notag\\
\end{align}\right.
\[\left\{ \begin{align} \dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\notag\\ \dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\notag\\ \end{align}\right.\]

或者直接使用 align* 环境。

1
2
3
4
5
\left\{
\begin{align*}
\dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\\
\dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\\
\end{align*}\right.
\[\left\{ \begin{align*} \dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\\ \dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\\ \end{align*}\right.\]

split environment

从上面可以看到,在 Markdown 文件中添加编号的 align 环境与左大括号的兼容性不太好。并且不能将整个公式作为一个整体,在多行的居中位置添加编号。而 split 环境可以有效解决这两个问题。

1
2
3
4
5
\left\{
\begin{split}
\dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\\
\dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\\
\end{split}\right.
\[\left\{ \begin{split} \dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\\ \dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\\ \end{split}\right.\]

如果不想添加编号,则在整个公式后面添加 \notag

1
2
3
4
5
\left\{
\begin{split}
\dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\\
\dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\\
\end{split}\right.\notag
\[\left\{ \begin{split} \dfrac{\mathrm{d}x_1}{\mathrm{d}t}=f_1(x_1,x_2,t)\\ \dfrac{\mathrm{d}x_2}{\mathrm{d}t}=f_2(x_1,x_2,t)\\ \end{split}\right.\notag\]

BTW,并不存在 split* 环境。

image-20220818190050788