Skip to main content

bibfish

Bibfish generates a local BibTeX file from a central BibTeX database based on the citations found in a LaTeX file. This is useful if you want to maintain a single master BibTeX file (or several) 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.

Installation

Bibfish is written in Python and can be installed using pip:

pip install bibfish

Basic usage

Bibfish may be used from the command line like so:

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

Warning Ordering these filenames incorrectly could result in data loss! Ensure that the arguments are ordered as follows: (1) The LaTeX manuscript file. (2) Your master BibTeX database. (3) The output file that will be created by Bibfish.

By default, Bibfish will not overwrite a local .bib file if it already exists. To override this behavior, use the -f option:

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

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

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

If you maintain multiple BibTex databases, you can pass additional .bib files with the --bib option:

bibfish manuscript.tex ~/master.bib references.bib --bib ~/my_papers.bib ~/my_abstracts.bib

Usage as part of a larger pipeline

Bibfish can also be used as an integral part of your typesetting procedure, with the following intended usage pattern:

  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). For example, depending on how you set things up, you might have a line like \bibliography{references.bib} or \addbibresource{references.bib}.
  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. Before typesetting, run Bibfish first; 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, xelatex, bibtex, biber, dvipdf, or whatever else you normally do in your pipeline.

For example, you might create a typesetting script like this:

#!/bin/bash

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

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.

Caveats

Bibfish relies on BibtexParser to read and write .bib files. Although we have configured it in a relatively permissive fashion, please raise an issue if Bibfish has trouble reading your database or is producing unexpected output.

Contributing

This project is in the stable/maintenance phase and is not under active development. I am only aiming to fix bugs and keep it compatible with current versions of Python so that it remains useful to the community. With that in mind, contributions are very welcome, but please read the CONTRIBUTING file before submitting a pull request.

Metadata

Release files for bibfish 0.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bibfish 0.3.4
File Size Uploaded
bibfish-0.3.4.tar.gz 48.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bibfish 0.3.4
File Interpreter ABI Platform
bibfish-0.3.4-py3-none-any.whl Python 3 none any Details

Total release size: 55.9 kB

Release files / bibfish-0.3.4.tar.gz

Download URL bibfish-0.3.4.tar.gz
Size 48.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d6c00330c8c37cbea1eb49253ed0cd0bb0291f83d8bd45916e5cdd75ff44a616
BLAKE2b-256 checksum
How to use checksums
43cb710f11529e6bde62243cd9660fc478106d5d85850ecb1f68dfed4e421a48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.0

Release files / bibfish-0.3.4-py3-none-any.whl

Download URL bibfish-0.3.4-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99b4d37729023fcc82dc639af8b65117bc6513dadc403997c254d1b2c8564bc7
BLAKE2b-256 checksum
How to use checksums
3fca1b9a5915ccf53a72340b4b4cde3fd6fda374293eb417fc614676fd393013
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.3.4 This release

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page