Skip to content

Instantly share code, notes, and snippets.

@tzelleke
Last active May 10, 2023 14:37
Show Gist options
  • Save tzelleke/e4d39a6b94f2a667baab716583dd61c4 to your computer and use it in GitHub Desktop.
Save tzelleke/e4d39a6b94f2a667baab716583dd61c4 to your computer and use it in GitHub Desktop.
Clean up your bibliography for journal submission. List unused references in bibtex bibliography
BIBTEXFILE=bibliography.bib
AUXFILE=manuscript.aux
REFS=$(mktemp -t $$_refs_XXXX) || exit 1
CITED=$(mktemp -t $$_cited_XXXX) || exit 1
egrep '^@' $BIBTEXFILE | \
sed 's/@.*{//' | \
sed 's/,$//' | \
sort >$REFS
egrep -e '^\\citation' $AUXFILE | \
sed 's/^.*{//' | \
sed 's/}$//' | \
sed 's/,/\n/g' | \
sort | \
uniq >$CITED
echo "**Unused references in ${BIBTEXFILE}**"
diff --old-line-format=%L --new-line-format= --unchanged-line-format= $REFS $CITED
echo ""
echo "**Missing citations**"
diff --old-line-format=%L --new-line-format= --unchanged-line-format= $CITED $REFS
echo ""
@tzelleke
Copy link
Author

List unused/missing references in/from your BibTeX file

When you need to "clean up" .bib for submission to the journal:

  • Run bibtex <your-manuscript> first to generate .aux file
  • Line 1: adjust for the name of your BibTeX file
  • Line 2: adjust for the name of the generated .aux file

Example output:

Unused references in bibliography.bib
Barducci2011Metadynamics
Basran2003H
Car1985Unified
Cleland1982Use
Hay2008Atomistic
Hay2008Incorporation
Hay2009Barrier
Hay2009Structural
Hedison2015Real
Hoeven2015Does
Klinman2009Integrated
Klinman2015Dynamically
Knapp2002Environmentally
Laio2002Escaping
Leferink2015Towards
Luk2013Unraveling
Nagel2009Century
Quhe2015Path
Roux1995Calculation
Sen2010Enzymatic
Swiderek2014Heavy
Warshel2016Perspective

Missing citations
apsrev41Control
REVTEX41Control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment