Even if you do not intend to use colour in your own documents, by
taking note of the points in this section you can ensure that your
class or package is compatible with the 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'.