I'm trying to combine the \num and \SI command of siunitx and change the order of the arguments. In particular, what I want to achieve is a new command \Zahl[siunitx-options]<pre-unit>{number}[measure] where everything but number is optional.
The MWE below achieves my objective by copying siunitx internals, which is a bad idea. In particular, I create a new Npn "jorg" based in \SI that changes the order of the original SI command and define \Zahl accordingly. Is there a more consistent and reliable way to achieve the same?
\documentclass{scrartcl}
\usepackage{siunitx,xparse,expl3}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\ExplSyntaxOn
% Create \Zahl based on siunitx' \num and \SI
% The syntax is then \Zahl[siunitx-options]<pre-unit>{number}[measure]
\cs_new_protected:Npn \__siunitx_jorg:nnnn #1#2#3#4 {
\IfNoValueTF {#2}
{ \tl_clear:N \l__siunitx_pre_unit_tl }
{
\group_begin:
\__siunitx_unit_in:nn {#2} {#1}
\cs_set_eq:NN \l__siunitx_pre_unit_tl \l__siunitx_unit_tl
\exp_args:NNNo \group_end:
\tl_set:Nn \l__siunitx_pre_unit_tl { \l__siunitx_unit_tl }
}
\cs_set_eq:NN \l__siunitx_brackets_bool
\l__siunitx_multi_brackets_bool
\__siunitx_combined_unit:nnn {#3} {#4} {#1}
\__siunitx_combined_output:n {#3}
}
\NewDocumentCommand\Zahl{o D<>{} m O{}}%
{
\leavevmode
\group_begin:
\IfNoValueTF {#1}
{ \__siunitx_jorg:nnnn { } {#2} {#3} {#4} }
{
\keys_set:nn { siunitx } {#1}
\__siunitx_jorg:nnnn {#1} {#2} {#3} {#4}
}
\group_end:
}
\ExplSyntaxOff
\DeclareSIUnit\%{\char37}
\begin{document}
\Zahl{200}
\Zahl{200}[\percent]
\Zahl<£>{200}
\Zahl<£>{200}[\percent]
\Zahl[round-mode=figures,round-precision=3]<£>{200.7}[\percent]
\end{document}