latexdiff: Superb diff tool for LaTeX

I am shepherding a paper for ASPLOS, and the authors kindly sent me a PDF highlighting all changes between the previous version and the next. They used latexdiff. I just used it to see some updates made by a student to a paper, and it is fantastic.

Here’s a sample of what the results look like:

(and no, this is not my paper or the ASPLOS paper).

If you are using a Mac, you can easily install it with MacPorts (just sudo port install latexdiff).

Generally, you will want to invoke latexdiff as follows (assuming you are in the directory with the latest version):

latexdiff --flatten /path/to/old/version/main.tex main.tex > diffs.tex

(the –flatten argument makes latexdiff recursively operate on any included .tex files.)

One trick: if, like me, you break your LaTeX documents into separate files, you need to put the preamble into your main document (it’s also automatically generated by latexdiff, but only for a main document). Reproduced here for your cut-n-paste convenience.



6 thoughts on “latexdiff: Superb diff tool for LaTeX”

  1. Thanks so much for the information. I had some trouble in the beginning because I didn’t create an extra directory for the old version. I thought if I just saved my “main.tex” to be “main_old.tex” it could find the changes. The problem is, the changes are *not* made within “main.tex”, but the included sections, “introduction.tex,” “methods.tex,” etc. This is why you need the extra folder of files, to compare the old “introduction.tex” with the new “introduction.tex”

  2. The tool works very well. It saved me a lot of time and manual effort. There is a minor bug in it though. I used the –flatten since my paper is broken into different sections. However, I had some sections commented out. latexdiff does not respect the comments and tried to look for those sections. It was a minor fix, but I thought I would let others know in case they have the same problem

Leave a Reply to Brett Kennedy Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s