LaTeX error "Emergency stop": cause and fix
TeX gave up and ended the run without writing a PDF. The message names no cause. The cause is the error directly above it in the log or the note directly below it.
Why it happens
- The file ends without
\end{document}. Below the message the log then says(job aborted, no legal \end found). - A file the document loads does not exist, for example in
\input{chapter1}or\usepackage. TeX would ask for another name; in a run without user input it stops. File `boktabs.sty' not found stands above the message. - A brace is still open at the end of the file. File ended while scanning use of \@xdblarg stands above the message.
\end{document}lies in a block TeX skips, for example behind an\iffalsewithout\fi. See Incomplete \iffalse; all text was ignored after line 4.
How to fix it
- Read the lines directly above and below the message in the log. One of them names the real problem.
- Add
\end{document}as the last line of the main file. - Correct the name or the path of the file that was not found.
- Close the brace or the condition that the error above the message names.
A document that produces the message
\documentclass{article}
\begin{document}
Some text.The corrected document
\documentclass{article}
\begin{document}
Some text.
\end{document}Both documents were compiled with pdfLaTeX from TeX Live 2023. The first produces the message, the second compiles without an error.
Finding the line in the editor
The editor lists every error and warning of a compile run with file and line. Select an entry and the cursor jumps to that line. See Error list with jump to the line.