Skip to content

snuhcs/overleaf-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

overleaf-diff

Generate visual diff PDFs for Overleaf/LaTeX projects. Additions are highlighted in blue; deletions are optionally shown in red strikethrough.

Built on top of latexdiff with fixes for common pain points: broken section titles, table environments, merge commits, and noisy single-word changes.

Quick Start

# Clone into your project (or anywhere in PATH)
git clone git@github.com:snuhcs/overleaf-diff.git

# cd into your Overleaf project
cd my-paper/

# Generate diff against a commit
/path/to/overleaf-diff/overleaf-diff.sh HEAD~5

The output PDF is saved to ./output/ and opened automatically on macOS.

Usage

./overleaf-diff.sh <base-commit> [options]

Options

Option Default Description
--min-words N 1 Ignore changes shorter than N consecutive words
--show-deletions off Show deletions as red strikethrough
--output DIR ./output Output directory
--name PREFIX directory name PDF filename prefix
--no-open auto-open Don't open PDF after generation

Examples

# Basic diff — blue additions only
./overleaf-diff.sh abc1234

# Filter out trivial 1-2 word changes
./overleaf-diff.sh abc1234 --min-words 3

# Show both additions (blue) and deletions (red strikethrough)
./overleaf-diff.sh abc1234 --show-deletions

# Custom output
./overleaf-diff.sh abc1234 --output ./build --name MyPaper --no-open

Requirements

  • latexdiff (included with TeX Live)
  • pdflatex + bibtex
  • Python 3 (for the short-change filter)

How It Works

  1. Extracts the old and current versions from git
  2. Runs latexdiff per-file (not flattened) to avoid .bbl corruption
  3. Cleans up structural markers that break compilation
  4. Filters out short changes (< --min-words) via strip_short_diff.py
  5. Handles new files (wraps in blue) and new tables (scoped \color{blue})
  6. Injects a minimal preamble for \DIFadd / \DIFdel rendering
  7. Compiles with 3 pdflatex passes + bibtex

What it fixes over raw latexdiff --flatten

  • Section/subsection titles are excluded from diff markup (no broken headings)
  • .bbl files are never flattened (no Illegal parameter errors)
  • Table environments are handled separately (no broken tabular)
  • Merge commits are resolved automatically (uses effective parent)
  • Noisy changes can be filtered by word count

Project Structure

overleaf-diff.sh      # Main script
strip_short_diff.py   # Helper: strips \DIFadd{} markup for short changes

Expected LaTeX Project Layout

The script works with standard Overleaf project structures:

my-paper/
  main.tex              # Entry point
  definition.tex        # Optional preamble (used for injection point)
  section/              # \input{section/...} files
  figure/               # \input{figure/...} table .tex files
  reference.bib

If definition.tex is not found, the preamble is injected before \begin{document}.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors