main.log
! Emergency stop means TeX had to stop before it reached \end{document}, and it could not ask
you what to do because the compile runs without a terminal. The line that starts with ***
names the cause. Find it in your log, then use the matching section below.
If your log shows none of these, see any other emergency stop.
Job aborted: no legal end found
The log ends with*** (job aborted, no legal \end found): TeX read the whole main file and never
found \end{document}. Common causes:
\end{document}was deleted, or the file was cut off while it was copied or uploaded.- The main file is empty. This happens when an empty
main.texsits next to the real document. - An environment or conditional was never closed and swallowed the rest of the file. In that case
the log shows a different error first, such as
File ended while scanning use of \@xverbatimfor an unclosedverbatimenvironment, orIncomplete \iffalse; all text was ignored after line 3for an\iffalsewithout\fi. Close that environment or conditional.
Minimal failing example
truncated.tex
Fixed version
Add\end{document} as the last line of the main file:
complete.tex
Ready to use this syntax? Continue in the browser editor when you want to adapt the example in a real project.Open LaTeX Cloud Studio
In LaTeX Cloud Studio, this failure appears in the Problems panel as
The main file ended before \end{document}. If the configured main file is empty and another
.tex file in the project is the real document, LaTeX Cloud Studio compiles that file instead, as
described below.
Job aborted: file error in nonstop mode
TeX could not open the file it was asked to compile, so it never read a line of your document. The terminal output names the file:terminal
texput.log instead of main.log, because TeX never opened your file:
texput.log
- The main file was renamed, or the document has a different name, such as
thesis.texorreport.tex. - The document is in a subfolder, but the compile starts in the project root.
- The name differs only in case. On Linux,
Main.texandmain.texare different files.
\documentclass and \begin{document}, from the folder
that contains it. On the command line, that is pdflatex thesis.tex or latexmk -pdf thesis.tex
in the document’s folder.
In LaTeX Cloud Studio
- If the configured main file, usually
main.tex, is missing or does not contain both\documentclassand\begin{document}, the compiler uses the.texfile that does. It looks at the shallowest folder level first, so an imported project whose document is calledthesis.texcompiles without a settings change. - If two files at the same level both qualify, the compiler keeps the configured main file. Rename or remove the copy you do not compile, so that one root document remains.
- When the main file cannot be opened, the Problems panel shows
The main file could not be opened.
Cannot read from terminal in nonstop modes
A file that the document loads with\input, \include, \usepackage, or \documentclass is
missing. TeX asks for a new file name, gets no answer in nonstop mode, and stops. The real error
is the not found line above the emergency stop:
report.log
report.tex
- Upload the missing file, or correct its name. Names are case-sensitive.
- Write the path relative to the main file’s folder. If the chapter is in
chapters/, use\input{chapters/chapter1}. - If the missing file ends in
.styor.cls, it is a package or class. See missing package errors.
Any other emergency stop
In nonstop mode, an emergency stop is often the last line of a longer failure. Read the log from the top and fix the first error. Errors start with!, or with ./file.tex:LINE: when the
compile uses -file-line-error. On the command line, this prints the first one:
Related pages
- Common LaTeX errors:
Missing $ inserted,Undefined control sequence, and others - Fix “Font unisong not found” in Chinese LaTeX
- Missing package errors
- Large documents: split a project with
\inputand\include - Troubleshooting center
