Track changes is a popular tool in Word. If you are looking for something similar for LaTeX latexdiff is the answer. For example if you are an academic researcher submitting papers to journals, you will most likely have to go through stages of revisions. Each time you will probably have to submit a marked-up document with all the changes. latexdiff will do that for you with minimal effort.
latexdiff is a Perl script. If you are on a Mac, Perl and latexdiff will most likely be already installed. On a Windows machine you might need to install them.
Using latexdiff is very simple. My two tex
documents are called old.tex
and new.tex
. I am interested in how the document changed from the old to the new version. All you need to do is put the following two lines of code to created and compile the diff-file.
latexdiff old.tex new.tex > diff.tex pdflatex diff.tex
The marked-up document diff.pdf will look like this:
A number of different mark-up styles are available. To change the type of the mark-up style use the following code.
latexdiff -t TYPEOPTION old.tex new.tex > diff.tex pdflatex diff.tex
TYPEOPTION
can be any of the following:
UNDERLINE
CTRADITIONAL
TRADITIONAL
CFONT
FONTSTRIKE
INVISIBLE
CHANGEBAR
CCHANGEBAR
CULINECHBAR
CFONTCBHBAR
BOLD
PDFCOMMENT
The default type is UNDERLINE
. Many more options are available to customize your diff-file. Refer to the latexdiff package manual to learn more.
Be aware: if you change an image, but not its name <a href="https://ctan.org/pkg/latexdiff?lang=en">latexdiff</a>
will not highlight this as a change. However it will highlight it if you change the name of the image, but not the image itself.
dre
where do i put the code?
tom
Hi dre,
Save a copy of the old and new version of your tex file in a directory. Next, use
latexdiff
in the command line to compare the two as shown in the post.HTH,
Tom
Dusty
Although these types of tools are tempting, I really think we should be teaching Latex users to use Git. The problems of collaborative and versioned documents are not trivial, and Git has solved them in a robust way that is now an industry standard. Along with the tool itself comes an entire ecosystem of collaborative tooling (like GitHub), that makes it possible for the less initiated to participate. In addition, Git knowledge translates to languages other than Tex, and is broadly useful.
tom
Hi Dusty,
Thanks, I fully agree with you. Nevertheless, there are drawbacks to using Git and the collaborative platforms (GitHub/Bitbucket/etc.). It can be overwhelming for someone who has never used a version control system before. Also, not all features on the collaborative platforms are free. Another alternative might be to use a LaTeX online editor (such as Overleaf), which often have track-changes functionality integrated.
Would you be interested in writing a beginner-level guest post on using Git with a LaTeX project?
Best,
Tom