Update LuaTeX testfiles for ^@ change
[latex2e.git] / latex2e-20170101 / required / graphics / color.dtx
blobd85b78349d88ba9b2d3c0ab4f6ad6b3a24fe60c7
2 % \iffalse
4 %% color.dtx Copyright (C) 1994--1999 David Carlisle
5 %%           Copyright (C) 2005--2016 David Carlisle, LaTeX3 Project
6 %%
7 %% This file is part of the Standard LaTeX `Graphics Bundle'.
8 %% It may be distributed under the terms of the LaTeX Project Public
9 %% License, as described in lppl.txt in the base LaTeX distribution.
10 %% Either version 1.3c or, at your option, any later version.
12 %% This file has the LPPL maintenance status "maintained".
14 %<*dtx>
15           \ProvidesFile{color.dtx}
16 %</dtx>
17 %<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
18 %<package>\ProvidesPackage{color}
19 %<driver> \ProvidesFile{color.drv}
20 % \fi
21 %         \ProvidesFile{color.dtx}
22           [2016/07/10 v1.1e Standard LaTeX Color (DPC)]
24 % \iffalse
25 %<*driver>
26 \documentclass{ltxdoc}
27 \newenvironment{option}[1]{\expandafter\macro\expandafter{%
28    \csname ds@#1\endcsname}}{\endmacro}
29 \begin{document}
30  \DocInput{color.dtx}
31 \end{document}
32 %</driver>
33 % \fi
35 % \GetFileInfo{color.dtx}
37 % \title{The \textsf{color} package\thanks{This file
38 %        has version number \fileversion, last
39 %        revised \filedate.}}
40 % \author{D. P. Carlisle}
41 % \date{\filedate}
42 % \MaintainedByLaTeXTeam{graphics}
43 % \maketitle
47 % \title{The implementation of the \LaTeX\ Colour interface.}
49 % \section{Introduction}
50 % This package implements \LaTeX\ support for colour, for those
51 % \texttt{dvi} drivers that can produce coloured text.
53 % The user level documentation of this package is contained in the
54 % document \emph{Packages in the `graphics' bundle} in the file
55 % \texttt{grfguide.tex}.
57 % \StopEventually{}
60 % \section{Options}
62 % \changes{v0.2a}{1994/04/13}
63 %     {TEMP KLUDGE for Feb 94 release of 2e:
64 %      Add extra groups}
65 % \changes{v0.2d}{1994/05/13}
66 %     {All support for Feb 1994 release removed (so used optional arg
67 %     of \cs{NeedsTeXFormat}).}
68 % \changes{v1.0}{1996/05/29}
69 %     {Version 1 at last}
71 %    \begin{macrocode}
72 %<*package>
73 %    \end{macrocode}
75 % First we save the catcodes of some characters, and set them to
76 % fixed values whilst this file is being read.
77 % \changes{v0.3b}{1994/09/14}
78 %     {Save and restore catcodes}
79 %    \begin{macrocode}
80 \edef\Gin@codes{%
81  \catcode`\noexpand\^^A\the\catcode`\^^A\relax
82  \catcode`\noexpand\"\the\catcode`\"\relax
83  \catcode`\noexpand\*\the\catcode`\*\relax
84  \catcode`\noexpand\!\the\catcode`\!\relax
85  \catcode`\noexpand\:\the\catcode`\:\relax}
86 \catcode`\^^A=\catcode`\%
87 \catcode`\"=12
88 \catcode`\*=11
89 \catcode`\!=12
90 \catcode`\:=12
91 %    \end{macrocode}
93 % \begin{macro}{\Gin@driver}
94 % Initialize the macro to hold the driver file name.
95 %    \begin{macrocode}
96 \providecommand\Gin@driver{}
97 %    \end{macrocode}
98 % \end{macro}
100 % \begin{macro}{\c@lor@error}
101 % \changes{v1.0d}{1997/01/07}
102 %      {Macro added for graphics/2350}
103 % Helper macro for error handling (redefined by the monochrome option
104 % to make errors warnings).
105 %    \begin{macrocode}
106 \def\c@lor@error#1{%
107   \@latex@error{Undefined color #1}\@ehd}
108 %    \end{macrocode}
109 % \end{macro}
111 % \begin{option}{monochrome}
112 % The |monochrome| option should be used \emph{in addition}
113 %  to one of the standard driver options.
114 % \changes{v0.3j}{1995/06/16}
115 %      {Use single hash for latex/1557}
116 % \changes{v1.0b}{1996/10/29}
117 %      {Add \cs{colors@false}}
118 % \changes{v1.0d}{1997/01/07}
119 %      {Add \cs{c@lor@error} for graphics/2350}
120 %    \begin{macrocode}
121 \DeclareOption{monochrome}{%
122   \def\c@lor@error#1{\PackageInfo{color}{Undefined color #1}}%
123   \AtEndOfPackage{%
124     \colors@false
125     \def\set@color{%
126       \c@lor@special\m@ne
127         {color push \current@color}\aftergroup\reset@color}%
128     \def\reset@color{\c@lor@special\m@ne{color pop}}%
129     \def\set@page@color{%
130       \c@lor@special\m@ne{background \current@color}}%
131     \def\define@color#1#2{%
132       \c@lor@special\m@ne{define #1 #2}}}}
133 %    \end{macrocode}
134 % \end{option}
136 % \begin{option}{debugshow}
137 % The |debugshow| option turns on debugging info (perhaps).
138 % \changes{v1.0a}{1996/09/16}
139 %     {debugshow option added}
140 %    \begin{macrocode}
141 \DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
142 %    \end{macrocode}
143 % \end{option}
145 % \begin{option}{setpagesize}
146 % \begin{option}{nosetpagesize}
147 % The |setpagesize| option requests that the driver option sets the page size.
148 % \changes{v1.1d}{2016/06/02}
149 %     {(no)setpagesize options added}
150 % (Whichever option is used, the page size is not set by this package if |\mag|
151 % has been changed from its default value.)
152 %    \begin{macrocode}
153 \newif\ifGin@setpagesize\Gin@setpagesizetrue
154 \DeclareOption{setpagesize}{\Gin@setpagesizetrue}
155 \DeclareOption{nosetpagesize}{\Gin@setpagesizefalse}
156 %    \end{macrocode}
157 % \end{option}
158 % \end{option}
160 % Now the options for supported drivers.
162 % \begin{option}{dvips}
163 % \begin{option}{xdvi}
164 % Tom Rokicki's dvips driver, and the X Windows previewer, xdvi which uses
165 % (a subset of) the same |\specials|.
166 %    \begin{macrocode}
167 \DeclareOption{dvips}{\def\Gin@driver{dvips.def}%
168                       \def\c@lor@namefile{dvipsnam.def}}
169 \DeclareOption{xdvi}{\ExecuteOptions{dvips,monochrome}}
170 %    \end{macrocode}
171 % \end{option}
172 % \end{option}
174 % \begin{option}{dvipdf}
175 % \changes{v1.0c}{1996/10/31}
176 %     {dvipdf added}
177 % Sergey Lesenko's dvipdf driver.
178 %    \begin{macrocode}
179 \DeclareOption{dvipdf}{\def\Gin@driver{dvipdf.def}}
180 %    \end{macrocode}
181 % \end{option}
183 % \begin{option}{dvipdfm}
184 % \changes{v1.0h}{1999/01/13}
185 %     {dvipdfm added}
186 % Mark Wick's dvipdfm driver.
187 %    \begin{macrocode}
188 \DeclareOption{dvipdfm}{\def\Gin@driver{dvipdfm.def}}
189 %    \end{macrocode}
190 % \end{option}
192 % \begin{option}{dvipdfmx}
193 % \changes{v1.0j}{2005/11/14}
194 %     {dvipdfmx added}
195 % The driver for the dvipdfmx project.
196 %    \begin{macrocode}
197 \DeclareOption{dvipdfmx}{\def\Gin@driver{dvipdfmx.def}}
198 %    \end{macrocode}
199 % \end{option}
201 % \begin{option}{pdftex}
202 % \changes{v1.0e}{1997/06/07}
203 %     {pdftex added}
204 %  Han The Thanh's \TeX\ variant.
205 %    \begin{macrocode}
206 \DeclareOption{pdftex}{\def\Gin@driver{pdftex.def}}
207 %    \end{macrocode}
208 % \end{option}
210 % \begin{option}{luatex}
211 % \changes{v1.1b}{2016/01/03}
212 %     {luatex added}
213 %  Lua\TeX\ \TeX\ variant.
214 %    \begin{macrocode}
215 \DeclareOption{luatex}{\def\Gin@driver{luatex.def}}
216 %    \end{macrocode}
217 % \end{option}
219 % \begin{option}{luatex}
220 % \changes{v1.1c}{2016/05/09}
221 %     {dvisvgm added}
222 %  dvisvgm driver.
223 %    \begin{macrocode}
224 \DeclareOption{dvisvgm}{\def\Gin@driver{dvisvgm.def}}
225 %    \end{macrocode}
226 % \end{option}
228 % \begin{option}{xetex}
229 % \changes{v1.0j}{2005/11/14}
230 %     {xetex added}
231 %  Jonathan Kew's \TeX\ variant.
232 %    \begin{macrocode}
233 \DeclareOption{xetex}{\def\Gin@driver{xetex.def}}
234 %    \end{macrocode}
235 % \end{option}
237 % \begin{option}{dvipsone}
238 % \begin{option}{dviwindo}
239 % \changes{v0.3k}{1995/09/07}
240 %      {Merge dviwindo and dvipsone options}
241 % The drivers of the Y\&Y \TeX\ system.
242 % (Which use the same |\specials|).
243 %    \begin{macrocode}
244 \DeclareOption{dvipsone}{\def\Gin@driver{dvipsone.def}}
245 \DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
246 %    \end{macrocode}
247 % \end{option}
248 % \end{option}
250 % \begin{option}{emtex}
251 % \begin{option}{dviwin}
252 % Freely available drivers for PCs.
253 %    \begin{macrocode}
254 \DeclareOption{emtex}{\def\Gin@driver{emtex.def}}
255 \DeclareOption{dviwin}{\def\Gin@driver{dviwin.def}}
256 %    \end{macrocode}
257 % \end{option}
258 % \end{option}
260 % \begin{option}{oztex}
261 % \changes{v1.0f}{1997/09/09}
262 %     {Merge dvips and oztex options}
263 % The Oz\TeX\ system for a Macintosh.
264 % Since release 3 of Oz\TeX, merge with dvips back end.
265 %    \begin{macrocode}
266 \DeclareOption{oztex}{\ExecuteOptions{dvips}}
267 %    \end{macrocode}
268 % \end{option}
270 % \begin{option}{textures}
271 % Blue sky's Textures system on a Macintosh.
272 %    \begin{macrocode}
273 \DeclareOption{textures}{\def\Gin@driver{textures.def}}
274 %    \end{macrocode}
275 % \end{option}
277 % \begin{option}{pctexps}
278 % \begin{option}{pctexwin}
279 % \begin{option}{pctexhp}
280 % \begin{option}{pctex32}
281 % \changes{v1.0b}{1996/10/29}
282 %     {pctex32 option added}
283 % The drivers for PTI's \TeX\ system on PCs.
284 %    \begin{macrocode}
285 \DeclareOption{pctexps}{\def\Gin@driver{pctexps.def}}
286 \DeclareOption{pctexwin}{\def\Gin@driver{pctexwin.def}}
287 \DeclareOption{pctexhp}{\def\Gin@driver{pctexhp.def}}
288 \DeclareOption{pctex32}{\def\Gin@driver{pctex32.def}}
289 %    \end{macrocode}
290 % \end{option}
291 % \end{option}
292 % \end{option}
293 % \end{option}
295 % \begin{option}{truetex}
296 % \begin{option}{tcidvi}
297 % \changes{v1.0b}{1996/10/29}
298 %     {truetex and tcidvi options added}
299 % The drivers of the Kinch \TeX\ system on PCs, and its
300 % version with extra  |\special| handling dll's as shipped with
301 % TCI's Scientific Word.
302 %    \begin{macrocode}
303 \DeclareOption{truetex}{\def\Gin@driver{truetex.def}}
304 \DeclareOption{tcidvi}{\def\Gin@driver{tcidvi.def}}
305 %    \end{macrocode}
306 % \end{option}
307 % \end{option}
309 % \begin{option}{vtex}
310 % \changes{v1.0g}{1998/05/27}
311 %     {vtex option added}
312 % V\TeX\ driver.
313 %    \begin{macrocode}
314 \DeclareOption{vtex}{\def\Gin@driver{vtex.def}}
315 %    \end{macrocode}
316 % \end{option}
318 % \begin{option}{dvi2ps}
319 % \begin{option}{dvialw}
320 % \begin{option}{dvilaser}
321 % \begin{option}{dvitops}
322 % \begin{option}{psprint}
323 % \begin{option}{pubps}
324 % \begin{option}{ln}
325 % \changes{v1.0b}{1996/10/29}
326 %     {old driver options depreciated}
327 % Old, probably obsolete, drivers commented out. See the section
328 % on `Driver support' in grfguide to see how to re-enable these
329 % options in |color.cfg| if you need them.
330 %    \begin{macrocode}
331 %\DeclareOption{dvi2ps}{\def\Gin@driver{dvi2ps.def}}
332 %\DeclareOption{dvialw}{\def\Gin@driver{dvialw.def}}
333 %\DeclareOption{dvilaser}{\def\Gin@driver{dvilaser.def}}
334 %\DeclareOption{dvitops}{\def\Gin@driver{dvitops.def}}
335 %\DeclareOption{psprint}{\def\Gin@driver{psprint.def}}
336 %\DeclareOption{pubps}{\def\Gin@driver{pubps.def}}
337 %\DeclareOption{ln}{\def\Gin@driver{ln.def}}
338 %    \end{macrocode}
339 % \end{option}
340 % \end{option}
341 % \end{option}
342 % \end{option}
343 % \end{option}
344 % \end{option}
345 % \end{option}
348 % \begin{option}{dvipsnames}
349 % \begin{option}{nodvipsnames}
350 % By default the named colour model has no pre-declared names.
351 % The |dvipsnames| option predeclares all the names in the colour
352 % prologue of dvips. The |dvips| option automatically implies
353 % |dvipsnames| unless this choice is overruled with the |nodvipsnames|
354 % option. For other drivers, eg |textures| you may use this option to
355 % explicitly request that these names be declared.
356 %    \begin{macrocode}
357 \DeclareOption{dvipsnames}{\def\c@lor@namefile{dvipsnam.def}}
358 \DeclareOption{nodvipsnames}{\let\c@lor@namefile\relax}
359 %    \end{macrocode}
360 % \end{option}
361 % \end{option}
363 % \begin{option}{usenames}
364 % The |usenames| option modifies the behaviour of |\DefineNamedColor|
365 % So that it declares the same name as a ```user's colour'' for use in
366 % a |\color| command, as well as a name in the |named| colour model.
367 % The normal behaviour is just to declare the name in the named colour
368 % model.
369 %    \begin{macrocode}
370 \let\c@lor@usename\@gobble
371 %    \end{macrocode}
373 %    \begin{macrocode}
374 \DeclareOption{usenames}{%
375   \def\c@lor@usename#1{%
376     \expandafter\color@named\csname\string\color @#1\endcsname{#1}}}
377 %    \end{macrocode}
378 % \end{option}
380 % \section{Using Colours}
382 % \subsection{Declarative form}
384 %  \begin{macro}{\color}
385 % |\color{|\emph{declared-colour}|}| switches to the colour
386 % \emph{declared-colour}, which must previously have been defined
387 % using |\definecolor|. This colour will stay in effect until the end of
388 % the current \TeX\ group.
390 % |\color[|\emph{model}|]{|\emph{colour-specification}|}| is similar
391 % to the above, but uses a colour not declared by |\definecolor|. The
392 % allowed \emph{model}'s vary depending on the driver. The syntax of
393 % the \emph{colour-specification} argument depends on the model.
395 % \changes{v0.3a}{1994/07/20}
396 %     {Make \cs{color} robust}
397 %    \begin{macrocode}
398 \DeclareRobustCommand\color{%
399   \@ifnextchar[\@undeclaredcolor\@declaredcolor}
400 %    \end{macrocode}
401 %  \end{macro}
403 %  \begin{macro}{\@undeclaredcolor}
404 % \changes{v0.2c}{1994/05/09}
405 %     {Improve error messages}
406 % \changes{v0.3a}{1994/07/20}
407 %     {New internal implementation of colour commands}
408 % Call the driver-dependent command |\color@|\meta{model} to define
409 % |\current@color|, then call |\set@color| to change the current colour
410 % accordingly.
411 %    \begin{macrocode}
412 \def\@undeclaredcolor[#1]#2{%
413   \@ifundefined{color@#1}%
414     {\c@lor@error{model `#1'}}%
415     {\csname color@#1\endcsname\current@color{#2}%
416      \set@color}%
417   \ignorespaces}
418 %    \end{macrocode}
419 %  \end{macro}
421 %  \begin{macro}{\@declaredcolor}%
422 % \changes{v0.1c}{1994/04/01}
423 %     {Add \cs{ignorespaces}}
424 % \changes{v0.1e}{1994/05/14}
425 %     {Minor change to error message}
426 % \changes{v0.3a}{1994/07/20}
427 %     {New internal implementation of colour commands}
428 % |\let| |\current@color| to the internal representation of the colour
429 % if the colour has  been declared, otherwise generate an error.
430 % Finally call |\set@color| to effect the colour change.
431 %    \begin{macrocode}
432 \def\@declaredcolor#1{%
433   \@ifundefined{\string\color @#1}%
434     {\c@lor@error{`#1'}}%
435     {\expandafter\let\expandafter\current@color
436      \csname\string\color @#1\endcsname
437      \set@color}%
438   \ignorespaces}
439 %    \end{macrocode}
440 %  \end{macro}
442 % \subsection{Command (Argument) Form}
444 %  \begin{macro}{\textcolor}
445 % |\textcolor{|\emph{declared-colour}|}{|\emph{text}|}| and
446 % |\textcolor[|\emph{model}|]{|\emph{colour-spec}|}{|\emph{text}|}|
447 % are just alternative syntax for |\color|, in
448 % which the groups are added implicitly. Thus \emph{text} appears in the
449 % specified colour, but then the colour reverts to its previous value.
450 % The naming is by analogy with |\textrm| (as opposed to |\rm| and
451 % |\rmfamily|) although it is slightly a misnomer as the command also
452 % works in math-mode.
454 % Since December 95, in fact this command has one other difference
455 % from |\color|. It calls |\leavevmode| to ensure the start of
456 % horizontal mode. Specifically this means that a construction
457 % such as
458 %\begin{verbatim}
459 % xxx\parbox[t]{1cm}{\textcolor{red}{a}.....
460 %\end{verbatim}
461 % now works as expected, with the |xxx| and the red |a| lining up
462 % correctly.
463 % \changes{v0.3a}{1994/07/20}
464 %     {Stop command being \cs{long}, and make robust.}
465 % \changes{v0.3l}{1995/12/07}
466 %      {Add \cs{leavevmode}}
467 %    \begin{macrocode}
468 \def\textcolor#1#{\@textcolor{#1}}
469 \def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
470 %    \end{macrocode}
471 %  \end{macro}
473 % \subsection{Background (Page) Colour}
475 % \begin{macro}{\pagecolor}
476 % |\pagecolor|, which has the same argument forms as |\color|, specifies
477 % the background colour for the current, and all following, pages. It is
478 % a global declaration which does not respect \TeX\ groups.
480 % \changes{v0.1c}{1994/04/01}
481 %     {end the group even if the colour command generates an error}
482 % \changes{v0.3c}{1994/09/19}
483 %     {Use \cs{color} to parse arguments}
484 %    \begin{macrocode}
485 \def\pagecolor{%
486   \begingroup
487       \let\ignorespaces\endgroup
488       \let\set@color\set@page@color
489       \color}
490 %    \end{macrocode}
491 %  \end{macro}
493 % \begin{macro}{\nopagecolor}
494 % |\nopagecolor| (suggested by Heiko Oberdiek) removes any currently specified page colour
495 % returning to the default transparent background. It is not yet supported by all driver options
496 % and so generates a warning if there is no definition in the driver file.
498 % \changes{v1.1a}{2014/04/23}
499 %     {add \cs{nopagecolor} graphics/3873}
500 %    \begin{macrocode}
501 \def\nopagecolor{%
502   \@ifundefined{no@page@color}{%
503     \PackageInfo{color}{\string\nopagecolor\space is not supported}%
504   }{%
505     \no@page@color
506   }%
508 %    \end{macrocode}
509 %  \end{macro}
512 % \section{Defining Colours}
514 %  \begin{macro}{\definecolor}
515 % |\definecolor{|\emph{name}|}{|\emph{model}|}{|\emph{colour-spec}|}|
516 % defines the color \emph{name}, which may then be used in subsequent
517 % |\color| or |\textcolor| commands to refer to a colour specified by
518 % \emph{colour-spec} in the colour model \emph{model}.
520 % |\definecolor| associates the \emph{name} the to a  colour in
521 % \emph{model}. So |\color{|\emph{name}|}| would check \emph{name}
522 % then issue a |\special| for the colour model \emph{model}.
524 % |\definecolor| just calls an internal macro that defines the colour
525 % for a particular model. This macro must have been defined by the
526 % driver file that supports the requested \emph{model}.
528 % \changes{v0.1b}{1994/03/15}
529 %     {change name from \cs{newcolor} to \cs{definecolor}}
530 % \changes{v0.1e}{1994/05/14}
531 %     {Minor change to error message}
532 % \changes{v0.3a}{1994/07/20}
533 %     {New internal implementation of colour commands}
534 % \changes{v0.3f}{1994/10/04}
535 %     {Give info about redefinitions}
536 %    \begin{macrocode}
537 \def\definecolor#1#2#3{%
538   \@ifundefined{color@#2}%
539     {\c@lor@error{model `#2'}}%
540     {\@ifundefined{\string\color @#1}{}%
541       {\PackageInfo{color}{Redefining color #1}}%
542      \csname color@#2\expandafter\endcsname
543          \csname\string\color @#1\endcsname{#3}}}
544 %    \end{macrocode}
545 %  \end{macro}
548 %  \begin{macro}{\DefineNamedColor}
549 % \changes{v0.3d}{1994/09/29}
550 %     {Macro added}
551 % \changes{v0.3e}{1994/10/03}
552 %     {usenames option added}
553 % \changes{v0.3f}{1994/10/04}
554 %     {Give info about redefinitions}
556 % Driver files may opt to define a `named' colour model.
557 % Placing colour names rather than numeric specifications into the dvi
558 % file has certain advantages, in that post processing software can
559 % tune the colour specifications to the particular technology being
560 % used, and more easily make colour separations for that colour.
561 % The disadvantage is that the driver must `know' the colour
562 % names.
564 % The `color1' drivers (dvips) currently ignore the specification of
565 % the colour, and once a name is defined, just put the colour name in
566 % the dvi file. For dvips, The header file \texttt{color.pro} is used to
567 % give the cmyk equivalents of the names.
569 % The `color2' drivers (textures) use a special postscript operator
570 % that takes both the name and the cmyk equivalent. so if the names are
571 % not being used, `fall back' definitions in the cmyk model are available.
572 % These drivers also allow a numeric value to affect the `density'
573 % of the colour to use.
575 % Drivers based on `color3' do not support named colours at the dvi
576 % level, but to ease document portability, the named model is still
577 % defined, but the |\special|'s just put the colour specifications, not
578 % the names, into the dvi file.
580 % Normally after a colour, say |JungleGreen|, has been declared with:\\
581 % |\DefineNamedColor{named}{JungleGreen}{cmyk}{1,2,3,4}|\\
582 %  it is available in the `named' colour model, for
583 % instance by\\
584 %  |\color[named]{JungleGreen}|\\
585 % A user may give a more convenient name, using\\
586 %  |\definecolor{mygreen}{named}{JungleGreen}|\\
587 % If however you are  happy with the original names, and want to use
588 % them directly, as in |\color{JungleGreen}| without specifying
589 % |[named]| all the time, just give the package option |usenames|, which
590 % will redefine |\DefineNamedColor|, so that the colour name is declared
591 % as a user-colour as well as a name in the `named' model.
592 %    \begin{macrocode}
593 \def\DefineNamedColor#1#2#3#4{%
594   \@ifundefined{define@color@#1}%
595     {\c@lor@error{model `#1'}}%
596     {\@ifundefined{color@#3}%
597       {\c@lor@error{model `#3'}}%
598       {\@ifundefined{c@lor@#1@#2}{}%
599         {\PackageInfo{color}{Redefining color #2 in named color model}}%
600       \csname color@#3\endcsname\@tempa{#4}%
601       \csname define@color@#1\endcsname{#2}\@tempa
602       \c@lor@usename{#2}}}}
603 \@onlypreamble\DefineNamedColor
604 %    \end{macrocode}
605 %  \end{macro}
607 % \section{Colour Switch}
609 %  \begin{macro}{\ifcolors@}
610 % This boolean can be tested by higher level macros that may want to
611 % alter their behaviour if a monochrome driver is being used.
612 %    \begin{macrocode}
613 \newif\ifcolors@
614 \colors@true
615 %    \end{macrocode}
616 %  \end{macro}
618 % \section{Whatsit\ldots}
620 % \begin{macro}{\c@lor@special}
621 % Some drivers can not support all the features of this package. They
622 % should always put a \meta{whatsit} in the current list though. The
623 % following macro has most of the features of |\special|, but does not
624 % put anything into the |dvi| file. It does write to the log file or the
625 % terminal (depending on the value of |#1|).
626 %    \begin{macrocode}
627 \def\c@lor@special#1#2{%
628   \edef\@tempa{\write#1{#2}}\@tempa}
629 %    \end{macrocode}
630 %  \end{macro}
632 % \section{Processing Options}
634 % A local configuration file may declare more options.
635 % It should also make one driver option the default, by calling
636 % |\ExecuteOptions| with the appropriate option.
637 %    \begin{macrocode}
638 \InputIfFileExists{color.cfg}{}{}
639 %    \end{macrocode}
641 % After the options are processed, load the appropriate driver file.
642 % If a site wants a default driver (eg |dvips|) it just needs to put
643 % |\ExecuteOptions{dvips}| in a |color.cfg| file.
644 % \changes{v0.3b}{1994/09/14}
645 %                {New style of loading driver files}
646 %    \begin{macrocode}
647 \ProcessOptions
648 %    \end{macrocode}
650 %    \begin{macrocode}
651 \if!\Gin@driver!
652   \PackageError{color}
653     {No driver specified}
654     {You should make a default driver option in a file \MessageBreak
655      color.cfg\MessageBreak
656      eg: \protect\ExecuteOptions{dvips}%
657      }
658 \else
659   \PackageInfo{color}{Driver file: \Gin@driver}
660   \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
662 %    \end{macrocode}
664 %    \begin{macrocode}
665 \@ifundefined{c@lor@namefile}{}{\input{\c@lor@namefile}}
666 %    \end{macrocode}
668 % \section{Default Colour}
670 % \begin{macro}{\normalcolor}
671 % Early versions of this package redefined |\reset@font| to reset the
672 % color as well. Current versions do not do this (there are too many
673 % |\reset@font| commands hidden in strange places) and so defines a
674 % separate command, |\normalcolor| to reset the colour to the colour in
675 % effect at the start of the document.
677 % |\normalcolor| is defined (to |\relax|) in the \LaTeX\ kernel, so it
678 % is safe to use this in macros that may possibly be used in
679 % conjunction with colour. It will have no effect until the |color|
680 % package is also loaded.
681 % \changes{v0.2b}{1994/04/18}
682 %     {Only reset the colour with \cmd{\reset@font} not
683 %      \cmd{\normalfont}}
684 % \changes{v0.2d}{1994/05/13}
685 %     {Stop changing \cs{reset@font}. Use the new \cs{normalfont}
686 %     instead.}
687 %    \begin{macrocode}
688 \def\normalcolor{\let\current@color\default@color\set@color}
689 %    \end{macrocode}
690 % \end{macro}
692 %  \begin{macro}{\default@color}
693 % Internal macro to store the `default' colour used by |\normalcolor|.
694 %    \begin{macrocode}
695 \AtBeginDocument{\let\default@color\current@color}
696 %    \end{macrocode}
697 % \end{macro}
699 % |\current@color| contains an internal representation of the colour
700 % at this point in the document. (This can only be an approximation to
701 % the truth as the `macro layer' of \TeX\ does not know where the output
702 % routine is going to re-insert floats. This is why drivers must
703 % maintain their own stack of colours in order to fully support these
704 % commands.
706 % For dvips, the |\current@color| it is something like `|Black|' or
707 % `|rgb 0 1 0|', but other packages should not rely on any particular
708 % format for this macro.
710 % The driver file \emph{must} initialise |\current@color| to a
711 % specification for Black. This initialisation can not occur here, as
712 % the possible colour models (and thus the syntax for `black')
713 % are not known at this point.
715 % \section{Higher Level Commands}
717 % With the basic colour primitives specified above we may define a few
718 % higher level commands for coloured boxes etc. This is still quite a low
719 % level and presumably packages and classes making use of colour will
720 % define more appropriate document-level commands.
722 % \subsection{Colour Block}
724 % \begin{macro}{\color@block}
725 % |\color@block{|\emph{width}|}{|\emph{height}|}{|\emph{depth}|}|\\
726 % Should take up no space for \TeX, but produce a block in the current
727 % colour of the specified size. It is mainly used for producing box
728 % backgrounds.
730 % The definition here works by selecting a colour, and then drawing a
731 % \TeX\ rule (unless |\ifcolors@false|). This allows the `driver
732 % independent' colour specials to be used. However it is defined using
733 % |\providecommand|, so that this file will not over-write any other
734 % definition of this command. A graphics package may want to define it
735 % using a special to produce (for example) a PostScript line. Producing
736 % the line in the |\special| has the advantage that on a preview that
737 % does not understand |\special|s, the line is automatically omited,
738 % without needing to modify the source of the document (for instance by
739 % adding the |monochrome| option).
741 %    \begin{macrocode}
742 \def\color@block#1#2#3{%
743   {\set@color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}}
744 %    \end{macrocode}
745 % \end{macro}
747 % \subsection{Coloured Boxes}
749 % \begin{macro}{\colorbox}
750 % |\colorbox| takes the same argument forms as |\textcolor|, but the
751 % colour specifies the \emph{background} colour of the box.
752 % \changes{v0.3b}{1994/09/14}
753 %                {New implementation}
754 %    \begin{macrocode}
755 \def\colorbox#1#{\color@box{#1}}
756 %    \end{macrocode}
757 % \end{macro}
759 % \changes{v0.3i}{1995/04/27}
760 %                {Move \cs{leavevmode} for graphics/1521}
761 % \begin{macro}{\color@box}
762 %    \begin{macrocode}
763 \def\color@box#1#2{\color@b@x\relax{\color#1{#2}}}
764 %    \end{macrocode}
765 % \end{macro}
767 % \begin{macro}{\fcolorbox}
768 % |\fcolorbox| has an extra \emph{colour-spec} argument, and puts a
769 % frame of the first colour around a box with a background specified by
770 % the second colour. If an optional argument is given, it specifies the
771 % colour model for both colours.
772 % \changes{v0.3b}{1994/09/14}
773 %                {New implementation}
774 % \begin{macro}{\fcolorbox}
775 %    \begin{macrocode}
776 \def\fcolorbox#1#{\color@fbox{#1}}
777 %    \end{macrocode}
779 %    \begin{macrocode}
780 \def\color@fbox#1#2#3{%
781   \color@b@x{\fboxsep\z@\color#1{#2}\fbox}{\color#1{#3}}}
782 %    \end{macrocode}
783 % \end{macro}
784 % \end{macro}
787 %  \begin{macro}{\color@b@x}
788 % Internal macro for |\colorbox| and |\fcolorbox|.
789 % \changes{v0.3b}{1994/09/14}
790 %                {Macro added.}
791 % \changes{v0.3i}{1995/04/27}
792 %                {Add \cs{leavevmode} for graphics/1521}
793 %    \begin{macrocode}
794 \long\def\color@b@x#1#2#3{%
795  \leavevmode
796  \setbox\z@\hbox{\kern\fboxsep{\set@color#3}\kern\fboxsep}%
797  \dimen@\ht\z@\advance\dimen@\fboxsep\ht\z@\dimen@
798  \dimen@\dp\z@\advance\dimen@\fboxsep\dp\z@\dimen@
799  {#1{#2\color@block{\wd\z@}{\ht\z@}{\dp\z@}%
800       \box\z@}}}
801 %    \end{macrocode}
802 %  \end{macro}
805 % \section{Extra Groups}
806 % Turning on extra groups in the standard \LaTeX\ commands, so that
807 % colour commands are scoped correctly.
809 % Like |\normalcolor|, the following five commands are defined in the
810 % kernel, with empty definitions (|\relax|). This means that they can
811 % be used to make macros in packages `colour safe'. The commands
812 % will not have any effect unless a user also uses this colour
813 % package, when the `active definitions' here will take effect and
814 % keep colour commands correctly scoped.
816 % \begin{macro}{\color@setgroup}
817 % This is to be used in contexts (eg `lrbox') where text is to be
818 % saved and used after some other, unknown, text that may contain
819 % colour commands. A matching |\color@endgroup| should be used at the
820 % end of the text.
821 % \changes{v0.2d}{1994/05/13}
822 %     {Macro added}
823 %    \begin{macrocode}
824 \def\color@setgroup{\begingroup\set@color}
825 %    \end{macrocode}
826 %  \end{macro}
828 %  \begin{macro}{\color@begingroup}
829 % This is to be used at the start of contexts that may contain colour
830 % commands, but where it is not necessary to save the current colour.
831 % Examples of this are in the box commands of |ltboxes.dtx| where
832 % user-supplied text is saved internally in a box between
833 % |\color@begingroup|, |\color@endgroup|, but the box is used before
834 % any other colour commands could intervene. A matching
835 % |\color@endgroup| should be used at the  end of the text.
836 % \changes{v0.2d}{1994/05/13}
837 %     {New definition, was previously like \cs{color@setgroup}}
838 %    \begin{macrocode}
839 \let\color@begingroup\begingroup
840 %    \end{macrocode}
841 %  \end{macro}
843 %  \begin{macro}{\color@endgroup}
844 % To be used to close the `group' started by one of the above two
845 % commands. The |\endgraf| in its definition is required in the case
846 % of groups of text in vertical `par' mode, but doesn't do any harm in
847 % horizontal `LR' contexts.
848 % \changes{v0.2d}{1994/05/13}
849 %     {New definition, was previously just \cs{endgroup}}
850 %    \begin{macrocode}
851 \def\color@endgroup{\endgraf\endgroup}
852 %    \end{macrocode}
853 %  \end{macro}
855 %  \begin{macro}{\color@hbox}
856 % To be used to open a `coloured hbox'
857 % \changes{v0.3g}{1994/11/08}
858 %     {Macro added}
859 %    \begin{macrocode}
860 \def\color@hbox{\hbox\bgroup\color@begingroup}
861 %    \end{macrocode}
862 %  \end{macro}
864 %  \begin{macro}{\color@vbox}
865 % To be used to open a `coloured hbox'
866 % \changes{v0.3h}{1994/11/22}
867 %     {Macro added}
868 %    \begin{macrocode}
869 \def\color@vbox{\vbox\bgroup\color@begingroup}
870 %    \end{macrocode}
871 %  \end{macro}
873 %  \begin{macro}{\color@endbox}
874 % To be used to close a `coloured hbox'
875 % \changes{v0.3g}{1994/11/08}
876 %     {Macro added}
877 %    \begin{macrocode}
878 \def\color@endbox{\color@endgroup\egroup}
879 %    \end{macrocode}
880 %  \end{macro}
883 % \changes{v0.2d}{1994/05/13}
884 %     {tabbing support removed (now in kernel)}
886 % \changes{v0.3l}{1995/12/07}
887 %      {\cs{underbar} removed (now in kernel)}
889 % \changes{v0.3h}{1994/11/22}
890 %     {marginpar, phantom and smash now supported in kernel}
892 % \changes{v0.3l}{1995/12/07}
893 %      {\cs{showhyphens} removed (now in kernel)}
896 % \section{Predefining Colours}
898 % As long as the driver file has defined sufficient colour models, we
899 % define a few colours, just to get people started.
901 % \begin{macro}{black}
902 % \begin{macro}{white}
903 % Black and white `colours'.
904 %    \begin{macrocode}
905 \ifx\color@gray\@undefined
906   \ifx\color@rgb\@undefined
907   \else
908     \definecolor{black}{rgb}{0,0,0}
909     \definecolor{white}{rgb}{1,1,1}
910   \fi
911 \else
912   \definecolor{black}{gray}{0}
913   \definecolor{white}{gray}{1}
915 %    \end{macrocode}
916 % \end{macro}
917 % \end{macro}
919 % \begin{macro}{red}
920 % \begin{macro}{green}
921 % \begin{macro}{blue}
922 % Additive primaries.
923 %    \begin{macrocode}
924 \ifx\color@rgb\@undefined\else
925   \definecolor{red}{rgb}{1,0,0}
926   \definecolor{green}{rgb}{0,1,0}
927   \definecolor{blue}{rgb}{0,0,1}
929 %    \end{macrocode}
930 % \end{macro}
931 % \end{macro}
932 % \end{macro}
934 % \begin{macro}{cyan}
935 % \begin{macro}{magenta}
936 % \begin{macro}{yellow}
937 % Subtractive primaries.
938 %    \begin{macrocode}
939 \ifx\color@cmyk\@undefined\else
940   \definecolor{cyan}{cmyk}{1,0,0,0}
941   \definecolor{magenta}{cmyk}{0,1,0,0}
942   \definecolor{yellow}{cmyk}{0,0,1,0}
944 %    \end{macrocode}
946 %    \begin{macrocode}
947 %</package>
948 %    \end{macrocode}
949 % \end{macro}
950 % \end{macro}
951 % \end{macro}
954 % \section{And Finally}
956 % Restore Catcodes
957 %    \begin{macrocode}
958 \Gin@codes
959 \let\Gin@codes\relax
960 %    \end{macrocode}
962 % \Finale