我在对齐此 MWE 中的某些项目时遇到了麻烦:
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\begin{document}
\begin{alignat}{2}
AAAAA &= BBBBBB \\
&&= CCCCCC + DDDDDDD,
\\[1ex]
EEE &= FFFFFFF \\
&&= 38 \, GGGGGGGG + 45 \, HHHHHHH,
\\[1ex]
KKKKKKKKK &= LL \\
&&= MM + N.
\end{alignat}
\end{document}
预览:
我的代码中用 $CCC\dots + DDD\dots$、$38 GGG \dots$ 和 $MM + N$ 标识的实际行实际上相当长,无法与它们上方的部分($BBB\dots$ 等)对齐。但是,我希望它们像这样对齐:
那么我该如何实现这个目标呢?
换句话说,短线 (1)、(3) 和 (5) 应保持对齐,而较长的线 (2)、(4) 和 (6) 应对齐。
编辑 以下是我的真实数学输出,来自三个选择。第一个是一个简单的对齐环境,但较长的部分放在右边距。第二个版本是收集环境有三个单独对齐的部分。第三个版本是一个简单的对齐,带有负空格,正如下面一些答案所建议的那样。那么哪一个是最好的、最不令人困惑的输出呢?
根据评论中 egreg 的要求,我添加了制作最后一张图片的(简化)代码:
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tensor}
\begin{document}
Blabla bla bla bla blablabla bla blabla bla bla blablabla:
\begin{align*}
\tensor{\gamma}{_i} \, \tensor{\gamma}{_j} + \tensor{\gamma}{_j} \, \tensor{\gamma}{_i} &= (\, \tensor{a}{_i} + a_i^{\dag} )(\, \tensor{a}{_j} + a_j^{\dag} ) + (\, \tensor{a}{_j} + a_j^{\dag} )(\, \tensor{a}{_i} + a_i^{\dag} ) \\
&= \tensor{a}{_i} \: \tensor{a}{_j} + \tensor{a}{_i} \: a_j^{\dag} + a_i^{\dag} \: \tensor{a}{_j} + a_i^{\dag} \: a_j^{\dag} + \tensor{a}{_j} \: \tensor{a}{_i} + \tensor{a}{_j} \: a_i^{\dag} + a_j^{\dag} \: \tensor{a}{_i} + a_j^{\dag} \: a_i^{\dag} = 2 \, \tensor{\delta}{_{ij}}, \\[1ex]
\tensor{\gamma}{_{n \,+\, i}} \, \tensor{\gamma}{_{n \,+\, j}} + \tensor{\gamma}{_{n \,+\, j}} \, \tensor{\gamma}{_{n \,+\, i}} &= -\: (\, \tensor{a}{_i} - a_i^{\dag} )(\, \tensor{a}{_j} - a_j^{\dag} ) - (\, \tensor{a}{_j} - a_j^{\dag} )(\, \tensor{a}{_i} - a_i^{\dag} ) \\
&= -\: \tensor{a}{_i} \: \tensor{a}{_j} + \tensor{a}{_i} \: a_j^{\dag} + a_i^{\dag} \: \tensor{a}{_j} - a_i^{\dag} \: a_j^{\dag} - \tensor{a}{_j} \: \tensor{a}{_i} + \tensor{a}{_j} \: a_i^{\dag} + a_j^{\dag} \: \tensor{a}{_i} - a_j^{\dag} \: a_i^{\dag} = 2 \, \tensor{\delta}{_{ij}}, \\[1ex]
\tensor{\gamma}{_{n \,+\, i}} \, \tensor{\gamma}{_j} + \tensor{\gamma}{_j} \, \tensor{\gamma}{_{n \,+\, i}} &= -\: i (\, \tensor{a}{_i} - a_i^{\dag} )(\, \tensor{a}{_j} + a_j^{\dag} ) - i (\, \tensor{a}{_j} + a_j^{\dag} )(\, \tensor{a}{_i} - a_i^{\dag} ) \\
&= -\: i \, \tensor{a}{_i} \: \tensor{a}{_j} - i \, \tensor{a}{_i} \: a_j^{\dag} + i \, a_i^{\dag} \: \tensor{a}{_j} + i \, a_i^{\dag} \: a_j^{\dag} - i \, \tensor{a}{_j} \: \tensor{a}{_i} + i \, \tensor{a}{_j} \: a_i^{\dag} - i \, a_j^{\dag} \: \tensor{a}{_i} + i \, a_j^{\dag} \: a_i^{\dag} = 0.
\end{align*}
Blabla bla bla bla blablabla bla blabla bla bla blablabla:
\begin{gather*}
\begin{aligned}
\tensor{\gamma}{_i} \, \tensor{\gamma}{_j} + \tensor{\gamma}{_j} \, \tensor{\gamma}{_i} &= (\, \tensor{a}{_i} + a_i^{\dag} )(\, \tensor{a}{_j} + a_j^{\dag} ) + (\, \tensor{a}{_j} + a_j^{\dag} )(\, \tensor{a}{_i} + a_i^{\dag} ) \\
&= \tensor{a}{_i} \: \tensor{a}{_j} + \tensor{a}{_i} \: a_j^{\dag} + a_i^{\dag} \: \tensor{a}{_j} + a_i^{\dag} \: a_j^{\dag} + \tensor{a}{_j} \: \tensor{a}{_i} + \tensor{a}{_j} \: a_i^{\dag} + a_j^{\dag} \: \tensor{a}{_i} + a_j^{\dag} \: a_i^{\dag} = 2 \, \tensor{\delta}{_{ij}},
\end{aligned}
\\[1ex]
\begin{aligned}
\tensor{\gamma}{_{n \,+\, i}} \, \tensor{\gamma}{_{n \,+\, j}} + \tensor{\gamma}{_{n \,+\, j}} \, \tensor{\gamma}{_{n \,+\, i}} &= -\: (\, \tensor{a}{_i} - a_i^{\dag} )(\, \tensor{a}{_j} - a_j^{\dag} ) - (\, \tensor{a}{_j} - a_j^{\dag} )(\, \tensor{a}{_i} - a_i^{\dag} ) \\
&= -\: \tensor{a}{_i} \: \tensor{a}{_j} + \tensor{a}{_i} \: a_j^{\dag} + a_i^{\dag} \: \tensor{a}{_j} - a_i^{\dag} \: a_j^{\dag} - \tensor{a}{_j} \: \tensor{a}{_i} + \tensor{a}{_j} \: a_i^{\dag} + a_j^{\dag} \: \tensor{a}{_i} - a_j^{\dag} \: a_i^{\dag} = 2 \, \tensor{\delta}{_{ij}},
\end{aligned}
\\[1ex]
\begin{aligned}
\tensor{\gamma}{_{n \,+\, i}} \, \tensor{\gamma}{_j} + \tensor{\gamma}{_j} \, \tensor{\gamma}{_{n \,+\, i}} &= -\: i (\, \tensor{a}{_i} - a_i^{\dag} )(\, \tensor{a}{_j} + a_j^{\dag} ) - i (\, \tensor{a}{_j} + a_j^{\dag} )(\, \tensor{a}{_i} - a_i^{\dag} ) \\
&= -\: i \bigl( \, \tensor{a}{_i} \: \tensor{a}{_j} + \tensor{a}{_i} \: a_j^{\dag} - a_i^{\dag} \: \tensor{a}{_j} - a_i^{\dag} \: a_j^{\dag} + \tensor{a}{_j} \: \tensor{a}{_i} - \tensor{a}{_j} \: a_i^{\dag} + a_j^{\dag} \: \tensor{a}{_i} - a_j^{\dag} \: a_i^{\dag} \bigr) = 0.
\end{aligned}
\end{gather*}
Blabla bla bla bla blablabla bla blabla bla bla blablabla:
\begin{align*}
\tensor{\gamma}{_i} \, \tensor{\gamma}{_j} + \tensor{\gamma}{_j} \, \tensor{\gamma}{_i} &= (\, \tensor{a}{_i} + a_i^{\dag} )(\, \tensor{a}{_j} + a_j^{\dag} ) + (\, \tensor{a}{_j} + a_j^{\dag} )(\, \tensor{a}{_i} + a_i^{\dag} ) \\
&\hspace{-2cm}= \tensor{a}{_i} \: \tensor{a}{_j} + \tensor{a}{_i} \: a_j^{\dag} + a_i^{\dag} \: \tensor{a}{_j} + a_i^{\dag} \: a_j^{\dag} + \tensor{a}{_j} \: \tensor{a}{_i} + \tensor{a}{_j} \: a_i^{\dag} + a_j^{\dag} \: \tensor{a}{_i} + a_j^{\dag} \: a_i^{\dag} = 2 \, \tensor{\delta}{_{ij}},
\\[1ex]
\tensor{\gamma}{_{n \,+\, i}} \, \tensor{\gamma}{_{n \,+\, j}} + \tensor{\gamma}{_{n \,+\, j}} \, \tensor{\gamma}{_{n \,+\, i}} &= -\: (\, \tensor{a}{_i} - a_i^{\dag} )(\, \tensor{a}{_j} - a_j^{\dag} ) - (\, \tensor{a}{_j} - a_j^{\dag} )(\, \tensor{a}{_i} - a_i^{\dag} ) \\
&\hspace{-2cm}= -\: \tensor{a}{_i} \: \tensor{a}{_j} + \tensor{a}{_i} \: a_j^{\dag} + a_i^{\dag} \: \tensor{a}{_j} - a_i^{\dag} \: a_j^{\dag} - \tensor{a}{_j} \: \tensor{a}{_i} + \tensor{a}{_j} \: a_i^{\dag} + a_j^{\dag} \: \tensor{a}{_i} - a_j^{\dag} \: a_i^{\dag} = 2 \, \tensor{\delta}{_{ij}},
\\[1ex]
\tensor{\gamma}{_{n \,+\, i}} \, \tensor{\gamma}{_j} + \tensor{\gamma}{_j} \, \tensor{\gamma}{_{n \,+\, i}} &= -\: i (\, \tensor{a}{_i} - a_i^{\dag} )(\, \tensor{a}{_j} + a_j^{\dag} ) - i (\, \tensor{a}{_j} + a_j^{\dag} )(\, \tensor{a}{_i} - a_i^{\dag} ) \\
&\hspace{-2cm}= -\: i \bigl( \, \tensor{a}{_i} \: \tensor{a}{_j} + \tensor{a}{_i} \: a_j^{\dag} - a_i^{\dag} \: \tensor{a}{_j} - a_i^{\dag} \: a_j^{\dag} + \tensor{a}{_j} \: \tensor{a}{_i} - \tensor{a}{_j} \: a_i^{\dag} + a_j^{\dag} \: \tensor{a}{_i} - a_j^{\dag} \: a_i^{\dag} \bigr) = 0.
\end{align*}
\end{document}
答案1
抱歉,但你自己的麻烦是你自己造成的。
答案2
您的对齐不正确,因为在偶数行上您缺少一个,&
所以片段是右对齐而不是左对齐,这在第一个块中显示,但看起来您想要在第二个块中对齐(这看起来有点令人困惑但是......)
请求形式中的负间距完全掩盖了数学原理:指向相同值的 = 是不是已对齐,但 = 指的是不同的值是对齐。
如果值太宽而无法对齐所有 =,我会对齐引用相同值的 =,但允许各个方程式分别对齐,如 ccc 中所示
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\begin{document}
aaa
\begin{alignat}{2}
AAAAA &= BBBBBB \\
&&&= CCCCCC + DDDDDDD,
\\[1ex]
EEE &= FFFFFFF \\
&&&= 38 \, GGGGGGGG + 45 \, HHHHHHH,
\\[1ex]
KKKKKKKKK &= LL \\
&&&= MM + N.
\end{alignat}
bbb
\begin{alignat}{1}
AAAAA &= BBBBBB \\
&\hspace{-1cm}= CCCCCC + DDDDDDD,
\\[1ex]
EEE &= FFFFFFF \\
&\hspace{-1cm}= 38 \, GGGGGGGG + 45 \, HHHHHHH,
\\[1ex]
KKKKKKKKK &= LL \\
&\hspace{-1cm}= MM + N.
\end{alignat}
ccc
\begin{align}
AAAAA &= BBBBBB \\
&= CCCCCC + DDDDDDD,
\end{align}
\begin{align}
EEE &= FFFFFFF \\
&= 38 \, GGGGGGGG + 45 \, HHHHHHH,
\end{align}
\begin{align}
KKKKKKKKK &= LL \\
&= MM + N.
\end{align}
\end{document}
答案3
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\def\z#1{\llap{$\mathrlap{\displaystyle#1}$\hspace{3.5em}}}
\begin{document}
\begin{alignat}{2}
AAAAA &= BBBBBB \\
&\z{= CCCCCC + DDDDDDD,}
\\[1ex]
EEE &= FFFFFFF \\
&\z{= 38 \, GGGGGGGG + 45 \, HHHHHHH,}
\\[1ex]
KKKKKKKKK &= LL \\
&\z{= MM + N.}
\end{alignat}
\end{document}