1

Consider following MWE:

\documentclass{article}
\usepackage[most]{tcolorbox}
\definecolor{block-gray}{gray}{0.95}
\newtcolorbox{zitat}[2][]{%
    breakable, % IMPORTANT
    colback=block-gray,
    boxrule=0pt,
    arc=0pt,
    boxsep=0pt,
    enhanced jigsaw,
    borderline west={4pt}{0pt}{gray},
    title={#2\par},
    colbacktitle={block-gray},
    coltitle={black},
    fonttitle={\large\bfseries},
    attach title to upper={},
    box align=top,
    #1,
}
\begin{document}
\section*{Quotes} % commenting removes difference
\begin{itemize}
  \item \begin{zitat}{Quote 1}
    Space: the final frontier.
  \end{zitat}
  \item \begin{zitat}{Quote 2}
    A long time ago in a galaxy far, far away\ldots
  \end{zitat}
  \item \begin{zitat}{Quote 2}
    A long time ago in a galaxy far, far away\ldots
  \end{zitat}
\end{itemize}
\end{document}

which produces following output

enter image description here

As you can see there is more vertical space before tcolorbox in the first item compared to the last two ones.

This disappears when I remove the section command.

What can I do to fix this without manually adjusting it?

(TexLive 2016 on OSX El Capitan, tcolorbox 2016/11/18 version 3.96)

UPDATE:

It appears that the option breakable is responsible. There is a related option vfill before first:

/tcb/vfill before first=true|false Inserts a \vfill at the begin of the first partial box to move this partial box to the end of the current page. This may be used as an alternative to /tcb/height fixed for=first to get justified columns or pages. The \vfill is not inserted, if the box gets not actually broken.

However, removing breakable and inserting a \vfill does not reproduce this issue. I guess the author of tcolorbox probably knows what is going on.

I report this to https://github.com/T-F-S/tcolorbox/issues

2
  • I'm sorry, but this code produces a normal spacing for me. You must have something else in your code. – Bernard Nov 29 '16 at 11:11
  • Yes, you are right. I removed randomly the option breakable to avoid vertical scrolling on tex.stackexchange.com which appears to be responsible. – Hotschke Nov 29 '16 at 11:14
2

tcolorbox takes special care to insert the right spacing after a heading. This is especially tricky, if the tcolorbox should be breakable, because breakable boxes always start a new paragraph. Putting this combination into a list environment like itemize seems to be too much for the algorithm.

Currently, I would'nt know how to handle this automatically without risking to break other mechanisms.

But, there are (at least) two ways to avoid the situation.

Way 1:

Add a \@nobreakfalse after your section heading. This will switch off the special treatment for headings which has a bad effect here.

\documentclass{article}
\usepackage[most]{tcolorbox}
\definecolor{block-gray}{gray}{0.95}
\newtcolorbox{zitat}[2][]{%
    breakable, % IMPORTANT
    colback=block-gray,
    boxrule=0pt,
    arc=0pt,
    boxsep=0pt,
    enhanced jigsaw,
    borderline west={4pt}{0pt}{gray},
    title={#2\par},
    colbacktitle={block-gray},
    coltitle={black},
    fonttitle={\large\bfseries},
    attach title to upper={},
    box align=top,
    #1,
}
\begin{document}
\section*{Quotes} 
\makeatletter\@nobreakfalse\makeatother%
\begin{itemize}
  \item \begin{zitat}{Quote 1}
    Space: the final frontier.
  \end{zitat}
  \item \begin{zitat}{Quote 2}
    A long time ago in a galaxy far, far away\ldots
  \end{zitat}
  \item \begin{zitat}{Quote 2}
    A long time ago in a galaxy far, far away\ldots
  \end{zitat}
\end{itemize}
\end{document}

Way 2:

Add an ignore nobreak option to the first of your zitat environments after the heading. Alternatively, this could be added to the general option list of your environment.

\documentclass{article}
\usepackage[most]{tcolorbox}
\definecolor{block-gray}{gray}{0.95}
\newtcolorbox{zitat}[2][]{%
    breakable, % IMPORTANT
    colback=block-gray,
    boxrule=0pt,
    arc=0pt,
    boxsep=0pt,
    enhanced jigsaw,
    borderline west={4pt}{0pt}{gray},
    title={#2\par},
    colbacktitle={block-gray},
    coltitle={black},
    fonttitle={\large\bfseries},
    attach title to upper={},
    box align=top,
    %  ignore nobreak,  %<---- could also be added here
    #1,
}
\begin{document}
\section*{Quotes} 
\begin{itemize}
  \item \begin{zitat}[ignore nobreak]{Quote 1}      
    Space: the final frontier.
  \end{zitat}
  \item \begin{zitat}{Quote 2}
    A long time ago in a galaxy far, far away\ldots
  \end{zitat}
  \item \begin{zitat}{Quote 2}
    A long time ago in a galaxy far, far away\ldots
  \end{zitat}
\end{itemize}
\end{document}

Both ways should give the desired result.

1
  • Thank you very much for your detailed answer! I've added ignore nobreak to the first zitat. – Hotschke Nov 29 '16 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.