I have bash script that generates several tex files when it is run and then uses latex and dvipdfm to generate a pdf file. The only problem I have is that when something fails latex will halt the process and ask for input on the errors. In this case I am generating more than one pdf and latex is called several times for each one. So I end up with the same errors several times and I have to mash through it.

Since this is being integrated into the build process for something else I would like to find a way to just let the script die with just a single message.

To recap I would like to have latex terminate when there is an error so that when people other than my self run this they are stuck trying to kill this script.

1 Answer 1


Call latex with the -halt-on-error option and the -interaction=nonstopmode option:

 latex -halt-on-error -interaction=nonstopmode file.tex
  • I am absolutely dumb founded that I didn't see this when looking at the latex command, that is exactly what I was looking for. Thanks!
    – Tarmon
    Commented Aug 18, 2011 at 20:28
  • 3
    Actually I would do -interaction=nonstopmode -halt-on-error or -interaction=batchmode -halt-on-error. Using -halt-on-error by itself will still pause for user input in certain situations, such as a missing package.
    – frabjous
    Commented Aug 18, 2011 at 21:14
  • @frabjous Good point, updated my answer accordingly.
    – N.N.
    Commented Aug 18, 2011 at 22:16
  • 3
    An alternative (on UNIX-like machines) is to force LaTeX to read from /dev/null: latex file_name < /dev/null. When LaTeX asks /dev/null to answer some inane question, /dev/null nicely responds with EOF, and LaTeX in turn dies with "Emergency stop!" (and gives a non-zero status to boot, which is very nice for makefiles). Commented Aug 19, 2011 at 1:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .