[Tex/LaTex] Why \numrange{number}{number} and \SIrange{number}{number}{unit} doesn’t work as expected in math mode

siunitx

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:

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?

Thank you for your help and effort in advance!

Best Answer

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.)