5

For personal reasons, I like when my paper is written in sans font while my math and units are written in serif. I recently updated to version 3 of the siunitx package and have no idea of how to reset the unit font to serif.

The command I use to set the default font is

    \renewcommand{\familydefault}{\sfdefault}

Here's my MWE:

\documentclass[12pt]{article}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{siunitx}
    \sisetup{mode = math, reset-text-family = true  }
\begin{document}

\qty{15}{mm}

\end{document}

And here's my output.enter image description here

Whilst my desired output is: enter image description here

Thank you.

2
  • 2
    Postponing execution of \renewcommand{\familydefault}{\sfdefault} until after \begin{document} gets the job done. Not sure why, though.
    – Mico
    Oct 30, 2021 at 8:02
  • @Mico That's interesting, never thought of changing the order. Thanks. Oct 30, 2021 at 17:25

2 Answers 2

3

You need to reverse an automatic setting change here:

\documentclass{article}
\usepackage{siunitx}
\renewcommand{\familydefault}{\sfdefault}
\AtBeginDocument{\sisetup{unit-font-command = \mathrm}}
\begin{document}
\qty{15}{mm}
\end{document}
1
  • Thanks, it works. Also, it keeps the sintaxis I prefer for my documents, so it's great. Oct 30, 2021 at 17:36
3

As Mico suggests in comments, you can postpone resetting \familydefault until after siunitx has made its decision.

Another way is to use text mode.

\documentclass[12pt]{article}
\usepackage{siunitx}

\renewcommand{\familydefault}{\sfdefault}

\sisetup{mode = text, text-font-command=\rmfamily }

\begin{document}

A length \qty{15}{mm} is specified

\end{document}

but this might have other issues.

The other way seems to be

\documentclass[12pt]{article}
\usepackage{siunitx}

\AtBeginDocument{\renewcommand{\familydefault}{\sfdefault}\normalfont}

\sisetup{mode = math}

\begin{document}

A length \qty{15}{mm} is specified

\end{document}

enter image description here

1

You must log in to answer this question.

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