1

When using labels in the enumerate and itemize environments, I sometimes get extra vertical space after an item. I've determined that the extra space occurs when the content in the item ends with a display equation and \label{...} is placed after the equation in the code.

I've included a minimum working example below to demonstrate. Notice that there is a lot of space between Items 3 and 4. I searched quite a bit for other relevant questions but couldn't find any that relate to this problem.

MWE

\documentclass{article}

\usepackage{lipsum}% For generating dummy text.

\begin{document}

\lipsum[1][1]
\begin{enumerate}
    \item This item has a label and does not have extra space.  \lipsum[1][2] \label{item 1}
    \item This item does not have a label and does not have extra space. \[
      e{\theta i} = \cos\theta + i\sin\theta.
    \]
    \item This item has a label after the equation and has extra space.
    \[
      a^2 + b^2 = c^2
    \]\label{item 3}%
    \item This item has a label before the equation and does not have extra space.
    \label{item 4}%
    \[
        \int \arctan(x)\, dx = \frac{1}{1 + x^2}
    \]%
\end{enumerate}%
\lipsum[2][1-4]

\end{document}

Output

Screenshot of MWE output

1 Answer 1

1

Remedy for your problem is to move labels imediately after \item command:

\documentclass{article}
\usepackage{lipsum}% For generating dummy text.

\begin{document}

\lipsum[1][1]
\begin{enumerate}
    \item This item has a label and does not have extra space.  \lipsum[1][2] \label{item 1}
    \item This item does not have a label and does not have extra space. 
    \[
      e^{\theta i} = \cos\theta + i\sin\theta.
    \]
    \item\label{item 3} This item has a label after the equation and has extra space.
    \[
      a^2 + b^2 = c^2
    \]%
    \item\label{item 4} This item has a label before the equation and does not have extra space.
    \[
        \int \arctan(x)\, dx = \frac{1}{1 + x^2}
    \]%
\end{enumerate}
Let referenced items: see item \ref{item 3} and \ref{item 3}.
\lipsum[2][1-4]

\end{document}

enter image description here

Label after displayed equation actually refer vertical space. This seems to cause additional vertical space after equation.

3
  • This fixes the problem, but my question is about the root cause.
    – Paul Wintz
    Commented Aug 23, 2023 at 5:46
  • 2
    @PaulWintz label tries hard to avoid affecting space but it is tricky as it is a write node that has to be saved until the page is shipped out. just after a displayed equation where tex is adding space automatically is particularly tricky and fragile Commented Aug 23, 2023 at 5:55
  • 1
    Interesting. It seems like it only happens inside list environments. I'm not sure how difficult this would be, but it would be nice if LaTeX showed a warning that extra space will (or might) be added when a label follows an equation.
    – Paul Wintz
    Commented Aug 23, 2023 at 6:45

You must log in to answer this question.

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