Skip to content

Instantly share code, notes, and snippets.

@SHDShim
Last active August 20, 2025 17:41
Show Gist options
  • Save SHDShim/d5755e861985cb51d26d5de19a3c4444 to your computer and use it in GitHub Desktop.
Save SHDShim/d5755e861985cb51d26d5de19a3c4444 to your computer and use it in GitHub Desktop.
How to prepare for revision in overleaf

How to Set Up LaTeX Overleaf Tracking for Revisions

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.

Step 1. Backup Your Last Submission

  1. Open your project in Overleaf. Go to Menu > Dropbox and confirm your folder is synced with your ASU Dropbox account.
  2. On your local computer, you can find the Overleaf-synced directory in ~/Users/<your-username>/Apps/Overleaf/, for example.
  3. Inside your Overleaf project folder:
    • If you do not already have a backups directory, 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 backups folder.
    • Name it clearly, e.g., 0-backup-original-submission.zip.

Step 2. Save a Directory Copy of the Last Submission

  1. Create a new subdirectory in your Overleaf project, e.g., 1-original-submission.
  2. Copy the last submission files (not zipped) into this new directory.
  3. These files will serve as the baseline for comparison with revised files in the project root directory.

Step 3. Create Setup Files for Tracking

(a) z-diff.tex

  1. In your root directory, check whether z-diff.tex exists.
  2. 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}

(b) diff-pre.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 PREAMBLE

(c) preamble-rebuttal.tex

Check 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%
}

Step 4. Update Your Main Document

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.

  1. At the top of the document, ensure these lines are included:
\usepackage{lineno}
\usepackage[usenames, dvipsnames]{color}
  1. Just before \end{document}, insert:
\newpage
\renewcommand{\figurename}{\bf Fig.}
\renewcommand{\tablename}{\bf Table}
\input{1-letter.tex}
  1. 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}

Step 5. Writing the Rebuttal Letter

  1. Create a new file named 1-letter.tex and 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}.
  1. 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}

Additional Notes

  • Ensure Shell escape is enabled in Overleaf: go to Menu > Settings > Compiler Settings > Enable shell escape.
  • Always compile z-diff.tex to 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-submission folders. 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment