[Tex/LaTex] Proper way to typeset units such as N/m when using different body text and math font

siunitx

I am writing a document which uses times for the main body text and the math font is the standard Latex math font (Computer modern). I am typing units such as N/m in a form which uses a backslash. I have read about the package siunitx which helps to typeset units and such. When I use siunitx without any options, it prints si{N/m} in the Computer Modern font. But I want the letters in the times font. So I use \sisetup{detect-all = true, detect-family = true}.

But then when I type si{N/m} I get the same output as just typing N/m. I guess this is expected? I definitely want to use the backslash to write this unit, i.e. I don't want to write something like Nm^{-1}. Am I doing it right? I assumed the \si command would help achieve 'correct' spacing for the units and the backslash. (if there is such a thing as 'correct' spacing of units like N/m). Here is an example of the output.

enter image description here

My question is am I using \si correctly?

\documentclass{article}
\usepackage{times}
\usepackage{siunitx}
\sisetup{detect-all = true, detect-family = true}
\begin{document}
\si{N/m} or N/m
\end{document}

Best Answer

Yes, you are using siunitx correctly by giving it literal input, but using unit macros will let you use more features of the package.

For simple units, as in your example, using an siunitx macro produces the same output as typing the characters in directly.

\si[detect-all]{N/m} is the same as N/m.

enter image description here

The power of the package becomes more evident when you use complex units, which quickly become awkward to typeset correctly.

\si[detect-all]{N/m^2} versus N/m$^2$. % The second ^2 uses math font instead of text font.

enter image description here

Another of siunitx's strengths is that it ensures that all of your units (and numbers) are typeset consistently. As you have already discovered, you can set whether units adapt to the font around them or are always set with math font:

\si{N/m} versus $\si{N/m}$. % Always use math font \\  
\sisetup{detect-all}
\si{N/m} versus $\si{N/m}$. % Adapts to math or text font

enter image description here

You can also use unit macro input, which gives you more flexibility because you can use global options to affect unit typesetting.

\sisetup{per-mode = reciprocal} % default setting
\si{N/m} versus \si{\newton\per\meter}\\
\sisetup{per-mode = symbol}
\si{N/m} versus \si{\newton\per\meter}

enter image description here

Sinuitx really becomes valuable when you use some other macros such as \SI that ensures numbers and units are properly joined by a thin, non-breaking space,

\SI{5}{N/m}\\
5 \si{N/m}

enter image description here

and \SIrange and \SIlist that automatically format ranges and lists automatically:

\SIrange{0}{5}{N/m}\\
\SIlist{0;1;2;3;4;5}{N/m}

enter image description here

Related Question