summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r--Master/texmf-dist/source/latex/colortbl/colortbl.dtx267
1 files changed, 236 insertions, 31 deletions
diff --git a/Master/texmf-dist/source/latex/colortbl/colortbl.dtx b/Master/texmf-dist/source/latex/colortbl/colortbl.dtx
index 2816d576c29..3e368d1a550 100644
--- a/Master/texmf-dist/source/latex/colortbl/colortbl.dtx
+++ b/Master/texmf-dist/source/latex/colortbl/colortbl.dtx
@@ -1,7 +1,7 @@
% \iffalse
%%
%% Source File: `colortbl.dtx'.
-%% Copyright 1996 1998 1999 2012 2018 2020 David Carlisle
+%% Copyright 1996 1998 1999 2012 2018 2020 2022 David Carlisle
%%
%% This file may be distributed under the terms of the LPPL.
%% See readme for details.
@@ -15,7 +15,7 @@
%<driver>\ProvidesFile{colortbl.drv}
% \fi
% \ProvidesFile{colortbl.dtx}
- [2020/01/04 v1.0e Color table columns (DPC)]
+ [2022/06/20 v1.0f Color table columns (DPC)]
%
% \iffalse
%<*driver>
@@ -41,11 +41,11 @@
% \date{\filedate}
%
% \maketitle
-%
+%
%
% \begin{abstract}
-% This package implements a flexible mechanism for giving coloured
-% `panels' behind specified columns in a table.
+% This package implements a flexible mechanism for giving coloured
+% `panels' behind specified columns in a table.
% This package requires the \textsf{array} and \textsf{color} packages.
% \end{abstract}
%
@@ -73,11 +73,12 @@
% \changes{v1.0c}{2018/05/02}{Updates to match new array code}
% \changes{v1.0d}{2018/12/22}{Updates to match even newer array code}
% \changes{v1.0e}{2020/01/04}{Updates to match updated hhline}
+% \changes{v1.0f}{2022/06/20}{moved \cs{rowcolors} code from xcolor}
%
% \section{Introduction}
%
% This package is for colouring tables (i.e., giving coloured panels
-% behind column entries). In that it has many similarities with
+% behind column entries). In that it has many similarities with
% Timothy Van Zandt's \textsf{colortab} package. The internal
% implementation is quite different though, also \textsf{colortab}
% works with the table constructs of other formats besides \LaTeX.
@@ -103,7 +104,7 @@
%
% \section{ The \cs{columncolor} command}
%
-% The examples below demonstrate various possibilities of the
+% The examples below demonstrate various possibilities of the
% "\columncolor" command introduced by this package. The vertical rules
% specified by "|" are kept in all the examples, to make the column
% positioning clearer, although possibly you would not want coloured
@@ -187,10 +188,10 @@
% \end{tabular}}
% \end{center}
%
-%
+%
% This package should work with most other packages that are
% compatible with the \textsf{array} package syntax. In particular it
-% works with \textsf{longtable} and \textsf{dcolumn}
+% works with \textsf{longtable} and \textsf{dcolumn}
% as the following example shows.
%\errorcontextlines10
% \newcolumntype{A}{%^^A
@@ -216,10 +217,10 @@
%^^A needs a June 96 version of dcolumn, so use -1 here.
% \newcolumntype{C}{%
% >{\columncolor{yellow}[.5\tabcolsep]}%
-% D{.}{\cdot}{-1}}
+% D{.}{\cdot}{-1}}
% \newcolumntype{I}{%^^A
% >{\columncolor[gray]{0.8}[\tabcolsep][.5\tabcolsep]}%^^A
-% D{.}{\cdot}{-1}}
+% D{.}{\cdot}{-1}}
%
% \setlength\minrowclearance{2pt}
% Before starting give a little space: "\setlength\minrowclearance{2pt}"
@@ -253,7 +254,7 @@
% aaa&Depending on your driver you may get unsightly gaps or lines
% where the `screens' used to produce different shapes interact
% badly. You may want to cause adjacent panels of the same colour by
-% specifying a larger overhang
+% specifying a larger overhang
% or by adding some negative space (in a "\noalign" between rows.&12.4\\
% aaa&bbb&45.3\\
% \end{longtable}
@@ -273,7 +274,7 @@
% p{3cm}}
% \newcolumntype{C}{%
% >{\columncolor{yellow}[.5\tabcolsep]}%
-% D{.}{\cdot}{3.3}}
+% D{.}{\cdot}{3.3}}
% \newcolumntype{E}{%
% >{\large\bfseries
% \columncolor{cyan}[.5\tabcolsep]}c}
@@ -285,7 +286,7 @@
% \newcolumntype{H}{>{\columncolor[gray]{0.8}}l}
% \newcolumntype{I}{%
% >{\columncolor[gray]{0.8}[\tabcolsep][.5\tabcolsep]}%
-% D{.}{\cdot}{3.3}}
+% D{.}{\cdot}{3.3}}
%\end{verbatim}
%
% \section{Using the `overhang' arguments for \textsf{tabular*}}
@@ -388,18 +389,114 @@
% \end{tabular}}
% \end{center}
%
+% \section{The \cs{rowcolors} command}
+% The \cs{rowcolors} command and its documentation originate in the \textsf{xcolor} package
+% by Dr. Uwe Kern.
+%
+% \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" (or \LaTeX\ counter "rownum")
+% may be used within such a table to access the current row number.
+%
+% At the present time, the "rownum" counter is only incremented in tables using "\rowcolors".
+%
+% \begin{center}
+% \begin{minipage}{\textwidth}
+% \begin{verbatim}
+% \rowcolors[\hline]{3}{green}{yellow} \arrayrulecolor{red}
+% \begin{tabular}{ll}
+% test & row \therownum\\
+% test & row \therownum\\
+% test & row \therownum\\
+% test & row \therownum\\
+% \arrayrulecolor{black}
+% test & row \therownum\\
+% test & row \therownum\\
+% \rowcolor{blue}
+% test & row \therownum\\
+% test & row \therownum\\
+% \hiderowcolors
+% test & row \therownum\\
+% test & row \therownum\\
+% \showrowcolors
+% test & row \therownum\\
+% test & row \therownum\\
+% \multicolumn{1}%
+% {>{\columncolor{red}}l}{test} & row \therownum\\
+% \end{tabular}
+% \end{verbatim}
+% \end{minipage}
+% \hskip-.5\textwidth
+% \rowcolors[\hline]{3}{green}{yellow} \arrayrulecolor{red}
+% \begin{tabular}{ll}
+% test & row \therownum\\
+% test & row \therownum\\
+% test & row \therownum\\
+% test & row \therownum\\
+% \arrayrulecolor{black}
+% test & row \therownum\\
+% test & row \therownum\\
+% \rowcolor{cyan}
+% test & row \therownum\\
+% test & row \therownum\\
+% \hiderowcolors
+% test & row \therownum\\
+% test & row \therownum\\
+% \showrowcolors
+% test & row \therownum\\
+% test & row \therownum\\
+% \multicolumn{1}%
+% {>{\columncolor{magenta}}l}{test} & row \therownum\\
+% \end{tabular}
+% \qquad
+% \rowcolors*[\hline]{3}{green}{yellow}\arrayrulecolor{red}
+% \begin{tabular}{ll}
+% test & row \therownum\\
+% test & row \therownum\\
+% test & row \therownum\\
+% test & row \therownum\\
+% \arrayrulecolor{black}
+% test & row \therownum\\
+% test & row \therownum\\
+% \rowcolor{blue}
+% test & row \therownum\\
+% test & row \therownum\\
+% \hiderowcolors
+% test & row \therownum\\
+% test & row \therownum\\
+% \showrowcolors
+% test & row \therownum\\
+% test & row \therownum\\
+% \multicolumn{1}%
+% {>{\columncolor{red}}l}{test} & row \therownum\\
+% \end{tabular}
+% \arrayrulecolor{black}
+% \end{center}
+%
% \section{The \cs{cellcolor} command}
%
% A background colour can be applied to a single cell of a table by
-% beginning it with
-% "\multicolumn"\nolinebreak[3]"{1}"\nolinebreak[3]"{>{\rowcolor"\ldots,
-% (or "\columncolor" if no row-colour is in effect) but this has some
-% deficiencies:
+% beginning it with
+% "\multicolumn"\nolinebreak[3]"{1}"\nolinebreak[3]"{>{\rowcolor"\ldots,
+% (or "\columncolor" if no row-colour is in effect) but this has some
+% deficiencies:
% 1)~It prevents data within the cell from triggering the colouration; \
% 2)~The alignment specification must be copied from the top of the tabular,
% which is prone to errors, especially for "p{}" columns; \
% 3)~"\multicolumn{1}" is just silly. \
-% Therefore, there is the \cs{cellcolor} command, which works like
+% Therefore, there is the \cs{cellcolor} command, which works like
% \cs{columncolor} and \cs{rowcolor}, but over-rides both of them;
% \cs{cellcolor} can be placed anywhere in the tabular cell to which
% it applies.
@@ -409,13 +506,13 @@
% So you want coloured rules as well?
%
% One could do vertical rules without any special commands, just use
-% something like "!{\color{green}\vline}" where you'd
+% something like "!{\color{green}\vline}" where you'd
% normally use "|". The space between "||" will normally be left white.
% If you want to colour that as well, either increase the overhang of
-% the previous column (to
+% the previous column (to
% "\tabcolsep" + "\arrayrulewidth" + "\doublerulesep")
% Or remove the inter rule glue, and replace by a coloured rule of the
-% required thickness. So
+% required thickness. So
%\begin{verbatim}
%!{\color{green}\vline}
%@{\color{yellow}\vrule width \doublerulesep}
@@ -446,7 +543,7 @@
% discard space, but the coloured `space' which is used once
% "\doublerulesep" is in effect is really a third rule of a different
% colour to the two outer rules, and rules are rather harder to
-% discard.)
+% discard.)
%
% \begin{center}
% \setlength\arrayrulewidth{2pt}\arrayrulecolor{blue}
@@ -568,7 +665,7 @@
% "\hline" or the top of a colour panel defined by this style.
% It is best to increase "\extrarowsep" or "\arraystretch"
% sufficiently to ensure this doesn't happen, as that will keep the
-% line spacing in the table regular. Sometimes however, you just want
+% line spacing in the table regular. Sometimes however, you just want
% to \LaTeX\ to insert a bit of extra space above a large entry.
% You can set the length "\minrowclearance" to a small value.
% (The height of a capital letter plus this value should not be
@@ -580,7 +677,7 @@
% compatibility with \textsf{tabls}, but that is implemented quite
% differently and probably has different behaviour. So I'll keep a new
% name for now.
-%
+%
% \StopEventually{}
%
% \section{The Code}
@@ -794,10 +891,11 @@
% \end{macro}
%
% \begin{macro}{\CT@extract}
+% \changes{v1.0f}{2022/06/20}{protect against active characters}
% Now the code to extract the "\columncolor" commands.
% \begin{macrocode}
\def\CT@extract#1\columncolor#2#3\@nil{%
- \if!#2%
+ \if!\noexpand#2%
% \end{macrocode}
% "!" is a fake token inserted at the end.
% \begin{macrocode}
@@ -806,7 +904,7 @@
% \end{macrocode}
% If there was an optional argument
% \begin{macrocode}
- \if[#2%
+ \if[\noexpand#2%
\CT@extractb{#1}#3\@nil
\else
% \end{macrocode}
@@ -850,13 +948,15 @@
% \begin{macro}{\CT@extractf}
% Add the overhang info to "\CT@do@color", for excuting later.
% \begin{macrocode}
-\def\CT@extractf#1[#2][#3]#4\columncolor#5\@nil{%
+{\catcode`\!\active
+\gdef\CT@extractf#1[#2][#3]#4\columncolor#5\@nil{%
\@tempdimb#2\relax
\@tempdimc#3\relax
+ \edef!{\string!}%
\edef\CT@column@color{%
\CT@column@color
\@tempdimb\the\@tempdimb\@tempdimc\the\@tempdimc\relax}%
- \toks\@tempcnta{#1#4}}%
+ \toks\@tempcnta{#1#4}}}%
% \end{macrocode}
% \end{macro}
%
@@ -954,7 +1054,7 @@
\else
\@addtopreamble{{\CT@drsc@\vrule\@width\doublerulesep}}%
\fi\or
- \@acol \or
+ \@acol \or
\@classvii
\fi}
% \end{macrocode}
@@ -1145,6 +1245,111 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@ifxempty}
+% \marg{arg}\marg{empty}\marg{non-empty}\\
+% Tests without expanding, whether the argument \marg{arg} is empty and executes the following code accordingly; \marg{arg} must not start with the token "\XC@@".
+% Can also be used within "\edef".
+% \begin{macrocode}
+\def\@ifxempty#1{\@@ifxempty#1\@@ifxempty\XC@@}
+\def\@@ifxempty#1#2\XC@@
+ {\ifx#1\@@ifxempty
+ \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \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}.
+%
+% In the starred version, \meta{commands} are ignored in rows with
+% inactive rowcolors status (see below), whereas in the non-starred
+% version, \meta{commands} are applied to every row of the
+% table.
+% \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{\@rowc@lors\the\everycr}%
+ \ignorespaces}
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\@rowc@lors{\noalign{\global\advance\rownum\@ne}\@rowcolors}
+ \let\@rowcolors\@empty
+% \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}
+ \@norowcolor
+% \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}
+% \begin{macro}{\c@rownum}
+% Reserve a counter register. Also alias as a \LaTeX\ counter
+% (but not via "\newcounter" as should not be in the reset list.)
+% \begin{macrocode}
+ \@ifundefined{rownum}{%
+ \@ifundefined{c@rownum}%
+ {\newcount\rownum\let\c@rownum\rownum}%
+ {\let\rownum\c@rownum}%
+ }%
+ {\let\c@rownum\rownum}
+ \providecommand\therownum{\arabic{rownum}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
% \begin{macro}{\cellcolor}
% "\cellcolor" applies the specified colour to just its own tabular cell.
% It is defined robust, but without using "\DeclareRobustCommand" or
@@ -1162,7 +1367,7 @@
\global\let\CT@cell@color\relax
}}
\global\let\CT@cell@color\relax
-% \end{macrocode}
+% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DC@endright}