# Staggered levels of alignment ; align to parts of previous line that weren't aligned with the lines before it

How can I align the maths equation as I've aligned it in the source?

\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}


Here's what it currently looks like, with annotations as to how I'd like it to look:

I don't really care about it being centred, I think it just looks uncomfortably left-aligned as it currently is.

I plan to add more lines of display maths below the current last one, which I'd also like to align with the equal sign of that first unnumbered line.

Nested aligned, with less code and the correct numbers without guessing at them.

However, the alignment is not at all necessary, particularly in the last line. I add an alternative solution. The reverse equality doesn't seem useful, though.

\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$:}
&\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}


Use a nested 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}


• In \begin{aligned}[t] what's the [t] for? – theonlygusti Sep 20 '17 at 16:11
• the [t] says to align the baseline of the top line with the baseline of what precedes the &. – barbara beeton Sep 20 '17 at 16:21
• How can I add a numbered equation at the very end of that aligned environment? – theonlygusti Sep 20 '17 at 16:23
• By default, it will be placed on the line of the last but one equation. I don't know if there's a simple solution. – Bernard Sep 20 '17 at 16:33
• It's because it's defined in the amsmath documentation, but it's the same. Also, it's shorter to type. – Bernard Sep 20 '17 at 16:49