Skip to main content
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. 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.tex sits 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 \@xverbatim for an unclosed verbatim environment, or Incomplete \iffalse; all text was ignored after line 3 for an \iffalse without \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
The log file is named texput.log instead of main.log, because TeX never opened your file:
texput.log
Common causes:
  • The main file was renamed, or the document has a different name, such as thesis.tex or report.tex.
  • The document is in a subfolder, but the compile starts in the project root.
  • The name differs only in case. On Linux, Main.tex and main.tex are different files.
To fix it, compile the file that contains \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 \documentclass and \begin{document}, the compiler uses the .tex file that does. It looks at the shallowest folder level first, so an imported project whose document is called thesis.tex compiles 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
To fix it:
  • 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 .sty or .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:
In LaTeX Cloud Studio, if the Problems panel cannot classify an error, it shows a Report this problem button. The report includes the end of the compile log, so you do not need to copy it.