# Shouldn't Beamer redefine \mathrm?

beamer does switch to a sans serif font for math. However, it does not redefine \mathrm. I think it should do so. I have a few formulas that use \mathrm to get upright characters and they look ugly with beamer.

Do you agree or did I miss something?

\documentclass{beamer}
\begin{document}
$abc\mathrm{abc}$
\end{document}


PS. I know how I could get properly looking formulas with beamer. I am not asking for help in this regard. In fact, I am suggesting an improvement (or even bugfix) here and would like to discuss how well the beamer package is written with regard to that issue.

Argument: Other packages that define sans-serif math fonts redefine \mathrm as upright math (sans-serif) font. For example:

\documentclass{article}
\usepackage{cmbright}
\begin{document}
$abc\mathrm{abc}$
\end{document}


cmbright, sfmath and arevmath all redefine \mathrm as upright sans-serif font. So I'd say beamer is the odd one here and should be changed.

• I would use \text{abc} and/or \DeclareMathOperator{}{} (both from amsmath) as appropriate to avoid the issue entirely. – Paul Gessler Jul 14 '14 at 19:49
• – Werner Jul 14 '14 at 20:10
• I don't see it is a bug in beamer. If anything, it strikes me as buggy to make \mathrm equivalent to \mathsf. (Except in the case where the entire document is to be in sans, I guess. So maybe beamer qualifies there. But I've never liked setting the default roman family to sans either as it just makes the effects of \rmfamily etc. more opaque.) – cfr Jul 15 '14 at 18:22

As Paul Gessler suggested, you can use \text{} instead of \mathrm{} when you want upright rather than specifically roman text. Since you are using beamer, you don't even need to load any additional packages:

\documentclass{beamer}
\begin{document}
$abc\text{abc}$
\end{document}


If you are producing an article version as well, you obviously want TeX to do the right thing in that case, too:

\documentclass{article}
\usepackage{beamerarticle}
\begin{document}
$abc\text{abc}$
\end{document}


This works because by default, beamer loads several ams packages. If you are not using beamer, you would need to load them yourself as Paul Gessler mentioned.

• Perhaps \textup – egreg Jul 15 '14 at 17:58
• Sorry, \mathrm and \text are two very different concepts. They look the same in beamer but they are generally not interchangable. First, because of math operators, other math features and spaces. Second, many documents have completely different math and text fonts. – mh543 Jul 15 '14 at 17:59
• @mh543 You indicated in the question that it was just certain characters needed in upright. So I didn't think you would need it for maths operators etc. Probably in that case you need to define a \mathup. – cfr Jul 15 '14 at 18:20
• It'd be nice if the down-voter would say why. – cfr Sep 16 '16 at 12:37

You get what you ask for: Roman text.

For advice on this, see Equivalent of \mathup for upright text in math mode?

• I see it differently. "Roman" denotes the standard upright font, in contrast to italic, bold or light variants. See linotype.com/en/526/Helvetica-family.html as an example, where Helvetica Roman is available. – mh543 Jul 15 '14 at 17:52
• No, you are confusing family with shape. You want to change the shape to upright (from italics), keeping the sans-serif family. This is what \textup and \upshape does for you in normal text. \textrm and \rmfamily gives you the Roman family, in latex this means glyphs with serifs. – Jan-Åke Larsson Jul 20 '14 at 7:31
• Then please help me to understand it correctly. What does \mathrm refer to and does it differ in meaning from \mathit or \mathbf? I read the LaTeX companion and found no definite answer. -- I know however that cmbright redefines \mathrm with a sans-serif font. So you would say beamer is right and cmbright is buggy? – mh543 Jul 20 '14 at 11:42
• cmbright, sfmath and arevmath all redefine \mathrm as upright sans-serif font. – mh543 Jul 20 '14 at 11:53
• @mh543 Because they put a sans serif in the “roman” place in LaTeX. So \mathrm points to the roman font, which happens to not have serifs. – Manuel Jul 20 '14 at 16:00
\documentclass{beamer}
\usefonttheme{professionalfonts}
\begin{document}
$abc\mathrm{abc}$
\end{document}


Then beamer doesn't change the math fonts.

• Sorry, this doesn't answer my question. – mh543 Jul 15 '14 at 18:03