我想把两个简单的等式一个接一个地写在下方,但是对齐环境似乎向右对齐,而我想将它们向左对齐。代码如下:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{aligned}
S_1' (x_0) = S_n' (x_n) = 0 \quad \text{(clamped boundary conditions),} \quad \text{or} \\
S_1'' (x_0) = S_n'' (x_n) = 0 \quad \text{(natural boundary conditions)}
\end{aligned}
\end{equation*}
\end{document}
产生
但我希望它S_1''(x_0)
直接出现在下方S_1'(x_0)
,而不是移动到左侧。您知道解决办法吗?
答案1
如果要将材料左对齐,则需要通过&
符号提供对齐点。
\documentclass{article}
\usepackage{amsmath} % for 'align*' environment
\begin{document}
\begin{align*}
&S_1' (x_0) = S_n' (x_n) = 0 \quad \text{(clamped boundary conditions), or} \\
&S_1'' (x_0) = S_n'' (x_n) = 0 \quad \text{(natural boundary conditions)}
\end{align*}
\end{document}
答案2
比对点用 标记&
。如果存在多个组(比对列),则进一步&
使用 来引入每个新组(第一组除外),因此 n 列比对需要 2n-1 个与号。
例如,您可以使用此代码:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
S_1' (x_0) &= S_n' (x_n) = 0 &&\text{(clamped boundary conditions),} \quad \text{or} \\
S_1'' (x_0) &= S_n'' (x_n) = 0 && \text{(natural boundary conditions)}
\end{align*}
\end{document}
我还建议根据这些解决方案alignat*
,使用\ArrowBetweenLines
来自的命令mathtools
(在这种情况下无需加载amsmath
),或者flalign*
:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{alignat*}{3}
& & S_1' (x_0) &= S_n' (x_n) = 0 &\quad & \text{(clamped boundary conditions),} \\
\ArrowBetweenLines[\text{or}]%
& & S_1'' (x_0) &= S_n'' (x_n) = 0 & & \text{(natural boundary conditions)}
\end{alignat*}
\begin{flalign*}
& & S_1' (x_0) &= S_n' (x_n) = 0 &&\text{(clamped boundary conditions),} \\
& \text{or} & S_1'' (x_0) &= S_n'' (x_n) = 0 && \text{(natural boundary conditions)}
\end{flalign*}
\end{document}
答案3
您忘记了对齐锚点(&符号):
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{aligned}
S_1' (x_0) & = S_n' (x_n) = 0 \quad \text{(clamped boundary conditions),} \quad \text{or} \\
S_1'' (x_0) & = S_n'' (x_n) = 0 \quad \text{(natural boundary conditions)}
\end{aligned}
\end{equation*}
\end{document}