4

I want to make alignments that look like this:

enter image description here

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

enter image description here

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

3 Answers 3

2

You can use alignat for this:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
           &\quad& \frac{\mathrm{d}x}{\mathrm{d}t} &= y \qquad \frac{\mathrm{d}y}{\mathrm{d}t} = x \\
  \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}
1
  • 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, 2019 at 23:19
2

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.

enter image description here

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

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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .