Skip to main content

Clean and optimize bib file.

Project description

logo

PyPI - Python Version Static Badge Static Badge

bib-optimizer

Oh, sure, because who doesn't love manually cleaning up messy .bib files? bib_optimizer.py heroically steps in to remove those lazy, unused citations and reorder the survivors exactly as they appear in the .tex file—because, clearly, chaos is the default setting for bibliographies.

In layman's terms, it automates bibliography management by:

  1. removing unused citations,
  2. reordering the remaining ones to match their order of appearance in the .tex file.

Input Files:

  • main.tex – The LaTeX source file.
  • ref.bib – The original bibliography file.

These input files will remain unchanged.

Output File:

  • ref_opt.bib – A placeholder filename for the newly generated, cleaned, and ordered bibliography file.

Installation

It can be installed with pip, ideally by using a virtual environment. Open up a terminal and install the package and the dependencies with:

    pip install bib_optimizer

or

    python -m pip install bib_optimizer

🐍 This requires Python 3.8 or newer versions


Steps to Clean Your Bibliography

  1. Prepare the input files (e.g., by downloading them from Overleaf).

  2. Run the command to generate a new .bib file (for example, you may name it ref_opt.bib):

           bibopt main.tex ref.bib ref_opt.bib

  3. Use the Cleaned Bibliography
    Replace ref.bib with ref_opt.bib in your LaTeX project.


Test

You may test the installation using the sample input files (sample_main.tex and sample_ref.bib) located in the test folder.

sample_main_shot  sample_ref_shot

sample_main.tex and sample_ref.bib

sample_ref_opt_shot

A sample ref_opt.bib created after running bibopt sample_main.tex sample_ref.bib ref_opt.bib


New feature (version 0.4.0)

If the main.tex calls inputs from other .tex (e.g., with \input{...}), the newly generated ref_opt.bib will preserve the order of appearances in the main.tex with each inputted .tex as well.
(The dependent .tex files need to be placed in the same directory as main.tex.)


New feature (version 0.4.1)

On top of version 0.4, skip any \input .tex file if not found.


New feature (version 0.4.2)

In addition to handling the \input{...} command, it also supports the \include{...} command.

♥ Lastly executed on Python 3.10 on 2025-07-14.

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

bib_optimizer-0.4.2.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

bib_optimizer-0.4.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file bib_optimizer-0.4.2.tar.gz.

File metadata

  • Download URL: bib_optimizer-0.4.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.18

File hashes

Hashes for bib_optimizer-0.4.2.tar.gz
Algorithm Hash digest
SHA256 c5e2bb8eb2313eec66c71281a4a551fde65c08c949d67238a5b4f6ab6b3a97d8
MD5 4266751d60147763e776492cc565e8fd
BLAKE2b-256 f015b563bfc2c7779f0b33b1e726fa6440d2e9baf10240fd6516053147cea2af

See more details on using hashes here.

File details

Details for the file bib_optimizer-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: bib_optimizer-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.18

File hashes

Hashes for bib_optimizer-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd13e366318e1153344519a99f89ca7ad529b3630bfcc6ced52aac757b2698cb
MD5 d215f14bc8b3c96a13a542d5cdef131d
BLAKE2b-256 ebe0bf6f9e05ea35e6ba74cf818e7f4f344c37b5f9d80b71627288201bb59a25

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