Nested alignments

I want to make alignments that look like this: which I have done by using

\begin{align}
& \frac{dx}{dt} = y \qquad \frac{dy}{dt} = x \\
\implies & \frac{d^2x}{dt^2} = \frac{d}{dt}\bigg(\frac{dx}{dt} \bigg) \\
& \; \; \; \; \; \; \, = \frac{dy}{dt} \\
& \; \; \; \; \; \; \, = x \\
\implies & \frac{d^2x}{dt^2} = x \\
\implies & x(t) = Ae^t + Be^{-t}
\end{align}


Of course, it's kinda silly to do \; \; \; \; ... and align them manually. However, when I try putting a \begin{align} within another \begin{align} like this

\begin{align}
\begin{align}

\end{align}
\end{align}


it gives me an error.

What is the correct way of doing this?

EDIT:

\begin{alignat} still doesn't quite get me there:

\begin{alignat}{2}
& \frac{dx}{dt} = y \qquad \frac{dy}{dt} = x \\
\implies & \frac{d^2x}{dt^2} && = \frac{d}{dt}\bigg(\frac{dx}{dt} \bigg) \\
&                   && = \frac{dy}{dt} \\
&                   && = x \\
\implies & \frac{d^2x}{dt^2} = x \\
\implies & x(t) = Ae^t + Be^{-t}
\end{alignat}


gives • You should use alignat rather than align -- alignat allows for multiple & 'columns' – user31729 Feb 2 at 18:52
• How should I use alignat? There is this massive spacing between the columns – glowstonetrees Feb 2 at 19:10
• Usually, the & is used before = – user31729 Feb 2 at 19:12
• but I also want to align the \implies – glowstonetrees Feb 2 at 19:13
• Well, that's not forbidden, of course – user31729 Feb 2 at 19:14

You can use alignat for this: \documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
\implies &&  \frac{\mathrm{d}^2x}{\mathrm{d}t^2} &= \frac{\mathrm{d}}{\mathrm{d}t} \biggl( \frac{\mathrm{d}x}{\mathrm{d}t} \biggr) \\
&&                                      &= \frac{\mathrm{d}y}{\mathrm{d}t} \\
&&                                      &= x \\
\implies &&  \frac{\mathrm{d}^2x}{\mathrm{d}t^2} &= x \\
\implies &&                                 x(t) &= Ae^t + Be^{-t}
\end{alignat*}

\end{document}

• I'm not sure why you used upright d's when the OP uses italic ones. Even I conform to \ln when the OP does on Math.SE, go figure! ;-) – egreg Feb 2 at 23:19

I wouldn't perform any alignment on the \implies symbols. To provide (visual) clarity of exposition, it suffices to perform alignment on the first instance of = in each line. I can't help but remark that the 5th line seems to be redundant.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\frac{dx}{dt}              &= y \qquad \frac{dy}{dt} = x \\
\implies \frac{d^2x}{dt^2} &= \frac{d}{dt}\biggl(\frac{dx}{dt}\biggr) \\
&= \frac{dy}{dt} \\
&= x \\
\implies \frac{d^2x}{dt^2} &= x \\
\implies x(t)              &= Ae^t + Be^{-t}
\end{align}
\end{document}


Nesting align environments directly doesn't work, because align environments start display math, so they can not be used inside math mode. Lucky for you, amsmath includes aligned as an alternative for cases like this (The t tells LaTeX to align the top line with the content outside of the environment):

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
& \frac{dx}{dt} = y \qquad \frac{dy}{dt} = x \\
\implies & \begin{aligned}[t]
\frac{d^2x}{dt^2} &= \frac{d}{dt}\bigg(\frac{dx}{dt} \bigg) \\
&= \frac{dy}{dt} \\
&= x
\end{aligned}\\
\implies & \frac{d^2x}{dt^2} = x \\
\implies & x(t) = Ae^t + Be^{-t}
\end{align}
\end{document} 