Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a LaTeX folder where I use the same makefile and preamble for building either a part of the report or the entire report. This is achieved by a hack in the makefile where I substitute the file I want to compile into the preamble (this part works fairly well).

But, whenever I build a document without citations, BibTeX fails, and LaTeX writes a warning saying Empty 'thebibliography' environment on input line 5..

I can avoid this problem by doing a \nocite{DummyCite} and having an entry for dummy cite in my .bib file. However, that's a rather nasty hack, and looks ugly when I have citations.

Is there any way I can figure out if there are citations? Can I do an \ifthenelse against the citation counter? How do I find out what the name of the citation counter is?

share|improve this question

migrated from Apr 3 '11 at 21:48

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 1 down vote accepted

if your <file>.aux does't have any \citation{..} line, then you have no \cite{..} in your document. In this case you should delete an existing <file>.bbl. Then LaTeX gives only a warning about a non existing file, which is not of interest for the LaTeX run.

share|improve this answer
Thanks if grep "\\citation" ./bin/$(*F).aux > /dev/null; then if bibtex -terse ./bin/$(*F).aux; then echo "bibtex: OK"; else echo "bibtex: Failed"; fi; fi Pretty much did the trick... Now I only run bibtex if there was any citations... – jopsen Apr 4 '11 at 11:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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