Specify -output-directory when using latexmk

As announced at Use MiKTeX option through latexmk, I've made a new version of latexmk, which supports -output-directory. It's v. 4.27a and can be found at http://www.phys.psu.edu/~collins/latexmk/versions.html (It'll be on CTAN soon.)

Just use the following settings in your latexmkrc file

$pdflatex="pdflatex -interaction=nonstopmode %O %S";
$out_dir = 'build';

You can use latexmk's -jobname option like this:

latexmk -pdf -jobname=/path/to/new/output/newfilename currentfile

and all of the output files will be routed to the directory specified and given the basename 'newfilename'. E.g., all the files associated with processing currentfile.tex will now be in output/ and be called newfilename.pdf, newfilename.bbl, etc.


As of Dec. 2011 with both MiKTeX and TeXLive you can use

-outdir=FOO or -output-directory=FOO

like so:

latexmk -output-directory="../out"

Source: http://mirrors.ctan.org/support/latexmk/latexmk.pdf