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?
Best Answer
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
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):