8

So I played around a little bit recently and I noticed that empty lines between text and and a \begin{align} produce a big vertical whitespace which is not the case with empty lines between text and \begin{equation}, even though there might be a very subtle effect with equation, but I am not entirely sure. I do not have any issue with this, but I am curious as to why that happens. As far as I know, LaTeX does usually not ignore empty lines, to form paragraphs for example. So why does that seem to be the case when setting an empty line in front of an equation environment?

example code:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
Line of text directly followed by "align"
\begin{align}
    a + b = c
\end{align}

Line of text followed by an empty line and then "align"

\begin{align}
    a + b = c
\end{align}

Line of text directly followed by "equation"
\begin{equation}
   a + b = c
\end{equation}

Line of text followed by an empty line and then "equation"

\begin{equation}
   a + b = c
\end{equation}

\end{document}

output: enter image description here

3
  • 1
    Just out of idle curiosity: Why are you using align for single-line displayed equations, for which there's nothing to align to begin with?
    – Mico
    Commented Jun 5, 2021 at 14:02
  • 1
    I am not, I was using align to align multiple expressions in a document that already had some equation environments in it, and then I stumbled upon this. the example is just meant to be as simple as possible since the large whitespace appears regardless of whether you actually align multiple expressions in your align envrionment or not.
    – M S
    Commented Jun 5, 2021 at 14:06
  • 5
    Take this as a rule: never leave a blank line before a math display.
    – egreg
    Commented Jun 5, 2021 at 15:23

2 Answers 2

10

Enrico is absolutely right: "do not use empty lines around display environments" (The LaTeX Companion, second edition, p. 481 bottom).

But to explain the difference:

The empty line before the equation/align gives an extra vertical space of \baselineskip (in fact the line is visibly empty, but not technically empty: it contains the \indent box). But the equation then uses a vertical space of \abovedisplayshortskip which by default is 0pt (plus some stretch).

The equation without empty line has a vertical space of \abovedisplayskip, which by default is 10pt (plus some stretch). This is almost the same as the \baselineskip.

The align environment uses a "display alignment" which is approximately

$$\halign{ . . .}$$

This is low level TeX's equivalent of the array environment. This, however, is always preceded by the vertical space \abovedisplayskip.

So the align with an empty line before it gets both the \baselineskip and the abovedisplayskip.

Check: Set \abovedisplayshortskip to \abovedisplayskip and the equation gets the same spacing as the align.

1
  • Thank you! perfect answer. I will certainly stick to that advice from now on. Seems like an easy way not to get my document's formatting screwed up.
    – M S
    Commented Jun 5, 2021 at 18:08
0

Sometimes, I find the standard spacings in LaTeX to be, not necessarily incorrect but, just not what I want, or consider aesthetically pleasing in the context: in aligning an image with the text line, or between a table or a text, or any number of other examples.

Perhaps these will change again with LaTeX3? Who knows?

In the meantime, I just use \vspace or \space*, sometimes with a negative value, to achieve the effect I want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .