LaTeX error · Commands, braces and arguments

Missing } inserted.

Quick answer

TeX had an open { group when it reached a point where the group must already be closed, such as the closing $ of a formula, so it inserted a } itself. Look for an unbalanced brace near the line shown in the log, typically in a subscript, a superscript or a group like {\bf ...}, and add the missing } where it belongs.

The error in the log

This is how the message appears in the .log file (and in the compile output). The line starting with l. is the line number where TeX noticed the problem; the real mistake is there or just before it.

! Missing } inserted.
<inserted text> 
                }
l.5 The term $x_{i$
                  grows with $i$.

Why it happens

  • An unclosed brace in a formula: $x_{i$ or $e^{-x$. (If the open brace belongs to a command argument such as \frac{a}{b, TeX keeps reading and reports File ended while scanning use of \frac instead.)
  • A brace opened in one table cell or align column and closed in the next one, across &.
  • Verbatim material (verbatim, lstlisting) inside a command argument or a Beamer frame without the [fragile] option.
  • A brace opened inside \left( ... \right) and not closed before \right, as in \left( x_{i \right).

How to fix it

Count the braces in the formula on the reported line and close the open group before the formula ends. Editors that highlight matching braces make this quick.

If you meant to print a brace, escape it: \{ and \}.

Broken: reproduces the error

\documentclass{article}

\begin{document}

The term $x_{i$ grows with $i$.

\end{document}

Try this in Octree — free LaTeX editor with AI, compiles in your browser

Fixed: compiles cleanly

\documentclass{article}

\begin{document}

The term $x_{i}$ grows with $i$.

\end{document}

Related errors

Frequently Asked Questions

Why does LaTeX insert a } on its own?

TeX tries to recover so it can continue. When a group has to end, for instance at the end of a formula, it adds the missing } and reports it. The output after that point may still be wrong, so fix the source.

I get Missing } inserted in a Beamer frame with code. Why?

Frames that contain verbatim or lstlisting need \begin{frame}[fragile]. Without it Beamer reads the frame as an argument and the special characters break the brace structure.

How do I find an unbalanced brace in a long document?

Start from the line number after l. in the log. If that does not help, comment out half of the document at a time until the error disappears; the problem is in the half you removed last.

Paste your document into Octree — compile errors get a Fix with AI button

When a compile fails, Octree shows the error next to the line that caused it and offers a one-click fix that you can review before applying. Free, nothing to install.

Fix it in Octree →