Comparing Two LaTeX documents with Latexdiff

Many researchers are using Latex to write research papers instead of using Microsoft Word. I previously wrote a blog post about the reasons for using Latex to write research papers. Today, I will go in more details about Latex and talk about a nice tool for comparing two Latex files to see the differences. The goal is to see the changes made between two files as it would appear when comparing two revisions of a document using Microsoft Word.  Comparing two documents is very useful for researchers, for example, to highlight the changes that have been made to improve a journal paper when it is revised.

We will use the latexdiff tool.   This tool can be used both on Windows and Linux/Unix. It is a Perl script.   I will first explain how to use it on Windows with MikTek.

Using Latexdiff on windows with the  MikTek Latex distribution

Consider that you want to compare two files called  v1.tex and v2.tex.

Step 1.  Open the Miktek Package Manager and install the package “latexdiff“.

As a result, latexdiff.exe  will be installed in  the directory \miktex\bin\ of your Miktek installation.

Step 2.  From the \miktex\bin\  directory, you can now run the command using the command line interface:

 latexdiff   v1.tex  v2.tex >  out.tex

This will create a new Latex file called out.tex that highlight the differences between your two Latex files.  You can then compile out.tex using Latex. The results is illustrated below:



Note 1: If you want to use latexdiff in any directories (not just in \miktek\bin\, you should add the path  to the directory \miktek\bin\ to the PATH environment variable of Windows.

Note 2 : There are a lot of things can go wrong when installing latexdiff on Windows. First, the encoding of your Latex files may cause some problems.  It took me several tries before I could make it work on some Latex files because the encoding was not in UTF-8.   I first had to convert my file to UTF-8. Also, for some Latex files, the output of latexdiff may not compile. Thus, I had to fix the output by hand.  But there are a lot of command line parameters for latexdiff that can be used perhaps to fix these problems if you encounter them.

Installing Latexdiff on other platforms

To install latexdiff on other platforms, you should first make sure that Perl is installed on your machine. Perl can be downloaded from here: Then, you should download the latexdiff package from CTAN to install it:

I will not provide further details about this because I did not install it that way.


In this blog post, I shown how to use a very useful tool called latexdiff for researchers who are writing their papers using Latex.

Philippe Fournier-Viger is a professor of Computer Science and also the founder of the open-source data mining software SPMF, offering more than 145 data mining algorithms.

Related posts:

This entry was posted in Academia, General, Latex, Research and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *