# Collectively aligning multiple align environments [duplicate]

I am using amsmath, and I want to be able to break a mathematical derivation into multiple align environments while maintaining their collective alignment. In particular, I would like to horizontally align an entire derivation as though it were one align environment for the purposes of visual flow, so that when the derivation continues in the next align, the eye can easily follow from where it left off, despite arbitrary explanatory text at any point in the middle.

As far as I'm aware, aligning align environments in this fashion is not directly possible. Is there a simple modification that can be made or a straightforward package that can be used to effectively "link" multiple align environments into one?

# MWE

\documentclass{article}
\usepackage{amsmath}

\begin{document}

This alternate derivation of the quadratic formula proceeds by first multiplying the equation by $4a$, rearranging, and adding $b^2$ to both sides:
\begin{align}
ax^2 + bx + c &= 0 \\
4 a^2 x^2 + 4abx + 4ac &= 0 \\
4 a^2 x^2 + 4abx &= -4ac \\
4 a^2 x^2 + 4abx + b^2 &= b^2 - 4ac
\end{align}

Then, having completed the square on the left-hand-side, factor it, take the square root, and solve for $x$:
\begin{align}
(2ax + b)^2 &= b^2 - 4ac \\
2ax + b &= \pm \sqrt{b^2-4ac} \\
2ax &= -b \pm \sqrt{b^2-4ac} \\
x &= \frac{-b \pm \sqrt{b^2-4ac}}{2a}
\end{align}

\end{document}


# Output

-

## marked as duplicate by Werner, dustin, Heiko Oberdiek, zeroth, mafpJul 21 '13 at 21:25

This question was marked as an exact duplicate of an existing question.

– Werner Jun 19 '13 at 23:37
@Werner Thanks. Using \intertext{} for explanatory text seems close to what I'm looking for, but what if I need a paragraph break somewhere in there? – Tim Parenti Jun 19 '13 at 23:42
@TimParenti Than you have to ask yourself if those equations are still related enough should they even be aligned across paragraphs. Instead of \par or a blank line you could use the (potentially dangerous) macro \endgraf: When is it better to use \par than \endgraf? – Qrrbrbirlbel Jun 20 '13 at 0:17
This question shows other options as well: Alignment of equals sign in multiple align environments – Qrrbrbirlbel Jun 20 '13 at 0:20
i think this one may have an answer you can use: Adding multiple paragraphs between aligned equations – barbara beeton Jun 21 '13 at 18:56

You can use the tabbing environment. This way you set up the desired spacing and then you can reuse it so they align down the page.

So if I wanted, the spacing below:

\begin{tabbing} \hspace{2cm} \= \hspace{.5cm} \= \hspace{3cm} \= \kill
Your equations here separated by \> \> and math delimiters for the math \\
$$x$$ \> $$=$$ \> $$6x$$\\
....
\end{tabbing}


If I invoke this later, it will align with the previous tabbing. If you want to center the equations, add \hspace{xcm} \= where x is the desired cms to center the line.

Someone taught me this on one of my posts:

If you want numbering in the tabbing environment, use \tagthisline and insert this into your preamble:

% line numbering for tabbing
\newcommand{\tagthisaux}{%
\refstepcounter{equation}%
(\theequation)%
}
\newcommand{\tagthisline}{\\tagthisaux}


\documentclass{article}
\usepackage{amsmath}

\begin{document}

This alternate derivation of the quadratic formula proceeds by first multiplying
the equation by $4a$, rearranging, and adding $b^2$ to both sides:
\begin{tabbing} \hspace{3cm} \= \hspace{3cm} \= \hspace{.5cm} \= \hspace{3cm} \=
\kill
\> $$ax^2 + bx + c$$ \> $$=$$ \> $$0$$ \\
\> $$4 a^2 x^2 + 4abx + 4ac$$ \> $$=$$ \> $$0$$ \\
\> $$4 a^2 x^2 + 4abx$$ \> $$=$$ \> $$-4ac$$ \\
\> $$4 a^2 x^2 + 4abx + b^2$$ \> $$=$$ \> $$b^2 - 4ac$$
\end{tabbing}
Then, having completed the square on the left-hand-side, factor it, take the
square root, and solve for $x$:
\begin{tabbing} \hspace{4.5cm} \= \hspace{1.5cm} \= \hspace{.5cm} \=
\hspace{1cm} \= \kill
\> $$(2ax + b)^2$$ \> $$=$$ \> $$b^2 - 4ac$$ \\
\> $$2ax + b$$ \> $$=$$ \> $$\pm \sqrt{b^2-4ac}$$ \\
\> $$2ax$$ \> $$=$$ \> $$-b \pm \sqrt{b^2-4ac}$$ \\
\> $$x$$ \> $$=$$ \> $$\frac{-b \pm \sqrt{b^2-4ac}}{2a}$$
\end{tabbing}

\end{document}


As you can see you just need the first two to add up to the same value which is 6 then they align at the =

Code with \tagthisline command:

If you want to increase the space between the lines, you can add [.3cm] after each \\. Also, you can use \displaystyle in the delimiters to get the displaymath appearance.

Code with \displaysytle and [.3cm] after \\

-
Breaking the equations into multiple equations to tabularize them like this seems like a bit of an abuse of the tabbing environment, something one Should Not Do. Since I'm curious, though, is there a way to right-align a tab stop within tabbing to achieve proper alignment of the left-hand-side? – Tim Parenti Jun 21 '13 at 15:52
No need to delete the comments; better to preserve the history. But adding \ in front seems only to right-align the right-hand-side against the margin of the page, which is worse. – Tim Parenti Jun 21 '13 at 16:24
@TimParenti I cant figure anything fruitful out but I bet some others could. You may need to ask a separate question on right aligning inside the tabbing environment. – dustin Jun 21 '13 at 17:04
just one more quibble -- the space between the equal sign and what follows it is uniformly too large. (the same space should really be used to the left of the equal sign, though that's hardly relevant with the left alignment. however, that space shouldn't be smaller than the space after the equal sign.) – barbara beeton Jun 21 '13 at 18:06
@dustin -- no chance that i would recommend adjusting a group of equations aligned with a tabular mechanism. yes, i could do it, but this problem is one of the reasons amsmath was created, and that handles it more reliably. – barbara beeton Jun 21 '13 at 18:59