Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In a beamer presentation I can use \usefonttheme[onlymath]{serif} to typeset the math in a serif font while the rest of the presentation is in a sans-serif font. But the \SI command from siunitx appears to typeset its argument as text, which means it follows the text font style, not the math one. Is there a way I can change this so that quantities with units appear with a serif font just like other math, whereas the text is still sans-serif?

\documentclass{beamer}
\usefonttheme[onlymath]{serif}
\usepackage{siunitx}

\begin{document}
 \begin{frame}
  Text appears in sans-serif font

  $x,2y,3z$ appears in serif font

  $\SI{1}{m}$ appears in sans-serif font, would like it to be serif
 \end{frame}
\end{document}

I've tried things like \sisetup{math-rm=\mathrm, text-rm=\rmfamily} or passing the detect-family option to siunitx, but no luck.

Of course I could just change the font family of the entire document to be serif, but I'd like to know whether I have another option.

share|improve this question
5  
Where are you doing the \sisetup? siunitx deliberately tests for 'all sanserif' using the \AtBeginDocument hook, so to reverse that you need to either do \sisetup after \begin{document} or use \AtBeginDocument from the preamble. –  Joseph Wright Aug 10 '12 at 21:44
    
Ah, that's the issue, I had \sisetup before \begin{document}. I could accept that if you'd like to post it as an answer. –  David Z Aug 10 '12 at 22:36
add comment

1 Answer

up vote 10 down vote accepted

siunitx checks if the document font is sanserif using the \AtBeginDocument hook, and adjusts the default if it is. That reflects the fact that in most cases if people set their document all sanserif the desired outcome is that siunitx also uses sanserif.

To reverse this, yo need to alter the settings after siunitx has done its test. That's easiest to do using \AtBeginDocument

\usepackage{siunitx}
\AtBeginDocument{\sisetup{math-rm=\mathrm, text-rm=\rmfamily}}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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