bibClean
is a tool designed to help clean .bib
files for LaTeX projects based on the citations used in the .tex
files.
The tool will provide a clean .bib
file as well as summary file with an overview of unused and used citations.
The tool expects a single .bib
file, but can read all .tex
files in the project. If only some .tex
files should be considered, these can be specified.
This document describes the CLI option, but the tool can also be used from a notebook.
API documentation.
Development
How does the tool work?
- bibClean - a LaTeX Citation Cleaner
- Process all
.tex
files in a folder or zip archive. - Process specific
.tex
files with a given.bib
file. - Support for both folder-based and zip-based input.
- Produce a
.bib
file containing only used entries from the.tex
files - Produce a summary of used and unused entries in an excel file
- Automatically assumes
--all_tex
when only--folder
or--zip
is specified.
-
Clone the repository:
git clone https://github.com/eztaban/bibtex-cleaner.git cd bibtex-cleaner
-
Install required dependencies:
conda env create -f environment_linux.yaml --name NEW_ENV_NAME
Drop the
--name
-flag to inherit the environment name from the yaml file
Get miniconda: Minicondaconda env create -f environment_windows.yaml --name NEW_ENV_NAME
- pandas
- openpyxl
- python 3.10
- ipykernel (for jupyter notebook interface)
- pytest (not included in environment file)
- Create folder called
input
at same level asmain.py
- Place folder or zip-file with latex project in folder
input
- Run the CLI tool using Python's
main.py
:
python main.py [OPTIONS]
Alternately, use the notebook
Flag | Description | Required? |
---|---|---|
--all_tex |
Process all .tex files in the specified location (folder or zip). If --folder or --zip is specified without --all_tex , this is assumed to be true. |
Optional |
--spec_tex |
Process specific .tex files. Provide a space-separated list of filenames. |
Optional |
--bib |
Path to the .bib file to be used (required with --spec_tex ). |
Optional |
--folder |
Path to the folder containing .tex files (and optionally a .bib file). |
Required (or --zip ) |
--zip |
Path to the zip file containing .tex files (and optionally a .bib file). |
Required (or --folder ) |
If only the --folder
argument is provided, the program assumes --all_tex
:
python main.py --folder /path/to/folder
Equivalent to:
python main.py --all_tex --folder /path/to/folder
If only the --zip
argument is provided, the program assumes --all_tex
:
python main.py --zip example.zip
Equivalent to:
python main.py --all_tex --zip example.zip
Process specific .tex
files file1.tex
and file2.tex
with references.bib
in the folder /path/to/folder
:
python main.py --spec_tex file1.tex file2.tex --bib references.bib --folder /path/to/folder
Process specific .tex
files file1.tex
and file2.tex
with references.bib
in the zip file example.zip
:
python main.py --spec_tex file1.tex file2.tex --bib references.bib --zip example.zip
-
Automatic
--all_tex
: If you provide only--folder
or--zip
, the tool will automatically assume--all_tex
and process all.tex
files in the specified location. -
Temporary Folder for Zip Files: If you provide a zip file, the tool unpacks it into a temporary directory. Ensure you have enough space for unpacking.
-
Error Handling:
- If you specify
--spec_tex
, you must also provide--bib
. - Either
--folder
or--zip
must be specified to locate input files. - The tool validates the input to ensure no conflicts.
- If you specify
This project is licensed under the MIT License.