3

Tcolorbox parbox=false option breaks by height fill option

\documentclass[]{article}
\usepackage[most, many]{tcolorbox}
\usepackage{lipsum}

\begin{document}

\begin{tcolorbox}[
parbox=false, 
height fill % this option breaks parbox=false option
]
\lipsum[1-3]
\end{tcolorbox}

\end{document}

enter image description here

3

Typically, the content of a tcolorbox is processed into one or more internal box registers. Then, this box / these boxes are typeset with appropriate drawing code etc.

For height fill, there are some exceptions. Especially, the before code is executed before the content is processed. Unfortunately, this makes side effects possible. Here, some setting from before punches through.

With a patch, this can be repaired for the current example:

\documentclass[]{article}
\usepackage[most, many]{tcolorbox}
\usepackage{lipsum}

\makeatletter
\tcbset{
  parskip/.style={before={\ifnum\lastnodetype=-1\relax\else\par%
      \ifvmode\edef\tcb@prevdepth{\the\glueexpr\prevdepth+\lineskip+\parskip}%
      \def\tcb@undo@before{\addvspace{-\glueexpr\tcb@prevdepth}}%
      \pagebreak[0]\fi\fi\noindent},
    after={\tcb@parfillskip@check\par}},
  noparskip/.style={before={\ifnum\lastnodetype=-1\relax\else\par%
      \ifvmode\edef\tcb@prevdepth{\the\glueexpr\prevdepth+\lineskip}%
      \def\tcb@undo@before{\addvspace{-\glueexpr\smallskipamount+\tcb@prevdepth}}%
      \pagebreak[0]\smallskip\fi\fi\noindent},
    after={\tcb@parfillskip@check\par\smallskip}},
}
\makeatother

\begin{document}

\begin{tcolorbox}[
parbox=false,
height fill
]
\lipsum[1-3]
\end{tcolorbox}

\end{document}

I will add this patch to the next tcolorbox version, if nothing new comes up.

|improve this answer|||||

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.