Skip to main content

LaTeXpkges3

This is a LaTeX package cleanup utility. You can use it to find packages that are included in your LaTeX document but are not actually used.

You may run it directly against your original sources. The utility operates on a copy of the original .tex file and will not modify any source files while working.

Note: it may delete your other LaTeX-related files with the following extensions: .log, .aux, .dvi, .ps, .pdf, .xdv, .bcf, .bbl, .blg.

Current version is based on python >= 3.6. If you need a version working for python < 3.0, please use the python 2 compatible release.

Installation

You can use pip to install LaTeXpkges3:

pip install latexpkges3

and then use it as a command-line tool:

latexpkges3 master.tex [options]

Please refer to the usage section for the detailed description of command-line arguments.

How it Works

Hash-based algorithm

The utility follows the following algorithm:

  1. Find all package imports in the LaTeX document
  2. Exclude them one by one
  3. Rebuild the project
  4. Check whether the PDF changes

The idea is that if after you excluded the package, the PDF did not change, then it is safe to remove that package. In the end, the utility suggests a list of packages that it deems safe to remove.

PDFs are compared using MD5 hash after being stripped of ID's and dates. XDV files are compared with diff.

Visual algorithm

Alternatively, you may use the flag --visual to convert the files (DVX or PDF) into images and compare them one-by-one instead.

Usually, this method is slower than the MD5-based algorithm but can sometimes provide more accurate results. Also, you can speed it up with the multiprocessing enabled.

Note: pdflatex yields some erratic results for MD5 comparison, so it is better to use it only in the visual mode.

General Assumptions

This utility runs on Linux and Windows platforms.

You may use any of the LaTeX engines: latex, pdflatex,xelatex or lualatex as a processor and either bibtex or biber for bibliography.

In order to use the visual comparison, you need to have ghostscript installed.

Usage

To use the utility, go to the location of your LaTeX project. Assuming your main .tex file is main.tex and it is in that folder, run the script from the command line:

latexpkges3 --latex pdflatex --bibtex biber  main.tex

Command-line arguments

LaTeXpkges3 accepts a single positional argument - the name of the .tex file to analyze and a number of optional arguments listed in the table below:

Argument Description
--latex The name of an engine to process .tex files (default: pdflatex). Supported engines: latex, pdflatex, xelatex, lualatex
--bibtex The name of a reference engine for .tex files (default: None). Supported engines: bibtex, biber
--num_threads The number of parallel processes (default: 1)
--visual Do the visual comarison instead of checksum
--verbose Enable extra verbosity
--debug Do not delete build artifacts and .pdf files generated during processing

You may run latexpkges3 -h or latexpkges3 --help for more info.

Development

This program was initially developed by Vasily Sidorov (@Bazzilic) and the development now continues under Taras Kuzyo with the support of Books in Bytes, Inc.

The program intentionaly handles ONLY packages that are inserted at top level, that is, that are inserted inside the main project file and not by file called via

\input 
\usepackage{}
\RequirePackage

The reasons for this are:

  • The programming may not be so simple, the logic would be quite messy and it will make the program harder for people to contrib ute to the project!

  • Potential for creating a messy directory with many copies of many files spread in many subdirectories

  • Confusing logic (to the user) because we definitely do not want the program to follow a \RequirePackage{amsmath} and start editing "amsmath" for exclusion of any of its subpackages, even if the user is able to edit it.

Metadata

Release files for latexpkges3 1.0

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

Source distribution (sdist)

Source distribution for latexpkges3 1.0
File Size Uploaded Provenance Actions
latexpkges3-1.0.tar.gz 6.7 kB Without provenance Details for latexpkges3-1.0.tar.gz

Built distribution (wheel)

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

Total release size: 14.2 kB

Release files / latexpkges3-1.0.tar.gz

Download URL latexpkges3-1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c728611a906ef67fc9c3eca744d72dc009ddc57f63749b0b322c66426915af2c
BLAKE2b-256 checksum
How to use checksums
f603b0519c2cd5d3c47d9bdedb89ef0a445fa94dfcb7688a6a082c7b104d47e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.7.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / latexpkges3-1.0-py3-none-any.whl

Download URL latexpkges3-1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81083e7b5d465a5eca706dd82cb4c67120b8c8a6b02209eb3a382d63b1fd2bfc
BLAKE2b-256 checksum
How to use checksums
6231154c94e38ae12004a2e280ae04acf0f0c7c760dac2ef31decb5ae566e263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.7.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Security for latexpkges3 1.0

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 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