命令
\begin{align*} 1 = 1 = 2 & & 2 + 2 = 4 \end{align*}
將兩個方程式向右對齊。我如何更改此設定以將兩個身份左對齊?
答案1
通常的風格是每個方程中有一個&
,方程式之間有一個&
或一個\\
\documentclass{article}
\usepackage{amsmath}
\begin{document}
on one line
\begin{align*} 1 + 1 &= 2 & 2 + 2 &= 4 \end{align*}
on two
\begin{align*} 1 + 1 &= 2 \\ 2 + 2 &= 4 \end{align*}
\end{document}
或者如果你想要方程式左齊平添加fleqn
\documentclass[fleqn]{article}
\usepackage{amsmath}
\begin{document}
on one line
\begin{align*} 1 + 1 &= 2 & 2 + 2 &= 4 \end{align*}
on two
\begin{align*} 1 + 1 &= 2 \\ 2 + 2 &= 4 \end{align*}
\end{document}
答案2
我要注意的第一件事是第一個公式有一個拼字錯誤。應該是1 + 1 = 2
又不是1 = 1 = 2
。
您可以透過將兩個公式寫在不同的行上來左對齊它們,例如,您可以透過將 替換& &
為 a 來實現\\
,因為\\
引入了換行符:
\begin{align*}
1 + 1 &= 2\\
2 + 2 &= 4\\
\end{align*}
但是,如果您仍然希望兩個公式位於同一行,您也可以直接使用行間距。這些不會改變左側的對齊方式。最常用的行間距是~
(小間距)、\quad
(中距)、\qquad
(大間距)和\,
, \;
, ...(小間距):
\begin{align*}
1 + 1 = 2 \qquad 2 + 2 = 4
\end{align*}
但是,如果您堅持使用 ,則可以使用使用& &
之外的其他命令作為空格或列,例如:align*
& &
matrix
\begin{align*}
\begin{matrix} 1 + 1 = 2 & & 2 + 2 = 4 \end{matrix}
\end{align*}
實現此目的的另一種方法是將空文本插入 LaTeX 程式碼中,例如使用\text{}
, \operatorname{}
, ...:
\begin{align*}
1 + 1 = 2 \text{ } \text{ } \text{ } \text{ } 2 + 2 = 4
\end{align*}
如果您確實想讓所有內容都保留下來,您也可以以 開始文章\documentclass[fleqn]{article}
。