There are two ways to produce a diff PDF with latexdiff. Choose the one that works best for you.
This approach requires you to have a LaTeX editor installed locally (e.g., TexShop) and latexdiff installed on your machine.
We assume that you work in [Overleaf]([your overleaf project]).
- Label the overleaf project at first submission: go to
[your overleaf project] > History > All history > [latest documented change] > More actions (3 dots) > Label this version > [choose your label] - After reviewing & introducing changes into the overleaf project, (recommended) do the labelling again for the re-submission
- to produce the diff pdf, download both overleaf projects:
- to download the current version:
[your overleaf project] > Download > Source - to download the previous (submitted) version:
[your overleaf project] > History > Labels > [choose the label] > More actions (3 dots) > Download this version
- to download the current version:
- compile both separately in your local latex editor (to get .bbl output files from bibtex). "Compile" = Run LaTeX, then BiBTex, then 2x LaTex compiler
- in terminal, navigate to new project folder
- run from command line:
latexdiff --flatten [filepath to old tex file] [name of new tex file] > diffs.tex - this will produce the diffs.tex file in the current folder; to produce the diffs PDF, compile the diffs tex
This approach runs latexdiff automatically every time you compile in Overleaf. No local tool installation required.
We assume that you work in [Overleaf]([your overleaf project]).
Overleaf uses LatexMk to compile your project. You can create a latexmkrc file to customize the compilation process, including running latexdiff before the actual PDF compilation.
- Create a file named
latexmkrcin your Overleaf project - Add the following content to configure latexdiff:
# Compile a single file normally (i.e. response.tex - comment out if needed)
#$pdflatex = "pdflatex %O response.tex"
# Run latexdiff to create a diff, then compile it
$pdflatex = "latexdiff -t UNDERLINE --flatten main_v1.tex main.tex > main-d.tex; pdflatex %O main-d"
- The first line is commented out but shows how you could compile a different file normally (just replace
response.texwith your desired filename). - The second line is the relevant configuration:
latexdiff -t UNDERLINE --flatten main_v1.tex main.tex > main-d.tex: runs latexdiff to comparemain_v1.tex(the frozen/old version) withmain.tex(the new version) and outputs the diff tomain-d.tex-t UNDERLINEsets the diff style (underline for deletions/additions)pdflatex %O main-d.tex— compiles the diff file.%Opasses through any options/flags Overleaf might add.- The semicolon
;chains the two commands together.
main.texshould contain your updated version with all the changes.main_v1.texshould be the frozen version (the last submitted version). Do not modify this file.- If your document uses
\includeor\inputto load additional TeX files, you may need to flatten those into a single file for the comparison to work correctly, or ensure both versions include their respective_v1.texor.tex, then latexdiff will take care of the flattening. - After uploading
latexmkrc, Overleaf will automatically run latexdiff on every recompile (the manual compilation options are shwdows by this). The resulting PDF will show all changes marked up.