Run pdflatex quietly

NomeN picture NomeN · Jun 24, 2009 · Viewed 38.2k times · Source

I'm calling pdflatex from within my (C++) program using system(), needless to say all the garbage pdflatex puts on screen is a bit irritating in this case.

So...how do I encourage pdflatex to forego the lengthy outputs? It would be even better if only errors would be visible...

Answer

Will Robertson picture Will Robertson · Jun 26, 2009

Unfortunately (La)TeX doesn't really abide by the rules of stdout and sterr, owing (I assume) to its origins in the early 80s. But there are some switches you can invoke to alter the amount of information being shown.

Execute latex with either the -interaction=nonstopmode or -interaction=batchmode switches for non-halting behaviour even in the case of a syntax error. nonstopmode will print all usual lines, it just won't stop. batchmode will suppress all but a handful of declarative lines ("this is pdfTeX v3.14...").

These can also be invoked from within the document with \batchmode and \nonstopmode, but this is less useful for the situation you're describing.