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:
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.
latexdiff*.exe
files in MiKTeX's bin
directory. I usually use latexdiff-so.exe
.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.
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
Thanks so much,
Glenna Jenkins
<a hrefs="https://google.com"jehfjeh</a>
Regards
Salman
Thank you very much!
Mely