I have a general and central preamble for a lot of similar-style documents (several dozens) and most of the documents have a Bibliography at the beginning, so I call
\bibliographystyle{alphadin}
\bibliography{refs}
in the central preamble to avoid a lot of duplicate code and to be able to change the bibliography style centrally. But sadly, a minority of these documents has an empty bibliography. And these give me a warning about an empty thebibliography environment. But the bigger problem is: the bibliography headline still appears in the pdf output.
Is there a way to only get the bibliography headline and no warning when there is a non-empty bibliography? What would be the correct counters or booleans to address? Or is there an easy-to-use option?
Minmal example:
\documentclass{article}
\begin{document}
\bibliographystyle{alphadin}
\bibliography{test}
\end{document}
Run latex, bibtex, latex, latex. Get for test.bbl
LaTeX Warning: Empty `thebibliography' environment on input line 10.
Entering the "patch" doesn't solve the problem. What I want ist: If there's no \cite{} within the document, don't display the bibliography.
Content of bbl:
\begin{thebibliography}{}
% this bibliography is generated by alphadin.bst [8.2] from 2005-12-21
\providecommand{\url}[1]{\texttt{#1}}
\expandafter\ifx\csname urlstyle\endcsname\relax
\providecommand{\doi}[1]{doi: #1}\else
\providecommand{\doi}{doi: \begingroup \urlstyle{rm}\Url}\fi
\end{thebibliography}
\bibliography{refs}
in the preamble of any of your documents. This instruction belongs in the body of the document, in the place where the bibliography section should be created.\bibliography{refs}
as the very first instruction following\begin{document}
.