[Tex/LaTex] How to use the Vim LaTeX-Suite multiple compile option with BibTeX and the -aux-directory option

auxiliary-filesbibtexcompilingvimvim-latex

I have a document composed of several subfiles and so have used the -aux-directory command to put all of the temporary files in a subfolder, 'auxdir', to keep my working folder clear (and me sane).

I now, however, can't use the multiple compile feature of Vim LaTeX-Suite, presumably because the algorithm it follows (here) will only run BibTeX if it finds a \bibdata line in the aux file, which it can't seem to do if the aux file isn't in the same directory.

The result is that the bibliography isn't compiled at all unless I turn off the -aux-directory option, or unless I manually run BibTeX on the aux file. I'm hoping there's a simpler way someone could point out to me!

Best Answer

There are several tools which can can help you.

arara

The cool tool arara provides several rules to specify all compilation steps from inside the document.

For example you want to compile with pdflatex+bibtex+pdflatex you need the following lines in the preamble of the main document:

% arara: pdflatex
% arara: bibtex
% arara: pdflatex

After this specifications you can compile your document with

arara myfile.tex

Options to the rules can be given too.

% arara: pdflatex: { options: { -aux-directory=auxdir }  }
% arara: bibtex: { files: [auxdir/filename1, auxdir/filename2] }

TrY

Another but equal method is the tool TrY. It works only for Unix systems and instead of rules you can type complete small scripts.

The adapted example from above with TrY is:

%$ pdflatex myfile.tex
%$ bibtex myfile.aux
%$ pdflatex myfile.tex

and the compilation step is:

try myfile.tex