2

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:

numprint-siuntix-beamer


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}

numprint-siunitx-beamer-detect-all

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

Translated with www.DeepL.com/Translator

Mico
  • 506,678
AndréC
  • 24,137
  • \sisetup{detect-all} – Henri Menke Jul 14 '18 at 06:57
  • 1
    @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 07:16
  • 1
    You may also consider using ˋ\ellˋ for Liter and define the unit accordingly by adding ˋ\DeclareSIUnit{\litre}{\ell}ˋ – Tobi Jul 14 '18 at 07:51
  • @Tobi Tobi, good idea. One question: does this conform to the official typography of international units? – AndréC Jul 14 '18 at 08:54
  • 1
    @Mico Right, I hadn't noticed that. I edited my question. – AndréC Jul 14 '18 at 09:16
  • 2
    This posting is most definitely not a duplicate. – Mico Jul 15 '18 at 05:48
  • @AndréC: I’d say yes, but I couldn’t find anything about the unit in my typography books. According to german Wikipedia the unit symbol could be either L, l or \ell. however the english Wikipedia \ell in parens and points to the official (?) guide, where only l and L are mentioned. I’d choose this on based on context: For non scientists (like on a bottle of water or in a popular text) \ell would be fine, however in most fonts it is more like an … – Tobi Jul 15 '18 at 07:48
  • … italic shape and thus by design can’t be a unit since units but be set upright. In that case maybe L is they to go when your typeface has indistinguishable forms for l=l, I=I (and maybe even 1=1 ) like the typeface used here. – Tobi Jul 15 '18 at 07:51
  • @Tobi Yes, L is an alternative proposed by the USA. In Europe, l is used with a prefix like cl, dl, ml but writes L when there is no prefix. Do I need to ask a new question about that?https://en.wikipedia.org/wiki/Litre#Symbol – AndréC Jul 15 '18 at 08:30
  • @Mico Yes, this question is not a duplicate but five people think otherwise. Should I delete this question? – AndréC Jul 15 '18 at 08:34
  • 2
    @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 08:36
  • 1
    @AndréC: Yes, wether to use l, L or \ell should be a new question, but on this site it would be considered off-tipoc since it has nothing to do with TeX … you could look for another StackExcahnge site (maybe Physics, Graphic Design or English Language) or you ask a question at https://typography.guru … – Tobi Jul 15 '18 at 09:11
  • @Tobi How to write the symbol of the liter according to the existence of the prefix or not (\ell or ml, cl, dl, dal, etc) with numprint or with siunitx does not concern LaTeX? – AndréC Jul 15 '18 at 09:16
  • 2
    @AndréC. This in fact is related to TeX but was already answered: in Micos answer below or in my comment (see also https://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 09:20
  • @AndréC: I just re-read your latest comment. This (using L when there’s no prefix and l otherwise) of course wasn’t answered jet. And is perfectly ok for a new question here on TeX.SX. However fo the reader a mixture of L and l for the same unit would be confusing … I’d stick to one symbol for all cases (indecently of having a prefix or not). – Tobi Jul 15 '18 at 19:46

1 Answers1

2

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.

enter image description here

\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}
Mico
  • 506,678
  • 1
    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 07:53