0

Let's say we have a piece of text that introduces some vertical spacing of its own at the end (say, the head of some environment). After that space, an enumeration comes, which also introduces a vertical gap of its own. We think that the two gaps together are too much and decide to remove the vertical gap inserted by enumerate (e.g., because this gap is well documented; cf. Fig. 1 of enumitem.pdf):

\documentclass{article}
\pagestyle{empty}
\usepackage{enumitem}
\begin{document}
Text before the list.\\%%% the explicit newline is not really present in a larger example. In this MWE, it's simply for demonstration that a vertical gap above enumerate is introduced somehow.
\vskip-\topsep\vskip-\parskip\vskip-\partopsep\vskip0pt plus.5ex minus.5ex
\begin{enumerate}
\item First item. It's long and includes formulas and can include sub-lists.
\item Second item. It's long and includes formulas and can include sub-lists.
\end{enumerate}
\the\topsep\\
\the\parskip\\
\the\partopsep
\end{document}

Running lualatex on it yields

output

This seems to work well in a small example, where all the stretch and shrink values are ignored because there's plenty of vertical space available, and there's just one page. I see that the minus symbol negates also the stretch and shrink values; in my understanding, \vskip-\topsep\vskip-\parskip\vskip-\partopsep together with the start of the enumerate environment effectively nullifies the sum of all the vertical skips, including the stretch and shrink values. Please correct me if I'm wrong here! As we still wish to have at least a little bit of elasticity before the start of the list, we add ½ ex of elasticity by means of \vskip0pt plus.5ex minus.5ex.

How about large examples in which stretch and shrink values do play a role? Is \vskip-\topsep\vskip-\parskip\vskip-\partopsep\vskip0pt plus.5ex minus.5ex a good™ way to remove the extra vertical gap and maintain a bit of elasticity? If so, is there an even better way? If not, what to do instead?

(By the way, we did not change the relevant skips \topsep, \parksip, and \partopsep (either directly or via the commands of enumitem) because the contents of the two items in general might use these skips.)

  • it is not clear exactly what you need here but the \\ before an enumerate is always an error so should be fixed by removing the \\ not by adding vskip to try to compensate for the underfull box – David Carlisle Mar 22 '23 at 07:16
  • @DavidCarlisle \\ is not there in a non-minimal example. Here, in this MWE, it's simply for demonstration that vertical space is added before enumerate by some other means. –  Mar 22 '23 at 07:52
  • \\ does not add vertical space, it adds an extra (empty) line of paragraph text. enumerate adds space above using \addvspace so it just adds the maximum of the requested space and any preceding space, but \\ does not add space at all, and a negatve vskip added to compensate is always less than the space requested (as it is negatve) so messes up the "maximum value" choice of \addvspace, – David Carlisle Mar 22 '23 at 08:28
  • @DavidCarlisle Oh. That's news to me, thanks! What you said seems like the space added by the start of enumerate is not a given by a fixed value with fixed stretches and shrinks but partially depends on what was before the list. In order to provide a usable (not-so-)minimal example, do we actually have to insert the full construction that provides vertical space before the list (whichever it might be, say, a theorem start) instead of Text before the list.\\? –  Mar 22 '23 at 11:15
  • well Text before the list.\\ makes it impossible to get anything reasonable so any answer starting there will start by removing the \\ see https://tex.stackexchange.com/a/334249/1090 – David Carlisle Mar 22 '23 at 11:19
  • @DavidCarlisle Alright, I'll reformulate. It'd take me a bit, though. Should I delete the question and restore it later? –  Mar 22 '23 at 11:55

0 Answers0