Have multiple align points

align

How can I achieve multiple align points as illustrated in the picture?

enter image description here

The corresponding latex code:

\begin{align*}
    \int_{}^{} \sin\left(x\right) \sin\left(x\right) \mathrm{d}x 
    =&-\sin\left(x\right) \cos\left(x\right) + \int_{}^{} \cos\left(x\right) ^{2} \mathrm{d}x 
    \\[10pt]
    =&-\sin\left(x\right) \cos\left(x\right) +\int_{}^{} \left( 1-\sin\left(x\right) ^{2} \right) \mathrm{d}x 
    \\[10pt]
    =&-\sin\left(x\right) \cos\left(x\right)  + \int_{}^{} 1 \ \mathrm{d}x - \int_{}^{} \sin\left(x\right) 
    ^{2}\mathrm{d}x 
    \\[10pt]
    \iff &\int_{}^{} \sin\left(x\right) ^{2}= \frac{-\sin\left(x\right) \cos\left(x\right) +x}
\end{align*}

Edit: I don't want to use \phantom{...} to align anything. Also, the integral signs should line up in the first and last line.

Best Answer

[I revised the answer to show the results of two different approaches to the alignment issue.]

If you prefer to align the integral symbols in the first and final rows, you may do so by encasing the first three rows in an interior aligned environment, and then align those three rows on their respective = symbols. You should also change all instances of =& to &= and fix a few further issues (such as supply the missing denominator term in the \frac expression in the final row), drop the _{}^{} "suffix" from all \int directives, and replace all instances of \left(x\right) with just x in order to cut down on the visual clutter.

Speaking for myself, I believe the whole expression would look just as good, and maybe even better [!], if all four rows were aligned on their = symbols. This may be achieved with the use of a single align* environment; see the lower half of the following screenshot.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'align*' and 'aligned' environments
\begin{document}

% alignment on the \int symbols in rows 1 and 4:
\begin{align*}
&\begin{aligned}
\int \sin x \sin x \,\mathrm{d}x 
    &= -\sin x \cos x + \int \cos^2 x \,\mathrm{d}x       \\
    &= -\sin x \cos x +\int ( 1-\sin^2 x ) \,\mathrm{d}x  \\
    &= -\sin x \cos x  + \int 1 \,\mathrm{d}x 
               - \int \sin^2 x \,\mathrm{d}x 
\end{aligned} \\[\jot]
\iff & {\int} \sin^2 x \,\mathrm{d}x = \frac{-\sin x \cos x +x}{2}
\end{align*}

\bigskip
% alignment of the `=` symbols in all 4 rows:
\begin{align*}
\int \sin x \sin x \,\mathrm{d}x 
    &= -\sin x \cos x + \int \cos^2 x \,\mathrm{d}x       \\
    &= -\sin x \cos x +\int ( 1-\sin^2 x ) \,\mathrm{d}x  \\
    &= -\sin x \cos x  + \int 1 \,\mathrm{d}x 
               - \int \sin^2 x \,\mathrm{d}x  \\[\jot]
\iff \int \sin^2 x \,\mathrm{d}x
    &= \frac{-\sin x \cos x +x}{2}
\end{align*}
\end{document}
Related Question