Skip to main content

BibTeX Entry Extractor for LaTeX

A simple yet powerful Python script to create a clean .bib file containing only the references cited in your .tex document. This is perfect for cleaning up your bibliography before sharing your project or submitting it to a journal.

Features

  • Extracts Only Used References: Scans your .tex file and pulls only the cited entries from your master .bib file.

  • Handles Various Cite Commands: Correctly identifies keys from a wide range of citation commands, including \cite, \citep, \citet, \citealt, etc.

  • Parses Complex Citations: Intelligently handles citations with pre-notes and post-notes, like \citep[see][p. 5]{key}.

  • Ignores Commented Citations: The script detects citations in commented-out lines (e.g., % \cite{key}) and excludes them from the final bibliography.

  • User-Friendly Warnings:

    • Notifies you if a cited key is present in the .tex file but missing from the .bib file.

    • Lists all the citation keys that were found in comments and therefore ignored.

Prerequisites

  • Python 3

No external libraries are needed.

Install

pip install minibib

Usage

Run the script from your terminal using the following command structure:

minibib <path_to_tex_file> <path_to_bib_file> [options]

Arguments

  • tex_file: The path to your main .tex file.

  • bib_file: The path to your master .bib file.

  • -o, --output: (Optional) The name of the new, cleaned .bib file. Defaults to minibib_output.bib.

Example

Imagine you have the following files:

my_paper.tex:

\documentclass{article}

\begin{document}

This paper references the work of \citet{Doe2021}.
We also build on previous results \citep[see Chapter 3]{Smith2019}.


\bibliography{references}
\bibliographystyle{plain}

\end{document}

references.bib:

@article{Doe2021,
    author  = {Doe, John},
    title   = {A Groundbreaking Study},
    journal = {Journal of Important Research},
    year    = {2021},
    volume  = {10},
    pages   = {1-20}
}

@book{Smith2019,
    author    = {Smith, Jane},
    title     = {Foundations of Modern Science},
    publisher = {Academic Press},
    year      = {2019}
}

@misc{Jones2022,
    author = {Jones, Sam},
    title  = {Preliminary Thoughts},
    year   = {2022},
    note   = {Unpublished}
}

To generate your clean bibliography, run:

minibib my_paper.tex references.bib -o final_references.bib

Console Output:

Warning: The following citation keys were found in comments and will be ignored:
  - Jones2022

Found 2 unique active citation keys in 'my_paper.tex'.
Found 3 entries in 'references.bib'.

Successfully created new .bib file: 'final_references.bib'

The resulting final_references.bib will contain:

@article{Doe2021,
    author  = {Doe, John},
    title   = {A Groundbreaking Study},
    journal = {Journal of Important Research},
    year    = {2021},
    volume  = {10},
    pages   = {1-20}
}

@book{Smith2019,
    author    = {Smith, Jane},
    title     = {Foundations of Modern Science},
    publisher = {Academic Press},
    year      = {2019}
}

License

This project is open-source under the MIT License.

Metadata

Release files for minibib 1.0.1

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

Source distribution (sdist)

Source distribution for minibib 1.0.1
File Size Uploaded Provenance Actions
minibib-1.0.1.tar.gz 5.3 kB Without provenance Details for minibib-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 11.0 kB

Release files / minibib-1.0.1.tar.gz

Download URL minibib-1.0.1.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b26162b34ae935339909f598206dee581553fa3519412a2d4a8895ff42d45729
BLAKE2b-256 checksum
How to use checksums
fc534d4fd551d977bae0b7b43eeb68841ab9bec31846a085d1cb644e6f97b532
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Release files / minibib-1.0.1-py3-none-any.whl

Download URL minibib-1.0.1-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fca3a9cffef485fefdc4754fc2f7adfb22a09dd6c17484de154bdf9c98e54a4f
BLAKE2b-256 checksum
How to use checksums
38a8219d4ff03938ea4e2dac45ea31eaf1f7a54c32ca540d4f819db4ebeebed3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Security for minibib 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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