交错对齐级别;与前一行未与其前一行对齐的部分对齐

交错对齐级别;与前一行未与其前一行对齐的部分对齐

我怎样才能对齐数学方程式,就像我在源中对齐它一样?

\begin{align}
         &\sin(A+B)=\sin A\cos B + \sin B\cos A \\
         &\sin(A-B)=\sin A\cos B - \sin B\cos A
%
  \intertext{It's possible to eliminate the $\sin B\cos A$ terms by summing the two
  equations, it will then be possible to rearrange for
  $\sin A\cos B$:}
%
(2)+(3): &\sin(A+B) + \sin(A-B)&=2\sin A\cos B \nonumber\\
                 2\sin A\cos B &=\sin(A+B) + \sin(A-B) \nonumber
\end{align}

这是它现在的样子,并附有我希望它看起来的样子的注释:

我不太在意它是否居中,我认为它目前的左对齐看起来不舒服。

我计划在当前最后一行下方添加更多行显示数学,我也想将其与第一个未编号行的等号对齐。

答案1

嵌套对齐,代码更少无需猜测就能得到正确的数字。

但是,对齐完全没有必要,特别是在最后一行。我添加了一个替代解决方案。不过,反向相等似乎没什么用。

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\section{How you want it}

\begin{align}
         &\sin(A+B)=\sin A\cos B + \sin B\cos A \label{sum}\\
         &\sin(A-B)=\sin A\cos B - \sin B\cos A \label{diff}
\intertext{It's possible to eliminate the $\sin B\cos A$ terms by summing the two
  equations, it will then be possible to rearrange for
  $\sin A\cos B$:}
\eqref{sum}+\eqref{diff}{:}\qquad
      &\begin{aligned}[t]
    \sin(A+B) + \sin(A-B)&=2\sin A\cos B \\
    2\sin A\cos B &=\sin(A+B) + \sin(A-B)
   \end{aligned}
  \notag
\end{align}

\section{How I would do it}

\begin{gather}
  \sin(A+B)=\sin A\cos B + \sin B\cos A \label{sum+}\\
  \sin(A-B)=\sin A\cos B - \sin B\cos A \label{diff+}
\end{gather}
It's possible to eliminate the $\sin B\cos A$ terms by summing the two
equations, it will then be possible to rearrange for $\sin A\cos B$:
\begin{equation*}
\makebox[0pt][r]{$[\eqref{sum+}+\eqref{diff+}]$\qquad}
\begin{gathered}
  \sin(A+B) + \sin(A-B)=2\sin A\cos B \\
  2\sin A\cos B =\sin(A+B) + \sin(A-B)
\end{gathered}
\end{equation*}

\end{document} 

在此处输入图片描述

答案2

使用嵌套的 aligned

\documentclass{article}
\usepackage{mathtools, nccmath}

\begin{document}

\begin{align}
         &\sin(A+B)=\sin A\cos B + \sin B\cos A \\
         &\sin(A-B)=\sin A\cos B - \sin B\cos A
%
  \intertext{It's possible to eliminate the $\sin B\cos A$ terms by summing the two
  equations, it will then be possible to rearrange for
  $\sin A\cos B$:}
%
(2)+(3): \qquad\notag&\smash{\begin{aligned}[t]\sin(A+B) + \sin(A-B)&=2\sin A\cos B \\
                 2\sin A\cos B &=\sin(A+B) + \sin(A-B)
                 \end{aligned}}\\[-0.05ex]%
\end{align}

\end{document} 

在此处输入图片描述

相关内容