# [texhax] Changing font color of a saved box of text - is it possible?

Ivan Griffin ivan at skynet.ie
Tue Sep 4 12:20:05 CEST 2012

Hi TeX gurus,

I'd like to be able to save a box, and then change the color of the font
in it when I come to use it.  Is this possible?

I suspect not (as the typesetting/macro expansion is already complete
within the box), and saving multiple boxes and chosing the one with the
color I want isn't practical in my particular application. I guess I'm
asking if there is any sneaky tricks I can use to override the color in
the saved box?

Here is a small working example that shows what I'm trying to do: Ideally,
both lines of text should be the same color (red).

--------------------------------------------

\documentclass{article}

\usepackage{xcolor}

\newsavebox{\boxFoo}

\begin{document}

\begin{lrbox}{\boxFoo}
This is test 1.
\end{lrbox}

\color{red}

\usebox{\boxFoo}

This is test 2.
\end{document}

--------------------------------------------

What I see is that "This is test 1" is typeset in black, whereas "This is
test 2" is typeset in red.

Best Regards,
Ivan.