6

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?

2
  • 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, 2021 at 18:39
  • 10 cm to 20 cm. BIPM says: The numerical value always precedes the unit and a space is always used to separate the unit from the number. Thus the value of the quantity is the product of the number and the unit. The space between the number and the unit is regarded as a multiplication sign (just as a space between units implies multiplication). The only exceptions to this rule are for the unit symbols for degree, minute and second for plane angle, °, ′ and ″, respectively, for which no space is left between the numerical value and the unit symbol. www.bipm.org/en/publications/si-brochure/
    – D Duck
    Jan 16 at 12:18

2 Answers 2

8

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.

4
  • OK, \qtyrange{10}{20}{\centi\metre} is looking decent. Thank you.
    – Bukaida
    Oct 20, 2021 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, 2021 at 18:51
  • @Skillmon On the 'to do' list is to parse cm to \centi\metre to allow manipulation ;)
    – Joseph Wright
    Oct 20, 2021 at 19:00
  • Just wanted to add that in less recent versions, the equivalent command is \SIrange. (Yes, I should update from TL 2020...) Feb 9 at 10:51
6

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .