The LaTeX build breaks because of Argument of \currency has extra }. This is strange since the output is (should be) the same as with \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}
The code breaks but runs if you comment the lines with the comment breaks???
P.S.: Because I shortened the code to create an MWE some functions seem to be unneccessarily split into two different functions. This is needed for the real code.
[]arguments. What exactly are you trying to do in that column? It compiles it you protect it using{...}– daleif May 09 '23 at 15:23\usepackage{tgheros}? If not, why is it in the example? – David Carlisle May 09 '23 at 16:11{}around the command. It indeed prevents crashing. However, the numbers are not aligned with the decimal point. Also I do not understand why it works with\EURsimplethis is also a command and should result in the same output. But it only works with that command but not\currency[noseparator]... – mrCarnivore May 09 '23 at 17:17\protectedso as documented, does not expand – David Carlisle May 09 '23 at 17:27\currencycommand? Define it as\cs_new:Nn? That also does not work. BTW: \currency[noseparator]also shows the wrong decimal point. There are so many things different to the\EURsimple` command... – mrCarnivore May 09 '23 at 17:32