Color leak from multicols within a figure
Interesting:-)
As it's an interaction between color
and multicol
then it's probably something to do with some code of mine or Frank's. Obviously I suspect Frank:-)
No time to debug now but such problems are usually fixed by adding an extra group, and adding {}
as here, fixes it in this case.
\begin{multicols}{2}
{\color{red}\normalcolor
Hello. World World World
World World World World World World
World World World World World World
World World World World World World
World World World World World World
World World World World World World
World World World World
World World World World World World
World World World World World World
World World World World World World
World World World World World World
World World World World World\par}
David's suspicion is correct: multicol
is at fault here. When the environment detects that it is used inside a box (e.g., in a float in this case) it will collect its material inside a vertical box and then applies its balancing routine by splitt the box into columns. It does this by using \setbox
in a way that is not "color safe".
As a result the first color change in the sequence \color{red}\normalcolor
(or more precisely the second last color change) will be misinterpreted by the surrounding float environment as the outer color to be restored after the float as it remains on the "color stack".
A possible patch for this would look as follows:
\usepackage{etoolbox}
\makeatletter
\patchcmd{\mult@@cols}{\vbox\bgroup}{\vbox\bgroup\color@setgroup}{}{\PATCHerror}
\patchcmd{\endmulticols}{\egroup}{\color@endgroup\egroup}{}{\PATCHerror}
\makeatother
but obviously that should be properly integrated into the multicol
package. A nice example of the fact that this part of the multicol
code predates LaTeX2e and quite interesting that it took this bug 20 years to surface.
Update
Just for the record this patch has been integrated in multicol for a while so this problem should no longer happen.