一、gather的用法
基本用法,公式编号
\begin{gather}
a+b = b+a \\
a\times b = b \times a
\end{gather}
a+b=b+aa×b=b×a
\begin{gather}
a+b = b+a \\
a\times b = b \times a
\end{gather}
a+b=b+aa×b=b×a
可以使用gather*不编号
\begin{gather*}
a+b = b+a \\
a\times b = b \times a
\end{gather*}
a+b=b+aa×b=b×a
\begin{gather*}
a+b = b+a \\
a\times b = b \times a
\end{gather*}
a+b=b+aa×b=b×a
或者在\\前用\notag命令阻止指定的行不编号,
a+b=b+aa×b=b×aa−b=−b+a
\begin{gather}
a+b = b+a \notag \\
a\times b = b \times a \notag \\
a-b=-b+a \\
\end{gather}
a+b=b+aa×b=b×aa−b=−b+a
二、align环境
gather环境中每行公式是剧中的,而align可以按照等号或其它关系符对齐
\begin{align}
a+b &= b+a \\
a\times b + 1 &= b \times a + 1
\end{align}
a+b=b+aa×b+1=b×a+1 \begin{align} a+b &= b+a \\ a\times b + 1 &= b \times a + 1 \end{align} a+ba×b+1=b+a=b×a+1
三、 alignat环境
alignat环境通过手动增加间距,有一个参数,表示每行要对齐的公式个数,每两列一组,例如把列间隔设定为一个\quad,即1em.
\begin{alignat}{2}
x &= \sin t & \quad & \text{水平方向} \\
y &= \cos t && \text{垂直方向}
\end{alignat}
x=sint水平方向y=cost垂直方向 \begin{alignat}{2} x &= \sin t & \quad & \text{水平方向} \\ y &= \cos t && \text{垂直方向} \end{alignat} xy=sint=cost水平方向垂直方向
四、cases环境
将几行公式前面用花括号括起来
\begin{equation}
f(x) = \begin{cases}
1, & \text{if } x \in [0, 1]; \\
0, & \text{if } x \in [-1, 0).
\end{cases}
\end{equation}
f(x)={1,if x∈[0,1];0,if x∈[−1,0). \begin{equation} f(x) = \begin{cases} 1, & \text{if } x \in [0, 1]; \\ 0, & \text{if } x \in [-1, 0). \end{cases} \end{equation} f(x)={1,0,if x∈[0,1];if x∈[−1,0).
本文介绍了LaTeX中用于数学公式排版的几个重要环境,包括gather用于居中排列公式,gather*不编号,align按等号对齐公式,alignat手动调整间距对齐,以及cases环境用于创建带有条件的公式表示。
2212

被折叠的 条评论
为什么被折叠?



