0

I just got some behavior I didn't expect for the spacing between equations; I think it's best explained through an MWE, which I put below.

The question is: what is the reason for this?

LaTeX, as far as I know, does most things, including spacing, for a reason, usually in an attempt to optimize the page layout according to its interpretation of the user's input. So I was wondering what the reason behind this choice is, so that I can better understand why I should leave it as is or if/why/how I should override it in some situations.

PS: I know about the align environment, and indeed, it doesn't have this issue; this question, however, is more about curiosity than trying to solve a specific problem.

PS2: If I add linebreaks or \pars after each \[a\] I also get consistent (though more generous) spacing.

\documentclass{article}

\begin{document}

\noindent These equations have inconsistent spacing if this line ``pushes down the first.''
\[a\]
\[a\]
\[a\]

\noindent These have inconsistent spacing, regardless of the length of this sentence.\par
\[a\]
\[a\]
\[a\]

\noindent These have consistent spacing, regardless of the length of this sentence.\\
\[a\] 
\[a\]
\[a\]

\end{document}

annotated screenshot of output

4
  • 1
    never use display math at the start of a paragraph or after another display math. Use a multi-line display such as gather Commented May 24, 2020 at 16:19
  • @DavidCarlisle I didn't know that! Is this spacing issue part of the reason, or are there also other reasons for it?
    – steve
    Commented May 24, 2020 at 16:22
  • 3
    this is exactly the reason: You are seeing the difference between \abovedisplayskip (used for long lines) and \abovedisplayshortskip used for short lines including the spurious empty paragraphs formed by the mis-placed display math Commented May 24, 2020 at 16:23
  • @DavidCarlisle Aah, I see, that makes sense now. Thank you! (If you post this as an answer I'll readily accept it of course)
    – steve
    Commented May 24, 2020 at 16:25

1 Answer 1

2

As this example shows you should use a multi-line display such as gather and never one display math following another or at the start of a paragraph.

\documentclass{article}

\showoutput
\showboxdepth=3

\begin{document}

\noindent These equations have inconsistent spacing if this line ``pushes down the first.''
\[a\]
\[a\]
\[a\]

\noindent These have inconsistent spacing, regardless of the length of this sentence.\par
\[a\]
\[a\]
\[a\]

\noindent These have consistent spacing, regardless of the length of this sentence.\\
\[a\] 
\[a\]
\[a\]

\end{document}

produces

...\hbox(6.94444+1.94444)x345.0, glue set 4.19391fil []
...\penalty 10000
...\glue(\abovedisplayskip) 10.0 plus 2.0 minus 5.0
...\glue(\baselineskip) 5.75002
...\hbox(4.30554+0.0)x5.28589, shifted 169.85706, display []
...\penalty 0
...\glue(\belowdisplayskip) 10.0 plus 2.0 minus 5.0
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x5.28589, shifted 169.85706, display []
...\penalty 0
...\glue(\belowdisplayshortskip) 6.0 plus 3.0 minus 3.0
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x5.28589, shifted 169.85706, display []
...\penalty 0
...\glue(\belowdisplayshortskip) 6.0 plus 3.0 minus 3.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 5.05556
...\hbox(6.94444+1.94444)x345.0, glue set 24.22176fil []
...\glue(\parskip) 0.0 plus 1.0
...\hbox(0.0+0.0)x345.0, glue set 122.9979fil []
...\penalty 10000
...\glue(\abovedisplayskip) 10.0 plus 2.0 minus 5.0
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x5.28589, shifted 169.85706, display []
...\penalty 0
...\glue(\belowdisplayskip) 10.0 plus 2.0 minus 5.0
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x5.28589, shifted 169.85706, display []
...\penalty 0
...\glue(\belowdisplayshortskip) 6.0 plus 3.0 minus 3.0
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x5.28589, shifted 169.85706, display []
...\penalty 0
...\glue(\belowdisplayshortskip) 6.0 plus 3.0 minus 3.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 5.05556
...\hbox(6.94444+1.94444)x345.0, glue set 32.55511fil []
...\penalty 200
...\glue(\baselineskip) 10.05556
...\hbox(0.0+0.0)x345.0 []
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x5.28589, shifted 169.85706, display []
...\penalty 0
...\glue(\belowdisplayshortskip) 6.0 plus 3.0 minus 3.0
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x5.28589, shifted 169.85706, display []
...\penalty 0
...\glue(\belowdisplayshortskip) 6.0 plus 3.0 minus 3.0
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x5.28589, shifted 169.85706, display []
...\penalty 0
...\glue(\belowdisplayshortskip) 6.0 plus 3.0 minus 3.0
...\glue 0.0 plus 1.0fil

So you see that unlike adjacent display environment such as center that try to merge white space, between later pairs of display you get

...\penalty 0
...\glue(\belowdisplayshortskip) 6.0 plus 3.0 minus 3.0
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0

so visible space the sum of the above and below short skips whereas before the second display you either get that or you get

...\glue(\belowdisplayskip) 10.0 plus 2.0 minus 5.0
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0
...\glue(\baselineskip) 7.69446

depending on whether the first display uses the display skips or short display skips

4
  • How did you get the second block of code in your answer?
    – steve
    Commented May 24, 2020 at 17:38
  • 1
    @steve it's not code it is the log from running your example as amended here with \showoutput added Commented May 24, 2020 at 18:21
  • You should also say that display math should not be preceded by \par or a blank line. Not only will the space before the display be enlarged, but this allows the display to break to a new page when it's at the bottom and there isn't room. Commented May 24, 2020 at 21:33
  • @barbarabeeton yes I said that in first comment under the question I'll copy it to the answer:-) Commented May 24, 2020 at 21:40

You must log in to answer this question.

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