# Italic in theorem environment

Consider the following theorem:

\begin{theorem}
If $x=0$, then $xy$ is equal to 0.
\end{theorem}


The first "0" will be typeset in upright typeface and the second one in italic. Including amsthm has no effect. Is this a bug? I personally think it look very weird.

I think I know how to fix this, and this question is more about the why it is not fixed by default. However, if you have a clever trick for avoiding this, feel free to share it.

-
You can redefine the theorem environment. –  xport Jan 3 '11 at 3:24
Yes, I have to do that. This default behavior looks very poor. –  Ben Jan 3 '11 at 17:39

The reason it is in italic is because the theorem style is to typeset the text in italic. Just write $0$ to have the 0 be treated as math and thus be upright.

-
Yes, but why isn't the theorem environment defined to use italic numbers in mathematics as well? The mixing of upright and italic typeface look wrong. –  Ben Jan 3 '11 at 16:46
Because mathematical objects are defined not only by their name/sequence of letters, but also by the font/style in which they are typesetted. --- E.g. for bold: \textbf{the real $$x$$} should not typeset the maths like \textbf{the vector $$\boldsymbol{x}$$} (some physicists like bold vectors). For numbers, in italics, the argument is less convincing, admittedly. But this is the behaviour of plain TeX as well. \input plain \it 0 + $0$ \bye will typeset the second 0 straight. –  Bruno Le Floch Jan 3 '11 at 17:12
@Ben: Because until TeX is told otherwise, it is going to typeset the characters it sees in the font it was told to typeset them in. The default theorem style uses italics which, unless you've changed the fonts, is going to be computer modern italics. The numbers in those fonts (I say "fonts" because a font is a particular size as well) are slanted. If they were old style figures instead, that's how they would be typeset. Putting the dollar signs around it tells TeX that it is math and should be typeset as such. –  TH. Jan 3 '11 at 18:54
it was proposed many years ago that there should be a "theorem font", with italic letters and upright digits and punctuation. sadly, this is one of the projects that fell into the black hole with the death of michael downes. but in any event, that 0 is math, and should be input as such. knuth is very clear about this in the texbook. not so well known is the use of \eqref in the ams classes to set xrefs to equations, in parentheses, all upright, even in theorems. –  barbara beeton Jan 3 '11 at 20:59
@barbara: \eqref is great. I use it all the time. –  TH. Jan 4 '11 at 1:16

In my opinion, it is sensible that 0 and $0$ are typeset differently. I think they have different purposes. Not all numbers are mathematical numbers.

For instance, when I say see Section 1, the 1 is a piece of text, not a piece of maths. Another example: a phone number - again, that's text, not maths.

Often it doesn't matter whether you type 0 or $0$, since LaTeX tends to use Computer Modern both for text and for maths. But when this default is not used, the text/maths distinction becomes visible in the output. For instance, I like to put \renewcommand\rmdefault{bch} in the preamble of my documents, to change the text font to Charter and leave maths in Computer Modern. Or maybe you're making slides, and want all the mathematical text to be highlighted in green.

Here are a few examples of the text/maths distinction in practice.

\documentclass{article}
\renewcommand\rmdefault{bch}
\begin{document}
In Section 2.4 we learnt that $2+2=4$.
\end{document}


\documentclass{beamer}
\usepackage{xcolor}
\setbeamercolor{math text}{fg=green!60!black}
\begin{document}
\begin{frame}
The maths hotline on 0800 123 123 told me that $2+2=4$.
\end{frame}
\end{document}


-