I try to maintain the current text colour in breakable boxes from tcolorbox
, but the manual clearly states (see manual of the current version, section 15.2, page 292, version 3.34)
• If your text content contains some text color changing commands, your color will not survive the break to the next box.
So, this has to fail (right now). However, colour changes are maintained in explicit
TeX boxes, being split using \vsplit
.
Is there a way (i.e. hack/patch) to force tcolorbox
to maintain the current text colour from one part of the broken box to the next one?
A grouping with { \color{....}...}
or \begingroup \color{...}...\endgroup
or \textcolor{...}{...}
does not work neither.
\documentclass{article}
\usepackage{blindtext}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\begin{document}
\begin{tcolorbox}[breakable]
\blindtext[3]
\color{blue} % To 'force' color change
\blindtext[3]
\color{red}
\blindtext
\color{brown}
\blindtext
\end{tcolorbox}
\end{document}
The colour should be blue on the upper half of the second box if it would work ;-)
\vsplit
is used internally, but coloring is not really supported for this command, see tex.stackexchange.com/questions/150780/… and David Carlisles answer to this. Changing color setting for the currenttcolorbox
implementation is very touchy since I put in a great deal of time to get it like it is now. It is not perfect and has same drawbacks, but it circumvents a lot of problems.