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:
\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 $ … $:
\documentclass{article}
\begin{document}
The derivative of $x^2$ is $2x$.
\end{document}_) 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
- Read the reported line: look for
_,^or a math command outside$. - Wrap the expression in
$ … $(or\( … \)). - For a displayed formula, use
\[ … \]. - Want a literal character (
_,%,&,#)? Escape it with a backslash:\_,\%…
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