46

When pdflatex can't compile a file, it drops me to a prompt. I've never used it and always try to get away from there as quickly as possible, usually generating a q.log file in the process.

Is there any way to avoid this behavior and let pdflatex drop back to command-line on error?

Tim N
  • 10,219
  • 13
  • 63
  • 88
  • 3
    Perhaps the answers to this question: Ignore compile errors will help. – Alan Munn Mar 13 '11 at 17:01
  • 1
    @Alan: Thanks. -halt-on-error (your link) and -interaction=nonstopmode (Martin Scharrer) seems to be what I'm looking for. – Tim N Mar 13 '11 at 17:05
  • 1
    Yes, -halt-on-error exits on error. Exactly what I'm after. Ignoring or not printing errors is not helpful. Especially when make then thinks everything's up to date. I've never used the interactive thing. Imo shouldn't be default. – jozxyqk Feb 15 '14 at 11:53
  • 1
    I don't believe I've ever had a meaningful interaction with latex when it has halted on an error. I'm sure there is much I could do, but I always ^d, modify source, and compile again. – lmat - Reinstate Monica May 01 '20 at 11:43

3 Answers3

44

Use the -interaction=nonstopmode command line argument or the \nonstopmode macro to disable stopping on errors.

Example: pdflatex -interaction=nonstopmode your.tex (note the -interaction flag before the filenames).

Luc
  • 214
Martin Scharrer
  • 262,582
10
-interaction <mode>
    Starts the so-called interaction mode, which can be specified as
    batchmode, nonstopmode, scrollmode or errorstopmode. The meaning of
    these options is the same as for that of the corresponding \commands.

Which is to say that placing \batchmode as the first line in your document would have the same effect.

If you didn’t know about those commands, here’s what they do (from TeX usage tips):

The modes make TeX behave in the following way:

  • errorstopmode stops on all errors, whether they are about errors in the source code or non-existent files.

  • scrollmode doesn't stop on errors in the source but requests input when a more serious error like like a missing file occurs.

  • In the somewhat misnamed nonstopmode, TeX does not request input after serious errors but stops altogether.

  • batchmode prevents all output in addition to that (intended for use in automated scripts). In all cases, all errors are written to the log file (yourtexfile.log).

9999years
  • 433
  • 2
  • 12
9

To drop back to the command line on the first error like gcc (or other compilers do), use:

pdflatex -halt-on-error yourfile.tex