This guide explains how to set up latexdiff-based tracking in Overleaf to prepare revision submissions with highlighted changes. Follow the steps carefully in order.
- Open your project in Overleaf.
Go to
Menu > Dropboxand confirm your folder is synced with your ASU Dropbox account. - On your local computer, you can find the Overleaf-synced directory in
~/Users/<your-username>/Apps/Overleaf/, for example. - Inside your Overleaf project folder:
- If you do not already have a
backupsdirectory, create one in the root directory of your project. - Create a zip archive of your last submitted files and all figures.
- Move the zip file into the
backupsfolder. - Name it clearly, e.g.,
0-backup-original-submission.zip.
- If you do not already have a
- Create a new subdirectory in your Overleaf project, e.g.,
1-original-submission. - Copy the last submission files (not zipped) into this new directory.
- These files will serve as the baseline for comparison with revised files in the project root directory.
- In your root directory, check whether
z-diff.texexists. - If not, create it and copy in the following code:
%%%%%%%%%%%%%%%%%
% How to use:
% 1. Make a copy of the old version (including all files) and save it in the "older-version" folder.
% 2. If your main file name differs from main.tex, update the filename in the command below. Do not change "main-d.tex".
% 3. Compile z-diff.tex to see tracked changes in PDF. Compile main.tex (or your own main file) to see a clean PDF without changes.
% - If you want to monitor differences continuously during revision, set diff.tex as your main file in Overleaf.
% - Otherwise, keep main.tex as your main file and compile diff.tex only when needed.
%%%%%%%%%%%%%%%%%
% Local LaTeX compilers:
% - This file also works locally for latexdiff compilation.
% - Use the option "--disable-citation-markup" to prevent errors. This is unnecessary in Overleaf but required locally.
%%%%%%%%%%%%%%%%%
% If compilation fails, clear the cache and recompile.
\RequirePackage{shellesc}
% Update the line below with your own manuscript filenames:
\ShellEscape{latexdiff -p ./diff-pre.tex --flatten --allow-spaces ./0-original-submission/0--manuscript.tex ./0--manuscript.tex > y-main-d.tex}
\input{y-main-d} % Do not change this
\documentclass{article} % Use a standard document class
\usepackage{graphicx} % For figures
\usepackage{cite} % For citations
\title{}In z-diff.tex, update the following line to use the correct filenames of your manuscript. Change ./0-original-submission/0--manuscript.tex, and ./0--manuscript.tex. Do not change y-main-d.tex.
\ShellEscape{latexdiff -p ./diff-pre.tex --flatten --allow-spaces ./0-original-submission/0--manuscript.tex ./0--manuscript.tex > y-main-d.tex}Check if diff-pre.tex exists in your root directory. If not, create one and copy this code:
\RequirePackage[normalem]{ulem}
\RequirePackage{color}
\definecolor{light-gray}{gray}{0.6}
\definecolor{lblue}{rgb}{0.6,0.6,1}
%DIF PREAMBLE
\RequirePackage[stable]{footmisc} %DIF PREAMBLE
%\RequirePackage{changebar} %DIF PREAMBLE
%\providecommand{\DIFadd}[1]{#1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{\textcolor{violet}{#1}} %DIF PREAMBLE
%\providecommand{\DIFdel}[1]{{\protect\color{red} [..\footnote{removed: #1}]}\xspace}
%\providecommand{\DIFdel}[1]{\textcolor{light-gray}{{#1}}}
\providecommand{\DIFdel}[1]{{\protect\color{lblue}\sout{#1}}}
%DIF PREAMBLE in the line above, strike through often has issues with math and others. So I am trying color differences for removed.
%DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
%\providecommand{\DIFaddbegin}{\protect\color{blue}} %DIF PREAMBLE
%\providecommand{\DIFaddend}{\protect\color{black}} %DIF PREAMBLE
%\providecommand{\DIFdelbegin}{\protect\cbdelete} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLECheck whether preamble-rebuttal.tex exists. If not, create it with the code below:
\nolinenumbers
\clearpage{}
\setcounter{equation}{0}
\setcounter{figure}{0}
\setcounter{table}{0}
\setcounter{page}{1}
\setcounter{section}{-1}
\makeatletter
\renewcommand{\theequation}{L\arabic{equation}}
\renewcommand{\thefigure}{L\arabic{figure}}
\renewcommand{\thetable}{L\arabic{table}}
\renewcommand{\thesection}{L\arabic{section}}
\renewcommand{\thepage}{L\arabic{page}}
%\newenvironment{reviewer}{\par\addvspace{0.2\baselineskip}\small\color{blue}}{\par\addvspace{0.2\baselineskip}} %\fontfamily{cmvtt}\selectfont
%\newenvironment{reviewer}{\par\addvspace{0.5\baselineskip}\color{blue}}{\par\addvspace{0.5\baselineskip}} %\fontfamily{cmvtt}\selectfont
\newenvironment{reviewer}{%
\par%
\vspace{1.2\baselineskip}%
\begingroup%
\small%
\setlength{\baselineskip}{0.8\baselineskip}%
\color{blue}%
%\itshape%
\setlength{\parskip}{0pt}%
\ignorespaces%
}{%
\par%
\vspace{0.\baselineskip}%
\endgroup%
}Make the following changes to your main .tex file (e.g., my_main.tex) in the rev folder.
Do not modify files in the org folder.
- At the top of the document, ensure these lines are included:
\usepackage{lineno}
\usepackage[usenames, dvipsnames]{color}- Just before
\end{document}, insert:
\newpage
\renewcommand{\figurename}{\bf Fig.}
\renewcommand{\tablename}{\bf Table}
\input{1-letter.tex}- In the original submission version (inside
0-original-submission), add this instead at the same location.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\renewcommand{\figurename}{\bf Fig.}
\renewcommand{\tablename}{\bf Table}
\input{../1-letter.tex}- Create a new file named
1-letter.texand add the following:
\input{preamble-rebuttal}
\setlength{\parindent}{0pt}
\setcounter{page}{1}
%%%%%%%%%%%%%%%%
\section{Editor}
\begin{reviewer}
Copy the editor’s letter here
\end{reviewer}
Dear Dr.~XXXX,
Paste the editor’s letter text here.
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\Large\bf Response to Reviewers}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Referee \#1}
\begin{reviewer}
Copy and paste reviewer comment here
\end{reviewer}
Your response here.
Example reference to lines: lines~\ref{ln:begin:example}--\ref{ln:end:example}.- To reference line numbers in your manuscript, add labels like this in your main tex file:
\linelabel{ln:begin:example} I revised this part. \linelabel{ln:end:example}- Ensure Shell escape is enabled in Overleaf: go to Menu > Settings > Compiler Settings > Enable shell escape.
- Always compile
z-diff.texto see tracked changes and main tex file to see the clean version. - If compilation fails, clear Overleaf’s cache (Menu > Clear cached files and recompile).
- Keep old files intact in the org or
0-original-submissionfolders. Only revise files in the root folder.
With this setup, you will have:
- A clean version of your revised manuscript.
- A tracked version highlighting differences with latexdiff.
- An integrated rebuttal letter at the end of the revised manuscript.