Terminal with olcli diff and olcli diff --latexdiff --pdf: marked up main.tex and compiled main-diff.pdf on Overleaf

latexdiff for Overleaf: A Marked-Up PDF of Your Revision in One Command

Your advisor reads your revision on paper, or at least on a PDF. A unified diff of .tex files is the wrong artifact for that. What advisors, coauthors and journal editors ask for is a marked-up PDF: deleted text struck through, new text underlined, everything else as it will appear in print.

latexdiff has produced exactly that for years. The friction is everything around it when your paper lives on Overleaf: export the old version, export the new one, run latexdiff, then compile the result with a local TeX installation that matches what Overleaf uses. Since version 0.16.0, olcli does all of it in one command.

Terminal recording: olcli diff shows a local edit to main.tex, then olcli diff --latexdiff --pdf produces a marked-up PDF compiled on Overleaf

The short version

olcli diff --latexdiff --pdf

Run it inside a project you pulled with olcli, after editing locally. It writes two files:

  • .olcli-diff/main-diff.tex: your document with the revision marked up
  • .olcli-diff/main-diff.pdf: the same document, compiled on Overleaf

Marked-up PDF from latexdiff: 91 and about two hours struck through in red, 94 and under 90 minutes underlined in blue

Struck through is what is on Overleaf right now. Underlined is what you changed locally. That is the PDF you send to your advisor before you push.

Setup in three commands

Install olcli with Homebrew or npm:

brew install aloth/tap/olcli
# or
npm install -g @aloth/olcli

Sign in and download a project:

olcli auth --browser
olcli pull "My Paper"
cd My_Paper

olcli auth --browser opens the Overleaf login page in a separate browser window with a temporary profile. You sign in there as usual, including SSO or two-factor, and olcli keeps only the session cookie. It needs Node 22 or newer; on older setups olcli auth --cookie asks for the cookie instead.

You also need latexdiff on your PATH. It ships with TeX Live and MacTeX. You do not need a working LaTeX compiler: the PDF is compiled on Overleaf.

All of this works on the free Overleaf plan. I checked it on a free overleaf.com account before the release.

A typical revision round

olcli pull                       # start from the current version on Overleaf
vim chapters/results.tex          # revise with your own editor
olcli diff                        # plain text diff, for yourself
olcli diff --latexdiff --pdf      # marked-up PDF, for your advisor
olcli push                        # upload once the changes are agreed

Your coauthors keep working in the Overleaf web editor the whole time. Nothing about the project changes for them.

What happens under the hood

olcli diff downloads the project as it is on Overleaf at that moment and compares it with your local files. With --latexdiff, both sides go to latexdiff instead of a text diff. Because the comparison is always against the live project, the marked-up PDF also shows if a coauthor changed something on Overleaf that you do not have locally.

Overleaf can only compile files that are part of the project. So --pdf uploads the marked-up document as olcli-latexdiff.tex, compiles it, downloads the PDF and deletes the file again. The command tells you before it does this, refuses to touch an existing file with that name, and prints the exact cleanup command if the deletion fails.

\input and \include are inlined before the comparison, so changes in chapter files show up in the marked-up PDF. Without that, Overleaf would compile the old chapter files that are still in the project and every chapter would look unchanged.

Options worth knowing

  • --main thesis.tex picks the root document when more than one file declares \documentclass
  • -o draft-v2-diff.tex writes the marked-up source somewhere else
  • --latexdiff-opt --math-markup=0 passes any option straight to latexdiff, for example to leave equations alone
  • --no-flatten keeps \input and \include as they are

One limit: the PDF is compiled against the project on Overleaf, not against your working directory. A .sty or .cls file you only have locally makes the compile fail, and olcli writes the compiler log next to the marked-up source. A figure you only have locally does not: Overleaf draws a placeholder box and the rest of the PDF is fine.

Bonus: catch drift in CI

The same command has a mode for scripts. olcli diff --exit-code exits with 0 when nothing differs, 1 when something does and 2 when the check itself failed, for example because the session expired. That makes it a useful scheduled job if you keep a copy of the paper in a git repository and want to know when the Overleaf version moves away from it. The details are in the diff documentation.

Try it

olcli is open source under the MIT license. Install it, pull a project and run olcli diff --latexdiff --pdf on your next revision. Questions, ideas and bug reports are welcome on GitHub.