color
package. This may
benefit people using your class or package who have access to colour
printers.
The simplest way to ensure `colour safety' is to always use LATEX
box commands rather than TEX primitives, that is use \sbox
rather
than \setbox
, \mbox
rather than \hbox
and \parbox
or
the minipage
environment rather than \vbox
.
The LATEX box commands have new options which mean that they are now
as powerful as the TEX primitives.
As an example of what can go wrong, consider that in
{\ttfamily <text>}
the font is restored just before the }
, whereas in the
similar looking construction
{\color{green} <text>}
the colour is restored just after the final }
. Normally this
distinction does not matter at all; but consider a primitive TEX
box assignment such as:
\setbox0=\hbox{\color{green} <text>}Now the colour-restore occurs after the
}
and so is not
stored in the box. Exactly what bad effects this can have depends on
how colour is implemented: it can range from getting the wrong
colours in the rest of the document, to causing errors in the
dvi-driver used to print the document.
Also of interest is the command \normalcolor
. This is
normally just \relax
(i.e., does nothing)
but you can use it rather like \normalfont
to
set regions of the page such as captions or section headings to the
`main document colour'.