summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-12-31 20:42:17 +0000
committerKarl Berry <karl@freefriends.org>2022-12-31 20:42:17 +0000
commit1d55d44d122681ab6f7921c1b81bf0ee2f2678ca (patch)
treed83e2999a9b0ae34d49db711eef30d556e8e648c /Master/texmf-dist/tex
parent8871a9e4f3b8df5593e27751a20cc18019c1fa0d (diff)
keyvaltable (31dec22)
git-svn-id: svn://tug.org/texlive/trunk@65416 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty223
1 files changed, 197 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty b/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty
index 8ea0356c378..a83b679c779 100644
--- a/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty
+++ b/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty
@@ -8,25 +8,32 @@
%%
%% Copyright (C) 2016-2020 by Richard Grewe <r-g+tex@posteo.net>
%%
-%% 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:
+%% This file 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.
+%% The latest version of this license is in
+%% https://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008 or later.
%%
-%% http://www.latex-project.org/lppl.txt
+%% This file has the LPPL maintenance status "maintained".
%%
-%% and version 1.2 or later is part of all distributions of LaTeX version
-%% 1999/12/01 or later.
+%% As this file contains legal notices, it is NOT PERMITTED to modify
+%% this file in any way that the legal information placed into
+%% generated files is changed (i.e., the files generated when the
+%% original file is executed). This restriction does not apply if
+%% (parts of) the content is reused in a different WORK producing its
+%% own generated files.
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{keyvaltable}
- [2020/04/05 v2.2 Package for filling tables using key-value lists]
+ [2020/08/09 v2.3 Package for filling tables using key-value lists]
\RequirePackage{etoolbox}
\RequirePackage{xkeyval}
\RequirePackage{trimspaces}
-\PassOptionsToPackage{table}{xcolor}
-\RequirePackage{xcolor}
+\RequirePackage{colortbl}
+\AtBeginDocument{\@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}}
\RequirePackage{booktabs}
\newcommand\kvt@DeclareTrimListParser{%
\@ifstar{\kvt@DeclareTrimListParser@i{*}}
@@ -152,6 +159,8 @@
\csdef{kvt@@hdcell@head@\kvt@@hdcell}{#1}}
\define@key[kvt]{HeadCell}{align}{%
\csdef{kvt@@hdcell@align@\kvt@@hdcell}{#1}}
+\define@boolkey[kvt]{HeadCell}{underline}[true]{%
+ \csdef{kvt@@hdcell@underline@\kvt@@hdcell}{#1}}
\kvt@def@globalopts{HeadCell}{align}
\define@cmdkey[kvt]{Row}{bg}{}
\define@cmdkey[kvt]{Row}{format}{}
@@ -189,7 +198,7 @@
width=\linewidth,
captionpos=b,
default=,
- format=\kvtStrutted,
+ format=\@firstofone,
align=l,
head=,
hidden=false,
@@ -201,7 +210,7 @@
Row/expand=false,
Row/expandonce=false,
ColGroup/align=c,
- ColGroup/format=\kvtStrutted,
+ ColGroup/format=\@firstofone,
HeadCell/align=c,
}}
\newcommand\NewKeyValTable[3][]{%
@@ -218,6 +227,7 @@
\csdef{kvt@alignments@#2}{}%
\csdef{kvt@allcolumns@#2}{}%
\csdef{kvt@displaycols@#2}{}%
+ \csdef{kvt@ndisplaycols@#2}{0}%
\csdef{kvt@rowcount@#2}{0}%
\csdef{kvt@rows@#2}{}%
\csdef{kvt@headings@#2}{\kvt@defaultheader}%
@@ -249,6 +259,8 @@
{\csappto{kvt@headings@#1}{{#2}}}%
{\cseappto{kvt@headings@#1}{{\csexpandonce{kvt@col@head@#1@#2}}}}%
\listcsadd{kvt@displaycols@#1}{#2}%
+ \csedef{kvt@ndisplaycols@#1}{%
+ \the\numexpr\csuse{kvt@ndisplaycols@#1}+1\relax}%
}%
\define@cmdkey[KeyValTable]{#1}{#2}[]{}%
\define@key[KeyValTable]{#1}{#2*}{%
@@ -296,6 +308,8 @@
\def\kvt@@colgrp{#2}%
\kvt@setkeys{#3}{ColGroup}%
\kvt@checkcolgroupcs{kvt@colgrp@span@#1@#2}{#1}{#2}%
+ \csxdef{kvt@colgrp@first@#1@#2}{\kvt@@colgrp@first}%
+ \csxdef{kvt@colgrp@count@#1@#2}{\kvt@@colgrp@n}%
\eappto\kvt@@result{%
\noexpand\define@cmdkey[KeyValTable]{#1}{#2}{%
\ifdefvoid\kvt@@colgrp@first{}{%
@@ -372,7 +386,9 @@
\def\do##1{\kvt@parsehdcolspec{#1}##1::\@undefined}%
\kvt@dossvlist{#2}%
\let\kvt@@tmpgrphd\@empty
- \kvt@@span\z@
+ \let\kvt@@tmpunderlines\@empty
+ \letcs\kvt@@tmpncols{kvt@ndisplaycols@#1}%
+ \kvt@@span\z@ \kvt@@coln\@ne
\undef\kvt@@curhd \undef\kvt@@lasthd
\kvt@def@atseconduse\kvt@@switchcol{\appto\kvt@@tmpgrphd{&}}%
\def\do##1{\letcs\kvt@@curhd{kvt@@hdcellof@##1}%
@@ -384,10 +400,17 @@
consecutive columns, but it is not}%
{Compare `\string\kvt@@curhd' to the column ordering as
specified in `\string\NewKeyValTable{#1}'}}{}}%
+ \advance\kvt@@coln\kvt@@span\relax
\kvt@@span\@ne \let\kvt@@lasthd\kvt@@curhd}%
}\dolistcsloop{kvt@displaycols@#1}%
\kvt@concludehdcolumn
\appto\kvt@@tmpgrphd{\tabularnewline}%
+ \ifdefempty\kvt@@tmpunderlines{}{%
+ \eappto\kvt@@tmpgrphd{%
+ \noexpand\kvtRule@cmid{\noexpand\cmidrulewidth}
+ {\expandonce\kvt@@tmpunderlines}
+ {\expandonce\cmdkvt@Table@headbg}
+ {\expandonce\cmdkvt@Table@headbg}}}%
\edef\do{\noexpand\csappto{kvt@@custheadrows@#1}{%
\unexpanded{\noexpand\kvt@rowcolorornot{\cmdkvt@Table@headbg}}%
\noexpand\unexpanded{\expandonce{\kvt@@tmpgrphd}}}}%
@@ -397,6 +420,7 @@
\expandafter\rowcolor\expandafter{#1}}}
\newcount\kvt@@bodyrow
\newcount\kvt@@span
+\newcount\kvt@@coln
\newcommand\kvt@concludehdcolumn{%
\kvt@@switchcol
\ifdefvoid\kvt@@lasthd{}{%
@@ -405,6 +429,11 @@
{\csexpandonce{kvt@@hdcell@align@\kvt@@lasthd}}
{\noexpand\cmdkvt@Table@headformat
{\csexpandonce{kvt@@hdcell@head@\kvt@@lasthd}}}}%
+ \ifcsstring{kvt@@hdcell@underline@\kvt@@lasthd}{true}
+ {\listeadd\kvt@@tmpunderlines{%
+ {\ifnumgreater{\kvt@@coln}{1}{l}{}%
+ \ifnumless{\kvt@@coln+\kvt@@span-1}{\kvt@@tmpncols}{r}{}}%
+ {\the\kvt@@coln-\the\numexpr\kvt@@coln+\kvt@@span-1\relax}}}{}%
\cslet{kvt@@hdcelldone@\kvt@@lasthd}{\@ne}}}
\def\kvt@parsehdcolspec#1#2:#3:#4\@undefined{%
\kvt@checkcolspecempty{#4}{header cell}{#2}%
@@ -433,9 +462,141 @@
\ifstrempty{#1}{\label{#3}}{\label[#1]{#3}}}%
\csuse{the#2}}
\newcounter{kvt@LabelCtr}
+\newcommand\kvt@RuleTop{\noalign{%
+ \edef\kvt@@do{\noexpand\kvtRuleTop{\ifbool{kvt@Table@showhead}
+ {\expandonce\cmdkvt@Table@headbg}{\expandonce\kvt@@bgcolor@odd}}}%
+ \expandafter}\kvt@@do}
+\newcommand\kvt@RuleBottom{\noalign{%
+ \edef\kvt@@do{\noexpand\kvtRuleBottom{\ifnumodd{\the\kvt@@bodyrow}
+ {\expandonce\kvt@@bgcolor@odd}{\expandonce\kvt@@bgcolor@even}}}%
+ \expandafter}\kvt@@do}
+\newcommand\kvt@RuleMid{\noalign{\ifnum0=`}\fi
+ \@ifnextchar[{\kvt@RuleMid@i}{\kvt@RuleMid@i[\lightrulewidth]}}
+\long\def\kvt@RuleMid@i[#1]{%
+ \edef\kvt@@do{\unexpanded{\ifnum0=`{\fi}\kvtRuleMid[{#1}]}%
+ \ifnumodd{\the\kvt@@bodyrow}
+ {{\expandonce\kvt@@bgcolor@odd}{\expandonce\kvt@@bgcolor@even}}
+ {{\expandonce\kvt@@bgcolor@even}{\expandonce\kvt@@bgcolor@odd}}}%
+ \kvt@@do}
+\newcommand\kvt@RuleSubHead{\noalign{%
+ \edef\kvt@@do{\noexpand\kvtRuleMid
+ {\expandonce\cmdkvt@Table@headbg}{\expandonce\kvt@@bgcolor@odd}}%
+ \expandafter}\kvt@@do}
+\newcommand\kvt@RuleCMid[1]{\noalign{\ifnum0=`}\fi
+ \@ifnextchar[{\kvt@RuleCMid@i{#1}}
+ {\kvt@RuleCMid@i{#1}[\cmidrulewidth]}}
+\long\def\kvt@RuleCMid@i#1[#2]#3{%
+ \let\kvt@@rules\@empty
+ \def\kvt@@do##1{%
+ \ifcsdef{kvt@colgrp@first@#1@##1}
+ {\kvt@RuleCMid@cg{#1}{##1}}
+ {\kvt@RuleCMid@cc{#1}{##1}{1}}}%
+ \forcsvlist\kvt@@do{#3}%
+ \edef\kvt@@rules{\unexpanded{\ifnum0=`{\fi}\kvtRule@cmid}%
+ {\unexpanded{#2}}%
+ {\expandonce\kvt@@rules}
+ \ifnumodd{\the\kvt@@bodyrow}
+ {{\expandonce\kvt@@bgcolor@odd}{\expandonce\kvt@@bgcolor@even}}
+ {{\expandonce\kvt@@bgcolor@even}{\expandonce\kvt@@bgcolor@odd}}}%
+ \kvt@@rules}
+\newcommand\kvt@RuleCMid@cg[2]{\bgroup%
+ \edef\kvt@@do{\egroup
+ \unexpanded{\kvt@RuleCMid@c{#1}}%
+ {\csuse{kvt@colgrp@first@#1@#2}}
+ {\csuse{kvt@colgrp@count@#1@#2}}}%
+ \kvt@@do}
+\newcommand\kvt@RuleCMid@cc[3]{%
+ \ifinlistcs{#2}{kvt@allcolumns@#1}
+ {\ifinlistcs{#2}{kvt@displaycols@#1}
+ {\kvt@RuleCMid@c{#1}{#2}{#3}}
+ {}}
+ {\kvt@error
+ {Column or column group `#2' for `\string\CMidRule'
+ not known in table type `#1'}
+ {Check the \string\NewKeyValTable{#1} for
+ the names of known columns and check `#2' for a typo.}}}
+\newcommand\kvt@RuleCMid@c[3]{%
+ \@tempcnta\z@
+ \def\do##1{\advance\@tempcnta\@ne
+ \ifstrequal{#2}{##1}{\listbreak}{}}%
+ \dolistcsloop{kvt@displaycols@#1}%
+ \listeadd\kvt@@rules{%
+ {\ifnumgreater{\@tempcnta}{1}{l}{}%
+ \ifnumless{\@tempcnta+#3-1}{\csuse{kvt@ndisplaycols@#1}}{r}{}}%
+ {\the\@tempcnta-\the\numexpr\@tempcnta+#3-1\relax}}}
+\newcommand\kvtRuleTop{\noalign{\ifnum0=`}\fi
+ \@ifnextchar[{\kvtRuleTop@i}{\kvtRuleTop@i[\heavyrulewidth]}}
+\long\def\kvtRuleTop@i[#1]#2{\ifnum0=`{\fi}%
+ \specialrule{#1}{\abovetopsep}{0pt}%
+ \kvtRule@ColorRule{#2}{2\belowrulesep}{0pt}{-\belowrulesep}}
+\newcommand\kvtRuleBottom{\noalign{\ifnum0=`}\fi
+ \@ifnextchar[{\kvtRuleBottom@i}{\kvtRuleBottom@i[\heavyrulewidth]}}
+\long\def\kvtRuleBottom@i[#1]#2{\ifnum0=`{\fi}%
+ \kvtRule@ColorRule{#2}{\aboverulesep}{0pt}{0pt}%
+ \specialrule{#1}{0pt}{\belowbottomsep}}
+\newcommand\kvtRuleMid{\noalign{\ifnum0=`}\fi
+ \@ifnextchar[{\kvtRuleMid@i}{\kvtRuleMid@i[\lightrulewidth]}}
+\long\def\kvtRuleMid@i[#1]#2#3{\ifnum0=`{\fi}%
+ \kvtRule@ColorRule{#2}{\aboverulesep}{0pt}{0pt}%
+ \specialrule{#1}{0pt}{0pt}%
+ \kvtRule@ColorRule{#3}{2\belowrulesep}{0pt}{-\belowrulesep}}
+\newcommand\kvtRuleCMid{\noalign{\ifnum0=`}\fi
+ \@ifnextchar[{\kvtRuleCMid@i}{\kvtRuleCMid@i[\cmidrulewidth]}}
+\long\def\kvtRuleCMid@i[#1]{%
+ \@ifnextchar({\kvtRuleCMid@ii{#1}}{\kvtRuleCMid@ii{#1}()}}
+\long\def\kvtRuleCMid@ii#1(#2)#3{\ifnum0=`{\fi}%
+ \kvtRule@cmid{#1}{{#2}{#3}}}
+\newcommand\kvtRule@cmid[4]{%
+ \kvtRule@ColorRule{#3}
+ {\the\dimexpr\aboverulesep+#1/2\relax}
+ {0pt}
+ {\the\dimexpr-#1/2\relax}%
+ \kvtRule@ColorRule{#4}
+ {\the\dimexpr\belowrulesep+#1/2\relax}{0pt}
+ {\the\dimexpr-\belowrulesep-#1\relax}%
+ \noalign{%
+ \let\kvt@@rules\@empty%
+ \def\kvt@@do##1{\appto\kvt@@rules{\kvtRule@cmid@i{#1}##1}}%
+ \forlistloop\kvt@@do{#2}%
+ \expandafter}%
+ \kvt@@rules
+ \noalign{\vskip\dimexpr\belowrulesep+#1\relax}}
+\newcommand\kvtRule@cmid@i[3]{%
+ \noalign{\ifnum0=`}\fi
+ \aboverulesep=0pt\relax
+ \@cmidrule[#1](#2){#3}%
+ \noalign{%
+ \vskip-\dimexpr #1+\belowrulesep\relax
+ \global\@lastruleclass\@ne}}
+\newcommand\kvtRulesCMid{\noalign{\ifnum0=`}\fi
+ \@ifnextchar[{\kvtRulesCMid@i}{\kvtRulesCMid@i[\cmidrulewidth]}}
+\long\def\kvtRulesCMid@i[#1]#2#3#4{%
+ \let\kvt@@rules\@empty
+ \forcsvlist\kvtRulesCMid@ii{#2}%
+ \ifnum0=`{\fi\expandafter}\expandafter
+ \kvtRulesCMid@v\expandafter{\kvt@@rules}{#1}{#3}{#4}}
+\newcommand\kvtRulesCMid@ii[1]{\kvtRulesCMid@iii#1\@undefined}
+\newcommand\kvtRulesCMid@iii{%
+ \@ifnextchar({\kvtRulesCMid@iv}{\kvtRulesCMid@iv()}}
+\long\def\kvtRulesCMid@iv(#1)#2\@undefined{%
+ \listadd\kvt@@rules{{#1}{#2}}}
+\newcommand\kvtRulesCMid@v[4]{\kvtRule@cmid{#2}{#1}{#3}{#4}}
+\newcommand\kvtRule@ColorRule[4]{%
+ \ifstrempty{#1}
+ {\noalign{\expandafter\vskip\the\dimexpr #2+#3+#4\relax}}
+ {\kvtRule@SaveRuleColor
+ \arrayrulecolor{#1}%
+ \specialrule{#2}{#3}{#4}%
+ \kvtRule@RestoreRuleColor}}
+\newcommand\kvtRule@SaveRuleColor{%
+ \noalign{\global\let\kvt@@ctarc\CT@arc@}}
+\newcommand\kvtRule@RestoreRuleColor{%
+ \noalign{\global\let\CT@arc@\kvt@@ctarc}}
\newenvironment{KeyValTable}[2][]{%
\def\Row{\kvt@AddKeyValRow
{\noalign\bgroup}{\expandafter\egroup\kvt@@row}{#2}}%
+ \def\MidRule{\kvt@RuleMid}%
+ \def\CMidRule{\kvt@RuleCMid{#2}}%
\kvt@SetOptions{#2}{#1}%
\ifbool{kvt@TableEnv@resume*}{}
{\gdef\kvt@@lastenvopt{#1}}%
@@ -537,10 +698,10 @@
\let\kvt@@endhook\@empty
\let\kvt@@prehook\@empty
\ifbool{kvt@Table@showrules}
- {\def\kvt@@rule##1{\csuse{##1rule}}}
+ {\def\kvt@@rule##1{\csuse{kvt@Rule##1}}}
{\def\kvt@@rule##1{}}%
- \appto\kvt@@prehook{\kvt@@rule{top}}%
- \appto\kvt@@endhook{\kvt@@rule{bottom}}%
+ \appto\kvt@@prehook{\kvt@@rule{Top}}%
+ \appto\kvt@@endhook{\kvt@@rule{Bottom}}%
\appto\kvt@@endhook{\noalign{%
\csxdef{kvt@rowcount@#2}{\thekvtTypeRow}%
\csxdef{kvt@@rowcountlast}{\thekvtRow}}}%
@@ -567,12 +728,17 @@
{Consider placing the KeyValTable environment inside a 'table'
environment and use the \string\caption\space macro inside.}}}%
\ifdefstring{\cmdkvt@Table@captionpos}{t}
- {\let\kvt@@caption@headmain\kvt@@caption@main\let\kvt@@caption@footmain\@empty
- \let\kvt@@caption@headalt\kvt@@caption@alt \let\kvt@@caption@footalt\@empty}
- {\let\kvt@@caption@footmain\kvt@@caption@main\let\kvt@@caption@headmain\@empty
- \let\kvt@@caption@footalt\kvt@@caption@alt \let\kvt@@caption@headalt\@empty}%
+ {\let\kvt@@caption@headmain\kvt@@caption@main
+ \let\kvt@@caption@footmain\@empty
+ \let\kvt@@caption@headalt\kvt@@caption@alt
+ \let\kvt@@caption@footalt\@empty}
+ {\let\kvt@@caption@footmain\kvt@@caption@main
+ \let\kvt@@caption@headmain\@empty
+ \let\kvt@@caption@footalt\kvt@@caption@alt
+ \let\kvt@@caption@headalt\@empty}%
\ifbool{kvt@Table@showhead}
- {\eappto\kvt@@prehook{\csuse{kvt@headings@#2}\noexpand\kvt@@rule{mid}}}
+ {\eappto\kvt@@prehook{\csuse{kvt@headings@#2}%
+ \noexpand\kvt@@rule{SubHead}}}
{}%
\ifdefvoid{\cmdkvt@Table@valign}{}{\metatblCanVAlign{#1}{}
{\undef{\cmdkvt@Table@valign}%
@@ -621,8 +787,11 @@
\noalign{\parbox{0pt}{\vskip\baselineskip}}%
\caption}
\newcommand\kvt@setrowcolors[1]{%
- \ifstrempty{#1}{}{\kvt@setrowcolors@i#1\@nil}}
+ \ifstrempty{#1}{\kvt@setrowcolors@ii{}{}}
+ {\kvt@setrowcolors@i#1\@nil}}
\def\kvt@setrowcolors@i#1..#2\@nil{%
+ \kvt@setrowcolors@ii{#1}{#2}}
+\newcommand\kvt@setrowcolors@ii[2]{%
\def\kvt@@bgcolor@odd{#1}%
\def\kvt@@bgcolor@even{#2}}
\newcommand\kvt@userowcolors{\ifnumodd{\the\kvt@@bodyrow}
@@ -697,9 +866,9 @@
{\appto\kvt@@row{\kvt@userowcolors}}
{\eappto\kvt@@row{\noexpand\rowcolor{\expandonce\cmdkvt@Row@bg}}}%
\ifdefvoid\cmdkvt@Row@align
- {\let\kvt@@rowmkmulticolumn\@empty}
+ {\def\kvt@@rowmkmulticolumn{\kvt@unicolumn}}
{\edef\kvt@@rowmkmulticolumn{%
- \noexpand\multicolumn{1}{\expandonce\cmdkvt@Row@align}}}%
+ \noexpand\kvt@multicolumn{1}{\expandonce\cmdkvt@Row@align}}}%
\ifcsvoid{cmdkvt@Row@format!}
{\edef\kvt@@cellfmtbuilder##1##2{%
\noexpand\edef##1####1{%
@@ -739,7 +908,7 @@
{\protected@edef\kvt@@cell{\kvt@@cell}}{}}%
\ifcsvoid{kvt@@noformat@#2@##1}
{\kvt@@cellfmtbuilder\kvt@@formatter{kvt@@curcolformat}}%
- {\let\kvt@@formatter\@firstofone}%
+ {\let\kvt@@formatter\kvt@unicolumn}%
\csundef{kvt@@noformat@#2@##1}%
\edef\kvt@@fmtcell{\expandafter\expandonce\expandafter{%
\expandafter\kvt@@formatter\expandafter{%
@@ -780,7 +949,9 @@
\newcommand\kvt@SetMulticolumn[3]{%
\kvt@@span=#2\relax \advance\kvt@@span\m@ne
\def\kvt@@cell{#3}%
- \def\kvt@@mkmulticolumn{\multicolumn{#2}{#1}}}
+ \def\kvt@@mkmulticolumn{\kvt@multicolumn{#2}{#1}}}
+\newcommand\kvt@unicolumn[1]{#1}
+\newcommand\kvt@multicolumn[3]{\multicolumn{#1}{#2}{#3}}
\newcommand\kvtNewRowStyle{\kvt@NewStyle{row}{\kvtRenewRowStyle}}
\newcommand\kvtRenewRowStyle{\kvt@RenewStyle{row}{\kvtNewRowStyle}}
\newcommand\kvtNewTableStyle{\kvt@NewStyle{table}{\kvtRenewTableStyle}}