# [texhax] Problem with color package

Reinhard Kotucha reinhard.kotucha at web.de
Fri Dec 13 02:53:38 CET 2013

On 2013-12-12 at 20:08:33 -0500, Michael Barr wrote:

> It is not surprising that using the color package, the word Test2 prints
> in red in the example:
> \setbox0\hbox{\color{red} Test1}\box0 Test2
>
> But it seems like a failure of the tex grouping mechanism when the same
> happens in this example:
>
> {\setbox0\hbox{\color{red} Test1}\box0} Test2
>
> Adding a group in another place does not improve things:
>
> \setbox0\hbox{{\color{red} Test1}}\box0 Test2
>
> but adding both sets of groupings does:
>
> {\setbox0\hbox{{\color{red} Test1}}\box0} Test2
>
> I got a partial (but not entirely convincing) explanation of this
> from Daniel Müllner.  But is there any way to force \color to
> confine itself to being inside a group.  And why does it need two
> levels of grouping to get it to work?
>
> The following also work:
> \setbox0\hbox{{{\color{red} Test1}}}\box0 Test2
> {{{\setbox0\hbox{\color{red} Test1}\box0\relax}}} Test2

Avoid plain TeX.  TeX doesn't support color at all.  The LaTeX color
package emits information to the PS or PDF driver but neither PS nor
PDF is aware of TeX's grouping mechanism.  LaTeX has it's own boxes
which support color much better than plain TeX.

Regards,
Reinhard

--
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------