LaTeX error: Missing $ inserted
Subscripts (_), superscripts (^), and math commands such as \frac or \alpha only work in math mode. When TeX finds one in running text it inserts a $ to switch into math, which almost never matches what you meant, and reports the error.
! Missing $ inserted.
Try it: this example has the error
Press Fix it in the error box, and it compiles to a PDF. What pdfTeX printed for it:
! Missing $ inserted.
<inserted text>
$
l.3 The first value x_
1 is positive.
Ready. Press Compile (or Ctrl/Cmd + Enter).
Common causes
- A formula typed without dollar signs, like
x_1ore^{i\pi}in a sentence. - An underscore in ordinary text, for example a file name or variable name (
my_file.tex). Write\_instead. - A blank line inside
$$ … $$or\[ … \]: math cannot span a paragraph break. - A math command inside
\text{…}or a section title without its own$…$.
How to fix it
- Wrap the formula in
$…$for inline math, or\[ … \]for a displayed equation. - For a literal underscore in text, use
\_; for a literal caret, use\textasciicircum. - TeXpad finds the formula on the reported line and offers "Wrap … in $…$".