3

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}
}
roboreb
  • 153
  • 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}. –  Jan 01 '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:

    https://danielgillis.wordpress.com/other/latex

    Feel free to downvote it if you think it's not helpful as-is.

    – roboreb Jan 01 '15 at 18:44
  • 1
    @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 01 '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 –  Jan 01 '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 01 '15 at 19:12
  • To notify other users, “tag” them with @<username> (like @roboreb), otherwise they won't notice your reply. – Pier Paolo Jan 01 '15 at 19:14
  • You should adapt the bibtex call so that it can find the aux-file. – Ulrike Fischer Jan 01 '15 at 23:09
  • @UlrikeFischer How would I do that? – roboreb Jan 02 '15 at 01:00
  • Try something like bibtex auxiliary/%.aux in the configuration of your editor. – Ulrike Fischer Jan 02 '15 at 08:00
  • @UlrikeFischer Unfortunately that didn't work. – roboreb Jan 02 '15 at 16:27

1 Answers1

0

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').

luneart
  • 534
  • 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 02 '15 at 16:26
  • my mistake: bibtex ./auxilliary/% – luneart Jan 02 '15 at 16:32
  • Still not working. :/ – roboreb Jan 02 '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 02 '15 at 16:48
  • The wildcard doesn't seem to be the issue, since it was "bibtex %" by default. – roboreb Jan 02 '15 at 16:56
  • Yep, I meant reverse the slashes ;) The wildcard replacement was just that as long as it doesn't work, you don't need extra stuff happening... – luneart Jan 02 '15 at 17:05
  • Oh, ya I tried that also since I had a similar hunch, but still no dice... it still doesn't generate a .bbl file. – roboreb Jan 02 '15 at 17:09
  • What I'm doing for decades on windows (miktex) seems to be the opposite : my compile script (.bat) for bibtex starts by copying the .bib file from working directory (where main file is) into auxiliary directiry and then runs bbtex on the main aux file created by pdflatex in this directory. By this method you don't need in any way to edit your files or include the path to bib file. The single crequirement is to have two "tools" for bibtex in your editor : one for regular run and another which calls this script. Adding the working ditectory to BIBINPUTS is an alternative (not tested). – Jhor Jul 28 '22 at 07:41