CorTeX DocsOpen CorTeX
Open CorTeX
Browse all topics

Fix “Missing $ inserted”

Find math syntax in prose or an unmatched delimiter, then repair the first broken math boundary.

On this page

Missing $ inserted means LaTeX met math-only syntax while it believed it was typesetting text, or met text after a math boundary was opened incorrectly. The reported line is often where LaTeX became unable to continue, not where the mistake began.

Inspect the first error#

Open Problems, select the first occurrence, and read backward through the current expression and previous line. Check these boundaries in order:

  1. an opening $, \(, or \[ without its matching close;
  2. a closing $, \), or \] without an opening delimiter;
  3. _, ^, or a math-only command in ordinary prose;
  4. a literal dollar sign that was not written as \$;
  5. text inside math mode that should use \text{...} from amsmath; this can produce incorrect typography even without this particular error.

These lines fail for different reasons:

The value x_1 is larger.        % _ is outside math mode
The price is $5.                % $ opens math mode
The estimate is \(\hat{y}.      % \( has no matching \)
sample_01.csv contains the data. % _ is outside math mode

Write only the intended expression as math and escape literal characters:

LaTeX source
\documentclass{article}
\begin{document}
The value \(x_1\) is larger. The price is \$5.
\end{document}
Compiled result
Open in CorTeX

For the other examples, use \(\hat{y}\) and sample\_01.csv. Inside an equation, write explanatory prose as \text{for treated samples} after loading amsmath; otherwise each letter is interpreted as a mathematical variable.

Repair the smallest boundary#

Do not insert a random $ at the reported location. That may silence the first message while turning a paragraph into italic variables and creating many later errors. Restore one matched pair around the smallest intended expression, then compile again.

If several Missing $ inserted messages disappear together, they were probably a cascade from the same boundary. Continue with the new first error rather than editing every old location. Also check copied URLs, file names, table cells, and captions: underscores commonly enter prose there.

Check that the first error is gone and the surrounding prose and mathematics look intentional in the newest PDF. Use math basics to choose clear delimiters, or return to the broader compile troubleshooting flow if a different first error remains.