修复嵌套对齐

修复嵌套对齐

我有 :

\begin{align}
\langle\lvert\mathcal{M}_{fi}\rvert^2\rangle&=\dfrac{16e^4}{4q^4}&&\left[p_2^\mu p_1^\nu-g^{\mu\nu}(p_1\cdot p_2)+p_2^\nu p_1^\mu +m^2g^{\mu\nu}\right]\times\left[p_\
{3\mu} p_{4\nu}-g_{\mu\nu}(p_3\cdot p_4)+p_{4\nu} p_{4\mu} +M^2g_{\mu\nu}\right]\\
&=\dfrac{4e^4}{q^4}&&\left[(p_2\cdot p_3)(p_1\cdot p_4)-(p_1\cdot p_4)(p_3\cdot p_4)+(p_2\cdot p_4)(p_1\cdot p_3)-M^2(p_1\cdot p_2)\right.\\
& &&-(p_1\cdot p_2)(p_3\cdot p_4)+4(p_1\cdot p_2)(p_3\cdot p_4)-(p_1\cdot p_2)(p_3\cdot p_4)+4M^2(p_1\cdot p_2)\\
& &&+(p_1\cdot p_3)(p_2\cdot p_4)-(p_1\cdot p_2)(p_3\cdot p_4)+(p_1\cdot p_4)(p_2\cdot p_3)-M^2(p_1\cdot p_2)\\
& &&-\left. m^2(p_3\cdot p_4)+4m^2(p_3\cdot p_4)-m^2(p_3\cdot p_4)+4m^2M^2\right]\\
&=\dfrac{4e^4}{q^4}&&\left[2M^2(p_1\cdot p_2)+2m^2(p_3\cdot p_4)+4m^2M^2+2(p_1\cdot p_4)(p_2\cdot p_3)+2(p_1\cdot p_3)(p_2\cdot p_4)\right].
\end{align}

输出结果如下: 输出

我如何改进代码以便:

  1. 分数和左方括号之间的空格被删除了?
  2. (选修的)加号和减号与左方括号对齐吗?

答案1

您可以使用alignat不在列对之间添加空格的方法,例如align并将其嵌套aligned在其中。

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat}{2}
\langle\lvert\mathcal{M}_{fi}\rvert^2\rangle
  &=&\frac{16e^4}{4q^4}
    &\begin{aligned}[t]
      &\bigl[p_2^\mu p_1^\nu-g^{\mu\nu}(p_1\cdot p_2)+p_2^\nu p_1^\mu+m^2g^{\mu\nu}\bigr]
      \\
      &\times\bigl[p_{3\mu}p_{4\nu}-g_{\mu\nu}(p_3\cdot p_4)+p_{4\nu}p_{4\mu}+M^2g_{\mu\nu}\bigr]
      \end{aligned}
\\
  &=&\frac{4e^4}{q^4}
    &\begin{aligned}[t]
      &\bigl[(p_2\cdot p_3)(p_1\cdot p_4)-(p_1\cdot p_4)(p_3\cdot p_4)
            +(p_2\cdot p_4)(p_1\cdot p_3)
      \\
      &-M^2(p_1\cdot p_2)-(p_1\cdot p_2)(p_3\cdot p_4)+4(p_1\cdot p_2)(p_3\cdot p_4)
      \\
      &-(p_1\cdot p_2)(p_3\cdot p_4)+4M^2(p_1\cdot p_2)+(p_1\cdot p_3)(p_2\cdot p_4)
      \\
      &-(p_1\cdot p_2)(p_3\cdot p_4)+(p_1\cdot p_4)(p_2\cdot p_3)-M^2(p_1\cdot p_2)
      \\
      &-m^2(p_3\cdot p_4)+4m^2(p_3\cdot p_4)-m^2(p_3\cdot p_4)+4m^2M^2\bigr]
      \end{aligned}
\\
  &=&\frac{4e^4}{q^4}
    &\begin{aligned}[t]
      &\bigl[2M^2(p_1\cdot p_2)+2m^2(p_3\cdot p_4)+4m^2M^2
      \\
      &+2(p_1\cdot p_4)(p_2\cdot p_3)+2(p_1\cdot p_3)(p_2\cdot p_4)\bigr].
      \end{aligned}
\end{alignat}

\end{document}

\left\right\bigl\bigr就足够了。我不会把加号和减号移到左边,因为它们属于托架中。

在此处输入图片描述

答案2

还有一个解决方案alignat,但我使用medsize来自的环境nccmath(约 80% 的\displaystyle)以减少行数。此外,我使用\MoveEqLeft来自mathtools, to have the+ and–` 的命令,符号与左括号对齐,但按其中心对齐:

\documentclass{article}
\usepackage{mathtools, nccmath}
\usepackage[showframe]{geometry}

\begin{document}

\begin{alignat}{2}
  \left\langle\lvert\mathcal{M}_{fi}\rvert^2\right\rangle&=\mfrac{16e^4}{4q^4}\begin{medsize}\bigl[p_2^\mu p_1^\nu-g^{\mu \nu}(p_1 \cdot p_2)+p_2^\nu p_1^\mu +m^2g^{\mu \nu}\bigr]%
   \times \bigl[p_{3\mu } p_{4\nu } -g_{\mu \nu}(p_3 \cdot p_4)+p_{4\nu } p_{4\mu } +M^2g_{\mu \nu}\bigr]
  \end{medsize}
  \\
    & =\mfrac{4e^4}{q^4}\!\!\begin{medsize}\begin{aligned}[t] & \bigl[(p_2 \cdot p_3)(p_1 \cdot p_4)-(p_1 \cdot p_4)(p_3 \cdot p_4)+(p_2 \cdot p_4)(p_1 \cdot p_3)-M^2(p_1 \cdot p_2)-(p_1 \cdot p_2)(p_3 \cdot p_4) \\%
  \MoveEqLeft[0.4] + 4 (p_1 \cdot p_2)(p_3 \cdot p_4)-(p_1 \cdot p_2)(p_3 \cdot p_4)+4M^2(p_1 \cdot p_2)(p_1 \cdot p_3)(p_2 \cdot p_4)-(p_1 \cdot p_2)(p_3 \cdot p_4)\\%
  \MoveEqLeft[0.4] + (p_1 \cdot p_4)(p_2 \cdot p_3)-M^2(p_1 \cdot p_2) -m^2(p_3 \cdot p_4)+4m^2(p_3 \cdot p_4)-m^2(p_3 \cdot p_4)+4m^2M^2\bigr]
  \end{aligned}
  \end{medsize}\\
  &=\mfrac{4e^4}{q^4}\begin{medsize}\bigl[2M^2(p_1 \cdot p_2)+2m^2(p_3 \cdot p_4) +4m^2M^2%
  +2(p_1 \cdot p_4)(p_2 \cdot p_3) +2(p_1 \cdot p_3)(p_2 \cdot p_4)\bigr].\end{medsize}
\end{alignat}

\end{document} 

输出

相关内容