# How to migrate from numprint to siunitx while keeping the same font?

Until now I used the numprint package to display the units correctly. But since the solution given by @egreg to this question: package eurosym: how to change the decimal separator?, I try to code everything with a single package: siunitx.

The problem is that I can't get the same display as with numprint.

For example, the abbreviation for liter is "l" (lowercase "ell"). Under beamer, it is without serif, which poses reading problems to young students who begin learning units of measurement, because one can confuse it with a stylized number "1".

\documentclass[a4paper, 11pt]{beamer} % Présentation générale et mise en page

\usepackage[french]{babel}
\usepackage[np]{numprint}
\usepackage{siunitx}
\sisetup{locale=FR}
\begin{document}
Avec numprint: Le bol contient \numprint[l]{0.3} de thé vert.

Avec siunitx: La bouteille contient \SI{0.75}{\litre} de vin.
\end{document}


Output:

Edit: The global detect-all option does not solve this problem. Specifically, the dectect-all option doesn't affect the font used for the units; see the following code and screenshot.

\documentclass[a4paper, 11pt]{beamer} % Présentation générale et mise en page

\usepackage[french]{babel}
\usepackage[np]{numprint}
\usepackage{siunitx}
\sisetup{locale=FR,detect-all}
\begin{document}
Avec numprint: Le bol contient \numprint[l]{0.3} de thé vert.

Avec siunitx: La bouteille contient \SI{0.75}{\litre} de vin.
\end{document}


How to get the same font combination as numprint when printing with siunitx?

Translated with www.DeepL.com/Translator

• @HenriMenke - I don't think it's a duplicate. The reason is that \numprint uses -- in a beamer document, at least -- sans-serif for the numbers and math-rm for the unit. A rather unusual setting, no doubt. This setting can't be replicated by specifying detect-all as one of the siunitx options. – Mico Jul 14 '18 at 7:16
• You may also consider using ˋ\ellˋ for Liter and define the unit accordingly by adding ˋ\DeclareSIUnit{\litre}{\ell}ˋ – Tobi Jul 14 '18 at 7:51
• This posting is most definitely not a duplicate. – Mico Jul 15 '18 at 5:48
• @AndréC - No, please don't delete it. In my experience with this site, once some posting has been tagged as a potential duplicate, others tend to vote to support the Close move without bothering too much with verifying that the duplicate claim is correct. (In fact, there's a perverse incentive to vote Yes: Voting Yes contributes earning a special badge, whereas voting No (i.e., keeping the posting open) does not contribute to earning this badge.) I've initiated a Reopen process for this posting; let's hope that two more persons sign on to it. – Mico Jul 15 '18 at 8:36
• @AndréC. This in fact is related to TeX but was already answered: in Micos answer below or in my comment (see also tex.stackexchange.com/q/6016/4918). So for that I see no need for a new question. The question which of the three symbol is the best choice is not related to TeX … – Tobi Jul 15 '18 at 9:20

I suggest you create a new macro, called (say) \SInp, to modify the operation of \SI to conform to the style of \numprint.

• Set the option detect-mode to change the shape of the decimal comma. Setting detect-mode is less intrusive than setting detect-all.

• Place the second argument of \SI in a \textrm{...} wrapper. That way, "Roman" (i.e., serif) glyphs will be used even if the rest of the document (including the first argument of \SI) uses sans-serif -- as is usually the case in a beamer document.

\documentclass[a4paper, 11pt]{beamer}
\usepackage[french]{babel}
\usepackage[np]{numprint}
\usepackage[locale=FR]{siunitx}
\newcommand\SInp[2]{\SI[detect-mode]{#1}{\textrm{#2}}}

\begin{document}
\begin{frame}
La bouteille contient \numprint[l]{0.75} de vin. --- numprint

La bouteille contient \SInp{0.75}{\litre} de vin. --- siunitx
\end{frame}
\end{document}

• The \SInp macro proposed in the answer is meant to work with the use case provided by the OP -- beamer documents that use sans-serif as the main document font. For documents in which small-caps were the main font shape, other adjustments would be necessary. I'm mentioning this point merely out of an overabundance of caution, in case future readers of this answer try to apply it to documents other than "basic" beamer documents. – Mico Jul 15 '18 at 7:53