0

I am using a sans serif font in the running text. In order to correctly set numbers and units with \SI{}{} in the running text, I used

\sisetup{detect-all}

which worked fine:

enter image description here

However, in math mode, where the serif font is used (which is fine) \SI{}{} now sets the units in the sans serif font:

enter image description here

How can I prevent it from doing that?

EDIT:

Minimal example:

\usepackage[a4paper, top=0cm,bottom=1cm,right=2cm,left=2cm]{geometry}
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

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

\setmainfont{MarkPro.otf}[BoldFont={MarkPro-Bold.otf}]

\begin{document}

Some running text with embedded math like attenuation $A_{tot}$ and some SI units like \SI{53}{d\bel}.

\begin{equation}
P_{RX,e}\Big|_{P_{TX}=\SI{7}{d\bel m}} \approx \SI{-46}{d\bel m}
\end{equation}

\end{document} 
5
  • Welcome to the TeX.SE community. Have you seen that siunitx package have a new recent updating? After, please can you put a minimal working example of your work (there are CM font and another font in your images)? Thank you.
    – Sebastiano
    Commented Jul 7, 2021 at 14:59
  • I have not! My version is 3.0.17
    – RadaD
    Commented Jul 7, 2021 at 15:01
  • Nobody have an idea?
    – RadaD
    Commented Aug 10, 2021 at 9:12
  • Excuse me. But do you want all in Computer modern in math-mode?
    – Sebastiano
    Commented Aug 10, 2021 at 12:37
  • 1
    Yes, I am bothered by the fact, that the unit inside the math is in a different font.
    – RadaD
    Commented Aug 10, 2021 at 12:41

1 Answer 1

1

Try this putting \setmainfont{MarkPro.otf}[BoldFont={MarkPro-Bold.otf}] instead of \setmainfont{TeX Gyre Pagella}[Scale=1.0] that I have not installed into my pc using XeLaTeX engine.

enter image description here

\documentclass[12pt]{article}
\usepackage[a4paper, top=1cm,bottom=1cm,right=2cm,left=2cm]{geometry}
\usepackage{unicode-math}
\usepackage{siunitx}
\sisetup{detect-all}
\setmainfont{TeX Gyre Pagella}[Scale=1.0]
\setmathrm{Latin Modern Math}
\begin{document}
Some running text with embedded math like attenuation $A_{\text{tot}}$ and some SI units like \SI{53}{d\bel}.
\begin{equation}
P_{RX,e}\Big|_{P_{TX}=\SI{7}{d\bel m}} \approx \SI{-46}{d\bel m}
\end{equation}
\end{document} 
2
  • Indeed: perhaps worth pointing out that the comparison of $-46\,\mathrm{dBm}$ shows exactly the same issue if you set things up manually: \mathrm is (as expected) taking the text font.
    – Joseph Wright
    Commented Aug 10, 2021 at 12:57
  • @JosephWright Truly kind I think yo have understood your comment. I hope I didn't make a mistake because I misunderstand English in some circumstances. Certainly if the user uses \text{...} or textual writing mode it takes the textual font. Obviously like everyone else you are allowed to make more in-depth changes or comments. I am almost always synthetic and then today even more so with 45 degrees in eastern Sicily.
    – Sebastiano
    Commented Aug 10, 2021 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .