Bib Cleaner removes unnecessary entries from your bib files. Documentation @ https://bib-cleaner.readthedocs.io.
You have been writing a TeX document for a while, and adding citation entries to your
.bib
file. Suppose it is calledmaster.bib
and contains the following:% master.bib @article{citation1 author = {Lastname1, Firstname1 and Lastname2, Firstname2}, title = {{Title of Paper 1}}, year = {2018} } @article{citation2 author = {Lastname1, Firstname1 and Lastname2, Firstname2 and Lastname3, Firstname3}, title = {{Title of Paper 2}}, year = {2012} } @article{citation3 author = {Lastname1, Firstname1 and Lastname2, Firstname2}, title = {{Title of Paper 3}}, year = {1953} } @article{citation4 author = {Lastname1, Firstname1 and Lastname2, Firstname2}, title = {{Title of Paper 4}}, year = {1959} }
In the course of writing, some entries in your
master.bib
have become obsolete. You don't use them in your TeX document anymore, which looks like this:% contents.tex \documentclass{article} \begin{document} I wished them the so long \cite{citation1} and thanked them for all the fish \cite{citation3}. \end{document}
Herecitation2
andcitation4
have become obsolete.
- Of course, LaTeX compiles quite happily with these extra entries (
citation2
andcitation4
) and excludes them from the typeset bibliography... but you know they are there. - You take a step back, sip some coffee, go for a walk, all the while pondering "Man, I wish I could just remove those extra bib entries". You yearn for a world where all
.bib
files everywhere carry only what they have to, and no more.
I gotchu. Enter bib_cleaner
.
This should work:
$ pip install bib_cleaner
For detailed instructions, see :ref:`detailed_install`
Verify if it installed by typing the following in the command-line:
$ bib_cleaner -h
You should see the help:
usage: bib_cleaner [-h] [-t TEXFILES [TEXFILES ...]] [-o OUTPUTBIB] masterfile Produce a minimal bib file with only the entries found in your .tex file(s) positional arguments: masterfile master bib file with used and unused citations (.bib) optional arguments: -h, --help show this help message and exit -t TEXFILES [TEXFILES ...], --texfiles TEXFILES [TEXFILES ...] content files to select entries from (.tex) -o OUTPUTBIB, --outputbib OUTPUTBIB output file name with extension
After installation, navigate to your TeX directory try:
$ bib_cleaner master.bib
Of course, replace master.bib
with the name of your bib file with obsolete bib entries. bib_cleaner
will
- automatically detect all the TeX files (
.tex
) in that directory and use them to determine which bib entries are obsolete. - create
new.bib
which does not have the obsolete citations.
After you run bib_cleaner
for the first time, you can
- update your TeX files to use
new.bib
instead ofmaster.bib
. Thereafter, any new citations added to your TeX files or addition/removal of entries frommaster.bib
should be followed by a call tobib_cleaner
. Of course, you can add it to your LaTeX makefile should you have one. - marvel at how much smaller
new.bib
. When the writing project is completed, runbib_cleaner
again,once and for all and update your TeX files to usenew.bib
instead ofmaster.bib
.
If you only want to keep the entries used in some TeX files, specify them with:
$ bib_cleaner master.bib --texfiles chapter1.tex chapter2.tex
or:
$ bib_cleaner master.bib -t chapter1.tex chapter2.tex
If you want to change the output bib file name from the default new.bib
, do:
$ bib_cleaner master.bib -t chapter1.tex --outputbib chapter1.bib
or:
$ bib_cleaner master.bib -t chapter1.tex -o chapter1.bib
- Remove typically unused lines from
.bib
files (likefile = {...}
orabstract = {...}
) - Detect and remove bib entries with identical tags / raise conflict
- Add tests for the command-line interface
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.