以下代码几乎满足了我的要求。您会看到,在显示的方程式的最后五行中,大多数表达式都向右移动了。我希望这些行中的第一个“+”与第 2 行和第 3 行中的第一个“+”对齐。谢谢。
\documentclass[10pt]{amsart}
\usepackage{}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{mathtools}
\usepackage{tikz}
\begin{document}
\begin{alignat*}{3}
\vert x + y + z \vert^{2}
&= [\cos{a} + \cos{b} + \cos{c}]^{2} + [\sin{a} + \sin{b} + \sin{c}]^{2} \\
&= \begin{aligned}[t] 3 &+ [2\cos{a}\cos{b} + 2\cos{a}\cos{c} + 2\cos{b}\cos{c}] \\
&+ [2\sin{a}\sin{b} + 2\sin{a}\sin{c} + 2\sin{b}\sin{c}]
\end{aligned} \\
&= 3&& + \bigl[&&\cos(a + b) + \cos(a + c) + \cos(b + c) \\
&&&&&+ \cos(a - b) + \cos(a - c) + \cos(b - c)\bigr] \\
&&&+ \bigl[&&\cos(a - b) + \cos(a - c) + \cos(b - c) \\
&&&&&- \bigl(\cos(a + b) + \cos(a + c) + \cos(b + c)\bigr) \bigr] \\
&= 3&&\mathrlap{{}+ 2\bigl(\cos(a - b) + \cos(a - c) + \cos(b - c)\bigr).}
\end{alignat*}
\end{document}
答案1
参考你的上一个问题:
\mathrlap
您也可以在前三行使用。
\documentclass[10pt]{amsart}
\usepackage{mathtools}% loads also amsmath
\begin{document}
\begin{alignat*}{3}
\vert x + y + z \vert^{2}
&= \mathrlap{[\cos{a} + \cos{b} + \cos{c}]^{2} + [\sin{a} + \sin{b} + \sin{c}]^{2}} \\
&= 3 &&\mathrlap{{}+ [2\cos{a}\cos{b} + 2\cos{a}\cos{c} + 2\cos{b}\cos{c}]} \\
&&&\mathrlap{{}+ [2\sin{a}\sin{b} + 2\sin{a}\sin{c} + 2\sin{b}\sin{c}]}\\
&= 3&& + \bigl[&&\cos(a + b) + \cos(a + c) + \cos(b + c) \\
&&&&&+ \cos(a - b) + \cos(a - c) + \cos(b - c)\bigr] \\
&&&+ \bigl[&&\cos(a - b) + \cos(a - c) + \cos(b - c) \\
&&&&&- \bigl(\cos(a + b) + \cos(a + c) + \cos(b + c)\bigr) \bigr] \\
&= 3&&\mathrlap{{}+ 2\bigl(\cos(a - b) + \cos(a - c) + \cos(b - c)\bigr).}
\end{alignat*}
\end{document}
结果:
\mathrlap
或者仅在第一行使用,并aligned
在其他行使用。
\documentclass[10pt]{amsart}
\usepackage{mathtools}% loads also amsmath
\begin{document}
\begin{alignat*}{2}
\vert x + y + z \vert^{2}
&= \mathrlap{[\cos{a} + \cos{b} + \cos{c}]^{2} + [\sin{a} + \sin{b} + \sin{c}]^{2}} \\
&= 3 &&
\!\begin{aligned}[t]
& + [2\cos{a}\cos{b} + 2\cos{a}\cos{c} + 2\cos{b}\cos{c}] \\
&+ [2\sin{a}\sin{b} + 2\sin{a}\sin{c} + 2\sin{b}\sin{c}]
\end{aligned} \\
&= 3&&
\!\begin{aligned}[t]
{}+ \bigl[&\cos(a + b) + \cos(a + c) + \cos(b + c) \\
&+ \cos(a - b) + \cos(a - c) + \cos(b - c)\bigr]
\end{aligned} \\
&&&
\!\begin{aligned}[t]
{}+ \bigl[&\cos(a - b) + \cos(a - c) + \cos(b - c) \\
&- \bigl(\cos(a + b) + \cos(a + c) + \cos(b + c)\bigr) \bigr]
\end{aligned}\\
&= 3&&+ 2\bigl(\cos(a - b) + \cos(a - c) + \cos(b - c)\bigr).
\end{alignat*}
\end{document}
结果:
前面\!
的\begin{aligned}[t]
是必需的,因为aligned
插入一个\,
答案2
据我了解,您想要获得以下内容(哦!):
\documentclass[10pt]{amsart}
\usepackage{}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{mathtools}
\usepackage{tikz}
\begin{document}
\begin{alignat*}{3}
\vert x + y + z \vert^{2}
&= [\cos{a} + \cos{b} + \cos{c}]^{2} + [\sin{a} + \sin{b} + \sin{c}]^{2} \\
&= \begin{aligned}[t] 3 &+ [2\cos{a}\cos{b} + 2\cos{a}\cos{c} + 2\cos{b}\cos{c}] \\
&+ [2\sin{a}\sin{b} + 2\sin{a}\sin{c} + 2\sin{b}\sin{c}]
\end{aligned}\\
&= \begin{aligned}[t]3 &+ \bigl[\cos(a + b) + \cos(a + c) + \cos(b + c) \\
& + \cos(a - b) + \cos(a - c) + \cos(b - c)\bigr] \\
&+ \bigl[\cos(a - b) + \cos(a - c) + \cos(b - c) \\
&- \bigl(\cos(a + b) + \cos(a + c) + \cos(b + c)\bigr) \bigr] \\
\end{aligned} \\
&= 3\mathrlap{{}+ 2\bigl(\cos(a - b) + \cos(a - c) + \cos(b - c)\bigr).}
\end{alignat*}
\end{document}
我不确定最后一行是否应该看起来有点不同,正如您的示例所建议的那样,但我保留了它。然而,我建议使用以下版本:
\documentclass[10pt]{amsart}
\usepackage{}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{mathtools}
\usepackage{tikz}
\begin{document}
\begin{alignat*}{3}
\vert x + y + z \vert^{2}
&= [\cos{a} + \cos{b} + \cos{c}]^{2} + [\sin{a} + \sin{b} + \sin{c}]^{2} \\
&= \!\begin{aligned}[t] 3 &+ [2\cos{a}\cos{b} + 2\cos{a}\cos{c} + 2\cos{b}\cos{c}] \\
&+ [2\sin{a}\sin{b} + 2\sin{a}\sin{c} + 2\sin{b}\sin{c}]
\end{aligned}\\
&=\! \begin{aligned}[t]3 &+ \bigl[\cos(a + b) + \cos(a + c) + \cos(b + c) \\
& + \cos(a - b) + \cos(a - c) + \cos(b - c)\bigr] \\
&+ \bigl[\cos(a - b) + \cos(a - c) + \cos(b - c) \\
&- \bigl(\cos(a + b) + \cos(a + c) + \cos(b + c)\bigr) \bigr] \\
\end{aligned} \\
% &= 3\mathrlap{{}+ 2\bigl(\cos(a - b) + \cos(a - c) + \cos(b - c)\bigr).}
&= 3{{}+ 2\bigl(\cos(a - b) + \cos(a - c) + \cos(b - c)\bigr).}
\end{alignat*}
\end{document}