TITLE: Track changes in LaTeX for reviewer comments
DATE: 2020-03-05
AUTHOR: John L. Godlee
====================================================================


I have recently submitted a paper and got reviews back with minor 
changes before publication, YAY! The journal thankfully supplied a 
LaTeX template for writing the paper which made me very happy, so I 
wrote the paper in LaTeX and have been using vimdiff to collaborate 
with co-authors, for those co-authors who are willing to edit .tex 
files, and using .pdf comments for those co-authors who are less 
keen on LaTeX.

Now I have to reply to the reviewers' comments and supply a revised 
version of the manuscript. They recommend on the website using 
"track changes" to make the changes clear in the manuscript, 
however LaTeX doesn't have this functionality, not being a WYSIWYG 
editor. If I was being smarmy I would recommend they use a 
plain-text diff utility, but that's probably not a good way to make 
friends. So I am now looking for a way to do "track changes" in 
LaTeX.

I have found a few notable options while searching the internet:

-   latexdiff - A Perl program which automatically diffs and 
highlights changes between 2 .tex files, conveniently includes 
--flatten if document is divided into separate files using \input 
or \include statements. See also texdiff, a less complex option.
-   changes - A TeX package which allows manual markup with changes 
as comments in the gutter. Conveniently supplies the final option 
to the package declaration, which clears markup.
-   changebar - Adds simple highlighted bars where text has been 
changed.
-   revdiff - A LaTeX package which is built specifically with the 
goal of making the work of reviewers of papers easier by marking 
changes in the text, adding tags and comments.
-   Manually declare highlight options with \newcommand, e.g. 
\newcommand{\added}[1]{\color{added}{}#1}

  [latexdiff]: https://ctan.org/pkg/latexdiff
  [texdiff]: https://www.ctan.org/tex-archive/support/texdiff/
  [changes]: 
https://www.ctan.org/tex-archive/macros/latex/contrib/changes
  [changebar]: 
https://www.ctan.org/tex-archive/macros/latex/contrib/changebar/
  [revdiff]: https://github.com/pedromateo/revdiff-LaTeX

LaTeXDiff

This tool is handy because it automates most of the diff-ing 
between two .tex files, providing simple red strikethrough lines 
when text is removed and blue if text is added. I found that this 
small utility doesn't handle complex changes well though, and is 
best suited to smaller edits like spelling and word choice. When 
whole paragraphs start moving around, a manual commenting system is 
still required, understandably.

I had some small issues getting this to run on the Windows machine 
I am using while working away from home, but I found this Stack 
Overflow page very helpful in providing a solution. I imagine when 
I try it on a UNIX machine the process will be considerably more 
streamlined as perl is already installed.

  [this Stack Overflow page very helpful in providing a solution]: 
https://tex.stackexchange.com/questions/165543/using-latexdiff-in-mi
ktex

Changes

A manual change highlighter, which is well developed. I ran into a 
few conflicts with definition of the \highlight command, which I 
think came from the listings package, but this was solved by 
redefining my lstlisting style.

This package adds:

-   \added and \deleted
-   \replaced
-   \highlight and \comment

It also provides the \listofchanges command which is similar to the 
list of figures output.

It provides options to clear the markup using the final option in 
the package declaration. There are a bunch of other package options 
which change what markup is shown in the output .pdf.

RevDiff

revdiff is another manual change highlighter. I guess the value of 
manual change highlighters is when a single author is preparing a 
document to send back to reviewers, so they can see how you have 
implemented changes. It comes with a few basic functions:

-   \rnew and \rold
-   \rchange
-   \rcomment, \rtcomment, \renclose and \rtenclose

It provides an option to remove markup and display the new version 
with \usepackage[clean]{revdiff}.

The package requires you to download revdiff.sty and keep it 
somewhere it can be foundby each project, like ~/.texmf/.

It's unfortunate that comments appear inline rather than in the 
gutter like "track changes".

Manual:

If your needs are simple, it's not difficult to create a couple of 
custom commands which style the enclosed text to show if something 
has been deleted or added. I've done this for a long time to add 
TODO notes for myself, using:

    \newcommand{\todo}[1]{\textcolor{red}{\textbf{#1}}} 

Summary

The only option I found which didn't give me any issues, and the 
one I ended up using for this project, was revdiff, which contains 
the minimum of commands I need and produces smart looking .pdf 
markup.

For future projects I think I will try and make sure that I will 
try to incorporate latexdiff into my workflow from the start. If I 
change my editing technique then latexdiff will be able to handle 
all of this automatically. Possibly if I have one round of 
latexdiff and then also use revdiff or changes to provide comments.