Everything below about latexdiff, latexdiff-vc and latexpand comes from their own documentation: the manual embedded in the latexdiff source and the help text of latexpand, both read on 2026-10-13. I did not run the commands for this page, because neither program is installed on the machine I wrote it on, so there is no sample output here. Run them on a copy of your project first.
Which tool for which job
- latexdiff compares two versions and produces a PDF where additions and deletions are visible on the page. Use it when an editor or co-author wants to see the changes without opening your source. It is the closest LaTeX has to Word's tracked changes, and the guide to showing changes between two LaTeX versions explains what it marks.
- A version-control history (git) answers a different question: what changed, when, and who changed it. It is what feeds
latexdiff-vcbelow. - Overleaf history keeps earlier versions of a project inside Overleaf. I have not tested its comparison features for this guide, so check Overleaf's own documentation for what it can show and export before relying on it for a journal submission.
One file
With a single .tex file per version:
latexdiff old.tex new.tex > diff.tex
pdflatex diff.tex
The manual says the old and new files must be real files, not pipes. It also says the preamble is compared line by line while the body is compared word by word, so a changed preamble shows up as commented lines (%DIF) rather than as marked text.
A project with several files
latexdiff compares the text of the two files you give it. If the main file only contains \input{intro}, a comparison of two main files sees an unchanged line. You need the included text in front of latexdiff. There are three ways to get it.
Option 1: latexdiff-vc with git
If the project is in a git repository, latexdiff-vc (installed alongside latexdiff) can check out two revisions into a temporary directory, flatten them and compare them. From the documentation:
# working copy against the last commit
latexdiff-vc --git --flatten -r HEAD main.tex
# two named revisions
latexdiff-vc --git --flatten -r v1-submitted -r HEAD main.tex
Here v1-submitted stands for any tag, branch or commit in your repository. Points from the documentation worth knowing:
- Run it from the directory that holds the project. That directory defines the subtree that is checked out.
- Files that
--flattendoes not pull in, such as package files and graphics, have to be reachable from the current directory. - For BibTeX, the manual recommends keeping the
.bblfile under version control. Recent versions also try to run bibtex in the checked-out copies, which only works if the.biband.bstfiles are tracked or on bibtex's search path. - If you renamed the main file between the two revisions, add
--old-filewith the old name. - The name of the difference file is chosen automatically and printed.
--pdfalso runs pdflatex on it, and--forceoverwrites an existing diff file without asking.
Option 2: flatten with latexpand, then compare
If the versions are two folders rather than two commits, flatten each one first. latexpand expands \input and \include and, by default, strips comments.
latexpand old/main.tex -o old-flat.tex
latexpand new/main.tex -o new-flat.tex
latexdiff old-flat.tex new-flat.tex > diff.tex
Two options from its help text matter for manuscripts. --keep-comments keeps comment lines, which is the documented workaround for verbatim blocks, because latexpand does not recognise verbatim environments and would strip a % inside one. --expand-bbl FILE inlines a compiled .bbl file; --biber FILE does the same for biblatex with biber. Compile diff.tex in the folder of the new version, or copy that version's figures and class files next to it, so LaTeX can find them.
Option 3: let latexdiff flatten
latexdiff has its own flag:
latexdiff --flatten old/main.tex new/main.tex > diff.tex
The manual says this replaces \input and \include in the body with the file contents, recursively, honours \includeonly, and also handles \import, \subimport and \subfile. It assumes included files sit in the same directories as the old and new main files. It also warns that processing time can become prohibitive for larger documents and that the result no longer reflects the structure of your input files. If it is slow on a long thesis, option 1 or 2 is the fallback.
Common failures and the options that exist for them
Every option below is listed in the latexdiff manual. Add them to the same command line.
- Errors from changed equations. Try
--math-markup=whole, which compares whole equations. If that still fails,--math-markup=offremoves equation markup, and deleted equations then do not appear. The default iscoarse;finemarks small changes inside equations. - Deleted math underlined instead of struck out. The manual attributes this to the ulem package. It says that loading
amsmathmakes deleted passages get wrapped in\text; if amsmath comes in through another package, add--packages=amsmath. - Overfull boxes around changed citations. latexdiff wraps changed citations in
\mbox. The manual offers-t CFONT(no ulem),--disable-citation-markup(deleted citations are not shown, added ones are shown plain), or--append-mboxsafecmdfor custom citation commands. - A custom command whose argument is text. latexdiff compares a command and its arguments as one unit, so a change inside
\mynote{...}is marked as the whole command. If the last argument is ordinary text,--append-textcmd="mynote"lets it be compared word by word. The value is a regular expression matched against the whole command name without the backslash, and a comma-separated list needs quotes in the shell. - A command that breaks inside the markup.
--exclude-safecmd="cmdname"removes it from the list of commands allowed inside added or deleted text, and--append-safecmdadds one to that list.--exclude-textcmddoes the same for the text-command list. - Spaces between a command and its braces. latexdiff assumes arguments directly follow the command.
\section {Title}can go wrong; write\section{Title}, or try--allow-spaces, which the manual says may have side effects. - Tables and figures. The manual says a "Misplaced \noalign" error can come from certain table changes, and its stated workaround is
--graphics-markup=none. For a passage that still breaks, wrap it in%BEGIN DIFNOMARKUPand%END DIFNOMARKUPcomments in the new file and rerun. Markup is suppressed there and the new text is shown. - Different look.
--type(short form-t) picks the style. The default isUNDERLINE. Others in the manual includeCTRADITIONAL(changes shown as footnotes),CFONT,CCHANGEBARandPDFCOMMENT.
A moved paragraph is compared as text, so it shows as deleted in one place and added in another. The manual describes no move detection.
What our online tool does today
Everything here is taken from the LaTeX diff tool page itself.
- You upload an old and a new version. Each can be a single
.texfile (up to 5 MB) or a project.zipwithmain.texat the root (up to 10 MB). - You choose pdfLaTeX or XeLaTeX and can add a legend that explains the colors.
- The output is a PDF with additions in blue and underlined and deletions in red and struck through.
- For zip uploads, the page says the new version's assets, such as figures and styles, are used for compilation.
- Changes inside tables are shown in final form only and are not marked.
- The page says files are processed in an ephemeral container, discarded immediately and never written to disk.
The tool page does not list any latexdiff options, so you cannot pass --math-markup or --append-textcmd to it, and it does not say how it handles a bibliography. If your project needs those, run latexdiff locally with the commands above. Install LaTeX on a Mac if you do not have a TeX distribution yet.
After the PDF
Check your journal's submission instructions for whether it wants a marked-up PDF. Producing a diff PDF for journal resubmission covers producing one. To compile the project itself in a browser, see compile a LaTeX project online, and check your response letter before resubmitting before it goes out.