I would like to have latexmk to fail on undefined references/citations. My initial thoughts were to accomplish this by checking the final output for "Reference ... undefined" warnings and exiting with non-zero status.

  • 2
    I think that although your question is well defined you should nonetheless give a MWE that does not exit with the non-zero status. – A Feldman Jan 18 '18 at 16:27
  • 3
    I guess part of the problem is that latexmk is designed to be run repeatedly until the references and citations are all resolved. So which run do you want your "fail" to happen? 1st run, 2nd run, 3rd run... Maybe a different tool would be a better choice. – A Feldman Jan 18 '18 at 16:44
  • Arara sounds like what you might use for this ctan.org/pkg/arara?lang=en – A Feldman Jan 18 '18 at 18:07
  • 1
    @AFeldman Not really. Solutions might look different for documents with thebibliography, \bibliographystyle{} and \usepackage{biblatex} and the last also has the choice of backend, which again affects what information might be available from the console output. Of course, you no doubt could write a script to detect which situation applies, but, if so, that too should be made clear in the question. – cfr Jan 19 '18 at 2:49
  • 2
    Is this about cross-references and citations or only citations? Or cross-references to or from citations? Or all of the above? – cfr Jan 19 '18 at 2:50

I've just added this possibility to latexmk. A new version 4.55a is now available for testing from http://personal.psu.edu/jcc8/latexmk/versions.html For details, see the documentation for the option -Werror and for the configuration variable $warnings_as_errors. When the option -Werror is used, warnings about undefined references or citations or multiply defined references result in a non-zero status code (indicating an error) being returned by latexmk to the operating system. The warnings are those on the last run of (pdf)latex, when for an error-free document all references and citations should have become defined.

In addition, I've given a way for getting a visual indicator in preview-continuous mode for these same warnings about references and citations. See the documentation for the variables $compiling_cmd, $failure_cmd, $warning_cmd, and $success_cmd. I find this addition very useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.