Is there a way to tell latexmk to run a certain command once it's done compiling everything? I haven't found anything in the documentation. Right now I'm using this latexmkrc:

$pdflatex = 'pdflatex -interaction=nonstopmode -file-line-error -synctex=1 %O %S';
$out_dir = 'build';

The reason I'm asking is because I'm using auctex in conjunction with latexmk, so I'd like the "View" command of auctex to open the pdf ; but for this, the pdf must be in the current directory, not in the build subdirectory. Besides, synctex only works when the synctex file is in the same directory. So I'd like to run something like copy %D . & copy %Z%B.synctex.gz . at the end of the run.

I managed to do it on Linux: I added this line:

$pdflatex .= ' && cp %D %Z%B.synctex.gz .';

but the similar one on Windows fails:

$pdflatex .= ' && copy /y %D . && copy /y %Z%B.synctex.gz .';

This is not an issue with the syntax of the command: when I copy directly in the cmd prompt the command latexmk tells me it runs, it works. So there must be some weird issue.

  • Doesn't the -pvc switch of latexmk do the job in that case ? – Bernard Nov 15 '13 at 21:56
  • @Bernard: Not quite. I'd like to take advantage of synctex features, so for example go directly from a line in AUCTeX to the corresponding line in the viewer. – Najib Idrissi Nov 15 '13 at 22:10

Your Answer

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

Browse other questions tagged or ask your own question.