# Why are so many symbols restricted to math mode?

A common beginner's mistake is to forget $$...$$/$...$ around symbols that require math mode.

Why doesn't (La)TeX let people use isolated symbols in text mode by default?

I am sure there are at least historical reasons, but a learner with an eye for parsing matters will wonder about an explanation (not found in introductory literature).

-
If it allowed this, people would write \alpha+\beta getting the space wrong. Math should always treated as math, even single symbols; consider it as markup, if you want. –  egreg Sep 7 '12 at 22:41

The real reason for not allowing \theta in normal text has to do with how TeX deals with fonts.

A TeX font has only 256 slots, while the mathematical symbols are many more. The command \theta is, essentially, a four digit hexadecimal number:

0x0112


which carries a good deal of information: the leftmost digit is 0 and tells TeX that it's an ordinary symbol; the next digit tells TeX what font it should draw the character from and the final two tell where in the font the symbol lives (place 0x12=18). Up to sixteen fonts can be used for math symbols and they are not necessarily tied to the text fonts (actually font number 0 should be a text font, but it's an exception).

TeX might have been designed so that a single command denoting a math symbol did the choice automatically, but the effects would be adverse in most cases.

One should also remember that math has its own spacing rules that TeX applies automatically. Letting people write math symbols in normal text would soon lead to poor typesetting.

-
“byte” might need to be “nibble” (bytes have 256 values and take two hex digits, nibbles have 16 values and take one hex digit). In other words, a nibble is half of a full byte. –  Jack Schmidt Sep 8 '12 at 2:21
@JackSchmidt Thanks; I changed it into "hexadecimal digit". –  egreg Sep 8 '12 at 7:26
consider the fact that italic letters can be either text or math. unless you mark them explicitly as math, how can a program tell the difference? tex may be "clever", but it can't be that clever. in a theorem in an english text, if "a" is a variable, even a person (other than the author) may have difficulty making this distinction. –  barbara beeton Sep 13 '12 at 13:56

It does, but you need to know what you're doing. Notation differs across users and most certainly disciplines, and therefore the typesetting is left up to the user, rather than (La)TeX. If you which to use certain commands conveniently in text and math mode, you have to provide your own rules. An elementary example:

\documentclass{article}
\let\oldtheta\theta
\renewcommand{\theta}{\ensuremath{\oldtheta}}
\begin{document}
Here is \theta\ (in text) and $\theta$ (in math).
\end{document}​

-
Thanks for your input. There is a misunderstanding: I was meaning to ask why one needs to switch to math mode (as you're doing using \ensuremath) to avoid an error. What is the gain of (La)TeX not doing this automatically? Please feel free to edit my question so that the intention of my question is clear to an expert. Either it's to make the TeX system simpler (though I find this hard to imagine) or it serves some useful purpose, except I don't know what this purpose is. Or is it only "to teach users to switch to math mode"? –  Lover of Structure Sep 7 '12 at 22:59
egreg explained it the best in his comment to your question: Math symbols belong to math to avoid spacing mistakes. And TBH, I don't think it hurts to write $\theta$. However, if you want to write long Greek texts, check this question. –  tohecz Sep 8 '12 at 6:40

Suppose you could use \times just in your text (I mean, like in 7×8=7\times 8=56), and \times would automagically switch to math mode (with proper spacing enabled and spaces ignored). How (and when) would you exit from the math mode ?

(corrected) You can use a Unicode encoding (by means of \usepackage[utf8]{inputenc} or \usepackage[utf8x]{inputenc}) to type a lot of special characters (in fact, the × character I typed instead of \times is such a character, and works with utf8x, but not with utf8). Using another package (textalpha) you can even type θ in your source text and get (more or tess) the expected result.

-
Sorry for disturbing you, but (1) the first part of this answer is more-or-less a copy of the previously-said things, and (2) the second part is incorrect: the character × finds the proper symbol in the proper font and simply typesets it, no \ensuremath is involved here. –  tohecz Sep 8 '12 at 9:10
The intention of the answer is good, perhaps an edit will help? ;-) What I had in mind was a modus operandi where for what you typed just the × and the \times would get converted to math mode locally, but this would lead to bad typesetting habits. If (La)TeX were to automatically produce math mode around those symbols like you suggest, the question is not only to know when math mode would need to end, it's also when it would need to begin. –  Lover of Structure Sep 8 '12 at 17:29
I do not suggest anything. I only point out two facts about your answer that make the answer wrong. –  tohecz Sep 8 '12 at 22:41
OK I just checked : you're right, that special char isn't connected to \times. So I corrected the answer. –  rcabane Sep 9 '12 at 9:47