Are you missing the track changes function in LaTeX? Only to point out the changes you made for the reviewers to note them, but is the functionality of the full track changes package to large? . This little snippet of code will help to do that. It is developed for the Elsevier template files and can be easily included by adding a .sty file in your folder. The only downside, when submitting your .tex files to elsevier, you have to remove the \added, \removed and \changed tags in order for the compiler to understand your code.

In order for the package to work, do the following:

  • create a trackchanges.sty file containing the code at the bottom of this post
  • add \usepackage{trackchanges} to the preamble of your article
  • adjust your text using one of the following commands:
    • \removed{the text you want to remove} will result in red strike through text
    • \added{new text}will result in green new text
    • \changed{new text}{old text}will combine the two above, new text will have the added markup, old text the removed markup

    When building your .tex document twice, change bars will also be added in the margin of the document.


The snippet of code:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{trackchanges}[2013/02/20 tvandenbrande style for track changes in the elsevier template]
\RequirePackage{changebar}
\RequirePackage{xcolor}
\RequirePackage{ulem}

\newif\ifdiff
\difftrue % activate this line to show the changes
%\difffalse %activate this line to apply changes

\ifdiff
\newcommand{\removed}[1]{\cbstart\removedfragile{#1}\cbend{}}
\newcommand{\removedfragile}[1]{{\sout{\color{red}{#1}}}{}}
\newcommand{\added}[1]{\cbstart\addedfragile{#1}\cbend{}}
\newcommand{\addedfragile}[1]{{\color{green!50!black}{#1}}{}}
\else
\newcommand{\removed}[1]{} % non-markup version
\newcommand{\added}[1]{#1}
\newcommand{\addedfragile}[1]{#1}
\fi
\newcommand{\changed}[2]{\added{#1}\removed{#2}}

\endinput

One thought on “Highlighting changes in LaTeX”

React!