Skip to content

Instantly share code, notes, and snippets.

@jgomezdans
Forked from adam-binks/latexdiff.md
Created September 15, 2022 11:48
Show Gist options
  • Save jgomezdans/cf22c4d82374ad36674ad106cd932cde to your computer and use it in GitHub Desktop.
Save jgomezdans/cf22c4d82374ad36674ad106cd932cde to your computer and use it in GitHub Desktop.
How to LaTeX diff your Overleaf project

How to LaTeX diff your Overleaf project

Set up local latex environment

Grab the two versions

  • Download the original version
    • Go to Overleaf > history > find the version > view single version > download project at this version
  • Download the current version
    • Go to Overleaf > menu (top left) > Download source
    • NB: if you've made changes using Overleaf's "track changes" feature, you'll need to accept those changes before they are reflected in your diff PDF
  • Unzip both versions, rename the folders "orig" and "updated"

Compile to generate bibliographies

  • Open orig/main.tex and updated/main.tex in Texstudio
  • Compile each of them (green play button)
    • This may take a while on first run because it needs to download the packages you're using

Create the diff file

  • Open a terminal in the folder containing the "orig" and "updated" folders
  • Run "latexdiff-so orig/main.tex updated/main.tex --flatten > diff.tex"
    • We use latexdiff-so as it is standalone (doesn't rely on any other Perl libraries)
    • --flatten tells latexdiff to follow \input commands properly

Check and upload the output

  • Open diff.tex in Texstudio, run "Build & View" (double green arrow) and inspect output
    • You might have to fix some errors here, for example removing tikz figures
  • You can upload the diff.tex into your Overleaf project to share with collaborators and submit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment