gathered 環境|LaTeX

gathered 環境は複数行の数式を中央揃えでまとめて表示するための環境です。 の中で使います。

基本的な使い方

複数の式を中央揃えで縦に並べます。

\[
\begin{gathered}
a + b = c \\
x + y = z
\end{gathered}
\]

align 環境と違い、揃える位置を & で指定する必要がありません。各行が独立して中央揃えになります。

3 行以上の数式

何行でも追加できます。

\[
\begin{gathered}
a = 1 \\
b = 2 \\
c = 3 \\
d = 4
\end{gathered}
\]

括弧で囲む

\left\right で括弧を付けることができます。

\[
\left\{
\begin{gathered}
x + y = 5 \\
x - y = 1
\end{gathered}
\right.
\]

連立方程式を表すときに便利です。

長さの異なる式

各行の長さが異なっていても、それぞれ中央に配置されます。

\[
\begin{gathered}
a = b \\
x + y + z = 10 \\
p = q
\end{gathered}
\]

数式の途中に挿入

他の数式の一部として使うこともできます。

\[
A = \left(
\begin{gathered}
\text{条件 1} \\
\text{条件 2}
\end{gathered}
\right)
\implies B
\]

aligned との違い

aligned 環境は & で揃え位置を指定しますが、gathered は単純に中央揃えです。

\[
\begin{aligned}
x + y &= 5 \\
x &= 3
\end{aligned}
\quad\text{vs}\quad
\begin{gathered}
x + y = 5 \\
x = 3
\end{gathered}
\]

左側の aligned は等号の位置が揃い、右側の gathered は各行が独立して中央に配置されています。

複数のグループ

複数の gathered を横に並べることもできます。

\[
\begin{gathered}
a = 1 \\
b = 2
\end{gathered}
\qquad
\begin{gathered}
x = 3 \\
y = 4
\end{gathered}
\]

説明文の追加

式の前後に説明を付けることもできます。

\[
\text{ここで、}
\begin{gathered}
a > 0 \\
b > 0
\end{gathered}
\text{とする。}
\]