The LaTeX team have recently extended the keyval implementation in expl3 so
that it understands the idea of appending (or adding) to keyvals using the
syntax <key> += <value>.
A few packages on CTAN use expl3 for key definition and set up their own
methods for appending to keys, by creating a pair of keys <key> and <key>+.
We’ve continued to support those (with a few
wrinkles), but it’s now easy to
use the build-in abilities.
For most keys, programmers won’t need to do anything: anything that sets a tl,
clist, int, dim or skip variable will ‘just work’. For other keys, it’s
easy to add dedicated code with .append_method:n, which I’ve already done for
siunitx:
\keys_define:nn { siunitx }
{
input-uncertainty-signs .code:n =
{
\tl_set:Nn \l_@@_input_uncert_sign_tl {#1}
\tl_map_inline:nn {#1}
{
\tl_if_in:NnF \l_siunitx_number_input_sign_tl {##1}
{ \tl_put_right:Nn \l_siunitx_number_input_sign_tl {##1} }
}
}
}
...
\IfExplAtLeastTF { 2026-11-26 }
{
\keys_define:nn { siunitx }
{
input-uncertainty-signs .append_method:n =
{
\tl_put_right:Nn \l_@@_input_uncert_sign_tl {#1}
\tl_map_inline:nn {#1}
{
\tl_if_in:NnF \l_siunitx_number_input_sign_tl {##1}
{ \tl_put_right:Nn \l_siunitx_number_input_sign_tl {##1} }
}
}
}
}
{ }
I’m hoping that over the coming few months, most packages currently defining
their own += support will move over the new kernel support. Longer-term, it
would be easier to avoid needing to handle trailing + in key names as well as
for the extended syntax.
See also: Original Source by Joseph Wright
Note: The copyright belongs to the blog author and the blog. For the license, please see the linked original source blog.
Leave a Reply
You must be logged in to post a comment.