I am using vscodium with the LaTeX Workshop package and the TeXLive 2023 distribution in vscodium on linux to write latex documents. I want to keep my directories clean while preserving the accelerated computing that latexmk offers (inspired by this reply).

Would the correct way to do this be to create a .latexmkrc in my home directory with the contents below?

$pdf_mode = 1;
$pdflatex = 'latexmk -outdir=/tmp/latexmk -f -pdf %F; mv %f /tmp/latexmk; mv /tmp/latexmk/%b.pdf %o;'

Alternatively, would it also be possible to just use the --aux-directory flag to avoid moving around the files so much? I tried 'pdflatex --shell-escape -interaction=nonstopmode --aux-directory=/tmp/latexmk', but it didn't seem to do anything.

1 Answer 1


Before doing anything else, read the latexmk documentation: for the -auxdir, -emulate-aux-dir, and -outdir options, for the corresponding configuration variables $aux_dir, $emulate_aux, and $out_dir, and the section 'AUXILIARY AND OUTPUT DIRECTORIES'. In principle, these have all the information you need.

The method proposed in the question for configuring latexmk was copied from an answer for configuring emacs, and is entirely wrong for configuring latexmk. (In addition, the answer about configuring emacs is out-of-date: It's from a time before latexmk supported the -auxdir option with TeXLive.)

To get the effect you need, just put the following in a .latexmkrc file:

$pdf_mode = 1;
$emulate_aux = 1;
$out_dir = '.';
$aux_dir = '/tmp/latexmk';
  • Thank you so much. I really appreciate your help. I used that emacs configuration reply because I used that for org mode and really liked the result. I will read the docs to get a better sense of the configuration options.
    – user41177
    Sep 6, 2023 at 18:50

You must log in to answer this question.

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