2

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}

enter image description here

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

3
  • 1
    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.
    – daleif
    Mar 17, 2018 at 7:12
  • @remco Yes, but how to?
    – Siwei Feng
    Mar 17, 2018 at 7:19
  • Something like that. Adapt it to what you want to expose your ptoblem.
    – Tarass
    Mar 17, 2018 at 7:34

1 Answer 1

4

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}
1
  • 1
    mode=math can be used in \sisetup to fix it globally
    – Dai Bowen
    Mar 17, 2018 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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