# [Tex/LaTex] Equivalent of \mathup for upright text in math mode

math-moderoman

To insert text in mathmode, there are a couple of commands:

• \mathrm for Roman script,
• \mathbf for bold weight,
• \mathit for italic shape,
• \mathsf for the sans serif variant,

and so on. Now, sometimes I would like to have some math entities typeset upright (see for example How to best typeset "special" constants (complex unit i, Euler's number e,…)?).
I understand that \mathrm sets the text in Roman and upright, but in some cases I do not want serifs (e.g., in presentations). The command \mathup does not seem to exist.

What is recommended way to set upright text in math mode?

I guess what you are seeing is the following when you use \mathrm with a serif font:

\documentclass{beamer}

\usepackage{amsmath}

\begin{document}

\begin{frame}
$$x y \mathrm{x} \text{\textup{x}}$$
\end{frame}

\end{document}


There are two ways to fix this: one fairly drastic option is to put

\renewcommand{\rmdefault}{cmss}


but this may feed through to places you are not expecting. An alternative is to replace the two relevant definitions from beamerbasefont.sty by

\AtBeginDocument{%
\SetMathAlphabet{\mathrm}{normal}{\encodingdefault}{cmss}{\mddefault}{n}
\SetMathAlphabet{\mathrm}{bold}{\encodingdefault}{cmss}{\bfdefault}{n}}


in your preamble. In the beamer style file {cmss} is {\rmdefault}.

Applied to the above example, either method gives you: