Aligning All Equations in a Document at Equality Sign
I only considered implementing a global alignment as egreg hinted in comments that it was a bad idea. Alignment is supposed to highlight the corresponding parts of a display and that meaning is destroyed if you align everything. But...
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{etoolbox}
\setlength\mathindent{3cm}
\makeatletter
\def\align@preamble{%
&\hfil
\strut@
\setboxz@h{\@lign$\m@th\displaystyle{##}$}%
\ifmeasuring@\savefieldlength@\fi
\llap{\set@field}%
\tabskip\z@skip
&\setboxz@h{\@lign$\m@th\displaystyle{{}##}$}%
\ifmeasuring@\savefieldlength@\fi
\rlap{\set@field}
\hfil
\tabskip\alignsep@
}
\def\a{One two three four five six seven. }
\def\b{\a\a\a Red yellow blue green. \a\a\a\a}
\begin{document}
\b\b\a
\begin{align}
1+2+3+4 &=4\\
x+y &=z
\end{align}
\b\b\b
\a\a\b
\a
\begin{align}
1&=a+y+b+w+x+n+m+s+d+e\\
2&=4
\end{align}
\b
\begin{align}
1&=0\\
2&=9
\end{align}
\end{document}
the macros here are not particularly general or robust but show a basic idea of using a flush left but very indented setting along with hiding the width of the first column.
Equations can be left aligned by option fleqn
. The left indentation can be controlled by register \mathindent
(package amsmath
). Then the left part of the equation can be written via \llap
in the indentation space:
\documentclass[fleqn]{article}
\usepackage{amsmath}
\setlength{\mathindent}{3em}
\newcommand*{\ml}[1]{%
\llap{$\displaystyle#1$}%
}
\begin{document}
\begin{gather*}
\ml{a} = b + c + d\\
{} + e + f + g
\intertext{A small amount of text can go htere with $x=2$ inline math,
but not a lot of text.}
\ml{k} = l + m + n + m + n + m + n\\
{} + o + p + q\\
\ml{r + s} = t + u
\end{gather*}
\end{document}