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.

  • 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 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 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 at 16:34
  • My bad, I think I confused table 12 and 13 – daleif Feb 11 at 16:37

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 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 at 16:43
  • sweet, thanks for your work! – Bastian Feb 11 at 17:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.