Is there something like a "post compile hook" for latexmk.

I want to configure latexmk to run some scripts automatically after a compilation process is completed.

1 Answer 1


Yes. Look at the latexmk documentation for the configuration variables $compiling_cmd, $success_cmd and $failure_cmd.

N.B. In response to a comment: The above only work in preview-continuous mode.

  • Thanks. I just tried to add the example from the manual fur $success_cmd but it didn't work. Then I just tried the more simple variant $success_cmd = "okular"; just to start okular for testing purposes after successful compilation, however this also doesn't work. By the way, it says that the pdflatex rule is out of date...
    – student
    Commented Mar 19, 2016 at 21:29
  • Sorry. I forgot those only work in preview-continuous mode. I'll amend my answer. Could you describe in more detail what you want to do. Depending on exactly what your needs are, there may be a way of doing what you want without modifying latexmk. Commented Mar 19, 2016 at 22:18
  • 1
    I have a graphics directory set via texinputs After compiling I want to run a script which creates (or deletes) hardlinks of the pictures used into subdirectory of my project.
    – student
    Commented Mar 19, 2016 at 22:41
  • I ended up using Hook::WrapSub on rdb_make.
    – Michaël
    Commented Jul 12, 2023 at 16:35

You must log in to answer this question.

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