When changing the text font to opensans, then siunitx decides to use a third sans serif font in math mode.

Is this still the case with the current texlive release?

If so, how can I fix this behavior?

The solution provided here didn't help.





    Text mode:                \\
    expecting: 5.1\,N         \\
    getting:  \SI{5.1}{N}

    Math mode:                \\
    expecting: $ a = 5.1\,\mathrm{N} $ \\
    getting:   $ a = \SI{5.1}{N} $  


enter image description here

Edit: As daleif pointed out in his/her comment below, the behavior is different when using lato instead of opensans. With the former, the output in math mode is correct, and now output in text mode fails.

Update, Version 2020/02/25:
The output has changed. Now I get
enter image description here

Update, Version v3.0.38, last revised 2022-01-04:
The output now matches my expectations without any modification of the LaTeX code required: output_v3.0.38
The same output is obtained when using mode=match instead of detect-all as pointed out by Joseph Wright in his answer.

  • It might be opensans that does something non standard. With lato I get exacly as expected (all N's except the first in a serif font)
    – daleif
    Feb 11, 2019 at 15:37
  • @daleif I disagree; the output you are getting is erroneous too. With detect-all the two outputs on the left should be identical (text font) and the two on the right should be identical (math font).
    – Bastian
    Feb 11, 2019 at 15:51
  • Nope, your mistaken. The manual reads "By default, all text is typeset in the current upright math font. This can be changed by setting the appropriate options: \sisetup{detect-all} will use the current font for typesetting." I'm using detect-all in the MWE, so I would expect both outputs on the left not to be in math font.
    – Bastian
    Feb 11, 2019 at 16:34
  • My bad, I think I confused table 12 and 13
    – daleif
    Feb 11, 2019 at 16:37

1 Answer 1


Version 3 answer

With version 3 of siunitx, the only thing you need to set here is mode = match so you select text or math mode output. Other than that, you will get the same font as your 'reference' input.

Version 2 answer

The detection in siunitx picks up that opensans is sanserif, so uses \mathsf not \mathrm/\mathnormal for the standard math mode typesetting. That is with your set up Computer Modern. You can reset that by adjusting how math-sf is interpretted by giving \sisetup{math-sf = \mathrm}.

  • fantastic, this fixes it, makes me wonder though if there is not a bug in the implementation of siunitx: The manual reads "\sisetup{detect-all} will use the current font for typesetting." So I would expect the current math font to be used and not the sans-serif math font.
    – Bastian
    Feb 11, 2019 at 16:38
  • 1
    @Bastian Ah well that's one of those edge cases. In the current set up, I do effectively \mbox{\ensuremath{...}} for the content, so I have to reset the math mode font. That means knowing what it is, and getting it right. I really do need to finish v3, which uses an alternative method which is less invasive.
    – Joseph Wright
    Feb 11, 2019 at 16:43
  • Thank you for updating the answer! Aha, detect-all and mode=match seem to do the same thing. I think I will be able to remember mode=match better, so that's what I'll go with then.
    – Bastian
    Jan 25, 2022 at 9:05

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .