Rules / Build

Missing $ inserted — Math symbol outside math mode

A _, ^ or math command appears in running text, or a formula is not closed, so TeX inserted a $.

Fix

Escape _ as \_ in text, or put the formula inside $…$.

Example

Reproduced on TeX Live 2026 by CI · pdflatex · corpus/underscore-in-text

Underscore in a file name outside math

Fails: main.tex
\documentclass{article}
\begin{document}
\section{Data}
The measurements are stored in output_file.csv next to the scripts.
\end{document}
Fixed
\documentclass{article}
\begin{document}
\section{Data}
The measurements are stored in output\_file.csv next to the scripts.
\end{document}
What TeX prints in main.log
! Missing $ inserted.
<inserted text> 
                $
l.4 The measurements are stored in output_
                                          file.csv next to the scripts.
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

! Missing $ inserted.
<inserted text> 
                $
l.5 \end{document}
…