[Tex/LaTex] Typesetting unit-less numbers and number-less units

siunitxunits

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.

Best Answer

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}