我对 expl3 语法还不熟悉,无法让它正常工作。我想将已知键的值放入变量中,但保留未知对以供以后使用,例如在将几个不同的包函数合并为一个的文档命令中使用,我该怎么做?
最小(非)工作示例
\documentclass{article}
\usepackage{expl3,xparse}
\ExplSyntaxOn
% Declare
\tl_new:N \l__mymod_keyi_tl
\seq_new:N \l_mymod_keyvalue_seq
% Define
\keys_define:nn { mymod } {
keyi .tl_set:N = \l__mymod_keyi_tl,
otherKeys .code:n = \mymod_store:Vn \l_keys_key_tl {#1},
}
\cs_new_protected:Nn \mymod_store:nn {
\seq_put_right:Nn \l_mymod_keyvalue_seq {#1~=~{#2},}
}
\cs_generate_variant:Nn \mymod_store:nn { V }
% Setter
\NewDocumentCommand{\setkeys}{m} {
\keys_set:nn { mymod } { #1 }
}
% Getter i
\NewExpandableDocumentCommand\printkeyi{} {
\text_expand:n{
\l__mymod_keyi_tl
}
}
% Usage here
% \NewDocumentCommand{\fun}{m} {
% \fun1{ keyName = \text_expand:n {\l__mymod_keyi_tl} }
% \fun2{ \otherKeys or \printkeys or whatever} % keyi should NOT be among them
% }
% Getter rest
\NewExpandableDocumentCommand\printkeys{} {
\seq_use:Nn \l_mymod_keyvalue_seq {,~}
}
\ExplSyntaxOff
\begin{document}
A few words
\setkeys{keyi = 3, keyii = 4, keyiii = 5}
another few
\printkeys
\end{document}
这里
答案1
unknown 是一个关键字。