Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 minipages (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.

enter image description here

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:

enter image description here

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:

  1. How can I adjust the align environment to automagically not have additional space at the top of a page or minipage?
  2. 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}
share|improve this question
    
if you add \topskip0pt at the preamble the issue goes away. –  Yiannis Lazarides Dec 3 '11 at 4:39
    
@YiannisLazarides: That seems to only change the spacing above the text at the top of the page, and has no effect on the spacing above the align environment. –  Peter Grill Dec 3 '11 at 20:16
    
Peter I am sorry, I misunderstood the question. –  Yiannis Lazarides Dec 3 '11 at 20:36
    

1 Answer 1

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) with

\usepackage{etoolbox}
\makeatletter
\pretocmd\start@align{%
  \if@minipage\kern-\topskip\kern-\abovedisplayskip\fi
}{}{}
\makeatother

This 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 subsequent align environments in the same minipage 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).

share|improve this answer
    
Your solution works perfectly for a minipage, as long as it is not at the top of a page (in which case it shifts the equation too far up). And while I agree that in a normal document one should not start a page with a displayed equation, most of the time I am producing a single page which is composed entirely of a \begin{align}...\end{align} with a few \shortintertext in-between so would like to eliminate that space. –  Peter Grill Dec 3 '11 at 20:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.