# Font settings in siunitx package

I have changed the whole font settings by using fontspec package.

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Source Sans Pro}[
UprightFont     =Source Sans Pro-Light,
BoldFont        =Source Sans Pro-Semibold,
ItalicFont      =Source Sans Pro-Light Italic,
BoldItalicFont  =Source Sans Pro-Semibold Italic]

\usepackage{siunitx}

\begin{document}

5 km \SI{5}{\km} $\SI{5}{\km}$ $5\text{km}$
\end{document}


But when I type inside \SI environment, I want the font to be the same as in math mode. How can I achieve this?

• As always on this site please post a full minimal example that others can copy and test as is without having to add anything. This makes it a lot easier to help you. Mar 17, 2018 at 7:12
• @remco Yes, but how to? Mar 17, 2018 at 7:19
• Something like that. Adapt it to what you want to expose your ptoblem. Mar 17, 2018 at 7:34

The \SI macro in siunitx has optional parameters (list of key-value pairs). One of the keywords is 'mode', with possible values 'text', 'math'. You may have to set 'detect-mode' to false in \sisetup.
If you want to always use the math fonts for your measures/units, then you can use

\sisetup{mode=math}


This is explained in the documentation of the siunitx package. You can also select the math fonts with other package macros. Full exemple (note that I use LuaLatex):

\documentclass[a4paper,article,openany,12pt]{memoir}
\usepackage{lipsum}
\usepackage{mathpazo} %shows the differences between math and text mode better
\usepackage{fontspec}
\usepackage{siunitx}

\begin{document}
\sisetup{mode=math}

\SI[mode=text]{9.8}{\kilogram\metre\per\second\squared}\\
\SI{9.8}{\kilogram\metre\per\second\squared}\\
$\SI{9.8}{\kilogram\metre\per\second\squared}$

\end{document}

• mode=math can be used in \sisetup to fix it globally Mar 17, 2018 at 9:27