[Tex/LaTex] Latexmk: Stop processing on pdflatex error

errorslatexmk

If my tex-files contain an error (such as an undefined control sequence), latexmk will present a prompt and ask for manual input before continuing. Now, of course it is possible to force further processing, e.g. as described here Don't make me manually abort a LaTeX compile when there's an error or here Make latexmk ignore errors and finish compiling.

However, in case of an error I would like Latexmk to stop processing completely and to return to the command line. Is there any way to accomplish this?

Best Answer

I have this in my .latexmkrc:

$pdflatex = "pdflatex -synctex=1 -halt-on-error %O %S"; 

In my case I tend to use -pvc all the time, so here it just stops the compilation if there is an error and go back to waiting for change. You can also use the -interaction=... option.

If I'm not mistaken you can also pass these on to pdflatex via latexmk CLI options

Reading latexmk --help you can actually use latexmk -halt-on-error directly

Related Question