# Handling LaTeX errors

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.

-

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

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 Aug 18 '11 at 21:14
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). – David Hammen Aug 19 '11 at 1:19