# Align multiple independent equations

Good morning,

I have found a lot questions and tutorials on how to align multi-line equations, even over several pages and such, but I am unable to figure out how to align several equations with paragraphs of text between them.

Here is a minimal working example of my problem:

    \documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{fleqn}
\begin{document}
Since we have
$$e^x = \frac{d}{dx}e^x$$
and
$$e^x = \int e^x dx$$
one of my students concluded that
$$\int dx = \frac{d}{dx}.$$
\end{document}


This compiles to:

As you can see the first two equations are perfectly aligned since the left sides take up the same width. Equation 3 is not aligned as the left side is wider. I am looking for a simple solution to align all equal signs, at least on a page, if not the entire document.

In the full document that I am writing there are several lines of explanation between equations, sometimes with inline math, references and so on, therefore solutions that simple put a few words in plain text inside a math environment are not really viable in my opinion.

I hope that I have stated my question clearly and wish you a good day.

• You might want to have a look at the macro \intertext. It's only supposed for one or two lines, so no fit for your problem, but it might be a good point to start looking for alternatives.
– Dave
Nov 29 '19 at 10:16
• @Dave it works for longer text too. I've been working on an answer about it. Nov 29 '19 at 10:18
• I'm not sure why the equals sign should be aligned. The three equations are independent of each other, so they shouldn't be aligned. From a mathematical point of view, $e^x=\int e^x\,dx$ is almost as wrong as the student's claim. Nov 29 '19 at 10:46
• Nov 29 '19 at 15:42

I know you said that solutions that "put a few words in plain text inside a math environment" don't seem to be viable. But you might still want to consider the \intertext (amsmath) and \shortintertext (mathtools) commands.

These allow you to put whole paragraphs of text between the equations, including inline math and citations.

The difference between the two commands is in the spacing: \shortintertext has smaller space between paragraphs, as shown in the example below.

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}

\usepackage{filecontents}

\begin{filecontents}{references.bib}
@inproceedings{TestSmith,
title={This is a Test},
author={Smith, John and Jones, Ben},
booktitle={2016 Placeholder Conference on Citation Testing},
pages={3--4},
year={2016}
}
\end{filecontents}

\begin{document}

The "intertext" and "shortintertext" commands allow you to put text inside an align environment.
\begin{align}
c + c + e^x &= \frac{d}{dx}e^x
\intertext{this is normal "intertext"}
\intertext{It has large spacing between paragraphs}
b + b + b + e^x &= \int e^x dx
\shortintertext{"shortintertext" from the "mathtools" package has smaller spacing}
\shortintertext{like this}
\int dx &= \frac{d}{dx}.
\shortintertext{This works even for multi-line paragraphs, inline math ($x=\alpha+\frac{a}{b+1}$) and citations~\cite{TestSmith}.}
\shortintertext{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. . Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}
\int dx &= \frac{d}{dx} + a + a + a.
\end{align}

\bibliographystyle{apalike}
\bibliography{references}

\end{document}



• Thanks for mentioning \shortintertext, I was looking for a possibility to decrease the vertical spacing as well. I think I will run with this method, it delivers exactly the output I was looking for. Nov 29 '19 at 14:52

\intertext works for single or multiple pages if that's sufficient for your needs.

\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{fleqn}
\begin{document}

Since we have
\begin{align}
e^x &= \frac{d}{dx}e^x
\intertext{and}
e^x &= \int e^x dx
\intertext{one of my students concluded that.. one of my students concluded that.. one of my students concluded that..}
\int dx &= \frac{d}{dx}.
\end{align}

\end{document}