% \iffalse meta-comment
%
% File: hycolor.dtx
% Version: 2020-01-27 v1.10
% Info: Color options for hyperref/bookmark
%
% Copyright (C)
%    2007-2011 Heiko Oberdiek
%    2016-2020 Oberdiek Package Support Group
%    https://github.com/ho-tex/hycolor/issues
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
% version. This version of this license is in
%    https://www.latex-project.org/lppl/lppl-1-3c.txt
% and the latest version of this license is in
%    https://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainers of this work are
% Heiko Oberdiek and the Oberdiek Package Support Group
% https://github.com/ho-tex/hycolor/issues
%
% This work consists of the main source file hycolor.dtx
% and the derived files
%    hycolor.sty, hycolor.pdf, hycolor.ins, hycolor.drv,
%    xcolor-patch.sty
%
% Distribution:
%    CTAN:macros/latex/contrib/hycolor/hycolor.dtx
%    CTAN:macros/latex/contrib/hycolor/hycolor.pdf
%
% Unpacking:
%    (a) If hycolor.ins is present:
%           tex hycolor.ins
%    (b) Without hycolor.ins:
%           tex hycolor.dtx
%    (c) If you insist on using LaTeX
%           latex \let\install=y\input{hycolor.dtx}
%        (quote the arguments according to the demands of your shell)
%
% Documentation:
%    (a) If hycolor.drv is present:
%           latex hycolor.drv
%    (b) Without hycolor.drv:
%           latex hycolor.dtx; ...
%    The class ltxdoc loads the configuration file ltxdoc.cfg
%    if available. Here you can specify further options, e.g.
%    use A4 as paper format:
%       \PassOptionsToClass{a4paper}{article}
%
%    Program calls to get the documentation (example):
%       pdflatex hycolor.dtx
%       makeindex -s gind.ist hycolor.idx
%       pdflatex hycolor.dtx
%       makeindex -s gind.ist hycolor.idx
%       pdflatex hycolor.dtx
%
% Installation:
%    TDS:tex/latex/hycolor/hycolor.sty
%    TDS:tex/latex/hycolor/xcolor-patch.sty
%    TDS:doc/latex/hycolor/hycolor.pdf
%    TDS:source/latex/hycolor/hycolor.dtx
%
%<*ignore>
\begingroup
  \catcode123=1 %
  \catcode125=2 %
  \def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
         \ifx\csname processbatchFile\endcsname\relax\else1\fi
         \ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: hycolor 2020-01-27 v1.10 Color options for hyperref/bookmark (HO)}
\Msg{************************************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax
\preamble

This is a generated file.

Project: hycolor
Version: 2020-01-27 v1.10

Copyright (C)
   2007-2011 Heiko Oberdiek
   2016-2020 Oberdiek Package Support Group

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3c of this license or (at your option) any later
version. This version of this license is in
   https://www.latex-project.org/lppl/lppl-1-3c.txt
and the latest version of this license is in
   https://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of
LaTeX version 2005/12/01 or later.

This work has the LPPL maintenance status "maintained".

The Current Maintainers of this work are
Heiko Oberdiek and the Oberdiek Package Support Group
https://github.com/ho-tex/hycolor/issues


This work consists of the main source file hycolor.dtx
and the derived files
   hycolor.sty, hycolor.pdf, hycolor.ins, hycolor.drv,
   xcolor-patch.sty

\endpreamble
\let\MetaPrefix\DoubleperCent

\generate{%
  \file{hycolor.ins}{\from{hycolor.dtx}{install}}%
  \file{hycolor.drv}{\from{hycolor.dtx}{driver}}%
  \usedir{tex/latex/hycolor}%
  \file{hycolor.sty}{\from{hycolor.dtx}{package}}%
  \file{xcolor-patch.sty}{\from{hycolor.dtx}{xcolor}}%
}

\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* files into a directory searched by TeX:}
\Msg{*}
\Msg{*     hycolor.sty, xcolor-patch.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `hycolor.drv'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}

\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{hycolor.drv}%
  [2020-01-27 v1.10 Color options for hyperref/bookmark (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2011/11/22]
\usepackage[ruled]{algorithm2e}

\makeatletter
\newcommand*{\makedefaultH}[1]{%
  \expandafter\edef\csname #1\endcsname{%
      \noexpand\@protected@testopt
      \expandafter\noexpand\csname#1\endcsname
      \expandafter\noexpand\csname
          \expandafter\string\csname#1\endcsname\endcsname
      {H}%
  }%
}
\makeatother
\makedefaultH{algorithm}
\makedefaultH{procedure}
\makedefaultH{function}

\SetKwInput{KwParam}{Param}
\newcommand*{\Param}[2]{%
  \KwParam{\ArgSty{#1} (#2)}%
}
\newcommand*{\Dat}[1]{%
  \texttt{\upshape#1}%
}
\newcommand*{\Var}[1]{%
  \ArgSty{#1}%
}
\newcommand*{\Gets}{%
  \ensuremath{\leftarrow}%
  \ %
}

\makeatletter
\newcommand*{\bs}{\texttt{\@backslashchar}}
\makeatother
\begin{document}
  \DocInput{hycolor.dtx}%
\end{document}
%</driver>
% \fi
%
%
%
% \GetFileInfo{hycolor.drv}
%
% \title{The \xpackage{hycolor} package}
% \date{2020-01-27 v1.10}
% \author{Heiko Oberdiek\thanks
% {Please report any issues at \url{https://github.com/ho-tex/hycolor/issues}}}
%
% \maketitle
%
% \begin{abstract}
% Package \xpackage{hycolor} implements the color option stuff that
% is used by packages \xpackage{hyperref} and \xpackage{bookmark}.
% It is not intended as package for the user.
% \end{abstract}
%
% \tableofcontents
%
% \section{Documentation}
%
% The package \xpackage{hycolor} implements color options
% for packages \xpackage{hyperref} and \xpackage{bookmark}.
%
% Package \xpackage{xcolor} provides macros for extracting
% color values and converting color data to other color models.
% If this package is loaded, the full range of color specifications
% of packages \xpackage{color} and \xpackage{xcolor} are supported
% including the optional argument for the color model.
% \begin{quote}
%   |\hypersetup{linkbordercolor=red}%| needs \xpackage{xcolor}\\
%   |\hypersetup{linkbordercolor=[named]{red}}%| needs \xpackage{xcolor}\\
%   |\hypersetup{linkbordercolor=[rgb]{1,0,0}}|
% \end{quote}
%
% Without package \xpackage{xcolor} some of the options only
% support some models, if they are given directly, e.g.:
% \begin{quote}
%   |\bookmarksetup{color=[rgb]{1,0,0}}|
% \end{quote}
%
% Because of compatibility some options of \xpackage{hyperref}
% also support space separated RGB values:
% \begin{quote}
%   |\hypersetup{linkbordercolor=1 0 0}%| is the same as\\
%   |\hypersetup{linkbordercolor=[rgb]{1,0,0}}|
% \end{quote}
%
% Coloring is optional, it can be turned off by using an empty
% value:
% \begin{quote}
%   |\hypersetup{linkbordercolor={}}|
% \end{quote}
%
% The PDF specification knows some kind of an emtpy color setting
% without values. This applies to form field colors. The new
% A virtual color model \texttt{empty} is introduced for this
% purpose, e.g.
% \begin{quote}
%   |\TextField[backgroundcolor={[empty]{}}, ...]{...}%| or\\
%   |\TextField[{backgroundcolor=[empty]{}, ...}]{...}|
% \end{quote}
% PDF specification 1.7 also allows this for border link colors.
% But this isn't currently supported by this package, because
% the tested viewers (AR7/Linux, xpdf 3.00, ghostscript 8.54)
% don't support this yet. In contrary ghostscript generates an
% error message.
%
% \subsection{Summary}
%
% \begin{tabular}{@{}llll@{}}
%   Color option & Models without \xpackage{xcolor}
%   & RGB color & Model empty\\
%   \hline
%   |BKM.color| & |gray|, |rgb| & no & no\\
%   |Hyp.*color| & all & no & no\\
%   |Hyp.*bordercolor| & |gray|, |rgb| & yes & no\\
%   |Field.*color| & |gray|, |rgb|, |cmyk| & yes & yes\\
%   |AtFi.color| & |gray|, |rgb| & yes & no\\
% \end{tabular}
%
% ``RGB color'' means that the color value can be given as
% space separated RGB numbers (real numbers in the range
% from 0 to 1).
% Explanation of the color option prefixes:
%
% \begin{tabular}{@{}ll@{}}
%   Prefix & Explanation\\
%   \hline
%   |BKM| & Package \xpackage{bookmark}\\
%   |Hyp| & Package \xpackage{hyperref}:
%           package options or |\hypersetup|\\
%   |Field| & Package \xpackage{hyperref}:
%             Form field options\\
%   |AtFi| & Package \xpackage{attachfile2}: option \xoption{color}\\
% \end{tabular}
%
%
% \StopEventually{
% }
%
% \section{Implementation}
%
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{hycolor}%
  [2020-01-27 v1.10 Color options for hyperref/bookmark (HO)]%
%    \end{macrocode}
%
% Should not be needed after \textsf{xcolor} updates,
% Avoid loading \xpackage{xcolor-patch} but fix Gray color model.
%    \begin{macrocode}
% \RequirePackage{xcolor-patch}[2019/12/15]
\AtBeginDocument{%
\def\@tempa#1,{%
    \XC@ifxcase\tm{%
      \XC@mod@rgb{%
        \XC@calcN{#1}\@@tmp
        \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
      }%
      \XC@mod@cmy{%
        \XC@calcC{#1}\@@tmp
        \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
      }%
      \XC@mod@cmyk{%
        \XC@calcC{#1}\@@tmp
        \edef\@@tmp{0,0,0,\@@tmp}%
      }%
      \XC@mod@RGB{%
        \edef\@@scl{\rangeRGB}%
        \XC@calcM{#1}\@@tmp
        \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
      }%
      \XC@mod@HTML{%
        \edef\@@scl{\@cclv}%
        \XC@calcM{#1}\@@tmp
        \XC@calcH\@@tmp\@@tmp
        \edef\@@tmp{\@@tmp\@@tmp\@@tmp}%
      }%
      \XC@mod@HSB{%
        \edef\@@scl{\rangeHSB}%
        \XC@calcM{#1}\@@tmp
        \edef\@@tmp{0,0,\@@tmp}%
      }%
      \XC@mod@Gray{%
        \edef\@@scl{\rangeGray}%
        \XC@calcM{#1}\@@tmp
      }%
    }%
    {%
      \XC@calcN{#1}\@@tmp
      \edef\@@tmp{0,0,\@@tmp}%
    }%
  }%
\ifx\XC@cnv@gray\@tempa
    \def\XC@cnv@gray#1,{%
      \XC@ifxcase\tm{%
        \XC@mod@rgb{%
          \XC@calcN{#1}\@@tmp
          \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
        }%
        \XC@mod@gray{}%
        \XC@mod@cmy{%
          \XC@calcC{#1}\@@tmp
          \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
        }%
        \XC@mod@cmyk{%
          \XC@calcC{#1}\@@tmp
          \edef\@@tmp{0,0,0,\@@tmp}%
        }%
        \XC@mod@RGB{%
          \edef\@@scl{\rangeRGB}%
          \XC@calcM{#1}\@@tmp
          \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
        }%
        \XC@mod@HTML{%
          \edef\@@scl{\@cclv}%
          \XC@calcM{#1}\@@tmp
          \XC@calcH\@@tmp\@@tmp
          \edef\@@tmp{\@@tmp\@@tmp\@@tmp}%
        }%
        \XC@mod@HSB{%
          \edef\@@scl{\rangeHSB}%
          \XC@calcM{#1}\@@tmp
          \edef\@@tmp{0,0,\@@tmp}%
        }%
        \XC@mod@Gray{%
          \edef\@@scl{\rangeGray}%
          \XC@calcM{#1}\@@tmp
        }%
      }%
      {%
        \XC@calcN{#1}\@@tmp
        \edef\@@tmp{0,0,\@@tmp}%
      }%
    }%
\fi
\let\@tempa\relax
}
%    \end{macrocode}
%
% \subsection{Normalization}
%
% \subsubsection{Sanitize value of color option}
%
%    \begin{procedure}
%      \Param{cmd}{macro}
%      \Param{value}{value of color option}
%      \BlankLine
%      \KwResult{\ArgSty{value} is expanded, sanitized, and
%                stored in macro \ArgSty{cmd}.}
%      \caption{DefSanitized(cmd, value)}
%      \BlankLine
%      Initialize active characters\;
%      \ArgSty{cmd} := Expand \ArgSty{value}\;
%      Sanitize \ArgSty{cmd}\;
%    \end{procedure}
%    \emph{Sanitization} means that the string does not contain any
%    macros or special tokens. It consists of characters with
%    catcode 12 (other). The only exception is the space with
%    catcode 10 (space).
%    \begin{macro}{\HyColor@DefSanitized}
%    \begin{macrocode}
\begingroup
  \catcode`\!=13 %
  \catcode`\:=13 %
  \catcode`\-=13 %
  \catcode`\+=13 %
  \catcode`\;=13 %
  \catcode`\"=13 %
  \catcode`\>=13 %
  \edef\x{%
    \def\noexpand!{\string!}%
    \def\noexpand:{\string:}%
    \def\noexpand-{\string-}%
    \def\noexpand+{\string+}%
    \def\noexpand;{\string;}%
    \def\noexpand"{\string"}%
    \def\noexpand>{\string>}%
  }%
  \def\y#1{\endgroup
    \def\HyColor@DefSanitized##1##2{%
      \begingroup
        \csname @safe@activestrue\endcsname
        #1%
        \edef\x{\endgroup
          \def\noexpand##1{##2}%
        }%
      \x
      \@onelevel@sanitize##1%
    }%
  }%
\expandafter\y\expandafter{\x}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{Normalize result}
%
%    \begin{procedure}
%      \Param{value}{Sanitized explicit number}
%      \Param{cmd}{Macro that stores result}
%      \BlankLine
%      \KwResult{\ArgSty{cmd} contains normalized number}
%      \caption{NormalizeNum(value, cmd)}
%      \BlankLine
%      \uIf{\Var{value}\,\Dat{pt} $<$ \Dat{0pt}}{
%        \ArgSty{cmd} \Gets \Dat{0}\;
%      }
%      \uElseIf{number before dot of \Var{value} $<$ \Dat{1}}{
%        \Var{cmd} \Gets number after dot of \Var{value}\;
%        \Var{cmd} \Gets strip trailing zeros from \Var{cmd}\;
%        \If{dot remains only}{
%          \Var{cmd} \Gets \Dat{0}\;
%        }
%      }
%      \Else{
%        \Var{cmd} \Gets \Dat{1}\;
%      }
%    \end{procedure}
%    The number is limited to the range between 0.0 and 1.0 and
%    formatted as short PDF number without leading or trailing zeros.
%    The precision of the number isn't changed.
%    \begin{macro}{\HyColor@NormalizeNum}
%    \begin{macrocode}
\def\HyColor@NormalizeNum#1#2{%
  \ifdim#1pt<\z@
    \def#2{0}%
  \else
    \edef#2{\zap@space#1 \@empty}%
    \expandafter\HyColor@CheckDot#2..\@nil#2%
  \fi
}
\def\HyColor@CheckDot#1.#2.#3\@nil#4{%
  \ifnum0#1<\@ne
    \ifx\\#2\\%
      \def#4{0}%
    \else
      \edef#4{\HyColor@ReverseString#2\@nil{}}%
      \edef#4{\expandafter\HyColor@StripLeadingZeros#4\@empty}%
      \ifx#4\@empty
        \def#4{0}%
      \else
        \edef#4{.\expandafter\HyColor@ReverseString#4\@nil{}}%
      \fi
    \fi
  \else
    \def#4{1}%
  \fi
}
\def\HyColor@ReverseString#1#2\@nil#3{%
  \ifx\\#2\\%
    #1#3%
  \else
    \@ReturnAfterFi{%
      \HyColor@ReverseString#2\@nil{#1#3}%
    }%
  \fi
}
\long\def\@ReturnAfterFi#1\fi{\fi#1}
\def\HyColor@StripLeadingZeros#1{%
  \ifx#10%
    \expandafter\HyColor@StripLeadingZeros
  \else
    #1%
  \fi
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\HyColor@NormalizeCommaRGB}
%    \begin{macrocode}
\def\HyColor@NormalizeCommaRGB#1,#2,#3\@nil#4{%
  \HyColor@NormalizeNum{#1}\HyColor@temp
  \let#4\HyColor@temp
  \HyColor@NormalizeNum{#2}\HyColor@temp
  \edef#4{#4 \HyColor@temp}%
  \HyColor@NormalizeNum{#3}\HyColor@temp
  \edef#4{#4 \HyColor@temp}%
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\HyColor@NormalizeCommaCMYK}
%    \begin{macrocode}
\def\HyColor@NormalizeCommaCMYK#1,#2,#3,#4\@nil#5{%
  \HyColor@NormalizeNum{#1}\HyColor@temp
  \let#5\HyColor@temp
  \HyColor@NormalizeNum{#2}\HyColor@temp
  \edef#5{#5 \HyColor@temp}%
  \HyColor@NormalizeNum{#3}\HyColor@temp
  \edef#5{#5 \HyColor@temp}%
  \HyColor@NormalizeNum{#4}\HyColor@temp
  \edef#5{#5 \HyColor@temp}%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{Main algorithm for color options}
%
% \begin{procedure}
%   \Param{key}{name of color option}
%   \Param{value}{value of color option}
%   \Param{cmd}{macro that stores result}
%   \BlankLine
%   \KwResult{Macro \ArgSty{cmd} contains the calculated
%      color specification string or has the meaning of \cs{relax}
%      if the color must not set}
%   \caption{MainColorOptionAlgorithm(key, value, cmd)}
%   \BlankLine
%   DefSanitized(\ArgSty{temp}, \ArgSty{value})\;
%   Call option specific algorithm(\ArgSty{key}, \ArgSty{temp}, \ArgSty{cmd})\;
% \end{procedure}
%
% \subsection{Package \xpackage{bookmark}}
%
% Since v0.8 2007/03/27 package \xpackage{bookmark} only provides
% one color option \xoption{color}. Because option \xoption{rgbcolor}
% can easily given as color specification in model rgb:
% \begin{quote}
%   |rgbcolor=|\meta{r} \meta{g} \meta{b} $\equiv$
%   |color=[rgb]{|\meta{r}|,|\meta{g}|,|\meta{b}|}|
% \end{quote}
% Package \xpackage{bookmark} stores the result in macro \cs{BKM@color}.
% The empty string is interpreted as \emph{no color}.
%
% \begin{procedure}
%   \Param{value}{value of option \xoption{color}}
%   \Param{cmd}{macro for result}
%   \Param{package}{package name for error message}
%   \Param{option}{option name for error message}
%   \caption{BookmarkColor(value, cmd, package, option)}
%   \BlankLine
%   \Switch{\Var{value}}{
%     \Case{empty}{
%       \Var{cmd} \Gets no color\;
%     }
%     \Case{with model}{
%       \eIf{with xcolor}{
%         \Var{cmd} \Gets ConvertToRGB(\Var{model}, \Var{values})\;
%       }{
%         \uIf{model $=$ rgb}{
%           \Var{cmd} \Gets \Var{values} as normalized values\;
%         }
%         \uElseIf{model $=$ gray}{
%           \Var{cmd} \Gets \Var{values} as normalized tripled values\;
%         }
%         \Else{
%           error\;
%         }
%       }
%     }
%     \Other{
%       \eIf{with xcolor}{
%         (\Var{model}, \Var{values} \Gets get model and values\;
%         \Var{cmd} \Gets ConvertToRGB(\Var{model}, \Var{values})\;
%       }{
%         error\;
%       }
%     }
%   }
% \end{procedure}
%
%    \begin{macrocode}
\def\HyColor@BookmarkColor#1#2#3#4{%
  \HyColor@IfModel{#1}{%
    \HyColor@IfXcolor{%
      \convertcolorspec\HyColor@model\HyColor@values
                       \HyColor@model@rgb#2%
      \expandafter\HyColor@NormalizeCommaRGB#2\@nil#2%
    }{%
      \ifx\HyColor@model\HyColor@model@rgb
        \expandafter\HyColor@NormalizeCommaRGB\HyColor@values\@nil#2%
      \else
        \ifx\HyColor@model\HyColor@model@gray
          \expandafter\HyColor@NormalizeNum
              \expandafter{\HyColor@values}#2%
          \edef#2{#2 #2 #2}%
        \else
          \let#2\@empty
          \HyColor@ErrorModelNoXcolor{#3}{#4}%
        \fi
      \fi
    }%
  }{%
    \let#2\HyColor@values
    \ifx#2\@empty
    \else
      \HyColor@IfXcolor{%
        \extractcolorspec{#1}#2%
        \expandafter\convertcolorspec#2\HyColor@model@rgb#2%
        \expandafter\HyColor@NormalizeCommaRGB#2\@nil#2%
      }{%
        \let#2\@empty
        \HyColor@ErrorSpecNoXcolor{#3}{#4}%
      }%
    \fi
  }%
}
%    \end{macrocode}
%    \begin{macrocode}
\def\HyColor@ErrorModelNoXcolor#1#2{%
  \PackageError{#1}{%
    Color model `\HyColor@model' is not supported\MessageBreak
    without package `xcolor' in\MessageBreak
    `#2=[\HyColor@model]{\HyColor@values}'%
  }\@ehc
}
%    \end{macrocode}
%    \begin{macrocode}
\def\HyColor@ErrorSpecNoXcolor#1#2{%
  \PackageError{#1}{%
    This color specification is not supported\MessageBreak
    without package `xcolor' in\MessageBreak
    `#2=\HyColor@values'%
  }\@ehc
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\HyColor@IfModel#1{%
  \@ifnextchar[{%
    \HyColor@WithModel
  }{%
    \HyColor@WithoutModel
  }%
  #1\@nil
}
\def\HyColor@WithModel[#1]#2\@nil{%
  \HyColor@DefSanitized\HyColor@model{#1}%
  \HyColor@DefSanitized\HyColor@values{#2}%
  \@firstoftwo
}
\def\HyColor@WithoutModel#1\@nil{%
  \let\HyColor@model\relax
  \HyColor@DefSanitized\HyColor@values{#1}%
  \@secondoftwo
}
%    \end{macrocode}
%
% \subsection{Utils}
%
%    \begin{macro}{\@ReturnAfterFi}
%    \begin{macrocode}
\long\def\@ReturnAfterFi#1\fi{\fi#1}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\HyColor@IfXcolor}
%    \begin{macrocode}
\def\HyColor@IfXcolor{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname convertcolorspec\endcsname\relax
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macrocode}
\def\HyColor@model@empty{empty}
\@onelevel@sanitize\HyColor@model@empty
\def\HyColor@model@gray{gray}
\@onelevel@sanitize\HyColor@model@gray
\def\HyColor@model@rgb{rgb}
\@onelevel@sanitize\HyColor@model@rgb
\def\HyColor@model@cmyk{cmyk}
\@onelevel@sanitize\HyColor@model@cmyk
\def\HyColor@model@Gray{Gray}
\@onelevel@sanitize\HyColor@model@Gray
%    \end{macrocode}
%
% \subsection{Package \xpackage{hyperref}}
%
% \subsubsection{Options \xoption{Hyp.*color}}
%
%    \begin{macrocode}
\def\HyColor@UseColor#1{%
  \ifx\relax#1\@empty
  \else
    \ifx\@empty#1\@empty
    \else
      \expandafter\expandafter\expandafter\HyColor@@UseColor#1\@nil
    \fi
  \fi
}
\def\HyColor@@UseColor{%
  \@ifnextchar[\HyColor@@@UseColor\HyColor@@@@UseColor
}
\def\HyColor@@@UseColor[#1]#2\@nil{%
  \color[{#1}]{#2}%
}
\def\HyColor@@@@UseColor#1\@nil{%
  \color{#1}%
}
%    \end{macrocode}
%
% \begin{procedure}
%   \Param{value}{value of the option}
%   \Param{cmd}{macro for result}
%   \caption{HyperrefColor(value, cmd)}
%   \BlankLine
%   \Switch{\Var{value}}{
%     \Case{empty}{
%       \Var{cmd} \Gets no color\;
%     }
%     \Case{with model}{
%       Call \cs{color} with model\;
%     }
%     \Case{without model}{
%       Call \cs{color} without model\;
%     }
%   }
% \end{procedure}
%
%    \begin{macrocode}
\def\HyColor@HyperrefColor#1#2{%
  \HyColor@IfModel{#1}{%
    \edef#2{[{\HyColor@model}]{\HyColor@values}}%
  }{%
    \let#2\HyColor@values
    \ifx#2\@empty
      \let#2\relax
    \fi
  }%
}
%    \end{macrocode}
%
% \subsubsection{Generic algorithm}
%
% \begin{procedure}
%   \footnotesize
%   \Param{value}{value of the option}
%   \Param{cmd}{macro for result}
%   \Param{package}{package name for error message}
%   \Param{option}{option name for error message}
%   \caption{Algorithm X0134(value, cmd, package, option)}
%   \BlankLine
%   \Switch{\Var{value}}{
%     \Case{empty}{
%       \Var{cmd} \Gets no color\;
%     }
%     \Case{with model}{
%       \Switch{\Var{model}}{
%         \Case{empty}{
%           \Var{cmd} \Gets ""\;
%         }
%         \Case{gray, rgb, cmyk}{
%           \Var{cmd} \Gets \Var{output}()\;
%         }
%         \Case{Gray}{
%           \eIf{with xcolor}{
%             (\Var{model}, \Var{values}) \Gets convert to gray\;
%           }{
%             error(\Var{package}, \Var{option}, "Missing xcolor"),
%             \Var{cmd} \Gets no color\;
%           }
%         }
%         \Else{
%           \eIf{with xcolor}{
%             (\Var{model}, \Var{values}) \Gets convert to rgb\;
%             \Var{cmd} \Gets \Var{output}()\;
%           }{
%             error(\Var{package}, \Var{option}, "Missing xcolor"),
%             \Var{cmd} \Gets no color\;
%           }
%         }
%       }
%     }
%     \Case{rgb values}{
%       (\Var{model}, \Var{values}) \Gets ("rgb", (r,g,b))\;
%       \Var{cmd} \Gets \Var{output}()\;
%     }
%     \Case{without model}{
%       \eIf{with xcolor}{
%         (\Var{model}, \Var{values}) \Gets
%             get model and values(\Var{value})\;
%         \Switch{\Var{model}}{
%           \Case{gray, rgb, cmyk}{
%             \Var{cmd} \Gets \Var{output}()\;
%           }
%           \Case{Gray}{
%             (\Var{model}, \Var{values}) \Gets convert to gray\;
%             \Var{cmd} \Gets \Var{output}()\;
%           }
%           \Else{
%             (\Var{model}, \Var{values}) \Gets convert to rgb\;
%             \Var{cmd} \Gets \Var{output}()\;
%           }
%         }
%       }{
%         error(\Var{package}, \Var{option}, "Missing xcolor"),
%         \Var{cmd} \Gets no color\;
%       }
%     }
%   }
% \end{procedure}
%
%    \begin{macro}{\HyColor@XZeroOneThreeFour}
%    \begin{macrocode}
\def\HyColor@XZeroOneThreeFour#1#2#3#4{%
  \HyColor@IfModel{#1}{%
    \ifx\HyColor@model\HyColor@model@empty
      \let#2\@empty
    \else\ifx\HyColor@model\HyColor@model@gray
      \expandafter\HyColor@NormalizeNum
          \expandafter{\HyColor@values}#2%
    \else\ifx\HyColor@model\HyColor@model@rgb
      \expandafter\HyColor@NormalizeCommaRGB\HyColor@values\@nil#2%
    \else\ifx\HyColor@model\HyColor@model@cmyk
      \expandafter\HyColor@NormalizeCommaCMYK\HyColor@values\@nil#2%
    \else\ifx\HyColor@model\HyColor@model@Gray
      \HyColor@IfXcolor{%
        \convertcolorspec\HyColor@model\HyColor@values
                         \HyColor@model@gray#2%
        \expandafter\HyColor@NormalizeNum\expandafter{#2}#2%
        \let\HyColor@model\HyColor@model@gray
      }{%
        \let#2\relax
        \HyColor@ErrorModelNoXcolor{#3}{#4}%
      }%
    \else
      \HyColor@IfXcolor{%
        \convertcolorspec\HyColor@model\HyColor@values
                         \HyColor@model@rgb#2%
        \expandafter\HyColor@NormalizeCommaRGB#2\@nil#2%
        \let\HyColor@model\HyColor@model@rgb
      }{%
        \let#2\relax
        \HyColor@ErrorModelNoXcolor{#3}{#4}%
      }%
    \fi\fi\fi\fi\fi
  }{%
    \let#2\HyColor@values
    \ifx#2\@empty
      \let#2\relax
    \else
      \expandafter\HyColor@IfRGB\expandafter{\HyColor@values}{%
        \expandafter\HyColor@NormalizeCommaRGB\HyColor@values\@nil#2%
      }{%
        \HyColor@IfXcolor{%
          \expandafter\extractcolorspec\expandafter{\HyColor@values}#2%
          \edef\HyColor@model{\expandafter\@firstoftwo#2}%
          \edef\HyColor@values{\expandafter\@secondoftwo#2}%
          \ifx\HyColor@model\HyColor@model@gray
            \expandafter\HyColor@NormalizeNum\expandafter
                {\HyColor@values}#2%
          \else\ifx\HyColor@model\HyColor@model@rgb
            \expandafter\HyColor@NormalizeCommaRGB
                \HyColor@values\@nil#2%
          \else\ifx\HyColor@model\HyColor@model@cmyk
            \expandafter\HyColor@NormalizeCommaCMYK
                \HyColor@values\@nil#2%
          \else\ifx\HyColor@model\HyColor@model@Gray
            \convertcolorspec\HyColor@model\HyColor@values
                \HyColor@model@gray#2%
            \expandafter\HyColor@NormalizeNum\expandafter
                {\HyColor@values}#2%
            \let\HyColor@model\HyColor@model@gray
          \else
            \convertcolorspec\HyColor@model\HyColor@values
                \HyColor@model@rgb#2%
            \expandafter\HyColor@NormalizeCommaRGB#2\@nil#2%
            \let\HyColor@model\HyColor@model@rgb
          \fi\fi\fi\fi
        }{%
          \let#2\relax
          \HyColor@ErrorSpecNoXcolor{#3}{#4}%
        }%
      }%
    \fi
  }%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{Field options}
%
%    \begin{macro}{\HyColor@FieldBColor}
%    \begin{macrocode}
\let\HyColor@FieldBColor\HyColor@XZeroOneThreeFour
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\HyColor@FieldColor}
%    \begin{macrocode}
\def\HyColor@FieldColor#1#2#3#4{%
  \let\HyColor@model\@empty
  \HyColor@XZeroOneThreeFour{#1}{#2}{#3}{#4}%
  \ifx#2\relax
    \let#2\@empty
  \else
    \ifx#2\@empty
    \else
      \ifx\HyColor@model\HyColor@model@gray
        \edef#2{#2 g}%
      \else\ifx\HyColor@model\HyColor@model@rgb
        \edef#2{#2 rg}%
      \else\ifx\HyColor@model\HyColor@model@cmyk
        \edef#2{#2 k}%
      \else
        \PackageError{#3}{Internal error: unsupported color model}\@ehc
      \fi\fi\fi
    \fi
  \fi
}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{Detection for naked RGB values}
%
%    \begin{macro}{\HyColor@IfRGB}
%    \begin{macrocode}
\newif\ifHyColor@result
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdfmatch\endcsname\relax
  \expandafter\@firstoftwo
\else
  \expandafter\@secondoftwo
\fi
{%
  \begingroup
    \def\x#1{\endgroup
      \def\HyColor@IfRGB##1{%
        \HyColor@@IfRGB##1#1#1#1\@nil
      }%
    }%
  \x{ }%
  \edef\HyColor@TwoSpaces{\space\space}%
  \def\HyColor@@IfRGB#1 #2 #3 #4\@nil{%
    \HyColor@resulttrue
    \def\HyColor@temp{#4}%
    \ifx\HyColor@temp\HyColor@TwoSpaces
      \HyColor@CheckNum{#1}%
      \ifHyColor@result
        \HyColor@CheckNum{#2}%
        \ifHyColor@result
          \HyColor@CheckNum{#3}%
        \fi
      \fi
    \else
      \HyColor@resultfalse
    \fi
    \ifHyColor@result
      \let\HyColor@model\HyColor@model@rgb
      \edef\HyColor@values{#1,#2,#3}%
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
  }%
  \def\HyColor@zero{0}%
  \def\HyColor@one{1}%
  \def\HyColor@dot{.}%
  \def\HyColor@CheckNum#1{%
    \def\HyColor@temp{#1}%
    \ifx\HyColor@temp\@empty
      \HyColor@resultfalse
    \else
      \edef\HyColor@temp{\@car#1\@nil}%
      \ifx\HyColor@temp\HyColor@zero
      \else
        \ifx\HyColor@temp\HyColor@one
        \else
          \ifx\HyColor@temp\HyColor@dot
          \else
            \HyColor@resultfalse
          \fi
        \fi
      \fi
    \fi
  }%
}{%
  \def\HyColor@MatchNum{%
    (0*1\string\.0*|0*1|0+\string\.?[0-9]*|\string\.[0-9]+)%
  }%
  \def\HyColor@IfRGB#1{%
    \ifnum\pdfmatch{^\HyColor@MatchNum\space\HyColor@MatchNum
        \space\HyColor@MatchNum$}{#1}>\z@
      \let\HyColor@model\HyColor@model@rgb
      \edef\HyColor@values{%
        \expandafter\strip@prefix\pdflastmatch1,%
        \expandafter\strip@prefix\pdflastmatch2,%
        \expandafter\strip@prefix\pdflastmatch3%
      }%
      \HyColor@resulttrue
      \expandafter\@firstoftwo
    \else
      \HyColor@resultfalse
      \expandafter\@secondoftwo
    \fi
  }%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{Options \xoption{*bordercolor}}
%
% \begin{procedure}
%   \Param{value}{value of the option}
%   \Param{cmd}{macro for result}
%   \Param{package, option}{package and option for error message}
%   \caption{HyperrefBorderColor(value, cmd, package, option)}
%   \BlankLine
%   \Switch{\Var{value}}{
%     \Case{empty}{
%       \Var{cmd} \Gets no color\;
%     }
%     \Case{with model}{
%       \eIf{with xcolor}{
%         (\Var{model}, \Var{values}) \Gets convert to rgb\;
%         \Var{cmd} \Gets output values\;
%       }{
%         \Switch{\Var{model}}{
%           \Case{rgb, gray}{
%             \Var{cmd} \Gets output values\;
%           }
%           \Else{
%             error(\Var{package}, \Var{option}, "Missing xcolor")\;
%             \Var{cmd} \Gets no color\;
%           }
%         }
%       }
%     }
%     \Case{rgb values}{
%       \Var{cmd} \Gets output values\;
%     }
%     \Case{without model}{
%       \eIf{with xcolor}{
%         (\Var{model}, \Var{values}) \Gets convert to rgb\;
%         \Var{cmd} \Gets output values\;
%       }{
%         error(\Var{package}, \Var{option}, "Missing xcolor");
%         \Var{cmd} \Gets no color\;
%       }
%     }
%   }
% \end{procedure}
%
%    \begin{macro}{\HyColor@HyperrefBorderColor}
%    \begin{macrocode}
\def\HyColor@HyperrefBorderColor#1#2#3#4{%
  \HyColor@IfModel{#1}{%
    \HyColor@IfXcolor{%
      \convertcolorspec\HyColor@model\HyColor@values
                       \HyColor@model@rgb#2%
      \expandafter\HyColor@NormalizeCommaRGB#2\@nil#2%
    }{%
      \ifx\HyColor@model\HyColor@model@rgb
        \expandafter\HyColor@NormalizeCommaRGB\HyColor@values\@nil#2%
      \else
        \ifx\HyColor@model\HyColor@model@gray
          \expandafter\HyColor@NormalizeNum
              \expandafter{\HyColor@values}#2%
          \edef#2{#2 #2 #2}%
        \else
          \let#2\relax
          \HyColor@ErrorModelNoXcolor{#3}{#4}%
        \fi
      \fi
    }%
  }{%
    \let#2\HyColor@values
    \ifx#2\@empty
      \let#2\relax
    \else
      \expandafter\HyColor@IfRGB\expandafter{\HyColor@values}{%
        \expandafter\HyColor@NormalizeCommaRGB\HyColor@values\@nil#2%
      }{%
        \HyColor@IfXcolor{%
          \extractcolorspec{#1}#2%
          \expandafter\convertcolorspec#2\HyColor@model@rgb#2%
          \expandafter\HyColor@NormalizeCommaRGB#2\@nil#2%
        }{%
          \let#2\relax
          \HyColor@ErrorSpecNoXcolor{#3}{#4}%
        }%
      }%
    \fi
  }%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{Package \xpackage{attachfile2}}
%
%    Before PDF-1.7 only RGB values are permitted in annotations.
%    Since PDF-1.7 the color entry in annotations understands
%    several color models, depending on the size of the color array:
%    \begin{itemize}
%    \item Zero entries: means transparent, not useful for
%          file attachments. AR7/Linux and AR8/Linux show black instead.
%    \item One entry: color model `gray'.
%    \item Three entries: color model `rgb'.
%    \item Four entries: color model `cmyk'.
%    \end{itemize}
%    An empty color specification is interpreted as ``no color''.
%
%    \begin{macro}{\HyColor@DetectPdfVersion}
%    \begin{macrocode}
\def\HyColor@DetectPdfVersion{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname Hy@pdfversion\endcsname\relax
    \global\chardef\HyColor@PdfVersion=0 %
  \else
    \global\chardef\HyColor@PdfVersion=\Hy@pdfversion\relax
  \fi
  \global\let\HyColor@DetectPdfVersion\relax
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\HyColor@SpaceToComma}
%    \begin{macrocode}
\def\HyColor@SpaceToComma#1 #2\@nil{%
  #1%
  \ifx\relax#2\relax
    \expandafter\@gobble
  \else
    ,%
    \expandafter\@firstofone
  \fi
  {%
    \HyColor@SpaceToComma#2\@nil
  }%
}%
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\HyColor@AttachfileColor}
%    \begin{macrocode}
\def\HyColor@AttachfileColor#1#2#3#4#5#6{%
  \def#2{#1}%
  \ifx#2\@empty
    \let#3\@gobble
    \let#4\@empty
  \else
    \HyColor@resultfalse
    \HyColor@XZeroOneThreeFour{#1}#3{#5}{#6}%
    \ifHyColor@result
      \edef#2{%
        [rgb]{\expandafter\HyColor@SpaceToComma#3 \@nil}%
      }%
    \fi
    \ifx\HyColor@model\HyColor@model@rgb
      \edef#4{/C[#3]}% hash-ok
      \edef#3##1{%
        #3 %
        \noexpand\csname atfi@SETRGBCOLOR##1\noexpand\endcsname
      }%
    \else
      \ifx\HyColor@model\HyColor@model@gray
        \HyColor@DetectPdfVersion
        \ifnum\HyColor@PdfVersion<7 %
          \edef#4{/C[#3 #3 #3]}% hash-ok
        \else
          \edef#4{/C[#3]}% hash-ok
        \fi
        \edef#3##1{%
          #3 %
          \noexpand\csname atfi@SETGRAYCOLOR##1\noexpand\endcsname
        }%
      \else
        \ifx\HyColor@model\HyColor@model@cmyk
          \HyColor@DetectPdfVersion
          \ifnum\HyColor@PdfVersion<7 %
            \HyColor@IfModel{#1}{%
              \HyColor@IfXcolor{%
                \convertcolorspec\HyColor@model\HyColor@values
                                 \HyColor@model@rgb#4%
                \expandafter\HyColor@NormalizeCommaRGB#4\@nil#4%
                \edef#4{/C[#4]}% hash-ok
              }{%
                \let#4\@empty
                \HyColor@ErrorModelNoXcolor{#5}{#6}%
              }%
            }{%
              \HyColor@IfXcolor{%
                \extractcolorspec{#1}#4%
                \expandafter\convertcolorspec#4%
                    \HyColor@model@rgb#4%
                \expandafter\HyColor@NormalizeCommaRGB#4\@nil#4%
                \edef#4{/C[#4]}% hash-ok
              }{%
                \let#4\@empty
                \HyColor@ErrorSpecNoXcolor{#5}{#6}%
              }%
            }%
          \else
            \edef#4{/C[#3]}% hash-ok
          \fi
          \edef#3##1{%
            #3 %
            \noexpand\csname atfi@SETCMYKCOLOR##1\noexpand\endcsname
          }%
        \else
          \ifx\HyColor@model\HyColor@model@empty
            \PackageError{#5}{%
              Color model `empty' is not permitted for option `#6'%
            }\@ehc
            \let#2\@empty
            \let#3\@gobble
            \let#4\@empty
          \else
            \ifx\HyColor@model\relax % (missing xcolor)
              \let#3\@gobble
              \let#4\@empty
            \else
              \PackageError{#5}{%
                Internal error: unsupported color model%
              }\@ehc
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \subsection{Patch for package \xpackage{xcolor}}
%
%    Because the test files triggered a bug in package \xpackage{xcolor}
%    of version 2007/01/21 v2.11.
%    I contacted the author of \xpackage{xcolor} Uwe Kern. He responded
%    with a test version 2007/03/27 v2.12a00 that fixes the problem.
%    However, apparently he did not found the time for an official
%    release yet. Thus I have reluctantly written the following
%    patch package using the fixes of v2.12a00.
%
%    The patch is immediately applied if package \xpackage{xcolor}
%    is already loaded.
%    Otherwise the patch is delayed using \cs{AfterPackage} if
%    package \xpackage{scrlfile} is loaded. As last resort
%    \cs{AtBeginDocument} is used.
%    \begin{macrocode}
%<*xcolor>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xcolor-patch}[2020/01/27 v1.10 xcolor patch]
%    \end{macrocode}
%    \begin{macrocode}
\RequirePackage{hopatch}
\hopatch@AfterPackage{xcolor}{%
%    \end{macrocode}
%    \begin{macro}{\XC@ifxcase}
%    \begin{macrocode}
  \long\def\reserved@a#1#2#3{%
    \long\def\@@tmp##1##2{%
      \ifx#1##1%
        \toks@{##2}%
        \expandafter\remove@to@nnil
      \else
        \expandafter\@@tmp
      \fi
    }%
    \@@tmp#2#1{#3}\@nnil\the\toks@
  }%
  \ifx\XC@ifxcase\reserved@a
    \long\def\XC@ifxcase#1#2#3{%
      \long\def\XC@if@##1##2{%
        \ifx#1##1%
          \toks@{##2}%
          \expandafter\remove@to@nnil
        \else
          \expandafter\XC@if@
        \fi
      }%
      \XC@if@#2#1{#3}\@nnil
      \the\toks@
    }%
  \fi
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\XC@ifcase}
%    \begin{macrocode}
  \long\def\reserved@a#1#2#3{%
    \long\def\@@tmp##1##2{%
      \@expandtwoargs\in@{,#1,}{,##1,}%
      \ifin@
        \toks@{##2}%
        \expandafter\remove@to@nnil
      \else
        \expandafter\@@tmp
      \fi
    }%
    \@@tmp#2{#1}{#3}\@nnil
    \the\toks@
  }%
  \ifx\XC@ifcase\reserved@a
    \long\def\XC@ifcase#1#2#3{%
      \long\def\XC@if@##1##2{%
        \@expandtwoargs\in@{,#1,}{,##1,}%
        \ifin@
          \toks@{##2}%
          \expandafter\remove@to@nnil
        \else
          \expandafter\XC@if@
        \fi
      }%
      \XC@if@#2{#1}{#3}\@nnil
      \the\toks@
    }%
  \fi
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\XC@cnv@gray}
%    \begin{macrocode}
  \def\reserved@a#1,{%
    \XC@ifxcase\tm{%
      \XC@mod@rgb{%
        \XC@calcN{#1}\@@tmp
        \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
      }%
      \XC@mod@cmy{%
        \XC@calcC{#1}\@@tmp
        \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
      }%
      \XC@mod@cmyk{%
        \XC@calcC{#1}\@@tmp
        \edef\@@tmp{0,0,0,\@@tmp}%
      }%
      \XC@mod@RGB{%
        \edef\@@scl{\rangeRGB}%
        \XC@calcM{#1}\@@tmp
        \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
      }%
      \XC@mod@HTML{%
        \edef\@@scl{\@cclv}%
        \XC@calcM{#1}\@@tmp
        \XC@calcH\@@tmp\@@tmp
        \edef\@@tmp{\@@tmp\@@tmp\@@tmp}%
      }%
      \XC@mod@HSB{%
        \edef\@@scl{\rangeHSB}%
        \XC@calcM{#1}\@@tmp
        \edef\@@tmp{0,0,\@@tmp}%
      }%
      \XC@mod@Gray{%
        \edef\@@scl{\rangeGray}%
        \XC@calcM{#1}\@@tmp
      }%
    }%
    {%
      \XC@calcN{#1}\@@tmp
      \edef\@@tmp{0,0,\@@tmp}%
    }%
  }%
  \ifx\XC@cnv@gray\reserved@a
    \def\XC@cnv@gray#1,{%
      \XC@ifxcase\tm{%
        \XC@mod@rgb{%
          \XC@calcN{#1}\@@tmp
          \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
        }%
        \XC@mod@gray{}%
        \XC@mod@cmy{%
          \XC@calcC{#1}\@@tmp
          \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
        }%
        \XC@mod@cmyk{%
          \XC@calcC{#1}\@@tmp
          \edef\@@tmp{0,0,0,\@@tmp}%
        }%
        \XC@mod@RGB{%
          \edef\@@scl{\rangeRGB}%
          \XC@calcM{#1}\@@tmp
          \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}%
        }%
        \XC@mod@HTML{%
          \edef\@@scl{\@cclv}%
          \XC@calcM{#1}\@@tmp
          \XC@calcH\@@tmp\@@tmp
          \edef\@@tmp{\@@tmp\@@tmp\@@tmp}%
        }%
        \XC@mod@HSB{%
          \edef\@@scl{\rangeHSB}%
          \XC@calcM{#1}\@@tmp
          \edef\@@tmp{0,0,\@@tmp}%
        }%
        \XC@mod@Gray{%
          \edef\@@scl{\rangeGray}%
          \XC@calcM{#1}\@@tmp
        }%
      }%
      {%
        \XC@calcN{#1}\@@tmp
        \edef\@@tmp{0,0,\@@tmp}%
      }%
    }%
  \fi
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{Fix fragile \cs{@frameb@x}}
%
%    \cs{fbox} becomes fragile, because the internal \cs{@frameb@x}
%    is redefined by package \xpackage{xcolor}. The redefinition is
%    no longer robust. Test file:
%\begin{quote}
%\begin{verbatim}
%\documentclass{article}
%\usepackage{xcolor}
%\makeatletter
%\protected@edef\x{\fbox{abc}}
%\@@end
%\end{verbatim}
%\end{quote}
%    \begin{macrocode}
  \@ifundefined{XC@frameb@x }{%
    \expandafter\let\csname XC@frameb@x \endcsname\XC@frameb@x
    \edef\XC@frameb@x{%
      \noexpand\protect
      \expandafter\noexpand\csname XC@frameb@x \endcsname
    }%
    \expandafter\ifx\csname XC@frameb@x \endcsname\@frameb@x
      \let\@frameb@x\XC@frameb@x
    \fi
  }{}%
}
%    \end{macrocode}
%    \begin{macrocode}
%</xcolor>
%    \end{macrocode}
%% \section{Installation}
%
% \subsection{Download}
%
% \paragraph{Package.} This package is available on
% CTAN\footnote{\CTANpkg{hycolor}}:
% \begin{description}
% \item[\CTAN{macros/latex/contrib/hycolor/hycolor.dtx}] The source file.
% \item[\CTAN{macros/latex/contrib/hycolor/hycolor.pdf}] Documentation.
% \end{description}
%
%
%
% \subsection{Package installation}
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip\ archive. The files are extracted by running the
% \xfile{.dtx} through \plainTeX:
% \begin{quote}
%   \verb|tex hycolor.dtx|
% \end{quote}
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree):
% \begin{quote}
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
%   hycolor.sty & tex/latex/hycolor/hycolor.sty\\
%   xcolor-patch.sty & tex/latex/hycolor/xcolor-patch.sty\\
%   hycolor.pdf & doc/latex/hycolor/hycolor.pdf\\
%   hycolor.dtx & source/latex/hycolor/hycolor.dtx\\
% \end{tabular}^^A
% }^^A
% \sbox0{\t}^^A
% \ifdim\wd0>\linewidth
%   \begingroup
%     \advance\linewidth by\leftmargin
%     \advance\linewidth by\rightmargin
%   \edef\x{\endgroup
%     \def\noexpand\lw{\the\linewidth}^^A
%   }\x
%   \def\lwbox{^^A
%     \leavevmode
%     \hbox to \linewidth{^^A
%       \kern-\leftmargin\relax
%       \hss
%       \usebox0
%       \hss
%       \kern-\rightmargin\relax
%     }^^A
%   }^^A
%   \ifdim\wd0>\lw
%     \sbox0{\small\t}^^A
%     \ifdim\wd0>\linewidth
%       \ifdim\wd0>\lw
%         \sbox0{\footnotesize\t}^^A
%         \ifdim\wd0>\linewidth
%           \ifdim\wd0>\lw
%             \sbox0{\scriptsize\t}^^A
%             \ifdim\wd0>\linewidth
%               \ifdim\wd0>\lw
%                 \sbox0{\tiny\t}^^A
%                 \ifdim\wd0>\linewidth
%                   \lwbox
%                 \else
%                   \usebox0
%                 \fi
%               \else
%                 \lwbox
%               \fi
%             \else
%               \usebox0
%             \fi
%           \else
%             \lwbox
%           \fi
%         \else
%           \usebox0
%         \fi
%       \else
%         \lwbox
%       \fi
%     \else
%       \usebox0
%     \fi
%   \else
%     \lwbox
%   \fi
% \else
%   \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
% TDS installing feature, then some files can already be in the right
% place, see the documentation of \docstrip.
%
% \subsection{Refresh file name databases}
%
% If your \TeX~distribution
% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
% these. For example, \TeX\,Live\ users run \verb|texhash| or
% \verb|mktexlsr|.
%
% \subsection{Some details for the interested}
%
% \paragraph{Unpacking with \LaTeX.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip\ and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX\ for \docstrip\ (really,
% \docstrip\ does not need \LaTeX), then inform the autodetect routine
% about your intention:
% \begin{quote}
%   \verb|latex \let\install=y\input{hycolor.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by the
% configuration file \xfile{ltxdoc.cfg}. For instance, put this
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
%   \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
% An example follows how to generate the
% documentation with pdf\LaTeX:
% \begin{quote}
%\begin{verbatim}
%pdflatex hycolor.dtx
%makeindex -s gind.ist hycolor.idx
%pdflatex hycolor.dtx
%makeindex -s gind.ist hycolor.idx
%pdflatex hycolor.dtx
%\end{verbatim}
% \end{quote}
%
% \begin{History}
%   \begin{Version}{2007/04/09 v1.0}
%   \item
%     First version.
%   \end{Version}
%   \begin{Version}{2007/04/11 v1.1}
%   \item
%     Line ends sanitized.
%   \end{Version}
%   \begin{Version}{2008/07/29 v1.2}
%   \item
%     Support for package \xpackage{attachfile2} added.
%   \end{Version}
%   \begin{Version}{2008/08/01 v1.3}
%   \item
%     Patch package \xpackage{xcolor-patch} added that fixes bugs in
%     package \xpackage{xcolor} to get the test files running.
%   \end{Version}
%   \begin{Version}{2008/09/08 v1.4}
%   \item
%     Fix added to package \xpackage{xcolor-patch}:
%     Fragile \cs{@frameb@x} (used in \cs{fbox}) is made robust.
%   \end{Version}
%   \begin{Version}{2009/10/02 v1.5}
%   \item
%     Doku fixes (Herbert Voss).
%   \end{Version}
%   \begin{Version}{2009/12/12 v1.6}
%   \item
%     Short info shortened.
%   \end{Version}
%   \begin{Version}{2011/01/30 v1.7}
%   \item
%     Package \xpackage{xcolor-patch} uses package \xpackage{hopatch}.
%   \end{Version}
%   \begin{Version}{2016/05/16 v1.8}
%   \item
%     Documentation updates.
%   \end{Version}
%   \begin{Version}{2019/12/15 v1.9}
%   \item
%     Documentation updates.
%   \item
%     Do not load \xpackage{xcolor-patch} by default.
%   \end{Version}
%   \begin{Version}{2020-01-27 v1.10}
%   \item extra expansion step to avoid \verb|! LaTeX Error: Undefined color `[{rgb}]| errors in hyperref.
%   \item add fix to Gray model from \xpackage{xcolor-patch}.
%   \end{Version}
% \end{History}
%
% \PrintIndex
%
% \Finale
\endinput
