How to Find Unused BibTeX Entries
BibTeX is a reference management system often used together with the LaTeX typesetting system. Today I wanted to find out if I had any unused references in my BibTeX file. There doesn't seem to be an easy way to do this. Luckily, a combination of tools did it. This is a quick brain dump of what I did. (If you find an easier way to do this, let me know.)
My bibtex file is paper.bib
. This contains all (used and unused) references.
My paper is in paper.tex
. When first compiling the paper, latex creates
paper.aux
. This intermediary file contains entries only for the references
that the paper actually cites.
-
Dump keys for all (used and unused) references, and sort them:
bib2bib paper.bib -ob /dev/null -oc /dev/stdout |sort >all
-
Dump keys for used references, and sort them:
aux2bib paper.aux |bib2bib -ob /dev/null -oc /dev/stdout |sort >used
-
List keys which are in
all
but not inused
:diff --old-line-format=%L --unchanged-line-format= all used
You can consult the manual pages for bib2bib, aux2bib, and diff to see what the
parameters above do. The commands bib2bib
and aux2bib
can be found in the
bibtex2html package.