Closed lvjr closed 3 weeks ago
Now I think it is an elegant solution to apply \evalWhole
to the second argument of every \keys_set:nn
command beforehand. With this solution you can also use functions from functional
packages or (defined a new one with \prgNewFunction
) in the key:
\someFunc{aaa} = \otherFunc{bbb}
where \someFunc
returns a key name, and \otherFunc
returns its value.
Also issue #207 can be solved by making a function return both key name and its value.
But we need to keep evaluate
and process
options safe in making this change.
Finally I added keyvalue
library to tabularray
. And here is an example.
\documentclass[b5paper]{article}
\usepackage{tabularray}
\usepackage{ninecolors}
\UseTblrLibrary{keyvalue}
\begin{document}
\begin{tblr}{
row{3} = {bg=\intIfOddTF{\value{page}}{\prgReturn{red7}}{\prgReturn{blue7}}}
}
Alpha & Beta & Gamma \\
Epsilon & Zeta & Eta \\
Iota & Kappa & Lambda \\
Alpha & Beta & Gamma \\
Epsilon & Zeta & Eta \\
Iota & Kappa & Lambda \\
\end{tblr}
\newpage
\begin{tblr}{
row{3} = {bg = \intIfOddTF{\value{page}}{\prgReturn{red7}}{\prgReturn{blue7}}}
}
Alpha & Beta & Gamma \\
Epsilon & Zeta & Eta \\
Iota & Kappa & Lambda \\
Alpha & Beta & Gamma \\
Epsilon & Zeta & Eta \\
Iota & Kappa & Lambda \\
\end{tblr}
\end{document}
In the above commit, I have merged keyvalue
library into functional
library, because writing functions in row{i}
values is the same as writing them in \SetRow
commands.
\documentclass{article}
\usepackage{tabularray}
\usepackage{ninecolors}
\UseTblrLibrary{functional}
\begin{document}
\begin{tblr}{
hlines,
row{2} = {bg=\intIfOddTF{\value{page}}{\prgReturn{red7}}{\prgReturn{blue7}}},
}
Alpha & Beta & Gamma \\
Epsilon & Zeta & Eta \\
Iota & Kappa & Lambda \\
\end{tblr}
\begin{tblr}[evaluate=all]{hlines}
Alpha & Beta & Gamma \\
\SetRow{bg=\intIfOddTF{\value{page}}{\prgReturn{red7}}{\prgReturn{blue7}}}
Epsilon & Zeta & Eta \\
Iota & Kappa & Lambda \\
\end{tblr}
\end{document}
From https://tex.stackexchange.com/questions/648786/how-to-define-new-key-properties-in-l3keys
Recently I found
tcolorbox
has an interestingIfEmptyTF
key, with which you can writeAnd I decided
tabularray
should have a similar feature, and can make the interface more natural and more powerful to users:where
\tlIfEmptyTF
function is fromfunctional
package. That is to say, users can use all functions infunctional
package in the values andtabularray
should replace them with their return values. And this feature should only be enabled iffunctional
library is load by users.