由于 ,LaTeX 构建中断。这很奇怪,因为输出(应该)与...Argument of \currency has extra }
相同\EURsimple
\documentclass{article}
\usepackage[mode=text, group-digits=integer, group-minimum-digits = 4]{siunitx}
\sisetup{group-separator = {\,}, input-decimal-markers={,.}, output-decimal-marker = {,}}
\newcommand{\EURsimple}[1]
{%
#1%
}
\ExplSyntaxOn
\str_new:N \g__eur_length_str
\NewDocumentCommand{\setcurrencyformat}{m}
{
\str_gset:Nn \g__eur_length_str { #1 }
}
\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 }
{ noseparator } { #2 } %\tl_use:N \l__currency_temp_tl }
}
}
\cs_generate_variant:Nn \currency_print:nnn { V }
\setcurrencyformat{full}
\ExplSyntaxOff
\begin{document}
\EURsimple{1234.56789} (EURsimple)
\currency[noseparator]{1234.56789} (currency[noseparator])
\begin{tabular}
{
S[table-format=5.4]
}
{\textbf{Einzelpreis}} \\
1234.56789 \\
13.45 \\
\EURsimple{1234.56789} \\
\EURsimple{13.45}\\
\num{1234.56789} \\
\num{13.45} \\
\currency{1234.56789} \\
\currency{13.45} \\
\currency[noseparator]{1234.56789} \\ % <= breaks ??
\currency[noseparator]{13.45} \\ % <= breaks ??
\end{tabular}
\end{document}
代码会中断,但如果您用注释注释这些行,代码仍会运行breaks???
PS:由于我缩短了代码以创建 MWE,因此某些函数似乎不必要地拆分为两个不同的函数。这是实际代码所需要的。