What is the Necessity of $...$ Around Numbers?

I typed up an assignment with a lot of numbers in LaTeX and turned it in to my adviser. When he returned it to me with some corrections, one of which was a lot of $ around my numbers. I understand that $ are necessary around some mathematical formulas, but I was just using numbers like -2 and 4. I did not see any change in the font of the numbers when I added the $ either. Since my adviser did not want to give me an explanation, what is the rationale? • Jun 16, 2014 at 22:43 • @Mathematician I clearly see a difference between -2 and $-2$: a hyphen is very different from a minus sign. Jun 16, 2014 at 22:47 • @Mathematician Because you only “save” 2 characters, and it's “incorrect”. Although it looks the same (again, by default, with computer modern in upright roman font). If you use another font (for instance, with old style figures) it won't look the same. Jun 16, 2014 at 22:59 • Just like you use \sin in math-mode because it represents some mathematical context, you should do the same with -2 or 999. The consistency is what your advisor was after, I'm guessing. Sure there is no difference in writing 2 and writing $2$ in terms of the output, because they represent single digits without much interaction with other objects. But when you compare (say) 2-2 with $2-2$ there is a major difference is spacing around the binary operator -. – Werner Jun 16, 2014 at 23:07 • Some fonts do have different math-mode numbers. Knuth himself ran into this when using the Euler fonts. Jun 17, 2014 at 7:58 4 Answers Numbers can be used in a printed document in two different meanings: as symbols representing mathematical objects (note that “1” is not “the number one”, but one of its possible representations, hence a symbol) or words. A number used in the second meaning is, for instance, a date or the reference to a page. Mathematical symbols should have the same shape independently of the context, while words can be affected by font changes. However, stylistic guidelines might require also some numbers representing words being typeset upright; this is however outside the scope of your question. Here is an example showing why mathematical numbers should always be typed as formulas (that is, between $...$). \begin{lemma} If$v\ne0$is a vector in$\mathbb{R}^{n}$, then$vv^T$is a rank~$1$matrix. \end{lemma}  If we don't type $1$ but simply 1, the style in which the statement is typeset would prevail and the number would probably appear in italics, as this is the usual font for mathematical statements. The 1 in italics would be wrong, without any doubt. One might try and remember to type numbers in statements between $...$, but being consistent is better because it avoids mistakes; moreover, code reusability mandates always using the same syntax for the same object. Of course, there's no question about negative numbers, because - outside math mode prints a hyphen, which is very different from a minus sign. In the above example there's no difference between $v$ and $1$: would you simply type v since the statement is printed in italics? I hope not. • Also this may get even more important if the doc is using old style numbers in text but lining numbers in math. Then the distinction is critical. So it is a good rule of thumb to mark math 'numbers' as such Jun 17, 2014 at 6:41 • "If$v$is a vector in$\mathbb{R}^{n}$, then$vv^T$is a rank~$1$matrix." Only if vector v is nonzero :p Jun 18, 2014 at 22:52 • @Jubobs Oh, right! Jun 18, 2014 at 22:54 In addition to the previous answers, a further reason might be that at some later point you consider changing fonts. It may happen that you end up choosing a font that uses different numerals for mathematical and ordinary text, or that you are even choosing different fonts for mathematical text and for ordinary text. This actually happened to Don Knuth, see Typesetting Concrete Mathematics using the AMS Euler font: [...] The Euler numerals [...] are distinctly different from the numerals [...] in ordinary text. In previous work I used to "optimize" my typing by saying, e.g.,$x$is either 1 or$-1$, thereby omitting$'s around a mathematical constant unless I needed them to get a minus sign instead of a hyphen. [...] In Concrete Mathematics I needed to type

$x$ is either $1$ or $-1$,

[...] The early drafts of my manuscript had been prepared in the old way; therefore I needed to spend several hours laboriously hunting down and correcting all instances where the new convention was necessary. This experience proved to be worthwhile, because it taught me that there is a useful and meaningful distinction between text numerals and mathematical numerals. Text numerals are used in contexts like '1776' and 'Chapter 5' and '41 ways', where the numbers are essentially part of the English language; mathematical numerals, by contrast, are used in contexts like 'the greatest common divisor of 12 and 18 is 6', where the numbers are part of the mathematics. (Authors of technical texts in languages like Japanese, where Arabic numerals are used in formulas but not in ordinary text, have always been well aware of this distinction; now I had a chance to learn it too.)

• The "41 ways" is an interesting example. This could be text or maths depending on the context -- e.g. the result of a calculation, especially as ways could be a layman's term for permutations in an introductory maths text. Jun 17, 2014 at 10:28

Please compare: 2, $2$ with \textit{2, $2$}. In the second case the second number remains upright. Additionally, e.g. -2 doesn't give a minus sign before 2.

Edited according to OP's request:

\documentclass{article}

\begin{document}

Without \$'s: 2, -2; \textit{2, -2} With \$'s:

$2$, $-2$;  \textit{$2$, $-2$}

The first version is rather unacceptable.

\end{document}


• I am sorry, but I understand neither the answer nor the comment. Please revise and elaborate. Jun 16, 2014 at 22:49
• @Mathematician The argument consists of two parts I. You want to differentiate between the way numbers are typeset and the way text is typeset, to give a readable body text which instantly makes the reader aware of that differentiation. II. Readability is also contingent on that consistent use of that subtle differentiation in the body text. Jun 16, 2014 at 23:06
• @Mathematician some of the examples in your question would not use the same font -2 for example. but even for 4 which would (by default) you should use $4$ otherwise if the fragment is published and \documentclass{article} is changed to \documentclass{somejournal} which does use different math fonts you have to edit teh whole document to fix the bad markup Jun 16, 2014 at 23:19
• @Mathematician Answering to the second question: because (s)he is a good advisor. :-) Jun 16, 2014 at 23:19
• @Mathematician -- if the numerals are in a theorem, they will be in italic unless you put $ around them (or otherwise mark them as upright). and it's better to code your input consistently, so that you don't forget it when it's really necessary. Jun 17, 2014 at 13:06 There is a huge difference if you are using right-to-left languages, like Arabic or Persian. This should show the difference. \documentclass{article} \usepackage{xepersian} \begin{document} -2$-2$\end{document}  There is another difference for some characters based on your font. Here I am using BZar.ttf font and as you can see the second form is the correct form for 0. \documentclass{article} \usepackage{xepersian} \setmainfont{BZar.ttf} \begin{document} 0$0\$
\end{document}


• You make an excellent additional point to the ones already offered in the earlier answers.
– Mico
Jun 19, 2014 at 5:28
• Excellent note. (+1) Jan 18, 2017 at 0:11