Preamble: Setting the output directories

TeX distros have the useful command line option --output-directory to create all output files in a specified directory.

MikTeX provides an even more convenient option to put only temporary material in a separate folder, which can be eventually deleted, that is:

pdflatex --aux-directory=auxdir mybook 

--aux-directory is particularly convenient for large projects with several TeX files, for example a book with several chapters, to reduce post-compilation clutter.

One can use together --aux-directory and --output-directory. Below I will address --aux-directory, but using --output-directory or both produces the same issue.

Using bibliographies when output/aux directories are diverted

I haven't yet tried them, but I am aware of --input-directory and --output_directory option, which should do similar jobs in biber.

As regards BibTeX, there are no such options. For a simple project, based on a single .tex file (and therefore .aux), depending on your path separator,

bibtex auxdir/mybook 
bibtex auxdir\mybook 

should work. If there are several .tex files (when the aux dir is actually useful), bibtex is unable to find the other aux files, which will still be searched in the project's root dir.

It is possible to cd to auxdir, but in this case the .bib and .bst files will not be found. A workaround consists in copying them in the auxdir. That works, but it is against the purpose of such directory and also time-consuming, as the original .bib file in the parent directory is likely to be updated often.

What is the correct workflow for bibtex and biber when the --aux-directory (--output-directory) option is employed?

  • 2
    Unlike bibtex, biber has an --output-directory flag that handles this properly.
    – ig0774
    Sep 18, 2017 at 12:07
  • 4
    Well my workflow is not to use the --aux-directory and --output-directory switches. While .log, .pdf, .blg are real output files, almost all other files are actually input files, so I find it quite illogical to move them to an output folder. Sep 18, 2017 at 12:13
  • 2
    @UlrikeFischer: Generally, I tend to do like you do, but for a book with several chapters, this is too much stress. Apart from definitions (which are always slippery), folders exist for a reason: organising files when a flat structure doesn't fit.
    – antonio
    Sep 18, 2017 at 13:45
  • 1
    I do find it much more stressing to constantly have to switch a folder to find some file. Sep 18, 2017 at 13:57
  • 1
    Some LaTeX editors have options to delete aux files. e. g. Texmaker Tools --> Clean. This is what I use. May 18, 2018 at 23:03

1 Answer 1


So some suggestions:

1. Don't use --output-directory or --aux-directory

Really. They just add a whole layer of unnecessary complexity. In addition to issues with bibtex, if you have use multiple input files, you'll likely end up having to recreate the same folder hierarchy in the output directory as you have in the main directory. Especially for large, multi-part documents, this can be a hassle for no real added value. Similarly, if you use other external tools, you'll end up needing to configure them to use the output directory appropriately.

2. Use latexmk

This will handle bibtex in an appropriate way and handle the issue with the output hierarchy detailed above. This is probably the simplest way to deal with things, if you insist on using an output directory.

3. A way to make things work

If you still want to use an output directory and don't want to use latexmk, you can do the same thing that latexmk does. From the command prompt, you can run bibtex like this (all one line):

cd auxdir & set BIBINPUTS="C:\path\to\mybook;%BIBINPUTS%" & set BSTINPUTS="C:\path\to\mybook;%BSTINPUTS%" & bibtex mybook

Which runs bibtex in the auxdir, while adding the directory containing the source files to the bib / bst search path.

  • 1
    +1 Especially for 1. --output-directory and friends create much more problems than they solve. Especially new users seem to like the 'use 'build' directory'-like options in editors, but the problems certainly outweigh the advantages.
    – moewe
    Sep 18, 2017 at 13:51
  • +1 thanks. BIBINPUTS solves, but the Windows equivalent of $BIBINPUTS="/path/to/mybook:%BIBINPUTS%" is set "BIBINPUTS=C:\path\to\mybook;%BIBINPUTS%" (quotes needed only with space in the paths). However set is global and not local to batch scripts, so for every call you would add up the same directory. Assuming current dir is mybook.tex dir, then set BIBINPUTS=auxdir & bibtex tex-aux-files\main is sufficient (with relative auxdir path). BSTINPUTS is not necessary. If BIBINPUTS is already defined, one needs a temp var to keep its value or setlocal. Consider fixing!
    – antonio
    May 18, 2018 at 15:40
  • @antonio: you’re right about the semicolons, and I’ve fixed that, but from the CMD prompt, using SETLOCAL instead of SET doesn’t work. Things are different in batch files. You’re also right that BIBINPUTS largely isn’t needed, but it may be in some cases and is pretty harmless in others. Similarly, the excess quotes may not be necessary, but are harmless and ARE necessary if the %BIBINPUTS% variable itself has unquoted spaces (which is perfectly possible).
    – ig0774
    May 18, 2018 at 22:29

You must log in to answer this question.

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