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 [2014/10/28 v1.1a 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}{xetex}
197 % \changes{v1.0j}{2005/11/14}
199 % Jonathan Kew's \TeX\ variant.
201 \DeclareOption{xetex}{\def\Gin@driver{xetex.def}}
205 % \begin{option}{dvipsone}
206 % \begin{option}{dviwindo}
207 % \changes{v0.3k}{1995/09/07}
208 % {Merge dviwindo and dvipsone options}
209 % The drivers of the Y\&Y \TeX\ system.
210 % (Which use the same |\specials|).
212 \DeclareOption{dvipsone}{\def\Gin@driver{dvipsone.def}}
213 \DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
218 % \begin{option}{emtex}
219 % \begin{option}{dviwin}
220 % Freely available drivers for PCs.
222 \DeclareOption{emtex}{\def\Gin@driver{emtex.def}}
223 \DeclareOption{dviwin}{\def\Gin@driver{dviwin.def}}
228 % \begin{option}{oztex}
229 % \changes{v1.0f}{1997/09/09}
230 % {Merge dvips and oztex options}
231 % The Oz\TeX\ system for a Macintosh.
232 % Since release 3 of Oz\TeX, merge with dvips back end.
234 \DeclareOption{oztex}{\ExecuteOptions{dvips}}
238 % \begin{option}{textures}
239 % Blue sky's Textures system on a Macintosh.
241 \DeclareOption{textures}{\def\Gin@driver{textures.def}}
245 % \begin{option}{pctexps}
246 % \begin{option}{pctexwin}
247 % \begin{option}{pctexhp}
248 % \begin{option}{pctex32}
249 % \changes{v1.0b}{1996/10/29}
250 % {pctex32 option added}
251 % The drivers for PTI's \TeX\ system on PCs.
253 \DeclareOption{pctexps}{\def\Gin@driver{pctexps.def}}
254 \DeclareOption{pctexwin}{\def\Gin@driver{pctexwin.def}}
255 \DeclareOption{pctexhp}{\def\Gin@driver{pctexhp.def}}
256 \DeclareOption{pctex32}{\def\Gin@driver{pctex32.def}}
263 % \begin{option}{truetex}
264 % \begin{option}{tcidvi}
265 % \changes{v1.0b}{1996/10/29}
266 % {truetex and tcidvi options added}
267 % The drivers of the Kinch \TeX\ system on PCs, and its
268 % version with extra |\special| handling dll's as shipped with
269 % TCI's Scientific Word.
271 \DeclareOption{truetex}{\def\Gin@driver{truetex.def}}
272 \DeclareOption{tcidvi}{\def\Gin@driver{tcidvi.def}}
277 % \begin{option}{vtex}
278 % \changes{v1.0g}{1998/05/27}
279 % {vtex option added}
282 \DeclareOption{vtex}{\def\Gin@driver{vtex.def}}
286 % \begin{option}{dvi2ps}
287 % \begin{option}{dvialw}
288 % \begin{option}{dvilaser}
289 % \begin{option}{dvitops}
290 % \begin{option}{psprint}
291 % \begin{option}{pubps}
293 % \changes{v1.0b}{1996/10/29}
294 % {old driver options depreciated}
295 % Old, probably obsolete, drivers commented out. See the section
296 % on `Driver support' in grfguide to see how to re-enable these
297 % options in |color.cfg| if you need them.
299 %\DeclareOption{dvi2ps}{\def\Gin@driver{dvi2ps.def}}
300 %\DeclareOption{dvialw}{\def\Gin@driver{dvialw.def}}
301 %\DeclareOption{dvilaser}{\def\Gin@driver{dvilaser.def}}
302 %\DeclareOption{dvitops}{\def\Gin@driver{dvitops.def}}
303 %\DeclareOption{psprint}{\def\Gin@driver{psprint.def}}
304 %\DeclareOption{pubps}{\def\Gin@driver{pubps.def}}
305 %\DeclareOption{ln}{\def\Gin@driver{ln.def}}
316 % \begin{option}{dvipsnames}
317 % \begin{option}{nodvipsnames}
318 % By default the named colour model has no pre-declared names.
319 % The |dvipsnames| option predeclares all the names in the colour
320 % prologue of dvips. The |dvips| option automatically implies
321 % |dvipsnames| unless this choice is overruled with the |nodvipsnames|
322 % option. For other drivers, eg |textures| you may use this option to
323 % explicitly request that these names be declared.
325 \DeclareOption{dvipsnames}{\def\c@lor@namefile{dvipsnam.def}}
326 \DeclareOption{nodvipsnames}{\let\c@lor@namefile\relax}
331 % \begin{option}{usenames}
332 % The |usenames| option modifies the behaviour of |\DefineNamedColor|
333 % So that it declares the same name as a ```user's colour'' for use in
334 % a |\color| command, as well as a name in the |named| colour model.
335 % The normal behaviour is just to declare the name in the named colour
338 \let\c@lor@usename\@gobble
342 \DeclareOption{usenames}{%
343 \def\c@lor@usename#1{%
344 \expandafter\color@named\csname\string\color @#1\endcsname{#1}}}
348 % \section{Using Colours}
350 % \subsection{Declarative form}
352 % \begin{macro}{\color}
353 % |\color{|\emph{declared-colour}|}| switches to the colour
354 % \emph{declared-colour}, which must previously have been defined
355 % using |\definecolor|. This colour will stay in effect until the end of
356 % the current \TeX\ group.
358 % |\color[|\emph{model}|]{|\emph{colour-specification}|}| is similar
359 % to the above, but uses a colour not declared by |\definecolor|. The
360 % allowed \emph{model}'s vary depending on the driver. The syntax of
361 % the \emph{colour-specification} argument depends on the model.
363 % \changes{v0.3a}{1994/07/20}
364 % {Make \cs{color} robust}
366 \DeclareRobustCommand\color{%
367 \@ifnextchar[\@undeclaredcolor\@declaredcolor}
371 % \begin{macro}{\@undeclaredcolor}
372 % \changes{v0.2c}{1994/05/09}
373 % {Improve error messages}
374 % \changes{v0.3a}{1994/07/20}
375 % {New internal implementation of colour commands}
376 % Call the driver-dependent command |\color@|\meta{model} to define
377 % |\current@color|, then call |\set@color| to change the current colour
380 \def\@undeclaredcolor[#1]#2{%
381 \@ifundefined{color@#1}%
382 {\c@lor@error{model `#1'}}%
383 {\csname color@#1\endcsname\current@color{#2}%
389 % \begin{macro}{\@declaredcolor}%
390 % \changes{v0.1c}{1994/04/01}
391 % {Add \cs{ignorespaces}}
392 % \changes{v0.1e}{1994/05/14}
393 % {Minor change to error message}
394 % \changes{v0.3a}{1994/07/20}
395 % {New internal implementation of colour commands}
396 % |\let| |\current@color| to the internal representation of the colour
397 % if the colour has been declared, otherwise generate an error.
398 % Finally call |\set@color| to effect the colour change.
400 \def\@declaredcolor#1{%
401 \@ifundefined{\string\color @#1}%
402 {\c@lor@error{`#1'}}%
403 {\expandafter\let\expandafter\current@color
404 \csname\string\color @#1\endcsname
410 % \subsection{Command (Argument) Form}
412 % \begin{macro}{\textcolor}
413 % |\textcolor{|\emph{declared-colour}|}{|\emph{text}|}| and
414 % |\textcolor[|\emph{model}|]{|\emph{colour-spec}|}{|\emph{text}|}|
415 % are just alternative syntax for |\color|, in
416 % which the groups are added implicitly. Thus \emph{text} appears in the
417 % specified colour, but then the colour reverts to its previous value.
418 % The naming is by analogy with |\textrm| (as opposed to |\rm| and
419 % |\rmfamily|) although it is slightly a misnomer as the command also
420 % works in math-mode.
422 % Since December 95, in fact this command has one other difference
423 % from |\color|. It calls |\leavevmode| to ensure the start of
424 % horizontal mode. Specifically this means that a construction
427 % xxx\parbox[t]{1cm}{\textcolor{red}{a}.....
429 % now works as expected, with the |xxx| and the red |a| lining up
431 % \changes{v0.3a}{1994/07/20}
432 % {Stop command being \cs{long}, and make robust.}
433 % \changes{v0.3l}{1995/12/07}
434 % {Add \cs{leavevmode}}
436 \def\textcolor#1#{\@textcolor{#1}}
437 \def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
441 % \subsection{Background (Page) Colour}
443 % \begin{macro}{\pagecolor}
444 % |\pagecolor|, which has the same argument forms as |\color|, specifies
445 % the background colour for the current, and all following, pages. It is
446 % a global declaration which does not respect \TeX\ groups.
448 % \changes{v0.1c}{1994/04/01}
449 % {end the group even if the colour command generates an error}
450 % \changes{v0.3c}{1994/09/19}
451 % {Use \cs{color} to parse arguments}
455 \let\ignorespaces\endgroup
456 \let\set@color\set@page@color
461 % \begin{macro}{\nopagecolor}
462 % |\nopagecolor| (suggested by Heiko Oberdiek) removes any currently specified page colour
463 % returning to the default transparent background. It is not yet supported by all driver options
464 % and so generates a warning if there is no definition in the driver file.
466 % \changes{v1.1a}{2014/04/23}
467 % {add \cs{nopagecolor} graphics/3873}
470 \@ifundefined{no@page@color}{%
471 \PackageInfo{color}{\string\nopagecolor\space is not supported}%
480 % \section{Defining Colours}
482 % \begin{macro}{\definecolor}
483 % |\definecolor{|\emph{name}|}{|\emph{model}|}{|\emph{colour-spec}|}|
484 % defines the color \emph{name}, which may then be used in subsequent
485 % |\color| or |\textcolor| commands to refer to a colour specified by
486 % \emph{colour-spec} in the colour model \emph{model}.
488 % |\definecolor| associates the \emph{name} the to a colour in
489 % \emph{model}. So |\color{|\emph{name}|}| would check \emph{name}
490 % then issue a |\special| for the colour model \emph{model}.
492 % |\definecolor| just calls an internal macro that defines the colour
493 % for a particular model. This macro must have been defined by the
494 % driver file that supports the requested \emph{model}.
496 % \changes{v0.1b}{1994/03/15}
497 % {change name from \cs{newcolor} to \cs{definecolor}}
498 % \changes{v0.1e}{1994/05/14}
499 % {Minor change to error message}
500 % \changes{v0.3a}{1994/07/20}
501 % {New internal implementation of colour commands}
502 % \changes{v0.3f}{1994/10/04}
503 % {Give info about redefinitions}
505 \def\definecolor#1#2#3{%
506 \@ifundefined{color@#2}%
507 {\c@lor@error{model `#2'}}%
508 {\@ifundefined{\string\color @#1}{}%
509 {\PackageInfo{color}{Redefining color #1}}%
510 \csname color@#2\expandafter\endcsname
511 \csname\string\color @#1\endcsname{#3}}}
516 % \begin{macro}{\DefineNamedColor}
517 % \changes{v0.3d}{1994/09/29}
519 % \changes{v0.3e}{1994/10/03}
520 % {usenames option added}
521 % \changes{v0.3f}{1994/10/04}
522 % {Give info about redefinitions}
524 % Driver files may opt to define a `named' colour model.
525 % Placing colour names rather than numeric specifications into the dvi
526 % file has certain advantages, in that post processing software can
527 % tune the colour specifications to the particular technology being
528 % used, and more easily make colour separations for that colour.
529 % The disadvantage is that the driver must `know' the colour
532 % The `color1' drivers (dvips) currently ignore the specification of
533 % the colour, and once a name is defined, just put the colour name in
534 % the dvi file. For dvips, The header file \texttt{color.pro} is used to
535 % give the cmyk equivalents of the names.
537 % The `color2' drivers (textures) use a special postscript operator
538 % that takes both the name and the cmyk equivalent. so if the names are
539 % not being used, `fall back' definitions in the cmyk model are available.
540 % These drivers also allow a numeric value to affect the `density'
541 % of the colour to use.
543 % Drivers based on `color3' do not support named colours at the dvi
544 % level, but to ease document portability, the named model is still
545 % defined, but the |\special|'s just put the colour specifications, not
546 % the names, into the dvi file.
548 % Normally after a colour, say |JungleGreen|, has been declared with:\\
549 % |\DefineNamedColor{named}{JungleGreen}{cmyk}{1,2,3,4}|\\
550 % it is available in the `named' colour model, for
552 % |\color[named]{JungleGreen}|\\
553 % A user may give a more convenient name, using\\
554 % |\definecolor{mygreen}{named}{JungleGreen}|\\
555 % If however you are happy with the original names, and want to use
556 % them directly, as in |\color{JungleGreen}| without specifying
557 % |[named]| all the time, just give the package option |usenames|, which
558 % will redefine |\DefineNamedColor|, so that the colour name is declared
559 % as a user-colour as well as a name in the `named' model.
561 \def\DefineNamedColor#1#2#3#4{%
562 \@ifundefined{define@color@#1}%
563 {\c@lor@error{model `#1'}}%
564 {\@ifundefined{color@#3}%
565 {\c@lor@error{model `#3'}}%
566 {\@ifundefined{c@lor@#1@#2}{}%
567 {\PackageInfo{color}{Redefining color #2 in named color model}}%
568 \csname color@#3\endcsname\@tempa{#4}%
569 \csname define@color@#1\endcsname{#2}\@tempa
570 \c@lor@usename{#2}}}}
571 \@onlypreamble\DefineNamedColor
575 % \section{Colour Switch}
577 % \begin{macro}{\ifcolors@}
578 % This boolean can be tested by higher level macros that may want to
579 % alter their behaviour if a monochrome driver is being used.
586 % \section{Whatsit\ldots}
588 % \begin{macro}{\c@lor@special}
589 % Some drivers can not support all the features of this package. They
590 % should always put a \meta{whatsit} in the current list though. The
591 % following macro has most of the features of |\special|, but does not
592 % put anything into the |dvi| file. It does write to the log file or the
593 % terminal (depending on the value of |#1|).
595 \def\c@lor@special#1#2{%
596 \edef\@tempa{\write#1{#2}}\@tempa}
600 % \section{Processing Options}
602 % A local configuration file may declare more options.
603 % It should also make one driver option the default, by calling
604 % |\ExecuteOptions| with the appropriate option.
606 \InputIfFileExists{color.cfg}{}{}
609 % After the options are processed, load the appropriate driver file.
610 % If a site wants a default driver (eg |dvips|) it just needs to put
611 % |\ExecuteOptions{dvips}| in a |color.cfg| file.
612 % \changes{v0.3b}{1994/09/14}
613 % {New style of loading driver files}
621 {No driver specified}
622 {You should make a default driver option in a file \MessageBreak
623 color.cfg\MessageBreak
624 eg: \protect\ExecuteOptions{dvips}%
627 \PackageInfo{color}{Driver file: \Gin@driver}
628 \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
633 \@ifundefined{c@lor@namefile}{}{\input{\c@lor@namefile}}
636 % \section{Default Colour}
638 % \begin{macro}{\normalcolor}
639 % Early versions of this package redefined |\reset@font| to reset the
640 % color as well. Current versions do not do this (there are too many
641 % |\reset@font| commands hidden in strange places) and so defines a
642 % separate command, |\normalcolor| to reset the colour to the colour in
643 % effect at the start of the document.
645 % |\normalcolor| is defined (to |\relax|) in the \LaTeX\ kernel, so it
646 % is safe to use this in macros that may possibly be used in
647 % conjunction with colour. It will have no effect until the |color|
648 % package is also loaded.
649 % \changes{v0.2b}{1994/04/18}
650 % {Only reset the colour with \cmd{\reset@font} not
652 % \changes{v0.2d}{1994/05/13}
653 % {Stop changing \cs{reset@font}. Use the new \cs{normalfont}
656 \def\normalcolor{\let\current@color\default@color\set@color}
660 % \begin{macro}{\default@color}
661 % Internal macro to store the `default' colour used by |\normalcolor|.
663 \AtBeginDocument{\let\default@color\current@color}
667 % |\current@color| contains an internal representation of the colour
668 % at this point in the document. (This can only be an approximation to
669 % the truth as the `macro layer' of \TeX\ does not know where the output
670 % routine is going to re-insert floats. This is why drivers must
671 % maintain their own stack of colours in order to fully support these
674 % For dvips, the |\current@color| it is something like `|Black|' or
675 % `|rgb 0 1 0|', but other packages should not rely on any particular
676 % format for this macro.
678 % The driver file \emph{must} initialise |\current@color| to a
679 % specification for Black. This initialisation can not occur here, as
680 % the possible colour models (and thus the syntax for `black')
681 % are not known at this point.
683 % \section{Higher Level Commands}
685 % With the basic colour primitives specified above we may define a few
686 % higher level commands for coloured boxes etc. This is still quite a low
687 % level and presumably packages and classes making use of colour will
688 % define more appropriate document-level commands.
690 % \subsection{Colour Block}
692 % \begin{macro}{\color@block}
693 % |\color@block{|\emph{width}|}{|\emph{height}|}{|\emph{depth}|}|\\
694 % Should take up no space for \TeX, but produce a block in the current
695 % colour of the specified size. It is mainly used for producing box
698 % The definition here works by selecting a colour, and then drawing a
699 % \TeX\ rule (unless |\ifcolors@false|). This allows the `driver
700 % independent' colour specials to be used. However it is defined using
701 % |\providecommand|, so that this file will not over-write any other
702 % definition of this command. A graphics package may want to define it
703 % using a special to produce (for example) a PostScript line. Producing
704 % the line in the |\special| has the advantage that on a preview that
705 % does not understand |\special|s, the line is automatically omited,
706 % without needing to modify the source of the document (for instance by
707 % adding the |monochrome| option).
710 \def\color@block#1#2#3{%
711 {\set@color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}}
715 % \subsection{Coloured Boxes}
717 % \begin{macro}{\colorbox}
718 % |\colorbox| takes the same argument forms as |\textcolor|, but the
719 % colour specifies the \emph{background} colour of the box.
720 % \changes{v0.3b}{1994/09/14}
721 % {New implementation}
723 \def\colorbox#1#{\color@box{#1}}
727 % \changes{v0.3i}{1995/04/27}
728 % {Move \cs{leavevmode} for graphics/1521}
729 % \begin{macro}{\color@box}
731 \def\color@box#1#2{\color@b@x\relax{\color#1{#2}}}
735 % \begin{macro}{\fcolorbox}
736 % |\fcolorbox| has an extra \emph{colour-spec} argument, and puts a
737 % frame of the first colour around a box with a background specified by
738 % the second colour. If an optional argument is given, it specifies the
739 % colour model for both colours.
740 % \changes{v0.3b}{1994/09/14}
741 % {New implementation}
742 % \begin{macro}{\fcolorbox}
744 \def\fcolorbox#1#{\color@fbox{#1}}
748 \def\color@fbox#1#2#3{%
749 \color@b@x{\fboxsep\z@\color#1{#2}\fbox}{\color#1{#3}}}
755 % \begin{macro}{\color@b@x}
756 % Internal macro for |\colorbox| and |\fcolorbox|.
757 % \changes{v0.3b}{1994/09/14}
759 % \changes{v0.3i}{1995/04/27}
760 % {Add \cs{leavevmode} for graphics/1521}
762 \long\def\color@b@x#1#2#3{%
764 \setbox\z@\hbox{\kern\fboxsep{\set@color#3}\kern\fboxsep}%
765 \dimen@\ht\z@\advance\dimen@\fboxsep\ht\z@\dimen@
766 \dimen@\dp\z@\advance\dimen@\fboxsep\dp\z@\dimen@
767 {#1{#2\color@block{\wd\z@}{\ht\z@}{\dp\z@}%
773 % \section{Extra Groups}
774 % Turning on extra groups in the standard \LaTeX\ commands, so that
775 % colour commands are scoped correctly.
777 % Like |\normalcolor|, the following five commands are defined in the
778 % kernel, with empty definitions (|\relax|). This means that they can
779 % be used to make macros in packages `colour safe'. The commands
780 % will not have any effect unless a user also uses this colour
781 % package, when the `active definitions' here will take effect and
782 % keep colour commands correctly scoped.
784 % \begin{macro}{\color@setgroup}
785 % This is to be used in contexts (eg `lrbox') where text is to be
786 % saved and used after some other, unknown, text that may contain
787 % colour commands. A matching |\color@endgroup| should be used at the
789 % \changes{v0.2d}{1994/05/13}
792 \def\color@setgroup{\begingroup\set@color}
796 % \begin{macro}{\color@begingroup}
797 % This is to be used at the start of contexts that may contain colour
798 % commands, but where it is not necessary to save the current colour.
799 % Examples of this are in the box commands of |ltboxes.dtx| where
800 % user-supplied text is saved internally in a box between
801 % |\color@begingroup|, |\color@endgroup|, but the box is used before
802 % any other colour commands could intervene. A matching
803 % |\color@endgroup| should be used at the end of the text.
804 % \changes{v0.2d}{1994/05/13}
805 % {New definition, was previously like \cs{color@setgroup}}
807 \let\color@begingroup\begingroup
811 % \begin{macro}{\color@endgroup}
812 % To be used to close the `group' started by one of the above two
813 % commands. The |\endgraf| in its definition is required in the case
814 % of groups of text in vertical `par' mode, but doesn't do any harm in
815 % horizontal `LR' contexts.
816 % \changes{v0.2d}{1994/05/13}
817 % {New definition, was previously just \cs{endgroup}}
819 \def\color@endgroup{\endgraf\endgroup}
823 % \begin{macro}{\color@hbox}
824 % To be used to open a `coloured hbox'
825 % \changes{v0.3g}{1994/11/08}
828 \def\color@hbox{\hbox\bgroup\color@begingroup}
832 % \begin{macro}{\color@vbox}
833 % To be used to open a `coloured hbox'
834 % \changes{v0.3h}{1994/11/22}
837 \def\color@vbox{\vbox\bgroup\color@begingroup}
841 % \begin{macro}{\color@endbox}
842 % To be used to close a `coloured hbox'
843 % \changes{v0.3g}{1994/11/08}
846 \def\color@endbox{\color@endgroup\egroup}
851 % \changes{v0.2d}{1994/05/13}
852 % {tabbing support removed (now in kernel)}
854 % \changes{v0.3l}{1995/12/07}
855 % {\cs{underbar} removed (now in kernel)}
857 % \changes{v0.3h}{1994/11/22}
858 % {marginpar, phantom and smash now supported in kernel}
860 % \changes{v0.3l}{1995/12/07}
861 % {\cs{showhyphens} removed (now in kernel)}
864 % \section{Predefining Colours}
866 % As long as the driver file has defined sufficient colour models, we
867 % define a few colours, just to get people started.
869 % \begin{macro}{black}
870 % \begin{macro}{white}
871 % Black and white `colours'.
873 \ifx\color@gray\@undefined
874 \ifx\color@rgb\@undefined
876 \definecolor{black}{rgb}{0,0,0}
877 \definecolor{white}{rgb}{1,1,1}
880 \definecolor{black}{gray}{0}
881 \definecolor{white}{gray}{1}
888 % \begin{macro}{green}
889 % \begin{macro}{blue}
890 % Additive primaries.
892 \ifx\color@rgb\@undefined\else
893 \definecolor{red}{rgb}{1,0,0}
894 \definecolor{green}{rgb}{0,1,0}
895 \definecolor{blue}{rgb}{0,0,1}
902 % \begin{macro}{cyan}
903 % \begin{macro}{magenta}
904 % \begin{macro}{yellow}
905 % Subtractive primaries.
907 \ifx\color@cmyk\@undefined\else
908 \definecolor{cyan}{cmyk}{1,0,0,0}
909 \definecolor{magenta}{cmyk}{0,1,0,0}
910 \definecolor{yellow}{cmyk}{0,0,1,0}
922 % \section{And Finally}