It seems that the align
environment adds additional vertical space if it starts at the top of a page or minipage
. Below are two pages, and two minipage
s (on Page 1), where the first page/minipage
has text followed by an align*
environment, and the second page/minipage
starts with an align*
environment, and note that the equations are still aligned.
Attempted Solution:
The closest related question I found was:
I attempted to use the solution by Gonzalo Medina at the above by adding \setlength\abovedisplayskip{0pt}
(after the preamble as per Vertical space before and after align environment). Although, this did move the equations up vertically, they were still vertically aligned:
And since the problem occurs at top of a page as well, I don't think this is related to Understanding minipages – aligning at top
Question:
- How can I adjust the
align
environment to automagically not have additional space at the top of a page orminipage
? - Is there a reason for this behavior, and perhaps should not be changed?
Code:
\documentclass{article}
\usepackage[showframe,paperwidth=3.5in,paperheight=2.2in,margin=0.5in]{geometry}
\usepackage{amsmath}
\begin{document}%\setlength\abovedisplayskip{0pt}
Top of Page 1
\begin{align*}% Text above at top of page
e &= m c^2
\end{align*}
\hrule
\begin{minipage}[t]{0.45\linewidth}
Top of minipage 1
\begin{align*}% Text above this minipage
e &= m c^2
\end{align*}
\end{minipage}
\begin{minipage}[t]{0.45\linewidth}
\begin{align*}% No text above in this minipage
e &= m c^2
\end{align*}
\end{minipage}
\newpage
\begin{align*}% No text above at top of page
e &= m c^2
\end{align*}
\end{document}
Best Answer
The alignment environments of amsmath are not designed to be at the start of a paragraph. While this can be acceptable in normal situations, this has bad effects when we use a
minipage
for typesetting an alignment at a reduced width.The
minipage
problem can be solved by patching the\start@align
command (and also\start@gather
and\start@multline
) withThis exploits the fact that at the start of a
minipage
the conditional\if@minipage
is true, but upon starting a paragraph it becomes false, so subsequentalign
environments in the sameminipage
won't be affected.There is a similar patch for "curing" the environments at start-of-paragraph, but I'm somewhat reluctant to show it, as I believe that a paragraph should never start with a displayed equation (with the above mentioned exception).