[Tex/LaTex] How to one stop LaTeX compilation

compilinglinux

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?

Best Answer

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.

enter image description here

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.

enter image description here

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.

Additional but Helpful

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.