Sarmate.net Sarmate.net
Home Features Pricing Documentation Contact
Log in Sign up

Missing $ inserted: what this LaTeX error means (and how to fix it)

This error is almost always the same thing: you used a math symbol outside math mode. LaTeX "repairs" it as best it can and reports "Missing $ inserted" — a $ is missing.

Symbols reserved for math — _ (subscript), ^ (superscript), \alpha, \frac… — only make sense between two $. In plain text, they trigger the error.

This code fails:

LaTeX
\documentclass{article}
\begin{document}
The derivative of x^2 is 2x.   % x^2 in plain text -> Missing $ inserted
\end{document}

Wrap the math expression in $ … $:

LaTeX
\documentclass{article}
\begin{document}
The derivative of $x^2$ is $2x$.
\end{document}
The reflex As soon as you want a subscript (_) or superscript (^), you're in math — wrap it in $.

Try it yourself

This example compiles. Remove the $ around x^2 and recompile to see "Missing $ inserted".

The method

  1. Read the reported line: look for _, ^ or a math command outside $.
  2. Wrap the expression in $ … $ (or \( … \)).
  3. For a displayed formula, use \[ … \].
  4. Want a literal character (_, %, &, #)? Escape it with a backslash: \_, \%
sarmate.net tip Our online editor reads the compilation log and tells you the likely cause in plain words, so you unblock without guessing.

An AI can fix the error — directly in your code

AI assistants (Claude, Gemini, ChatGPT…) know LaTeX very well: describe the error message and they explain the cause with a fix. The usual drawback is the back-and-forth — copying your code to the AI, then pasting its answer back into the editor.

sarmate.net removes this round-trip with its MCP server: you connect the AI directly to your online editor. It reads your files, compiles them, analyzes the error log and fixes the code in place, with no copy-paste. You stay in control: nothing is changed without your approval.

Write and compile LaTeX online

Full editor, instant compilation (pdfLaTeX/XeLaTeX/LuaLaTeX), nothing to install.

Open the online editor