Track changes and highlight revisions in LaTeX documents with latexdiff

When several authors are editing a paper, it is sometimes necessary to quickly highlight what changes have been made in a particular version of the paper compared to previous versions. Word processors have long had revision tracking features for this but some LaTeX authors are unaware that there is a handy utility called latexdiff that can also highlight changes between two revisions by comparing two LaTeX documents:

latexdiff can highlight and show changes between two versions of a LaTeX document.

This page briefly describes this program. While LaTeX authors can use revision control software like software developers to track changes, there are cases where this is not convenient. For example, grad students may revise papers, get feedback from their advisor and then revise the paper again (I know I did). The advisor just wants to see quickly and with formatting what changes were made on the manuscript without learning how to use revision control software. latexdiff provides a way to do this. It performs a “diff” (like the Unix utility) on the two documents and then creates a new LaTeX document where the changes are made clear.

Prerequisites

  • Ensure that the latexdiff program is in your system path. Windows users with MiKTeX will find that it already comes with latexdiff: there are several latexdiff*.exe files in MiKTeX's bin directory. I usually use latexdiff-so.exe.
  • Make sure that Perl is on the system path, as it is required by latexdiff to run.

Usage

Obviously you need to have two versions of your document to compare. latexdiff can be run with the following command:

latexdiff-so old_version.tex new_version.tex > differences.tex

The resulting differences.tex file can be run through LaTeX to produce the version with revisions highlighted.

It has been pointed out to me that the file names should not have spaces or else you will have to enclose them in quotes.

Additional Tips

Sometimes latexdiff produces wrong output that will give an error when you run LaTeX on the file. In the cases I have seen, you simply need to go to the place where the error occurs and make sure that the various commands that latexdiff adds are properly closed. For example, you may have to add some \DIFaddend to unclosed \DIFadd commands.

The program does not necessarily handle complex math equations properly but I have found that it is enough to do the job most of the time. It also has a number of command line options that I have not had to use yet.

Finally, if your document is split up into sections, it might be best to split the LaTeX files up into a file per section so the diff process can work more smoothly. I have been particularly lazy and have not done this for my journal submissions but it is probably a good idea.

Discussion

Glenna Jenkins, 2013/09/06 08:36
Hi Peter: I am an editor who revises economic documents. Many of my clients write their documents in LaTex. I use a MacBook Pro and prefer to do mark-up in 'track changes'. I am considering downloading MacTex so that I can accommodate clients without asking them to convert their documents to Word. Would LaTexdiff work for this of should I consider LyX? I would really appreciate your help on this one.
Thanks so much,
Glenna Jenkins
Peter Yu, 2013/09/08 21:49
I think you could use any PDF markup tool to do this if your clients can generate PDF from their LaTeX documents. Otherwise, latexdiff could work for this, but keep in mind it's simply going to mark the differences between documents and not necessarily give you a way to leave comments. So you'd edit their LaTeX file and then run latexdiff to highlight the differences.
Salman, 2014/06/03 05:38
Hi Peter! How do you go on to accept the changes made using this method? For my specific case, i have to show the reviewers where I have incorporated their comments in my thesis and finally accept them all.
Regards
Salman
Peter Yu, 2014/06/05 21:02
You have to keep in mind this just highlights the changes between two versions of your document. Let's say you start with version 1. Your reviewers give you comments and you make version 2. You use latexdiff to highlight changes between V1 and V2. Then you give V2 and the highlighted file to the reviewers. When you make V3, you can then compare the differences between V2 and V3.
I would love to hear your feedback. Enter your comment below [ Terms of Use ]:
BBZRC
 

About Peter Yu I am a research and development professional with expertise in the areas of image processing, remote sensing and computer vision. I received BASc and MASc degrees in Systems Design Engineering at the University of Waterloo. My working experience covers industries ranging from district energy to medical imaging to cinematic visual effects. I like to dabble in 3D artwork, I enjoy cycling recreationally and I am interested in sustainable technology. More about me...

Feel free to contact me with any questions about this site at [user]@[host] where [user]=web and [host]=peteryu.ca

Copyright © 1997 - 2017 Peter Yu