Missing $ inserted.
A maths-only character or command (_ ^ \alpha) appeared in text, or text appeared in maths. Wrap the maths in $ … $ or escape the character.
Help centre › LaTeX errors › Maths · Error: the build stops or the output is wrong
What the log says
! Missing $ inserted.
<inserted text>
$
l.3 Results for model_
v2 are shown below.What it means
Some things exist only in maths mode (subscripts _, superscripts ^, Greek letters, \frac), and some things are forbidden there (a blank line, a paragraph). TeX found one of them in the wrong mode and inserted a $ to switch modes, which is almost never what you meant. The rest of the paragraph is then typeset in the wrong mode, so one cause often produces a second Missing $ inserted further on.
Causes and fixes
Most common first. Each example is a complete document; the first fails with this message, the second is the same document fixed.
1. An underscore or caret in ordinary text
In text, _ and ^ must be written \_ and \^{} (file names, variable names, identifiers such as model_v2). For code-like names use \texttt{model\_v2}, or \verb|model_v2| outside other commands' arguments.
\documentclass{article}
\begin{document}
Results for model_v2 are shown below.
\end{document}\documentclass{article}
\begin{document}
Results for model\_v2 are shown below.
\end{document}2. A maths command used outside maths
Greek letters, \frac, \sum, \leq, \infty and other maths symbols must be inside $ … $, \( … \) or a display environment. Write $\alpha$, not \alpha.
\documentclass{article}
\begin{document}
The significance level \alpha was 0.05.
\end{document}\documentclass{article}
\begin{document}
The significance level $\alpha$ was 0.05.
\end{document}3. A blank line inside an equation
A blank line is a paragraph break, which maths does not allow. Remove empty lines inside equation, align, \[ … \] and similar environments; use % on an otherwise empty line if you want visual space in the source.
\documentclass{article}
\begin{document}
\begin{equation}
a = b + c
\end{equation}
\end{document}\documentclass{article}
\begin{document}
\begin{equation}
a = b + c
%
\end{equation}
\end{document}4. A closing $ is missing
If an inline formula is opened with $ and never closed, the paragraph ends in maths mode and TeX inserts the $ at the paragraph break. Look for an odd number of $ signs in the paragraph the error points to.
\documentclass{article}
\begin{document}
We set $x = 2 and continue.
Next paragraph.
\end{document}\documentclass{article}
\begin{document}
We set $x = 2$ and continue.
Next paragraph.
\end{document}5. Maths inside an argument that is typeset as text
Arguments of \text{…}, \mbox{…}, \textbf{…} and table cells of a tabular are text, even inside a formula. A _ or ^ there needs its own $ … $: \text{for $x_i > 0$}.
Finding the line when the line number does not help
- The
l.<n>line breaks exactly after the character that triggered the error: in the log above, aftermodel_. - When the line reported is
\end{document}or the end of a paragraph, the cause is an unclosed$earlier in that paragraph.
In Manulyx
The editor shows the error beside the line with an explanation, and the compile log is parsed into a list of problems so a follow-on Missing $ is easy to tell from the first.
Write in Manulyx for free · Journal templates
More in maths
- Double subscript.Two _ (or two ^) apply to the same symbol, as in x_i_j. Group them with braces: x_{i_j} or x_{ij}, x^{2^3} or {x^2}^3.
- Missing \right. inserted.A \left has no matching \right in the same formula or line, or a \right has no \left. Pair them, or use \right. / \left. as invisible partners.
- LaTeX Error: Bad math environment delimiter.\[ or \( was used inside maths, or \] or \) without its opening. Close one formula before opening the next, and pair each delimiter.
Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors