summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-nodollar.html
blob: 4c0b9128d295cc2333dc1608e125069e60101eff (plain)
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>&ldquo;Missing <code>$</code> inserted&rdquo;</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&rsquo;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 &lsquo;forgot&rsquo;, so that
the maths-only object will work; as often as not this will land you in
further confusion.
<p/>It&rsquo;s not just the single-character maths sub- and superscript
operators: anything that&rsquo;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&rsquo;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>