# Defining -aux-directory for pdflatex breaks citations for natbib

When I run pdflatex with an -aux-directory flag it makes it so natbib can't find the citations.

pdflatex command with -aux-directory:

pdflatex.exe -synctex=1 -interaction=nonstopmode %.tex -aux-directory=auxillary


and without:

pdflatex.exe -synctex=1 -interaction=nonstopmode %.tex


When I run it with -aux-directory, no bbl file is generated, the references page is missing, and the log shows a long sequence of errors like the following:

Package natbib Warning: Citation Altman2006' on page 1 undefined on input line


When I run it without -aux-directory, then everything is fine.

Has anyone else experienced this problem?

MWE:

PhD_Thesis.tex

\documentclass[11pt,twoside,a4paper]{article}

\usepackage[round,authoryear]{natbib}
\begin{document}

Bibtex test: \citet{Card1999}

\bibliographystyle{apalike}
\bibliography{PhD_Bibliography}
\end{document}


PhD_Bibliography.bib

@INCOLLECTION{Card1999,
author = {David Card},
title = {The Causal Effects of Education on Earnings},
booktitle = {Handbook of Labour Economics},
year = {1999},
editor = {O. Ashenfelter and David Card},
volume = {3},
pages = {1801-1863},
publisher = {Elsevier Science B.V},
chapter = {30}
}

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jan 1 '15 at 18:30
• Sorry, but I would have a pretty tough time making a MWE from my environment, based on my expertise. I am using a thesis template with few modifications: danielgillis.wordpress.com/other/latex Feel free to downvote it if you think it's not helpful as-is. – roboreb Jan 1 '15 at 18:44
• @roboreb But can you create a different MWE that reproduces this problem, i.e. if you only load the natbib package and try a test citation, does the same problem happen? – darthbith Jan 1 '15 at 18:50
• @roboreb:I have no inclination to downvote it... but other's are perhaps not so 'graceful'. Please try to add a MWE, as darthbith and I have asked already – user31729 Jan 1 '15 at 18:57
• Alright, I added an MWE that seems to be working (and not working, depending on the pdflatex command) for me. – roboreb Jan 1 '15 at 19:12

If your thesis is a single file (which is somehow unlikely) it is enough to append your bibtex command with ./auxillary/%.

Else, I've written a bash script shared in this answer but it's for linux environments. However you can copy the working in a bat file for windows:

• first, the script needs to go into the aux folder
• run bibtex on the main aux
• copy the generated bbl file to all chapter filenames (eg main.bbl, chapter1.bbl, etc)

That's it, call the script instead of bibtex. Also, (that probably isn't a problem with -aux-directory, but one with -output-directory) if each chapter is in its own dedicated folder, you need to copy the folder structure into the build folder (here 'auxilliary').

• Unfortunately changing the bibtex command from "bibtex.exe %" to "bibtex.exe auxillary/%" didn't work - natbib is throwing the same errors. (My thesis isn't a single file, but the bibliography is). – roboreb Jan 2 '15 at 16:26
• my mistake: bibtex ./auxilliary/% – luneart Jan 2 '15 at 16:32
• Still not working. :/ – roboreb Jan 2 '15 at 16:39
• that path works for me with TeXmaker on a linux system. I'm guessing the trouble here comes from the syntax differences between linux and windows... Have you tried bibtex .\auxilliary\<filename>, bibtex auxilliary\<filename>` ? – luneart Jan 2 '15 at 16:48
• The wildcard doesn't seem to be the issue, since it was "bibtex %" by default. – roboreb Jan 2 '15 at 16:56