Skip to main content

Extract entries from a .bib file that are cited in a .tex file

Project description

bibfish

bibfish is a command line utility that extracts BibTeX entries cited in a LaTeX file from a central database. This is useful if you want to maintain a single master BibTeX file and automatically generate a separate, independent BibTeX file for each manuscript you're working on. It is similar to bibexport and makebib, except bibfish is not dependent on any particular LaTeX tool and is therefore agnostic about your choice of bibliographic software (BibTeX vs. BibLaTeX, etc) or general typesetting pipeline.

bibfish can be run once if all you want to do is create a subset of your master.bib to send to the publisher. Alternatively, bibfish can be used as an integral part of your typesetting procedure, with an intended usage pattern like this:

  1. Start a new LaTeX document and, when setting up the bibliography, point it to e.g. references.bib (no need to create this file; it will be generated automatically)
  2. Add any BibTeX entries you want to cite to your master.bib (stored e.g. in your home directory)
  3. Cite some BibTeX entries in your LaTeX document using their citekeys as normal
  4. Each time you typeset, first run bibfish; this will fish out the relevant entries from master.bib and place them in references.bib
  5. Continue with the rest of your typesetting procedure, e.g. run pdflatex, latex, bibtex, biber, or whatever else you normally do in your pipeline

For example, given that manuscript.tex contains a reference to references.bib and cites BibTeX entries contained in ~/master.bib, you might have a typesetting script like this:

#!/bin/bash

bibfish manuscript.tex ~/master.bib references.bib
latex manuscript.tex
bibtex manuscript.aux
latex manuscript.tex
dvipdfm manuscript.dvi

Thus, each time you run this script, bibfish will search manuscript.tex for citekeys, extract the relevant entries from ~/master.bib, and write them out to references.bib, allowing the rest of the typesetting process to proceed as normal.

The benefit of this is that your LaTeX document does not need to have any dependence on or reference to ~/master.bib. This means you can maintain a single master.bib, while also maintaining each manuscript as its own independent self-contained package. You could, for example, send manuscript.tex and references.bib to a coauthor or publisher without needing to supply your entire master.bib, and manuscript.tex and references.bib can be kept under version control without any connection to master.bib.

Installation

bibfish can be installed using pip:

pip install bibfish

Usage

Once installed, bibfish may be used from the command line like this:

bibfish manuscript.tex ~/master.bib references.bib

By default, bibfish searches your manuscript for \citet{} and \citep{}. If you are using a different set of cite commands, you can specify them with the --cc option:

bibfish manuscript.tex ~/master.bib references.bib --cc "textcite,parencite,possessivecite"

Caveats

I have not tested bibfish against any BibTeX file other than my own, and it will likely break if your master.bib is structured in a substantially different way. For reference, a typical entry in my master.bib looks like this:

@article{Carr:2020,
author = {Carr, Jon W and Smith, Kenny and Culbertson, Jennifer and Kirby, Simon},
title = {Simplicity and Informativeness in Semantic Category Systems},
journal = {Cognition},
year = {2020},
volume = {202},
pages = {Article 104289},
doi = {10.1016/j.cognition.2020.104289}
}

Note in particular that the first line of an entry should start with an @ and the final line should contain a single }; everything between these two characters will be extracted and copied verbatim.

License

bibfish is licensed under the terms of the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bibfish-0.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bibfish-0.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file bibfish-0.0.1.tar.gz.

File metadata

  • Download URL: bibfish-0.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for bibfish-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0501fdfe7ca486c75618d7545bd1fc2d6e4cdf6d5e7be1cdf0f8e8bba7656bfa
MD5 ac08c6ac39c52acd8976db7eb695e300
BLAKE2b-256 9740b8f17c74771118ceed024c085bf4ef37bad203a9256d0b14742e884b435b

See more details on using hashes here.

File details

Details for the file bibfish-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: bibfish-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for bibfish-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aadf97e42b0d9d8a4648a62e04f0d5a9f3631253b95246af83f13d6a88e0d817
MD5 9c6dec36de4f214e34fcae6bd16e79d8
BLAKE2b-256 f3627a8fea1bdb9f4f0510b0badc39807cb36df675cd8ef709848caf9373ad36

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page