1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
<head>
<title>UK TeX FAQ -- question label nodollar</title>
</head><body>
<h3>“Missing <code>$</code> inserted”</h3>
<p/>There are certain things that <em>only</em> work in maths mode. If your
document is not in maths mode and you have an <code>_</code> or a <code>^</code> character,
TeX (and by inheritance, LaTeX too) will say
<pre>
! Missing $ inserted
</pre>
as if you couldn’t possibly have misunderstood the import of what you
were typing, and the only possible interpretation is that you had
committed a typo in failing to enter maths mode. TeX, therefore,
tries to patch things up by inserting the <code>$</code> you ‘forgot’, so that
the maths-only object will work; as often as not this will land you in
further confusion.
<p/>It’s not just the single-character maths sub- and superscript
operators: anything that’s built in or declared as a maths operation,
from the simplest lower-case <code>\</code><code>alpha</code> through the inscrutable
<code>\</code><code>mathchoice</code> primitive, and beyond, will provoke the error if
misused in text mode.
<p/>LaTeX offers a command <code>\</code><code>ensuremath</code>, which will put you in maths
mode for the execution of its argument, if necessary: so if you want
an <code>\</code><code>alpha</code> in your running text, say
<code>\</code><code>ensuremath{<code>\</code><code>alpha</code>}</code>; if the bit of running text somehow
transmutes into a bit of mathematics, the <code>\</code><code>ensuremath</code> will become
a no-op, so it’s pretty much always safe.
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=nodollar">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=nodollar</a>
</body>
|