# Italics in theorem environment only for text but not for equations

I have got the following problem, I would like to keep the text in italics in my theorems but to not allow for italics in the equations (math mode, align, equation environments etc.) inside the theorem.

\documentclass{article}[12pt]

\usepackage{amsmath}

\usepackage{amsthm}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}

\def\bs{\ensuremath\mathbf} %This command makes \bs a shortcut for \boldsymbol

\begin{document}

\begin{thm}
This is a theorem.

\begin{align*}
\text{Var}(\bs{A}) = \text{Var}(\bs{Y} + \bs{X})
\end{align*}

\end{thm}

I would like to have the following in the theorem

\begin{align*}
\text{Var}(\bs{A}) = \text{Var}(\bs{Y} + \bs{X})
\end{align*}

\end{document}

• I think you should use \mathrm instead of \text. Or better, use \DeclareMathOperator{\Var}{Var} then use \Var... – Phelype Oleinik Oct 15 '18 at 16:57
• I agree with Phelype you're using \text completely wrong here. Normal users should only use \text for textual comments in displayed math. These are functions not comments, mark them as such. – daleif Oct 15 '18 at 17:03
• BTW, sadly, this misuse of \text is very common. May I ask, where do you have it from? – daleif Oct 15 '18 at 17:04
• Another comment with respect of the style, as suggested here: (tex.stackexchange.com/questions/655/…) is better to use \newcommand instead of \def, unless you really know why are you using \def – Luis Turcio Oct 15 '18 at 17:13
• Note that your \bs is definitely not a shorthand for \boldsymbol and, as defined, works by pure chance. – egreg Oct 15 '18 at 17:22

Several errors here.

1. [12pt] should go between \documentclass and {article}.

2. \def\bs{\ensuremath\mathbf} isn't a “shorthand of \boldsymbol, but a wrong definition under many respects. Try it outside of math mode to see. Moreover, \boldsymbol{X} typesets a bold italic X, whereas \mathbf prints it bold upright.

3. There should be no blank line before any math display environment.

4. For a single equation, use equation (numbered) or equation* (unnumbered).

5. There should be no blank line between the end of a display environment and \end{thm}.

Now the bigger problem: \text{Var} is wrong, because in an italic context will print its argument in italics. You want \operatorname{Var} instead or \Var defined by

\DeclareMathOperator{\Var}{Var}


Full fixed example. I used \rv (random variable) instead of a more generic name; using the right semantics is helpful. I also loaded bm for better math boldfacing.

\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{bm}
\usepackage{amsthm}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}

\newcommand{\rv}[1]{\boldsymbol{#1}} % random variable
% or \mathbf{#1} if you want upright type

\DeclareMathOperator{\Var}{Var}

\begin{document}

\begin{thm}
This is a theorem.
\begin{equation*}
\Var(\rv{A}) = \Var(\rv{Y} + \rv{X})
\end{equation*}
\end{thm}

I would like to have the following in the theorem
\begin{equation*}
\Var(\rv{A}) = \Var(\rv{Y} + \rv{X})
\end{equation*}

\end{document}