Skip to main content
! 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. 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.tex beside 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. or Incomplete \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
The transcript goes to texput.log:
texput.log
Common causes:
  • The main file was renamed (for example thesis.tex or report.tex).
  • The file lives in a subfolder while the compile starts in the project root.
  • Letter case differs (Main.tex vs main.tex on Linux).
Compile the .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 \documentclass and \begin{document}, the compiler looks for a unique shallowest .tex file 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
To fix it:
  • 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 .sty or .cls files, see missing package errors. With no not found line, remove interactive \read/\typein prompts.

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):
In LaTeX Cloud Studio, for unknown problems (and in repair recovery), the Problems panel shows a Report this problem button; when a compile record is available, the report can include up to 20,000 characters of log tail. Need a clean starting document that already compiles? Open the Basic Article template in LaTeX Cloud Studio.