# Second Equation Alignment Column Aligning Incorrectly

Currently having problems with alignment of equations, I've checked multiple other threads and tried multiple methods to no avail. I'm sure it's a simple fix though.

I'm aware my code is also not the prettiest, I'm pretty new to Latex.

\begin{alignat*}{2}
\delta^{s(0)}_{\ell m}(k) &= \delta_{\ell m}(k) &&=  \sqrt{\frac{2}{\pi}}\int_0^\infty dr\, r^2\, \int d\Omega \delta(r, \Omega)k \, j_\ell(kr)Y^\ast_{\ell m} (\Omega) \\
&&=  i^\ell k \int d\Omega \,\delta(k, \Omega) \,Y^\ast_{\ell m}(\Omega) \\
\delta^{s(1)}_{\ell m}(k) &= \sqrt{\frac{2}{\pi}} \int_0^\infty dr \, r^2 \, \int d\Omega[1+\delta(r, \Omega]\frac{\mathbf{v(r)}\cdot\Omega}{aH}k^2 j'_\ell(kr)Y^\ast_{\ell m}(\Omega)
\end{alignat*}


As you can see I would like the two equations with one & to align at one point, and the equations with the double && to align at a different point. However my code is displaying this

It seems the equations with one & have aligned correctly but I can't get the others to align. I've also tried using &{}={}& and &&=& as I've also seen those used, but had no luck.

!!!EDIT!!!: Following the first comment, I'd like to clarify I'd like the equation to align similarly to below but with the second line aligned with the second = on the first line.

Since the 1st line has a total of 3 & tab-seps prior to the equation, so requires the 2nd line. Thus, the second line of the equation set needs an extra & at the beginning.

Then, I use \mathrlap for the right hand of the 3rd line. What this macro from the mathtools package does, is to typeset its argument rightward from the invocation point, but treat it as if it occupies zero horizontal space. As such, it can extend past the extent of the prior tab-sep & fields, without pushing them rightward.

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{mathtools}

\begin{document}
\begin{alignat*}{2}
\delta^{s(0)}_{\ell m}(k) &= \delta_{\ell m}(k) &&=  \sqrt{\frac{2}{\pi}}\int_0^\infty dr\, r^2\, \int d\Omega \delta(r, \Omega)k \, j_\ell(kr)Y^\ast_{\ell m} (\Omega) \\
%
&&&=  i^\ell k \int d\Omega \,\delta(k, \Omega) \,Y^\ast_{\ell m}(\Omega) \\
%
\delta^{s(1)}_{\ell m}(k) &= \mathrlap{\sqrt{\frac{2}{\pi}} \int_0^\infty dr \, r^2
\int d\Omega[1+\delta(r, \Omega]\frac{\mathbf{v(r)}\cdot\Omega}{aH}k^2 j'_\ell(kr)Y^\ast_{\ell m}(\Omega)}
\end{alignat*}
\end{document}


• You may want to add a (brief) explanation of how \mathrlap manages to succeed here. – Mico Jun 30 '17 at 11:07

I don't think you want to use an alignat* environment here. Instead, I believe you should be using an aligned environment nested inside an align* environment.

\documentclass{article}
\usepackage{amsmath} % for "align*" and "aligned" environments

\begin{document}
\begin{align*}
\delta^{s(0)}_{\ell m}(k)
&= \begin{aligned}[t]
\delta_{\ell m}(k)
&=  \sqrt{\frac{2}{\pi}}\int_0^\infty \mkern-6mu dr\, r^2
\int\! d\Omega\, \delta(r, \Omega)\,k \, j^{}_\ell(kr)Y^\ast_{\ell m} (\Omega) \\
&=  i^\ell k \int\! d\Omega \,\delta(k, \Omega) \,Y^\ast_{\ell m}(\Omega)
\end{aligned}\\
\delta^{s(1)}_{\ell m}(k)
&= \sqrt{\frac{2}{\pi}} \int_0^\infty \mkern-6mu dr \, r^2
\int\! d\Omega[1+\delta(r, \Omega]\frac{\mathbf{v(r)}\cdot\Omega}{aH}
\,k^2 j'_\ell(kr)Y^\ast_{\ell m}(\Omega)
\end{align*}
\end{document}