# Align equations over multiple sections

Is there a way to make the math mode "align" work over multiple sections? Here is the code example:

section*{Polynomials}
Do the following polynomial devisions
\begin{align}
&(x^7 - x^4 - 21x^2 + 4x + 18) \div (x^2-9) \tag{a} \\
&7x^3 - 6x^2 - 2x + 8 \div (x-1) \tag{b}
\end{align}
\section*{Simplifying}
\begin{align}
Rewrite the follwing equations as sums
& (g^7+c)\cdot (f+\pi k^{-7}+3jg)-\pi-8hb^2-er^2 \tag{a}\\
& \beta^{56}\cdot (x^5-\frac{85l^8}{\beta^9}+\beta^{-54}) \tag{b}
\end{align}


The problem now is that the equations are only aligned in each section (as they should be, so that works).

Meaning the equations in section "Polynomials" so not align (or start at the same place) as the ones in the next section "Simplifying".

Is there a way to do this?

-
Welcome to TeX.SE! – Mico Aug 24 '14 at 13:44
Remember to check spelling - devisions, follwing, ... – Ethan Bolker Aug 24 '14 at 14:01

Your objective may be achieved easily by placing the sectioning instructions and short paragraphs inside an \intertext wrapper. In the example below, there is now only one align environment that spans a \section* directive. Do note that some material can not be placed inside \intertext.

To play it safe, one should probably provide the instruction \allowdisplaybreaks to allow page breaks within what may turn out to be a rather lengthy align environment.

Two asides:

• The example below shows a single sectioning header included in the large align environment. There is no LaTeX-based reason for not having a single align environment span multiple pages and includes several sectioning headers. Of course, there will most likely be reasons related to document content and layout that make it unnecessary -- or undesirable -- to have an align environment that stretches across a multitude of pages.

• Just because sectioning headers can be placed in the argument of \intertext does not imply that everything does. For instance, as @eldering has noted in a comment, \footnote commands should not be placed in the argument of \intertext (unless one resorts to some pretty fancy workarounds, I suppose).

\documentclass{article}
\usepackage{amsmath}
\allowdisplaybreaks
\begin{document}
\section*{Polynomials}
Do the following polynomial devisions
\begin{align}
&(x^7 - x^4 - 21x^2 + 4x + 18) \div (x^2-9) \tag{a} \\
&7x^3 - 6x^2 - 2x + 8 \div (x-1) \tag{b}
\intertext{%
\section*{Simplifying}
Rewrite the follwing equations as sums}
& (g^7+c)\cdot (f+\pi k^{-7}+3jg)-\pi-8hb^2-er^2 \tag{a}\\
& \beta^{56}\cdot (x^5-\frac{85l^8}{\beta^9}+\beta^{-54}) \tag{b}
\end{align}
\end{document}

-
Interesting, I didn't know this was possible. On the other hand, some things do break when using \intertext. For example, for footnotes inside an intertext I had to use \savenotes and \spewnotes from the footnote package. – eldering Aug 26 '14 at 11:41
@eldering - Thanks for mentioning things -- footnotes -- that will not work, at least not without some workaround effort, inside \intertext. I'll amend my answer to note that not all things can go in the argument of \intertext. – Mico Aug 26 '14 at 12:50

The Answer of Mico will definitly work, but will be very costly if you'll write a much longer piece of text (e.g. Master Thesis). Using a koma-script class with the option fleqn (flush left equation) will "align" all equations on the left side:

\documentclass[fleqn]{scrartcl}
\usepackage{amsmath}

\begin{document}
\section*{Polynomials}
Do the following polynomial devisions
\begin{align}
&(x^7 - x^4 - 21x^2 + 4x + 18) \div (x^2-9) \tag{a} \\
&7x^3 - 6x^2 - 2x + 8 \div (x-1) \tag{b}
\end{align}

\section*{Simplifying}
Rewrite the follwing equations as sums
\begin{align}
& (g^7+c)\cdot (f+\pi k^{-7}+3jg)-\pi-8hb^2-er^2 \tag{a}\\
& \beta^{56}\cdot (x^5-\frac{85l^8}{\beta^9}+\beta^{-54}) \tag{b}
\end{align}
\end{document}


-
Do you have reasons to believe that the OP might wish to write "a much longer piece" with a single align environment? – Mico Aug 24 '14 at 21:19
@ Mico: "Is there a way to make the math mode "align" work over multiple sections?". IMHO multiple is more than two as shown in the example. – Allaria Aug 26 '14 at 9:04
Please see the addendum to my answer. As long as the material is allowed inside \intertext, there's no LaTeX-based reason why an align environment can't span several pages and include multiple sectioning headers. Of course, there will almost certainly be reasons related to document content and layout for not wanting an align environment span most or all of an entire document... – Mico Aug 26 '14 at 14:34