Although many have attempted to explain the difference among \mathrm, \textrm, \textnormal and \text (and others?), I found them misleading.
See for example the LaTeX's Wiki \mathrm explanation

Why is it wrong? Let's try all of them within an article and a beamer and you'll see the difference and, therefore, error.
equation.tex
\begin{eqnarray*}
\int_1^9\! \cos{x} \,\mathrm{d}x & & \textrm{this is textrm}\
\sum_1^9 y & & \textsf{this is textsf}\
\prod_1^9 z & & \textnormal{this is textnormal}\
\bigcup_1^9 w & & \text{and this is just text}
\end{eqnarray*}
article.tex
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\input {equation}
\end{document}

And until here everything looks fine...
beamer.tex
\documentclass{beamer}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\begin{frame}
\input{equation}
\end{frame}
\end{document}

And here we can clearly see that \mathrm does not behave as expected, i.e. does not provide a function aspect to the d. Does anyone know what am I supposed to use here instead? Just \text?? o.O
Moreover, I cannot see any difference between \textnormal and \text.
Finally, \textrm looks useless..



\textpicks up any setting outside of math mode. Issue\itshapebefore\inputto see (also affects\textrm). – Qrrbrbirlbel Aug 28 '13 at 14:26beamer's font set up is rather odd and should not at all be taken as giving 'guidance' on normal input for LaTeX. (I can't do much about that at this point.) – Joseph Wright Aug 28 '13 at 14:29\mathsf– karlkoeller Aug 28 '13 at 14:47\mathrmdoes not behave as expected..." To me the expected result of\mathrmis upright roman font. Also "\textrmlooks useless" : why so? Your beamer example shows that it allows you to typeset upright roman font, even when the environment (in this case, thebeamerclass) tries to enforce sans serif fonts. As I understand it, the wikibook mistakes\mathrm(roman font) for\textnormal(upright font). – T. Verron Aug 28 '13 at 14:51\mathrmwas to reproduce the font type of cosine function shown above. So, have undefined functions to be enclosed in a\textnormalenvironment? Is this the common practice? And what about\text? Is it used for normal text? – Atcold Sep 01 '13 at 05:15\textrmcommand exists to switch to the default serif font without changing any other formatting. It works in math mode, but wasn’t created for this. It might have some use for switching to bold serif symbols in a bold sans-serif title, however. – Davislor Dec 01 '20 at 09:19