# siunitx uses the same fonts in and out of math mode

I want siunitx to use the math font when it's used inside math mode (eg ). However, I can't find any combination of settings that works. MWE:

\documentclass{article}

\usepackage{amsmath,amsfonts,mathtools}

\usepackage{fontspec}
\usepackage{unicode-math}
\usepackage{siunitx}
\sisetup{detect-all}

\setmainfont[Mapping=tex-text]{DejaVu Sans}

\setmathfont[%
Extension = .otf,
BoldFont = *bold,
StylisticSet=1]{xits-math}

\usepackage{polyglossia}
\setmainlanguage{greek}
\setotherlanguages{english}

\begin{document}
τέστ: \SI{200}{\micro\ohm} vs $\SI{200}{\micro\ohm}$ vs $200μΩ$

$$5^{x} - \frac{45}{x} = \SI{200}{\micro\ohm} = 200\mu\Omega$$
\end{document}


The result:

As you can see, using \SI{}{} and $\SI{}{}$ has no difference. The font that is being used though is not the math font but the normal text font.

How can I make siunitx use the correct (math) font when inside math mode?

• Why are you using the option detect-all? – Mico Nov 13 '16 at 3:50
• It doesn't seem to make any difference actually. I was playing around with the options before asking here. – orestisf Nov 13 '16 at 4:06

## 1 Answer

You've run into the issue that Unicode math mode set up is entirely different to classical TeX. This makes some 'normal' assumptions invalid but without necessarily giving me a good alternative. (I'm working on v3 of siunitx and this is an area I will be examining.)

The issue comes down to the fact that \mathrm here is in your sanserif document font but \mathnormal is not. So you likely want

\sisetup{math-rm = \ensuremath}


You'll also need to alter the definition for the micro symbol, probably best is

\sisetup{math-micro = \symup{μ}}


Example

\documentclass{article}

\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{DejaVuSans.ttf}

\usepackage{unicode-math}
\setmathfont[%
Extension = .otf,
BoldFont = *bold,
StylisticSet=1]{xits-math}

\usepackage{siunitx}
\sisetup{detect-all, math-rm = \ensuremath, math-micro = \symup{μ}}

\begin{document}

Reference: 200\,μΩ $200\,\symup{μΩ}$

\textsf{siunitx}: \SI{200}{\micro\ohm} $\SI{200}{\micro\ohm}$

\end{document}

• Is there a way to still use regular text font in tables but use math font in all \equations and other math environments? – Redfox87678 Jul 23 '17 at 17:31