1 unstable release
Uses new Rust 2024
| new 0.1.0 | May 15, 2026 |
|---|
#47 in #latex
22KB
393 lines
pdfdiff
Produces a PDF from two LaTeX sources with all changes marked in red — additions in red, deletions in red strikethrough.
Wraps latexdiff and handles the full build pipeline: bibliography generation, multi-file projects, and arXiv-style embedded .bbl files.
Usage
pdfdiff <original> <modified> <output-dir>
Each source can be:
| Form | Example |
|---|---|
| Git branch name | main |
.tex file path |
paper/main.tex |
| Project directory | paper/ |
For directories and branches, the file containing \documentclass is used as the root automatically.
diff.tex and diff.pdf are written to <output-dir>.
Examples
# Compare two git branches
pdfdiff main feature-branch out/
# Compare two directories
pdfdiff paper-v1/ paper-v2/ out/
# Compare specific .tex files
pdfdiff old/main.tex new/main.tex out/
# Mix and match
pdfdiff main paper-v2/ out/
Requirements
Required:
latexdiff— usually part of TeX Live / MiKTeXpdflatexgit(for branch inputs)
Optional but recommended:
latexpand— enables--flattenso\input/\includedirectives are inlined; ships with TeX Livebibtex/biber— required if the project has a bibliography
Installation
cargo install pdfdiff
How it works
- Each source is resolved to a root
.texfile (extracting git branches viagit archiveinto a temp directory as needed). - The modified project is copied into
<output-dir>so all relative asset paths work. - The modified source is pre-built (
pdflatex+ bibliography tool) to generate.bbland other artifacts before the diff is compiled. latexdiffproducesdiff.texwith change markup.- Red colour overrides are injected: both additions and deletions render in red (deletions get a strikethrough via
\sout). diff.texis compiled twice withpdflatexto resolve cross-references.
arXiv projects
Projects that embed \input{main.bbl} instead of a live \bibliography{} call are handled automatically: a minimal .aux stub is written and bibtex is run to synthesise the missing .bbl before compilation.
Dependencies
~2.7–9MB
~193K SLoC