! Emergency stop. means TeX stopped the run, and the errors above it and any *** line below it can help you find the cause. Look above Emergency stop. for the first error (see how to find it), then match the *** line after Emergency stop. below.
main.log
None of these? See any other emergency stop.
Job aborted: no legal end found
TeX reached end-of-file without finding\end{document}. Common causes:
\end{document}was deleted or truncated during a copy or upload.- The main file is empty (for example, an empty
main.texbeside your real document). - An unclosed environment or conditional swallowed the rest of the file — check earlier lines for errors such as
File ended while scanning use of \@xverbatim.orIncomplete \iffalse; all text was ignored after line 3., then close that block.
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, the Problems panel shows The main file ended before \end{document}. If the configured main file is empty and another .tex file is the sole root document, LaTeX Cloud Studio compiles that file instead (details below).
Job aborted: file error in nonstop mode
TeX could not open the target file, so it read no lines. Terminal output names the missing file:terminal
texput.log:
texput.log
- The main file was renamed (for example
thesis.texorreport.tex). - The file lives in a subfolder while the compile starts in the project root.
- Letter case differs (
Main.texvsmain.texon Linux).
.tex file containing \documentclass and \begin{document} from its folder — for example pdflatex thesis.tex or latexmk -pdf thesis.tex.
In LaTeX Cloud Studio
- If the configured main file is missing or does not contain both
\documentclassand\begin{document}, the compiler looks for a unique shallowest.texfile that contains both. - If two root candidates tie at the shallowest depth, the compiler keeps the configured file. Move the extra file deeper or remove it from the root candidates.
- 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
TeX stops when it needs terminal input in nonstop mode, for example when a missing\input, \usepackage, or \documentclass file triggers a prompt or the source requests terminal input with \typein or \read on a stream with no open file. Check above Emergency stop. for the first error (such as a not found line):
report.log
report.tex
- Upload the missing file or correct its spelling (names are case-sensitive).
- Write paths relative to the directory where TeX runs — compile from the main file’s folder (LaTeX Cloud Studio runs
latexmk -cd), then use paths like\input{chapters/chapter1}. - For missing
.styor.clsfiles, see missing package errors. With nonot foundline, remove interactive\read/\typeinprompts.
Any other emergency stop
In nonstop mode,Emergency stop. often follows an earlier error. Fix the first error line in the log (starting with ! or ./file.tex:LINE: under -file-line-error):
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
