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.

Possible Duplicate:
Can I make siunitx commands use serif fonts like the rest of the math in beamer?

I have a MWE showing setting the family default to sans serif with \renewcommand{\familydefault}{\sfdefault}. When this is done, no matter what settings to siunitx I have tried to use (shown in the example), I can't get the math modes ($$ and \[\]) to display units and numbers in the roman serif font.

\documentclass[12pt]{article} % use larger type; default would be 10pt
\renewcommand{\familydefault}{\sfdefault}
\usepackage{siunitx}
\sisetup{detect-mode=false,detect-family=false,
        detect-display-math=false,detect-shape=false,
        mode=math}

\begin{document}
text where you have \SI{450}{\volt}\\
$\textrm{inline math} \quad \sin^2(x) \quad \SI{450}{\volt}\\
\textrm{textrm V}$
\[\textrm{math environment}\quad \SI{450}{\volt}\]
\end{document}

The result is

enter image description here

Ideally, I would expect the units given in text to be typeset in sans serif (even though this is considered naughty by SI standards), and the units inside $$ or \[\] to be typeset in roman or whatever the current math font is.

I have noticed that it can get halfway there if you use \sfseries instead of \familydefault, meaning that text and $$ will be typeset sans serif, while \[\] can be typeset roman. That solution is a problem for my documents, since I use sans serif for section headings as well.

share|improve this question

marked as duplicate by Marco Daniel, Brent.Longborough, Martin Schröder, tohecz, Jake Aug 15 '12 at 12:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Welcome to TeX.sx!. Virtually the same basic question came up very recently: tex.stackexchange.com/questions/66713/…. I don't blame you for missing this, as the link is much clearer to me than anyone else, but we might consider this question to be a duplicate of that one (same underlying issue). –  Joseph Wright Aug 14 '12 at 19:13
    
Yes, it looks like this is a duplicate. I made one other change than what your answer described there, so I will answer and close. Thanks! –  Thav Aug 15 '12 at 12:06

1 Answer 1

Joseph pointed me in the right direction with this question Can I make siunitx commands use serif fonts like the rest of the math in beamer?. Beyond adding the \AtBeginDocument as recommended there, I changed text-rm=\rmfamily to text-rm=\sffamily to get sans serif mid text, then removed the mode setting and changed detect-mode=true.

\documentclass[12pt]{article} % use larger type; default would be 10pt
\renewcommand{\familydefault}{\sfdefault}
\usepackage{siunitx}
\sisetup{detect-mode=true,detect-family=false,
        detect-display-math=false,detect-shape=false}
\AtBeginDocument{\sisetup{math-rm=\mathrm, text-rm=\sffamily}}


\begin{document}
text where you have \SI{450}{\volt}\\
$\textrm{inline math} \quad \sin^2(x) \quad \SI{450}{\volt}\\
\textrm{textrm V}$
\[\textrm{math environment}\quad \SI{450}{\volt}\]
\end{document}

MWE showing sans in text, roman in all math

share|improve this answer

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