2

I have noticed a weird vertical spacing issue when combining \color with an enumerate environment. Basically, it seems that {(line break)} takes up different amounts of horizontal space depending on how it is wrapped in \color and extra {...}, leading to extra lines being allocated (vertical space):

\documentclass{article}
\usepackage{color}
\newcommand{\red}[1]{{\color{red}{#1}}}
\newcommand{\var}[1]{\color{red}{#1}}
\begin{document}
    \begin{enumerate}
        \item \hspace*{320pt}\red{
        }
    \end{enumerate}
    This line is way too far down!

    \begin{enumerate}
        \item \hspace*{320pt}{\color{red}{
        }}
    \end{enumerate}
    Same here! But compare to the next ones:

    \begin{enumerate}
    \item \hspace*{318pt}\red{
    }
    \end{enumerate}
    Less hspace - not as far down (interestingly: overfull hbox!)

    \begin{enumerate}
        \item \hspace*{320pt}\var{
        }
    \end{enumerate}
    One less level of curly braces - not as far down

    \begin{enumerate}
        \item \hspace*{320pt}\red{%
        }
    \end{enumerate}
    Line break commented - not as far down

    \begin{enumerate}
        \item \hspace*{320pt}\red{}
    \end{enumerate}
    No line break in colored text - not as far down

    \begin{enumerate}
        \item \hspace*{320pt}{{
        }}
    \end{enumerate}
    No color - not as far down

    \begin{enumerate}
        \item \hspace*{320pt}
    \end{enumerate}
    Standard case - not as far down

\end{document}

enter image description here

To be honest, I don't really know what my question is: I have encountered this as a result of latexdiff (which introduces extra line breaks at the end of \DIFadd constructions - hence the tag), but it's really only relevant at the end of very full lines, and easy to miss. I have solved this by shortening the sentence (yes, I did), so I think the most relevant question is, why is that? Is there anything on a general level that I can do against that?

0

You must log in to answer this question.

Browse other questions tagged .