# Don't show bibliography heading if there aren't any citations

We use LaTeX to generate PDF documents dynamically from the web. Sometimes reports have bibliography citations, and sometimes they don't.

At the end of our LaTeX document, we have a bibliography block, where all citations are automatically listed (we use BibTeX). But what we want to avoid is to show the bibliography heading when it is empty (with no bibliography entries).

Our actual solution is to add the bibliography block also dynamically, after searching for citations in the final document text, and ensuring that we have, at least, one citation.

Is there another way to do that with LaTeX? I'm thinking about some bibliography block setting or something like this ...

• may be just remove \bibliography{bibfile} when there are no bibliography entries why use it anyway. – texenthusiast Feb 13 '14 at 14:49
• – texenthusiast Feb 13 '14 at 14:56
• This might be easier with biblatex, which separates loading the bibliography database from printing it. – jon Feb 13 '14 at 16:43

As jon has suggested in a comment, this is yet another reason to use biblatex. Compare the output of the following two examples -- note that \printbibliography (a biblatex-specific command that replaces \bibliography) is present in both examples.

\documentclass{article}

\usepackage{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
\end{filecontents}

\begin{document}

Some text \autocite{A01}.

\printbibliography

\end{document}


\documentclass{article}

\usepackage{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
\end{filecontents}