I often use the out-of-source compilation on my LaTeX code to separate the generated files from the source files, thus I can conveniently commit my code to the repository. The command is like this:

pdflatex -c-style-errors -include-directory=dir_of_source_files -output-directory=dir_of_generated_files -aux-directory=dir_of_aux_files main_tex_file.tex

As the options indicated, the generated files are well managed by the compiler. Recently, I turn to bibtex to manage my bibliography instead of typing the bibitems directly in a tex file. And I would like to use the workflow as above - to put the generated file into another directory. As a result, I failed. This is the test snippet:

The device \cite{Vikas01} is special \cite{Bernard03}.

The content of the bib file is:

  AUTHOR={Bernard Desgraupes},
  TITLE={{\LaTeX}, {A}pprentissage, guide et r{\'e}f{\'e}rence},

  AUTHOR={Kawadia, Vikas},
  TITLE={Protocols for Media Access Control and Power Control in Wireless Networks},
  BOOKTITLE={40th IEEE Conference on Decision and Control},

And my compilation commands are:

pdflatex -c-style-errors -include-directory=dir_of_source_files -output-directory=dir_of_generated_files -aux-directory=dir_of_aux_files main_tex_file.tex
bibtex -include-directory=dir_of_aux_files main_tex_file

Then the prompt comes out:

I couldn't open file name 'refs.aux'

And there is also a suspicious warning in the log file:

LaTeX Warning: Citation `Vikas01' on page 1 undefined on input line 5.

LaTeX Warning: Citation `Bernard03' on page 1 undefined on input line 5.

No file testbib.bbl.
] (d:\tex\bin\testbib-shadow\au\testbib.aux)

LaTeX Warning: There were undefined references.

I guess that the compiler failed to generate the .bbl file. How to fix this problem?

  • Welcome to TeX.sx! I ran your example and it worked without errors or warnings. I used pdfTeXify in WindEdt+MiKTeX. Did you run the required number of times? The warnings you get are typical from the first run where the files required for proper formatting are generated. – Peter Jansson Jan 25 '13 at 10:35
  • @PeterJansson Thanks for your help! Then you're testing the snippet in an IDE while my target is to do it in the windows command line and compile it out-of-source, or you can call it shadow build. – stoneyang Jan 25 '13 at 10:47

bibtex does not have a -include-directory switch, so it has to see the .aux file of your document in the directory where it is invoked.


bibtex dir_of_aux_files/main_tex_file

should be used, where main_tex_file is of course without the .tex at the end.

| improve this answer | |
  • It is just a slightly modification to enable that. But what I want to add is that bibtex does have a -include-directory switch although it doesn't work well on my machine with Windows 7 Ultimate 64-bit and MikTex-BibTeX 2.8.3581 (0.99c). :) – stoneyang Jan 25 '13 at 11:22
  • @stoneyang Interesting. I too have version 0.99c, and I swear it has no -include-directory switch. But I use Linux, so maybe the MiKTeX people patched bibtex. – mafp Jan 25 '13 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.