Why is a second displaymath instance a short line?

I wanted to change \belowdisplayshortskip to move an equation up onto the preceding line, as there is space for it there, I like things compact in my notes.

However, this also moves equations up, namely those with 2, 4 and 5:

So as I understand it, why is it that display-math counts as a short line? how can I achieve the "moving up" without having space underneath? (\belowdisplayshortskip = 1\baselineskip plus 3.5pt minus 3pt would remedy the overlaps, but creates unnecessary and unwanted space underneath 2 and 5)

MWE:

\documentclass[12pt]{article}
\usepackage{lipsum}
\begin{document}
% \abovedisplayshortskip = 0pt plus 3pt minus 0pt % default
% \belowdisplayshortskip = 6.5pt plus 3.5pt minus 3pt % default
\abovedisplayshortskip = -1\baselineskip plus 3pt minus 0pt
\belowdisplayshortskip = 6.5pt plus 3.5pt minus 3pt
\lipsum[1]
A short line,
$\int \mathrm{1 math}\int$
$\int \mathrm{2 math}\int$
\lipsum[1]
$\int \mathrm{3 math}\int$
$\int \mathrm{4 math}\int$
$\int \mathrm{5 math}\int$
\lipsum[1]
\end{document}

• Have you any reason for ,ot typing these equations within a single equation, instead of trying to do complicated things? – Bernard May 2 '20 at 8:49
• You appear to be badly abusing the $...$ machinery, e.g., by setting a negative value for \abovedisplayshortskip and by using $...$ to typeset consecutive displayed equations. I find it neither surprising nor troubling that the output of such a dubious exercise doesn't "look right". Could you maybe tell us more about your intended use case? – Mico May 2 '20 at 9:01
• Should I not use $...$ to write consecutive equations? What would be the alternative? I like my notes to be as compact as possible – josh May 2 '20 at 9:33
• never use consecutive display math environments nor have a blank line before them, in either case you get a spurious empty paragraph (which as you see counts as a short line) but in general if you set the display skips negative you have to expect over-printing – David Carlisle May 2 '20 at 10:02
• @Josh, align and gather come to mind. – oliversm May 2 '20 at 11:29

If you need such compact notes, then you must set the glue values above and below display as follows:

\abovedisplayshortskip = -1\baselineskip
\abovedisplayskip=0pt
\belowdisplayshortskip = 0pt
\belowdisplayskip=0pt


Moreover, define the shortcut:

\def\nd{\predisplaysize=\hsize}


Then you can write:

\lipsum[1]

A short line,
$$\int \mathrm{1 math}\int$$
$$\nd \int \mathrm{2 math}\int$$
\lipsum[1]
$$\int \mathrm{3 math}\int$$
$$\nd \int \mathrm{4 math}\int$$
$$\nd \int \mathrm{5 math}\int$$
\lipsum[1]


It means that if a next display math follows a previous immediately, then you must use \nd inside the next display. It re-assigns the internal value of \predisplaysize to the value as if it were the previous paragraph line full.

Of course, you can add some "plus" values to the glues, but "minus" values does not have sense here.

• I see, makes sense, though I'd wished for a more automated solution that doesn't require me to insert \nd – josh May 2 '20 at 9:36
• @josh OK, use \everydisplay{\ifdim\predisplaysize=-\maxdimen \predisplaysize=\hsize \fi} in your preamble. Then you need not put any \nd. – wipet May 2 '20 at 9:49
• yes indeed that works, thank you – josh May 2 '20 at 10:14
• This is a plain TeX solution, and even there, it's not a good idea to use consecutive one-line display coding. For that, \eqalign is provided: \eqalign{<first line>\cr <next line>\cr} – barbara beeton May 2 '20 at 16:50
• Maybe \displaylines instead \eqalign because there is no ask to alignment. But OP needs to put consecutive displays into your document. My answer respects this and shows, how to set the above/below glues properly with respect to the original question. – wipet May 2 '20 at 17:20

I think you're after the gather environment (or its non-numbered version gather*) from amsmath:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{nccmath}
\usepackage{etoolbox}
\BeforeBeginEnvironment{gather*}{\useshortskip}

\usepackage{lipsum}

\begin{document}

\lipsum[47]
A short line,
\begin{gather*}
\int \mathrm{1 math}\int \\
\int \mathrm{2 math}\int
\end{gather*}
\lipsum[47]
\begin{gather*}
\int \mathrm{3 math}\int \\
\int \mathrm{4 math}\int \\
\int \mathrm{5 math}\int
\end{gather*}
\lipsum[47]

\end{document}


• While yes, that does work, it does not move the gathered part up onto the short line, and it introduces more white-space between 3math and the preceding long paragraph which I can not remove via setting all of the displayskips to 0pt, see tex.stackexchange.com/questions/385774 – josh May 2 '20 at 10:39
• @josh: I've added a code using nccmath and etoolbox. Is it more like you want? – Bernard May 2 '20 at 11:07
• that only lets me choose shortskip or skip, this doesn't use the \predisplaysize, but that is a general issue with the environments from amsmath – josh May 2 '20 at 11:37

If you want compact notes consider using the savetrees package

\usepackage[extreme]{savetrees}


or some other alternatives as outlined here I'm looking for a compact style for the whole document. Also, for better math typesetting, look into aligned and gather from amsmath.

Output

notice the reduction in lines:

Code

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage[extreme]{savetrees}

\begin{document}
\lipsum[47]
A short line,
\begin{gather*}
\int \mathrm{1 math}\int \\
\int \mathrm{2 math}\int
\end{gather*}
\lipsum[47]
\begin{gather*}
\int \mathrm{3 math}\int \\
\int \mathrm{4 math}\int \\
\int \mathrm{5 math}\int
\end{gather*}
\lipsum[47]
\end{document}

• Yes, the amsmath environments are preferred, but they ignore the \predisplaysize. savetrees seems interesting, but I myself already change a bunch of the mentioned variables, and I don't like the narrower glyphs. But thank you for the package recommendation, I will probably look into changing more variables it changes to my own liking. – josh May 2 '20 at 11:50