texlive[49063] Master/texmf-dist: keyvaltable (3nov18)
commits+karl at tug.org
commits+karl at tug.org
Sat Nov 3 22:07:14 CET 2018
Revision: 49063
http://tug.org/svn/texlive?view=revision&revision=49063
Author: karl
Date: 2018-11-03 22:07:14 +0100 (Sat, 03 Nov 2018)
Log Message:
-----------
keyvaltable (3nov18)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/keyvaltable/README.md
trunk/Master/texmf-dist/doc/latex/keyvaltable/keyvaltable.pdf
trunk/Master/texmf-dist/source/latex/keyvaltable/keyvaltable.dtx
trunk/Master/texmf-dist/source/latex/keyvaltable/keyvaltable.ins
trunk/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty
Modified: trunk/Master/texmf-dist/doc/latex/keyvaltable/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/keyvaltable/README.md 2018-11-03 21:07:00 UTC (rev 49062)
+++ trunk/Master/texmf-dist/doc/latex/keyvaltable/README.md 2018-11-03 21:07:14 UTC (rev 49063)
@@ -1,7 +1,7 @@
The keyvaltable Package
=======================
-Copyright (C) 2016 Richard Gay
+Copyright (C) 2016-2018 Richard Grewe
Released under the [LaTeX Project Public License](http://www.latex-project.org/lppl/) version 1.2 or later
Modified: trunk/Master/texmf-dist/doc/latex/keyvaltable/keyvaltable.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/keyvaltable/keyvaltable.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/keyvaltable/keyvaltable.dtx 2018-11-03 21:07:00 UTC (rev 49062)
+++ trunk/Master/texmf-dist/source/latex/keyvaltable/keyvaltable.dtx 2018-11-03 21:07:14 UTC (rev 49063)
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2016 by Richard Gay <gay at mais.informatik.tu-darmstadt.de>
+% Copyright (C) 2016-2018 by Richard Grewe <r-g+tex at posteo.net>
% -------------------------------------------------------
%
% This file may be distributed and/or modified under the
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{keyvaltable}
%<*package>
- [2016/05/22 v0.2 Package for filling tables using key-value lists]
+ [2018/11/01 v0.3b Package for filling tables using key-value lists]
%</package>
%
%<*driver>
@@ -54,7 +54,10 @@
% and ref mechanism is otherwise disabled.
\newcommand\FakeRefs{%
\def\ref##1{\csuse{fakelabel@##1}}%
- \def\label##1{\global\csletcs{fakelabel@##1}{@currentlabel}}%
+ \def\cref##1{\csuse{cref@\csuse{fakelname@##1}@name}\ \ref{##1}}%
+ \renewcommand\label[2][]{%
+ \csgdef{fakelname@##2}{##1}%
+ \global\csletcs{fakelabel@##2}{@currentlabel}}%
\let\marginpar=\origmarginpar
}
\let\origmarginpar=\marginpar
@@ -64,6 +67,7 @@
\CodelineIndex
\RecordChanges
% the following packages are for the examples
+\usepackage{cleveref}
\usepackage{xintexpr}
\usepackage{makecell}
\begin{document}
@@ -93,6 +97,7 @@
% Right brace \} Tilde \~}
%
% \changes{v0.1}{2016/03/13}{Initial version}
+% \changes{v0.3b}{2018/11/01}{Package author's name change}
%
% \GetFileInfo{keyvaltable.dtx}
%
@@ -104,7 +109,7 @@
% The package is available online at
% \url{http://www.ctan.org/pkg/keyvaltable} and
% \url{https://github.com/Ri-Ga/keyvaltable}.}}
-% \author{Richard Gay \\ \texttt{gay at mais.informatik.tu-darmstadt.de}}
+% \author{Richard Grewe \\ \texttt{r-g+tex at posteo.net}}
%
% \maketitle
%
@@ -246,6 +251,22 @@
% must then be a comma-separated list of \meta{property}|=|\meta{value}
% pairs. The following \meta{property} names are available:
% \begin{description}\label{page:table-options}
+% \item[|shape|:]
+% This property specifies the table's shape. For \meta{value}, the
+% package currently supports |multipage| (the default) and |onepage|.
+% In case of |multipage|, the table may span multiple pages and on
+% each page, the column header is repeated. In case of |onepage|, the
+% table does not split into multiple pages.
+% \item[|showhead|:]
+% This property specifies whether the head row shall be shown. The
+% \meta{value} must be a Boolean (i.e., |true| or |false|), where
+% |true| (the default) specifies that the head row is shown and
+% |false| specifies that the head row is not shown.
+% \item[|headbg|:]
+% This property specifies the background color of the head row. The
+% \meta{value} must be a single color specification that is understood
+% by the \textsf{xcolor} package.\footnote{The \meta{value} is passed
+% directly to the \cs{rowcolor} macro.} The default is |black!14|.
% \item[|rowbg|:]
% This property specifies the background colors of content rows. The
% format of the \meta{value} for this property must be
@@ -253,19 +274,27 @@
% passed directly to \cs{taburowcolors} of the \textsf{tabu} package.}
% The default is |white..black!10|, i.e., alternatingly white and light
% very gray.
-% \item[|headbg|:]
-% This property specifies the background color of the head row. The
-% \meta{value} must be a single color specification that is understood
-% by the \textsf{xcolor} package.\footnote{The \meta{value} is passed
-% directly to the \cs{rowcolor} macro.} The default is |black!14|.
-% \item[|shape|:]
-% This property specifies the table's shape. For \meta{value}, the
-% package currently supports |multipage| (the default) and |onepage|.
-% In case of |multipage|, the table may span multiple pages and on
-% each page, the column header is repeated. In case of |onepage|, the
-% table does not split into multiple pages.
% \end{description}
+% The following example shows the \meta{options} in action.
+% \begin{LTXexample}
+% \NewKeyValTable[shape=onepage,
+% showhead=false, headbg=blue!25,
+% rowbg=blue!10..blue!15,
+% ]{TabOptions}{
+% opt: align=l, format=\texttt;
+% val: align=l, format=\texttt;}
+% \begin{table}\centering
+% \begin{KeyValTable}{TabOptions}
+% \Row{opt=shape, val=onepage}
+% \Row{opt=showhead, val=false}
+% \Row{opt=headbg, val=blue!25}%invisible
+% \Row{opt=rowbg, val=blue!10..blue!15}
+% \end{KeyValTable}
+% \caption{table options demo}
+% \end{table}
+% \end{LTXexample}
%
+%
% \NiceDescribeMacro{\Row}{\marg{content}}
% A table row is produced by the |\Row| macro. The
% \meta{content} must be a comma-separated list of
@@ -386,7 +415,7 @@
% used for this purpose.
% \begin{LTXexample}[preset=\FakeRefs]
% \NewKeyValTable{Labeled}{
-% label: align=r, head=\#,
+% label: align=r, head=\textbf{\#},
% format=\kvtLabel{kvtRow};
% text: align=l, head=\textbf{Text}}
% \begin{KeyValTable}{Labeled}
@@ -395,7 +424,7 @@
% \end{KeyValTable}
% \end{LTXexample}
%
-% \NiceDescribeMacro{\kvtLabel}{\marg{counter}\marg{label}}
+% \NiceDescribeMacro{\kvtLabel}{\oarg{labelopts}\marg{counter}\marg{label}}
% The |\kvtLabel| macro shows the current value of the \meta{counter} --
% in particular |kvtRow|, |kvtTypeRow|, and |kvtTotalRow| -- and sets
% the \meta{label} to the value of \meta{counter}. When using the macro
@@ -403,8 +432,38 @@
% must be provided, as the above example shows. The second argument
% (\meta{label}) is provided by the respective cell content.
%
+% The |\kvtLabel| macro should work well with packages that change the
+% referencing, like \textsf{cleveref} or \textsf{varioref}. When using a
+% package that add an optional argument to the |\label| command (like
+% \textsf{cleveref} does), the \meta{labelopts} can be used to pass an
+% optional argument to |\label|. This feature is demonstrated in
+% \cref{sec:package-cleveref}.
+%
+%
% \section{Use with Other Packages}
%
+% \subsection{Named References}\label{sec:package-cleveref}
+%
+% The |\kvtLabel| feature of the \textsf{keyvaltable} package can be
+% used together with named references, as provided by the
+% \textsf{cleveref} package. A name to a row label can be given by using
+% the optional first argument to the |\kvtLabel| formatting macro and
+% specifying the name to use using |\crefname|. The following example
+% uses ``row'' for the optional argument and ``line'' for the displayed
+% name of the reference.
+% \begin{LTXexample}[preset=\FakeRefs]
+% \usepackage{cleveref}
+% \crefname{row}{line}{lines}
+% \NewKeyValTable{NamedRef}{
+% label: align=r, head=\textbf{Line},
+% format=\kvtLabel[row]{kvtRow};
+% text: align=l, head=\textbf{Text}}
+% \begin{KeyValTable}{NamedRef}
+% \Row{text=First row, label=one}
+% \Row{text=After \cref{one}}
+% \end{KeyValTable}
+% \end{LTXexample}
+%
% \subsection{Computational Cells}
%
% The mechanism of cell formatting macros enables a simple means for
@@ -568,6 +627,21 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\kvt at addbooltableprop}
+% The |\kvt at addbooltableprop|\marg{name}\marg{default}
+% macro adds a new table option, named \meta{name} and with default
+% value \meta{default} and possible values being booleans (|true|,
+% |false|).
+% \begin{macrocode}
+\newcommand\kvt at addbooltableprop[2]{%
+ \define at boolkey[kvt]{defaults}{#1}{%
+ \kvt at lazypreset{Table}{#1=##1}}%
+ \presetkeys[kvt]{defaults}{#1=#2}{}%
+ \define at boolkey[kvt]{Table}{#1}%
+ {\csdef{cmdkvt at Table@#1}{##1}}%
+ \presetkeys[kvt]{Table}{#1=#2}{}}
+% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{\kvt at addcolumnprop}
% The |\kvt at addcolumnprop|\marg{name}\marg{default} macro adds a new
@@ -626,6 +700,7 @@
% \begin{macrocode}
\kvt at addtableprop{rowbg}{white..black!10}
\kvt at addtableprop{headbg}{black!14}
+\kvt at addbooltableprop{showhead}{true}
\kvt at addchoicetableprop{shape}{multipage}{multipage,onepage}
\kvt at addcolumnprop{default}{}
\kvt at addcolumnprop{format}{\kvt at struttedcell}
@@ -640,8 +715,9 @@
% the argument \meta{arg} with a |\strut|. When used for formatting
% cell content, this makes sure that there is some vertical space
% between the content of a cell and the top and bottom of the row.
+% \changes{v0.3}{2016/06/06}{Fix for cells with vertical material}
% \begin{macrocode}
-\newcommand\kvt at struttedcell[1]{\strut #1\strut}
+\newcommand\kvt at struttedcell[1]{\strut #1\ifhmode\expandafter\strut\fi}
% \end{macrocode}
% \end{macro}
%
@@ -749,26 +825,37 @@
% \end{macro}
%
% \begin{macro}{\kvtLabel}
-% The |\kvtLabel|\marg{counter}\marg{label} macro sets a label, named
-% \meta{label}, for the current value of the \LaTeX{} counter named
-% \meta{counter}.
+% The |\kvtLabel|\oarg{labelopts}\marg{counter}\marg{label} macro sets
+% a label, named \meta{label}, for the current value of the \LaTeX{}
+% counter named \meta{counter}.
% \changes{v0.2}{2016/05/22}{Added macro for row labeling}
+% \changes{v0.3}{2016/06/09}{Robustified for use with, e.g., \textsf{cleveref}}
% \begin{macrocode}
-\newcommand\kvtLabel[2]{%
+\newcommand\kvtLabel[3][]{%
% \end{macrocode}
% The following imitates a |\refstepcounter| in the sense of setting the
-% current label, but it does not touch the \meta{counter}.
+% current label, but it does not touch the \meta{counter} (in case
+% someone added some custom hooks to them).
% \begin{macrocode}
- \protected at edef\@currentlabel
- {\csname p@#1\endcsname\csname the#1\endcsname}%
+ \setcounter{kvt at LabelCtr}{\csname the#2\endcsname}%
+ \addtocounter{kvt at LabelCtr}{-1}%
+ \refstepcounter{kvt at LabelCtr}%
% \end{macrocode}
% Next, define the \meta{label} (if provided) and show the value of
% \meta{counter}.
% \begin{macrocode}
- \ifstrempty{#2}{}{\label{#2}}%
- \csuse{the#1}}
+ \ifstrempty{#3}{}{%
+ \ifstrempty{#1}{\label{#3}}{\label[#1]{#3}}}%
+ \csuse{the#2}}
% \end{macrocode}
% \end{macro}
+% \begin{macro}{kvt at LabelCtr}
+% The |kvt at LabelCtr| counter is an auxiliary counter for setting labels,
+% used by |\kvtLabel|.
+% \begin{macrocode}
+\newcounter{kvt at LabelCtr}
+% \end{macrocode}
+% \end{macro}
%
% \subsection{Key-Value Table Content}
%
@@ -828,15 +915,17 @@
% \end{macrocode}
% The |\kvt@@recenttable| allows the |\AfterEndEnvironment| hook for
% |KeyValTable| to access the most recent table type.
+% \changes{v0.3}{2016/06/05}{Added \texttt{showhead} option}
% \begin{macrocode}
\gdef\kvt@@recenttable{#2}%
\bgroup\edef\kvt@@do{\egroup
- \noexpand\taburowcolors[2] 2{\cmdkvt at Table@rowbg}%
\noexpand\begin{#1}{\csuse{kvt at alignments@#2}}%
\noexpand\toprule
- \noexpand\rowcolor{\cmdkvt at Table@headbg}%
+ \ifbool{kvt at Table@showhead}{%
+ \noexpand\rowcolor{\cmdkvt at Table@headbg}%
+ \unexpanded{\csuse{kvt at headings@#2}\\\midrule}}{}%
+ \noexpand\taburowcolors 2{\cmdkvt at Table@rowbg}%
}\kvt@@do%
- \csuse{kvt at headings@#2}\\\midrule
\iftabu at long\expandafter\endhead\fi
\setcounter{kvtRow}{1}%
\setcounter{kvtTypeRow}{\csuse{kvt at rowcount@#2}}%
Modified: trunk/Master/texmf-dist/source/latex/keyvaltable/keyvaltable.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/keyvaltable/keyvaltable.ins 2018-11-03 21:07:00 UTC (rev 49062)
+++ trunk/Master/texmf-dist/source/latex/keyvaltable/keyvaltable.ins 2018-11-03 21:07:14 UTC (rev 49063)
@@ -1,5 +1,5 @@
%%
-%% Copyright (C) 2016 by Richard Gay <gay at mais.informatik.tu-darmstadt.de>
+%% Copyright (C) 2016-2018 by Richard Grewe <r-g+tex at 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
@@ -17,7 +17,7 @@
\usedir{tex/latex/keyvaltable}
\preamble
-Copyright (C) 2016 by Richard Gay <gay at mais.informatik.tu-darmstadt.de>
+Copyright (C) 2016-2018 by Richard Grewe <r-g+tex at 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
Modified: trunk/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty 2018-11-03 21:07:00 UTC (rev 49062)
+++ trunk/Master/texmf-dist/tex/latex/keyvaltable/keyvaltable.sty 2018-11-03 21:07:14 UTC (rev 49063)
@@ -6,7 +6,7 @@
%%
%% keyvaltable.dtx (with options: `package')
%%
-%% Copyright (C) 2016 by Richard Gay <gay at mais.informatik.tu-darmstadt.de>
+%% Copyright (C) 2016-2018 by Richard Grewe <r-g+tex at 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
@@ -20,7 +20,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{keyvaltable}
- [2016/05/22 v0.2 Package for filling tables using key-value lists]
+ [2018/11/01 v0.3b Package for filling tables using key-value lists]
\RequirePackage{etoolbox}
\RequirePackage{xkeyval}
\RequirePackage[table]{xcolor}
@@ -46,6 +46,13 @@
\define at choicekey[kvt]{Table}{#1}{#3}%
{\csdef{cmdkvt at Table@#1}{##1}}%
\presetkeys[kvt]{Table}{#1=#2}{}}
+\newcommand\kvt at addbooltableprop[2]{%
+ \define at boolkey[kvt]{defaults}{#1}{%
+ \kvt at lazypreset{Table}{#1=##1}}%
+ \presetkeys[kvt]{defaults}{#1=#2}{}%
+ \define at boolkey[kvt]{Table}{#1}%
+ {\csdef{cmdkvt at Table@#1}{##1}}%
+ \presetkeys[kvt]{Table}{#1=#2}{}}
\newcommand\kvt at addcolumnprop[2]{%
\define at key[kvt]{defaults}{#1}{%
\kvt at lazypreset{Column}{#1=##1}}%
@@ -64,6 +71,7 @@
}
\kvt at addtableprop{rowbg}{white..black!10}
\kvt at addtableprop{headbg}{black!14}
+\kvt at addbooltableprop{showhead}{true}
\kvt at addchoicetableprop{shape}{multipage}{multipage,onepage}
\kvt at addcolumnprop{default}{}
\kvt at addcolumnprop{format}{\kvt at struttedcell}
@@ -71,7 +79,7 @@
\kvt at addcolumnprop{head}{}
\kvt at addchoicecolumnprop{hidden}{false}{false,true}
\kvtSet{}
-\newcommand\kvt at struttedcell[1]{\strut #1\strut}
+\newcommand\kvt at struttedcell[1]{\strut #1\ifhmode\expandafter\strut\fi}
\newcommand\NewKeyValTable[3][]{%
\csdef{kvt at options@#2}{#1}%
\csdef{kvt at headings@#2}{}%
@@ -103,11 +111,14 @@
\newcounter{kvtTypeRow}
\newcounter{kvtTotalRow}
\setcounter{kvtTotalRow}{1}
-\newcommand\kvtLabel[2]{%
- \protected at edef\@currentlabel
- {\csname p@#1\endcsname\csname the#1\endcsname}%
- \ifstrempty{#2}{}{\label{#2}}%
- \csuse{the#1}}
+\newcommand\kvtLabel[3][]{%
+ \setcounter{kvt at LabelCtr}{\csname the#2\endcsname}%
+ \addtocounter{kvt at LabelCtr}{-1}%
+ \refstepcounter{kvt at LabelCtr}%
+ \ifstrempty{#3}{}{%
+ \ifstrempty{#1}{\label{#3}}{\label[#1]{#3}}}%
+ \csuse{the#2}}
+\newcounter{kvt at LabelCtr}
\newenvironment{KeyValTable}[2][]{%
\bgroup%
\def\Row##1{\kvt at AddKeyValRow{#2}{##1}\kvt@@row\\}%
@@ -130,12 +141,13 @@
\newcommand\kvt at StartTabu[2]{%
\gdef\kvt@@recenttable{#2}%
\bgroup\edef\kvt@@do{\egroup
- \noexpand\taburowcolors[2] 2{\cmdkvt at Table@rowbg}%
\noexpand\begin{#1}{\csuse{kvt at alignments@#2}}%
\noexpand\toprule
- \noexpand\rowcolor{\cmdkvt at Table@headbg}%
+ \ifbool{kvt at Table@showhead}{%
+ \noexpand\rowcolor{\cmdkvt at Table@headbg}%
+ \unexpanded{\csuse{kvt at headings@#2}\\\midrule}}{}%
+ \noexpand\taburowcolors 2{\cmdkvt at Table@rowbg}%
}\kvt@@do%
- \csuse{kvt at headings@#2}\\\midrule
\iftabu at long\expandafter\endhead\fi
\setcounter{kvtRow}{1}%
\setcounter{kvtTypeRow}{\csuse{kvt at rowcount@#2}}%
More information about the tex-live-commits
mailing list