4

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 ...

3

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}

\addbibresource{\jobname.bib}

\begin{document}

Some text \autocite{A01}.

\printbibliography

\end{document}

xxx

\documentclass{article}

\usepackage{biblatex}

\usepackage{filecontents}

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

\addbibresource{\jobname.bib}

\begin{document}

Some text.

\printbibliography

\end{document}

enter image description here

You may also be interested in the following question: What to do to switch to biblatex?

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.