I'd like to have a command \globalred that makes all subsequent text red, even if the command is issued inside a group. For example, the output of the TeX file
\documentclass{article}
\begin{document}
a {\globalred b} c
\end{document}
should be
, with a red c. I do have some very hacky solution, but it only works by redefining the \set@color and \reset@color commands from pdftex.def to what they where up to version 0.03t (or by using an old TeX installation before 2007):
\documentclass{article}
\usepackage[pdftex]{xcolor}
\makeatletter
\def\set@color {\pdfliteral{\current@color}%
\aftergroup\reset@color}
\def\reset@color{\pdfliteral{\current@color}}
\def\globalred {\xdef\current@color{\xcolor@ {}{1 0 0 rg 1 0 0 RG}{rgb}{1,0,0}}%
\set@color}
\makeatother
\begin{document}
a {\globalred b} c
\end{document}
This leads me to the following questions:
- Is there an "official" way to achieve what I want?
- Why doesn't
\set@colorfrom more recentpdftex.defversions act globally anymore, although I globally redefine\current@colorwith\xdef? (Is this a design choice or just an unforeseen side effect of the new implementation of\set@color?)
Let me shortly explain how I came up with this: in my hacky code above, I'm roughly emulating what beamer does to produce transparent text. beamer aims to do this in a way that transcedes groups (see the user guide, pages 24 and 79), but it appears that it doesn't work anymore; at least for me, the example on page 79 gives strange output:

The same problem (and hacky solution) came up in this question my mine.


beameruser guide, page 24:-)) – Hendrik Vogt Sep 20 '12 at 12:22:). It's from Latin "trans" plus "scandere" (to climb), not "trans" plus "cedere" (to move). Compare "descend" and "procede". – egreg Sep 20 '12 at 12:48beameruser guide without thinking about it:-)– Hendrik Vogt Sep 20 '12 at 12:53