8

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!

0
10

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

0
8

enter image description 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}
3
  • 2
    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.
    – Su-47
    Apr 5 '17 at 16:19
  • @Su-47 Holà. I hoped that suited my answer. I done my best.
    – Sebastiano
    Apr 5 '17 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.