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.texlatexdiff 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 CFONTuses colored sans-serif text;-t CHANGEBARadds bars in the margin.--flatten: pull\inputand\includefiles into one before comparing.--math-markup=wholemarks a changed equation as a whole;offleaves 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
\deletedand\replacedcannot span a paragraph break; mark each paragraph separately.- With the changes package, define every author with
\definechangesauthorbefore using itsid. - A latexdiff of documents in different classes (after moving to another journal) mixes two layouts; compare versions that use the same class.
- latexdiff compares the source, so changes made only in the .bib file do not show; compare the .bbl or list the new references in the response letter.
In journal templates
- Journals that ask for a "marked" or "tracked" manuscript usually want it as an extra PDF beside the clean revision; compile diff.tex with the journal class so the pages match.
Errors you may meet
- Paragraph ended before \<name> was complete.A blank line (paragraph break) appeared inside an argument or maths environment that cannot contain one, often because a } or \end{…} is missing.
- Undefined control sequence.LaTeX met a command it does not know: usually a typo, or a command whose package is not loaded. The log's l. line ends with the culprit.
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
- Adding line numbers to a LaTeX manuscript for peer reviewNumber the lines of a manuscript with the lineno package: \linenumbers, every fifth line, both columns, around equations, and journal review options.
- Double spacing a LaTeX manuscript for submissionDouble-space a LaTeX document with the setspace package (\doublespacing, \setstretch), or a journal class's review option.
The examples on this page were compiled with pdfLaTeX to check that they work as shown. LaTeX quick reference · LaTeX errors explained