7

The following minimal example:

\documentclass{article}
\renewcommand{\familydefault}{\sfdefault}

\begin{document}
10$^5$ and CO$_2$.
\end{document}

produces the following:

enter image description here

The superscript and subscript fonts are different from the body font. Why is this happening, and how can I ensure that those fonts are the same as the body font?

  • 5
    Those are the fonts used in math mode. There are packages like siunitx or chemformula that can help you with a consistent appearance. – Johannes_B May 22 '15 at 11:33
12

In my view, it's abusing the math environment to use it only to make superscript and subscript numbers in a context that is not math. So I would use \textsuperscript and \textsubscript instead.

\documentclass{article}
\usepackage{fixltx2e}
\renewcommand{\familydefault}{\sfdefault}

\begin{document}
10\textsuperscript{5} and CO\textsubscript{2}.
\end{document}

enter image description here

  • 2
    I agree completely with your first sentence, but 10^5 is maths, and should (if not using siunitx's \num -- which I wouldn't here) be written as $10^5$. In this case $\mathsf{10^5}$ is appropriate. – Chris H May 22 '15 at 15:01
  • 1
    Note that fixltx2e is an obsolete package. Use changes. – Fran May 23 '15 at 4:33
  • @ChrisH I don't fully agree with that. 10^5 is in of itself not math - I consider it to be just a number. The context should decide. To me, a sentence like "There are 10^5 CO_2 particles in this sample" is no more math than a sentence "I am 20 years old". They're both just numbers in a sentence telling us the amount of particles and years. If the number is part of a mathematical operation, then that's another story: $10^5 - 1 = 99999$ is math just like $20 - 1 = 19$ is. – Sverre May 23 '15 at 12:25
  • @Fran, true but it's made obsolete so recently that I think most users probably need it here. I'll wait until after the release of texlive2015 to consider it obsolete. – Sverre May 23 '15 at 12:26
5

Those are the fonts used in math mode. Using mathsf you can switch to a sans serif math font. On the other hand, there are packages like siunitx and chemformula that ease the input significantly.

sabrewolfyMathSf

\documentclass{article}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{siunitx}
\usepackage{chemformula}
\begin{document}
10$^5$ and CO$_2$.\par
10$^\mathsf{5}$ and CO$_\mathsf{2}$.\par
\num{1e5} and \ch{CO2}.\par
\end{document}
  • 2
    With siunitx, \num{e5} works if you don't want the 1x part. – TonioElGringo May 22 '15 at 11:43
  • 1
    @TonioElGringo Yeah, but the syntax is very powerful and should be shown ;-) – Johannes_B May 22 '15 at 11:54
5

A variant with package siunitx for numbers and units (with font detection) and mhchem for chemical formulas:

\documentclass{article}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[version=3]{mhchem}
\usepackage{siunitx}
\begin{document}
\num{e5} and \ce{CO2}.
\end{document}

Result

1

Use sfmath package here.

\documentclass{article}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{sfmath}
\begin{document}
10$^5$ and CO$_2$.
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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