Show changes between two versions of a LaTeX paper

Help centre › LaTeX › Review and submission · Packages: changes

Run latexdiff old.tex new.tex > diff.tex and compile diff.tex: insertions appear underlined in blue and deletions struck through in red. To mark edits by hand instead, load the changes package and write \added{new text}, \deleted{old text} and \replaced{new}{old}; \usepackage[final]{changes} later removes the marks.

A complete example

A whole document: paste it into an empty project and compile it.

\documentclass{article}
\usepackage{changes}
\definechangesauthor[name={Reviewer 1}, color=orange]{R1}
\begin{document}
We measured the samples \added{twice, on separate days,} at room temperature.
The effect was \deleted{very} small and \replaced{consistent}{repeatable}.
\added[id=R1]{As Reviewer 1 suggested, we also report the error bars.}
\listofchanges
\end{document}

latexdiff: compare two versions

latexdiff is a TeX tool, included in the main TeX distributions, that compares two .tex files and writes a third with the differences marked. Compile the result like any other document, with the same class, packages and .bib as the new version.

latexdiff submitted.tex revised.tex > diff.tex
pdflatex diff.tex

# documents split with \input or \include
latexdiff --flatten submitted/main.tex revised/main.tex > diff.tex

# compare with an earlier commit in a git repository
latexdiff-vc --git -r HEAD~1 main.tex

latexdiff options

When diff.tex does not compile, the usual cause is a change inside a command latexdiff cannot mark (a table, a caption with maths, a custom macro). Compare with --math-markup=off, exclude the command, or fix the few lines by hand in diff.tex.

  • -t UNDERLINE (default): additions with a wavy blue underline, deletions struck through in red. -t CFONT uses colored sans-serif text; -t CHANGEBAR adds bars in the margin.
  • --flatten: pull \input and \include files into one before comparing.
  • --math-markup=whole marks a changed equation as a whole; off leaves maths unmarked, which helps when complex equations break the diff.
  • --exclude-textcmd="section,subsection": leave changes inside those commands unmarked, useful when headings cause errors.

The changes package: marking edits by hand

  • \added{text}, \deleted{text}, \replaced{new}{old}, \highlight{text}: the marks.
  • \definechangesauthor[name={…}, color=…]{ID}, then \added[id=ID]{…}: each author or reviewer in a color of their own.
  • \added[comment={Reviewer 2, point 3}]{…}: a note beside the change.
  • \listofchanges: a list of every change with its page, handy for a response letter.
  • \usepackage[final]{changes}: the accepted text with every mark removed, without editing the source.

Which to use

latexdiff marks everything that changed, without touching your source, and suits a full marked manuscript. The changes package marks only what you choose and lets you tie a change to the reviewer who asked for it, at the cost of writing the marks as you edit.

Common mistakes

In journal templates

Errors you may meet

In Manulyx

Turn on Track changes to record every edit with its author; PDF with these changes marked compiles the paper with insertions underlined in blue and deletions struck through in red. For a revision, Marked manuscript (PDF) compares it with the submitted stage across every .tex file, and Highlighted manuscript (PDF) shows new and changed text in blue.

Write in Manulyx for free · Journal templates

Related

The examples on this page were compiled with pdfLaTeX to check that they work as shown. LaTeX quick reference · LaTeX errors explained