4

I like to print something like 10-20 cm using \SI option. I have tried \SI{10-20}{\cm} which is giving error. How to write it properly?

1
  • 3
    IIRC, the correct way of typesetting ranges according to the guidelines of the SI is to include the unit for both numbers, so instead of 10-20 cm you should use 10cm - 20cm.
    – Skillmon
    Oct 20 at 18:39
5

The correct command in recent versions of siunitx is \qtyrange:

\documentclass[border=3.14]{standalone}

\usepackage{siunitx}

\begin{document}
\qtyrange{10}{20}{\centi\metre}
\end{document}

This will result in

enter image description here

Just like in @Bernard's answer you can change the used phrase to an en-dash using range-phrase (for which I'd add non-breaking spaces using ~):

\documentclass[border=3.14]{standalone}

\usepackage{siunitx}

\begin{document}
\qtyrange[range-phrase=~--~]{10}{20}{\cm}
\end{document}

enter image description here

Problem: This looks like a minus and I'd say the result is -10 cm.

3
  • OK, \qtyrange{10}{20}{\centi\metre} is looking decent. Thank you.
    – Bukaida
    Oct 20 at 18:49
  • @Bukaida of course you don't have to type \centi\metre everytime, \cm will work just as fine (and siunitx is smart enough to also parse \qtyrange{10}{20}{cm} correctly, but I'd prefer using \cm if you have to be short).
    – Skillmon
    Oct 20 at 18:51
  • @Skillmon On the 'to do' list is to parse cm to \centi\metre to allow manipulation ;)
    – Joseph Wright
    Oct 20 at 19:00
5

Use \numrange[range-phrase=--]{10}{20}\,\unit{\cm}͵.

3
  • @Skillmon: You're right. I'll add it instantly. Thanks!
    – Bernard
    Oct 20 at 18:40
  • I've added code highlighting to your answer, hope you don't mind.
    – Skillmon
    Oct 20 at 18:41
  • Not at all. On my system, it didn't yield exactly the expected result for some reason.
    – Bernard
    Oct 20 at 18:43

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.