# Why does $…$ do the wrong thing at the top of a page?

Upon reading What are the differences between , [, align, equation and displaymath?, I decided I really wanted to understand what was going on inside $...$ and so I devised some tests. What I discovered confounds me. Why does $...$ do the wrong thing at the top of a page? The definition of $ goes out of its way to suppress additional vertical space by invoking \nointerlineskip, but then adds vertical space implicitly by making an empty box 60% the width of the line: \makebox[.6\linewidth]{}. I can see how this might be desirable in some cases, but it's certifiably the wrong thing to do for a displayed formula at the top of a page, as it causes a whole extra line's worth of unwanted space at the top. This happens whether the result of a forced page break or the result of natural break after a paragraph. Here is a minimal working example: \documentclass{article} \begin{document} \newpage y=x^2 \newpage \[y=x^2$ \end{document}  Notice how the second equation is much lower on the page than the first. Does anyone know why this is? Is it a flaw in $...$? Is it by design? Note that it also does this inside of (at the top of) a \parbox. - This is fixed with the loading of amsmath, since it redefines $ and $. – Werner Feb 8 '12 at 19:34 Aha! Now all my test-cases of ... vs. $...$ line up perfectly. Cool. – Todd Lehman Feb 8 '12 at 19:57

The amsmath package redefines the display math equation definitions of $ and $ which corrects this behaviour. So, all you need to do is use

\usepackage{amsmath}% http://ctan.org/pkg/amsmath


-
That's a pretty good reason always to load amsmath as part of a boilerplate! – Todd Lehman Feb 8 '12 at 20:41

The simple answer is unfortunately that the whole set of core LaTeX "math" environments are flawed (if not to say broken). Compare, for example, the result of $a=b$ with \begin{eqnarray} a&=&b \end{eqnarray} -- the spacing is all wrong.

Your example is just another instance of this, however in that case for some reason a deliberate design decision by Leslie (or so I believe from the code).

In any case, if doing any serious math the use of amsmath is the way to go; the basic implementations in core LaTeX should rather be avoid.

Now in case anybody asks why isn't this fixed? The answer is document typesetting compatibility with all documents produced in the last 25+ years that have been written with just core LaTeX. The fix is there since 1994 and it is called

\usepackage{amsmath}

-

You have two good answers already; I'd like to explain why you don't really have to care. Under usual circumstances there should be no displayed formula at the top of a page. From the TeXbook, page 189:

Plain TeX sets \predisplaypenalty=10000, because fine printers traditionally shun displayed formulas at the very top of a page.

The effect of \predisplaypenalty=10000 is that no page breaks are allowed before a displayed formula. Thus your premise is wrong in

This happens whether the result of a forced page break or the result of natural break after a paragraph.

Yes, after a forced page break it can happen, but "naturally" it doesn't happen unless you change \predisplaypenalty. Moreover, forced page breaks should only be used in special circumstances, and never before a displayed formula :-) I also wouldn't recommend starting a \parbox with a displayed formula.

-