Thinking of classical programming languages, many compilers support error levels. Error levels let one specify the severity at which the compile process halts. This is very handy. Once a project comes to an end, I typically enable a very pedantic error level, such that I can make sure that what I contribute is really free of all errors.

I am wondering is there something similar for Latex? To give an example, I would find it desirable if there was a flag that halts compilation on undefined references, rather than having to forge my entire document for ???.


I ended up using the accepted answer. Since references aren't present on the first run, I added a \pedantic flag to my Makefile.

$(FILE)_pedantic.pdf: *.tex
    pdflatex -synctex=1 -shell-escape "\def\pedantic{0} \input{$(FILE).tex}"
    pdflatex -synctex=1 -shell-escape "\def\pedantic{0} \input{$(FILE).tex}"
    bibtex $(FILE)
    makeglossaries $(FILE)
    pdflatex -synctex=1 -shell-escape "\def\pedantic{0} \input{$(FILE).tex}"
    pdflatex -synctex=1 -shell-escape "\def\pedantic{1} \input{$(FILE).tex}"

My root.tex file then sets


as suggested by the author of the accepted answer.

  • 4
    LaTeX has error messages (where compilation can hang), warnings, and a log file that summarises how many errors, warnings, unresolved references you have.
    – Johannes_B
    Commented Nov 18, 2019 at 17:02
  • That is absolutely correct, but after all, doesn't address the question (my bad if i was unclear). I am wondering whether there is a specific option that will halt compilation on a specific "warning level".
    – Flo Ryan
    Commented Nov 18, 2019 at 21:07

1 Answer 1


A simple solution to this problem is to redefine LaTeX's \GenericWarning macro with the more severe \GenericError:



See section \ref{foo} ...

... and section \ref{bar}.

LaTeX will then report the first warning as normal but stop compilation on the second one:

LaTeX Warning: Reference `foo' on page 1 undefined on input line 11.

! LaTeX Warning: Reference `bar' on page 1 undefined.

Type  H <return>  for immediate help.
  • 1
    This did it! Thanks!
    – Flo Ryan
    Commented Nov 18, 2019 at 21:48
  • 2
    It might be worth pointing out that compilation will actually stop only if the job is being run interactively. Most compilations run from scripts will use batch mode. Also, references will always be unresolved on the initial run, so a check for unresolved references isn't really helpful until after BibTeX (or equivalent) has been run. Obviously the OP is aware of this, but new LaTeX users might not be. Commented Nov 19, 2019 at 16:38
  • This is true. I added a suggestion to my initial question.
    – Flo Ryan
    Commented Nov 20, 2019 at 11:17

You must log in to answer this question.

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