某些选项未返回参数

某些选项未返回参数

当使用 a 的一个选项时,返回的字符串\str_casenoseperator空。我不明白为什么...

\documentclass{article}

\RequirePackage{booktabs}

\usepackage[mode=text, reset-text-series = false, separate-uncertainty, group-digits=integer, group-minimum-digits = 4]{siunitx}

\sisetup{group-separator = {\,}, input-decimal-markers={,.}, output-decimal-marker = {,}}

\ExplSyntaxOn

\str_new:N \g__eur_length_str

\NewDocumentCommand{\setcurrencyformat}{m}
{
    \str_gset:Nn \g__eur_length_str { #1 }
}

\NewDocumentCommand{\EUR}{om}
{
    \currency_print_value:nnn { #1 } { #2 } { € }
}

\NewDocumentCommand{\currency}{om}
{
    \currency_print_value:nnn { #1 } { #2 } { }
}


\cs_new_protected:Nn \currency_print_value:nnn
{
    \IfNoValueTF{#1}
    {% no optional argument
        \currency_print:Vnn \g__eur_length_str { #2 } { #3 }
    }
    {% optional argument present
        \currency_print:nnn { #1 } { #2 } { #3 }
    }
}

\tl_new:N \l__currency_temp_tl

\cs_new_protected:Nn \currency_print:nnn
{
    \str_if_eq:nnTF {#3} { }
    { % empty
        \tl_set:Nn \l__currency_temp_tl {}
    }
    { % not empty
        \tl_set:Nn \l__currency_temp_tl { \nobreakspace \unit{#3} }
    }
    
    \str_case:nn { #1 }
    {
        { full }    { \num[group-separator = {.}, minimum-decimal-digits = 2]{#2} \tl_use:N \l__currency_temp_tl }
        { standard }{ \num[group-separator = {.}, round-mode = places, round-precision = 2]{#2} \tl_use:N \l__currency_temp_tl }     
        { min }     { \num[group-separator = {.}, round-mode = places, round-precision = 0]{#2} \tl_use:N \l__currency_temp_tl }
        { noseperator }  { #2 \tl_use:N \l__currency_temp_tl }  % <= returns nothing
    }
}
\cs_generate_variant:Nn \currency_print:nnn { V }

\setcurrencyformat{full}

\ExplSyntaxOff

\begin{document}
    
        \currency[noseparator]{123.45678} (currency[noseparator])  % <= returns nothing
        
        \EUR[noseparator]{123.45678} (EUR[noseparator]) % <= returns nothing
        
        \currency{123.45678} (currency)     
        
        \currency[full]{123.45678} (currency[full]) 
        
\end{document}

答案1

noseperator 不是noseparator

相关内容