How to make a marked (tracked-changes) manuscript in LaTeX
With a revised paper, most journals ask for a version that shows what changed. Word users switch on tracked changes; LaTeX has no such switch, because the source is plain text and the PDF is built from it. The standard tool is latexdiff, which compares two versions of a .tex file and writes a third that typesets the differences. This guide explains what journals ask for, how to use latexdiff, and how to deal with the cases where its output does not compile.
What journals ask for
- A marked manuscript (“tracked changes”): deleted text struck through, new text underlined or in colour.
- A highlighted manuscript: the revised text with new and changed passages in colour, and deleted text not shown.
- A clean manuscript: the revision with no marking, usually as well.
Read the instructions for the journal you are revising for: some want one of the first two, some want both, and some ask authors to mark changes by hand. For a small revision, marking by hand is reasonable. Wrap new text in \textcolor{blue}{...}, or use the changes package, whose \added{...}, \deleted{...} and \replaced{new}{old} commands produce a marked version, and a clean one when the package is loaded with the final option. For a substantial revision, generating the comparison is faster and more complete.
latexdiff in one command
latexdiff is included in TeX Live and MiKTeX. It is a Perl script, so it needs Perl; if it stops with “Can’t locate Algorithm/Diff.pm”, install that Perl module. It also needs the version you submitted, so keep a copy of it (a tagged commit, or a folder you do not edit) before you start revising. Then:
latexdiff submitted.tex revised.tex > diff.tex
pdflatex diff.texlatexdiff writes to standard output, hence the redirection. In its default style, deleted text is struck through in red and new text has a wavy blue underline. The diff file has the preamble of the revised file plus the marking commands, so compile it in the revised version’s folder, where its class, packages, figures and bibliography are found, and run BibTeX or biber as you would for the paper itself.
If the revision is in git, latexdiff-vc does the checkout for you: latexdiff-vc --git -r v1-submitted main.tex compares the working file with the revision tagged v1-submitted. On Windows, latexdiff’s own documentation recommends running it from the Command Prompt rather than PowerShell, where the character encoding of the output can break.
Manuscripts split across files
latexdiff compares the two files it is given and nothing else. If the text lives in files brought in with \input or \include, as a thesis or a long paper usually does, comparing the main files alone marks almost nothing. The --flatten option replaces each \input and \include with the contents of the file before comparing (it also handles \subfile, \import and \subimport):
latexdiff --flatten submitted/main.tex revised/main.tex > revised/main-diff.texThe included files are looked for beside each main file, so keep two complete copies of the project in separate folders. With --flatten, a \bibliography command is also replaced by the contents of its .bbl file when one exists. Run BibTeX on both versions first, and the reference list is compared too.
When the result does not compile
latexdiff has to place its marking inside somebody else’s document, and some constructions resist it. The common failures, and the options its documentation gives for each:
- Equations. Changes inside complicated display maths can produce invalid LaTeX.
--math-markup=wholemarks a changed equation as a whole;--math-markup=offshows only the new version. - Figures and tables. A changed
\includegraphicsis framed in blue by default. Some changes inside tables produce “Misplaced \noalign” errors;--graphics-markup=noneis the documented work-around. - Custom macros. latexdiff only marks inside commands it knows to take text. If your own command takes text as its last argument,
--append-textcmd=mycommandlets it mark changes inside;--append-safecmddeclares a command safe to sit inside the marking. - Citations inside the marking. The default style underlines and strikes through with the ulem package, which handles citations badly, so latexdiff wraps changed citations in
\mbox. A box cannot break across lines, which causes overfull lines.-t CFONTmarks changes with colour and font instead of ulem;--disable-citation-markupstops marking citations. - A passage that still fails. Surround it in the revised file with
%BEGIN DIFNOMARKUPand%END DIFNOMARKUP: it is shown as it now reads, without marking, and the rest of the document is still marked.
The same ulem limitation applies when you mark changes by hand. With natbib and hyperref loaded, a citation with a page number inside \uwave or \sout stops the compile with Extra }, or forgotten \endgroup; boxing it, as in \mbox{\cite[p.~3]{key}}, fixes it. And if your preamble already loads ulem without options, a second load with an option, such as latexdiff’s \RequirePackage[normalem]{ulem}, stops with “Option clash for package ulem”. Add the option to your own \usepackage line, or remove it from the diff file’s preamble.
The highlighted version
Since version 1.3.3, latexdiff’s --no-del option leaves deleted text out of the diff altogether, which gives the revised manuscript with additions marked:
latexdiff --no-del submitted.tex revised.tex > highlighted.texCheck latexdiff --help for the options of the version you have installed.
Doing it in Manulyx
Manulyx keeps the version you submitted as a read-only stage, so the comparison does not depend on having kept a copy. From a stage’s menu, or a .tex file’s, Marked manuscript (PDF) compiles the revision against an earlier submitted stage, deletions struck through in red and insertions underlined in blue, across every .tex file in the stage, chapters included, with nothing to flatten. Highlighted manuscript (PDF) gives the same comparison as the revised manuscript itself, with new and changed text in blue and nothing deleted shown.
latexdiff is tried first. When it does not return a complete result, Manulyx uses a conservative differ of its own that is built to compile: it boxes citations in changed lines, and adds its marking commands without package options so that they cannot clash with your preamble. Your source is never changed. If the marked manuscript still does not compile, Manulyx says so and tells you how to download the LaTeX it produced. See The marked and highlighted manuscript, and for the details, How the marked manuscript is built.
More articles
- After a rejection: moving a paper to another journal's template
- Checking your references for retracted papers before you submit
- How to convert a Word document to LaTeX (equations included)
- How to write a response letter to reviewers
- Fixing common BibTeX and biblatex errors
- Choosing and setting up a thesis template in LaTeX
- How Manulyx keeps the version you submitted
- How the marked manuscript is built
- How co-editing keeps your work safe
- All articles