4 %% color.dtx Copyright (C) 1994--1999 David Carlisle
5 %% Copyright (C) 2005--2016 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/07/10 v1.1e 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}
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}.
62 % \changes{v0.2a}{1994/04/13}
63 % {TEMP KLUDGE for Feb 94 release of 2e:
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}
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}
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`\%
93 % \begin{macro}{\Gin@driver}
94 % Initialize the macro to hold the driver file name.
96 \providecommand\Gin@driver{}
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).
107 \@latex@error{Undefined color #1}\@ehd}
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}
121 \DeclareOption{monochrome}{%
122 \def\c@lor@error#1{\PackageInfo{color}{Undefined color #1}}%
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}}}}
136 % \begin{option}{debugshow}
137 % The |debugshow| option turns on debugging info (perhaps).
138 % \changes{v1.0a}{1996/09/16}
139 % {debugshow option added}
141 \DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
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.)
153 \newif\ifGin@setpagesize\Gin@setpagesizetrue
154 \DeclareOption{setpagesize}{\Gin@setpagesizetrue}
155 \DeclareOption{nosetpagesize}{\Gin@setpagesizefalse}
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|.
167 \DeclareOption{dvips}{\def\Gin@driver{dvips.def}%
168 \def\c@lor@namefile{dvipsnam.def}}
169 \DeclareOption{xdvi}{\ExecuteOptions{dvips,monochrome}}
174 % \begin{option}{dvipdf}
175 % \changes{v1.0c}{1996/10/31}
177 % Sergey Lesenko's dvipdf driver.
179 \DeclareOption{dvipdf}{\def\Gin@driver{dvipdf.def}}
183 % \begin{option}{dvipdfm}
184 % \changes{v1.0h}{1999/01/13}
186 % Mark Wick's dvipdfm driver.
188 \DeclareOption{dvipdfm}{\def\Gin@driver{dvipdfm.def}}
192 % \begin{option}{dvipdfmx}
193 % \changes{v1.0j}{2005/11/14}
195 % The driver for the dvipdfmx project.
197 \DeclareOption{dvipdfmx}{\def\Gin@driver{dvipdfmx.def}}
201 % \begin{option}{pdftex}
202 % \changes{v1.0e}{1997/06/07}
204 % Han The Thanh's \TeX\ variant.
206 \DeclareOption{pdftex}{\def\Gin@driver{pdftex.def}}
210 % \begin{option}{luatex}
211 % \changes{v1.1b}{2016/01/03}
213 % Lua\TeX\ \TeX\ variant.
215 \DeclareOption{luatex}{\def\Gin@driver{luatex.def}}
219 % \begin{option}{luatex}
220 % \changes{v1.1c}{2016/05/09}
224 \DeclareOption{dvisvgm}{\def\Gin@driver{dvisvgm.def}}
228 % \begin{option}{xetex}
229 % \changes{v1.0j}{2005/11/14}
231 % Jonathan Kew's \TeX\ variant.
233 \DeclareOption{xetex}{\def\Gin@driver{xetex.def}}
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|).
244 \DeclareOption{dvipsone}{\def\Gin@driver{dvipsone.def}}
245 \DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
250 % \begin{option}{emtex}
251 % \begin{option}{dviwin}
252 % Freely available drivers for PCs.
254 \DeclareOption{emtex}{\def\Gin@driver{emtex.def}}
255 \DeclareOption{dviwin}{\def\Gin@driver{dviwin.def}}
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.
266 \DeclareOption{oztex}{\ExecuteOptions{dvips}}
270 % \begin{option}{textures}
271 % Blue sky's Textures system on a Macintosh.
273 \DeclareOption{textures}{\def\Gin@driver{textures.def}}
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.
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}}
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.
303 \DeclareOption{truetex}{\def\Gin@driver{truetex.def}}
304 \DeclareOption{tcidvi}{\def\Gin@driver{tcidvi.def}}
309 % \begin{option}{vtex}
310 % \changes{v1.0g}{1998/05/27}
311 % {vtex option added}
314 \DeclareOption{vtex}{\def\Gin@driver{vtex.def}}
318 % \begin{option}{dvi2ps}
319 % \begin{option}{dvialw}
320 % \begin{option}{dvilaser}
321 % \begin{option}{dvitops}
322 % \begin{option}{psprint}
323 % \begin{option}{pubps}
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.
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}}
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.
357 \DeclareOption{dvipsnames}{\def\c@lor@namefile{dvipsnam.def}}
358 \DeclareOption{nodvipsnames}{\let\c@lor@namefile\relax}
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
370 \let\c@lor@usename\@gobble
374 \DeclareOption{usenames}{%
375 \def\c@lor@usename#1{%
376 \expandafter\color@named\csname\string\color @#1\endcsname{#1}}}
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}
398 \DeclareRobustCommand\color{%
399 \@ifnextchar[\@undeclaredcolor\@declaredcolor}
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
412 \def\@undeclaredcolor[#1]#2{%
413 \@ifundefined{color@#1}%
414 {\c@lor@error{model `#1'}}%
415 {\csname color@#1\endcsname\current@color{#2}%
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.
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
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
459 % xxx\parbox[t]{1cm}{\textcolor{red}{a}.....
461 % now works as expected, with the |xxx| and the red |a| lining up
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}}
468 \def\textcolor#1#{\@textcolor{#1}}
469 \def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
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}
487 \let\ignorespaces\endgroup
488 \let\set@color\set@page@color
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}
502 \@ifundefined{no@page@color}{%
503 \PackageInfo{color}{\string\nopagecolor\space is not supported}%
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}
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}}}
548 % \begin{macro}{\DefineNamedColor}
549 % \changes{v0.3d}{1994/09/29}
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
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
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.
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
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.
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|).
627 \def\c@lor@special#1#2{%
628 \edef\@tempa{\write#1{#2}}\@tempa}
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.
638 \InputIfFileExists{color.cfg}{}{}
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}
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}%
659 \PackageInfo{color}{Driver file: \Gin@driver}
660 \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
665 \@ifundefined{c@lor@namefile}{}{\input{\c@lor@namefile}}
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
684 % \changes{v0.2d}{1994/05/13}
685 % {Stop changing \cs{reset@font}. Use the new \cs{normalfont}
688 \def\normalcolor{\let\current@color\default@color\set@color}
692 % \begin{macro}{\default@color}
693 % Internal macro to store the `default' colour used by |\normalcolor|.
695 \AtBeginDocument{\let\default@color\current@color}
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
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
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).
742 \def\color@block#1#2#3{%
743 {\set@color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}}
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}
755 \def\colorbox#1#{\color@box{#1}}
759 % \changes{v0.3i}{1995/04/27}
760 % {Move \cs{leavevmode} for graphics/1521}
761 % \begin{macro}{\color@box}
763 \def\color@box#1#2{\color@b@x\relax{\color#1{#2}}}
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}
776 \def\fcolorbox#1#{\color@fbox{#1}}
780 \def\color@fbox#1#2#3{%
781 \color@b@x{\fboxsep\z@\color#1{#2}\fbox}{\color#1{#3}}}
787 % \begin{macro}{\color@b@x}
788 % Internal macro for |\colorbox| and |\fcolorbox|.
789 % \changes{v0.3b}{1994/09/14}
791 % \changes{v0.3i}{1995/04/27}
792 % {Add \cs{leavevmode} for graphics/1521}
794 \long\def\color@b@x#1#2#3{%
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@}%
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
821 % \changes{v0.2d}{1994/05/13}
824 \def\color@setgroup{\begingroup\set@color}
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}}
839 \let\color@begingroup\begingroup
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}}
851 \def\color@endgroup{\endgraf\endgroup}
855 % \begin{macro}{\color@hbox}
856 % To be used to open a `coloured hbox'
857 % \changes{v0.3g}{1994/11/08}
860 \def\color@hbox{\hbox\bgroup\color@begingroup}
864 % \begin{macro}{\color@vbox}
865 % To be used to open a `coloured hbox'
866 % \changes{v0.3h}{1994/11/22}
869 \def\color@vbox{\vbox\bgroup\color@begingroup}
873 % \begin{macro}{\color@endbox}
874 % To be used to close a `coloured hbox'
875 % \changes{v0.3g}{1994/11/08}
878 \def\color@endbox{\color@endgroup\egroup}
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'.
905 \ifx\color@gray\@undefined
906 \ifx\color@rgb\@undefined
908 \definecolor{black}{rgb}{0,0,0}
909 \definecolor{white}{rgb}{1,1,1}
912 \definecolor{black}{gray}{0}
913 \definecolor{white}{gray}{1}
920 % \begin{macro}{green}
921 % \begin{macro}{blue}
922 % Additive primaries.
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}
934 % \begin{macro}{cyan}
935 % \begin{macro}{magenta}
936 % \begin{macro}{yellow}
937 % Subtractive primaries.
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}
954 % \section{And Finally}