LaTeX error · Math mode
LaTeX Error: Bad math environment delimiter
Quick answer
LaTeX checks that \[ and \( are only used in text mode and \] and \) only in math mode. The error means one of them appeared in the wrong mode: usually a display closed with \[ instead of \], a \[ inside $...$ or an equation, or a stray \] with no opening. Make every \[ end with \] and every \( with \), and never open one inside another math environment.
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.
! LaTeX Error: Bad math environment delimiter.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.4 \[ E = mc^2 \[Why it happens
- A display closed with
\[instead of\], a typo that is easy to miss because the two look alike. - A
\[ ... \]or\( ... \)placed inside anequation,alignor$...$, so math mode is opened twice. - A closing
\]or\)with no matching opening, often left behind after deleting part of a formula. - Using
\[to mean a literal bracket in text, for example after\\at the end of a line (that is\\[...]with an optional length, not math).
How to fix it
Look at the line in the log and match each delimiter to its partner. Display math is \[ ... \], inline math is \( ... \) or $ ... $, and the two kinds must not be mixed or nested.
If the formula is already inside equation or align, delete the extra \[ \] around it: those environments start math mode themselves.
Broken: reproduces the error
\documentclass{article}
\begin{document}
The equation
\[ E = mc^2 \[
holds.
\end{document}Try this in Octree — free LaTeX editor with AI, compiles in your browser
Fixed: compiles cleanly
\documentclass{article}
\begin{document}
The equation
\[ E = mc^2 \]
holds.
\end{document}Related errors
- Missing $ inserted – A math-only symbol (
_,^,\alpha) was used in text, or math mode was left early. - \begin{split} won't work here –
splitused outside a math display; wrap it inequation(or usealign). - Missing \right. inserted – A
\leftdelimiter without its\right, often split across lines of align. - All LaTeX errors and warnings – The full list, grouped by cause
Frequently Asked Questions
What is the difference between \[ \] and $$ $$ in LaTeX?
Both produce display math, but \[ ... \] is the LaTeX form: it checks that it is opened and closed correctly and gets the vertical spacing right. $$ ... $$ is plain TeX, gives no such check and can produce inconsistent spacing, so prefer \[ \] or the equation* environment.
Can I put \[ \] inside an equation environment?
No. equation, align, gather and similar environments already switch to math mode, so a \[ inside them opens math a second time and causes this error. Remove the inner delimiters.
How do I find which delimiter is wrong?
The l. line in the log shows where LaTeX noticed the problem, normally the delimiter itself. Check the formulas just above it as well: a missing \] earlier leaves LaTeX in math mode, and the next \[ is then the one reported.
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 →