I try to create a command that shows the euro value. I want it to show different types (0 decimal digits, 2 decimal digits or all decimal digits) and have this set by a \seteurformat
command.
That works great (uncommented part of the code).
I also want to have to option to temporarily change the length just for one call of the command and therefore created a local variable but somehow the copying from the global to the local variable does not work and it stays empty which leads to nothing being displayed...
\documentclass{scrlttr2}
\usepackage[ngerman]{babel}
\RequirePackage[defaultsans, scale=0.9]{opensans}
\renewcommand\familydefault{\sfdefault}
\usepackage[detect-all, separate-uncertainty]{siunitx}
\sisetup{group-minimum-digits = 4, group-separator = {~}, locale=DE}
\ExplSyntaxOn
\str_new:N \g__eur_length_str
\NewDocumentCommand{\seteurformat}{m}
{
\str_gset:Nn \g__eur_length_str { #1 }
}
\str_new:N \l__eur_length_temp_str
\NewDocumentCommand{\EUR}{O{}m}
{
\str_if_empty:nTF { #1 }
{ % true
\str_set:Nn \l__eur_length_temp_str { \str_show:N \g__eur_length_str }
}
{ % false
\str_set:Nn \l__eur_length_temp_str { #1 }
}
\str_case:Vn \l__eur_length_temp_str
{
{full}{\num[group-separator = {.}, minimum-decimal-digits=2]{#2} \nobreakspace \unit{€}}
{standard}{\num[group-separator = {.},round-mode = places, round-precision = 2]{#2} \nobreakspace \unit{€}}
{min}{\num[group-separator = {.}, round-mode = places, round-precision = 0]{#2} \nobreakspace \unit{€}}
}
% this part works but then I lose the option to temporarily change the length with #1
% \str_case:Vn \g__eur_length_str
% {
% {full}{\num[group-separator = {.}, minimum-decimal-digits=2]{#2} \nobreakspace \unit{€}}
% {standard}{\num[group-separator = {.},round-mode = places, round-precision = 2]{#2} \nobreakspace \unit{€}}
% {min}{\num[group-separator = {.}, round-mode = places, round-precision = 0]{#2} \nobreakspace \unit{€}}
% }
}
\ExplSyntaxOff
\begin{document}
\seteurformat{full}
\EUR{456}
\seteurformat{min}
\EUR{456}
\EUR[full]{456}
\EUR{456}
\EUR[min]{456}
\EUR{456}
\end{document}
_eq
version, ie\let
not\def