My students found this problem, which I could not solve. The percent is always printed in the serif font.
Here is a test code:
\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % T1 Schrift Encoding
\usepackage{lmodern} % Latin Modern
\usepackage[ngerman]{babel}
\usepackage{float}
\usepackage{siunitx}
\sisetup{%
mode = math,
detect-family,
detect-weight,
exponent-product = \cdot,
number-unit-separator=\text{\,},
output-decimal-marker={\text{,}},
math-rm=\mathsf,
text-rm=\sffamily,
}
\begin{document}
\sffamily\noindent
Text \SI{1.23}{\%} and further text.
\begin{table}[H]
\sffamily
\begin{tabular}{ll}
\SI{1.23}{\%} & 1,23\,\%
\end{tabular}
\end{table}
\end{document}
Best Answer
From page 5 of the siunitx manual:
Thus, just replace the options
detect-family
anddetect-weight
in the preamble's\sisetup{...}
instruction withdetect-all
, and your students will be all set.Incidentally, if you run
\addto\extrasngerman{\sisetup{locale=DE}}
after loading thebabel
package with the optionngerman
, you don't have to specify the optionsoutput-decimal-marker={\text{,}}
exponent-product = \cdot
, andnumber-unit-separator=\text{\,}
explicitly while loading thesiunitx
package.