0

If I remove the textcolor specification (and the corresponding 2 curly braces), the useless space around "someItem" disappears.
If I replace the "\begin{itemize} ... \end{itemize}" bloc by just a text, the useless space around "someItem" disappears.

Why are there these differences? I tried to remove all the blanks in my LaTeX source, because I thought there were causing some problems, but that didn't help.

Is it related to the notion of "vertical mode" (that I don't understand yet, but someone mentioned it in one my other posts about unwanted spaces)?

I saw some posts with similar problems (for example: Why does tcolorbox adds vertical space?), maybe their solution would work, but I still wouldn't understand what textcolor or itemize are breaking in my MWE...

I'm using LuaLaTex, but the result in the same on this online service: https://latex.net/texlive/

In fact, I don't really need a color for my text. I just put it to play with fonts in one of my documents. So I'll just remove the "textcolor" and my document will be ok, but I would still like to understand what's going on!

\documentclass{article}%
\usepackage{tcolorbox}%
\usepackage{enumitem}%
\begin{document}%
\begin{tcolorbox}[notitle]%
{\textcolor{blue}{%
\begin{itemize}%
\item{someItem}%
\end{itemize}%
}}%
\end{tcolorbox}%
\end{document}%

unwanted_vertical_space_around_text

1 Answer 1

1

Well color can affect spacing as it adds whatsits. And if you use \textcolor instead of \color you additionally start a paragraph. With lualatex can use use luacolor, that avoids parts of the problem.

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{enumitem}
%\usepackage{luacolor}
\begin{document}
\begin{tcolorbox}[notitle]
\begin{itemize}
\item{someItem}
\end{itemize}
\end{tcolorbox}


\begin{tcolorbox}[notitle]
\color{blue}
\begin{itemize}
\item{someItem}
\end{itemize}
\end{tcolorbox}

\begin{tcolorbox}[notitle]
\textcolor{blue}
{\begin{itemize}
\item{someItem}
\end{itemize}}
\end{tcolorbox}

\begin{tcolorbox}[notitle]
\leavevmode
\begin{itemize}
\item{someItem}
\end{itemize}
\end{tcolorbox}
\end{document}

with luacolor

enter image description here

without luacolor

enter image description here

1
  • Thanks, I think I'll use \color. I'm still not very experienced with LaTeX, so would you say that, for experienced LaTeX users, whatsits problems/surprises...: - are common, or are they more frequent with people like me who learn by themselves, and/or stumble on these problems because they don't have any filter, they don't know what's useful, what's dangerous, etc.? - are easily solved (like using \color instead of \textcolor), or are they mostly tricky?
    – Michaël
    Jun 13, 2022 at 13:15

You must log in to answer this question.

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