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 bibitem
s 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:
\documentclass{book}
\begin{document}
The device \cite{Vikas01} is special \cite{Bernard03}.
\bibliographystyle{ieeetr}
\bibliography{refs}
\end{document}
The content of the bib file is:
@BOOK{Bernard03,
AUTHOR={Bernard Desgraupes},
TITLE={{\LaTeX}, {A}pprentissage, guide et r{\'e}f{\'e}rence},
PUBLISHER={Vuibert},
YEAR={2003},
address={Paris},
edition={second},
month={mar}}
@INPROCEEDINGS{Vikas01,
AUTHOR={Kawadia, Vikas},
TITLE={Protocols for Media Access Control and Power Control in Wireless Networks},
BOOKTITLE={40th IEEE Conference on Decision and Control},
YEAR={2001},
month={mar}}
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.
[1
] (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?
Best Answer
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.Therefore,
should be used, where
main_tex_file
is of course without the.tex
at the end.