[Tex/LaTex] Use MiKTeX option through latexmk

auxiliary-fileslatexmkmiktexoptions

When I use MiKTeX normally, I call this:

pdflatex --aux-directory="C:\Users\doncherry\Documents\LaTeX\AUXI_global" foo.tex

For latexmk outputting pdf (via pdfLaTeX) with continuous previewing, my attempt is

latexmk -pvc -pdf foo

with a file in the same directory called latexmkrc (see p. 9 of the manual), containing

$pdflatex = 'pdflatex --aux-directory="C:\Users\doncherry\Documents\LaTeX\AUXI_global" %O %S';
$pdf_previewer = 'start "C:\Program Files (x86)\SumatraPDF\SumatraPDF.exe" %O %S';

This doesn't work, latexmk just runs pdflatex once and the table of contents isn't generated. Latexmk produces the error message:

Latexmk: Errors, so I did not complete making targets
Latexmk: (Pdf)LaTeX failed to generate a log file

How can I use the --aux-directory option through latexmk?

Best Answer

I've made a new version of latexmk, which supports -aux-directory and -output-directory. It's v. 4.27a and can be found at

http://www.phys.psu.edu/~collins/latexmk/versions.html

This version will be submitted to CTAN fairly soon, but some feedback would be useful, since I have not tested the new features extensively, especially as I don't have current access to MiKTeX or a more recent one can be found on CTAN as well.

Latexmk now has options -auxdir, -aux-directory, -outdir, and -out-directory, plus corresponding configuration variables $aux_dir and $out_dir. See the documentation for more details. To achieve what the original poster wanted, it's sufficient to put

$aux_dir = 'C:/Users/doncherry/Documents/LaTeX/AUXI_global';

in a latexmkrc file. (I've used forward slashes in directory names since these are acceptable to MS-Windows, and avoid running afoul of quoting conventions.)

I've done some tests with the -output-directory option, and the only problem that needs sorting out is that the combination of biblatex with bibtex doesn't work because a file needed by bibtex isn't in its usual place. (Biblatex with biber works, as do ordinary uses of bibtex.) If you don't use biblatex, the last issue doesn't affect you.

Related Question