这是一个 mwe
\documentclass{article}
\ExplSyntaxOn
\cs_new:Nn \en_direct: { beginning }
\keys_define:nn { test }
{
direct .bool_set:N = \test_direct_bool,
indirect .bool_set_inverse:N = \test_direct_bool,
direct .initial:n = {true},
direct .default:n = {true},
direct .code:n = {
\bool_if:nTF {\test_direct_bool}
{\cs_set:Nn \en_direct: { DIRECT }}
{\cs_set:Nn \en_direct: { INDIRECT }}
},
indirect .initial:n = {false},
indirect .default:n = {true},
indirect .code:n = {
\bool_if:nTF {\test_direct_bool}
{\cs_set:Nn \en_direct: { DIRECT }}
{\cs_set:Nn \en_direct: { INDIRECT }}
}
}
\NewDocumentCommand{\seekey}{ m }{
\bool_if:nTF {\use:c{test_#1_bool}} {key~#1~is~true} {key~#1~is~false}
\qquad [\en_direct:]\par\noindent\hrulefill\par
}
\NewDocumentCommand{\valuekey}{m}
{
\keys_set:nn { test }{ #1 } The~key~\textbf{#1}~has~been~set~to~TRUE.\par
}
\ExplSyntaxOff
\begin{document}
\seekey{direct}
\valuekey{direct} \seekey{direct}
\valuekey{indirect} \seekey{direct}
\end{document}
我期望最后一位给出“key direct is false”和“INDIRECT”作为值,\en_direct:
但事实并非如此。
我对以下 expl3 文档中的内容有什么遗漏或误解:
key .bool_set_inverse:N = boolean
定义
key
为设置boolean
为的逻辑逆value
(必须为真或假)。