[Tex/LaTex] Adding custom build step to latexmk sequence

latexmk

I wonder if I can run, say, a shell script before actually starting latexmk routine?

I've found compiling_cmd, but it doesn't seem to work for me.

I can write custom shell script to call anything I want in any order, of caurse, but I'd be pleased to find native latexmk solution.

Just in case there's another solution: I have several .dia files which are exported to png in order to insert them as figures. My script just forces Dia to update those png's.

The reason why I'm looking for latexmk solution is that I'm using texstudio which is configured to run latexmk by default, so I don't want to have unique build command for one of my documents.

Best Answer

John Collins suggested to use "custom dependency" functionality. Despite the fact I wasn't able to make custom dependency working for my case, it lead me to solution. I've appended following code to my latexmkrc file:

sub dia2png{ 
    system("bash ./diaGen.sh"); 
} 
dia2png();

So latexmk basically allows you to define and run anything before starting actual compilation process. But if you're trying to implement something more complicated, them your choice is custom dependencies.

Related Question