4 %% color.dtx Copyright (C) 1994--1999 David Carlisle
5 %% Copyright (C) 2005--2015 David Carlisle, LaTeX3 Project
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".
15 \ProvidesFile{color.dtx}
17 %<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
18 %<package>\ProvidesPackage{color}
19 %<driver> \ProvidesFile{color.drv}
21 % \ProvidesFile{color.dtx}
22 [2016/01/03 v1.1b Standard LaTeX Color (DPC)]
26 \documentclass{ltxdoc}
27 \newenvironment{option}[1]{\expandafter\macro\expandafter{%
28 \csname ds@#1\endcsname}}{\endmacro}
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}
42 % \MaintainedByLaTeXTeam{graphics}
48 % \title{The implementation of the \LaTeX\ Colour interface.}
50 % \section{Introduction}
51 % This package implements \LaTeX\ support for colour, for those
52 % \texttt{dvi} drivers that can produce coloured text.
54 % The user level documentation of this package is contained in the
55 % document \emph{Packages in the `graphics' bundle} in the file
56 % \texttt{grfguide.tex}.
63 % \changes{v0.2a}{1994/04/13}
64 % {TEMP KLUDGE for Feb 94 release of 2e:
66 % \changes{v0.2d}{1994/05/13}
67 % {All support for Feb 1994 release removed (so used optional arg
68 % of \cs{NeedsTeXFormat}).}
69 % \changes{v1.0}{1996/05/29}
76 % First we save the catcodes of some characters, and set them to
77 % fixed values whilst this file is being read.
78 % \changes{v0.3b}{1994/09/14}
79 % {Save and restore catcodes}
82 \catcode`\noexpand\^^A\the\catcode`\^^A\relax
83 \catcode`\noexpand\"\the\catcode`\"\relax
84 \catcode`\noexpand\*\the\catcode`\*\relax
85 \catcode`\noexpand\!\the\catcode`\!\relax
86 \catcode`\noexpand\:\the\catcode`\:\relax}
87 \catcode`\^^A=\catcode`\%
94 % \begin{macro}{\Gin@driver}
95 % Initialize the macro to hold the driver file name.
97 \providecommand\Gin@driver{}
101 % \begin{macro}{\c@lor@error}
102 % \changes{v1.0d}{1997/01/07}
103 % {Macro added for graphics/2350}
104 % Helper macro for error handling (redefined by the monochrome option
105 % to make errors warnings).
108 \@latex@error{Undefined color #1}\@ehd}
112 % \begin{option}{monochrome}
113 % The |monochrome| option should be used \emph{in addition}
114 % to one of the standard driver options.
115 % \changes{v0.3j}{1995/06/16}
116 % {Use single hash for latex/1557}
117 % \changes{v1.0b}{1996/10/29}
118 % {Add \cs{colors@false}}
119 % \changes{v1.0d}{1997/01/07}
120 % {Add \cs{c@lor@error} for graphics/2350}
122 \DeclareOption{monochrome}{%
123 \def\c@lor@error#1{\PackageInfo{color}{Undefined color #1}}%
128 {color push \current@color}\aftergroup\reset@color}%
129 \def\reset@color{\c@lor@special\m@ne{color pop}}%
130 \def\set@page@color{%
131 \c@lor@special\m@ne{background \current@color}}%
132 \def\define@color#1#2{%
133 \c@lor@special\m@ne{define #1 #2}}}}
137 % \begin{option}{debugshow}
138 % The |debugshow| option turns on debugging info (perhaps).
139 % \changes{v1.0a}{1996/09/16}
140 % {debugshow option added}
142 \DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
146 % Now the options for supported drivers.
148 % \begin{option}{dvips}
149 % \begin{option}{xdvi}
150 % Tom Rokicki's dvips driver, and the X Windows previewer, xdvi which uses
151 % (a subset of) the same |\specials|.
153 \DeclareOption{dvips}{\def\Gin@driver{dvips.def}%
154 \def\c@lor@namefile{dvipsnam.def}}
155 \DeclareOption{xdvi}{\ExecuteOptions{dvips,monochrome}}
160 % \begin{option}{dvipdf}
161 % \changes{v1.0c}{1996/10/31}
163 % Sergey Lesenko's dvipdf driver.
165 \DeclareOption{dvipdf}{\def\Gin@driver{dvipdf.def}}
169 % \begin{option}{dvipdfm}
170 % \changes{v1.0h}{1999/01/13}
172 % Mark Wick's dvipdfm driver.
174 \DeclareOption{dvipdfm}{\def\Gin@driver{dvipdfm.def}}
178 % \begin{option}{dvipdfmx}
179 % \changes{v1.0j}{2005/11/14}
181 % The driver for the dvipdfmx project.
183 \DeclareOption{dvipdfmx}{\def\Gin@driver{dvipdfmx.def}}
187 % \begin{option}{pdftex}
188 % \changes{v1.0e}{1997/06/07}
190 % Han The Thanh's \TeX\ variant.
192 \DeclareOption{pdftex}{\def\Gin@driver{pdftex.def}}
196 % \begin{option}{luatex}
197 % \changes{v1.1b}{2016/01/03}
199 % Lua\TeX\ \TeX\ variant.
201 \DeclareOption{luatex}{\def\Gin@driver{luatex.def}}
205 % \begin{option}{xetex}
206 % \changes{v1.0j}{2005/11/14}
208 % Jonathan Kew's \TeX\ variant.
210 \DeclareOption{xetex}{\def\Gin@driver{xetex.def}}
214 % \begin{option}{dvipsone}
215 % \begin{option}{dviwindo}
216 % \changes{v0.3k}{1995/09/07}
217 % {Merge dviwindo and dvipsone options}
218 % The drivers of the Y\&Y \TeX\ system.
219 % (Which use the same |\specials|).
221 \DeclareOption{dvipsone}{\def\Gin@driver{dvipsone.def}}
222 \DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
227 % \begin{option}{emtex}
228 % \begin{option}{dviwin}
229 % Freely available drivers for PCs.
231 \DeclareOption{emtex}{\def\Gin@driver{emtex.def}}
232 \DeclareOption{dviwin}{\def\Gin@driver{dviwin.def}}
237 % \begin{option}{oztex}
238 % \changes{v1.0f}{1997/09/09}
239 % {Merge dvips and oztex options}
240 % The Oz\TeX\ system for a Macintosh.
241 % Since release 3 of Oz\TeX, merge with dvips back end.
243 \DeclareOption{oztex}{\ExecuteOptions{dvips}}
247 % \begin{option}{textures}
248 % Blue sky's Textures system on a Macintosh.
250 \DeclareOption{textures}{\def\Gin@driver{textures.def}}
254 % \begin{option}{pctexps}
255 % \begin{option}{pctexwin}
256 % \begin{option}{pctexhp}
257 % \begin{option}{pctex32}
258 % \changes{v1.0b}{1996/10/29}
259 % {pctex32 option added}
260 % The drivers for PTI's \TeX\ system on PCs.
262 \DeclareOption{pctexps}{\def\Gin@driver{pctexps.def}}
263 \DeclareOption{pctexwin}{\def\Gin@driver{pctexwin.def}}
264 \DeclareOption{pctexhp}{\def\Gin@driver{pctexhp.def}}
265 \DeclareOption{pctex32}{\def\Gin@driver{pctex32.def}}
272 % \begin{option}{truetex}
273 % \begin{option}{tcidvi}
274 % \changes{v1.0b}{1996/10/29}
275 % {truetex and tcidvi options added}
276 % The drivers of the Kinch \TeX\ system on PCs, and its
277 % version with extra |\special| handling dll's as shipped with
278 % TCI's Scientific Word.
280 \DeclareOption{truetex}{\def\Gin@driver{truetex.def}}
281 \DeclareOption{tcidvi}{\def\Gin@driver{tcidvi.def}}
286 % \begin{option}{vtex}
287 % \changes{v1.0g}{1998/05/27}
288 % {vtex option added}
291 \DeclareOption{vtex}{\def\Gin@driver{vtex.def}}
295 % \begin{option}{dvi2ps}
296 % \begin{option}{dvialw}
297 % \begin{option}{dvilaser}
298 % \begin{option}{dvitops}
299 % \begin{option}{psprint}
300 % \begin{option}{pubps}
302 % \changes{v1.0b}{1996/10/29}
303 % {old driver options depreciated}
304 % Old, probably obsolete, drivers commented out. See the section
305 % on `Driver support' in grfguide to see how to re-enable these
306 % options in |color.cfg| if you need them.
308 %\DeclareOption{dvi2ps}{\def\Gin@driver{dvi2ps.def}}
309 %\DeclareOption{dvialw}{\def\Gin@driver{dvialw.def}}
310 %\DeclareOption{dvilaser}{\def\Gin@driver{dvilaser.def}}
311 %\DeclareOption{dvitops}{\def\Gin@driver{dvitops.def}}
312 %\DeclareOption{psprint}{\def\Gin@driver{psprint.def}}
313 %\DeclareOption{pubps}{\def\Gin@driver{pubps.def}}
314 %\DeclareOption{ln}{\def\Gin@driver{ln.def}}
325 % \begin{option}{dvipsnames}
326 % \begin{option}{nodvipsnames}
327 % By default the named colour model has no pre-declared names.
328 % The |dvipsnames| option predeclares all the names in the colour
329 % prologue of dvips. The |dvips| option automatically implies
330 % |dvipsnames| unless this choice is overruled with the |nodvipsnames|
331 % option. For other drivers, eg |textures| you may use this option to
332 % explicitly request that these names be declared.
334 \DeclareOption{dvipsnames}{\def\c@lor@namefile{dvipsnam.def}}
335 \DeclareOption{nodvipsnames}{\let\c@lor@namefile\relax}
340 % \begin{option}{usenames}
341 % The |usenames| option modifies the behaviour of |\DefineNamedColor|
342 % So that it declares the same name as a ```user's colour'' for use in
343 % a |\color| command, as well as a name in the |named| colour model.
344 % The normal behaviour is just to declare the name in the named colour
347 \let\c@lor@usename\@gobble
351 \DeclareOption{usenames}{%
352 \def\c@lor@usename#1{%
353 \expandafter\color@named\csname\string\color @#1\endcsname{#1}}}
357 % \section{Using Colours}
359 % \subsection{Declarative form}
361 % \begin{macro}{\color}
362 % |\color{|\emph{declared-colour}|}| switches to the colour
363 % \emph{declared-colour}, which must previously have been defined
364 % using |\definecolor|. This colour will stay in effect until the end of
365 % the current \TeX\ group.
367 % |\color[|\emph{model}|]{|\emph{colour-specification}|}| is similar
368 % to the above, but uses a colour not declared by |\definecolor|. The
369 % allowed \emph{model}'s vary depending on the driver. The syntax of
370 % the \emph{colour-specification} argument depends on the model.
372 % \changes{v0.3a}{1994/07/20}
373 % {Make \cs{color} robust}
375 \DeclareRobustCommand\color{%
376 \@ifnextchar[\@undeclaredcolor\@declaredcolor}
380 % \begin{macro}{\@undeclaredcolor}
381 % \changes{v0.2c}{1994/05/09}
382 % {Improve error messages}
383 % \changes{v0.3a}{1994/07/20}
384 % {New internal implementation of colour commands}
385 % Call the driver-dependent command |\color@|\meta{model} to define
386 % |\current@color|, then call |\set@color| to change the current colour
389 \def\@undeclaredcolor[#1]#2{%
390 \@ifundefined{color@#1}%
391 {\c@lor@error{model `#1'}}%
392 {\csname color@#1\endcsname\current@color{#2}%
398 % \begin{macro}{\@declaredcolor}%
399 % \changes{v0.1c}{1994/04/01}
400 % {Add \cs{ignorespaces}}
401 % \changes{v0.1e}{1994/05/14}
402 % {Minor change to error message}
403 % \changes{v0.3a}{1994/07/20}
404 % {New internal implementation of colour commands}
405 % |\let| |\current@color| to the internal representation of the colour
406 % if the colour has been declared, otherwise generate an error.
407 % Finally call |\set@color| to effect the colour change.
409 \def\@declaredcolor#1{%
410 \@ifundefined{\string\color @#1}%
411 {\c@lor@error{`#1'}}%
412 {\expandafter\let\expandafter\current@color
413 \csname\string\color @#1\endcsname
419 % \subsection{Command (Argument) Form}
421 % \begin{macro}{\textcolor}
422 % |\textcolor{|\emph{declared-colour}|}{|\emph{text}|}| and
423 % |\textcolor[|\emph{model}|]{|\emph{colour-spec}|}{|\emph{text}|}|
424 % are just alternative syntax for |\color|, in
425 % which the groups are added implicitly. Thus \emph{text} appears in the
426 % specified colour, but then the colour reverts to its previous value.
427 % The naming is by analogy with |\textrm| (as opposed to |\rm| and
428 % |\rmfamily|) although it is slightly a misnomer as the command also
429 % works in math-mode.
431 % Since December 95, in fact this command has one other difference
432 % from |\color|. It calls |\leavevmode| to ensure the start of
433 % horizontal mode. Specifically this means that a construction
436 % xxx\parbox[t]{1cm}{\textcolor{red}{a}.....
438 % now works as expected, with the |xxx| and the red |a| lining up
440 % \changes{v0.3a}{1994/07/20}
441 % {Stop command being \cs{long}, and make robust.}
442 % \changes{v0.3l}{1995/12/07}
443 % {Add \cs{leavevmode}}
445 \def\textcolor#1#{\@textcolor{#1}}
446 \def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
450 % \subsection{Background (Page) Colour}
452 % \begin{macro}{\pagecolor}
453 % |\pagecolor|, which has the same argument forms as |\color|, specifies
454 % the background colour for the current, and all following, pages. It is
455 % a global declaration which does not respect \TeX\ groups.
457 % \changes{v0.1c}{1994/04/01}
458 % {end the group even if the colour command generates an error}
459 % \changes{v0.3c}{1994/09/19}
460 % {Use \cs{color} to parse arguments}
464 \let\ignorespaces\endgroup
465 \let\set@color\set@page@color
470 % \begin{macro}{\nopagecolor}
471 % |\nopagecolor| (suggested by Heiko Oberdiek) removes any currently specified page colour
472 % returning to the default transparent background. It is not yet supported by all driver options
473 % and so generates a warning if there is no definition in the driver file.
475 % \changes{v1.1a}{2014/04/23}
476 % {add \cs{nopagecolor} graphics/3873}
479 \@ifundefined{no@page@color}{%
480 \PackageInfo{color}{\string\nopagecolor\space is not supported}%
489 % \section{Defining Colours}
491 % \begin{macro}{\definecolor}
492 % |\definecolor{|\emph{name}|}{|\emph{model}|}{|\emph{colour-spec}|}|
493 % defines the color \emph{name}, which may then be used in subsequent
494 % |\color| or |\textcolor| commands to refer to a colour specified by
495 % \emph{colour-spec} in the colour model \emph{model}.
497 % |\definecolor| associates the \emph{name} the to a colour in
498 % \emph{model}. So |\color{|\emph{name}|}| would check \emph{name}
499 % then issue a |\special| for the colour model \emph{model}.
501 % |\definecolor| just calls an internal macro that defines the colour
502 % for a particular model. This macro must have been defined by the
503 % driver file that supports the requested \emph{model}.
505 % \changes{v0.1b}{1994/03/15}
506 % {change name from \cs{newcolor} to \cs{definecolor}}
507 % \changes{v0.1e}{1994/05/14}
508 % {Minor change to error message}
509 % \changes{v0.3a}{1994/07/20}
510 % {New internal implementation of colour commands}
511 % \changes{v0.3f}{1994/10/04}
512 % {Give info about redefinitions}
514 \def\definecolor#1#2#3{%
515 \@ifundefined{color@#2}%
516 {\c@lor@error{model `#2'}}%
517 {\@ifundefined{\string\color @#1}{}%
518 {\PackageInfo{color}{Redefining color #1}}%
519 \csname color@#2\expandafter\endcsname
520 \csname\string\color @#1\endcsname{#3}}}
525 % \begin{macro}{\DefineNamedColor}
526 % \changes{v0.3d}{1994/09/29}
528 % \changes{v0.3e}{1994/10/03}
529 % {usenames option added}
530 % \changes{v0.3f}{1994/10/04}
531 % {Give info about redefinitions}
533 % Driver files may opt to define a `named' colour model.
534 % Placing colour names rather than numeric specifications into the dvi
535 % file has certain advantages, in that post processing software can
536 % tune the colour specifications to the particular technology being
537 % used, and more easily make colour separations for that colour.
538 % The disadvantage is that the driver must `know' the colour
541 % The `color1' drivers (dvips) currently ignore the specification of
542 % the colour, and once a name is defined, just put the colour name in
543 % the dvi file. For dvips, The header file \texttt{color.pro} is used to
544 % give the cmyk equivalents of the names.
546 % The `color2' drivers (textures) use a special postscript operator
547 % that takes both the name and the cmyk equivalent. so if the names are
548 % not being used, `fall back' definitions in the cmyk model are available.
549 % These drivers also allow a numeric value to affect the `density'
550 % of the colour to use.
552 % Drivers based on `color3' do not support named colours at the dvi
553 % level, but to ease document portability, the named model is still
554 % defined, but the |\special|'s just put the colour specifications, not
555 % the names, into the dvi file.
557 % Normally after a colour, say |JungleGreen|, has been declared with:\\
558 % |\DefineNamedColor{named}{JungleGreen}{cmyk}{1,2,3,4}|\\
559 % it is available in the `named' colour model, for
561 % |\color[named]{JungleGreen}|\\
562 % A user may give a more convenient name, using\\
563 % |\definecolor{mygreen}{named}{JungleGreen}|\\
564 % If however you are happy with the original names, and want to use
565 % them directly, as in |\color{JungleGreen}| without specifying
566 % |[named]| all the time, just give the package option |usenames|, which
567 % will redefine |\DefineNamedColor|, so that the colour name is declared
568 % as a user-colour as well as a name in the `named' model.
570 \def\DefineNamedColor#1#2#3#4{%
571 \@ifundefined{define@color@#1}%
572 {\c@lor@error{model `#1'}}%
573 {\@ifundefined{color@#3}%
574 {\c@lor@error{model `#3'}}%
575 {\@ifundefined{c@lor@#1@#2}{}%
576 {\PackageInfo{color}{Redefining color #2 in named color model}}%
577 \csname color@#3\endcsname\@tempa{#4}%
578 \csname define@color@#1\endcsname{#2}\@tempa
579 \c@lor@usename{#2}}}}
580 \@onlypreamble\DefineNamedColor
584 % \section{Colour Switch}
586 % \begin{macro}{\ifcolors@}
587 % This boolean can be tested by higher level macros that may want to
588 % alter their behaviour if a monochrome driver is being used.
595 % \section{Whatsit\ldots}
597 % \begin{macro}{\c@lor@special}
598 % Some drivers can not support all the features of this package. They
599 % should always put a \meta{whatsit} in the current list though. The
600 % following macro has most of the features of |\special|, but does not
601 % put anything into the |dvi| file. It does write to the log file or the
602 % terminal (depending on the value of |#1|).
604 \def\c@lor@special#1#2{%
605 \edef\@tempa{\write#1{#2}}\@tempa}
609 % \section{Processing Options}
611 % A local configuration file may declare more options.
612 % It should also make one driver option the default, by calling
613 % |\ExecuteOptions| with the appropriate option.
615 \InputIfFileExists{color.cfg}{}{}
618 % After the options are processed, load the appropriate driver file.
619 % If a site wants a default driver (eg |dvips|) it just needs to put
620 % |\ExecuteOptions{dvips}| in a |color.cfg| file.
621 % \changes{v0.3b}{1994/09/14}
622 % {New style of loading driver files}
630 {No driver specified}
631 {You should make a default driver option in a file \MessageBreak
632 color.cfg\MessageBreak
633 eg: \protect\ExecuteOptions{dvips}%
636 \PackageInfo{color}{Driver file: \Gin@driver}
637 \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
642 \@ifundefined{c@lor@namefile}{}{\input{\c@lor@namefile}}
645 % \section{Default Colour}
647 % \begin{macro}{\normalcolor}
648 % Early versions of this package redefined |\reset@font| to reset the
649 % color as well. Current versions do not do this (there are too many
650 % |\reset@font| commands hidden in strange places) and so defines a
651 % separate command, |\normalcolor| to reset the colour to the colour in
652 % effect at the start of the document.
654 % |\normalcolor| is defined (to |\relax|) in the \LaTeX\ kernel, so it
655 % is safe to use this in macros that may possibly be used in
656 % conjunction with colour. It will have no effect until the |color|
657 % package is also loaded.
658 % \changes{v0.2b}{1994/04/18}
659 % {Only reset the colour with \cmd{\reset@font} not
661 % \changes{v0.2d}{1994/05/13}
662 % {Stop changing \cs{reset@font}. Use the new \cs{normalfont}
665 \def\normalcolor{\let\current@color\default@color\set@color}
669 % \begin{macro}{\default@color}
670 % Internal macro to store the `default' colour used by |\normalcolor|.
672 \AtBeginDocument{\let\default@color\current@color}
676 % |\current@color| contains an internal representation of the colour
677 % at this point in the document. (This can only be an approximation to
678 % the truth as the `macro layer' of \TeX\ does not know where the output
679 % routine is going to re-insert floats. This is why drivers must
680 % maintain their own stack of colours in order to fully support these
683 % For dvips, the |\current@color| it is something like `|Black|' or
684 % `|rgb 0 1 0|', but other packages should not rely on any particular
685 % format for this macro.
687 % The driver file \emph{must} initialise |\current@color| to a
688 % specification for Black. This initialisation can not occur here, as
689 % the possible colour models (and thus the syntax for `black')
690 % are not known at this point.
692 % \section{Higher Level Commands}
694 % With the basic colour primitives specified above we may define a few
695 % higher level commands for coloured boxes etc. This is still quite a low
696 % level and presumably packages and classes making use of colour will
697 % define more appropriate document-level commands.
699 % \subsection{Colour Block}
701 % \begin{macro}{\color@block}
702 % |\color@block{|\emph{width}|}{|\emph{height}|}{|\emph{depth}|}|\\
703 % Should take up no space for \TeX, but produce a block in the current
704 % colour of the specified size. It is mainly used for producing box
707 % The definition here works by selecting a colour, and then drawing a
708 % \TeX\ rule (unless |\ifcolors@false|). This allows the `driver
709 % independent' colour specials to be used. However it is defined using
710 % |\providecommand|, so that this file will not over-write any other
711 % definition of this command. A graphics package may want to define it
712 % using a special to produce (for example) a PostScript line. Producing
713 % the line in the |\special| has the advantage that on a preview that
714 % does not understand |\special|s, the line is automatically omited,
715 % without needing to modify the source of the document (for instance by
716 % adding the |monochrome| option).
719 \def\color@block#1#2#3{%
720 {\set@color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}}
724 % \subsection{Coloured Boxes}
726 % \begin{macro}{\colorbox}
727 % |\colorbox| takes the same argument forms as |\textcolor|, but the
728 % colour specifies the \emph{background} colour of the box.
729 % \changes{v0.3b}{1994/09/14}
730 % {New implementation}
732 \def\colorbox#1#{\color@box{#1}}
736 % \changes{v0.3i}{1995/04/27}
737 % {Move \cs{leavevmode} for graphics/1521}
738 % \begin{macro}{\color@box}
740 \def\color@box#1#2{\color@b@x\relax{\color#1{#2}}}
744 % \begin{macro}{\fcolorbox}
745 % |\fcolorbox| has an extra \emph{colour-spec} argument, and puts a
746 % frame of the first colour around a box with a background specified by
747 % the second colour. If an optional argument is given, it specifies the
748 % colour model for both colours.
749 % \changes{v0.3b}{1994/09/14}
750 % {New implementation}
751 % \begin{macro}{\fcolorbox}
753 \def\fcolorbox#1#{\color@fbox{#1}}
757 \def\color@fbox#1#2#3{%
758 \color@b@x{\fboxsep\z@\color#1{#2}\fbox}{\color#1{#3}}}
764 % \begin{macro}{\color@b@x}
765 % Internal macro for |\colorbox| and |\fcolorbox|.
766 % \changes{v0.3b}{1994/09/14}
768 % \changes{v0.3i}{1995/04/27}
769 % {Add \cs{leavevmode} for graphics/1521}
771 \long\def\color@b@x#1#2#3{%
773 \setbox\z@\hbox{\kern\fboxsep{\set@color#3}\kern\fboxsep}%
774 \dimen@\ht\z@\advance\dimen@\fboxsep\ht\z@\dimen@
775 \dimen@\dp\z@\advance\dimen@\fboxsep\dp\z@\dimen@
776 {#1{#2\color@block{\wd\z@}{\ht\z@}{\dp\z@}%
782 % \section{Extra Groups}
783 % Turning on extra groups in the standard \LaTeX\ commands, so that
784 % colour commands are scoped correctly.
786 % Like |\normalcolor|, the following five commands are defined in the
787 % kernel, with empty definitions (|\relax|). This means that they can
788 % be used to make macros in packages `colour safe'. The commands
789 % will not have any effect unless a user also uses this colour
790 % package, when the `active definitions' here will take effect and
791 % keep colour commands correctly scoped.
793 % \begin{macro}{\color@setgroup}
794 % This is to be used in contexts (eg `lrbox') where text is to be
795 % saved and used after some other, unknown, text that may contain
796 % colour commands. A matching |\color@endgroup| should be used at the
798 % \changes{v0.2d}{1994/05/13}
801 \def\color@setgroup{\begingroup\set@color}
805 % \begin{macro}{\color@begingroup}
806 % This is to be used at the start of contexts that may contain colour
807 % commands, but where it is not necessary to save the current colour.
808 % Examples of this are in the box commands of |ltboxes.dtx| where
809 % user-supplied text is saved internally in a box between
810 % |\color@begingroup|, |\color@endgroup|, but the box is used before
811 % any other colour commands could intervene. A matching
812 % |\color@endgroup| should be used at the end of the text.
813 % \changes{v0.2d}{1994/05/13}
814 % {New definition, was previously like \cs{color@setgroup}}
816 \let\color@begingroup\begingroup
820 % \begin{macro}{\color@endgroup}
821 % To be used to close the `group' started by one of the above two
822 % commands. The |\endgraf| in its definition is required in the case
823 % of groups of text in vertical `par' mode, but doesn't do any harm in
824 % horizontal `LR' contexts.
825 % \changes{v0.2d}{1994/05/13}
826 % {New definition, was previously just \cs{endgroup}}
828 \def\color@endgroup{\endgraf\endgroup}
832 % \begin{macro}{\color@hbox}
833 % To be used to open a `coloured hbox'
834 % \changes{v0.3g}{1994/11/08}
837 \def\color@hbox{\hbox\bgroup\color@begingroup}
841 % \begin{macro}{\color@vbox}
842 % To be used to open a `coloured hbox'
843 % \changes{v0.3h}{1994/11/22}
846 \def\color@vbox{\vbox\bgroup\color@begingroup}
850 % \begin{macro}{\color@endbox}
851 % To be used to close a `coloured hbox'
852 % \changes{v0.3g}{1994/11/08}
855 \def\color@endbox{\color@endgroup\egroup}
860 % \changes{v0.2d}{1994/05/13}
861 % {tabbing support removed (now in kernel)}
863 % \changes{v0.3l}{1995/12/07}
864 % {\cs{underbar} removed (now in kernel)}
866 % \changes{v0.3h}{1994/11/22}
867 % {marginpar, phantom and smash now supported in kernel}
869 % \changes{v0.3l}{1995/12/07}
870 % {\cs{showhyphens} removed (now in kernel)}
873 % \section{Predefining Colours}
875 % As long as the driver file has defined sufficient colour models, we
876 % define a few colours, just to get people started.
878 % \begin{macro}{black}
879 % \begin{macro}{white}
880 % Black and white `colours'.
882 \ifx\color@gray\@undefined
883 \ifx\color@rgb\@undefined
885 \definecolor{black}{rgb}{0,0,0}
886 \definecolor{white}{rgb}{1,1,1}
889 \definecolor{black}{gray}{0}
890 \definecolor{white}{gray}{1}
897 % \begin{macro}{green}
898 % \begin{macro}{blue}
899 % Additive primaries.
901 \ifx\color@rgb\@undefined\else
902 \definecolor{red}{rgb}{1,0,0}
903 \definecolor{green}{rgb}{0,1,0}
904 \definecolor{blue}{rgb}{0,0,1}
911 % \begin{macro}{cyan}
912 % \begin{macro}{magenta}
913 % \begin{macro}{yellow}
914 % Subtractive primaries.
916 \ifx\color@cmyk\@undefined\else
917 \definecolor{cyan}{cmyk}{1,0,0,0}
918 \definecolor{magenta}{cmyk}{0,1,0,0}
919 \definecolor{yellow}{cmyk}{0,0,1,0}
931 % \section{And Finally}