# siunitx uses weird font in math mode

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.

\documentclass{standalone}

\usepackage[default]{opensans}

\usepackage{siunitx}
\sisetup{detect-all}

\begin{document}

\begin{minipage}[t]{50mm}
Text mode:                \\
expecting: 5.1\,N         \\
getting:  \SI{5.1}{N}
\end{minipage}

\begin{minipage}[t]{50mm}
Math mode:                \\
expecting: $a = 5.1\,\mathrm{N}$ \\
getting:   $a = \SI{5.1}{N}$
\end{minipage}

\end{document}


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}.
• @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