% \iffalse meta-comment
%%
%% ---------------------------------------------------------
%% Copyright (C) 2003-2004 by Dr. Uwe Kern <xcolor@ukern.de>
%% ---------------------------------------------------------
%%
%% Please send error reports and suggestions for
%% improvements to the above email address.
%%
%<*package>
%% This package contains code copied from
%%
%% color.dtx [1999/02/16 v1.0i Standard LaTeX Color (DPC)]
%% Copyright (C) 1994--1999 David Carlisle
%%
%% which is part of the Standard LaTeX `Graphics Bundle'.
%</package>
%%
% \fi
\def\XCfilesource{xcolor.dtx}%
\def\XCfileversion{v2.00}%
\def\XCfiledate{2004/07/04}%
%
% \iffalse meta-comment
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.
%
% \fi
%
% \CheckSum{3654}
%
% \DoNotIndex{\def,\gdef,\edef,\xdef,\long,\let}
% \DoNotIndex{\if,\ifnum,\ifdim,\ifcat,\ifmmode,\ifvmode,\ifhmode}
% \DoNotIndex{\iftrue,\iffalse,\ifvoid,\ifx,\ifeof,\ifcase,\else,\or,\fi}
% \DoNotIndex{\hbox,\vbox,\setbox,\sbox,\box,\copy,\unhbox,\unvbox,\wd,\ht,\dp}
% \DoNotIndex{\immediate,\write,\openin,\openout,\closein,\closeout}
% \DoNotIndex{\bgroup,\egroup,\begingroup,\endgroup,\begin,\end}
% \DoNotIndex{\relax,\space,\endinput}
% \DoNotIndex{\csname,\endcsname,\string,\the,\noexpand,\expandafter}
% \DoNotIndex{\hsize,\hskip,\hfil,\hfill,\hss,\vfil,\vfill,\vss,\kern,\unskip}
% \DoNotIndex{\vsize,\vskip,\vfil,\vfill,\vss}
% \DoNotIndex{\advance,\divide,\multiply,\count,\dimen}
% \DoNotIndex{\m@ne,\z@,\z@skip,\@ne,\tw@,\p@,\@spaces}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \iffalse
%<*batchfile>
\IfFileExists{xcolor.ins}{\let\uknext=\relax}{\let\uknext=\stop}
\begin{filecontents*}{xcolor.ins}
%% Package `xcolor' by Dr. Uwe Kern
%%
%% Extract all package files:
%%   `latex xcolor.ins'
%%
%% Create the documentation:
%%   `latex xcolor.dtx'
%%   `latex xcolor.dtx'
%%   `makeindex -s gind.ist xcolor.idx'
%%   `latex xcolor.dtx'
%%   `latex xcolor.dtx'
%%
%% Run the test files (N=1,2,...):
%%   `latex xcolorN.tex'
%%   `latex xcolorN.tex'
%%
\def\batchfile{xcolor.ins}
\input docstrip.tex
\askforoverwritefalse
\generate{\file{xcolor.lox}{\from{xcolor.dtx}{extract}}}
\batchinput{xcolor.lox}
\endbatchfile
\end{filecontents*}
%</batchfile>
%
%<*driver>
\listfiles
\let\XCfileDate\XCfiledate
\let\XCfileVersion\XCfileversion
\ProvidesFile{xcolor.dtx}[\XCfileDate\space\XCfileVersion\space
                          `xcolor' source and documentation (UK)]
\documentclass{ltxdoc}
\usepackage[table,showerrors,dvipsnames,hyperref]{xcolor}[2004/07/04]
%\usepackage[frenchb]{babel}
\usepackage{chngpage,varioref,tabularx,amsmath,amsthm}
\usepackage
 [\GinDriver,hyperindex=false,bookmarks,bookmarksopen,bookmarksopenlevel=1,%
  pdftitle={xcolor \XCfileVersion{} (\XCfileDate)},pdfauthor={Dr. Uwe Kern},%
  pdfsubject={Color extensions for LaTeX and pdfLaTeX},%
  pdfkeywords={xcolor,color,colour,model,tint,tone,shade,latex,%
   conversion,mask,separation,rgb,cmy,cmyk,hsb,gray,html}]{hyperref}
\OnlyDescription
\EnableCrossrefs
\RecordChanges
\CodelineIndex
\makeatletter
\def\Meaning#1{\texttt{\expandafter\expandafter\expandafter\strip@prefix\expandafter\meaning\csname #1\endcsname}}
\makeatother
\begin{document}
 \DocInput{xcolor.dtx}
 \let\Section\section\def\section*#1{\Section*{#1}\addcontentsline{toc}{section}{#1}}
 \PrintChanges\PrintIndex
\end{document}
%</driver>
%
%<*extract>
\generate{
\file{xcolor.sty}{\from{\XCfilesource}{package}}
\file{svgnam.def}{\from{\XCfilesource}{svgnames}}
\file{xcolor1.tex}{\from{\XCfilesource}{test1}}
\file{xcolor2.tex}{\from{\XCfilesource}{test2}}
\file{xcolor3.tex}{\from{\XCfilesource}{test3}}
}
%</extract>
% \fi
%
%
%
% \iffalse
%-------------------------------------------------------------------------------
% \fi
%
%
% \makeatletter
%
% \newcommand*\XCchanges[3]
%  {\edef\@@tmp
%    {200\ifcase#2#3 3/09/09\or 3/09/15\or 3/09/19\or 3/09/21\or 3/11/09\or 3/11/21\or 3/12/15\or 4/01/20\or 4/02/04\or
%     4/02/16\or 4/03/10\fi}\edef\@@tmp{\noexpand\changes{\@@tmp{} v#1.#2#3}{\@@tmp}}\@@tmp}
% \def\XCchanges#1#2#3#4{}
% \def\testclr#1#{\@testclr{#1}}
% \def\@testclr#1#2{{\fboxsep\z@\fbox{\colorbox#1{#2}{\phantom{XX}}}}}
% \def\Testclr#1{\testclr{#1}~\rlap{\Color{#1}}\endgraf}
% \newcommand*\ShowColor[1]{\fcolorbox{black}{#1}{\phantom{000}}}
% \newcommand\TestColorRow[1]%
%  {#1: &
%   \ShowColor{\theColor!#1} &
%   \ShowColor{\theColor!#1!gray} &
%   \ShowColor{\theColor!#1!black} &
%   \ShowColor{\theColor!#1!red} &
%   \ShowColor{\theColor!#1!blue} &
%   \ShowColor{\theColor!#1!yellow} &
%   \ShowColor{-\theColor!#1} &
%   \ShowColor{-\theColor!#1!black} &
%   \ShowColor{-\theColor!#1!yellow} \\}
% \newcommand\TestColor[1]%
%  {\begin{figure}\caption{Color example: #1}\label{fig.#1}
%   \bigskip\small
%   \expandafter\let\expandafter\xtmp\csname \string\color@#1\endcsname
%   \edef\xtmp{\expandafter\@gobble\xtmp}
%   \centering
%   Definition of base color:\endgraf
%   \Meaning{xtmp}\endgraf\bigskip
%   \def\theColor{#1}
%   \begin{tabular}{@{}r*9{c}@{}}
%   \em P/C &
%   \makebox[0pt]{\Color{white}\footnotemark[1]}&
%   \makebox[0pt]{\Color{gray}\footnotemark[1]}&
%   \makebox[0pt]{\Color{black}\footnotemark[1]}&
%   \makebox[0pt]{\Color{red}\footnotemark[1]}&
%   \makebox[0pt]{\Color{blue}\footnotemark[1]}&
%   \makebox[0pt]{\Color{yellow}\footnotemark[1]}&
%   \makebox[0pt]{\Color{white}\footnotemark[2]}&
%   \makebox[0pt]{\Color{black}\footnotemark[2]}&
%   \makebox[0pt]{\Color{yellow}\footnotemark[2]}\\
%   \TestColorRow{100} \TestColorRow{90} \TestColorRow{80} \TestColorRow{70}
%   \TestColorRow{60}  \TestColorRow{50} \TestColorRow{40} \TestColorRow{30}
%   \TestColorRow{20}  \TestColorRow{10} \TestColorRow{0}
%   \noalign{\medskip}
%   &\multicolumn{9}{l}%
%    {\footnotemark[1]\cmd\color\texttt{\{#1!\emph P!\emph C\}}\hfill
%     \footnotemark[2]\cmd\color\texttt{\{-#1!\emph P!\emph C\}}}\\
%   \end{tabular}
%   \end{figure}}
%
% \newif\if@Meta
% \DeclareRobustCommand*\Meta{\@ifstar{\@Metatrue\@Meta}{\@Metafalse\@Meta}}
% \newcommand*\@Meta[2][]{\meta{#2}\@ifxempty{#1}{}{\ensuremath{\mskip-1mu\rule[-.4ex]{0pt}{1ex}_{#1}}}\if@Meta\index{arguments\levelchar\meta{#2}\string|usage}\fi}
% \def\DescribeArg#1{\leavevmode\@bsphack\marginpar{\raggedleft\Meta*{#1}}\@esphack\ignorespaces}
%
% \makeatother
%
% \def\Index#1{#1\index{#1\string|usage}}
% \def\Package#1{\textsf{#1}\index{packages\levelchar\textsf{#1}\string|usage}}
% \def\Model#1{\textsf{\bfseries#1}\index{color models\levelchar\textsf{\bfseries#1}\string|usage}}
% \def\nModel#1{`#1'\index{color models\levelchar`#1'\string|usage}}
% \newcommand*\Color[2][+]{\textsl{#2}\ifx#1+\index{color names\levelchar\textsl{#2}\string|usage}\fi}
% \def\Option#1{\texttt{#1}\index{package options\levelchar\texttt{#1}\string|usage}}
% \def\Key#1{\textit{#1}\index{keys\levelchar\textit{#1}\string|usage}}
% \def\File#1{\texttt{#1}\index{files\levelchar\texttt{#1}\string|usage}}
% \def\Op#1#2{#1\nolimits_{\,\Model{#2}}}
% \def\med{\mathop{\textrm{med}}}
% \def\mix{\mathop{\textrm{mix}}}
% \def\rd{\mathop{\textrm{round}}}
% \def\tint{\mathop{\textrm{tint}}}
% \def\shade{\mathop{\textrm{shade}}}
% \def\tone{\mathop{\textrm{tone}}}
% \def\LC{\Package{color}}
% \def\LCP{\Package{color} package}
% \def\XC{\Package{xcolor}}
% \def\XCP{\Package{xcolor} package}
% \def\XCW{\texttt{\href{http://www.ukern.de/tex/xcolor.html}{www.ukern.de/tex/xcolor.html}}}
% \newtheorem{lemma}{Lemma}
% \def\RtoI#1{\Gamma_{\!#1}}
% \def\ItoR#1{\Delta_{#1}}
%
% \newdimen\XCdim
%
% \parindent0pt
% \extrarowheight1pt
% \colorlet{tableheadcolor}{gray!25}
% \colorlet{tablerowcolor}{gray!12.5}
%
%
% \XCchanges100{First published release.}
% \XCchanges110{Index generation depended on local configuration file.}
%
% \title{Extending \LaTeX's color facilities: the \XCP}
% \author{\href{mailto:xcolor@ukern.de}{\fboxrule0pt\fboxsep2pt\fbox{Dr. Uwe Kern}}}
% \date{\XCfileversion{} (\XCfiledate)
%       \thanks{This package can be downloaded from the CTAN mirrors: \texttt{/macros/latex/contrib/xcolor/}.
%               There is also an \textsf{xcolor} homepage: \XCW.
%               Please send error reports and suggestions for improvements to the author:
%               \texttt{\href{mailto:xcolor@ukern.de}{xcolor@ukern.de}}.}}
% \maketitle
%
% \begin{abstract}
% \noindent
% \XC{} provides easy driver-independent access to several kinds of colors, tints, shades, tones, and mixes of arbitrary colors by means of color expressions like |\color{red!50!green!20!blue}|.
% It allows to select a document-wide target color model and offers tools for automatic color schemes, conversion between nine color models, alternating table row colors, color blending and masking, and color separation.
% \end{abstract}
%
% \phantomsection\pdfbookmark[1]{\contentsname}{toc}
% \tableofcontents\listoftables\listoffigures\newpage
%
%
%
%
% \section{Introduction}
%
% \subsection{Purpose of this package}
%
% The \LCP{} provides a powerful tool for handling colors within (pdf)\LaTeX{} in a consistent and driver-independent way, supporting several color models (slightly less driver-independent).
%
% Nevertheless, it is sometimes a bit clumsy to use, especially in cases where slight color variations, color mixes or color conversions are involved:
% this usually implies the usage of another program that calculates the necessary parameters, which are then copied into a |\definecolor| command in \LaTeX.
% Quite often, also a pocket calculator is involved in the treatment of issues like the following:
% \begin{itemize}
% \item My company has defined a corporate color, and the printing office tells me how expensive it is to use more than two colors in our new brochure, whereas all kinds of tints (e.g. a 75\% version) of our color can be used at no extra cost.
% But how to access these color variations in \LaTeX?
% \item My friend uses a nice color which I would like to apply in my own documents; unfortunately, it is defined in the \Model{hsb} model which is not supported in my favorite application pdf\LaTeX.
% What to do now?
% \item How does a mixture of 40\% \Color{green} and 60\% \Color{yellow} look like?\\
% (Answer: 40\% \testclr{green} $+$ 60\% \testclr{yellow} $=$ \testclr{green!40!yellow})
% \item And how does its complementary color look like?
% (Answer: \testclr{-green!40!yellow})
% \item Now I want to mix three parts of the last color with two parts of its complement and one part of \Color{red}.
% How does that look?\\
% (Answer: $3\times$ \testclr{-green!40!yellow} $+ 2\times$ \testclr{green!40!yellow} $+ 1\times$ \testclr{red} $=$ \testclr{rgb:-green!40!yellow,3;green!40!yellow,2;red,1})
% \item My printing office wants all color definitions in my document to be transformed into the \Model{cmyk} model.
% How can I do the calculations efficiently?
% \item I have a table with 50 rows.
% How can I get alternating colors for entire rows without copying 50 |\rowcolor| commands?
% \end{itemize}
% These are some of the issues solved by the \XCP.
%
%
%
% \subsection{Color tints, shades, tones, and complements}
%
% According to \cite{smith} we define the terms
% \begin{itemize}
% \item \textbf{\Index{tint}}: a color with \Color{white} added,
% \item \textbf{\Index{shade}}: a color with \Color{black} added,
% \item \textbf{\Index{tone}}: a color with \Color{gray} added.
% \end{itemize}
% These are special cases of a general function
% $\mix(C,C',p)$ which constructs a new color, consisting of $p$ parts of color $C$ and $1-p$ parts of color $C'$, where $0\le p\le1$.
% Thus, we set
% \begin{align}
% \tint(C,p) &:= \mix(C,|white|,p)\\
% \shade(C,p) &:= \mix(C,|black|,p)\\
% \tone(C,p) &:= \mix(C,|gray|,p)
% \end{align}
% where |white|, |black|, and |gray| are model-specific constants, see table \vref{tab.const}.
% Further we define the term
% \begin{itemize}
% \item \textbf{complement}: a color $C^*$ that yields \Color{white} if superposed with the original color $C$.
% \end{itemize}
% See section \vref{sec.cnv} for details.
%
%
%
% \subsection{Color models}
%
% A color model is a tool to describe or represent a certain set of colors in a way that is suitable for the desired target device, e.g.~a screen or a printer.
% There are proprietary models (like Pantone) that provide finite sets of colors, where the user has to choose from without caring about parametrisations; on the other hand, there are parameter-driven models like \Model{gray}, \Model{rgb}, and \Model{cmyk}, that aim to represent large finite or even (theoretically) infinite sets of colors, built on very small subsets of base colors and rules, how to construct other colors from these base colors.
% For example, a large range of colors can be constructed by linear combinations of the base colors \Color{red}, \Color{green}, and \Color{blue}.
%
%
%
%
% \section{The User Interface}
%
% \subsection{Preparation}
%
% \subsubsection{Package installation}
%
% First of all, put the file |xcolor.sty| to some place where (pdf)\LaTeX{} finds it.
% Then simply use \XC{} (instead of \LC) in your document.
% Thus, the general command is |\usepackage|\oarg{options}|{xcolor}| in the document preamble.
% Table \vref{tab.package} shows what has to be taken into account with respect to the package loading order.
%
% \begin{table}[p]\caption{Package loading order}\label{tab.package}
% \bigskip\centering
% \extrarowheight2pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{lcccc}
% \hline
% \rowcolor{tableheadcolor}
% \em Action/Package & \LC & \Package{pstcol}& \Package{colortbl}& \Package{hyperref}\\
% load before \XC & no & allowed\footnotemark[1] & allowed & allowed \\
% load with \XC{} option& --- & \Option{pst}\footnotemark[1] & \Option{table} & ---\\
% load after \XC & no & no & allowed & allowed \\
% \hline\hline
% \multicolumn5{c}{\footnotemark[1]\,not recommended, better use recent \File{pstricks.sty}}\\
% \hline
% \end{tabular}
% \end{table}
%
%
% \subsubsection{Package options}
%
% In general, there are several types of options:
% \begin{itemize}
% \item options that determine the color driver as explained in \cite{dpc} and \cite{color} (currently: \Option{dvips}, \Option{xdvi}, \Option{dvipdf}, \Option{dvipdfm}, \Option{pdftex}, \Option{dvipsone}, \Option{dviwindo}, \Option{emtex}, \Option{dviwin}, \Option{oztex}, \Option{textures}, \Option{pctexps}, \Option{pctexwin}, \Option{pctexhp}, \Option{pctex32}, \Option{truetex}, \Option{tcidvi}, \Option{vtex}),
% \item options that determine the target color model\footnote{Section \vref{sec.tgt} explains how this setting can be overridden at any point in a document.} (\Option{natural}, \Option{rgb}, \Option{cmy}, \Option{cmyk}, \Option{hsb}, \Option{gray}, \Option{RGB}, \Option{HTML}, \Option{HSB}, \Option{Gray}) or disable colored output (\Option{monochrome}),
% \item options that control whether certain sets of predefined colors are being loaded (\Option{dvipsnames}, \Option{svgnames}),
% \item options that determine which other packages are to be loaded (\Option{pst}\footnote{\label{fnt.pst}This option will soon become obsolete, since recent \File{pstricks.sty} versions do load \XC, whereas \Package{pstcol} is no longer needed.}, \Option{table}) or supported (\Option{hyperref}),
% \item options that determine the behaviour of other commands (\Option{showerrors}, \Option{hideerrors}),
% \item obsolete options (\Option{override}, \Option{usenames}, \Option{nodvipsnames}).
% \end{itemize}
% All available package options (except driver selection and obsolete options) are listed in table \vref{tab.opt}.
% \DescribeMacro\GetGinDriver
% \DescribeMacro\GinDriver
% In order to facilitate the co-operation with the \Package{hyperref} package, there is a command |\GetGinDriver|\footnote{This command is executed automatically if the package option \Option{hyperref} is used.} that grabs the driver actually used and puts it into the command |\GinDriver|.
% The latter can then be used within \Package{hyperref} (or other packages), see the code example on page \pageref{ex.range}.
% If there is no corresponding \Package{hyperref} option, \Option{hypertex} will be taken as default.
%
% Warning: there is a substantial difference between \XC{} and \LC{} regarding how the \Option{dvips} option is being handled.
% The \LCP{} implicitly invokes the \Option{dvipsnames} option, whenever one of the |dvips|, |oztex|, |xdvi| drivers is selected.
% This makes documents less portable, since whenever one of these colors is used without explicit \Option{dvipsnames} option, other drivers like |pdftex| will issue error messages because of unknown colors.
% Therefore, \XC{} always requires an explicit \Option{dvipsnames} option to use these names --- which then works for all drivers.
%
%
% \begin{table}[p]\caption{Package options}\label{tab.opt}
% \bigskip
% \extrarowheight2pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabularx}{\linewidth}{lX}
% \hline
% \rowcolor{tableheadcolor}
% \em Option & \em Description\\
% \Option{natural}& (Default.) Keep all colors in their model, except \Model{RGB} (converted to \Model{rgb}), \Model{HSB} (converted to \Model{hsb}), and \Model{Gray} (converted to \Model{gray}).\\
% \Option{rgb}& Convert all colors to the \Model{rgb} model.\\
% \Option{cmy}& Convert all colors to the \Model{cmy} model.\\
% \Option{cmyk}& Convert all colors to the \Model{cmyk} model.\\
% \Option{hsb}& Convert all colors to the \Model{hsb} model.\\
% \Option{gray}& Convert all colors to the \Model{gray} model. Especially useful to simulate how a black \& white printer will output the document.\\
% \Option{RGB}& Convert all colors to the \Model{RGB} model (and afterwards to \Model{rgb}).\\
% \Option{HTML}& Convert all colors to the \Model{HTML} model (and afterwards to \Model{rgb}).\\
% \Option{HSB}& Convert all colors to the \Model{HSB} model (and afterwards to \Model{hsb}).\\
% \Option{Gray}& Convert all colors to the \Model{Gray} model (and afterwards to \Model{gray}).\\
% \hline
% \Option{pst}& Load the \Package{pstcol} package, in order to use `normal' color definitions within \Package{pstricks} macros (see footnote \vref{fnt.pst}).\\
% \Option{table}& Load the \Package{colortbl} package, in order to use the tools for coloring rows, columns, and cells within tables.\\
% \Option{hyperref}& Support the \Package{hyperref} package in terms of color expressions by defining additional keys (cf. section \vref{sec.hyperref}).\\
% \hline
% \Option{dvipsnames}& Load a set of predefined colors as shown in figure \vref{fig.dvipsnam}.\\
% \Option{svgnames}& Load a set of predefined colors as shown in figure \vref{fig.svgnam}.\\
% \hline
% \Option{showerrors}& (Default.) Display an error message if an undefined color is being used (same behaviour as in the original \LCP).\\
% \Option{hideerrors}& Display only a warning if an undefined color is being used, and replace this color by \Color{black}.\\
% \hline
% \end{tabularx}
% \end{table}
%
%
% \begin{table}[htbp]\caption{Supported color models}\label{tab.mod}
% \bigskip\centering
% \extrarowheight2pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{l>{\em}l>{$}l<{$}rl}
% \hline
% \rowcolor{tableheadcolor}
% \emph{Name}  & Base colors/notions & \emph{Parameter range}& \multicolumn2{>{\columncolor{tableheadcolor}}l}{\emph{Default}}\\
% \Model{rgb}  & red, green, blue & [0,1]^3&& \\
% \Model{cmy}  & cyan, magenta, yellow & [0,1]^3&& \\
% \Model{cmyk} & cyan, magenta, yellow, black & [0,1]^4&& \\
% \Model{hsb}  & hue, saturation, brightness & [0,1]^3&& \\
% \Model{gray} & gray & [0,1]&& \\
% \Model{RGB}  & Red, Green, Blue & \{0,1,\dots,L\}^3& $L\,=$& $\mkern-15mu\rangeRGB$\\
% \Model{HTML} & RRGGBB & \{\texttt{000000},\dots,\texttt{FFFFFF}\}&& \\
% \Model{HSB}  & Hue, Saturation, Brightness & \{0,1,\dots,M\}^3& $M=$& $\mkern-15mu\rangeHSB$\\
% \Model{Gray} & Gray & \{0,1,\dots,N\}& $N\,=$& $\mkern-15mu\rangeGray$\\
% \hline\hline
% \multicolumn5{c}{$L,M,N$ are positive integers}\\
% \hline
% \end{tabular}
% \end{table}
%
%
% \subsubsection{Executing additional initialisation commands}
%
% \DescribeMacro\xcolorcmd
% Here is a simple interface to pass commands that should be executed at the end of the \XCP{} (immediately before the initialising |\color{black}| is executed).
% Just say |\def\xcolorcmd|\marg{commands} at some point before \XC{} is loaded.
%
% Example: assuming that |a.tex| is a complete \LaTeX{} document, the command
% |latex \def\xcolorcmd{\colorlet{black}{red}}\input{a}|
% at the console generates a file |a.dvi| with all occurences of \Color{black} being replaced by \Color{red}, without the necessity to change the source file itself.
%
%
%
% \subsection{Color models}
%
% \subsubsection{Supported color models}
%
% The list of supported color models is given in table \vref{tab.mod}.
% We emphasize that this color support is independent of the chosen driver.
%
% `Color model support' also means that it is possible to specify colors directly with their parameters, e.g.{} by saying |\textcolor[cmy]{0.7,0.5,0.3}{foo}| (\textcolor[cmy]{0.7,0.5,0.3}{foo}) or |\textcolor[HTML]{AFFE90}{foo}| (\textcolor[HTML]{AFFE90}{foo}).
% It is noteworthy that the \Model{HTML} model accepts any combination of the characters \texttt0--\texttt9, \texttt A--\texttt F, \texttt a--\texttt f, as long as the string has a length of exactly 6~characters.
% However, outputs of conversions to \Model{HTML} will always consist of numbers and \emph{uppercase} letters.
%
% \DescribeMacro\adjustUCRBG
% There is a special command to fine-tune the mechanisms of \emph{undercolor-removal} and \emph{black-generation} during conversion to the \Model{cmyk} model, see section \vref{sec.cmy2cmyk} for details.
%
% \DescribeMacro\rangeRGB
% \DescribeMacro\rangeHSB
% \DescribeMacro\rangeGray
% For the \emph{integer models} \Model{RGB}, \Model{HSB}, and \Model{Gray}, the constants $L, M, N$ of table \ref{tab.mod} are defined via the commands |\def\rangeRGB|\marg{L}, |\def\rangeHSB|\marg{M}, and |\def\rangeGray|\marg{N}.
% Changes of these constants should be done \emph{before} the \XCP{} is loaded, e.g.:
% \label{ex.range}\begin{verbatim}
% \documentclass{article}
% ...
% \def\rangeRGB{15}
% \usepackage[dvips]{xcolor}
% ...
% \GetGinDriver
% \usepackage[\GinDriver]{hyperref}
% ...
% \begin{document}
% ...
% \end{verbatim}
%
%
% \subsubsection{Changing the target color model within a document}\label{sec.tgt}
%
% \DescribeMacro\selectcolormodel
%   \marg{num model}\\
% Sets the target model to \Meta{num model}, where the latter is one of the model names allowed as package option (i.e., \Option{natural}, \Option{rgb}, \Option{cmy}, \Option{cmyk}, \Option{hsb}, \Option{gray}, \Option{RGB}, \Option{HTML}, \Option{HSB}, \Option{Gray}), see figure \vref{fig.tgt} for an example.
% There are two possible hooks, where the conversion to the target model can take place:
% \begin{itemize}
% \item \DescribeMacro\ifconvertcolorsD at color \emph{definition} time\footnote{This means that all \emph{newly} defined colors will be first converted to the target model, then saved.} (i.e., within |\definecolor| and friends); this is controlled by the switch |\ifconvertcolorsD|;
% \item \DescribeMacro\ifconvertcolorsU at time of color \emph{usage} (immediately before a color is displayed, therefore covering colors that have been defined in other models or that are being specified directly like |\color[rgb]{.1,.2,.3}|); this is controlled by the switch |\ifconvertcolorsU|.
% \end{itemize}
% Both switches are set to `true' by selecting any of the models, except \Option{natural}, which sets them to `false'.
% This applies for selection via a package option as well as via |\selectcolormodel|.
% Why don't we simply convert all colors at time of usage?
% If many colors are involved, it can save some processing time when all conversions are already done during color definitions.
% Best performance can be achieved by saying |\usepackage[rgb,...]{xcolor}\convertcolorsUfalse|, which is actually the way how \XC{} worked up to version 1.07.
%
%
% \begin{figure}[htbp]\caption{Target color model --- Example}\label{fig.tgt}
% \bigskip\centering\small
% \extrarowheight2pt
% \makeatletter
% \def\X#1%
%  {\def\tmp{{#1}}\dots\Meaning{tmp}&
%   \selectcolormodel{#1}\testclr{red} \testclr{green} \testclr{blue} \testclr{cyan} \testclr{magenta} \testclr{yellow} \testclr{orange} \testclr{violet} \testclr{purple} \testclr{brown} \testclr{black} \testclr{darkgray} \testclr{gray} \testclr{lightgray} \testclr{white}\\}
% \makeatother
% \begin{tabular}{@{}>{\ttfamily}l@{ }l@{}}
% \string\selectcolormodel&\\
% \X{natural}
% \X{rgb}
% \X{cmy}
% \X{cmyk}
% \X{hsb}
% \X{gray}
% \end{tabular}
% \end{figure}
%
%
% \begin{table}[htbp]\caption{Arguments and terminology}\label{tab.term}
% \def\RS{\ensuremath{\to}\space}
% \bigskip\raggedleft
% \extrarowheight2pt
% \begin{adjustwidth}{-2.5cm}{}
% \advance\textwidth2.5cm
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabularx}{\textwidth}{l@{ }X}
% \hline
% \rowcolor{tableheadcolor}
% \em Element & \em Replacement string\\
% \Meta*{empty}& \RS empty string `'\\
% \Meta*{minus}& \RS non-empty string consisting of one or more minus signs `|-|'\\
% \Meta*{plus}& \RS non-empty string consisting of one or more plus signs `|+|'\\
% \hline
% \Meta*{int}& \RS integer number\hfill(\emph{integer})\\
% \Meta*{num}& \RS non-negative integer number\hfill(\emph{number})\\
% \Meta*{dec}& \RS real number\hfill(\emph{decimal})\\
% \Meta*{div}& \RS non-zero real number\hfill(\emph{divisor})\\
% \Meta*{pct}& \RS real number from the interval $[0,100]$\hfill(\emph{percentage})\\
% \hline
% \Meta*{name}& \RS non-empty string consisting of letters and digits\hfill(\emph{explicit name})\newline
%               \RS `|.|'\hfill(\emph{implicit name})\\
% \Meta*{core model}& \RS `|rgb|', `|cmy|', `|cmyk|', `|hsb|', `|gray|'\hfill(\emph{core models})\\
% \Meta*{num model}& \RS \Meta{core model}\newline
%                    \RS `|RGB|', `|HTML|', `|HSB|', `|Gray|'\hfill(\emph{integer models})\\
% \Meta*{model}& \RS \Meta{num model}\hfill(\emph{numerical models})\newline
%                \RS `|named|'\hfill(\emph{pseudo model})\\
% \Meta*{spec}& \RS comma-separated list of numerical values\hfill(\emph{explicit specification})\newline
%               \RS name of a `named' color\hfill(\emph{implicit specification})\\
% \Meta*{type}& \RS \Meta{empty}\newline
%               \RS `|named|'\\
% \hline
% \Meta*{expr}& \RS \Meta{prefix}\Meta{name}\Meta{mix expr}\Meta{postfix}\hfill(\emph{standard color expression})\\
% \Meta*{prefix}& \RS \Meta{empty}\newline
%                 \RS \Meta{minus}\hfill(\emph{complement indicator})\\
% \Meta*{mix expr}& \RS |!|\Meta[1]{pct}|!|\Meta[1]{name}|!|\Meta[2]{pct}|!|\Meta[2]{name}|!|\dots|!|\Meta[n]{pct}|!|\Meta[n]{name} \hfill(\emph{complete mix expr.})\newline
%                   \RS |!|\Meta[1]{pct}|!|\Meta[1]{name}|!|\Meta[2]{pct}|!|\Meta[2]{name}|!|\dots|!|\Meta[n]{pct} \hfill(\emph{incomplete mix expr.})\\
% \Meta*{postfix}& \RS \Meta{empty}\newline
%                  \RS |!!|\Meta{plus}\hfill(\emph{series step})\newline
%                  \RS |!![|\Meta{num}|]|\hfill(\emph{series access})\\
% \hline
% \Meta*{ext expr}& \RS \Meta{core model}|,|\Meta{div}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}\newline
%                   \RS \Meta{core model}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}\\
% \hline
% \Meta*{color}& \RS \Meta{name}\newline
%                \RS \Meta{expr}\newline
%                \RS \Meta{ext expr}\\
% \hline\hline
% \rowcolor{white}
% Remarks:& Each \RS denotes a possible replacement string for the element in the left column;
%           however, further restrictions may apply --- depending on the context.
%           See main text for details.
%           A string `|foo|' is always to be understood without the quotes.\newline
%           $n$ and $k$ denote positive integers.\\
% \hline
% \end{tabularx}
% \end{adjustwidth}
% \end{table}
%
%
%
% \subsection{Arguments and terminology}\label{sec.term}
%
% Before we describe \XC's color-related commands in detail, we define several elements or identifiers that appear repeatedly within arguments of those commands.
% A general syntax overview is given in table \vref{tab.term}.
%
%
% \subsubsection{Additional remarks and restrictions on arguments}
%
% \paragraph{Basic strings and numbers}
% \DescribeArg{empty}
% \DescribeArg{minus}
% \DescribeArg{plus}
% \DescribeArg{int}
% \DescribeArg{num}
% \DescribeArg{dec}
% \DescribeArg{pct}
% \DescribeArg{div}
% These arguments do not need much explanation.
% However, as far as numerical values are concerned, it is noteworthy that real numbers in (La)\TeX{} are --- as long as they are to be used in the context of lengths, dimensions, or skips --- are restricted to a maximum absolute value $<16384$.
% Certainly, in a chain of numerical calculations, this constraint has also to be obeyed for every single interim result, which usually implies further range restrictions.
% Since \XC{} makes extensive use of \TeX's internal dimension registers for most types of calculations, this should be kept in mind whenever \Meta{ext expr} expressions are to be used.
%
%
% \paragraph{Color names}
% \DescribeArg{name}
% A \Meta{name} denotes the declared name (or the name to be declared) of a \emph{color} or a \emph{color series};
% it may be declared \emph{explicitly} by one of the following commands: |\definecolor|, |\providecolor|, |\colorlet|, |\definecolorset|, |\providecolorset|, |\definecolorseries|.
% On the other hand, the reserved color name `|.|' is declared \emph{implicitly} and denotes the \emph{current color}.
% Actually, besides letters and digits, certain other characters do also work for \Meta{name} declarations, but the given restriction avoids misunderstandings and ensures compatibility with future extensions of \XC.
%
% Examples: `|red|', `|MySpecialGreen1980|', `|.|'.
%
%
% \paragraph{Color models}
% \DescribeArg{core model}
% \DescribeArg{num model}
% \DescribeArg{model}
% The differentiation between \emph{core models} (\Model{rgb}, \Model{cmy}, \Model{cmyk}, \Model{hsb}, \Model{gray}), \emph{integer models} (\Model{RGB}, \Model{HTML}, \Model{HSB}, \Model{Gray}), and \emph{pseudo models} (currently only \nModel{named}) has a simple reason: core models with their parameter ranges based on the unit interval $[0,1]$ are best suited for all kinds of calculations, whereas the purpose of the integer models is mainly to facilitate the input of parameters, followed by some transformation into one of the core models.
% Finally, the pseudo model \nModel{named} has a special status, since it is `calculation-averse': it is usually only possible to convert such a color into one of the other models, but not the other way round.
%
%
% \paragraph{Color specifications}
% \DescribeArg{spec}
% The \Meta{spec} argument --- which specifies the parameters of a color --- obviously depends on the underlying color model.
% We differentiate between \emph{explicit} and \emph{implicit} specification, the former referring to numerical parameters as explained in table \vref{tab.mod}, the latter --- ideally --- referring to driver-provided names.
%
% Examples: `|.1,.2,.3|', `|0.56789|', `|89ABCD|', `|ForestGreen|'.
%
% \paragraph{The type argument}
% \DescribeArg{type} This is used only in the context of color defining commands, see the description of |\definecolor| and friends.
%
%
% \paragraph{Standard color expressions}
% \DescribeArg{expr}
% \DescribeArg{prefix}
% \DescribeArg{mix expr}
% \DescribeArg{postfix}
% These expressions serve as a tool to easily specify a certain form of cascaded color mixing which is described in detail in section \vref{sec.expr-meaning}.
% The \Meta{prefix} argument controls whether the color following thereafter or its complement will be relevant:
% an odd number of minus signs indicates that the color resulting from the remaining expression has to be converted into its complementary color.
% An \emph{incomplete mix expression} is just an abbreviation for a \emph{complete mix expression} with $\Meta[n]{name} = |white|$, in order to save some keystrokes in the case of tints.
% The \Meta{postfix} string is usually empty, but it offers some additional functionality in the case of a \emph{color series}:
% the non-empty cases require that
% \begin{itemize}
% \item \Meta{name} denotes the name of a \emph{color series},
% \item \Meta{mix expr} is a \emph{complete} mix expression.
% \end{itemize}
% Examples: `|red|', `|-red|', `|--red!50!green!12.345|', `|red!50!green!20!blue|', `|foo!!+|', `|foo!![7]|', `|foo!25!red!!+++|', `|foo!25!red!70!green!![7]|'.
%
%
% \paragraph{Extended color expressions}
% \DescribeArg{ext expr}
% These expressions provide another method of color mixing, see section \vref{sec.extexpr-meaning} for details.
% The shorter form
% \begin{align*}
% \Meta{core model}&|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}\\
% \intertext{is an abbreviation for the special (and probably most used) case}
% \Meta{core model}|,|\Meta{div}&|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}\\
% \intertext{with the following definition (requiring a non-zero sum of all \Meta[\kappa]{dec} coefficients):}
% \Meta{div} &:= \Meta[1]{dec} + \Meta[2]{dec} + \dots + \Meta[k]{dec} \neq0.
% \end{align*}
% Examples: `|rgb:red,1|', `|cmyk:red,1;-green!25!blue!60,11.25;blue,-2|'.
%
%
% \paragraph{Colors}
% \DescribeArg{color}
% Finally, \Meta{color} is the `umbrella' argument, covering the different concepts of specifying colors.
% This means, whenever there is a \Meta{color} argument, the full range of names and expressions, as explained above, may be used.
%
%
% \subsubsection{Meaning of standard color expressions}\label{sec.expr-meaning}
%
% We explain now how an expression
% \begin{gather*}
% \Meta{prefix}\Meta{name}|!|\Meta[1]{pct}|!|\Meta[1]{name}|!|\Meta[2]{pct}|!|\dots|!|\Meta[n]{pct}|!|\Meta[n]{name}\Meta{postfix}
% \end{gather*}
% is being interpreted and processed:
% \begin{enumerate}
% \item First of all, the model and color parameters of \Meta{name} are extracted to define a temporary color \Meta{temp}.
% If \Meta{postfix} has the form `|!![|\Meta{num}|]|', then \Meta{temp} will be the corresponding (direct-accessed) color \Meta{num} from the series \Meta{name}.
% \item Then a color mix, consisting of \Meta[1]{pct}\% of color \Meta{temp} and $(100-\Meta[1]{pct})$\% of color \Meta[1]{name} is computed; this is the new temporary color \Meta{temp}.
% \item The previous step is being repeated for all remaining parameter pairs (\Meta[2]{pct},\Meta[2]{name}), \dots, (\Meta[n]{pct},\Meta[n]{name}).
% \item If \Meta{prefix} consists of an odd number of minus signs `-', then \Meta{temp} will be changed into its complementary color.
% \item If \Meta{postfix} has the form `|!!+|', `|!!++|', `|!!+++|', etc., a number of step commands (=~number of `|+|' signs) are performed on the underlying color series \Meta{name}.
% This has no consequences for the color \Meta{temp}.
% \item Now the color \Meta{temp} is being displayed or serves as an input for other operations, depending on the invoking command.
% \end{enumerate}
% Note that in a typical step 2 expression \Meta{temp}|!|\Meta[\nu]{pct}|!|\Meta[\nu]{name}, if \Meta[\nu]{pct}=100 resp.{} \Meta[\nu]{pct}=0, the color \Meta{temp} resp.{} \Meta[\nu]{name} is used without further transformations.
% In the true mix case, $0<$\Meta[\nu]{pct}$<100$, the two involved colors may have been defined in different color models, e.g.{} |\definecolor{foo}{rgb}{...}| and |\definecolor{bar}{cmyk}{...}|.
% In general, the second color, \Meta[\nu]{name}, is transformed into the model of the first color, \Meta{temp}, then the mix is calculated within that model.\,\footnote{Exception: in order to avoid strange results, this rule is being reversed if \Meta{temp} origins from the \Model{gray} model; in this case it is converted into the underlying model of \Meta[\nu]{name}.}
% Thus, \Meta{temp}|!|\Meta[\nu]{pct}|!|\Meta[\nu]{name} and \Meta[\nu]{name}|!|\Meta[\nu]{$100-$pct}|!|\Meta{temp}, which should be equivalent theoretically, will not necessarily yield identical visual results.
%
% Figures \vrefrange{fig.expr}{fig.ex} show some first applications of colors and expressions.
% More examples are given in figures \vrefrange{fig.MyGreen}{fig.MyGreen-gray}.
% Over and above that, a large set of color examples can be found in \cite{chroma}.
%
% \begin{figure}[tbp]\caption{Standard color expressions --- Example}\label{fig.expr}
% \bigskip\centering\small
% \def\test#1{\testclr{#1}& \texttt{#1}}
% \def\X#1{\test{#1}& \test{-#1}}
% \begin{tabular}{@{}l@{ \ }ll@{ \ }l@{}}
% \X{red}\\
% \X{red!75}\\
% \X{red!75!green}\\
% \X{red!75!green!50}\\
% \X{red!75!green!50!blue}\\
% \X{red!75!green!50!blue!25}\\
% \X{red!75!green!50!blue!25!gray}\\
% \end{tabular}
% \end{figure}
%
%
% \begin{figure}[tbp]\caption{Standard color expressions --- Box example}\label{fig.ex}
% \begin{minipage}{\textwidth}\small
% \vspace*{3ex}
% \begin{verbatim}
% \fboxrule6pt
% \fcolorbox
%  {red!70!green}% outer frame
%  {yellow!30!blue}% outer background
%  {\fcolorbox
%    {-yellow!30!blue}% inner frame
%    {-red!70!green}% inner background
%    {Test\textcolor{red!72.75}{Test}\color{-green}Test}}
% \end{verbatim}
% \end{minipage}\relax
% \llap{\fboxrule6pt \fcolorbox
%   {red!70!green}{yellow!30!blue}{\fcolorbox
%     {-yellow!30!blue}{-red!70!green}{Test\textcolor{red!72.75}{Test}\color{-green}Test}}}
% \end{figure}
%
%
% \subsubsection{Meaning of extended color expressions}\label{sec.extexpr-meaning}
%
% An \emph{extended color expression}
% \begin{gather*}
% \Meta{core model}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}
% \end{gather*}
% mimes color mixing as painters do it: specify a list of colors, each with a \Meta{dec} factor attached to.
% For such an \Meta{ext expr}, each standard color expression \Meta[\kappa]{expr} will be converted to \Meta{core model}, then the resulting vector is multiplied by $\Meta[\kappa]{dec}/\Meta{div}$, where
% \begin{gather*}
% \Meta{div} := \Meta[1]{dec} + \Meta[2]{dec} + \dots + \Meta[k]{dec}.
% \end{gather*}
% Afterwards the sum of all of these vectors is calculated.
%
% Example: mixing 4~parts of \testclr{red} \Color{red}, 2~parts of \testclr{green} \Color{green}, and 1~part of \testclr{yellow} \Color{yellow}, we get \testclr{rgb:red,4;green,2;yellow,1} by saying |\color{rgb:red,4;green,2;yellow,1}|.
% Trying the same with $-1$ parts of \Color{yellow} instead, we get \testclr{rgb:red,4;green,2;yellow,-1}.
% Note that this mechanism can also be used to display an individual color (expression) in a certain color model: |\color{rgb:yellow,1}| results in such a conversion.
% The general form
% \begin{gather*}
% \Meta{core model}|,|\Meta{div}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}
% \end{gather*}
% does the same operation with the only difference that the divisor \Meta{div} is being specified instead of calculated.
% In the above example, we get a shaded version \testclr{rgb,9:red,4;green,2;yellow,1} by saying |\color{rgb,9:red,4;green,2;yellow,1}|.
% Note that it is not forbidden to specify a \Meta{div} argument which is smaller than the sum of all \Meta[\kappa]{dec}, such that one or more of the final color specification parameters could be outside the interval $[0,1]$.
% However, the mapping of equation (\ref{eq.U}) takes care of such cases.
%
%
%
% \subsection{Predefined colors}
%
% \subsubsection{Colors that are always available}
%
% \def\test#1{\testclr{#1}~\Color{#1}}
% Within |xcolor.sty|, the following color names are defined:
% \test{red}, \test{green}, \test{blue}, \test{cyan}, \test{magenta}, \test{yellow}, \test{orange}, \test{violet}, \test{purple}, \test{brown}, \test{black}, \test{darkgray}, \test{gray}, \test{lightgray}, \test{white}.
%
% This base set of colors can be used without restrictions in all kinds of color expressions, as explained in section \vref{sec.term}.
%
%
% \subsubsection{Additional sets of colors}
%
% There are also sets of color names that may be loaded by \XC{} via package options:
% \begin{itemize}
% \item \Option{dvipsnames} loads a set of 68 \Model{cmyk} colors as defined in the |dvips| driver. However, these colors may be used in all supported drivers. See figure \vref{fig.dvipsnam}.
% \item \Option{svgnames} loads a set of 147 \Model{rgb} color names\footnote{In fact, these names represent 138 different colors.} according to the SVG~1.1 specification \cite{svg}\footnote{Actually, the cited specification lists only lowercase names, and the original definitions are given in \Model{RGB} parameters, converted to \Model{rgb} by the author.}, see figure \vref{fig.svgnam}.
% \end{itemize}
% Note that --- due to some overlap in the names --- the option order is important, if you plan to use more than one of these sets.
% See also \cite{chroma} for a systematic set of color and mix examples.
%
% \begin{figure}[htbp]\caption{Colors defined by the \Option{dvipsnames} option}\label{fig.dvipsnam}
% \bigskip\centering\small
% \def\DefineNamedColor#1#2#3#4{\Testclr{#2}}
% \begin{minipage}{\textwidth}
% \columnsep2.5em
% \begin{multicols}{4}
% \iffalse
% \makeatletter
% \edef\restore{\catcode`\noexpand\%\the\catcode`\%\relax}
% \catcode`\%14\relax\input{dvipsnam.def}\restore
% \fi
% \let\0\Testclr
% \0{Apricot}
% \0{Aquamarine}
% \0{Bittersweet}
% \0{Black}
% \0{BlueGreen}
% \0{BlueViolet}
% \0{Blue}
% \0{BrickRed}
% \0{Brown}
% \0{BurntOrange}
% \0{CadetBlue}
% \0{CarnationPink}
% \0{Cerulean}
% \0{CornflowerBlue}
% \0{Cyan}
% \0{Dandelion}
% \0{DarkOrchid}
% \0{Emerald}
% \0{ForestGreen}
% \0{Fuchsia}
% \0{Goldenrod}
% \0{Gray}
% \0{GreenYellow}
% \0{Green}
% \0{JungleGreen}
% \0{Lavender}
% \0{LimeGreen}
% \0{Magenta}
% \0{Mahogany}
% \0{Maroon}
% \0{Melon}
% \0{MidnightBlue}
% \0{Mulberry}
% \0{NavyBlue}
% \0{OliveGreen}
% \0{OrangeRed}
% \0{Orange}
% \0{Orchid}
% \0{Peach}
% \0{Periwinkle}
% \0{PineGreen}
% \0{Plum}
% \0{ProcessBlue}
% \0{Purple}
% \0{RawSienna}
% \0{RedOrange}
% \0{RedViolet}
% \0{Red}
% \0{Rhodamine}
% \0{RoyalBlue}
% \0{RoyalPurple}
% \0{RubineRed}
% \0{Salmon}
% \0{SeaGreen}
% \0{Sepia}
% \0{SkyBlue}
% \0{SpringGreen}
% \0{Tan}
% \0{TealBlue}
% \0{Thistle}
% \0{Turquoise}
% \0{VioletRed}
% \0{Violet}
% \0{White}
% \0{WildStrawberry}
% \0{YellowGreen}
% \0{YellowOrange}
% \0{Yellow}
% \end{multicols}
% \end{minipage}
% \end{figure}
%
% \begin{figure}[htbp]\caption{Colors defined by the \Option{svgnames} option}\label{fig.svgnam}
% \begin{adjustwidth}{-2cm}{}
% \bigskip\centering\small
% \advance\textwidth3cm
% \iffalse
% \mbox{}\hspace*{-2cm}\begin{minipage}{\textwidth}
% \fi
% \begin{minipage}{\textwidth}
% \columnsep2.5em
% \begin{multicols}{4}
% \makeatletter
% \def\definecolorset
%  {\def\XC@defclr[##1]##2##3##4{\definecolor[##1]{##2}{##3}{##4}\Testclr{##2}}\@testopt{\XC@definecolorset}{}}
% \edef\restore{\catcode`\noexpand\%\the\catcode`\%\relax}
% \catcode`\%14\relax\input{svgnam.def}\restore
% \end{multicols}
% \smallskip
% \begin{adjustwidth}{1cm}{1cm}
% \raggedright Duplicate colors:
% \Color{Aqua} = \Color{Cyan},
% \Color{Fuchsia} = \Color{Magenta};
% \Color{Gray} = \Color{Grey},
% \Color{DarkGray} = \Color{DarkGrey},
% \Color{LightGray} = \Color{LightGrey},
% \Color{SlateGray} = \Color{SlateGrey},
% \Color{DarkSlateGray} = \Color{DarkSlateGrey},
% \Color{LightSlateGray} = \Color{LightSlateGrey},
% \Color{DimGray} = \Color{DimGrey}.
% \end{adjustwidth}
% \end{minipage}
% \end{adjustwidth}
% \end{figure}
%
%
%
% \subsection{Color definition}\label{sec.def}
%
% \subsubsection{Ordinary and named colors}
%
% In the \LCP{} there is a distinction between `colors' (defined by the command |\definecolor|) and `named colors' (defined by |\DefineNamedColor|, which is allowed only in the preamble).
% Whenever an ordinary color is being used in a document, it will be translated into a |\special| command that contains a --- driver-specific --- numerical description of the color which is written to the |dvi| file.
% On the other hand, named colors offer the opportunity to store numerical values at a central place whereas during usage, colors may be identified by their names, thus enabling post-processing if required by the output device.
% Unfortunately, this concept is supported in quite a different way by different drivers, which leads to a strange situation:
% \begin{itemize}
% \item the \Option{dvips} driver, which supports the concept of named colors, restricts their usage to the universe defined in \File{dvipsnam.def} (as shown in figure \ref{fig.dvipsnam}), any other named colors have to be defined both in the document preamble and in separate dvips header files, thus making documents less portable.
% \item the \Option{pdftex} driver, which does not support the named color concept, allows unrestricted definition and usage of named colors (although offering no added value through this).
% \end{itemize}
% Conclusion: don't use |\DefineNamedColor| unless you know exactly what you are doing!
%
%
% \subsubsection{Color definition in \XC}
%
% \DescribeMacro\definecolor
%   \oarg{type}\marg{name}\marg{model}\marg{spec}\footnote{Prior to version 2.00, this command was called \cs{xdefinecolor}, the latter name still being available for compatibility reasons.}\\
% This is one of the commands that may be used to assign a \Meta{name} to a specific color.
% Afterwards, this color is known to the system (in the current group) and may be used in \emph{\Index{color expression}s}, as explained in section \vref{sec.term}.
% It replaces both \LC's |\DefineNamedColor| and |\definecolor|.
% Note that an already existing color \Meta{name} will be overwritten.
% The variable |\tracingcolors| controls whether such an overwriting will be logged or not (see section \vref{sec.info} for details).
% The arguments are described in section \vref{sec.term}.
% Hence, valid expressions for color definitions are
% \begin{itemize}
% \item |\definecolor{red}{rgb}{1,0,0}|,
% \item |\definecolor[named]{Black}{cmyk}{0,0,0,1}|,
% \item |\definecolor{myblack}{named}{Black}|,
% \end{itemize}
% where the last command is equivalent to |\colorlet{myblack}{Black}| (see below).
%
% \medskip
%
% \DescribeMacro\providecolor
%   \oarg{type}\marg{name}\marg{model}\marg{spec}\\
% Similar to |\definecolor|, but the color \Meta{name} is only defined if it does not exist already.
%
% \medskip
%
% \DescribeMacro\colorlet
%   \marg{name}\oarg{num model}\marg{color}\\
% Copies the actual color which results from \Meta{color} to \Meta{name}.
% If \Meta{num model} is non-empty, \Meta{color} is first transformed to the specified model, before \Meta{name} is being defined.
% The pseudo model \nModel{named} is \emph{not} allowed here.
% Note that an already existing color \Meta{name} will be overwritten.
%
% Example: we said |\colorlet{tableheadcolor}{gray!25}| in the preamble of this document.
% In most of the tables we then formatted the first row by using the command |\rowcolor{tableheadcolor}|.
%
%
% \subsubsection{Defining sets of colors}
%
% \DescribeMacro\definecolorset
%   \oarg{type}\marg{model}\marg{head}\marg{tail}\marg{set spec}\\
% This command facilitates the construction of \emph{\Index{color set}s} with common underlying \Meta{model} and \Meta{type}.
% Here, \Meta{set spec} = \Meta[1]{name},\Meta[1]{spec};\dots;\Meta[l]{name},\Meta[l]{spec} ($l\ge1$ name/specification pairs).
% Individual colors are being constructed by single
% \begin{center}
% |\definecolor|\oarg{type}|{|\Meta{head}\Meta[\lambda]{name}\Meta{tail}|}|\marg{model}|{|\Meta[\lambda]{spec}|}|
% \end{center}
% commands, $\lambda=1,\dots,l$.
% For example,
% \begin{itemize}
% \item |\definecolorset{rgb}{}{}{red,1,0,0;green,0,1,0;blue,0,0,1}|\\
% is used in \XC{} to define the basic colors \Color{red}, \Color{green}, and \Color{blue};
% \item |\definecolorset{rgb}{x}{10}{red,1,0,0;green,0,1,0;blue,0,0,1}|\\
% would define the colors \Color[-]{xred10}, \Color[-]{xgreen10}, and \Color[-]{xblue10}.
% \end{itemize}
%
% \DescribeMacro\providecolorset
%   \oarg{type}\marg{model}\marg{head}\marg{tail}\marg{set spec}\\
% Similar to |\definecolorset|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already.
%
% \medskip
%
% \DescribeMacro\DefineNamedColor
%   \marg{type}\marg{name}\marg{model}\marg{spec}
% is provided mainly for compatibility reasons, especially to support the predefined colors in \File{dvipsnam.def}.
% It is the same as |\definecolor|\oarg{type}\marg{name}\marg{model}\marg{spec}.
% Note that \LC's restriction to allow |\DefineNamedColor| only in the document preamble has been abolished in \XC.
%
%
% \subsubsection{Global color definitions}
%
% \XCchanges111{New switch \cs{ifglobalcolors}.}
% \DescribeMacro\ifglobalcolors
% By default, definitions via |\definecolor|, |\providecolor|, \dots{} are available only within the current group.
% By setting |\globalcolorstrue|, all such definitions are being made globally available --- until the current group ends\footnote{The switch may also be set in the preamble in order to control the whole document.}.
% \DescribeMacro\xglobal
% Another method to specify that an individual color definition is to be made global is to prefix it by |\xglobal|, e.g., |\xglobal\definecolor{foo}...|.
%
%
%
% \subsection{Color application}
%
% Here is the list of user-level color commands, as known from the \LCP, but with an extended syntax for the colors:\\
% \DescribeMacro\color\marg{color}\\
% \oarg{model}\marg{spec}\\
% \DescribeMacro\textcolor\marg{color}\marg{text}\\
% \oarg{model}\marg{spec}\marg{text}\\
% \DescribeMacro\colorbox\marg{color}\marg{text}\\
% \oarg{model}\marg{spec}\marg{text}\\
% \DescribeMacro\fcolorbox\marg{frame color}\marg{background color}\marg{text}\\
% \oarg{model}\marg{frame spec}\marg{background spec}\marg{text}\\
% \DescribeMacro\pagecolor\marg{color}\\
% \oarg{model}\marg{spec}\\
% Hence, the formal difference to the \LCP{} is that color \emph{expressions} may be used instead of pure color \emph{names}.
% A previous section explains how color expressions are constructed.
%
% Remark: all of these commands except |\color| require that the \Meta{color} resp.{} \Meta{spec} arguments are put into curly braces |{}|, even if they are buried in macros.
%
% For example, after |\def\foo{red}|, one may say |\color\foo|, but one should always write |\textcolor{\foo}{bar}| instead of |\textcolor\foo{bar}| in order to avoid unexpected results.
%
% Note that color-specific commands from other packages may give unexpected results if directly confronted with color expressions (e.g.~\Package{soul}'s |\sethlcolor| and friends).
% However, one can turn the expression into a name via |\colorlet| and try to use that name instead.
%
%
% \def\ukColor{MyGreen}
% \definecolor{\ukColor}{cmyk}{0.92,0,0.87,0.09}
% \colorlet{\ukColor-rgb}[rgb]{\ukColor}
% \colorlet{\ukColor-cmy}[cmy]{\ukColor}
% \colorlet{\ukColor-hsb}[hsb]{\ukColor}
% \colorlet{\ukColor-gray}[gray]{\ukColor}
%
% \TestColor{\ukColor}
% \TestColor{\ukColor-cmy}
% \TestColor{\ukColor-rgb}
% \TestColor{\ukColor-hsb}
% \TestColor{\ukColor-gray}
%
%
% \subsubsection{Using the current color}
%
% Within a color expression, `.' serves as a placeholder for the current color.
% See figure \vref{fig.cc} for an example.
%
% It is also possible to save the current color for later use, e.g., via the command |\colorlet{foo}{.}|.
%
% Note that in some cases the current color is of rather limited use, e.g., the construction of an |\fcolorbox| implies that at the time when the \Meta{background color} is evaluated, the current color equals the \Meta{frame color}; in this case `|.|' does not refer to the current color \emph{outside} the box.
%
%
% \begin{figure}[tbp]\caption{Current color --- Example}\label{fig.cc}
% \begin{minipage}{\textwidth}\small
% \vspace*{3ex}
% \begin{verbatim}
% \def\test{current, \textcolor{.!50}{50\%},
%           \textcolor{-.}{complement},
%           \textcolor{yellow!50!.}{mix}}
% \textcolor{blue}{\test}\\
%  and \textcolor{red}{\test}\\
% \def\Test{\color{.!80}Test}
% \textcolor{blue}{\Test\Test\Test\Test\Test}\\
% and \textcolor{red}{\Test\Test\Test\Test\Test}
% \end{verbatim}
% \end{minipage}\relax
% \llap{\begin{minipage}{.5\textwidth}\small\raggedleft
% \def\test{current, \textcolor{.!50}{50\%},
%           \textcolor{-.}{complement},
%           \textcolor{yellow!50!.}{mix}}
% \textcolor{blue}{\test}\\
%  and \textcolor{red}{\test}\\
% \def\Test{\color{.!80}Test}
% \textcolor{blue}{\Test\Test\Test\Test\Test}\\
% and \textcolor{red}{\Test\Test\Test\Test\Test}
% \end{minipage}}
% \end{figure}
%
%
%
% \subsection{Color blending}
%
% The purpose of \emph{color blending} is to add some mixing color (expression) to all subsequent explicit color commands.
% Thus, it is possible to perform such a mix (or blend) operation for many colors without touching the individual commands.
%
% \medskip
%
% \DescribeMacro\blendcolors
%   \marg{mix expr}\\
% \DescribeMacro{\blendcolors*}
%   \marg{mix expr}\\
% Initialises all necessary parameters for color blending.
% The actual (completed) color blend expression is stored in |\colorblend|.
% In the starred version, the argument will be appended to a previously defined blend expression.
% An empty \Meta{mix expr} argument will switch blending off.
%
% Example: after |\blendcolors{!50!yellow}|, the colors \testclr{red} \testclr{green} \testclr{blue} are transformed into {\blendcolors{!50!yellow}\testclr{red} \testclr{green} \testclr{blue}, an additional |\blendcolors*{!50}| yields \blendcolors*{!50}\testclr{red} \testclr{green} \testclr{blue}}.
% \DescribeMacro\xglobal
% In order to achieve global scope, |\blendcolors| may be prefixed by |\xglobal|.
%
% Remark: color blending is applied only to \emph{explicit} color commands, i.e.~|\color|, |\fcolorbox| and the like.
% In the previous example the frames are not being blended because their color is set by an driver-internal command (switching back to the `current color').
% Thus, to influence these \emph{implicit} colors as well, we have to set the current color \emph{after} the blending:
% |\blendcolors{!50!yellow}\color{black}| results in {\blendcolors{!50!yellow}\color{black}\testclr{red} \testclr{green} \testclr{blue}, an additional |\blendcolors*{!50}\color{black}| yields \blendcolors*{!50}\color{black}\testclr{red} \testclr{green} \testclr{blue}}.
%
%
%
% \subsection{Color masks and separation}
%
% The purpose of \emph{color separation} is to represent all colors that appear in the document as a combination of a finite subset of base colors and their tints.
% Most prominent is \Model{cmyk} separation, where the base colors are \Color{cyan}, \Color{magenta}, \Color{yellow}, and \Color{black}, as required by the printers.
% This can be done by choosing the package option \Option{cmyk}, such that all colors will be converted in this model, and post-processing the output file.
% We describe now another --- and more general --- solution: \emph{color masking}.
% How does it work?
% Color masking is based on a specified color model \Meta{m-model} and a parameter vector \Meta{m-spec}.
% Whenever a color is to be displayed in the document, it will first be converted to \Meta{m-model}, afterwards each component of the resulting color vector will be multiplied by the corresponding component of \Meta{m-spec}.
% For example, let's assume that \Meta{m-model} equals |cmyk|, and \Meta{m-spec} equals $(\mu_c,\mu_m,\mu_y,\mu_k)$.
% Then an arbitrary color \Color{foo} will be transformed according to
% \begin{gather}
% \Color{foo} \mapsto (c,m,y,k) \mapsto (\mu_c\cdot c,\mu_m\cdot m,\mu_y\cdot y,\mu_k\cdot k)
% \end{gather}
% Obviously, color separation is a special case of masking by the vectors $(1,0,0,0)$, $(0,1,0,0)$, etc.
% An interesting application is to shade or tint all colors by masking them with $(x,x,x)$ in the \Model{rgb} or \Model{cmy} model, see the last two rows in figure \vref{fig.mask}.
%
% \medskip
%
% \DescribeMacro\maskcolors
%   \oarg{num model}\marg{color}\\
% Initialises all necessary parameters for color masking:
% if \Meta{num model} is not specified (or empty), \Meta{m-model} will be set to the natural model of \Meta{color}, otherwise to \Meta{num model};
% the color specification of \Meta{color} is extracted to define \Meta{m-spec}.
% Additionally, |\maskcolorstrue| is performed.
% \DescribeMacro\ifmaskcolors
% Color masking can be switched off temporarily by |\maskcolorsfalse|, or --- in a more radical way --- by |\maskcolors{}|, which in addition clears the initialisation parameters.
% \DescribeMacro\xglobal
% In general, the scope of |\maskcolors| is the current group (unless it is prefixed by the |\xglobal| command), but it may be used in the document preamble as well.
% The final remark of the color blending section applies here similarly.
%
% Now it is easy to separate a complete document without touching the source code:
% |latex| |\def\xcolorcmd{\maskcolors[cmyk]{cyan}}\input{a}| will do the \Color{cyan} part of the job for |a.tex|.
%
% \DescribeMacro\colormask
% Caution: \XC{} has no idea about colors in files that are included via the command |\includegraphics|, e.g.{} images of type \File{eps}, \File{pdf}, \File{jpg}, or \File{png}.
% Such files have to be separated separately.
% Nevertheless, \XC{} offers some basic support by storing the mask color in |\colormask|, which can be used to decide which file is to be included:
% \begin{verbatim}
% \def\temp{cyan}\ifx\colormask\temp \includegraphics{foo_c}\else
% \def\temp{magenta}\ifx\colormask\temp \includegraphics{foo_m}\else
% ...
% \fi\fi
% \end{verbatim}
%
% \begin{figure}[htbp]\caption{Color masking --- Example}\label{fig.mask}
% \bigskip\centering\small
% \extrarowheight2pt
% \makeatletter
% \def\X#1#2%
%  {\edef\tmp{\@ifxempty{#1}{}{[#1]}{#2}}\dots\Meaning{tmp}&
%   \maskcolors[#1]{#2}\testclr{red} \testclr{green} \testclr{blue} \testclr{cyan} \testclr{magenta} \testclr{yellow} \testclr{orange} \testclr{violet} \testclr{purple} \testclr{brown} \testclr{black} \testclr{darkgray} \testclr{gray} \testclr{lightgray} \testclr{white}\\}
% \makeatother
% \begin{tabular}{@{}>{\ttfamily}l@{ }l@{}}
% \string\maskcolors&\\
% \hline
% \X{}{}
% \hline
% \X{cmyk}{cyan}
% \X{cmyk}{magenta}
% \X{cmyk}{yellow}
% \X{cmyk}{black}
% \hline
% \X{cmyk}{red}
% \X{cmyk}{green}
% \X{cmyk}{blue}
% \hline
% \X{rgb}{red}
% \X{rgb}{green}
% \X{rgb}{blue}
% \hline
% \X{hsb}{red}
% \X{hsb}{green}
% \X{hsb}{blue}
% \hline
% \X{rgb}{gray}
% \X{cmy}{gray}
% \end{tabular}
% \end{figure}
%
%
%
% \subsection{Color series}\label{sec.series}
%
% Automatic coloring may be useful in graphics or chart applications, where a --- potentially large and unspecified --- number of colors are needed, and the user does not want or is not able to specify each individual color.
% Therefore, we introduce the term \emph{color series}, which consists of a base color and a scheme, how the next color is being constructed from the current color.
%
% The practical application consists of three parts:
% definition of a color series (usually once in the document), initialisation of the series (potentially several times), and application --- with or without stepping --- of the current color of the series (potentially many times).
%
%
% \subsubsection{Definition of a color series}
%
% \DescribeMacro\definecolorseries
%   \marg{name}\marg{core model}\marg{method}\oarg{b-model}\marg{b-spec}\oarg{s-model}\marg{s-spec}\\
% Defines a color series called \Meta{name}, whose calculations are performed within the color model \Meta{core model}, where \Meta{method} selects the algorithm (one of |step|, |grad|, |last|, see below).
% The method details are determined by the remaining arguments:
% \begin{itemize}
% \item \oarg{b-model}\marg{b-spec} specifies the \emph{base} (= first) color in the algorithm, either directly, e.g.\ |[rgb]{1,0.5,0.5}|, or as a \Meta{color}, e.g.\ |{-yellow!50}|, if the optional argument is missing.
% \item \oarg{s-model}\marg{s-spec} specifies how the \emph{step} vector is calculated in the algorithm, according to the chosen \Meta{method}:
%   \begin{itemize}
%   \item |step|,\ |grad|:\ the optional argument is meaningless, and \Meta{s-spec} is a parameter vector whose dimension is determined by \Meta{core model}, e.g.\ |{0.1,-0.2,0.3}| in case of |rgb|, |cmy|, or |hsb|.
%   \item |last|:\ the last color is specified either directly, e.g.\ |[rgb]{1,0.5,0.5}|, or as a \Meta{color}, e.g.\ |{-yellow!50}|, if the optional argument is missing.
%   \end{itemize}
% \end{itemize}
% This is the general scheme:
% \begin{gather}
% \emph{color}_1 := \emph{base},\qquad
% \emph{color}_{n+1} := U\bigl(\emph{color}_{n} + \emph{step}\bigr)
% \end{gather}
% for $n=1,2,\dots$, where $U$ maps arbitrary real $m$-vectors into the unit $m$-cube:
% \begin{gather}
% U(x_1,\dots,x_m) = (u(x_1),\dots,u(x_m)),\qquad
% u(x) =
% \begin{cases}
%  1 & \text{if $x=1$}\\
%  x-[x]& \text{if $x\neq1$}\\
% \end{cases}\label{eq.U}
% \end{gather}
% Thus, every step of the algorithm yields a valid color with parameters from the interval $[0,1]$.
%
% \medskip
% Now, the different methods use different schemes to calculate the \emph{step} vector:
% \begin{itemize}
% \item |step|,\ |grad|:\ the last argument, \marg{s-spec}, defines the directional vector \emph{grad}.
% \item |last|:\ \marg{s-spec} resp.\ \oarg{s-model}\marg{s-spec} defines the color parameter vector \emph{last}.
% \end{itemize}
% Then, during |\resetcolorseries|, the actual \emph{step} vector is calculated:
% \begin{gather}
% \emph{step} :=
% \begin{cases}
% \emph{grad} & \text{if $\Meta{method} = |step|$}\\
% \frac1{\Meta{div}}\cdot\emph{grad} & \text{if $\Meta{method} = |grad|$}\\
% \frac1{\Meta{div}}\cdot(\emph{last}-\emph{base}) & \text{if $\Meta{method} = |last|$}\\
% \end{cases}\label{eq.cs}
% \end{gather}
% Please note that it is also possible to use the current color placeholder `.' within the definition of color series.
% Thus, |\definecolorseries{foo}{rgb}{last}{.}{-.}| will set up a series that starts with the current color and ends with its complement.
% Of course, similar to \TeX's |\let| primitive, the \emph{current} definition of the current color at the time of execution is used, there is no relation to current colors in any later stage of the document.
%
%
% \subsubsection{Initialisation of a color series}
%
% \DescribeMacro\resetcolorseries
%   \oarg{div}\marg{name}\\
% This command has to be applied at least once, in order to make use of the color series \Meta{name}.
% It resets the current color of the series to the base color and calculates the actual step vector according to the chosen \Meta{div}, a non-zero real number, for the methods |grad| and |last|, see equation (\ref{eq.cs}).
% \DescribeMacro\colorseriescycle
% If the optional argument is empty, the value stored in the macro |\colorseriescycle| is applied.
% Its default value is \colorseriescycle, which can be changed by |\def\colorseriescycle|\marg{div}, applied \emph{before} the \XCP{} is loaded (similar to |\rangeRGB| and friends).
% The optional argument is ignored in case of the |step| method.
%
%
% \subsubsection{Application of a color series}
%
% There are two ways to display the current color of a color series:
% any of the \emph{color expressions} in section \vref{sec.term} used within a |\color|, |\textcolor|, \dots{} command will display this color according to the usual syntax of such expressions.
% However, in the cases when \Meta{postfix} equals `|!!+|', |\color{|\Meta{name}|!!+}| etc., will not only display the color, but it will also perform a step operation.
% Thus, the current color of the series will be changed in that case.
% An expression |\color{|\Meta{name}|!![|\Meta{num}|]}| enables direct access to an element of a series, where \Meta{num} = $0,1,2,\dots$, starting with~0 for the base color.
% See figure \vref{fig.csx} for a demonstration of different methods.
%
%
% \begin{figure}[htbp]\caption{Color series --- Example}\label{fig.csx}
% \bigskip\centering
% \def\tabulartest
% {\resetcolorseries[12]{test}%
%  \rowcolors[\hline]{1}{test!!+}{test!!+}%
%  \begin{tabular}{c}
%  \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
%  \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
%  \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
%  \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
%  \end{tabular}}
%
% \begin{tabular}{@{}*{9}{c}@{}}
% $S_1$ & $S_2$ & $G_1$ & $G_2$ & $L_1$ & $L_2$ & $L_3$ & $L_4$ & $L_5$ \\[3pt]
% \definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}\tabulartest &
% \definecolorseries{test}{hsb}{step}[hsb]{.575,1,1}{.11,-.05,0}\tabulartest &
% \definecolorseries{test}{rgb}{grad}[rgb]{.95,.85,.55}{3,11,17}\tabulartest &
% \definecolorseries{test}{hsb}{grad}[hsb]{.575,1,1}{.987,-.234,0}\tabulartest &
% \definecolorseries{test}{rgb}{last}[rgb]{.95,.85,.55}[rgb]{.05,.15,.55}\tabulartest &
% \definecolorseries{test}{hsb}{last}[hsb]{.575,1,1}[hsb]{-.425,.15,1}\tabulartest &
% \definecolorseries{test}{rgb}{last}{yellow!50}{blue}\tabulartest &
% \definecolorseries{test}{hsb}{last}{yellow!50}{blue}\tabulartest &
% \definecolorseries{test}{cmy}{last}{yellow!50}{blue}\tabulartest \\
% \end{tabular}
%
% \bigskip
%
% \footnotesize
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{>{$}l<{$}l}
% \hline
% \multicolumn2{>{\columncolor{tableheadcolor}}c}{\em Individual definitions}\\
% S_1& |\definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}|\\
% S_2& |\definecolorseries{test}{hsb}{step}[hsb]{.575,1,1}{.11,-.05,0}|\\
% G_1& |\definecolorseries{test}{rgb}{grad}[rgb]{.95,.85,.55}{3,11,17}|\\
% G_2& |\definecolorseries{test}{hsb}{grad}[hsb]{.575,1,1}{.987,-.234,0}|\\
% L_1& |\definecolorseries{test}{rgb}{last}[rgb]{.95,.85,.55}[rgb]{.05,.15,.55}|\\
% L_2& |\definecolorseries{test}{hsb}{last}[hsb]{.575,1,1}[hsb]{-.425,.15,1}|\\
% L_3& |\definecolorseries{test}{rgb}{last}{yellow!50}{blue}|\\
% L_4& |\definecolorseries{test}{hsb}{last}{yellow!50}{blue}|\\
% L_5& |\definecolorseries{test}{cmy}{last}{yellow!50}{blue}|\\
% \hline
% \multicolumn2{>{\columncolor{tableheadcolor}}c}{\em Common definitions}\\
% \hiderowcolors
% &|\resetcolorseries[12]{test}|\\
% &|\rowcolors[\hline]{1}{test!!+}{test!!+}|\\
% &|\begin{tabular}{c}|\\
% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\
% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\
% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\
% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\
% &|\end{tabular}|\\
% \hline
% \end{tabular}
% \end{figure}
%
%
% \subsubsection{Differences between colors and color series}
%
% Although they behave similar if applied within color expressions, the objects defined by |\definecolor| and |\definecolorseries| are fundamentally different with respect to their scope/availability:
% like \LC's original |\definecolor| command, |\definecolor| generates \emph{local} colors, whereas |\definecolorseries| generates \emph{global} objects (otherwise it would not be possible to use the stepping mechanism within tables or graphics conveniently).
% E.g., if we assume that |bar| is an undefined color, then after saying
% \begin{verbatim}
% \begingroup
% \definecolorseries{foo}{rgb}{last}{red}{blue}
% \resetcolorseries[10]{foo}
% \definecolor{bar}{rgb}{.6,.5,.4}
% \endgroup
% \end{verbatim}
% commands like |\color{foo}| or |\color{foo!!+}| may be used without restrictions, whereas |\color{bar}| will give an error message.
% However, it is possible to say |\colorlet{bar}{foo}| or |\colorlet{bar}{foo!!+}| in order to save the current color of a series locally --- with or without stepping.
%
%
%
% \subsection{Border colors for hyperlinks}\label{sec.hyperref}
%
% The \Package{hyperref} package offers all kinds of support for hyperlinks, pdfmarks etc.
% There are two standard ways to make hyperlinks visible (see the package documentation \cite{hyperref} for additional information on how to set up these features):
% \begin{itemize}
% \item print hyperlinks in a different color than normal text, using the keys \Key{citecolor}, \Key{filecolor}, \Key{linkcolor}, \Key{menucolor}, \Key{pagecolor}, \Key{runcolor}, \Key{urlcolor} with color expressions, e.g.~|\hypersetup{urlcolor=-green!50}|;
% \item display a colored border around hyperlinks, using the keys \Key{citebordercolor}, \Key{filebordercolor}, \Key{linkbordercolor}, \Key{menubordercolor}, \Key{pagebordercolor}, \Key{runbordercolor}, \Key{urlbordercolor} with explicit numerical \Model{rgb} parameter specification, e.g.~|\hypersetup{urlbordercolor={1 0.5 0.25}}|.
% \end{itemize}
% Obviously, the second method is somewhat inconvenient since it does not allow for color names or even color expressions.
% Therefore, \XC{} provides --- via the package option \Option{hyperref} --- a set of extended keys \Key{xcitebordercolor}, \Key{xfilebordercolor}, \Key{xlinkbordercolor}, \Key{xmenubordercolor}, \Key{xpagebordercolor}, \Key{xrunbordercolor}, \Key{xurlbordercolor} which are being used in conjunction with color expressions, e.g.~|\hypersetup{xurlbordercolor=-green!50}|.
%
% Another new key, \Key{xpdfborder}, provides a way to deal with a |dvips|-related problem:
% for most of the drivers, a setting like |pdfborder={0 0 1}| will determine the width of the border that is drawn around hyperlinks in points.
% However, in the |dvips| case, the numerical parameters are interpreted in relation to the chosen output resolution for processing the |dvi| file into a |ps| file.
% Unfortunately, at the time when the |dvi| is constructed, nobody knows if and at which resolution a transformation into |ps| will take place afterwards.
% Consequently, any default value for \Key{pdfborder} may be useful or not.
% Within \Package{hyperref}, the default for |dvips| is |pdfborder={0 0 12}|, which works fine for a resolution of 600 or 1200 dpi, but which produces an invisible border for a resolution of 8000 dpi, as determined by the command-line switch |-Ppdf|.
% On the other hand, setting |pdfborder={0 0 80}| works fine for |dvips| at 8000 dpi, but makes a document unportable, since other drivers (or even |dvips| in a low resolution) will draw very thick boxes in that case.
% This is were the \Key{xpdfborder} key comes in handy: it rescales its arguments for the |dvips| case by a factor 80 (ready for 8000 dpi) and leaves everything unchanged for other drivers.
% Thus one can say |xpdfborder={0 0 1}| in a driver-independent way.
%
%
%
% \subsection{Color in tables}
%
% \DescribeMacro\rowcolors
%   \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\
% \DescribeMacro{\rowcolors*}
%   \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\
% One of these commands has to be executed \emph{before} a table starts.
% \Meta{row} tells the number of the first row which should be colored according to the \Meta{odd-row color} and \Meta{even-row color} scheme.
% Each of the color arguments may also be left empty (= no color).
% In the starred version, \Meta{commands} are ignored in rows with inactive \emph{rowcolors status} (see below), whereas in the non-starred version, \Meta{commands} are applied to every row of the table.
% Such optional commands may be |\hline| or |\noalign|\marg{stuff}.
%
% \DescribeMacro\showrowcolors
% \DescribeMacro\hiderowcolors
% The \emph{rowcolors status} is activated (i.e., use coloring scheme) by default and/or |\showrowcolors|, it is inactivated (i.e., ignore coloring scheme) by the command |\hiderowcolors|.
% \DescribeMacro\rownum
% The counter |\rownum| may be used within such a table to access the current row number.
% An example is given in figure \vref{fig.row}.
% These commands require the \Package{colortbl} package.
%
% Note that table coloring may be combined with color series.
% This method was used to construct the examples in figure \vref{fig.csx}.
%
% \begin{figure}[htbp]\caption{Alternating row colors in tables: \cmd\rowcolors{} vs. \cmd\rowcolors\texttt*}\label{fig.row}
% \centering
% \begin{minipage}{\textwidth}
% \vspace*{3ex}
% \begin{verbatim}
% \rowcolors[\hline]{3}{green!25}{yellow!50} \arrayrulecolor{red!75!gray}
% \begin{tabular}{ll}
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% \arrayrulecolor{black}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \rowcolor{blue!25}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \hiderowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \showrowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \multicolumn{1}%
%  {>{\columncolor{red!12}}l}{test} & row \number\rownum\\
% \end{tabular}
% \end{verbatim}
% \end{minipage}
% \hskip-.5\textwidth
% \rowcolors[\hline]{3}{green!25}{yellow!50} \arrayrulecolor{red!75!gray}
% \begin{tabular}{ll}
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% \arrayrulecolor{black}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \rowcolor{blue!25}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \hiderowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \showrowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \multicolumn{1}%
%  {>{\columncolor{red!12}}l}{test} & row \number\rownum\\
% \end{tabular}
% \qquad
% \rowcolors*[\hline]{3}{green!25}{yellow!50}\arrayrulecolor{red!75!gray}
% \begin{tabular}{ll}
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% \arrayrulecolor{black}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \rowcolor{blue!25}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \hiderowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \showrowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \multicolumn{1}%
%  {>{\columncolor{red!12}}l}{test} & row \number\rownum\\
% \end{tabular}
% \arrayrulecolor{black}
% \end{figure}
%
%
%
% \subsection{Color information}\label{sec.info}
%
% \DescribeMacro\extractcolorspec
%   \marg{color}\marg{cmd}\\
% Extracts the color specification of \Meta{color} and puts it into \marg{cmd}; equivalent to |\def\cmd{|\marg{model}\marg{spec}|}|.
%
% \medskip
% \DescribeMacro\tracingcolors
%   |=|\Meta{int}\\
% Controls the amount of information that is written into the |log| file:
% \begin{itemize}
% \item \mbox{$\Meta{int}\le0$:}~no specific color logging.
% \item \mbox{$\Meta{int}\ge1$:}~ignored color definitions due to |\providecolor| are logged.
% \item \mbox{$\Meta{int}\ge2$:}~multiple (i.e.~overwritten) color definitions are logged.
% \item \mbox{$\Meta{int}\ge3$:}~every command that defines a color will be logged.
% \item \mbox{$\Meta{int}\ge4$:}~every command that sets a color will be logged.
% \end{itemize}
% Like \TeX's |\tracing...| commands, this command may be used globally (in the document preamble) or locally/block-wise.
% The package sets |\tracingcolors=0| as default.
% Remark: since registers are limited and valuable, no counter is wasted for this issue.
%
% Note that whenever a color is used that has been defined via \LC's |\definecolor| command rather than \XC's new |\definecolor| and friends, a warning message `Incompatible color definition' will be issued.\footnote{This should not happen since usually there is no reason to load \LC{} in parallel to \XC{}.}
%
%
%
% \subsection{Color conversion}
%
% \DescribeMacro\convertcolorspec
%   \marg{model}\marg{spec}\marg{target model}\marg{cmd}\\
% Converts a color, given by the \Meta{spec} in model \Meta{model}, into \Meta{target model} and stores the new color specification in |\cmd|.
% \Meta{target model} must be of type \Meta{num model}, whereas \Meta{model} may also be `named', in which case \Meta{spec} is simply the name of the color.
%
%
%
%
% \section{Technical Supplement}
%
% \subsection{Color models supported by drivers}
%
% Since some of the drivers only pretend to support the \Model{hsb} model, we included some code to bypass this behaviour.
% The models actually added by \XC{} are shown in the log file.
% Table \vref{tab.drv} lists the drivers that are part of current MiK\TeX{} \cite{mik} distributions and their color model support.
% Probably, other distributions behave similarly.
%
% \begin{table}[htbp]\caption{Drivers and color models}\label{tab.drv}
% \bigskip\centering\small
% \extrarowheight1pt
% \tabcolsep3pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{ll*{9}{c}}
% \rowcolor{tableheadcolor}
% \hline
% \em Driver&\em Version&\Model{rgb}&\Model{cmy}&\Model{cmyk}&\Model{hsb}&\Model{gray}&\Model{RGB}&\Model{HTML}&\Model{HSB}&\Model{Gray}\\
% \Option{dvipdf}&1999/02/16 v3.0i&d&n&d&n&d&i&n&n&n\\
% \Option{dvips}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\
% \Option{dvipsone}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\
% \Option{pctex32}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\
% \Option{pctexps}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\
% \hline
% \Option{pdftex}&2002/06/19 v0.03k&d&n&d&n&d&i&n&n&n\\
% \hline
% \Option{dvipdfm}&1998/11/24 vx.x\,\footnotemark[1]&d&n&d&a&d&i&n&n&n\\
% \Option{dvipdfm}&1999/9/6 vx.x\,\footnotemark[2]&d&n&d&a&d&i&n&n&n\\
% \hline
% \Option{textures}&1997/5/28 v0.3&d&n&d&a&i&n&n&n&n\\
% \hline
% \Option{vtex}&1999/01/14 v6.3&d&n&d&n&i&i&n&n&n\\
% \hline
% \Option{tcidvi}&1999/02/16 v3.0i&i&n&i&n&i&d&n&n&n\\
% \Option{truetex}&1999/02/16 v3.0i&i&n&i&n&i&d&n&n&n\\
% \hline
% \Option{dviwin}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\
% \Option{emtex}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\
% \Option{pctexhp}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\
% \Option{pctexwin}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\
% \hline\hline
% \multicolumn{10}c{\Option{dviwindo} = \Option{dvipsone}; \Option{oztex} = \Option{dvips}; \Option{xdvi} = \Option{dvips} + \Option{monochrome}}\\
% \multicolumn{10}c{\footnotemark[1]\,part of \Package{graphics} package\quad \footnotemark[2]\,additionally distributed with MiK\TeX}\\
% \hline
% \multicolumn{10}c{Driver's color model support: d = direct, i = indirect, a = alleged, n = none}\\
% \hline
% \end{tabular}
% \end{table}
%
%
%
% \subsection{Behind the scenes: internal color representation}
%
% Every definition of a color in order to access it by its name requires an internal representation of the color, i.e.~a macro that contains some bits of information required by the driver to display the color properly.
%
% \LC's |\definecolor{foo}{...}{...}| generates a command |\\color@foo|\footnote{The double backslash is intentional.} which contains the color definition in a driver-dependent way; therefore it is possible but non-trivial to access the color model and parameters afterwards (see the \Package{colorinfo} package \cite{colorinfo} for a solution).
%
% \LC's |\DefineNamedColor{named}{foo}{...}{...}| generates |\col@foo|\footnote{The single backslash is intentional.} which again contains some driver-dependent information.
% In this case, an additional |\\color@foo| will only be defined if the package option \Option{usecolors} is active.
%
% \XC's |\definecolor{foo}{...}{...}| generates\footnote{This was introduced in version 1.10; prior to that, a command \cs{\string\xcolor@foo} with a different syntax was generated.} a command |\\color@foo| as well, which combines the features of the former commands and contains both the driver-dependent and driver-independent information, thus making it possible to access the relevant parameters in a standardised way.
% Although it has now a different syntax, |\\color@foo| expands to the same expression as the original command.
% On the other hand, |\col@foo| commands are no longer needed and therefore not generated in the `named' case: \XC{} works with a single color data structure (as described).
%
% Table \vref{tab.internal} shows some examples for the two most prominent drivers.
% See also figures \vrefrange{fig.MyGreen}{fig.MyGreen-gray}; the lines immediately below the captions display the definitions with respect to the driver that was used to process this document.
%
%
% \begin{table}[htb]\caption{Driver-dependent internal color representation}\label{tab.internal}
% \bigskip\centering\small
% \def\X{\hspace*{-.845\textwidth}\\}
% \extrarowheight1pt
% \tabcolsep8pt
% \begin{tabular}{l>{\color{blue}(}r<{)}l}
% \hline
% \multicolumn3{>{\columncolor{tableheadcolor}}l}{\Option{dvips} driver}\\
% \hline
% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}| & \LC\\
% |->rgb .5 0 1.|\X
% \hline
% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}|& \XC\\
% |->\xcolor@ {}{rgb 0.5 0 1}{rgb}{0.5,0,1}.|\X
% \hline
% |\col@Plum=macro:| & |\DefineNamedColor{Plum}{rgb}{.5,0,1}|& \LC\\
% |->\@nil .|\X
% |\\color@Plum=macro:| & with option \Option{usenames}\\
% |-> Plum.|\X
% \hline
% |\\color@Plum=macro:| & |\definecolor[named]{Plum}{rgb}{.5,0,1}|& \XC\\
% |->\xcolor@ {\@nil }{ Plum}{rgb}{0.5,0,1}.|\X
% \hline
% \multicolumn3{>{\columncolor{tableheadcolor}}l}{\Option{pdftex} driver}\\
% \hline
% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}|& \LC\\
% |->.5 0 1 rg .5 0 1 RG.|\X
% \hline
% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}|& \XC\\
% |->\xcolor@ {}{0.5 0 1 rg 0.5 0 1 RG}{rgb}{0.5,0,1}.|\X
% \hline
% |\col@Plum=macro:| & |\DefineNamedColor{Plum}{rgb}{.5,0,1}|& \LC\\
% |->.5 0 1 rg .5 0 1 RG.|\X
% |\\color@Plum=macro:| & with option \Option{usenames}\\
% |->.5 0 1 rg .5 0 1 RG.|\X
% \hline
% |\\color@Plum=macro:| & |\definecolor[named]{Plum}{rgb}{.5,0,1}|& \XC\\
% |->\xcolor@ {0.5 0 1 rg 0.5 0 1 RG}{0.5 0 1 rg 0.5 0 1 RG}{rgb}{0.5,0,1}.|\X
% \hline
% \end{tabular}
% \end{table}
%
%
%
% \subsection{A remark on accuracy}
%
% Since the macros presented here require some computation, special efforts were made to ensure a maximum of accuracy for conversion and mixing formulas --- all within \TeX's limited numerical capabilities.\footnote{For example, applying the `transformation' \cs{dimen0=0.}\Meta{int}\texttt{pt} \cs{the\string\dimen0} to all 5-digit numbers \Meta{int} of the range 00000\dots 99999, exactly 34464 of these 100000 numbers don't survive unchanged. We are not talking about gobbled final zeros here \dots}
% We decided to develop and include a small set of commands to improve the quality of division and multiplication results, instead of loading one of the packages that provide multi-digit arithmetic and a lot more, like \Package{realcalc} or \Package{fp}.
% The marginal contribution of the latter packages seems not to justify their usage for our purposes.
% Thus, we stay within a sort of fixed-point arithmetic framework, providing at most 5~decimal digits via \TeX's dimension registers.
%
%
%
%
% \section{The Formulas}
%
% \subsection{Color mixing}
%
% In general, we use linear interpolation for color mixing:
% \begin{align}
% \mix(C, C', p) = p \cdot C + (1-p) \cdot C'\label{eq.mix}
% \end{align}
% Note that there is a special situation in the \Model{hsb} case:
% if $\emph{saturation}=0$ then the color equals a gray color of level \emph{brightness}, independently of the \emph{hue} value.
% Therefore, to achieve smooth transitions of an arbitrary color to a specific gray (like white or black), we actually use the formulas
% \begin{align}
% \Op\tint{hsb}(C, p) &= p \cdot C + (1-p) \cdot \bigl(\emph{hue},0,1\bigr)\\
% \Op\shade{hsb}(C, p) &= p \cdot C + (1-p) \cdot \bigl(\emph{hue},0,0\bigr)\\
% \Op\tone{hsb}(C, p) &\textstyle= p \cdot C + (1-p) \cdot \bigl(\emph{hue},0,\frac12\bigr)
% \end{align}
% where $C=(\emph{hue},\emph{saturation},\emph{brightness})$.
%
% \XCchanges110{Added formula for general color expressions.}
% From equation (\ref{eq.mix}) and the way how color expressions are being interpreted, as described in section \vref{sec.term}, it is an easy proof by induction to verify that a color expression
% \begin{gather}
% C_0!P_1!C_1!P_2!\dots!P_n!C_n
% \end{gather}
% with $n\in\{0,1,2,\dots\}$, colors $C_0,C_1,\dots,C_n$, and percentages $P_1,\dots,P_n\in [0,100]$ will result in a parameter vector
% \begin{equation}
% \begin{split}
% C &= \sum_{\nu=0}^n \Biggl(\prod_{\mu=\nu+1}^n p_\mu \Biggr) (1-p_\nu)\cdot C_\nu\\
%   &= p_n\cdots p_1\cdot C_0\\
%   &\quad + p_n\cdots p_2(1-p_1)\cdot C_1\\
%   &\quad + p_n\cdots p_3(1-p_2)\cdot C_2\\
%   &\quad + \dots\\
%   &\quad + p_n(1-p_{n-1})\cdot C_{n-1}\\
%   &\quad + (1-p_n)\cdot C_n
% \end{split}
% \end{equation}
% where $p_0 := 0$ and $p_\nu := P_\nu/100$ for $\nu=1,\dots,n$.
% We note also a split formula:
% \begin{equation}
% \begin{split}
% C_0!P_1!C_1!\dots!P_{n+k}!C_{n+k}
%  &= p_{n+k}\cdots p_{n+1}\cdot C_0!P_1!C_1!\dots!P_n!C_n\\
%  &\quad - p_{n+k}\cdots p_{n+1}\cdot C_n\\
%  &\quad + C_n!P_{n+1}!C_{n+1}!\dots!P_{n+k}!C_{n+k}
% \end{split}
% \end{equation}
%
%
% \begin{table}[p]\caption{Color constants}\label{tab.const}
% \bigskip\centering
% \extrarowheight2pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{*4{c}}
% \hline
% \rowcolor{tableheadcolor}
% \emph{model/constant} &
%       \ttfamily white  &  \ttfamily black & \ttfamily gray\\[2pt]
% \Model{rgb}&  $(1,1,1)$   & $(0,0,0)$   & $(\frac12,\frac12,\frac12)$ \\[2pt]
% \Model{cmy}&  $(0,0,0)$   & $(1,1,1)$   & $(\frac12,\frac12,\frac12)$ \\[2pt]
% \Model{cmyk}& $(0,0,0,0)$ & $(0,0,0,1)$ & $(0,0,0,\frac12)$ \\[2pt]
% \Model{hsb}&  $(h,0,1)$   & $(h,0,0)$   & $(h,0,\frac12)$ \\[2pt]
% \Model{gray}& $1$ & $0$ & $\frac12$ \\[2pt]
% \Model{RGB}&  $(L,L,L)$ & $(0,0,0)$ & $(\lfloor\frac {L+1}2\rfloor,\lfloor\frac {L+1}2\rfloor,\lfloor\frac {L+1}2\rfloor)$ \\[2pt]
% \Model{HTML}& \texttt{FFFFFF}& \texttt{000000}& \texttt{808080}\\[2pt]
% \Model{HSB}&  $(H,0,M)$ & $(H,0,0)$ & $(H,0,\lfloor\frac {M+1}2\rfloor)$ \\[2pt]
% \Model{Gray}& $N$ & $0$ & $\lfloor\frac {N+1}2\rfloor$ \\[2pt]
% \hline
% \end{tabular}
% \end{table}
%
%
% \begin{table}[p]\caption{Color conversion pairs}\label{tab.cnv}
% \bigskip\centering\small
% \def\Em#1{\Model{#1}}
% \def\sp{\hbox to3em{\hfil$\ast$\hfil}}
% \def\id{\textrm{id}}
% \extrarowheight1pt
% \tabcolsep3pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{c*9{>{\sffamily}c}}
% \rowcolor{tableheadcolor}
% \hline
% \emph{from/to}&
%            \Em{rgb}& \Em{cmy}& \Em{cmyk}& \Em{hsb}& \Em{gray}& \Em{RGB}& \Em{HTML}& \Em{HSB}& \Em{Gray}\\
% \Em{rgb}&  \id     & \sp     & (cmy)    & \sp     & \sp      & \sp     & \sp      & (hsb)   & (gray)\\
% \Em{cmy}&  \sp     & \id     & \sp      & (rgb)   & \sp      & (rgb)   & (rgb)    & (rgb)   & (gray)\\
% \Em{cmyk}& (cmy)   & \sp     & \id      & (cmy)   & \sp      & (cmy)   & (cmy)    & (cmy)   & (gray)\\
% \Em{hsb}&  \sp     & (rgb)   & (rgb)    & \id     & (rgb)    & (rgb)   & {rgb}    & \sp     & (rgb)\\
% \Em{gray}& \sp     & \sp     & \sp      & \sp     & \id      & \sp     & \sp      & \sp     & \sp\\
% \Em{RGB}&  \sp     & (rgb)   & (rgb)    & (rgb)   & (rgb)    & \id     & (rgb)    & (rgb)   & (rgb)\\
% \Em{HTML}& \sp     & (rgb)   & (rgb)    & (rgb)   & (rgb)    & (rgb)   & \id      & (rgb)   & (rgb)\\
% \Em{HSB}&  (hsb)   & (hsb)   & (hsb)    & \sp     & (hsb)    & (hsb)   & (hsb)    & \id     & (hsb)\\
% \Em{Gray}& (gray)  & (gray)  & (gray)   & (gray)  & \sp      & (gray)  & (gray)   & (gray)  & \id\\
% \hline\hline
% \multicolumn{10}{c}{\id{} = identity function; $\ast$ = specific conversion function;}\\
% \multicolumn{10}{c}{\textsf{(model)} = conversion via specified model}\\
% \hline
% \end{tabular}
% \end{table}
%
%
%
% \subsection{Conversion between integer and real models}
%
% We fix a positive integer $n$ and define the sets $\mathcal I_n:=\{0,1,\dots,n\}$ and $\mathcal R:= [0,1]$.
% The complement of $\nu\in\mathcal I_n$ is $n-\nu$, the complement of $x\in\mathcal R$ is $1-x$.
%
% \subsubsection{Real to integer conversion}\label{sec.real2int}
%
% The straightforward mapping for this case is
% \begin{gather}
% \textstyle\RtoI n : \mathcal R \to \mathcal I_n,\ x \mapsto \rd(n\cdot x) = \left\lfloor \frac12+n\cdot x\right\rfloor
% \end{gather}
% This mapping nearly always preserves complements, as shown in the next lemma.
% \begin{lemma}[Preservation of complements]
% For $x\in\mathcal R$,
% \begin{gather}
% \textstyle\RtoI n(x) + \RtoI n(1-x) = n \iff x \notin \mathcal R_n^\circ := \left\{ \frac1n\bigl(\nu - \frac12\bigr) \bigm\vert \nu=1,2,\dots,n\right\}.
% \end{gather}
% \end{lemma}
% \begin{proof}
% Let $\nu:=\RtoI n(x)$, then from $-\frac12 \le \eta := n\cdot x - \nu < \frac12$ we conclude
% \begin{gather*}
% \textstyle \RtoI n(1-x) = \rd(n(1-x)) = \rd(n-\nu-\eta) =
% \begin{cases}
%  n-\nu   & \text{if $\eta\neq-\frac12$}\\
%  n-\nu+1 & \text{if $\eta=-\frac12$}
% \end{cases}
% \end{gather*}
% Now, $\eta = -\frac12 \iff x = \frac1n\bigl(\nu-\frac12\bigr) \iff x\in\mathcal I_n'$.
% \end{proof}
% Remark: the set $\mathcal R_n^\circ$ is obviously identical to the set of points where $\RtoI n$ is not continuous.
%
%
% \subsubsection{Integer to real conversion}\label{sec.int2real}
%
% The straightforward way in this case is the function
% \begin{gather}
% \ItoR n^*: \mathcal I_n \to \mathcal R,\ \nu \mapsto \frac \nu n.
% \end{gather}
% This is, however, only one out of a variety of solutions: every function $\ItoR n:\mathcal I_n\to\mathcal R$ that obeys the condition
% \begin{gather}
% \nu\in\mathcal I_n \Rightarrow \Gamma_n\bigl(\ItoR n(\nu)\bigr) = \nu
% \end{gather}
% which is equivalent to
% \begin{gather}
% \nu\in\mathcal I_n \Rightarrow \nu + \frac12 > n\cdot\ItoR n(\nu) \ge \nu - \frac12\label{eq.round}
% \end{gather}
% does at least guarantee that all integers $\nu$ may be reconstructed from $\ItoR n(\nu)$ via multiplication by $n$ and rounding to the nearest integer.
% Preservation of complements means now
% \begin{gather}
% \nu\in\mathcal I_n \Rightarrow \ItoR n(\nu) + \ItoR n(n-\nu) = 1
% \end{gather}
% which is obviously the case for $\ItoR n = \ItoR n^*$.
% If we consider, more generally, a transformation
% \begin{gather}
% \ItoR n(\nu) = \frac{\nu + \alpha}{n + \beta}
% \end{gather}
% with $\beta\neq-n$, then the magic inequality (\ref{eq.round}) is equivalent to
% \begin{gather}
% \frac12 > \frac{\alpha n - \beta\nu}{n + \beta} \ge -\frac12
% \end{gather}
% which is obeyed by the function
% \begin{gather}
% \ItoR n':\mathcal I_n\to\mathcal R,\ \nu \mapsto
% \begin{cases}
% \frac\nu{n+1}& \text{if $\nu\le\frac{n+1}2$}\\[0.25ex]
% \frac{\nu+1}{n+1}& \text{if $\nu>\frac{n+1}2$}
% \end{cases}
% \end{gather}
% that has the nice feature $\ItoR n'\bigl(\frac{n+1}2\bigr) = \frac12$ for odd $n$.
% \begin{lemma}[Preservation of complements]
% For odd $n$ and each $\nu\in\mathcal I_n$,
% \begin{gather}
% \textstyle\ItoR n'(\nu) + \ItoR n'(n-\nu) = 1 \iff \nu \notin \mathcal I_n^\circ := \left\{ \frac{n-1}2, \frac{n+1}2 \right\}.
% \end{gather}
% \end{lemma}
% \begin{proof}
% The assertion is a consequence of the following arguments:
% \begin{itemize}
% \item $\nu<\frac{n-1}2 \iff n-\nu>\frac{n+1}2$ \ and \ $\frac{n-1}2 + \frac{n+1}2 = n$;
% \item $\nu<\frac{n-1}2 \,\Rightarrow\, \ItoR n'(\nu) + \ItoR n'(n-\nu) = \frac\nu{n+1} + \frac{n-\nu+1}{n+1} = 1$;
% \item $\nu=\frac{n-1}2 \,\Rightarrow\, \ItoR n'(\nu) + \ItoR n'(n-\nu) = \frac{n-1}{2(n+1)} + \frac12 = \frac n{n+1} \neq1$.\qedhere
% \end{itemize}
% \end{proof}
%
% For the time being, we choose \fbox{$\ItoR n := \ItoR n^*$} as default transformation function.
%
%
% \subsection{Color conversion and complements}\label{sec.cnv}
%
% We collect here the specific conversion formulas between the supported color models.
% Table \vref{tab.cnv} gives an overwiew of how each conversion pair is handled.
% In general, PostScript (as described in \cite{plrm}) is used as a basis for most of the calculations, since it supports the color models \Model{rgb}, \Model{cmyk}, \Model{hsb}, and \Model{gray} natively.
% Furthermore, Smith's paper \cite{smith} is cited in \cite{plrm} as reference for \Model{hsb}-related formulas.
%
% First, we define a constant which is being used throughout the conversion formulas:
% \begin{gather}
% E := (1,1,1)
% \end{gather}
% \subsubsection{The \Model{rgb} model}
%
% \paragraph{Conversion \Model{rgb} to \Model{cmy}}\label{sec.rgb2cmy}
% Source: \cite{plrm}, p. 475.
% \begin{gather}
% (\emph{cyan}, \emph{magenta}, \emph{yellow}) := E-(\emph{red}, \emph{green}, \emph{blue})
% \end{gather}
%
% \paragraph{Conversion \Model{rgb} to \Model{hsb} (1)}
% We set
% \begin{align}
% x & := \max\{\emph{red}, \emph{green}, \emph{blue}\}\\
% y & := \med\{\emph{red}, \emph{green}, \emph{blue}\}\\
% z & := \min\{\emph{red}, \emph{green}, \emph{blue}\}%\\
% \end{align}
% where `$\med$' denotes the median of the values.
% Then,
% \begin{align}
% \emph{brightness} & := x\\
% \intertext{Case $x=z$:}
% \emph{saturation} & := 0\\
% \emph{hue} & := 0\\
% \intertext{Case $x\neq z$:}
% \emph{saturation} & := \frac{x - z}x\\
% f & := \frac{x - y}{x - z}
% \end{align}
% \begin{gather}
% \emph{hue} := \frac 16\cdot
%  \begin{cases}
%  1-f & \text{if $x=\emph{red}\ge\emph{green}\ge\emph{blue}=z$}\\
%  1+f & \text{if $x=\emph{green}\ge\emph{red}\ge\emph{blue}=z$}\\
%  3-f & \text{if $x=\emph{green}\ge\emph{blue}\ge\emph{red}=z$}\\
%  3+f & \text{if $x=\emph{blue}\ge\emph{green}\ge\emph{red}=z$}\\
%  5-f & \text{if $x=\emph{blue}\ge\emph{red}\ge\emph{green}=z$}\\
%  5+f & \text{if $x=\emph{red}\ge\emph{blue}>\emph{green}=z$}
%  \end{cases}\label{eq.rgb2hsb1}
% \end{gather}
%
% \medskip
%
% This is based on \cite{smith}, \emph{RGB to HSV Algorithm (Hexcone Model)}, which reads (slightly reformulated):
% \begin{gather}
% r := \frac{x - \emph{red}}{x - z},\qquad
% g := \frac{x - \emph{green}}{x - z},\qquad
% b := \frac{x - \emph{blue}}{x - z}\\
% \emph{hue} := \frac 16\cdot
%  \begin{cases}
%  5+b & \text{if $\emph{red}=x$ and $\emph{green}=z$}\\
%  1-g & \text{if $\emph{red}=x$ and $\emph{green}>z$}\\
%  1+r & \text{if $\emph{green}=x$ and $\emph{blue}=z$}\\
%  3-b & \text{if $\emph{green}=x$ and $\emph{blue}>z$}\\
%  3+g & \text{if $\emph{blue}=x$ and $\emph{red}=z$}\\
%  5-r & \text{if $\emph{blue}=x$ and $\emph{red}>z$}
%  \end{cases}
% \end{gather}
% Note that the singular case $x=z$ is not covered completely in Smith's original algorithm; we stick here to PostScript's behaviour in real life.
%
% Because we need to sort three numbers in order to calculate $x,y,z$, several comparisons are involved in the algorithm.
% We present now a second method which is more suited for \TeX.
%
% \paragraph{Conversion \Model{rgb} to \Model{hsb} (2)}
% Let $\beta$ be a function that takes a Boolean expression as argument and returns 1 if the expression is true, 0 otherwise; set
% \begin{gather}
% i := 4\cdot\beta(\emph{red}\ge\emph{green}) + 2\cdot\beta(\emph{green}\ge\emph{blue}) + \beta(\emph{blue}\ge\emph{red}),
% \intertext{and}
% (\emph{hue},\emph{saturation},\emph{brightness}) :=
% \begin{cases}
% \Phi(\emph{blue},\emph{green},\emph{red},3,1) & \text{if $i=1$}\\
% \Phi(\emph{green},\emph{red},\emph{blue},1,1) & \text{if $i=2$}\\
% \Phi(\emph{green},\emph{blue},\emph{red},3,-1) & \text{if $i=3$}\\
% \Phi(\emph{red},\emph{blue},\emph{green},5,1) & \text{if $i=4$}\\
% \Phi(\emph{blue},\emph{red},\emph{green},5,-1) & \text{if $i=5$}\\
% \Phi(\emph{red},\emph{green},\emph{blue},1,-1) & \text{if $i=6$}\\
% (0,0,\emph{blue}) &  \text{if $i=7$}
% \end{cases}\label{eq.rgb2hsb2}
% \intertext{where}
% \Phi(x,y,z,u,v) := \Bigl( \frac{u\cdot(x-z)+v\cdot(x-y)}{6(x-z)}, \frac{x-z}x, x\Bigr)
% \end{gather}
%
% The singular case $x=z$, which is equivalent to $\emph{red}=\emph{green}=\emph{blue}$, is covered here by $i=7$.
%
% \medskip
%
% It is not difficult to see that this algorithm is a reformulation of the previous method.
% The following table explains how the transition from equation (\ref{eq.rgb2hsb1}) to equation (\ref{eq.rgb2hsb2}) works:
%
% \medskip
%
% \begin{tabular*}{\textwidth}{@{\extracolsep\fill}*5{>{$}c<{$}}l@{}}
% 6\cdot\emph{hue}& \emph{Condition}& \emph{red}\ge\emph{green}& \emph{green}\ge\emph{blue}& \emph{blue}\ge\emph{red}& $i$\\\hline
%  1-f & \emph{red}\ge\emph{green}\ge\emph{blue}& 1& 1& *& \textbf6/7\\
%  1+f & \emph{green}\ge\emph{red}\ge\emph{blue}& *& 1& *& \textbf2/3/6/7\\
%  3-f & \emph{green}\ge\emph{blue}\ge\emph{red}& *& 1& 1& \textbf3/7\\
%  3+f & \emph{blue}\ge\emph{green}\ge\emph{red}& *& *& 1& \textbf1/3/5/7\\
%  5-f & \emph{blue}\ge\emph{red}\ge\emph{green}& 1& *& 1& \textbf5/7\\
%  5+f & \emph{red}\ge\emph{blue}\ge\emph{green}& 1& *& *& \textbf4/5/6/7\\
% \end{tabular*}
%
% \medskip
%
% Here, $*$ denotes possible 0 or 1 values.
% Bold $i$~values mark the main cases where all $*$~values of a row are zero.
% The slight difference to equation (\ref{eq.rgb2hsb1}) in the last inequality is intentional and does no harm.
%
% \paragraph{Conversion \Model{rgb} to \Model{gray}}
% Source: \cite{plrm}, p. 474.
% \begin{align}
% \emph{gray} & := 0.3\cdot\emph{red} + 0.59\cdot\emph{green} + 0.11\cdot\emph{blue}
% \end{align}
%
% \paragraph{Conversion \Model{rgb} to \Model{RGB}}
% As described in section \vref{sec.real2int}.
% \begin{align}
% \emph{Red} & := \RtoI L(\emph{red})\\
% \emph{Green} & := \RtoI L(\emph{green})\\
% \emph{Blue} & := \RtoI L(\emph{blue})
% \end{align}
%
% \paragraph{Conversion \Model{rgb} to \Model{HTML}}
% As described in section \vref{sec.real2int}. Convert to hexadecimal afterwards.
% \begin{align}
% \emph{RR} & := \RtoI L(\emph{red})_{\emph{hex}}\\
% \emph{GG} & := \RtoI L(\emph{green})_{\emph{hex}}\\
% \emph{BB} & := \RtoI L(\emph{blue})_{\emph{hex}}
% \end{align}
%
% \paragraph{Complement of \Model{rgb} color}
% We simply take the complementary vector:
% \begin{gather}
% (\emph{red}^*, \emph{green}^*, \emph{blue}^*) := E - (\emph{red}, \emph{green}, \emph{blue})
% \end{gather}
%
%
% \subsubsection{The \Model{cmy} model}
%
% \paragraph{Conversion \Model{cmy} to \Model{rgb}}
% This is simply a reversion of the $\Model{rgb}\to\Model{cmy}$ case, cf. section \vref{sec.rgb2cmy}.
% \begin{gather}
% (\emph{red}, \emph{green}, \emph{blue}) := E - (\emph{cyan}, \emph{magenta}, \emph{yellow})
% \end{gather}
%
% \paragraph{Conversion \Model{cmy} to \Model{cmyk}}\label{sec.cmy2cmyk}
% This is probably the hardest of our conversion tasks: many sources emphasize that there does not exist any universal conversion algorithm for this case because of device-dependence.
% The following algorithm is an extended version of the one given in \cite{plrm}, p. 476.
% \begin{align}
% k & := \min\{\emph{cyan},\emph{magenta},\emph{yellow}\}\\
% \emph{cyan} & := \min\{1,\max\{0,\emph{cyan} - \emph{UCR}_c(k)\}\}\\
% \emph{magenta} & := \min\{1,\max\{0,\emph{magenta} - \emph{UCR}_m(k)\}\}\\
% \emph{yellow} & := \min\{1,\max\{0,\emph{yellow} - \emph{UCR}_y(k)\}\}\\
% \emph{black} & := \emph{BG}(k)
% \end{align}
% Here, four additional functions are required:
% \begin{align}
% \emph{UCR}_c, \emph{UCR}_m, \emph{UCR}_y & : [0,1] \to [-1,1]\tag*{\em undercolor-removal}\\
% \emph{BG} & : [0,1] \to [0,1]\tag*{\em black-generation}
% \end{align}
% These functions are device-dependent, see the remarks in \cite{plrm}.
% Although there are some indications that they should be chosen as nonlinear functions, as long as we have no further knowledge about the target device we define them linearly:
% \begin{align}
% \emph{UCR}_c(k) &:= \beta_c\cdot k\\
% \emph{UCR}_m(k) &:= \beta_m\cdot k\\
% \emph{UCR}_y(k) &:= \beta_y\cdot k\\
% \emph{BG}(k) &:= \beta_k\cdot k
% \end{align}
% \DescribeMacro\adjustUCRBG
% where the parameters are given by |\def\adjustUCRBG{|\Meta{$\beta_c$},\Meta{$\beta_m$},\Meta{$\beta_y$},\Meta{$\beta_k$}|}| at any point in a document, defaulting to |{|$\adjustUCRBG$|}|.
%
% \paragraph{Conversion \Model{cmy} to \Model{gray}}
% This is derived from the conversion chain $\Model{cmy}\to\Model{rgb}\to\Model{gray}$.
% \begin{align}
% \emph{gray} & := 1 - (0.3\cdot\emph{cyan} + 0.59\cdot\emph{magenta} + 0.11\cdot\emph{yellow})
% \end{align}
%
% \paragraph{Complement of \Model{cmy} color}
% We simply take the complementary vector:
% \begin{gather}
% (\emph{cyan}^*, \emph{magenta}^*, \emph{yellow}^*) := E - (\emph{cyan}, \emph{magenta}, \emph{yellow})
% \end{gather}
%
%
% \subsubsection{The \Model{cmyk} model}
%
% \paragraph{Conversion \Model{cmyk} to \Model{cmy}}\label{sec.cmyk2cmy}
% Based on \cite{plrm}, p. 477, in connection with $\Model{rgb}\to\Model{cmy}$ conversion.
% \begin{align}
% \emph{cyan} & := \min\{1,\emph{cyan} + \emph{black}\}\\
% \emph{magenta} & := \min\{1,\emph{magenta} + \emph{black}\}\\
% \emph{yellow} & := \min\{1,\emph{yellow} + \emph{black}\}
% \end{align}
%
% \paragraph{Conversion \Model{cmyk} to \Model{gray}}
% Source: \cite{plrm}, p. 475.
% \begin{align}
% \emph{gray} & := 1 - \min\{1,0.3\cdot\emph{cyan} + 0.59\cdot\emph{magenta} + 0.11\cdot\emph{yellow} + black\}
% \end{align}
%
% \paragraph{Complement of \Model{cmyk} color}
% The simple vector complement does not yield useful results.
% Therefore, we first convert %$C=(\emph{cyan}, \emph{magenta}, \emph{yellow}, \emph{black})$
% to the \Model{cmy} model, calculate the complement there, and convert back to \Model{cmyk}.
%
%
% \subsubsection{The \Model{hsb} model}
%
% \paragraph{Conversion \Model{hsb} to \Model{rgb}}
% \begin{gather}
% (\emph{red},\emph{green},\emph{blue}) :=
%  \emph{brightness}\cdot( E - \emph{saturation}\cdot F)\\
% \intertext{with}
% i := \left\lfloor 6\cdot\emph{hue}\right\rfloor,\qquad f := 6\cdot\emph{hue} - i\\
% \intertext{and}
% F :=
%  \begin{cases}
%   (0,1-f,1) & \text{if $i=0$}\\
%   (f,0,1) & \text{if $i=1$}\\
%   (1,0,1-f) & \text{if $i=2$}\\
%   (1,f,0) & \text{if $i=3$}\\
%   (1-f,1,0) & \text{if $i=4$}\\
%   (0,1,f) & \text{if $i=5$}\\
%   (0,1,1) & \text{if $i=6$}
%  \end{cases}\label{eq.hsb2rgb2}
% \end{gather}
%
% \medskip
%
% This is based on \cite{smith}, \emph{HSV to RGB Algorithm (Hexcone Model)}, which reads (slightly reformulated):
% \begin{align}
% m & := 1-\emph{saturation}\\
% n & := 1-f\cdot\emph{saturation}\\
% k & := 1-(1-f)\cdot\emph{saturation}\\
% (\emph{red},\emph{green},\emph{blue}) & := \emph{brightness}\cdot
%  \begin{cases}
%   (1,k,m) & \text{if $i=0,6$}\\
%   (n,1,m) & \text{if $i=1$}\\
%   (m,1,k) & \text{if $i=2$}\\
%   (m,n,1) & \text{if $i=3$}\\
%   (k,m,1) & \text{if $i=4$}\\
%   (1,m,n) & \text{if $i=5$}
%  \end{cases}\label{eq.hsb2rgb1}
% \end{align}
% Note that the case $i=6$ (which results from $\emph{hue}=1$) is missing in Smith's algorithm.
% Because of
% \begin{align}
% \lim_{f\to1} (0,1,f) = (0,1,1) = \lim_{f\to0} (0,1-f,1)
% \end{align}
% it is clear that there is only one way to define $F$ for $i=6$ in order to get a continuous function, as shown in equation (\ref{eq.hsb2rgb2}).
% This has been transformed back to equation (\ref{eq.hsb2rgb1}).
% A similar argument shows that $F$ indeed is a continuous function of \emph{hue} over the whole range $[0,1]$.
%
%
% \paragraph{Conversion \Model{hsb} to \Model{HSB}}
% As described in section \vref{sec.real2int}. Convert to hexadecimal afterwards.
% \begin{align}
% \emph{Hue} & := \RtoI M(\emph{hue})\\
% \emph{Saturation} & := \RtoI M(\emph{saturation})\\
% \emph{Brightness} & := \RtoI M(\emph{brightness})
% \end{align}
%
%
% \paragraph{Complement of \Model{hsb} color}
% We have not found a formula in the literature, therefore we give a short proof afterwards.
% \begin{lemma}
% The \textup{\Model{hsb}}-complement can be calculated by the following formulas:\em
% \begin{align}
% \emph{hue}^* & :=
% \begin{cases}
% \emph{hue} + \frac12 & \text{if $\emph{hue}<\frac12$}\\[1ex]
% \emph{hue} - \frac12 & \text{if $\emph{hue}\ge\frac12$}\\
% \end{cases}\\[1ex]
% \emph{brightness}^* & := 1 - \emph{brightness}\cdot(1-\emph{saturation})\\[1ex]
% \emph{saturation}^* & :=
% \begin{cases}
% 0 & \text{if $\emph{brightness}^*=0$}\\[1ex]
% \displaystyle\frac{\emph{brightness}\cdot\emph{saturation}}{\emph{brightness}^*} & \text{if $\emph{brightness}^*\ne0$}
% \end{cases}
% \end{align}
% \end{lemma}
%
% \begin{proof}
% Starting with the original color $C=(h,s,b)$, we define color $C^*=(h^*,s^*,b^*)$ by the given formulas, convert both $C$ and $C^*$ to the \Model{rgb} model and show that
% \begin{gather}
% C_{\Model{rgb}} + C_{\Model{rgb}}^* = b\cdot(E - s\cdot F) + b^*\cdot(E - s'\cdot F^*) \stackrel!= E,\label{eq.hsbcompl1}
% \end{gather}
% which means that $C_{\Model{rgb}}$ is the complement of $C_{\Model{rgb}}^*$.
% First we note that the parameters of $C^*$ are in the legal range $[0,1]$.
% This is obvious for $h^*,b^*$.
% From
% $b^* = 1-b\cdot(1-s) = 1 - b + b\cdot s$
% we derive $b\cdot s = b^* - (1-b) \le b^*$, therefore $s^*\in[0,1]$, and
% \begin{gather*}
% b^* = 0 \Leftrightarrow s=0 \text{ and } b=1.
% \end{gather*}
% Thus, equation (\ref{eq.hsbcompl1}) holds in the case $b^*=0$.
% Now we assume $b^*\ne0$, hence
% \begin{align*}
% C_{\Model{rgb}} + C_{\Model{rgb}}^*
% &= b\cdot(E - s\cdot F) + b^*\cdot\Bigl(E - \frac{b\cdot s}{b^*}\cdot F^*\Bigr) \\
% &= b\cdot E - b\cdot s\cdot F + b^*\cdot E - b\cdot s\cdot F^*\\[1ex]
% &= E - b\cdot s\cdot(F+F^*-E)
% \end{align*}
% since $b^*=1-b+bs$.
% Therefore, it is sufficient to show that
% \begin{gather}
% F+F^*=E.\label{eq.hsbcompl2}
% \end{gather}
% From
% \begin{gather*}\textstyle
% h<\frac12 \Rightarrow h^*=h+\frac12 \Rightarrow 6h^* = 6h+3 \Rightarrow i^*=i+3 \text{ and } f^*=f
% \end{gather*}
% it is easy to see from (\ref{eq.hsb2rgb2}) that equation (\ref{eq.hsbcompl2}) holds for the cases $i=0,1,2$.
% Similarly,
% \begin{gather*}\textstyle
% h\ge\frac12 \Rightarrow h^*=h-\frac12 \Rightarrow 6h^* = 6h-3 \Rightarrow i^*=i-3 \text{ and } f^*=f
% \end{gather*}
% and again from (\ref{eq.hsb2rgb2}) we derive (\ref{eq.hsbcompl2}) for the cases $i=3,4,5$.
% Finally, if $i=6$ then $f=0$ and $F+F^* = (0,1,1) + (1,0,0) = E$.
% \end{proof}
%
%
% \subsubsection{The \Model{gray} model}
%
% \paragraph{Conversion \Model{gray} to \Model{rgb}}
% Source: \cite{plrm}, p. 474.
% \begin{gather}
% (\emph{red}, \emph{green}, \emph{blue}) := \emph{gray}\cdot E
% \end{gather}
%
% \paragraph{Conversion \Model{gray} to \Model{cmy}}
% This is derived from the conversion chain $\Model{gray}\to\Model{rgb}\to\Model{cmy}$.
% \begin{gather}
% (\emph{cyan}, \emph{magenta}, \emph{yellow}) := (1-\emph{gray})\cdot E
% \end{gather}
%
% \paragraph{Conversion \Model{gray} to \Model{cmyk}}
% Source: \cite{plrm}, p. 475.
% \begin{gather}
% (\emph{cyan}, \emph{magenta}, \emph{yellow}, \emph{black}) := (0,0,0,1-\emph{gray})
% \end{gather}
%
% \paragraph{Conversion \Model{gray} to \Model{hsb}}
% This is derived from the conversion chain $\Model{gray}\to\Model{rgb}\to\Model{hsb}$.
% \begin{gather}
% (\emph{hue}, \emph{saturation}, \emph{brightness}) := (0,0,\emph{gray})
% \end{gather}
%
% \paragraph{Conversion \Model{gray} to \Model{Gray}}
% As described in section \vref{sec.real2int}.
% \begin{gather}
% \emph{Gray} := \RtoI N(\emph{gray})
% \end{gather}
%
% \paragraph{Complement of \Model{gray} color}
% This is similar to the \Model{rgb} case:
% \begin{gather}
% \emph{gray}^* := 1 - \emph{gray}
% \end{gather}
%
%
% \subsubsection{The \Model{RGB} model}
%
% \paragraph{Conversion \Model{RGB} to \Model{rgb}}
% As described in section \vref{sec.int2real}.
% \begin{gather}
% (\emph{red}, \emph{green}, \emph{blue}) := \bigl(\ItoR L(\emph{Red}), \ItoR L(\emph{Green}), \ItoR L(\emph{Blue})\bigr)
% \end{gather}
%
%
% \subsubsection{The \Model{HTML} model}
%
% \paragraph{Conversion \Model{HTML} to \Model{rgb}}
% As described in section \vref{sec.int2real}: starting with \emph{RRGGBB} set
% \begin{gather}
% (\emph{red}, \emph{green}, \emph{blue}) := \bigl(\ItoR{255}(\emph{RR}_{\emph{dec}}), \ItoR{255}(\emph{GG}_{\emph{dec}}), \ItoR{255}(\emph{BB}_{\emph{dec}})\bigr)
% \end{gather}
%
%
% \subsubsection{The \Model{HSB} model}
%
% \paragraph{Conversion \Model{HSB} to \Model{hsb}}
% As described in section \vref{sec.int2real}.
% \begin{gather}
% (\emph{hue}, \emph{saturation}, \emph{brightness}) := \bigl(\ItoR M(\emph{Hue}), \ItoR M(\emph{Saturation}), \ItoR M(\emph{Brightness})\bigr)
% \end{gather}
%
%
% \subsubsection{The \Model{Gray} model}
%
% \paragraph{Conversion \Model{Gray} to \Model{gray}}
% As described in section \vref{sec.int2real}.
% \begin{gather}
% \emph{gray} := \ItoR N(\emph{Gray})
% \end{gather}
%
%
% \StopEventually{
%  \begin{thebibliography}{00}
%  \addcontentsline{toc}{section}{References}
%
%  \bibitem{plrm}%
%   {Adobe Systems Incorporated: ``PostScript Language Reference Manual''. Addison-Wesley, third edition, 1999.\\
%    \texttt{\href{http://www.adobe.com/products/postscript/pdfs/PLRM.pdf}{www.adobe.com/products/postscript/pdfs/PLRM.pdf}}}
%
%  \bibitem{dpc}%
%   {David~P.~Carlisle:~``Packages in the `graphics' bundle'', 1999.\\
%    \texttt{CTAN/macros/latex/required/graphics/grfguide.tex}}
%
%  \bibitem{color}%
%   {David~P.~Carlisle:~\LCP, ``1999/02/16 v1.0i Standard \LaTeX{} Color''.\\
%    \texttt{CTAN/macros/latex/required/graphics/color.*}}
%
%  \bibitem{colortbl}%
%   {David~P.~Carlisle:~\Package{colortbl} package, ``2001/02/13 v0.1j Color table columns''.\\
%    \texttt{CTAN/macros/latex/contrib/carlisle/colortbl.*}}
%
%  \bibitem{pstcol}%
%   {David~P.~Carlisle:~\Package{pstcol} package, ``2001/06/20 v1.1 PSTricks color compatibility''.
%    \texttt{CTAN/macros/latex/required/graphics/pstcol.*}}
%
%  \bibitem{chroma}%
%   {Uwe~Kern:~``Chroma: a reference book of \LaTeX{} colors''.\\
%    \texttt{CTAN/info/colour/chroma/}\\
%    \texttt{\href{http://www.ukern.de/tex/chroma.html}{www.ukern.de/tex/chroma.html}}}
%
%  \bibitem{xcolor}%
%   {Uwe~Kern:~\Package{xcolor} package, ``\LaTeX{} color extensions''.\\
%    \texttt{CTAN/macros/latex/contrib/xcolor/}\\
%    \XCW}
%
%  \bibitem{mik}%
%   {MiK\TeX{} Project:
%    \texttt{\url{http://www.miktex.org/}}}
%
%  \bibitem{colorinfo}%
%   {Rolf~Niepraschk:~\Package{colorinfo} package, ``2003/05/04 v0.3c Info from defined colors''.
%    \texttt{CTAN/macros/latex/contrib/colorinfo/}}
%
%  \bibitem{hyperref}%
%   {Sebastian~Rahtz:~\Package{hyperref} package, ``2003/11/30 v6.74m Hypertext links for \LaTeX''.
%    \texttt{CTAN/macros/latex/contrib/hyperref/}}
%
%  \bibitem{smith}%
%   {Alvy Ray Smith: ``Color Gamut Transform Pairs''. \emph{Computer Graphics} (ACM SIGGRAPH), Volume 12, Number 3, August 1978.\\
%    \texttt{\href{http://alvyray.com/Papers/PapersCG.htm}{alvyray.com/Papers/PapersCG.htm}}}
%
%  \bibitem{svg}%
%   {World Wide Web Consortium: ``Scalable Vector Graphics (SVG) 1.1 Specification --- Basic Data Types and Interfaces''.\\
%    \texttt{\href{http://www.w3.org/TR/SVG11/types.html\#ColorKeywords}{www.w3.org/TR/SVG11/types.html\#ColorKeywords}}}
%
%  \end{thebibliography}
%
%  \section*{Acknowledgement}
%  \addcontentsline{toc}{section}{Acknowledgement}
%  This package is based on and contains code copied from \cite{color} (Copyright (C) 1994--1999 David Carlisle), which is part of the Standard \LaTeX{} `Graphics Bundle'.
%  Although many commands and features have been added and most of the original \LC{} commands have been rewritten or adapted within \XC, the latter package would not exist without \LC.
%  Thus, the author is grateful to David Carlisle for having created \LC{} and its accompanying files.
%
%  \section*{Known Issues}
%  \addcontentsline{toc}{section}{Known Issues}
%  \begin{itemize}
%  \iffalse
%  \item Currently, no errors known to the author.
%  \fi
%  \item Incompatibility with \Option{textures} driver.
%  \end{itemize}
%
%  \section*{History}
%  \addcontentsline{toc}{section}{History}
%  \subsection*{2004/07/04 v2.00}
%  \begin{itemize}
%  \item New features:
%    \begin{itemize}
%    \item extended functionality for color expressions: mix colors like a painter;
%    \item support for color blending: specify color mix expressions that are being blended with every displayed color;
%    \item \cs{xglobal} command for selective control of globality for color definitions, blends, and masks;
%    \item multiple step operations (e.g.~\cs{color\string{foo!!+++\string}}) and access to individual members (e.g.~\cs{color\string{foo!![7]\string}}) in color series;
%    \item \cs{providecolor} command to define only non-existent colors;
%    \item \cs{definecolorset} and \cs{providecolorset} commands to facilitate the construction of color sets with common underlying color model;
%    \item additional 147 predefined color names according to SVG~1.1 specification;
%    \item \Key{xpdfborder} key for setting the width of hyperlink borders in a more driver-independent way if \texttt{dvips} is used.
%    \end{itemize}
%  \item Changes:
%    \begin{itemize}
%    \item \LCP{} now completely integrated within \XC;
%    \item \Option{override}, \Option{usenames}, \Option{nodvipsnames} options and \cs{xdefinecolor} command no longer needed;
%    \item \Option{dvips} and \Option{dvipsnames} options now independent of each other;
%    \item \cs{tracingcolors}'s behaviour changed to make it more versatile and reduce log file size in standard cases;
%    \item \cs{rdivide}'s syntax made more flexible (divide by numbers and/or dimensions);
%    \item code restructured, some internal commands renamed;
%    \item documentation rearranged and enhanced.
%    \end{itemize}
%  \item Bugfixes:
%    \begin{itemize}
%    \item \cs{definecolor\string{foo\string}\string{named\string}\string{bar\string}} did not work (error introduced in v1.11);
%    \item more robust behaviour of conditionals within \Package{pstricks} key-values.
%    \end{itemize}
%  \end{itemize}
%  \subsection*{2004/05/09 v1.11}
%  \begin{itemize}
%  \item New features:
%    \begin{itemize}
%    \item switch \cs{ifglobalcolors} to control whether color definitions are global or local;
%    \item option \Option{hyperref} provides color expression support for the border colors of hyperlinks, e.g.~\cs{hypersetup\string{xurlbordercolor=red!50!yellow\string}};
%    \item internal hooks \cs{XC@bcolor}, \cs{XC@mcolor}, and \cs{XC@ecolor} for additional code that has to be executed immediately before/after the current color is being displayed.
%    \end{itemize}
%  \item Changes:
%    \begin{itemize}
%    \item \cs{XC@logcolor} renamed to \cs{XC@display}, which is now the core color display command;
%    \item improved interface to \Package{pstricks}.
%    \end{itemize}
%  \end{itemize}
%  \subsection*{2004/03/27 v1.10}
%  \begin{itemize}
%  \item New features:
%    \begin{itemize}
%    \item support for \nModel{named} model;
%    \item support for \Package{dvips} colors (may now be used within color expressions);
%    \item internal representation of `ordinary' and `named' colors merged into unified data structure;
%    \item allow multiple `-' signs at the beginning of color expressions.
%    \end{itemize}
%  \item Bugfixes:
%    \begin{itemize}
%    \item commands like \cs{color[named]\string{foo\string}} caused errors when color masking or target model conversion were active;
%    \item incompatibility with \Package{soul} package: commands \cs{hl}, \cs{ul}, etc. could yield unexpected results.
%    \end{itemize}
%  \item Documentation:
%    \begin{itemize}
%    \item added formula for general color expressions;
%    \item enhanced text and index;
%    \item removed dependence of index generation on local configuration file.
%    \end{itemize}
%  \end{itemize}
%  \subsection*{2004/02/16 v1.09}
%  \begin{itemize}
%  \item New features:
%    \begin{itemize}
%    \item color model \Model{HTML}, a 24-bit hexadecimal \Model{RGB} variant; allows to specify colors like \cs{color[HTML]\string{AFFE90\string}};
%    \item color names \Color{orange}, \Color{violet}, \Color{purple}, and \Color{brown} added to the set of predefined colors.
%    \end{itemize}
%  \item New \XC{} homepage: \XCW
%  \item Bugfix: \cs{xdefinecolor} sometimes did not normalise its parameters.
%  \item Changes:
%    \begin{itemize}
%    \item slight improvements of the documentation;
%    \item example file \texttt{xcolor1.tex} reorganised and abridged.
%    \end{itemize}
%  \end{itemize}
%  \subsection*{2004/02/04 v1.08}
%  \begin{itemize}
%  \item New commands:
%    \begin{itemize}
%    \item \cs{selectcolormodel} to change the target model within a document;
%    \item \cs{adjustUCRBG} to fine-tune undercolor-removal and black-generation during conversion to \Model{cmyk}.
%    \end{itemize}
%  \item Bugfix: color expressions did not work correctly in connection with active `!' character, e.g.{} in case of \cs{usepackage[frenchb]\string{babel\string}}.
%  \item Code re-organisation:
%    \begin{itemize}
%    \item \cs{XC@xdefinecolor} merged into \cs{xdefinecolor}, making the first command obsolete;
%    \item several internal commands improved/streamlined.
%    \end{itemize}
%  \end{itemize}
%  \subsection*{2004/01/20 v1.07}
%  \begin{itemize}
%  \item New feature: support for color masking and color separation.
%  \item New commands:
%    \begin{itemize}
%    \item \cs{rmultiply} to multiply a dimension register by a real number;
%    \item \cs{xcolorcmd} to pass commands that are to be executed at the end of the package.
%    \end{itemize}
%  \item Changes:
%    \begin{itemize}
%    \item more consistent color handling: extended colors now always take precedence over standard colors;
%    \item several commands improved by using code from the \LaTeX{} kernel.
%    \end{itemize}
%  \item Documentation: some minor changes.
%  \item Example files: additional \Package{pstricks} examples (file \texttt{xcolor2.tex}).
%  \end{itemize}
%  \subsection*{2003/12/15 v1.06}
%  \begin{itemize}
%  \item New feature: extended color expressions, allowing for cascaded mix operations, e.g.{} \cs{color\string{red!30!green!40!blue\string}}.
%  \item Documentation: new section on color expressions.
%  \item Bugfix:~color series stepping did not work correctly within non-displaying commands like \cs{extractcolorspec\string{foo!!+\string}} (this bug was introduced in v1.05).
%  \item Renamed~commands:~\cs{ukfileversion} and similar internal constants renamed to \cs{XCfileversion} etc.
%  \item Removed~commands:~\cs{ifXCpst} and \cs{ifXCtable} made obsolete by a simple trick.
%  \end{itemize}
%  \subsection*{2003/11/21 v1.05}
%  \begin{itemize}
%  \item Bugfixes:
%    \begin{itemize}
%    \item package option \Option{hideerrors} should now work as expected;
%    \item usage of `.' in the first color expression in a document caused an error due to incorrect initialisation.
%    \end{itemize}
%  \item Code re-organisation: \cs{extractcolorspec} now uses \cs{XC@splitcolor}, making \cs{XC@extract} obsolete.
%  \end{itemize}
%  \subsection*{2003/11/09 v1.04}
%  \begin{itemize}
%  \item New feature: easy access to current color within color expressions.
%  \item New option: \Option{override} to replace \cs{definecolor} by \cs{xdefinecolor}.
%  \item New command: \cs{tracingcolors} for logging color-specific information.
%  \end{itemize}
%  \subsection*{2003/09/21 v1.03}
%  \begin{itemize}
%  \item Change: bypass strange behaviour of some drivers.
%  \item New feature: driver-sharing with \Package{hyperref}.
%  \end{itemize}
%  \subsection*{2003/09/19 v1.02}
%  \begin{itemize}
%  \item Change: \cs{extractcolorspec} and \cs{colorlet} now also accept color series as arguments.
%  \end{itemize}
%  \subsection*{2003/09/15 v1.01}
%  \begin{itemize}
%  \item New feature: \cs{definecolorseries} and friends.
%  \item Documentation: removed some \Package{doc}-related side-effects.
%  \item Code re-organisation: all calculation-related tools put to one place.
%  \item Bugfixes:
%    \begin{itemize}
%    \item \cs{@rdivide}: added \cs{relax} to fix problem with negative numerators;
%    \item \cs{rowc@l@rs}: replaced \cs{@ifempty} by \cs{@ifxempty}.
%    \end{itemize}
%  \end{itemize}
%  \subsection*{2003/09/09 v1.00}
%  \begin{itemize}
%  \item First published release.
%  \end{itemize}
% }
%
% \clearpage
%
% \section{The Implementation}
%
% Some commands have been copied unchanged from \cite{color} (Copyright (C) 1994--1999 David Carlisle), which is part of the Standard \LaTeX{} `Graphics Bundle'.
% Additionally, also some parts of the code documentation were copied from \cite{color}.
%
%
%
% \subsection{Preparation}
%
% \subsubsection{File identification}
%
% \renewcommand*\MacroFont{\footnotesize\ttfamily}
% \renewcommand*\AltMacroFont{\footnotesize\ttfamily\slshape}
%
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xcolor}[\XCfiledate\space\XCfileversion\space
                         LaTeX color extensions (UK)]
%    \end{macrocode}
%
%
% \subsubsection{Safety first}
%
% \begin{macro}{\XC@catcodes}
% Save catcodes for later restore:
%    \begin{macrocode}
\edef\XC@catcodes
 {\catcode`\noexpand\!\the\catcode`\!\relax
  \catcode`\noexpand\:\the\catcode`\:\relax
  \catcode`\noexpand\-\the\catcode`\-\relax
  \catcode`\noexpand\+\the\catcode`\+\relax
  \catcode`\noexpand\;\the\catcode`\;\relax
  \catcode`\noexpand\"\the\catcode`\"\relax
  \catcode`\noexpand\^^A\the\catcode`\^^A\relax}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\catcode`\!=12
\catcode`\:=12
\catcode`\-=12
\catcode`\+=12
\catcode`\;=12
\catcode`\"=12
\catcode`\^^A=\catcode`\%
%    \end{macrocode}
%
%
% \subsubsection{Switches}
%
%  \begin{macro}{\ifcolors@}
% This boolean can be tested by higher level macros that may want to alter their behaviour if a monochrome driver is being used.
%    \begin{macrocode}
\newif\ifcolors@ \colors@true
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\ifcolorerrors@}
% Controls whether missing color models/names result in error or warning messages.
%    \begin{macrocode}
\newif\ifcolorerrors@
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\ifglobalcolors}
% Controls whether |\definecolor| and |\colorlet| generate global or local color definitions.
%    \begin{macrocode}
\newif\ifglobalcolors \globalcolorsfalse
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifconvertcolorsD}
% \begin{macro}{\ifconvertcolorsU}
% Control whether conversion to target models take place at \emph{definition} time (|\ifconvertcolorsD|) and/or \emph{usage} (|\ifconvertcolorsU|).
%    \begin{macrocode}
\newif\ifconvertcolorsD
\newif\ifconvertcolorsU
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifblendcolors}
% \begin{macro}{\ifmaskcolors}
% Control whether colors are to be blended and/or masked at display time.
%    \begin{macrocode}
\newif\ifblendcolors
\newif\ifmaskcolors
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifXC@@tst}
% Auxiliary test variable.
%    \begin{macrocode}
\newif\ifXC@@tst
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Error handling}
%
% \begin{macro}{\c@lor@error}
% Multi-purpose error handler (issues warnings instead of errors if the \Option{hideerrors} option is used).
% This command is used already in the options section.
%    \begin{macrocode}
\def\c@lor@error#1%
 {\ifcolorerrors@\PackageError{xcolor}{Undefined color #1}\@ehc
  \else\PackageWarning{xcolor}{Undefined color #1}\fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Macro concatenation}
%
% \begin{macro}{\XC@append}
%   \marg{cmd}\marg{token list}\\
% Append \Meta{token list} to the definition of \Meta{cmd}.
% This command is used already in the options section.
%    \begin{macrocode}
\def\XC@append#1#2%
 {\ifx#1\@undefined\def#1{#2}\else\ifx#1\relax\def#1{#2}\else
  \toks@\expandafter{#1#2}\edef#1{\the\toks@}\fi\fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Package options}
%
% \subsubsection{Color model selection}
%
% \begin{macro}{\selectcolormodel}
%   \marg{num model}\\
% Determines the target model for color definitions with |\definecolor| and friends.
%    \begin{macrocode}
\def\selectcolormodel#1%
 {\@ifundefined{XC@mod@#1}%
   {\c@lor@error{model `#1'}}%
   {\expandafter\ifx\csname XC@mod@#1\endcsname\XC@mod@natural
      \def\XC@tgt@mod##1{##1}\convertcolorsDfalse\convertcolorsUfalse
    \else
      \edef\XC@tgt@mod##1{#1}\convertcolorsDtrue\convertcolorsUtrue
    \fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@mod@named}
% Put model names into commands.
%    \begin{macrocode}
\def\XC@mod@named{named}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@mod@natural}
% \begin{macro}{\XC@mod@rgb}
% \begin{macro}{\XC@mod@cmy}
% \begin{macro}{\XC@mod@cmyk}
% \begin{macro}{\XC@mod@hsb}
% \begin{macro}{\XC@mod@gray}
% \begin{macro}{\XC@mod@RGB}
% \begin{macro}{\XC@mod@HTML}
% \begin{macro}{\XC@mod@HSB}
% \begin{macro}{\XC@mod@Gray}
% Put model names into commands and define package options:
% \Option{natural}, \Option{rgb}, \Option{cmy}, \Option{cmyk}, \Option{hsb}, \Option{gray}, \Option{RGB}, \Option{HTML}, \Option{HSB}, \Option{Gray}.
%    \begin{macrocode}
\@tfor\@@tmp:={natural}{rgb}{cmy}{cmyk}{hsb}{gray}{RGB}{HTML}{HSB}{Gray}\do
 {\expandafter\let\csname XC@mod@\@@tmp\endcsname\@@tmp
  \edef\@@tmp
   {\noexpand\DeclareOption{\@@tmp}{\noexpand\selectcolormodel{\@@tmp}}}%
  \@@tmp}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% The \Option{monochrome} option should be used \emph{in addition} to one of the standard driver options.
%    \begin{macrocode}
\DeclareOption{monochrome}
 {\ExecuteOptions{hideerrors}%
  \AtEndOfPackage
   {\colors@false
    \def\set@color{\c@lor@special\m@ne
      {color push \current@color}\aftergroup\reset@color}%
    \def\reset@color{\c@lor@special\m@ne{color pop}}%
    \def\set@page@color{\c@lor@special\m@ne{background \current@color}}}}
%    \end{macrocode}
%
%
% \subsubsection{Sets of predefined colors}
%
% \begin{macro}{\XC@colornames}
% Initalise the macro to hold the names of files that contain predefined colors; these files are loaded near to the end of this package.
%    \begin{macrocode}
\let\XC@colornames\relax
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\DeclareOption{dvipsnames}{\XC@append\XC@colornames{\input{dvipsnam.def}}}
\DeclareOption{svgnames}{\XC@append\XC@colornames{\input{svgnam.def}}}
%    \end{macrocode}
%
%
% \subsubsection{Support for other packages}
%
% Use this option to load David Carlisle's \Package{pstcol} package in order to make standard color definitions available within \Package{pstricks}:
%    \begin{macrocode}
\DeclareOption{pst}{\def\XC@pst{\RequirePackage{pstcol}}}
%    \end{macrocode}
%
% Use this option to load David Carlisle's \Package{colortbl} package:
%    \begin{macrocode}
\DeclareOption{table}{\def\XC@table{\RequirePackage{colortbl}}}
%    \end{macrocode}
%
% \begin{macro}{\KV@Hyp@xcitebordercolor}
% \begin{macro}{\KV@Hyp@xfilebordercolor}
% \begin{macro}{\KV@Hyp@xlinkbordercolor}
% \begin{macro}{\KV@Hyp@xmenubordercolor}
% \begin{macro}{\KV@Hyp@xpagebordercolor}
% \begin{macro}{\KV@Hyp@xrunbordercolor}
% \begin{macro}{\KV@Hyp@xurlbordercolor}
% \begin{macro}{\KV@Hyp@xpdfborder}
% Use this option to define the extended keys for the \Package{hyperref} package.
%    \begin{macrocode}
\DeclareOption{hyperref}
 {\@tfor\@@tmp:={cite}{file}{link}{menu}{page}{run}{url}\do
   {\expandafter\edef\csname KV@Hyp@x\@@tmp bordercolor\endcsname #1%
     {\noexpand\XC@bordercolor{\@@tmp}{#1}}}%
  \AtEndOfPackage
   {\GetGinDriver\def\KV@Hyp@xpdfborder#1{\edef\@pdfborder{#1}}%
    \@tfor\@@tmp:={dvips}\do
     {\ifx\GinDriver\@@tmp
       \def\KV@Hyp@xpdfborder#1%
        {\edef\@pdfborder{#1}\expandafter\XC@pdfborder\@pdfborder\relax}%
      \@break@tfor\fi}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Driver options}
%
% \begin{macro}{\Gin@driver}
% Initalise the macro to hold the driver file name.
%    \begin{macrocode}
\providecommand\Gin@driver{}
%    \end{macrocode}
%
% Drivers that come with their individual definition files:
%    \begin{macrocode}
\@tfor\@@tmp:={dvipdf}{dvipdfm}{dvips}{dvipsone}{dviwin}{emtex}%
              {pctex32}{pctexhp}{pctexps}{pctexwin}{pdftex}{tcidvi}%
              {textures}{truetex}{vtex}\do
 {\edef\@@tmp{\noexpand\DeclareOption{\@@tmp}%
    {\noexpand\def\noexpand\Gin@driver{\@@tmp.def}}}%
  \@@tmp}
%    \end{macrocode}
%
% Drivers that are derivatives of others:
%    \begin{macrocode}
\DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
\DeclareOption{oztex}{\ExecuteOptions{dvips}}
\DeclareOption{xdvi}{\ExecuteOptions{dvips,monochrome}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Other options}
%
% These options control how non-existing colors are treated:
%    \begin{macrocode}
\DeclareOption{showerrors}{\colorerrors@true}
\DeclareOption{hideerrors}{\colorerrors@false}
%    \end{macrocode}
%
% The \Option{debugshow} option turns on debugging info (perhaps).
%    \begin{macrocode}
\DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
%    \end{macrocode}
%
% All other options (including \LC's \Option{usenames}, \Option{nodvipsnames}) are being ignored.
%    \begin{macrocode}
\DeclareOption*%
 {\PackageInfo{xcolor}{Package option `\CurrentOption' ignored}}
%    \end{macrocode}
%
% Choose default options:
%    \begin{macrocode}
\ExecuteOptions{natural,showerrors}
%    \end{macrocode}
%
%
% \subsubsection{Processing options}
%
% A local configuration file may declare more options.
% It should also make one driver option the default, by calling |\ExecuteOptions| with the appropriate option.
%    \begin{macrocode}
\InputIfFileExists{color.cfg}{}{}
%    \end{macrocode}
%
% After the options are processed, load the appropriate driver file.
% If a site wants a default driver (e.g.{} |dvips|) it just needs to put |\ExecuteOptions{dvips}| in a \File{color.cfg} file.
%    \begin{macrocode}
\ProcessOptions\relax
%    \end{macrocode}
%
%    \begin{macrocode}
\if!\Gin@driver!
  \PackageError{xcolor}
    {No driver specified}
    {You should make a default driver option in a file \MessageBreak
     color.cfg\MessageBreak
     eg: \protect\ExecuteOptions{dvips}}
\else
  \PackageInfo{xcolor}{Driver file: \Gin@driver}
  \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
\fi
%    \end{macrocode}
%
%
% \subsubsection{Required packages}
%
%    \begin{macrocode}
\@nameuse{XC@pst}
\@namedef{ver@color.sty}{1999/02/16}
\@nameuse{XC@table}
%    \end{macrocode}
%
%
% \subsection{Macro tools}
%
% \subsubsection{General tools}
%
% \begin{macro}{\@secondoffive}
% Argument grabbing, similar to \LaTeX{} kernel.
%    \begin{macrocode}
\long\def\@secondoffive#1#2#3#4#5{#2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@namelet}
%   \marg{name1}\marg{name2}\\
% Performs |\let\|\Meta{name1}|=\|\Meta{name2}.
%    \begin{macrocode}
\def\@namelet#1#2%
 {\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@namexdef}
% Similar to the \LaTeX{} internal |\@namedef| command.
%    \begin{macrocode}
\def\@namexdef#1{\expandafter\xdef\csname #1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\aftergroupdef}
%   \marg{cmd}\marg{code}
%    \begin{macrocode}
\def\aftergroupdef#1#2%
 {\edef\@@tmp{\noexpand\def\noexpand#1{#2}}%
  \expandafter\endgroup\@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@edef}
%   \marg{cmd}\marg{code}\\
% Defines \Meta{cmd} as a safe expansion of \Meta{code}; needed for color expressions in certain languages.
%    \begin{macrocode}
\begingroup
\catcode`\!=13 \catcode`\:=13 \catcode`\-=13 \catcode`\+=13
\catcode`\;=13 \catcode`\"=13
\gdef\XC@edef#1#2%
 {\begingroup
  \ifnum\catcode`\!=13 \edef!{\string!}\fi
  \ifnum\catcode`\:=13 \edef:{\string:}\fi
  \ifnum\catcode`\-=13 \edef-{\string-}\fi
  \ifnum\catcode`\+=13 \edef+{\string+}\fi
  \ifnum\catcode`\;=13 \edef;{\string;}\fi
  \ifnum\catcode`\"=13 \edef"{\string"}\fi
  \edef\@@tmp{#2}\@onelevel@sanitize\@@tmp
  \aftergroupdef#1\@@tmp}
\endgroup
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ifxempty}
%   \marg{arg}\marg{empty}\marg{non-empty}\\
% Tests without expanding, whether the argument \Meta{arg} is empty and executes the following code accordingly.
% Can also be used within |\edef|.
%    \begin{macrocode}
\def\@ifxempty#1{\@@ifxempty#1\@@ifxempty\XC@@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@@ifxempty#1#2\XC@@
 {\ifx#1\@@ifxempty
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xglobal}
% \begin{macro}{\xglobal@test}
% If |\foo| occurs in the token list |\xglobal@@|, then the command |\xglobal\foo| will set the switch |\xglobal@true| which can be used inside |\foo| to determine whether certain definitions are to be made explicitely global.
% |\foo| is responsible for resetting |\xglobal@false| in order to avoid side effects.
% To include |\foo| in the magic list, simply say |\XC@append\xglobal@list{\foo}|.
% If |\foo| is not in the list, |\xglobal\foo| will behave like |\global\foo|, thus |\xglobal\let| will be like |\global\let| etc.
%    \begin{macrocode}
\def\xglobal{\xglobal@stop\begingroup\futurelet\@@tok\xglobal@test}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\xglobal@test
 {\expandafter\@tfor\expandafter\@@tmp
   \expandafter:\expandafter=\xglobal@list\do
    {\expandafter\ifx\@@tmp\@@tok
       \aftergroup\let\aftergroup\xglobal@\@break@tfor\fi}%
  \endgroup\global}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\xglobal@stop}
% Resetting |\xglobal@|.
%    \begin{macrocode}
\def\xglobal@stop{\let\xglobal@\@empty}
\xglobal@stop
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xglobal@list}
% Initial list of commands that may be prefixed by |\xglobal|.
%    \begin{macrocode}
\def\xglobal@list
 {\definecolor\providecolor\colorlet\definecolorset\providecolorset
  \blendcolors\maskcolors}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xglobalize@}
% Globalisation command: makes a local definition global.
%    \begin{macrocode}
\def\xglobalize@#1{\ifx\xglobal@\global\global\let#1#1\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\GetGinDriver}
% Transforms the chosen driver option ready for \Package{hyperref}.
%    \begin{macrocode}
\def\GetGinDriver{\expandafter\GetGinDriver@\Gin@driver.:}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\GetGinDriver@#1.#2:%
 {\def\GinDriver{#1}\@tempswatrue
  \@tfor\@@tmp:={dvips}{pdftex}{dvipdf}{dvipdfm}{dvipsone}{vtex}{textures}%
  \do{\ifx\GinDriver\@@tmp\@tempswafalse\@break@tfor\fi}%
  \if@tempswa\def\GinDriver{hypertex}\fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{String manipulation}
%
% \begin{macro}{\@hex@Hex}
%   \Meta{hex-string}|\relax|\\
% Converts \Meta{hex-string} to a string where all letters a--f are changed into their uppercase variants.
% All other letters are left unchanged.
% May be used inside |\edef|.
%    \begin{macrocode}
\def\@hex@Hex#1{\ifx#1\relax\else\expandafter\@hex@@Hex\expandafter#1\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@hex@@Hex#1%
 {\if#1aA\else \if#1bB\else \if#1cC\else \if#1dD\else \if#1eE\else
  \if#1fF\else #1\fi\fi\fi\fi\fi\fi \@hex@Hex}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Scalar arithmetic}
%
% \begin{macro}{\rdivide}
%   \marg{dimension register}\marg{div}\\
% Divides \Meta{dimension register} by a real number \Meta{div}, which may also be buried in a dimension (register), and stores the resulting rounded dimension in \Meta{dimension register}.
% The denominator \Meta{div} is assumed to be non-zero.
%    \begin{macrocode}
\def\rdivide#1#2%
 {\begingroup\toks@{#1}\edef\@@tmp{\noexpand\@tempdima\the#1}%
  \@defaultunits\@tempdimb=#2pt\relax\@nnil \@@tmp\relax
  \ifdim\@tempdima<\z@ \@tempdima-\@tempdima\def\@sign{-}\else
    \def\@sign{}\fi
  \ifdim\@tempdimb<\z@ \@tempdimb-\@tempdimb\edef\@sign{\@sign-}\fi
  \ifdim\@tempdima<.1\maxdimen \ifdim\@tempdimb<.01\maxdimen
    \lshift\@tempdima \lshift\@tempdimb \fi\fi
  \@tempcnta=\@tempdima \@tempcntb=\@tempdimb
  \count@=\@tempcnta \divide\count@\@tempcntb
  \edef\@@tmp{\number\count@.}%
  \@tempswatrue  \@rdivide \@rdivide \@rdivide \@rdivide \@rdivide
  \@tempswafalse \@rdivide
  \dimen@\@@tmp\p@ \ifnum\count@>4\advance\dimen@.00001\p@\fi
  \dimen@\@sign\dimen@
  \edef\@@tmp{\the\toks@\the\dimen@}%
  \expandafter\endgroup\@@tmp}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@rdivide
 {\multiply\count@\@tempcntb \advance\@tempcnta-\count@
  \multiply\@tempcnta10 \count@=\@tempcnta \divide\count@\@tempcntb
  \if@tempswa\edef\@@tmp{\@@tmp\number\count@}\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rmultiply}
%   \marg{dimension register}\marg{dec}\\
% Multiplies \Meta{dimension register} by \Meta{dec} and stores the resulting dimension in \Meta{dimension register}.
%    \begin{macrocode}
\def\rmultiply#1#2%
 {\begingroup
  \edef\@@mul{#2}\@tempdima\the#1\relax
  \afterassignment\@tempdimb\@tempcntb=\@@mul\p@
  \ifdim\@tempdima<\z@ \@tempdima-\@tempdima\def\@sign{-}\else
    \def\@sign{}\fi
  \ifnum\@tempcntb<\z@ \@tempcntb-\@tempcntb\edef\@sign{\@sign-}\fi
  \lshift\@tempdima \dimen@\z@
  \expandafter\@rmultiply\@@mul.0.\@nil
  \advance\dimen@\@tempcntb\@tempdima \rshift\dimen@
  \dimen@\@sign\dimen@
  \edef\@@tmp{#1\the\dimen@}%
  \expandafter\endgroup\@@tmp}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@rmultiply#1.#2.#3\@nil
 {\def\@@tmp{}%
  \@tfor\@@mul:=#2\do
   {\edef\@@tmp
     {\advance\dimen@\@@mul\@tempdima \divide\dimen@10 \@@tmp}}%
  \@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lshift}
% \begin{macro}{\llshift}
%   \marg{dimension register}\\
% Multiplies \Meta{dimension register} safely by 10 resp. 100.
%    \begin{macrocode}
\def\lshift#1{#1\expandafter\lshift@\the#1}
\def\llshift#1{\lshift#1\lshift#1}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lshiftnum}
% \begin{macro}{\llshiftnum}
%   \marg{decimal number}\\
% Multiplies \Meta{decimal number} by 10 resp. 100.
%    \begin{macrocode}
\def\lshiftnum#1{\expandafter\lshiftnum@#1.00.:}
\def\lshiftnum@#1.#2#3.#4:{#1#2\ifnum0#3>\z@.#3\fi}
\def\llshiftnum#1{\expandafter\llshiftnum@#1\@empty.00.:}
\def\llshiftnum@#1.#2#3#4.#5:%
 {#1#2\ifnum0#3>\z@#3\else0\fi\ifnum0#4>\z@.#4\fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lshiftset}
% \begin{macro}{\llshiftset}
%   \marg{dimension register}\marg{decimal number}\\
% Multiplies \Meta{decimal number} by 10 resp. 100 and puts it into \Meta{dimension register}.
%    \begin{macrocode}
\def\lshiftset#1#2{\edef\@@XC{\noexpand\lshiftnum{#2}}#1\@@XC\p@}
\def\llshiftset#1#2{\edef\@@XC{\noexpand\llshiftnum{#2}}#1\@@XC\p@}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rshift}
% \begin{macro}{\rrshift}
%   \marg{dimension register}\\
% Divides \Meta{dimension register} safely by 10 resp. 100.
%    \begin{macrocode}
\def\rshift#1{#1\expandafter\rshift@\the#1}
\def\rrshift#1{\rshift#1\rshift#1}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The following definitions are similar to the way how |\strip@pt| is defined in the \LaTeX{} kernel:
%    \begin{macrocode}
\begingroup
\catcode`P=12
\catcode`T=12
\lowercase
 {\def\@@tmp{\def\lshift@##1.##2##3PT{##1##2\ifnum0##3>\z@.##3\fi\p@}
             \def\rshift@##1.##2PT{\rshift@@##1\relax##2\p@}}}
\expandafter\endgroup\@@tmp
%    \end{macrocode}
%
%    \begin{macrocode}
\def\rshift@@#1#2%
 {\ifx#2\relax.#1\else#1\expandafter\rshift@@\expandafter#2\fi}
%    \end{macrocode}
%
%
% \subsubsection{Vector arithmetic}
%
% \begin{macro}{\XC@inflate}
%   \marg{core model}\marg{first}\marg{second}\marg{cmd}\\
% Constructs an 8-dimensional vector based on two vectors \Meta{first}, \Meta{second} (of common dimension $1,3,4$) and an underlying color model (stored in the macro \Meta{core model}).
% The resulting vector is stored in \Meta{cmd}.
%    \begin{macrocode}
\def\XC@inflate#1#2#3#4%
 {\edef#4{#2,\ifx#1\XC@mod@cmyk #3\else
             \ifx#1\XC@mod@gray ,,,#3,,,\else ,#3,\fi\fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@vec}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Generic vector calculation for two vectors (of common dimension $1,3,4$), puts the result into \Meta{cmd}.
%    \begin{macrocode}
\def\XC@vec#1,#2,#3,#4,#5,#6,#7,#8,#9%
 {\def\@@tmp{}%
  \XC@vec@{#1}{#5}%
  \@ifxempty{#2}{}%
   {\XC@vec@{#2}{#6}\XC@vec@{#3}{#7}\@ifxempty{#4}{}{\XC@vec@{#4}{#8}}}%
  \aftergroupdef#9\@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@add}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Calculates the sum of two vectors (of common dimension $1,3,4$) and puts it into \Meta{cmd}.
%    \begin{macrocode}
\def\XC@add{\begingroup \let\XC@vec@\XC@add@ \XC@vec}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@add@#1#2%
 {\llshiftset\dimen@{#1}\llshiftset\@tempdima{#2}%
  \advance\dimen@\@tempdima \rrshift\dimen@
  \edef\@@tmp{\ifx\@@tmp\@empty\else\@@tmp,\fi\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@sub}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Calculates the difference of two vectors (of common dimension $1,3,4$) and puts it into \Meta{cmd}.
%    \begin{macrocode}
\def\XC@sub{\begingroup \let\XC@vec@\XC@sub@ \XC@vec}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@sub@#1#2{\XC@add@{#1}{-#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@mul}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Calculates the (component-wise) product of two vectors (of common dimension $1,3,4$) and puts it into \Meta{cmd}.
%    \begin{macrocode}
\def\XC@mul{\begingroup \let\XC@vec@\XC@mul@ \XC@vec}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@mul@#1#2%
 {\llshiftset\dimen@{#1}\rmultiply\dimen@{#2}\rrshift\dimen@
  \edef\@@tmp{\ifx\@@tmp\@empty\else\@@tmp,\fi\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@mix}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Calculates the linear interpolation of two color parameter vectors and puts it into \Meta{cmd}.
% The percentage parameter $p$ is input via register |\dimen@|.
%    \begin{macrocode}
\def\XC@mix%
 {\begingroup
  \@tempdima\dimen@ \@tempdimb100\p@ \advance\@tempdimb-\@tempdima
  \let\XC@vec@\XC@mix@ \XC@vec}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@mix@#1#2%
 {\dimen@#1\@tempdima \advance\dimen@#2\@tempdimb \rrshift\dimen@
  \edef\@@tmp{\ifx\@@tmp\@empty\else\@@tmp,\fi\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@calc@}
%   \Meta{x}|,|\Meta{y}|,|\Meta{z}|,|\Meta{w}|,|\Meta{dummy}|:|\marg{function}\\
% Performs, dependent on the number of non-empty parameters, |\edef\@@tmp{|$f(x)$|}| or |\edef\@@tmp{|$f(x),f(y),f(z)$|}| or |\edef\@@tmp{|$f(x),f(y),f(z),f(w)$|}|, where the function $f$ is determined by the parameter \Meta{function}.
%    \begin{macrocode}
\def\XC@calc@#1,#2,#3,#4,#5:#6%
 {\toks@\expandafter{\csname XC@calc#6\endcsname}%
  \the\toks@{#1}\@@tmp
  \@ifxempty{#2}{}%
   {\the\toks@{#2}\@tempa \the\toks@{#3}\@tempb
    \@ifxempty{#4}%
     {\edef\@@tmp{\@@tmp,\@tempa,\@tempb}}%
     {\the\toks@{#4}\@tempc \edef\@@tmp{\@@tmp,\@tempa,\@tempb,\@tempc}}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcC}
%   \marg{x}\marg{cmd}\\
% \textbf Complement of $x$: performs |\def|\Meta{cmd}|{|$1-x$|}|.
%    \begin{macrocode}
\def\XC@calcC#1#2%
 {\lshiftset\dimen@{-#1}\advance\dimen@10\p@ \rshift\dimen@
  \edef#2{\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcD}
%   \marg{x}\marg{cmd}\\
% \textbf Division of $x$ by $s$: performs |\def|\Meta{cmd}|{|$x/s$|}|.
% The parameter $s$ is input via |\@@scl|.
%    \begin{macrocode}
\def\XC@calcD#1#2%
 {\dimen@#1\p@ \rdivide\dimen@\@@scl \edef#2{\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcH}
%   \marg{x}\marg{cmd}\\
% \textbf Hexadecimal transformation of $x\in\{0,1,\dots,255\}$: performs |\def|\Meta{cmd}|{|$x_{16}$|}|.
%    \begin{macrocode}
\def\XC@calcH#1#2%
 {\count@#1 \divide\count@\sixt@@n \edef\XC@@tmp{\hexnumber@\count@}%
  \multiply\count@-\sixt@@n \advance\count@#1
  \edef#2{\XC@@tmp\hexnumber@\count@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcM}
%   \marg{x}\marg{cmd}\\
% \textbf Multiplication of $x$ by $s$ plus rounding: performs |\def|\Meta{cmd}|{|$[s\cdot x+0.5]$|}|.
% The parameter $s$ is input via |\@@scl|.
%    \begin{macrocode}
\def\XC@calcM#1#2%
 {\dimen@#1\p@ \dimen@\@@scl\dimen@ \advance\dimen@.5\p@
  \afterassignment\dimen@\count@=\the\dimen@ \edef#2{\number\count@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcN}
%   \marg{x}\marg{cmd}\\
% \textbf Normalisation of $x$: performs |\def|\Meta{cmd}|{|$\min\{1,\max\{0,x\}\}$|}|.
%    \begin{macrocode}
\def\XC@calcN#1#2%
 {\edef#2{#1}%
  \edef#2{\ifdim#2\p@<\z@0\else \ifdim#2\p@<\p@
          0\expandafter\XC@@calcN#2.0.:\else 1\fi\fi}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@calcN#1.#2.#3:%
 {\ifnum0#2=0 \else.\XC@@@calcN#2:\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@@calcN#1#2:%
 {\ifnum0#1#2=0 \else #1\ifnum0#2=0 \else \XC@@@calcN#2:\fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcS}
%   \marg{x}\marg{cmd}\\
% \textbf Scaling of $x$ by $s$: performs |\def|\Meta{cmd}|{|$s\cdot x$|}|.
% The parameter $s$ is input via |\@@scl|.
%    \begin{macrocode}
\def\XC@calcS#1#2%
 {\lshiftset\dimen@{#1}\dimen@\lshiftnum\@@scl\dimen@ \rrshift\dimen@
  \edef#2{\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcT}
%   \marg{x}\marg{cmd}\\
% \textbf Translate $x$ by $a$ and cut to unit interval: performs |\def|\Meta{cmd}|{|$\min\{1,\max\{0,x+a\}\}$|}|.
% The parameter $a$ is input via |\@@arg|.
%    \begin{macrocode}
\def\XC@calcT#1#2%
 {\lshiftset\dimen@{#1}\advance\dimen@\lshiftnum\@@arg\p@ \rshift\dimen@
  \edef#2%
   {\ifdim\dimen@>\p@1\else\ifdim\dimen@<\z@0\else\strip@pt\dimen@\fi\fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcU}
%   \marg{x}\marg{cmd}\\
% \textbf Unit interval mapping of $x$: performs |\def|\Meta{cmd}|{|$x-[x]$|}| if $x\neq1$, $1$ otherwise.
%    \begin{macrocode}
\def\XC@calcU#1#2%
 {\dimen@#1\p@
  \ifdim\dimen@=\p@\else
    \afterassignment\dimen@\count@=\the\dimen@
    \ifnum\count@<\z@
      \lshift\dimen@ \dimen@-\dimen@ \advance\dimen@10\p@ \rshift\dimen@
    \fi
  \fi
  \edef#2{\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Color definition}
%
% \subsubsection{Constants}
%
% \begin{macro}{\rangeRGB}
% \begin{macro}{\rangeHSB}
% \begin{macro}{\rangeGray}
% Scaling ranges for `integer models':
%    \begin{macrocode}
\ifx\rangeRGB\@undefined\def\rangeRGB{255}\fi
\ifx\rangeHSB\@undefined\def\rangeHSB{240}\fi
\ifx\rangeGray\@undefined\def\rangeGray{15}\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\adjustUCRBG}
% Parameters for undercolor-removal (UCR) and black-generation (BG) during \Model{cmy} to \Model{cmyk} conversion:
%    \begin{macrocode}
\ifx\adjustUCRBG\@undefined\def\adjustUCRBG{1,1,1,1}\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\colorseriescycle}
% Default cycle length for color series:
%    \begin{macrocode}
\ifx\colorseriescycle\@undefined\def\colorseriescycle{16}\fi
%    \end{macrocode}
% \end{macro}
%
% Model-dependent base colors (`1' may be left empty):
%    \begin{macrocode}
\def\XC@clr@rgb@white{,,}
\def\XC@clr@cmy@white{0,0,0}
\def\XC@clr@cmyk@white{0,0,0,0}
\def\XC@clr@hsb@white{\@@hue,0,}
\def\XC@clr@hsb@gray{\@@hue,0,.5}
\def\XC@clr@hsb@black{\@@hue,0,0}
\def\XC@clr@gray@white{}
%    \end{macrocode}
%
% \begin{macro}{\XC@met@grad}
% \begin{macro}{\XC@met@last}
% \begin{macro}{\XC@met@step}
% Methods for color series:
%    \begin{macrocode}
\@tfor\@@tmp:={grad}{last}{step}\do
 {\@namelet{XC@met@\@@tmp}{@@tmp}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Colors}\label{sec.definition}
%
% \begin{macro}{\definecolor}
%   \oarg{type}\marg{name}\marg{model}\marg{spec}\\
% Extends the facilities of \LC's |\definecolor|.
% The optional argument \Meta{type} has currently to be either empty (= normal color definition) or `named'.
% |\definecolor| creates a new command |\\color@|\Meta{name} that contains the \emph{internal representation}
% |\xcolor@|\marg{type-spec}\marg{driver-spec}\marg{n-model}\marg{n-color-spec} of the color, where
% \begin{itemize}
% \item \Meta{type-spec} is either empty (if \Meta{type} was empty), or a driver-dependent macro or expression (if \Meta{type} was `named');
% \item \Meta{driver-spec} is a driver-dependent representation of the color, which also depends on \Meta{type};
% \item \Meta{n-model} is either \Meta{model} or the name of another color model, dependent on the desired transformation(s) at definition time;
% \item \Meta{n-color-spec} are the comma-separated normalised parameter values of the color with respect to \Meta{n-model}.
% \end{itemize}
% See table \vref{tab.internal} for some examples.
%    \begin{macrocode}
\def\definecolor{\@testopt{\XC@definecolor}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definecolor[#1]#2#3#4%
 {\@ifundefined{XC@mod@#3}%
   {\c@lor@error{model `#3'}}%
   {\begingroup
    \edef\@@cls{#1}\XC@edef\@@nam{#2}\edef\@@mod{#3}\XC@edef\@@clr{#4}%
    \XC@logdef\@@nam
    \ifx\@@mod\XC@mod@named
      \XC@@colorlet\@@nam\@@clr
    \else
      \ifconvertcolorsD
        \edef\@@mod{\XC@tgt@mod{#3}}\convertcolorspec{#3}\@@clr\@@mod\@@clr
      \fi
      \XC@coremodel\@@mod\@@clr
%    \end{macrocode}
%
% Determine driver-dependent color definition:
%    \begin{macrocode}
      \csname color@\@@mod\expandafter\endcsname
        \expandafter\@@drv\expandafter{\@@clr}%
%    \end{macrocode}
%
% Handle `named' colors:
%    \begin{macrocode}
      \ifx\@@cls\@empty
        \@temptokena{}%
      \else
        \@nameuse{define@color@\@@cls}{\@@nam}\@@drv
        \@temptokena\expandafter{\@@col}%
        \csname color@\@@cls\expandafter\endcsname
          \expandafter\@@drv\expandafter{\@@nam}%
      \fi
%    \end{macrocode}
%
% Finally write all information into macro |\\color@|\Meta{name}:
%    \begin{macrocode}
      \toks@\expandafter{\@@drv}%
      \edef\@@tmp
       {\ifglobalcolors\global\else\xglobal@\fi
        \noexpand\@namedef{\string\color@\@@nam}%
         {\noexpand\xcolor@{\the\@temptokena}{\the\toks@}{\@@mod}{\@@clr}}}%
    \fi
    \expandafter\endgroup\@@tmp\xglobal@stop}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xdefinecolor}
% This command is identical with |\definecolor|, it is kept mainly for compatibility reasons.
%    \begin{macrocode}
\let\xdefinecolor\definecolor
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\providecolor}
%   \oarg{type}\marg{name}\marg{model}\marg{spec}\\
% Similar to |\definecolor|, but the color \Meta{name} is only defined if it does not exist already.
%    \begin{macrocode}
\def\providecolor{\@testopt{\XC@providecolor}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@providecolor[#1]#2#3#4%
 {\XC@edef\XC@@tmp{#2}%
  \@ifundefined{\string\color@\XC@@tmp}{\definecolor[#1]{#2}{#3}{#4}}%
   {\ifnum\XC@tracing>0
      \PackageInfo{xcolor}{Ignoring color definition `\XC@@tmp'}\fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xcolor@}
%   \marg{type-spec}\marg{driver-spec}\marg{model}\marg{spec}\\
% Simply grabs the driver-specific part of the color definition.
% Therefore, the command |\\color@|\Meta{name} behaves like in the original case, when first-level expanded.
%    \begin{macrocode}
\def\xcolor@#1#2#3#4{#2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\colorlet}
%   \marg{name}\oarg{num model}\marg{color}\\
% Create a color `name' consisting of \Meta{color}, converted to \Meta{num model} if non-empty.
%    \begin{macrocode}
\def\colorlet#1{\@testopt{\XC@colorlet{#1}}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@colorlet#1[#2]#3%
 {\begingroup
  \XC@edef\@@nam{#1}\edef\@@mod{#2}\XC@edef\@@tmp{#3}\XC@@tsttrue
%    \end{macrocode}
%
% Check whether |#2| is empty and |#3| is a defined name: in this case, a simple |\let| command will do the job.
%    \begin{macrocode}
  \@ifundefined{\string\color@\@@tmp}%
    {}{\ifx\@@mod\@empty\XC@@tstfalse\fi}%
  \ifXC@@tst
    \extractcolorspec\@@tmp\@@tmp
    \ifx\@@mod\@empty\else
      \expandafter\convertcolorspec\@@tmp\@@mod\@@tmp
      \edef\@@tmp{{\@@mod}{\@@tmp}}\fi
    \edef\@@tmp{\noexpand\XC@definecolor[]{\@@nam}\@@tmp}%
  \else
    \XC@logdef\@@nam\XC@@colorlet\@@nam\@@tmp
  \fi
  \expandafter\endgroup\@@tmp\xglobal@stop}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@colorlet#1#2%
 {\@ifundefined{\string\color@#2}%
   {\c@lor@error{`#2'}\let\@@tmp\@empty}%
   {\edef\@@tmp
     {\ifglobalcolors\global\else\xglobal@\fi
      \noexpand\@namelet{\string\color@#1}{\string\color@#2}}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DefineNamedColor}
%   \marg{type}\marg{name}\marg{model}\marg{spec}
%    \begin{macrocode}
\def\DefineNamedColor#1{\XC@definecolor[#1]}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Sets of colors}
%
% \begin{macro}{\definecolorset}
%   \oarg{type}\marg{model}\marg{head}\marg{tail}\marg{set spec}\\
% This command facilitates the construction of \emph{color sets} with common underlying \Meta{model} and \Meta{type}.
% Here, \Meta{set spec} = \Meta[1]{name},\Meta[1]{spec};\dots;\Meta[k]{name},\Meta[k]{spec} ($k\ge1$ name/specification pairs).
% Individual colors are being constructed by |\definecolor|\oarg{type}|{|\Meta{head}\Meta[1]{name}\Meta{tail}|}{|\Meta[1]{spec}|}| etc.
%    \begin{macrocode}
\def\definecolorset
 {\let\XC@defclr\definecolor\@testopt{\XC@definecolorset}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definecolorset[#1]#2#3#4#5%
 {\XC@edef\XC@@tmp{#5}\let\XC@@glb\xglobal@
  \def\XC@@definecolorset##1,##2;%
   {\@ifxempty{##1}{}%
     {\let\xglobal@\XC@@glb
      \XC@defclr[#1]{#3##1#4}{#2}{##2}\XC@@definecolorset}}%
  \expandafter\XC@@definecolorset\XC@@tmp;,;}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\providecolorset}
%   \oarg{type}\marg{model}\marg{name-prefix}\marg{name-postfix}\marg{set spec}\\
% Similar to |\definecolorset|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already.
%    \begin{macrocode}
\def\providecolorset
 {\let\XC@defclr\providecolor\@testopt{\XC@definecolorset}{}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Color series}
%
% \begin{macro}{\definecolorseries}
% \XCchanges101{New feature.}
%   \marg{name}\marg{core model}\marg{method}\oarg{b-model}\marg{base color}\oarg{l-model}\marg{delta}
%    \begin{macrocode}
\def\definecolorseries#1#2#3%
 {\@testopt{\XC@definecolorseries{#1}{#2}{#3}}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definecolorseries#1#2#3[#4]#5%
 {\@testopt{\XC@@definecolorseries{#1}{#2}{#3}[#4]{#5}}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@definecolorseries#1#2#3[#4]#5[#6]#7%
 {\begingroup
  \edef\@@mod{#2}%
  \@ifxempty{#4}{\extractcolorspec{#5}\@@clr}{\edef\@@clr{{#4}{#5}}}%
  \expandafter\convertcolorspec\@@clr\@@mod\@@clr
  \@namexdef{\string\colorB@#1}{{\@@mod}{\@@clr}}%
  \edef\@@met{#3}%
  \ifx\@@met\XC@met@last
    \@ifxempty{#6}{\extractcolorspec{#7}\@@tmp}{\edef\@@tmp{{#6}{#7}}}%
    \expandafter\convertcolorspec\@@tmp\@@mod\@@tmp
    \XC@inflate\@@mod\@@tmp\@@clr\@@tmp
    \expandafter\XC@sub\@@tmp,\@@tmp
  \else
    \edef\@@tmp{#7}%
  \fi
  \@namexdef{\string\colorD@#1}{{\@@met}{\@@tmp}}%
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\resetcolorseries}
% \XCchanges101{New feature.}
%   \oarg{div}\marg{name}
%    \begin{macrocode}
\def\resetcolorseries{\@testopt{\XC@resetcolorseries}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@resetcolorseries[#1]#2%
 {\begingroup
  \@namexdef
   {\string\color@#2}{\noexpand\xcolor@{}{}\@nameuse{\string\colorB@#2}}%
  \@namelet{@@tmp}{\string\colorD@#2}%
  \edef\@@met{\expandafter\@firstoftwo\@@tmp}%
  \edef\@@tmp{\expandafter\@secondoftwo\@@tmp}%
  \ifx\@@met\XC@met@step\else
    \edef\@@scl{\@ifxempty{#1}\colorseriescycle{#1}}%
    \expandafter\XC@calc@\@@tmp,,,,:D%
  \fi
  \@namexdef{\string\colorS@#2}{\@@tmp}%
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@step}
% \begin{macro}{\XC@stepabs}
%   \marg{name}\\
% Perform a relative or absolute (= direct access) step within a color series \Meta{name}.
% In the relative case, the (non-negative) number of single steps is supposed to be stored in |\@tempcnta|.
%    \begin{macrocode}
\def\XC@step#1%
 {\let\xcolor@\@gobbletwo\edef\@@tmp{\@nameuse{\string\color@#1}}%
  \expandafter\XC@@step\@@tmp{#1}%
  \@namexdef{\string\color@#1}{\noexpand\xcolor@{}{}{\@@mod}{\@@tmp}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@step#1#2#3%
 {\def\@@mod{#1}\def\@@tmp{#2}\edef\@@vec{\@nameuse{\string\colorS@#3}}%
  \@whilenum\@tempcnta>\z@\do
   {\XC@inflate\@@mod\@@tmp\@@vec\@@tmp
    \expandafter\XC@add\@@tmp,\@@tmp \expandafter\XC@calc@\@@tmp,,,,:U%
    \advance\@tempcnta\m@ne}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@stepabs#1%
 {\edef\@@tmp{\@nameuse{\string\colorB@#1}}%
  \expandafter\XC@@step\@@tmp{#1}%
  \edef\@@tmp
   {\noexpand\def\noexpand\@@mod{\@@mod}%
    \noexpand\def\noexpand\@@clr{\@@tmp}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Color blending}
%
% \begin{macro}{\blendcolors}
% \begin{macro}{\blendcolors*}
%   \marg{mix expr}\\
% Initialises all necessary parameters for color blending.
% The actual (completed) color blend expression is stored in |\colorblend|.
% In the starred version, the argument will be appended to a previously defined blend expression.
% An empty \Meta{mix expr} argument will switch blending off.
%    \begin{macrocode}
\def\blendcolors{\@ifstar{\XC@blendcolors\colorblend}{\XC@blendcolors{}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@blendcolors#1#2%
 {\edef\colorblend{#1}\XC@edef\XC@@tmp{#2}%
  \ifx\XC@@tmp\@empty
    \xglobal@\blendcolorsfalse
  \else
    \xglobal@\blendcolorstrue
    \expandafter\XC@@blendcolors\XC@@tmp!!\@nil
  \fi
  \xglobalize@\colorblend \xglobal@stop}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@blendcolors!#1!#2!#3\@nil
 {\@ifxempty{#1}{}%
   {\@ifxempty{#2}%
    {\edef\colorblend{\colorblend!#1!white}}%
    {\edef\colorblend{\colorblend!#1!#2}\XC@@blendcolors!#3!\@nil}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\blendcolors{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Color masks and separation}
%
% \begin{macro}{\maskcolors}
%   \oarg{core model}\marg{color}\\
% Initialises all necessary parameters for color masking.
% The actual color mask expression is stored in |\colormask|.
% An empty \Meta{color} argument will switch masking off.
% The optional \Meta{core model} argument may be used to determine the underlying color model.
%    \begin{macrocode}
\def\maskcolors{\@testopt{\XC@maskcolors}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@maskcolors[#1]#2%
 {\XC@edef\colormask{#2}%
  \ifx\colormask\@empty
    \xglobal@\maskcolorsfalse \def\XC@mmod{}\def\XC@mclr{}%
  \else
    \xglobal@\maskcolorstrue \extractcolorspec\colormask\XC@mclr
    \edef\XC@mmod{\expandafter\@firstoftwo\XC@mclr}%
    \edef\XC@mclr{\expandafter\@secondoftwo\XC@mclr}%
    \@ifxempty{#1}{}%
     {\convertcolorspec\XC@mmod\XC@mclr{#1}\XC@mclr \edef\XC@mmod{#1}}%
    \XC@coremodel\XC@mmod\XC@mclr
  \fi
  \xglobalize@\colormask \xglobalize@\XC@mmod \xglobalize@\XC@mclr
  \xglobal@stop}
%    \end{macrocode}
%
%    \begin{macrocode}
\maskcolors{}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Color application}
%
% \subsubsection{The core command}
%
%  \begin{macro}{\color}
%   \marg{color}\\
%   \oarg{model}\marg{spec}\\
% Switches to the color given either by name/expression or by model/specification.
% This color will stay in effect until the end of the current \TeX\ group.
%    \begin{macrocode}
\DeclareRobustCommand\color
 {\@ifnextchar[\@undeclaredcolor\@declaredcolor}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\@undeclaredcolor}
%   \oarg{model}\marg{spec}\\
% Display a color that is given by \Meta{model} name and numerical \Meta{spec}.
%    \begin{macrocode}
\def\@undeclaredcolor[#1]#2%
 {\begingroup
  \edef\@@mod{#1}\XC@edef\@@clr{#2}%
  \ifblendcolors
    \ifx\colorblend\@empty\else
      \edef\@@mix{\expandafter\@gobble\colorblend}\@tempswafalse
      \XC@coremodel\@@mod\@@clr\@xcolor@{}{}\@@mod\@@clr
    \fi
  \fi
  \ifconvertcolorsU
    \edef\@@tmp{\XC@tgt@mod{\@@mod}}%
    \convertcolorspec\@@mod\@@clr\@@tmp\@@clr \let\@@mod\@@tmp
  \fi
  \ifmaskcolors
    \convertcolorspec\@@mod\@@clr\XC@mmod\@@clr
    \let\@@mod\XC@mmod
    \XC@inflate\@@mod\XC@mclr\@@clr\@@tmp
    \expandafter\XC@mul\@@tmp,\@@clr
  \fi
  \edef\@@tmp{\noexpand\XC@undeclaredcolor{\@@mod}{\@@clr}}%
  \expandafter\endgroup\@@tmp}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@undeclaredcolor#1#2%
 {\@ifundefined{color@#1}%
   {\c@lor@error{model `#1'}}%
   {\@nameuse{color@#1}\current@color{#2}%
    \edef\XC@current@color{\noexpand\xcolor@{}{\current@color}{#1}{#2}}%
    \XC@display}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@declaredcolor}
%   \marg{color}\\
% Display a color that is given by an arbitrary \Meta{color}.
%    \begin{macrocode}
\def\@declaredcolor#1%
 {\XC@edef\XC@@tmp{#1}\XC@@tstfalse
  \ifcase\XC@type{\XC@@tmp}\relax \XC@@tsttrue\or \relax\else
    \ifblendcolors\XC@@tsttrue\fi \ifmaskcolors\XC@@tsttrue\fi
    \ifconvertcolorsU\XC@@tsttrue\fi
  \fi
  \ifXC@@tst
    \expandafter\XC@declaredcolor
  \else
    \expandafter\XC@@declaredcolor
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@declaredcolor
 {\XC@split\XC@@tmp
  \edef\@@tmp{\noexpand\@undeclaredcolor[\@@mod]{\@@clr}}%
  \expandafter\endgroup\@@tmp}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@declaredcolor
 {\@namelet{XC@current@color}{\string\color@\XC@@tmp}%
  \edef\current@color{\XC@current@color}%
  \XC@display}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Internal commands}
%
% \begin{macro}{\@xcolor@}
%   \marg{type-spec}\marg{driver-spec}\marg{model}\marg{spec}\\
% This is the `work-horse' that does all necessary conversions and calculations if a color (expression) has to be displayed.
% \Meta{type-spec}  and \Meta{driver-spec} are ignored.
% |\@@mix| may contain a mix expression without leading `!'.
%    \begin{macrocode}
\def\@xcolor@#1#2#3#4%
 {\edef\@@mod{#3}\edef\@@clr{#4}%
  \ifx\@@mix\@empty\else\expandafter\@xcolor@@\@@mix!!!!\@nil\fi
  \if@tempswa
    \@namelet{@@tmp}{XC@cnv@\@@mod @compl}%
    \ifx\@@tmp\relax \expandafter\XC@calc@\@@clr,,,,:C\else
                     \expandafter\@@tmp\@@clr,\fi
    \let\@@clr\@@tmp
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@xcolor@@#1!#2!#3!#4!#5\@nil
 {\dimen@\@ifxempty{#1}{100}{#1}\p@
  \edef\@@mix{\@ifxempty{#2}{white}{#2}}%
  \ifdim\dimen@=100\p@
    \expandafter\XC@postfix\@@mix]\relax
  \else\ifdim\dimen@=\z@
    \extractcolorspec\@@mix\@@tmp
    \edef\@@mod{\expandafter\@firstoftwo\@@tmp}%
    \edef\@@clr{\expandafter\@secondoftwo\@@tmp}%
  \else
    \@namelet{@@tmp}{XC@clr@\@@mod @\@@mix}%
    \ifx\@@tmp\relax
      \extractcolorspec\@@mix\@@tmp
      \ifx\@@mod\XC@mod@gray
        \edef\@@mod{\expandafter\@firstoftwo\@@tmp}%
          \edef\@@tmp{\expandafter\@secondoftwo\@@tmp}%
          \convertcolorspec\XC@mod@gray\@@clr\@@mod\@@clr
      \else
        \expandafter\convertcolorspec\@@tmp\@@mod\@@tmp
      \fi
    \else
      \ifx\@@mod\XC@mod@hsb\expandafter\XC@extract@hue\@@clr:\@@hue\fi
    \fi
    \XC@inflate\@@mod\@@clr\@@tmp\@@tmp
    \expandafter\XC@mix\@@tmp,\@@clr
  \fi\fi
  \@ifxempty{#3}%
   {\@ifxempty{#4}{}{\@xcolor@@!#4!#5\@nil}}%
   {\@xcolor@@#3!#4!#5\@nil}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split}
%   \marg{ext expr}\\
% Split \Meta{ext expr} into all of its components, do the necessary calculations, and save the model of the resulting color in |\@@mod| and the parameters in |\@@clr|.
% Note: |\XC@split| opens a group which has to be closed afterwards by |\endgroup|.
%    \begin{macrocode}
\def\XC@split#1%
 {\begingroup\XC@edef\@@tmp{#1}\expandafter\XC@split@i\@@tmp:\@nil}
%    \end{macrocode}
%
% \begin{macro}{\XC@split@i}
% Check whether it is an \emph{extended} or \emph{standard} color expression.
%    \begin{macrocode}
\def\XC@split@i#1:#2\@nil
 {\@ifxempty{#2}{\XC@split@v}{\XC@split@ii#1,,:#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@ii}
% Initialisation for extended color expressions.
% The magic \Meta{div} is either given as second argument, or calculated as the sum of all weights.
%    \begin{macrocode}
\def\XC@split@ii#1,#2,#3:#4:%
 {\edef\XC@@mod{\@nameuse{XC@mod@#1}}\let\@tempa\@empty
  \@ifxempty{#2}{\XC@@tsttrue\@tempdima\z@}{\XC@@tstfalse\@tempdima#2\p@}%
  \XC@split@iii#4;,;}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@iii}
%   \marg{expr}\marg{dec}\\
% Step through the list of \Meta{expr},\Meta{dec} pairs.
% Add \Meta{dec} to the sum of weights (in order to calculate the ultimate \Meta{div}) and append pair information to |\@tempa| command.
% At the end of the list, execute |\@tempa| and map resulting parameter vector into unit cube.
% Finally, |\@@mod| and |\@@clr| contain the desired information about color model and parameters.
%    \begin{macrocode}
\def\XC@split@iii#1,#2;%
 {\@ifxempty{#1}%
   {\let\XC@@clr\@empty \@tempa \expandafter\XC@calc@\XC@@clr,,,,:U%
    \let\@@mod\XC@@mod \let\@@clr\@@tmp}
   {\XC@append\@tempa{\XC@split@iv{#1}{#2}}%
    \ifXC@@tst\advance\@tempdima#2\p@\fi
    \XC@split@iii}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@iv}
%   \marg{expr}\marg{dec}\\
% Extract color specification from \Meta{expr}, convert to target model, multiply the resulting vector by the quotient of \Meta{dec} and \Meta{div}, add that vector to the overall parameter vector.
%    \begin{macrocode}
\def\XC@split@iv#1#2%
 {\def\@@tmp{#1}\XC@split@v
  \ifx\@@mod\XC@@mod\else
    \convertcolorspec\@@mod\@@clr\XC@@mod\@@clr
  \fi
  \dimen@#2\p@ \rdivide\dimen@\@tempdima
  \edef\@@scl{\strip@pt\dimen@}%
  \expandafter\XC@calc@\@@clr,,,,:S%
  \ifx\XC@@clr\@empty\let\XC@@clr\@@tmp\else
    \XC@inflate\XC@@mod\XC@@clr\@@tmp\@@tmp
    \expandafter\XC@add\@@tmp,\XC@@clr
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@v}
% Start splitting process for standard color expression.
%    \begin{macrocode}
\def\XC@split@v{\count@\z@ \expandafter\XC@split@vi\@@tmp!\@nil}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@vi}
% Count number of `-' signs at the beginning of the string.
%    \begin{macrocode}
\def\XC@split@vi#1%
 {\ifx#1-\advance\count@\@ne\expandafter\XC@split@vi
  \else\expandafter\XC@split@vii\expandafter#1\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@vii}
% Extract \Meta{name} and \Meta{mix expr} part of color expression.
% Delegate control to |\@xcolor@|.
%    \begin{macrocode}
\def\XC@split@vii#1!#2\@nil
 {\edef\@@nam{#1}\edef\@@mix{#2}%
  \ifodd\count@\@tempswatrue\else\@tempswafalse\fi
  \@ifundefined{\string\color@\@@nam}%
   {\c@lor@error{`\@@nam'}\def\@@nam{black}}{}%
  \let\xcolor@\@xcolor@\@nameuse{\string\color@\@@nam}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\XC@postfix}
% Examine the postfix of a color expression and derive the actions to be taken for color series.
%    \begin{macrocode}
\def\XC@postfix#1#2]#3\relax
 {\begingroup
  \if#1[\@tempcnta#2\relax\XC@stepabs\@@nam
  \else\@tempcnta\z@
    \@tfor\@@tok:=#1#2\do
     {\if\@@tok+\advance\@tempcnta\@ne
      \else\if\@@tok-\advance\@tempcnta\m@ne
      \else\@tempcnta\z@\expandafter\@break@tfor\fi\fi}%
    \ifnum\@tempcnta=\z@\relax\else\XC@step\@@nam\fi
    \let\@@tmp\@empty
  \fi\expandafter\endgroup\@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@display}
% Write information to log file and display the current color.
%    \begin{macrocode}
\def\XC@display
 {\XC@bcolor\@namelet{\string\color@.}{XC@current@color}%
  \ifnum\XC@type{.}=1
    \PackageWarning{xcolor}{Incompatible color definition}%
  \else
    \ifnum\XC@tracing>2
      \begingroup \let\xcolor@\@empty \def\@nil{\string\@nil}%
      \PackageInfo{xcolor}{Setting color `\XC@current@color'}%
      \endgroup
    \fi
  \fi
  \XC@mcolor\set@color\XC@ecolor\ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@bcolor}
% \begin{macro}{\XC@mcolor}
% \begin{macro}{\XC@ecolor}
% Hooks that may be used to execute additional code within |\XC@display| immediately before/after a color is being displayed.
% Note that |\XC@bcolor| can use the current color information given by |\current@color| and |\XC@current@color| if further manipulation of the color is necessary.
% These hooks are intended for class/package writers and not used by \XC{} itself.
% In order to prevent unwanted side effects, please make sure that all internal \XC{} variables are restored properly at the end of |\XC@display|.
%    \begin{macrocode}
\let\XC@bcolor\relax
\let\XC@mcolor\relax
\let\XC@ecolor\relax
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Additional user-level commands}
%
%  \begin{macro}{\textcolor}
%   \marg{color}\marg{text}\\
%   \oarg{model}\marg{spec}\marg{text}\\
% are just alternative syntax for |\color|, in which the groups are added implicitly.
% Thus \emph{text} appears in the specified color, but then the color reverts to its previous value.
% The naming is by analogy with |\textrm| (as opposed to |\rm| and |\rmfamily|) although it is slightly a misnomer as the command also works in math-mode.
% Additionally, it calls |\leavevmode| to ensure the start of horizontal mode.
%    \begin{macrocode}
\def\textcolor#1#{\@textcolor{#1}}
\def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\color@block}
%   \marg{width}\marg{height}\marg{depth}\\
% Should take up no space for \TeX, but produce a block in the current color of the specified size.
% It is mainly used for producing box backgrounds.
%
% The definition here works by selecting a color, and then drawing a \TeX\ rule (unless |\ifcolors@false|).
% This allows the `driver independent' color specials to be used.
% A graphics package may want to define it using a |\special| to produce (for example) a PostScript line.
% Producing the line in the |\special| has the advantage that on a preview that does not understand |\special|s, the line is automatically omited, without needing to modify the source of the document (for instance by adding the \Option{monochrome} option).
%    \begin{macrocode}
\def\color@block#1#2#3{%
 {\set@color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\colorbox}
%   \marg{color}\marg{text}\\
%   \oarg{model}\marg{spec}\marg{text}\\
% Takes the same argument forms as |\textcolor|, but the color specifies the \emph{background} color of the box.
%    \begin{macrocode}
\def\colorbox#1#{\color@box{#1}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\color@box#1#2{\color@b@x\relax{\color#1{#2}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fcolorbox}
%   \marg{frame color}\marg{background color}\marg{text}\\
%   \oarg{model}\marg{frame spec}\marg{background spec}\marg{text}\\
% Puts a frame of the first color around a box with a background specified by the second color.
% If an optional argument is given, it specifies the color model for both colors.
%    \begin{macrocode}
\def\fcolorbox#1#{\color@fbox{#1}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\color@fbox#1#2#3{%
  \color@b@x{\fboxsep\z@\color#1{#2}\fbox}{\color#1{#3}}}
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\color@b@x}
% Internal macro for |\colorbox| and |\fcolorbox|.
%    \begin{macrocode}
\long\def\color@b@x#1#2#3{%
 \leavevmode
 \setbox\z@\hbox{\kern\fboxsep{\set@color#3}\kern\fboxsep}%
 \dimen@\ht\z@\advance\dimen@\fboxsep\ht\z@\dimen@
 \dimen@\dp\z@\advance\dimen@\fboxsep\dp\z@\dimen@
 {#1{#2\color@block{\wd\z@}{\ht\z@}{\dp\z@}%
      \box\z@}}}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Background (page) color}
%
% \begin{macro}{\pagecolor}
%   \marg{color}\\
%   \oarg{model}\marg{spec}\\
% Specifies the background color for the current, and all following, pages.
% It is a global declaration which does not respect \TeX\ groups.
%    \begin{macrocode}
\def\pagecolor
 {\begingroup
  \let\ignorespaces\endgroup \let\set@color\set@page@color
  \color}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Border colors for hyperlinks}
%
% \begin{macro}{\XC@bordercolor}
%   \marg{type}\marg{color}\\
% Basic macro to transform \Meta{color} into the format required by \Package{hyperref}.
% Here, \Meta{type} corresponds to the key `x\Meta{type}bordercolor'.
%    \begin{macrocode}
\def\XC@bordercolor#1#2%
 {\extractcolorspec{#2}\XC@@tmp
  \expandafter\convertcolorspec\XC@@tmp\XC@mod@rgb\XC@@tmp
  \expandafter\edef\csname @#1bordercolor\endcsname
   {\expandafter\XC@@bordercolor\XC@@tmp,}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@bordercolor#1,#2,#3,{#1 #2 #3}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@pdfborder}
%   \Meta[1]{number}| |\Meta[2]{number}| |\Meta[3]{number}|\relax|\\
% Basic macro to transform a pdfborder expression into a suitable format for |dvips| with a resolution of 8000~dpi.
%    \begin{macrocode}
\def\XC@pdfborder#1 #2 #3\relax
 {\def\@@scl{80}\XC@calc@#1,#2,#3,,:S%
  \edef\@pdfborder{\expandafter\XC@@bordercolor\@@tmp,}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Colored rows in tables}
%
% The following definitions make only sense if the \Package{colortbl} package has been loaded at some point.
%    \begin{macrocode}
\AtBeginDocument{\@ifundefined{ver@colortbl.sty}{}{%
%    \end{macrocode}
%
% \begin{macro}{\rowcolors}
% \begin{macro}{\rowcolors*}
%   \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\
% Defines alternating colors for the next tabular environment.
% Starting with row \Meta{row}, odd and even rows get their respective colors.
% The color arguments may also be left empty (= no color).
% Optional commands may be |\hline| or |\noalign|\marg{stuff}.
%    \begin{macrocode}
 \def\rowcolors{\@ifstar{\@rowcmdfalse\rowc@lors}{\@rowcmdtrue\rowc@lors}}%
%    \end{macrocode}
%
%    \begin{macrocode}
 \def\rowc@lors{\@testopt{\rowc@l@rs}{}}%
%    \end{macrocode}
%
%    \begin{macrocode}
 \def\rowc@l@rs[#1]#2#3#4%
  {\global\rownum=\z@
   \global\@rowcolorstrue
   \@ifxempty{#3}%
     {\def\@oddrowcolor{\@norowcolor}}%
     {\def\@oddrowcolor{\gdef\CT@row@color{\CT@color{#3}}}}%
   \@ifxempty{#4}%
     {\def\@evenrowcolor{\@norowcolor}}%
     {\def\@evenrowcolor{\gdef\CT@row@color{\CT@color{#4}}}}%
   \if@rowcmd
     \def\@rowcolors
      {#1\if@rowcolors
         \noalign{\relax\ifnum\rownum<#2\@norowcolor\else
                  \ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi\fi}%
       \fi}%
   \else
     \def\@rowcolors
      {\if@rowcolors
         \ifnum\rownum<#2\noalign{\@norowcolor}\else
         #1\noalign{\ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi}\fi
       \fi}%
   \fi
   \CT@everycr{\noalign{\rownum@step}\@rowcolors\the\everycr}%
   \ignorespaces}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\showrowcolors}
% \begin{macro}{\hiderowcolors}
% Switch coloring mode on/off.
%    \begin{macrocode}
 \def\showrowcolors{\noalign{\global\@rowcolorstrue}\@rowcolors}%
 \def\hiderowcolors{\noalign{\global\@rowcolorsfalse\@norowcolor}}%
 \def\@norowcolor{\global\let\CT@row@color\relax}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@rowcolors}
% \begin{macro}{\if@rowcmd}
%    \begin{macrocode}
 \newif\if@rowcolors
 \newif\if@rowcmd
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rownum}
% Reserve a counter register.
%    \begin{macrocode}
 \ifx\rownum\@undefined\newcount\rownum\fi
 \def\rownum@step{\global\advance\rownum\@ne}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@extract}
% This is a fix for active `!' character to enable color expressions; it is apparently only necessary for |\columncolor| commands within |\multicolumn|.
%    \begin{macrocode}
 \def\CT@extract#1\columncolor#2#3\@nil{%
   \if!#2%
     \let\CT@column@color\@empty
   \else
     \if[#2%
       \CT@extractb{#1}#3\@nil
     \else
       \XC@edef\XC@@tmp{#2}%
       \edef\CT@column@color{\noexpand\CT@color{\XC@@tmp}}%
       \CT@extractd{#1}#3\@nil
     \fi
   \fi}%
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
 }}
%    \end{macrocode}
%
%
% \subsubsection{Color information}
%
% \begin{macro}{\extractcolorspec}
%   \marg{color}\marg{cmd}\\
% Extracts the color specification of \Meta{color} and puts it into \Meta{cmd}; equivalent to
% |\def|\Meta{cmd}|{|\marg{model}\marg{spec}|}|.
%    \begin{macrocode}
\def\extractcolorspec#1#2%
 {\XC@split{#1}\aftergroupdef#2{{\@@mod}{\@@clr}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@extract@hue#1,#2:#3{\edef#3{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@type}
%   \marg{name}\\
% Determines the \emph{type} of color \Meta{name}, expressed as a natural number (here, $t_1,t_2,\dots$ denote the tokens of |\\color@|\Meta{name}):
% \begin{center}
% \begin{tabular}{cll}
% \em type& \em description& \em conditions\\
% 0 & undefined\\
% 1 & unidentified& $t_1\neq|\xcolor@|$\\
% 2 & named & $t_1=|\xcolor@|\quad t_2\neq\emptyset$\\
% 3 & declared & $t_1=|\xcolor@|\quad t_2=\emptyset\quad t_3\neq\emptyset$\\
% 4 & undeclared & $t_1=|\xcolor@|\quad t_2=\emptyset\quad t_3=\emptyset$\\
% \end{tabular}
% \end{center}
%    \begin{macrocode}
\def\XC@type#1%
 {\expandafter\expandafter\expandafter\XC@@type
  \csname\string\color@#1\endcsname\@empty\@empty\@empty\XC@@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@type#1#2#3#4\XC@@
 {\ifx#1\relax 0\else
    \ifx#1\xcolor@
      \ifx$#2$%
        \ifx$#3$4\else3\fi\@gobbletwo
      \else2\fi\@gobbletwo
    \else1\fi
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tracingcolors}
% Put the integer following |\tracingcolors| into the macro |\XC@tracing|.
%    \begin{macrocode}
\def\tracingcolors{\begingroup\afterassignment\XC@tracingcolors\count@}
\def\XC@tracingcolors{\aftergroupdef\XC@tracing{\the\count@}}
%    \end{macrocode}
%
%    \begin{macrocode}
\tracingcolors=0
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@logdef}
%   \marg{name}\\
% Issue a log file information if color \Meta{name} is being (re)defined.
%    \begin{macrocode}
\def\XC@logdef#1%
 {\ifnum\XC@tracing>1
    \@ifundefined{\string\color@#1}%
     {\ifnum\XC@tracing>2
        \PackageInfo{xcolor}{Defining color `#1'}%
      \fi}%
     {\PackageInfo{xcolor}{Redefining color `#1'}}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Extra groups}
% Turning on extra groups in the standard \LaTeX\ commands, so that color commands are scoped corectly.
%
% Like |\normalcolor|, the following five commands are defined in the kernel, with empty definitions (|\relax|).
% This means that they can be used to make macros in packages `color safe'.
% The commands will not have any effect unless a user also uses a color package, when the `active definitions' here will take effect and keep color commands correctly scoped.
%
% \begin{macro}{\color@setgroup}
% This is to be used in contexts (eg `lrbox') where text is to be saved and used after some other, unknown, text that may contain color commands.
% A matching |\color@endgroup| should be used at the end of the text.
%    \begin{macrocode}
\def\color@setgroup{\begingroup\set@color}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@begingroup}
% This is to be used at the start of contexts that may contain color commands, but where it is not necessary to save the current color.
% Examples of this are in the box commands of \File{ltboxes.dtx} where user-supplied text is saved internally in a box between |\color@begingroup|, |\color@endgroup|, but the box is used before any other color commands could intervene.
% A matching |\color@endgroup| should be used at the end of the text.
%    \begin{macrocode}
\let\color@begingroup\begingroup
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@endgroup}
% To be used to close the `group' started by one of the above two commands.
% The |\endgraf| in its definition is required in the case of groups of text in vertical `par' mode, but doesn't do any harm in horizontal `LR' contexts.
%    \begin{macrocode}
\def\color@endgroup{\endgraf\endgroup}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@hbox}
% To be used to open a `colored hbox'
%    \begin{macrocode}
\def\color@hbox{\hbox\bgroup\color@begingroup}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@vbox}
% To be used to open a `colored hbox'
%    \begin{macrocode}
\def\color@vbox{\vbox\bgroup\color@begingroup}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@endbox}
% To be used to close a `colored (h/v)box'
%    \begin{macrocode}
\def\color@endbox{\color@endgroup\egroup}
%    \end{macrocode}
%  \end{macro}
%
%
%
% \subsection{Color calculation}
%
% \subsubsection{Color conversion}
%
% \begin{macro}{\convertcolorspec}
%   \marg{source model}\marg{spec}\marg{target model}\marg{cmd}\\
% General color conversion command.
%    \begin{macrocode}
\def\convertcolorspec#1#2#3#4%
 {\begingroup
  \edef\sm{#1}\edef\tm{#3}\edef\@@tmp{#2}%
  \ifx\sm\XC@mod@named
    \extractcolorspec\@@tmp\@@tmp
    \edef\sm{\expandafter\@firstoftwo\@@tmp}%
    \edef\@@tmp{\expandafter\@secondoftwo\@@tmp}%
  \fi
  \ifx\sm\tm\else\csname XC@cnv@\sm\expandafter\endcsname\@@tmp,\fi
  \aftergroupdef#4\@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@coremodel}
%   \marg{model-cmd}\marg{color-cmd}\\
% Convert color, given by \marg{model-cmd} and \marg{color-cmd}, into parametrisation in one of the \emph{core} models.
% The result is again saved in \marg{model-cmd} and \marg{color-cmd}.
%    \begin{macrocode}
\def\XC@coremodel#1#2%
 {\ifx#1\XC@mod@RGB
    \convertcolorspec#1#2\XC@mod@rgb#2\let#1\XC@mod@rgb\else
  \ifx#1\XC@mod@HTML
    \convertcolorspec#1#2\XC@mod@rgb#2\let#1\XC@mod@rgb\else
  \ifx#1\XC@mod@HSB
    \convertcolorspec#1#2\XC@mod@hsb#2\let#1\XC@mod@hsb\else
  \ifx#1\XC@mod@Gray
    \convertcolorspec#1#2\XC@mod@gray#2\let#1\XC@mod@gray\else
  \ifx#1\XC@mod@named\else
  \expandafter\XC@calc@#2,,,,:N\let#2\@@tmp
  \fi\fi\fi\fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@rgb}
%   \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,|
%    \begin{macrocode}
\def\XC@cnv@rgb#1,#2,#3,%
 {\ifx\tm\XC@mod@cmy
    \XC@calc@#1,#2,#3,,:C%
  \else\ifx\tm\XC@mod@cmyk
    \XC@calc@#1,#2,#3,,:C\expandafter\XC@cnv@cmy@cmyk\@@tmp,%
  \else\ifx\tm\XC@mod@hsb
    \XC@cnv@rgb@hsb#1,#2,#3,%
  \else\ifx\tm\XC@mod@gray
    \XC@cnv@rgb@gray#1,#2,#3,%
  \else\ifx\tm\XC@mod@RGB
    \edef\@@scl{\rangeRGB}\XC@calc@#1,#2,#3,,:M%
  \else\ifx\tm\XC@mod@HTML
    \edef\@@scl{\@cclv}\XC@calc@#1,#2,#3,,:M%
    \expandafter\XC@calc@\@@tmp,,:H%
    \expandafter\XC@cnv@rgb@HTML\@@tmp,%
  \else\ifx\tm\XC@mod@HSB
    \XC@cnv@rgb@hsb#1,#2,#3,%
    \edef\@@scl{\rangeHSB}\expandafter\XC@calc@\@@tmp,,:M%
  \else\ifx\tm\XC@mod@Gray
    \XC@cnv@rgb@gray#1,#2,#3,%
    \edef\@@scl{\rangeGray}\XC@calcM\@@tmp\@@tmp
  \else
    \XC@calc@#1,#2,#3,,:N%
  \fi\fi\fi\fi\fi\fi\fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@rgb@hsb}
%   \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,|
%    \begin{macrocode}
\def\XC@cnv@rgb@hsb#1,#2,#3,%
 {\count@\z@
  \ifdim#2\p@>#1\p@ \else\advance\count@4 \fi
  \ifdim#3\p@>#2\p@ \else\advance\count@2 \fi
  \ifdim#1\p@>#3\p@ \else\advance\count@1 \fi
  \ifcase\count@\or
  \XC@@cnv@rgb@hsb{#3}{#2}{#1}3{}\or
  \XC@@cnv@rgb@hsb{#2}{#1}{#3}1{}\or
  \XC@@cnv@rgb@hsb{#2}{#3}{#1}3-\or
  \XC@@cnv@rgb@hsb{#1}{#3}{#2}5{}\or
  \XC@@cnv@rgb@hsb{#3}{#1}{#2}5-\or
  \XC@@cnv@rgb@hsb{#1}{#2}{#3}1-\or
  \def\@tempa{0}\def\@tempb{0}\XC@calcN{#3}\@tempc
  \fi
  \edef\@@tmp{\@tempa,\@tempb,\@tempc}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@@cnv@rgb@hsb}
%   \marg{max}\marg{med}\marg{min}\marg{const}\marg{sign}
%    \begin{macrocode}
\def\XC@@cnv@rgb@hsb#1#2#3#4#5%
 {\XC@calcN{#1}\@tempc \llshiftset\dimen@{#1}%
  \llshiftset\@tempdimb{-#3}\advance\@tempdimb\dimen@
  \llshiftset\@tempdima{-#5#2}\advance\@tempdima#5\dimen@
  \advance\@tempdima#4\@tempdimb \rdivide\@tempdima{6\@tempdimb}%
  \edef\@tempa{\ifdim\@tempdima>\p@1\else\strip@pt\@tempdima\fi}%
  \rdivide\@tempdimb\dimen@
  \edef\@tempb{\strip@pt\@tempdimb}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@rgb@gray}
%   \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,|
%    \begin{macrocode}
\def\XC@cnv@rgb@gray#1,#2,#3,%
 {\llshiftset\dimen@{#1}\@tempdima30\dimen@
  \llshiftset\dimen@{#2}\advance\@tempdima59\dimen@
  \llshiftset\dimen@{#3}\advance\@tempdima11\dimen@
  \rrshift\@tempdima \rdivide\@tempdima{100}%
  \edef\@@tmp{\strip@pt\@tempdima}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@rgb@HTML}
%   \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,|
%    \begin{macrocode}
\def\XC@cnv@rgb@HTML#1,#2,#3,%
 {\edef\@@tmp{#1#2#3}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@cmy}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|
%    \begin{macrocode}
\def\XC@cnv@cmy#1,#2,#3,%
 {\ifx\tm\XC@mod@rgb
    \XC@calc@#1,#2,#3,,:C%
  \else\ifx\tm\XC@mod@cmyk
    \XC@cnv@cmy@cmyk#1,#2,#3,%
  \else\ifx\tm\XC@mod@hsb
    \XC@calc@#1,#2,#3,,:C\expandafter\XC@cnv@rgb@hsb\@@tmp,%
  \else\ifx\tm\XC@mod@gray
    \XC@cnv@rgb@gray#1,#2,#3,\XC@calcC\@@tmp\@@tmp
  \else\ifx\tm\XC@mod@RGB
    \XC@calc@#1,#2,#3,,:C%
    \edef\@@scl{\rangeRGB}\expandafter\XC@calc@\@@tmp,,:M%
  \else\ifx\tm\XC@mod@HTML
    \XC@calc@#1,#2,#3,,:C\expandafter\XC@cnv@rgb\@@tmp,%
  \else\ifx\tm\XC@mod@HSB
    \XC@calc@#1,#2,#3,,:C\expandafter\XC@cnv@rgb@hsb\@@tmp,%
    \edef\@@scl{\rangeHSB}\expandafter\XC@calc@\@@tmp,,:M%
  \else\ifx\tm\XC@mod@Gray
    \XC@cnv@rgb@gray#1,#2,#3,\XC@calcC\@@tmp\@@tmp
    \edef\@@scl{\rangeGray}\XC@calcM\@@tmp\@@tmp
  \else
    \XC@calc@#1,#2,#3,,:N%
  \fi\fi\fi\fi\fi\fi\fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@cmy@cmyk}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\\
% This transformation includes linear \emph{undercolor-removal} and \emph{black-generation}, as specified by the 4-dimensional parameter vector |\adjustUCRBG|.
%    \begin{macrocode}
\def\XC@cnv@cmy@cmyk#1,#2,#3,%
 {\edef\@@scl
   {\ifdim#1\p@<#2\p@
    \ifdim#1\p@<#3\p@ #1\else #3\fi \else
    \ifdim#2\p@<#3\p@ #2\else #3\fi \fi}%
  \expandafter\XC@calc@\adjustUCRBG,:S%
  \expandafter\XC@@cnv@cmy@cmyk\@@tmp,#1,#2,#3,}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@cnv@cmy@cmyk#1,#2,#3,#4,#5,#6,#7,%
 {\XC@add#5,#6,#7,,-#1,-#2,-#3,,\@@tmp \edef\@@tmp{\@@tmp,#4}%
  \expandafter\XC@calc@\@@tmp,:N}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@cmyk}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\Meta{black}|,|
%    \begin{macrocode}
\def\XC@cnv@cmyk#1,#2,#3,#4,%
 {\ifx\tm\XC@mod@rgb
    \XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@calc@\@@tmp,,:C%
  \else\ifx\tm\XC@mod@cmy
    \XC@cnv@cmyk@cmy#1,#2,#3,#4,%
  \else\ifx\tm\XC@mod@hsb
    \XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@calc@\@@tmp,,:C%
    \expandafter\XC@cnv@rgb@hsb\@@tmp,%
  \else\ifx\tm\XC@mod@gray
    \XC@cnv@rgb@gray#1,#2,#3,%
    \edef\@@arg{#4}\XC@calcT\@@tmp\@@tmp \XC@calcC\@@tmp\@@tmp
  \else\ifx\tm\XC@mod@RGB
    \XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@calc@\@@tmp,,:C%
    \edef\@@scl{\rangeRGB}\expandafter\XC@calc@\@@tmp,,:M%
  \else\ifx\tm\XC@mod@HTML
    \XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@cnv@cmy\@@tmp,%
  \else\ifx\tm\XC@mod@HSB
    \XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@calc@\@@tmp,,:C%
    \expandafter\XC@cnv@rgb@hsb\@@tmp,%
    \edef\@@scl{\rangeHSB}\expandafter\XC@calc@\@@tmp,,:M%
  \else\ifx\tm\XC@mod@Gray
    \XC@cnv@rgb@gray#1,#2,#3,%
    \edef\@@arg{#4}\XC@calcT\@@tmp\@@tmp \XC@calcC\@@tmp\@@tmp
    \edef\@@scl{\rangeGray}\XC@calcM\@@tmp\@@tmp
  \else
    \XC@calc@#1,#2,#3,#4,:N%
  \fi\fi\fi\fi\fi\fi\fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@cmyk@cmy}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\Meta{black}|,|
%    \begin{macrocode}
\def\XC@cnv@cmyk@cmy#1,#2,#3,#4,%
 {\edef\@@arg{#4}\XC@calc@#1,#2,#3,,:T}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@hsb}
%   \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@hsb#1,#2,#3,%
 {\ifx\tm\XC@mod@HSB
    \edef\@@scl{\rangeHSB}\XC@calc@#1,#2,#3,,:M%
  \else
    \XC@cnv@hsb@rgb#1,#2,#3,%
    \ifx\tm\XC@mod@rgb\else\expandafter\XC@cnv@rgb\@@tmp,\fi
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@hsb@rgb}
%   \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@hsb@rgb#1,#2,#3,%
 {\llshiftset\dimen@{#1}\dimen@6\dimen@ \rrshift\dimen@
  \afterassignment\dimen@\count@=\the\dimen@
  \edef\@@tmp{\strip@pt\dimen@}%
  \ifodd\count@\else\XC@calcC\@@tmp\@@tmp\fi
  \edef\@@tmp
   {\ifcase\count@ 0,\@@tmp,1\or \@@tmp,0,1\or 1,0,\@@tmp\or
    1,\@@tmp,0\or \@@tmp,1,0\or 0,1,\@@tmp\or 0,\@@tmp,1\fi}%
  \edef\@@scl{#2}\expandafter\XC@calc@\@@tmp,,:S%
  \expandafter\XC@calc@\@@tmp,,:C%
  \edef\@@scl{#3}\expandafter\XC@calc@\@@tmp,,:S}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@gray}
%   \Meta{gray}|,|
%    \begin{macrocode}
\def\XC@cnv@gray#1,%
 {\ifx\tm\XC@mod@rgb
    \XC@calcN{#1}\@@tmp \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
  \else\ifx\tm\XC@mod@cmy
    \XC@calcC{#1}\@@tmp \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
  \else\ifx\tm\XC@mod@cmyk
    \XC@calcC{#1}\@@tmp \edef\@@tmp{0,0,0,\@@tmp}%
  \else\ifx\tm\XC@mod@hsb
    \XC@calcN{#1}\@@tmp \edef\@@tmp{0,0,\@@tmp}%
  \else\ifx\tm\XC@mod@RGB
    \edef\@@scl{\rangeRGB}\XC@calcM{#1}\@@tmp
    \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
  \else\ifx\tm\XC@mod@HTML
    \edef\@@scl{\@cclv}\XC@calcM{#1}\@@tmp \XC@calcH\@@tmp\@@tmp
    \edef\@@tmp{\@@tmp\@@tmp\@@tmp}%
  \else\ifx\tm\XC@mod@HSB
    \edef\@@scl{\rangeHSB}\XC@calcM{#1}\@@tmp
    \edef\@@tmp{0,0,\@@tmp}%
  \else\ifx\tm\XC@mod@Gray
    \edef\@@scl{\rangeGray}\XC@calcM{#1}\@@tmp
  \else
    \XC@calcN{#1}\@@tmp
  \fi\fi\fi\fi\fi\fi\fi\fi}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@RGB}
%   \Meta{Red}|,|\Meta{Green}|,|\Meta{Blue}|,|
%    \begin{macrocode}
\def\XC@cnv@RGB#1,#2,#3,%
 {\edef\@@scl{\rangeRGB}\XC@calc@#1,#2,#3,,:D\expandafter\XC@cnv@rgb\@@tmp,}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@HTML}
%   \Meta{RRGGBB}|,|
%    \begin{macrocode}
\def\XC@cnv@HTML#1,%
 {\edef\@@tmp{\expandafter\@hex@Hex#1\relax}\expandafter\XC@cnv@HTML@\@@tmp
  \edef\@@scl{\@cclv}\expandafter\XC@calc@\@@tmp,,:D%
  \expandafter\XC@cnv@rgb\@@tmp,}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@cnv@HTML@#1#2#3#4#5#6%
 {\edef\@@tmp{\number"#1#2,\number"#3#4,\number"#5#6}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@HSB}
%   \Meta{Hue}|,|\Meta{Saturation}|,|\Meta{Brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@HSB#1,#2,#3,%
 {\edef\@@scl{\rangeHSB}\XC@calc@#1,#2,#3,,:D\expandafter\XC@cnv@hsb\@@tmp,}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@Gray}
%   \Meta{Gray}|,|
%    \begin{macrocode}
\def\XC@cnv@Gray#1,%
 {\edef\@@scl{\rangeGray}\XC@calcD{#1}\@@tmp \XC@cnv@gray\@@tmp,}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Color complement}
%
% \begin{macro}{\XC@cnv@cmyk@compl}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\Meta{black}|,|
%    \begin{macrocode}
\def\XC@cnv@cmyk@compl#1,#2,#3,#4,%
 {\XC@cnv@cmyk@cmy#1,#2,#3,#4,%
  \expandafter\XC@calc@\@@tmp,,:C%
  \expandafter\XC@cnv@cmy@cmyk\@@tmp,}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@hsb@compl}
%   \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@hsb@compl#1,#2,#3,%
 {\lshiftset\dimen@{#1}\advance\dimen@\ifdim\dimen@<5\p@-\fi-5\p@
  \rshift\dimen@
  \edef\@@tmp{\strip@pt\dimen@}%
  \lshiftset\dimen@{#3}%
  \@tempdima#2\dimen@
  \@tempdimb\@tempdima \advance\@tempdimb10\p@ \advance\@tempdimb-\dimen@
  \ifdim\@tempdimb=\z@
    \edef\@@tmp{\@@tmp,0,0}%
  \else
    \rdivide\@tempdima\@tempdimb \rshift\@tempdimb
    \edef\@@tmp{\@@tmp,\strip@pt\@tempdima,\strip@pt\@tempdimb}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Color initialisation}
%
% \subsubsection{Support for missing color models}
%
% These macros provide generic support for missing color models in specific drivers.
% For example, \File{pdftex.def} does not support the \Model{hsb} model.
% It is assumed that at least one of the models \Model{rgb} and \Model{cmyk} exists.
% \begin{macro}{\color@rgb}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\ifx\color@rgb\@undefined
  \PackageInfo{xcolor}{Color model `rgb' added}
  \def\color@rgb#1#2%
   {\convertcolorspec\XC@mod@rgb{#2}\XC@mod@cmyk\XC@@tmp
    \expandafter\color@cmyk\expandafter#1\expandafter{\XC@@tmp}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@cmyk}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\ifx\color@cmyk\@undefined
  \PackageInfo{xcolor}{Color model `cmyk' added}
  \def\color@cmyk#1#2%
   {\convertcolorspec\XC@mod@cmyk{#2}\XC@mod@rgb\XC@@tmp
    \expandafter\color@rgb\expandafter#1\expandafter{\XC@@tmp}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@cmy}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\ifx\color@cmy\@undefined
  \PackageInfo{xcolor}{Color model `cmy' added}
  \def\color@cmy#1#2{\color@cmyk#1{#2,0}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@hsb}
%   \marg{cmd}\marg{spec}\\
% Since the \Option{dvipdfm} and \Option{textures} drivers only pretend to support \Model{hsb}, we have to check for these drivers.
%    \begin{macrocode}
\ifx\color@hsb\@undefined\@tempswatrue
\else\def\@@tmp{dvipdfm.def}\ifx\@@tmp\Gin@driver\@tempswatrue
\else\def\@@tmp{textures.def}\ifx\@@tmp\Gin@driver\@tempswatrue
\else\@tempswafalse\fi\fi\fi
\if@tempswa
  \PackageInfo{xcolor}{Color model `hsb' added}
  \def\color@hsb#1#2%
   {\convertcolorspec\XC@mod@hsb{#2}\XC@mod@rgb\XC@@tmp
    \expandafter\color@rgb\expandafter#1\expandafter{\XC@@tmp}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@gray}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\ifx\color@gray\@undefined
  \PackageInfo{xcolor}{Color model `gray' added}
  \def\color@gray#1#2{\color@rgb#1{#2,#2,#2}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@RGB}
%   \marg{cmd}\marg{spec}\\
% If the model is supported and |\rangeRGB| equals 255, we stick to the algorithm provided by the driver.
%    \begin{macrocode}
\ifx\color@RGB\@undefined\@tempswatrue
\else\ifnum\rangeRGB<255 \@tempswatrue
\else\ifnum\rangeRGB>255 \@tempswatrue
\else\@tempswafalse\fi\fi\fi
\if@tempswa
  \PackageInfo{xcolor}{Color model `RGB' added}
  \def\color@RGB#1#2%
   {\convertcolorspec\XC@mod@RGB{#2}\XC@mod@rgb\XC@@tmp
    \expandafter\color@rgb\expandafter#1\expandafter{\XC@@tmp}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@HTML}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\ifx\color@HTML\@undefined
  \PackageInfo{xcolor}{Color model `HTML' added}
  \def\color@HTML#1#2%
   {\convertcolorspec\XC@mod@HTML{#2}\XC@mod@rgb\XC@@tmp
    \expandafter\color@rgb\expandafter#1\expandafter{\XC@@tmp}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@HSB}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\ifx\color@HSB\@undefined
  \PackageInfo{xcolor}{Color model `HSB' added}
  \def\color@HSB#1#2%
   {\convertcolorspec\XC@mod@HSB{#2}\XC@mod@hsb\XC@@tmp
    \expandafter\color@hsb\expandafter#1\expandafter{\XC@@tmp}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@Gray}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\ifx\color@Gray\@undefined
  \PackageInfo{xcolor}{Color model `Gray' added}
  \def\color@Gray#1#2%
   {\convertcolorspec\XC@mod@Gray{#2}\XC@mod@gray\XC@@tmp
    \expandafter\color@gray\expandafter#1\expandafter{\XC@@tmp}}
\fi
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{PostScript-related stuff}
%
%    \begin{macrocode}
\@ifundefined{XC@pst}{%
%    \end{macrocode}
%
% \begin{macro}{\XC@getcolor}
%   \marg{color*}\marg{cmd}\\
% Transformation of a color, given by \Meta{color*}, especially needed for \Package{pstricks}.
% The result will always be an internal color representation (as described in section \vref{sec.definition}) and is stored in \Meta{cmd}.
% \Meta{color*} may be either a macro whose \emph{first level} expansion is an internal color representation (e.g.~|\XC@getcolor\pslinecolor|), or anything for which |\color|\marg{color*} makes sense (e.g.~a color expression).
%    \begin{macrocode}
\def\XC@getcolor#1#2%
 {\begingroup
  \XC@@getcolor#1\XC@@
  \toks@\expandafter{\@@tmp}\aftergroupdef#2{\the\toks@}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@getcolor#1#2\XC@@
 {\@ifxempty{#2}%
   {\expandafter\XC@@@getcolor#1\XC@@}%
   {\color{#1#2}\let\@@tmp\XC@current@color}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@@getcolor#1#2\XC@@
 {\ifx#1\xcolor@
    \def\@@tmp{\xcolor@#2}%
  \else
    \color{#1#2}\let\@@tmp\XC@current@color
  \fi}
%    \end{macrocode}
% \end{macro}
%
% This alternative code is temporarily needed for compatibility reasons if \Package{pstricks} is loaded via the \Option{pst} option:
%    \begin{macrocode}
}{% compatibility code begin
\def\XC@getcolor#1#2%
 {\@ifundefined{\string\color@#1}%
   {\begingroup\color{#1}%
    \edef\@@tmp
     {\noexpand\edef\noexpand#2{\noexpand\expandafter\noexpand\c@lor@to@ps
      \current@color\noexpand\@@}}%
    \expandafter\endgroup\@@tmp}%
   {\edef#2{\XC@usecolor{#1}}}}
}% compatibility code end
%    \end{macrocode}
%
% \begin{macro}{\XC@usecolor}
%   \marg{color*}\\
% Transformation of a color into PostScript code.
% \Meta{color*} may be either a command whose \emph{first-level} expansion is an internal color representation (e.g.~the outcome of an |\XC@getcolor| command: |\XC@usecolor\pslinecolor|), or a \Meta{name} (e.g.~|\XC@usecolor{green}|).
% Note that non-trivial color expressions like |green!50| are forbidden and that |\XC@usecolor| is fully expandable, for example, |\edef\foo{\XC@usecolor{green}}| is valid.
%    \begin{macrocode}
\def\XC@usecolor#1{\expandafter\XC@@usecolor#1\XC@@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@@usecolor#1#2\XC@@
 {\ifx#1\xcolor@
    \expandafter\expandafter\expandafter\c@lor@to@ps#1#2\@@
  \else
    \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
    \expandafter\c@lor@to@ps\csname\string\color@#1#2\endcsname\@@
  \fi
  \space}
%    \end{macrocode}
%
% For compatibility reasons, we need the following command temporarily; however, |\XC@c@lor@to@ps| will disappear soon!
%    \begin{macrocode}
\let\XC@c@lor@to@ps\XC@usecolor
%    \end{macrocode}
% \end{macro}
%
% If \Package{pstcol} has been loaded, we have to redefine two macros from this package.
% The conditional code is needed temporarily, until a new version of \Package{pstricks} is released.
%    \begin{macrocode}
\let\pst@getcolor\XC@getcolor
\@ifundefined{XC@pst}{%
  \let\pst@usecolor\XC@usecolor
}{}
%    \end{macrocode}
%
%
% \subsubsection{Whatsit \ldots}
%
% \begin{macro}{\c@lor@special}
% Some drivers do not support all the features of this package.
% They should always put a \Meta{whatsit} in the current list though.
% The following macro has most of the features of |\special|, but does not put anything into the |dvi| file.
% It does write to the |log| file or the terminal (depending on the value of |#1|).
%    \begin{macrocode}
\def\c@lor@special#1#2{\edef\@tempa{\write#1{#2}}\@tempa}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Default color}
%
% \begin{macro}{\normalcolor}
% |\normalcolor| is defined (to |\relax|) in the \LaTeX\ kernel, so it is safe to use this in macros that may possibly be used in conjunction with color.
% It will have no effect until the \XCP{} is also loaded.
%    \begin{macrocode}
\def\normalcolor{\let\current@color\default@color\set@color}
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\default@color}
% Internal macro to store the `default' color used by |\normalcolor|.
%    \begin{macrocode}
\AtBeginDocument{\let\default@color\current@color}
%    \end{macrocode}
% \end{macro}
%
% |\current@color| contains an internal representation of the color at this point in the document.
% (This can only be an approximation to the truth as the `macro layer' of \TeX\ does not know where the output routine is going to re-insert floats.
% This is why drivers must maintain their own stack of colors in order to fully support these commands.
%
% For |dvips|, the |\current@color| it is something like `|Black|' or `|rgb 0 1 0|', but other packages should not rely on any particular format for this macro.
%
%
% \subsubsection{Driver-specific definitions for named colors}
%
% \begin{macro}{\c@lor@@named}
% \begin{macro}{\define@color@named}
% We have to modify two driver-specific commands in order to avoid generation of superfluous macros.
%    \begin{macrocode}
\@tfor\@@tmp:={dvipdf}{dvipdfm}{dvips}{pctex32}\do
 {\edef\@@tmp{\@@tmp.def}%
  \ifx\Gin@driver\@@tmp
    \def\c@lor@@named#1,#2,#3\@@#4{\edef#4{ #1}}
    \def\define@color@named#1#2{\let\@@col\@nnil}
  \@break@tfor\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\@tfor\@@tmp:={dvipsone}{pctexps}{pdftex}{tcidvi}{truetex}{vtex}\do
 {\edef\@@tmp{\@@tmp.def}%
  \ifx\Gin@driver\@@tmp
    \def\c@lor@@named#1,#2,#3\@@#4%
     {\edef#4{\expandafter\expandafter\expandafter\@secondoffive
               \csname\string\color@#1\endcsname}}
    \def\define@color@named#1#2%
     {\edef\@@col{#2}\@namedef{\string\color@#1}{{}{#2}{}{}{}}}
  \@break@tfor\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\@tfor\@@tmp:={textures}\do
 {\edef\@@tmp{\@@tmp.def}%
  \ifx\Gin@driver\@@tmp
    \def\c@lor@@named#1,#2,#3\@@#4%
     {\edef\@tempa{\color@P@custom{#1}{\if!#2!1\else#2\fi}}%
      \expandafter\def\expandafter#4\@tempa}
    \def\define@color@named#1#2%
     {\edef\@tempa{{#1}{#2}}\expandafter\AddCustomColor\@tempa
      \edef\@@col{#2}}
  \@break@tfor\fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Basic color definitions}
%
%    \begin{macrocode}
\definecolorset{rgb}{}{}{red,1,0,0;green,0,1,0;blue,0,0,1}
\definecolorset{cmyk}{}{}{cyan,1,0,0,0;magenta,0,1,0,0;yellow,0,0,1,0}
\definecolorset{gray}{}{}{black,0;darkgray,.25;gray,.5;lightgray,.75;white,1}
\colorlet{orange}{red!50!yellow}
\colorlet{violet}{blue!50!red}
\colorlet{purple}{violet!50!red}
\colorlet{brown}{violet!50!yellow}
%    \end{macrocode}
%
% Load predefined sets of colors (e.g.{} \File{dvipsnam.def}).
%    \begin{macrocode}
\XC@colornames
%    \end{macrocode}
%
%
% \subsubsection{Finale}
%
% Restore catcodes.
%    \begin{macrocode}
\XC@catcodes
\let\XC@catcodes\relax
%    \end{macrocode}
%
%    \begin{macrocode}
\@nameuse{xcolorcmd}
\color{black}
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
%
% \clearpage
% \Finale
% \endinput
%
%
% \iffalse
%-------------------------------------------------------------------------------
%<*svgnames>
\ProvidesFile{svgnam.def}[\XCfiledate\space\XCfileversion\space
                          Predefined color names according to SVG 1.1 (UK)]
\definecolorset{rgb}{}{}{%
AliceBlue,.94,.972,1;%
AntiqueWhite,.98,.92,.844;%
Aqua,0,1,1;%
Aquamarine,.498,1,.83;%
Azure,.94,1,1;%
Beige,.96,.96,.864;%
Bisque,1,.894,.77;%
Black,0,0,0;%
BlanchedAlmond,1,.92,.804;%
Blue,0,0,1;%
BlueViolet,.54,.17,.888;%
Brown,.648,.165,.165;%
BurlyWood,.87,.72,.53;%
CadetBlue,.372,.62,.628;%
Chartreuse,.498,1,0;%
Chocolate,.824,.41,.116;%
Coral,1,.498,.312;%
CornflowerBlue,.392,.585,.93;%
Cornsilk,1,.972,.864;%
Crimson,.864,.08,.235;%
Cyan,0,1,1;%
DarkBlue,0,0,.545;%
DarkCyan,0,.545,.545;%
DarkGoldenrod,.72,.525,.044;%
DarkGray,.664,.664,.664;%
DarkGreen,0,.392,0;%
DarkGrey,.664,.664,.664;%
DarkKhaki,.74,.716,.42;%
DarkMagenta,.545,0,.545;%
DarkOliveGreen,.332,.42,.185;%
DarkOrange,1,.55,0;%
DarkOrchid,.6,.196,.8;%
DarkRed,.545,0,0;%
DarkSalmon,.912,.59,.48;%
DarkSeaGreen,.56,.736,.56;%
DarkSlateBlue,.284,.24,.545;%
DarkSlateGray,.185,.31,.31;%
DarkSlateGrey,.185,.31,.31;%
DarkTurquoise,0,.808,.82;%
DarkViolet,.58,0,.828;%
DeepPink,1,.08,.576;%
DeepSkyBlue,0,.75,1;%
DimGray,.41,.41,.41;%
DimGrey,.41,.41,.41;%
DodgerBlue,.116,.565,1;%
FireBrick,.698,.132,.132;%
FloralWhite,1,.98,.94;%
ForestGreen,.132,.545,.132;%
Fuchsia,1,0,1;%
Gainsboro,.864,.864,.864;%
GhostWhite,.972,.972,1;%
Gold,1,.844,0;%
Goldenrod,.855,.648,.125;%
Gray,.5,.5,.5;%
Grey,.5,.5,.5;%
Green,0,.5,0;%
GreenYellow,.68,1,.185;%
Honeydew,.94,1,.94;%
HotPink,1,.41,.705;%
IndianRed,.804,.36,.36;%
Indigo,.294,0,.51;%
Ivory,1,1,.94;%
Khaki,.94,.9,.55;%
Lavender,.9,.9,.98;%
LavenderBlush,1,.94,.96;%
LawnGreen,.488,.99,0;%
LemonChiffon,1,.98,.804;%
LightBlue,.68,.848,.9;%
LightCoral,.94,.5,.5;%
LightCyan,.88,1,1;%
LightGoldenrodYellow,.98,.98,.824;%
LightGray,.828,.828,.828;%
LightGreen,.565,.932,.565;%
LightGrey,.828,.828,.828;%
LightPink,1,.712,.756;%
LightSalmon,1,.628,.48;%
LightSeaGreen,.125,.698,.668;%
LightSkyBlue,.53,.808,.98;%
LightSlateGray,.468,.532,.6;%
LightSlateGrey,.468,.532,.6;%
LightSteelBlue,.69,.77,.87;%
LightYellow,1,1,.88;%
Lime,0,1,0;%
LimeGreen,.196,.804,.196;%
Linen,.98,.94,.9;%
Magenta,1,0,1;%
Maroon,.5,0,0;%
MediumAquamarine,.4,.804,.668;%
MediumBlue,0,0,.804;%
MediumOrchid,.73,.332,.828;%
MediumPurple,.576,.44,.86;%
MediumSeaGreen,.235,.7,.444;%
MediumSlateBlue,.484,.408,.932;%
MediumSpringGreen,0,.98,.604;%
MediumTurquoise,.284,.82,.8;%
MediumVioletRed,.78,.084,.52;%
MidnightBlue,.098,.098,.44;%
MintCream,.96,1,.98;%
MistyRose,1,.894,.884;%
Moccasin,1,.894,.71;%
NavajoWhite,1,.87,.68;%
Navy,0,0,.5;%
OldLace,.992,.96,.9;%
Olive,.5,.5,0;%
OliveDrab,.42,.556,.136;%
Orange,1,.648,0;%
OrangeRed,1,.27,0;%
Orchid,.855,.44,.84;%
PaleGoldenrod,.932,.91,.668;%
PaleGreen,.596,.985,.596;%
PaleTurquoise,.688,.932,.932;%
PaleVioletRed,.86,.44,.576;%
PapayaWhip,1,.936,.835;%
PeachPuff,1,.855,.725;%
Peru,.804,.52,.248;%
Pink,1,.752,.796;%
Plum,.868,.628,.868;%
PowderBlue,.69,.88,.9;%
Purple,.5,0,.5;%
Red,1,0,0;%
RosyBrown,.736,.56,.56;%
RoyalBlue,.255,.41,.884;%
SaddleBrown,.545,.27,.075;%
Salmon,.98,.5,.448;%
SandyBrown,.956,.644,.376;%
SeaGreen,.18,.545,.34;%
Seashell,1,.96,.932;%
Sienna,.628,.32,.176;%
Silver,.752,.752,.752;%
SkyBlue,.53,.808,.92;%
SlateBlue,.415,.352,.804;%
SlateGray,.44,.5,.565;%
SlateGrey,.44,.5,.565;%
Snow,1,.98,.98;%
SpringGreen,0,1,.498;%
SteelBlue,.275,.51,.705;%
Tan,.824,.705,.55;%
Teal,0,.5,.5;%
Thistle,.848,.75,.848;%
Tomato,1,.39,.28;%
Turquoise,.25,.88,.815;%
Violet,.932,.51,.932;%
Wheat,.96,.87,.7;%
White,1,1,1;%
WhiteSmoke,.96,.96,.96;%
Yellow,1,1,0;%
YellowGreen,.604,.804,.196}
%</svgnames>
%
%<*test1>
\ProvidesFile{xcolor1}[\XCfiledate\space\XCfileversion\space
                       Color conversion test (UK)]

\documentclass[a4paper]{article}

\usepackage{array,multicol,multido,textcomp}
\usepackage{xcolor}[2004/07/04]
\usepackage[hmargin={1.25cm,.75cm},vmargin=1.25cm,footskip=.5cm,nohead]{geometry}

\newdimen\Argwd
\newdimen\Errsum
\newdimen\Errmax
\newcount\Colors
\newcount\Errors
\newcount\Loops
\newif\ifColor

\makeatletter

\def\DisplayColor#1#2#3%
 {\global\advance\Loops\@ne
  \@tempdima=#1\p@ \edef\@tempa{\the\@tempdima}%
  \edef\Colori{\strip@pt\@tempdima}%
  \ifColor
    \@tempdimb=#2\p@ \edef\@tempb{\the\@tempdimb}%
    \@tempdimc=#3\p@ \edef\@tempc{\the\@tempdimc}%
    \edef\Colori{\Colori,\strip@pt\@tempdimb,\strip@pt\@tempdimc}%
  \fi
  \Make12\Make23\Make34\Make45\Make56\Make67%
  \begin{tabular}{@{}ll*4{@{ }p{\Argwd}}@{}}
  \Row1\Row2\Row3\Row4\Row5\Row6\noalign{\medskip}
  \end{tabular}
  \global\advance\Colors1 \relax\ifnum\Colors=30 \newpage\global\Colors=0 \fi}

\def\Make#1#2%
 {\edef\@@tmp
   {\noexpand\definecolor{Color\romannumeral#1}%
     {\@nameuse{Model\romannumeral#1}}{\@nameuse{Color\romannumeral#1}}%
   }\@@tmp
  \relax\ifnum#1<6
    \convertcolorspec
     {\@nameuse{Model\romannumeral#1}}{\@nameuse{Color\romannumeral#1}}%
     {\@nameuse{Model\romannumeral#2}}\@@tmp
    \@namelet{Color\romannumeral#2}{@@tmp}%
  \fi}

\def\Row#1%
 {\edef\@@tmp{\@nameuse{Color\romannumeral#1}\@nameuse{Row\romannumeral#1}}%
  \expandafter\@Row\@@tmp}

\def\@Row#1,#2,#3,#4,#5#6%
 {\fcolorbox{black}{Color\romannumeral#5}{\phantom{000}}&
  \csname Model\romannumeral#5\endcsname &
  \ifodd#6 \@Error{#1}\@tempa \else #1\fi &
  \ifColor\ifodd#6 \@Error{#2}\@tempb \else #2\fi\else #2\fi &
  \ifColor\ifodd#6 \@Error{#3}\@tempc \else #3\fi\else #3\fi &
  #4\\}

\def\defModel#1#2#3#4% number, name, commas, check
 {\@namedef{Model\romannumeral#1}{#2}\@namedef{Row\romannumeral#1}{#3#1#4}}

\def\@Error#1#2%
 {\ifdim#1\p@=#2\relax #1\else
    \textcolor{red}{#1}\global\advance\Errors\@ne
    \dimen@#2\advance\dimen@-#1\p@ \ifdim\dimen@<\z@\dimen@-\dimen@\fi
    \global\advance\Errsum\dimen@
    \ifdim\dimen@>\Errmax \global\Errmax\dimen@
      \dimen@\@tempa \edef\@@tempa{\strip@pt\dimen@}%
      \ifColor
        \dimen@\@tempb \edef\@@tempb{\strip@pt\dimen@}%
        \dimen@\@tempc \edef\@@tempc{\strip@pt\dimen@}%
        \xdef\Errcase{\@@tempa\noexpand~\@@tempb\noexpand~\@@tempc}%
      \else
        \xdef\Errcase{\@@tempa}%
      \fi
    \fi
  \fi}

\newenvironment{ColorTest}[1]%
 {\addcontentsline{toc}{section}{Color conversion chain: #1}
  \Colors\z@ \Errors\z@ \Loops\z@ \Errsum\z@ \Errmax\z@
  \begin{multicols}{3}\centering}%
 {\end{multicols}\bigskip
  \begin{tabular}{@{}l@{ = }l@{}}
  \multicolumn2{@{}l@{}}{Rounding error statistics of color conversion test}\\
  \multicolumn2{@{}l@{}}%
   {$\textbf\Modeli\rightarrow \textbf\Modelii\rightarrow \textbf\Modeliii\rightarrow
     \textbf\Modeliv\rightarrow \textbf\Modelv\rightarrow \textbf\Modelvi$:}\\[1ex]
  number of examples& \number\Loops\\
  number of errors& \number\Errors\\
  sum of absolute errors& \strip@pt\Errsum\\
  \ifnum\Errors>\z@
    average error& \Errsum100\Errsum \dimen@\Errors\p@ \divide\dimen@\@m
    \rdivide\Errsum\dimen@ \strip@pt\Errsum\textperiodcentered10\textsuperscript{-5}\\
    maximum error& \strip@pt\Errmax{} @ \Modeli~\Errcase\\
  \fi
  \end{tabular}\newpage}

\def\thepage{\sffamily\footnotesize\@nameuse{@arabic}\c@page}

\makeatother

\parindent0pt
\setcounter{secnumdepth}{-1}

\begin{document}

\title{Color conversion with the \textsf{xcolor} package --- Examples}
\author{Dr. Uwe Kern\thanks{This file is part of the \textsf{xcolor} distribution which can be downloaded from the CTAN mirrors (\texttt{macros/latex/contrib/xcolor/}) or the homepage \texttt{www.ukern.de/tex/xcolor.html}. Please send error reports and suggestions for improvements to \texttt{xcolor@ukern.de}.}}
\date{\XCfileversion{} (\XCfiledate)}
\maketitle

\begin{center}
\begin{minipage}{.75\textwidth}
\tableofcontents
\end{minipage}
\end{center}
\newpage

\sffamily\footnotesize
\fboxrule.25pt
\settowidth\Argwd{0.00000}

\defModel1{rgb}{,,}0
\defModel2{cmy}{,,}0
\defModel3{cmyk}{,}0
\defModel4{hsb}{,,}0
\defModel5{rgb}{,,}1
\defModel6{gray}{,,,,}0
\Colortrue

\begin{ColorTest}{rgb, cmy, cmyk, hsb, rgb, gray}
\multido{\nR=1+-.1}{11}%
 {\multido{\nG=1+-.1}{11}%
  {\multido{\nB=1+-.1}{11}%
   {\DisplayColor{\nR}{\nG}{\nB}}}}%
\end{ColorTest}

\defModel1{gray}{,,,,}0
\defModel2{rgb}{,,}0
\defModel3{cmy}{,,}0
\defModel4{cmyk}{,}0
\defModel5{hsb}{,,}0
\defModel6{gray}{,,,,}1
\Colorfalse

\begin{ColorTest}{gray, rgb, cmy, cmyk, hsb, gray}
\multido{\nG=1+-.01}{101}{\DisplayColor{\nG}{}{}}%
\end{ColorTest}

\end{document}
%</test1>
%
%<*test2>
\listfiles
\ProvidesFile{xcolor2}[\XCfiledate\space\XCfileversion\space
                       Pstricks color test (UK)]

\documentclass{article}

\usepackage{pstricks,pst-tree,pst-slpe}
\makeatletter
\@ifpackagelater{pstricks}{2004/05/12}{}{\usepackage[pst]{xcolor}}
\makeatother

\parindent0pt

\begin{document}
\title{Color extensions with the \textsf{xcolor} package --- \textsf{pstricks} examples}
\author{Dr. Uwe Kern\thanks{This file is part of the \textsf{xcolor} distribution which can be downloaded from the CTAN mirrors (\texttt{macros/latex/contrib/xcolor/}) or the homepage \texttt{www.ukern.de/tex/xcolor.html}. Please send error reports and suggestions for improvements to \texttt{xcolor@ukern.de}.}}
\date{\XCfileversion{} (\XCfiledate)}
\maketitle

\centerline{\fcolorbox{red}{yellow!50}{This document is not suitable for pdf\LaTeX! Please use \LaTeX{} + \texttt{dvips} etc.}}

\begin{figure}[htb]\caption{Color extensions --- \textsf{pstricks} example\protect\footnotemark[1]}
\bigskip
\begin{minipage}{\textwidth}\small
\begin{verbatim}
\begin{pspicture}[.5](0,-2)(3,2)
\cnode(0,0){.5cm}{root}
\cnode*[linecolor=red](3,1.5){4pt}{A}
\cnode*[linecolor=red!72.5375!blue](3,0){4pt}{B}
\cnode*[linecolor=-red](3,-1.5){4pt}{C}
\psset{nodesep=3pt}
\ncline[linecolor=green!50!red]{root}{A}
\ncline[linecolor=blue]{root}{B}
\ncline[linecolor=-green!50!red]{root}{C}
\end{pspicture}
\end{verbatim}
\end{minipage}\relax
\llap{%
\begin{pspicture}[.5](0,-2)(3,2)
\cnode(0,0){.5cm}{root}
\cnode*[linecolor=red](3,1.5){4pt}{A}
\cnode*[linecolor=red!72.5375!blue](3,0){4pt}{B}
\cnode*[linecolor=-red](3,-1.5){4pt}{C}
\psset{nodesep=3pt}
\ncline[linecolor=green!50!red]{root}{A}
\ncline[linecolor=blue]{root}{B}
\ncline[linecolor=-green!50!red]{root}{C}
\end{pspicture}}
\end{figure}
\footnotetext[1]{This is a modified version of an example from the \textsf{pstricks} manual; requires \textsf{pst-tree}.}

\begin{figure}[htb]\caption{Color extensions --- \textsf{pstricks} example\protect\footnotemark[2]}
\bigskip
\begin{minipage}{\textwidth}\small
\begin{verbatim}
\begin{pspicture}(4,1)
\psframe[fillstyle=slope,
         slopeangle=30,
         slopebegin=red!72.5375!blue,
         slopeend=-red!72.5375!blue](4,1)
\end{pspicture}
\end{verbatim}
\end{minipage}\relax
\llap{%
\begin{pspicture}(4,1)
\psframe[fillstyle=slope,
         slopeangle=30,
         slopebegin=red!72.5375!blue,
         slopeend=-red!72.5375!blue](4,1)
\end{pspicture}}
\end{figure}
\footnotetext[2]{Requires \textsf{pst-slpe}.}

\begin{figure}[htb]\caption{Color series --- \textsf{pstricks} example\protect\footnotemark[3]}
\bigskip\centering
\newcommand*\SheepHead
 {\begin{pspicture}(3,1.5)
    \pscustom[liftpen=2,fillstyle=solid,fillcolor=sheep!!+]{%
      \pscurve(0.5,-0.2)(0.6,0.5)(0.2,1.3)(0,1.5)(0,1.5)
        (0.4,1.3)(0.8,1.5)(2.2,1.9)(3,1.5)(3,1.5)(3.2,1.3)
        (3.6,0.5)(3.4,-0.3)(3,0)(2.2,0.4)(0.5,-0.2)}
    \pscircle*(2.65,1.25){0.12\psunit}% Eye
    \psccurve*(3.5,0.3)(3.35,0.45)(3.5,0.6)(3.6,0.4)% Muzzle
    % Mouth
    \pscurve(3,0.35)(3.3,0.1)(3.6,0.05)
    % Ear
    \pscurve(2.3,1.3)(2.1,1.5)(2.15,1.7)
    \pscurve(2.1,1.7)(2.35,1.6)(2.45,1.4)
  \end{pspicture}}
\newcommand*\Sheep
 {\SheepHead\SheepHead\SheepHead\SheepHead\SheepHead}
\definecolorseries{sheep}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
\resetcolorseries{sheep}
\psset{unit=0.5}
\begin{pspicture}(-8,-1.5)(8.5,7.5)
  \rput(0,6){\Sheep}
  \rput(0,4.5){\Sheep}
  \rput(0,3){\Sheep}
  \rput(0,1.5){\Sheep}
  \rput(0,0){\Sheep}
\end{pspicture}

\small
\begin{verbatim}
\newcommand*\SheepHead
 {\begin{pspicture}(3,1.5)
    \pscustom[liftpen=2,fillstyle=solid,fillcolor=sheep!!+]{%
      \pscurve(0.5,-0.2)(0.6,0.5)(0.2,1.3)(0,1.5)(0,1.5)
        (0.4,1.3)(0.8,1.5)(2.2,1.9)(3,1.5)(3,1.5)(3.2,1.3)
        (3.6,0.5)(3.4,-0.3)(3,0)(2.2,0.4)(0.5,-0.2)}
    \pscircle*(2.65,1.25){0.12\psunit}% Eye
    \psccurve*(3.5,0.3)(3.35,0.45)(3.5,0.6)(3.6,0.4)% Muzzle
    % Mouth
    \pscurve(3,0.35)(3.3,0.1)(3.6,0.05)
    % Ear
    \pscurve(2.3,1.3)(2.1,1.5)(2.15,1.7)
    \pscurve(2.1,1.7)(2.35,1.6)(2.45,1.4)
  \end{pspicture}}
\newcommand*\Sheep
 {\SheepHead\SheepHead\SheepHead\SheepHead\SheepHead}
\definecolorseries{sheep}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
\resetcolorseries{sheep}
\psset{unit=0.5}
\begin{pspicture}(-8,-1.5)(8.5,7.5)
  \rput(0,6){\Sheep}
  \rput(0,4.5){\Sheep}
  \rput(0,3){\Sheep}
  \rput(0,1.5){\Sheep}
  \rput(0,0){\Sheep}
\end{pspicture}
\end{verbatim}
\end{figure}
\footnotetext[3]{This is a modified version of an example from the \textsf{pst-fill} manual.}

\end{document}
%</test2>
%
%<*test3>
\listfiles
\ProvidesFile{xcolor3}[\XCfiledate\space\XCfileversion\space
                       Color logging test (UK)]

\documentclass{article}
\usepackage[table,dvipsnames]{xcolor}[2004/07/04]

\tracingcolors=4
%%\tracingcolors=3
%%\tracingcolors=2
%%\tracingcolors=1
%%\tracingcolors=0

\parindent0pt
\pagecolor{gray!25}

\begin{document}
\title{Color extensions with the \textsf{xcolor} package --- log file example}
\author{Dr. Uwe Kern\thanks{This file is part of the \textsf{xcolor} distribution which can be downloaded from the CTAN mirrors (\texttt{macros/latex/contrib/xcolor/}) or the homepage \texttt{www.ukern.de/tex/xcolor.html}. Please send error reports and suggestions for improvements to \texttt{xcolor@ukern.de}.}}
\date{\XCfileversion{} (\XCfiledate)}
\maketitle

The purpose of this file is to demonstrate the logging facilities of the \textsf{xcolor} package.
By playing around with different values of \texttt{\string\tracingcolors}, one can observe the different behavior in the \texttt{log} file.

\bigskip
Table example:
\rowcolors[\hline]{1}{green!25}{yellow!50}
\begin{tabular}{ll}
test & row \number\rownum\\
test & row \number\rownum\\
\rowcolor{blue!25}
test & row \number\rownum\\
test & row \number\rownum\\
\hiderowcolors
test & row \number\rownum\\
test & row \number\rownum\\
\showrowcolors
test & row \number\rownum\\
test & row \number\rownum\\
\multicolumn{1}%
 {>{\columncolor{red!12}}l}{test} & row \number\rownum\\
\end{tabular}

\bigskip
\providecolor{dummy}{rgb}{.6,.5,.4}
\definecolor{dummy}{rgb}{.6,.5,.4}
\providecolor{dummy}{rgb}{.6,.5,.4}
\hbox{\textcolor{dummy}{Test with \texttt{\string\definecolor}}}

{\color[rgb]{.4,.5,.6}Test with \texttt{\string\color}}

\bigskip
Current color application:\par
\def\test{current, \textcolor{.!50}{50\%}, \textcolor{-.}{complement},
          \textcolor{yellow!50!.}{mix}}
\textcolor{blue}{\test} and \textcolor{red}{\test},\par
\def\Test{\color{.!80}Test}
\textcolor{blue}{\Test\Test\Test\Test\Test} and
\textcolor{red}{\Test\Test\Test\Test\Test}.

\bigskip
Current color test with \texttt{\string\definecolorseries}:\par
\color{blue}
\definecolorseries{foo}{rgb}{last}{.}{-.}
\resetcolorseries[5]{foo}
\def\test{\hbox to 1em{{\color{foo!!+}\vrule width 1em height 1.5ex}}}
Test\test\test\test\test\test\test Test

\resetcolorseries[5]{foo}
\def\test{\hbox to 1em{{\color{foo!!++}\vrule width 1em height 1.5ex}}}
Test\test\test\test\test\test\test Test

\resetcolorseries[5]{foo}
\def\test{\hbox to 1em{{\color{foo!![2]}\vrule width 1em height 1.5ex}}}
Test\test\test\test\test\test\test Test

\bigskip
\color{black}
Test with named colors:\par
\color{blue}
Test: \textcolor[named]{JungleGreen}{JungleGreen};
Test: \textcolor{JungleGreen}{JungleGreen};
Test: \textcolor{JungleGreen!50!DarkOrchid}{JungleGreen!50!DarkOrchid};
Test: \textcolor{green!50!red}{green!50!red}.

Type test:
\makeatletter
\@namedef{\string\color@foo1}{foo1{}{}{}{}}\edef\tempa{\XC@type{foo1}}\tempa
\@namedef{\string\color@foo2}{\xcolor@{foo2}{}{}{}}\edef\tempb{\XC@type{foo2}}\tempb
\@namedef{\string\color@foo3}{\xcolor@{}{foo3}{}{}}\edef\tempc{\XC@type{foo3}}\tempc
\@namedef{\string\color@foo4}{\xcolor@{}{}{foo4}{}}\edef\tempd{\XC@type{foo4}}\tempd
\makeatother

\textcolor{rgb:red!50,4;green!25,2}{Extended color expression (rgb:red!50,4;green!25,2)}.

\end{document}
%</test3>
%
% \fi
\endinput
