# Why \numrange{number}{number} and \SIrange{number}{number}{unit} doesn't work as expected in math mode?

See the code:

\documentclass{scrartcl}
\usepackage[per-mode = fraction]{siunitx}
\begin{document}
Text. \numrange{1}{3} experiments.\\[\baselineskip]
Text. \SIrange{1}{5}{\kg} text.\\[\baselineskip]
Text. $k = \numrange{1}{3}$ experiments text.\\[\baselineskip]
Text. $v = \SIrange{1}{5}{\cubic\m\per\kg}$ text.\\[\baselineskip]
\end{document}


And the result:

In text mode it works properly. But in math mode there is no space before and after to and it has italic shape. Why is it so? What do I wrong?

The commands \SIrange and \numrange are implemented such that they can only be used reliably in text mode: this relates to handling spaces if a line break occurs within the output of the commands. As such, they behaviour in math mode is undefined. (I am working on a new implementation of all of siunitx and this is one area to examine. At present I cannot be sure of whether v3 will be able to offer better outcomes here.)

\documentclass{scrartcl}
\usepackage[per-mode = fraction]{siunitx}
\sisetup{mode=text,range-phrase = {\text{~to~}}}
\begin{document}
Text. \numrange{1}{3} experiments.\\[\baselineskip]
Text. \SIrange{1}{5}{\kg} text.\\[\baselineskip]
Text. $k = \numrange{1}{3}$ experiments text.\\[\baselineskip]
Text. $v = \SIrange{1}{5}{\cubic\m\per\kg}$ text.\\[\baselineskip]
\end{document}

• The disadvantage of this approach is, that the ranges in text mode become unbreakable and can cause overfull lines. Maybe \text{\space to~} instead? Apr 5 '17 at 10:52
• Hello @Joseph Wright and @Sebastiano! Thank you for your answers! Maybe it is better to do it locally: $k = \numrange[range-phrase = {\text{\ to\ }}]{1}{3}$ and $v = \SIrange[range-phrase = {\text{\ to\ }}]{1}{5}{\cubic\m\per\kg}$? Another woraround: $k =$ \numrange[range-phrase = {\text{\ to\ }}]{1}{3} and $v =$ \SIrange{1}{5}{\cubic\m\per\kg}. But both aren't good solutions. Apr 5 '17 at 16:19
• @Su-47 Holà. I hoped that suited my answer. I done my best. Apr 5 '17 at 17:23