How can I configure latexmk to run a linter or two such as lacheck or chktex?

1 Answer 1


Add this to the end your .latexmkrc to cause latexmk to run your linters first and then your regularly-specified $pdflatex:

sub run_chktex {
  my $name = shift;
  if ( $silent ) {
    system "chktex -q -v0 $name";
  else {
    system "chktex $name";

sub run_lacheck {
  my $name = shift;
  system "lacheck $name";

sub lint {
  my $fname = shift;
  # lint
  run_chktex $fname;
  run_lacheck $fname;
  return system(@_);

$pdflatex = "internal lint %S $pdflatex";

We use John Collins’ answer here for the bulk of the lint routine and mhp’s question on makeglossaries (answer validated by Collins) for the run_chktex routine (lacheck has no such options).

You must log in to answer this question.

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