![`\bool_case` 的使用](https://linux22.com/image/470255/%60%5Cbool_case%60%20%E7%9A%84%E4%BD%BF%E7%94%A8.png)
我如何使用\bool_case
?
在以下示例中,我使用了\int_compare
和\int_case
。这里两者都被注释掉,并且按预期工作。
我正在尝试使用\bool_case
它来实现相同的目的。但是我得到了一个Undefined control sequence
错误(见下文)。
\documentclass[]{article}
\ExplSyntaxOn
\NewDocumentCommand \mycommand { m }
{
\seq_new:N \myseq
\seq_set_from_clist:Nn \myseq { #1 }
\seq_map_indexed_function:NN \myseq \myfunction:nn
}
\cs_new:Nn \myfunction:nn
{
% \int_compare:nT { #1 > 1 } { > } #2
% \int_case:nnF { #1 }
% {
% { 1 }{ #2 }
% }
% { > #2 }
\bool_case:nF{
{\int_compare_p:n {#1 = 1}}{ #2 }
}
{ > #2 }
}
\ExplSyntaxOff
\begin{document}
\mycommand{1,2,3}
\end{document}
$ xelatex test.tex
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-03-30>
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-xetex.def)
(./test.aux) (/usr/local/texlive/2023/texmf-dist/tex/latex/base/ts1cmr.fd)
! Undefined control sequence.
\myfunction:nn #1#2->\bool_case:nF
{{\int_compare_p:n {#1=1}}{#2}}{>#2}
l.29 \mycommand{1,2,3}
?