summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/keyvaltable
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-03-19 22:14:15 +0000
committerKarl Berry <karl@freefriends.org>2016-03-19 22:14:15 +0000
commit619a3feba04810e6c12a1007bafb3209a6597071 (patch)
tree76fd11efee3953c2376d566e674b22b6d3ec799e /Master/texmf-dist/tex/latex/keyvaltable
parent04e521880f42c9699c6b045c32176f3f59bd11c8 (diff)
keyvaltable (19mar16)
git-svn-id: svn://tug.org/texlive/trunk@40079 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/keyvaltable')
-rw-r--r--Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty154
1 files changed, 154 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty b/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty
new file mode 100644
index 00000000000..7cf966e62ff
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty
@@ -0,0 +1,154 @@
+%%
+%% This is file `keyvaltable.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% keyvaltable.dtx (with options: `package')
+%%
+%% Copyright (C) 2016 by Richard Gay <gay@mais.informatik.tu-darmstadt.de>
+%%
+%% 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.
+%%
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\ProvidesPackage{keyvaltable}
+ [2016/03/13 v0.1 Package for filling tables using key-value lists]
+\RequirePackage{etoolbox}
+\RequirePackage{xkeyval}
+\RequirePackage[table]{xcolor}
+\RequirePackage{booktabs}
+\RequirePackage{longtable,tabu}
+\newcommand\kvtSet[1]{\bgroup
+ \def\kvt@@presetqueue{\egroup}
+ \setkeys[kvt]{defaults}{#1}{}%
+ \kvt@@presetqueue}
+\newcommand\kvt@lazypreset[2]{%
+ \appto\kvt@@presetqueue{\presetkeys[kvt]{#1}{#2}{}}}
+\DeclareListParser{\mkv@dossvlist}{;}
+\newcommand\kvt@addtableprop[2]{%
+ \define@key[kvt]{defaults}{#1}{%
+ \kvt@lazypreset{Table}{#1=##1}}%
+ \presetkeys[kvt]{defaults}{#1=#2}{}%
+ \define@cmdkey[kvt]{Table}{#1}{}%
+ \presetkeys[kvt]{Table}{#1=#2}{}%
+}
+\newcommand\kvt@addcolumnprop[2]{%
+ \define@key[kvt]{defaults}{#1}{%
+ \kvt@lazypreset{Column}{#1=##1}}%
+ \presetkeys[kvt]{defaults}{#1=#2}{}%
+ \define@key[kvt]{Column}{#1}{%
+ \csdef{kvt@col@#1@\kvt@@column}{##1}}%
+ \presetkeys[kvt]{Column}{#1=#2}{}%
+}
+\newcommand\kvt@addchoicecolumnprop[3]{%
+ \define@choicekey[kvt]{defaults}{#1}{#3}{%
+ \kvt@lazypreset{Column}{#1=##1}}%
+ \presetkeys[kvt]{defaults}{#1=#2}{}%
+ \define@choicekey[kvt]{Column}{#1}{#3}%
+ {\csdef{kvt@col@#1@\kvt@@column}{##1}}%
+ \presetkeys[kvt]{Column}{#1=#2}{}%
+}
+\kvt@addtableprop{rowbg}{white..black!10}
+\kvt@addtableprop{headbg}{black!14}
+\kvt@addcolumnprop{default}{}
+\kvt@addcolumnprop{format}{\kvt@struttedcell}
+\kvt@addcolumnprop{align}{l}
+\kvt@addcolumnprop{head}{}
+\kvt@addchoicecolumnprop{hidden}{false}{false,true}
+\kvtSet{}
+\newcommand\kvt@struttedcell[1]{\strut #1\strut}
+\newcommand\NewKeyValTable[2]{%
+ \csdef{kvt@headings@#1}{}%
+ \csdef{kvt@alignments@#1}{}%
+ \csdef{kvt@colkeys@#1}{}%
+ \csdef{kvt@rowcount@#1}{1}%
+ \csdef{kvt@rows@#1}{}%
+ \listadd\kvt@alltables{#1}%
+ \def\do##1{%
+ \kvt@parsecolspec{#1}##1::\@undefined}%
+ \mkv@dossvlist{#2}%
+}
+\def\kvt@parsecolspec#1#2:#3:#4\@undefined{%
+ \def\kvt@@column{#1@#2}%
+ \setkeys[kvt]{Column}{#3}%
+ \ifcsstring{kvt@col@hidden@#1@#2}{true}{}{%
+ \cseappto{kvt@alignments@#1}{\csexpandonce{kvt@col@align@#1@#2}}%
+ \ifcsvoid{kvt@headings@#1}{}{\csappto{kvt@headings@#1}{&}}%
+ \ifcsstring{kvt@col@head@#1@#2}{}%
+ {\cseappto{kvt@headings@#1}{#2}}%
+ {\cseappto{kvt@headings@#1}{\csexpandonce{kvt@col@head@#1@#2}}}%
+ \listcsadd{kvt@colkeys@#1}{#2}%
+ }%
+ \define@cmdkey[KeyValTable]{#1}{#2}[]{}%
+ \presetkeys[KeyValTable]{#1}{#2}{}%
+}
+\newcommand\kvt@alltables{}
+\newcounter{kvtRow}
+\newcounter{kvtTypeRow}
+\newcounter{kvtTotalRow}
+\setcounter{kvtTotalRow}{1}
+\newenvironment{KeyValTable}[2][]{%
+ \bgroup%
+ \def\Row##1{\kvt@AddKeyValRow{#2}{##1}\kvt@@row\\}%
+ \kvt@StartTable{#2}{#1}%
+ }{%
+ \bottomrule%
+ \end{longtabu}\egroup}
+\AfterEndEnvironment{KeyValTable}{%
+ \csdef{kvt@rowcount@\kvt@@recenttable}{\thekvtTypeRow}}
+\newcommand\kvt@StartTable[2]{%
+ \setkeys[kvt]{Table}{#2}%
+ \gdef\kvt@@recenttable{#1}%
+ \bgroup\edef\kvt@@do{\egroup
+ \noexpand\taburowcolors[2] 2{\cmdkvt@Table@rowbg}%
+ \noexpand\begin{longtabu}{\csuse{kvt@alignments@#1}}%
+ \noexpand\toprule
+ \noexpand\rowcolor{\cmdkvt@Table@headbg}%
+ }\kvt@@do%
+ \csuse{kvt@headings@#1}\\\midrule\endhead
+ \setcounter{kvtRow}{1}%
+ \setcounter{kvtTypeRow}{\csuse{kvt@rowcount@#1}}%
+ \everyrow{%
+ \addtocounter{kvtRow}{1}%
+ \addtocounter{kvtTypeRow}{1}%
+ \addtocounter{kvtTotalRow}{1}%
+ }%
+}
+\newcommand\kvt@AddKeyValRow[2]{%
+ \setkeys[KeyValTable]{#1}{#2}%
+ \def\do##1{%
+ \ifdefvoid\kvt@@row{}{\appto\kvt@@row{&}}%
+ \eappto\kvt@@row{%
+ \csexpandonce{kvt@col@format@#1@##1}{%
+ \ifcsvoid{cmdKeyValTable@#1@##1}%
+ {\csexpandonce{kvt@col@default@#1@##1}}%
+ {\csexpandonce{cmdKeyValTable@#1@##1}}}%
+ }%
+ }\dolistcsloop{kvt@colkeys@#1}%
+}
+\newcommand\ShowKeyValTable[2][]{%
+ \bgroup
+ \kvt@StartTable{#2}{#1}%
+ \csuse{kvt@rows@#2}%
+ \bottomrule
+ \end{longtabu}%
+ \egroup
+ \csdef{kvt@rows@#2}{}}
+\newcommand\AddKeyValRow[2]{%
+ \bgroup%
+ \kvt@AddKeyValRow{#1}{#2}%
+ \csxappto{kvt@rows@#1}{\expandonce{\kvt@@row}\noexpand\\}%
+ \egroup}
+\newenvironment{KeyValTableContent}[1]{%
+ \def\Row{\AddKeyValRow{#1}}}{}%
+\endinput
+%%
+%% End of file `keyvaltable.sty'.