Skip to content

Instantly share code, notes, and snippets.

@adam-binks
Created May 7, 2022 17:18
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save adam-binks/b8b1de266415df71cf10dbecad8cf54a to your computer and use it in GitHub Desktop.
Save adam-binks/b8b1de266415df71cf10dbecad8cf54a 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
@adam-binks
Copy link
Author

There are also some ways to do it in Overleaf, but these weren't working for me: https://tex.stackexchange.com/questions/603303/install-and-use-latexdiff-without-miktex

@fbarez
Copy link

fbarez commented Oct 20, 2023

is there a way to compile diff in a different colour to show the changes?

@adam-binks
Copy link
Author

adam-binks commented Oct 20, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment