# How can one stop LaTeX compilation?

When I start to compile a TeX file with wrong syntax, LaTeX complains. The first thing that I try is to stop (kill) the LaTeX compilation. However, nothing works. I have tried Ctrl+C, Ctrl+q, quit, exit, q, quit()... At the end I need to use top-command from Linux to kill the process. Is there a civilized way to kill LaTeX?

• Which editor you are using? It will have some options.
– user11232
Nov 28, 2013 at 7:15
• With most command-line programs, EOF (ctrl+d) is normally a good first guess
– sapi
Nov 28, 2013 at 12:29
• On windows, Ctrl-Z will normally work.
– Dan
Nov 28, 2013 at 20:47
• In TeXnicCenter (under Windows) it allows you to stop a build.
– Werner
Nov 29, 2013 at 0:55

Personal Statement

I am a command-line human and (blissfully) ignorant of LaTeX IDEs (front ends) and editor specific compilations. I do my typing in emacs using AUCTeX, and compile in a terminal. So, my answer is focused in the command-line area.

The Solution

Actually, there is a civilized way to kill LaTeX, as asked by you.

Enter x at the prompt, then press Enter. Pressing Ctrl-d may be even faster. Most terminals send en end-of-file with this keystroke, which makes LaTeX react in the same way as if x was entered.

(The above two are not exactly identical. In case of x, LaTeX will tell about, "No pages of output...". In case of Ctrl-d, it will be treated as, "Emergency stop. .... Fatal error". I wish I could be more specific about the nuances of these two.)

Consider the following example. I have intentionally introduced a syntax error in my file.

LaTeX stops and complains about "Undefined control sequence". I type x and then press Enter. There is a clean exit.

If I press Ctrl-d under a similar situation, there is again an exit, with slightly different messages.

If you want to know more about your available options, enter ? while in the LaTeX prompt and press Enter. This gives,

? ?
Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, E to edit your file,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.


Additionally, learning the following helps (may be Linux/command line specific).

• To interrupt a long compilation, press Ctrl-c, that gives you the prompt mentioned above.
• If LaTeX is waiting for an input file which does not exist,
! I can't find file nosuchfile.tex'.
l.5 \input nosuchfile.tex

(Press Enter to retry, or Control-D to exit)
Please type another input file name:


press Ctrl-d.

• Front ends (or IDE, if you prefer) usually call the typesetting engine with the --interaction=nonstopmode command line option (or equivalent method). Nov 28, 2013 at 16:52
• x+Enter works for Notepad++ too! This has bugged me forever Nov 29, 2013 at 0:35

If you run pdflatex as

pdflatex -halt-on-error file.tex


it will stop after the first error.

I'm late to the party, but I was wondering the same thing and found this answer in my search, so I thought I'd post it.

If you're using AUCTeX, the command TeX-kill-job is what you need. By default it's bound to C-c C-k`.