13

I am using the siunitx package to typeset my numbers, but sometimes I find situations in which I have numbers without units (when the units are not nearby) and units without numbers. E.g.:

The bird can fly 40 to 50 km per hour.

The data in the table above uses kg.

What is the prefered way to typeset these?

The bird can fly $40$ to $\SI{50}{\kilo\meter\per\hour}$.

The bird can fly \num{40} to \SI{50}{\kilo\meter\per\hour}.

The bird can fly \SI{40}{} to \SI{50}{\kilo\meter\per\hour}.

The data in the table above uses kg.

The data in the table above uses \SI{}{\kilo\gram}.

If find achieving visual consistency and correctness in the output is more important than having consistent, context-intelligent code.

21

To typeset units without numbers, you can use \si{<unit>} (note the lower case).

The mathematically correct way to typeset ranges of values with units is to include the unit with each of the numbers. This is what the command \SIrange{<lower>}{<upper>} does. If you don't want to repeat the units, you can set [range-units = single].

Note that the most common units can be accessed using abbreviations (like \km for \kilo\metre).

\documentclass{article}
\usepackage{siunitx}

\begin{document}
The bird can fly \SIrange{40}{50}{\km\per\hour}.

The bird can fly \SIrange[range-units=single]{40}{50}{\km\per\hour}.

The data table above uses \si{\kg}.
\end{document}
  • 1
    What about "The bird can fly 40 or 50 km/h?" – bers Apr 6 '15 at 20:01
  • 1
    You can use the \SIlist{} command: \SIlist[list-pair-separator = { or }, list-units=single]{40; 50}{\kilo\meter\per\hour}. – applesoup Oct 26 '17 at 20:42

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.