I use .latexmkrc
in my project folders, and then I compile from the command line. Here is how my latexmkrc file looks like:
This solution will create the temp and build folder if it doesn't exist and you can have these on a per project basis. (by using the file .latexmkrc in the project folder)
ensure_path('TEXINPUTS', './some/paths//'); # "//" searches recursively
$clean_ext = 'aux, fdb_latexmk, fls, out, xdv'; # files to clean
#$pdflatex = ""; # add your chain here.
$pdf_mode = [..]; # see latexmk documentation for your os
$pdf_update_method = [..]; # see latexmk documentation for your viewer.
$pdf_previewer = 'start "some/pdf/viewer" %O %S'; # If you use the -pvc switch
sub latex_fix_aux {
my @move_exts = ('dvi', 'fls', 'pdf', 'ps', 'synctex.gz' );
my $auxD = '';
my $outD = '';
foreach (@_) {
if ( /^-{1,2}aux-directory=(.*)$/ ) {
$auxD = $1;
}
elsif ( /^-{1,2}output-directory=(.*)$/ ) {
$outD = $1;
}
}
if ( $outD eq '' ) { $outD = '.'; }
if ( $auxD eq '' ) { $auxD = $outD; }
my @args_act = ();
my $set_outD = 0;
foreach (@_) {
if ( /^-{1,2}(aux|output)-directory=.*$/ ) {
if ( ! $set_outD ) {
push @args_act, "-output-directory=$auxD";
$set_outD = 1;
}
}
else {
push @args_act, $_;
}
}
my $outD1 = $outD;
my $auxD1 = $auxD;
foreach ( $auxD1, $outD1 ) {
if ( ($_ ne '') && ! m([\\/\:]$) ) {
$_ .= '/';
}
while ( s[^\.\/][] ) {}
}
print "Running: '@args_act'\n";
my $ret = system @args_act;
if ($auxD ne $outD) {
print "Move @move_exts files from '$auxD' to '$outD'\n";
foreach my $ext (@move_exts) {
copy "$auxD1$root_filename.$ext", "$outD1$root_filename.$ext";
unlink "$auxD1$root_filename.$ext";
}
}
return $ret;
}
$out_dir = '.build/'; # pdf and fls etc. goes here.
$aux_dir = '.temp/'; # other aux files goes here
Then I usually run latexmk in live mode like this:
latexmk -pvc -jobname=projectName
Which will start latexmk in live mode (continuous compile on save) and the files will be named projectName.pdf etc.
output-directory
. If you put the auxiliary files to a non-standard place you will have to configure every additional tool to look there and this not easy, you can find quite a lot questions from people having various problems with it.latexmk -outdir=aux -pdf filename
where filename is your.tex
file. This creates anaux
directory and puts both auxiliary and final output file there. When you're done you can justcp aux/*.pdf ./
.