# Is there a more convenient way to represent (1,2+3,4) m with siunitx?

## Background:

• I want all decimal numbers in my TeX input file use . as the decimal separator.
• If my document is translated to German (for example), the . can be globally converted to , by locale option.
• Now consider if I want to output (1,2+3,4) m in the translated version but (1.2+3,4) m in the original version.
• Using $\num{1.2}+\num{3.4}$\si{\m}$ produces an output with incorrect spacing between the ) and m. • Using $\SI{(1.2+3.4)}{\m}$ throws an error. • Using $\SI[parse-numbers=false]{(1.2+3.4)}{\m}$ will ignore locale=DE option so the output will use . rather than ,. • Using $\SI[parse-numbers=false]{(1{,}2+3{,}4)}{\m}$ will make my translator unhappy. ## MWE: \documentclass[preview,border=12pt,varwidth]{standalone} \usepackage{amsmath} \usepackage[locale=DE]{siunitx} \def\x{1.23} \def\y{4.56} \def\X{1{,}23} \def\Y{4{,}56} \begin{document}$\!
\begin{aligned}[t]
L &= \SI{\x}{\m} + \SI{\y}{\m}\\
&= (\num{\x}+\num{\y})\si{\m}
\end{aligned}
\!
\begin{aligned}[t]
L &= \SI{\x}{\m} + \SI{\y}{\m}\\
&= \SI[parse-numbers=false]{(\x+\y)}{\m}
\end{aligned}
\!
\begin{aligned}[t]
L &= \SI{\x}{\m} + \SI{\y}{\m}\\
&= \SI[parse-numbers=false]{(\X+\Y)}{\m}
\end{aligned}
\end{document}


## Output

-
(1) Maybe the line (\parse@numbers#2\parse@stop)% should be replaced by \left(\parse@numbers#2\parse@stop\right)%. (2) How do I change the spacing between the number and unit from \  to \,? – Svend Tveskæg Apr 29 '13 at 0:52
@SvendTveskæg (1) Not really, as \left and \right) might produce too big delimiters. I added the functionality of \DeclarePairedDelimiter from the mathtools package. A \SIany* forwards the * to the delimiter, as well the optional () argument does. (The examples do hopefully make this clear.) [Note that siunitx has some form of bracket/parentheses functionality with lists and ranges, which could be extended to these delimiters, too.] (2) The default spacing is \, and can be set by the mentioned inter-unit-product option of siunitx. – Qrrbrbirlbel Apr 29 '13 at 2:09
(1) Good point. (2) Hmmm. It just looks like \  to me, but it is nice if it isn't. – Svend Tveskæg Apr 29 '13 at 2:13
@SvendTveskæg (1) I have introduced a new siunitx key instead of that weird first optional argument of \SIany: The any key! (2) Compare: \documentclass{article}\usepackage{siunitx}\begin{document}\ExplSyntaxOn\fbox{\‌​l__siunitx_unit_product_tl}\par\fbox{\,}\end{document}. It’s the same spacing as around +, - or \times (a thin one). – Qrrbrbirlbel Apr 29 '13 at 2:39
This is really great. Good job! – Svend Tveskæg Apr 29 '13 at 2:40