CommunityData:LaTex Diff: Difference between revisions

From CommunityData
No edit summary
No edit summary
 
Line 9: Line 9:
You will need the original version of the .tex file. If needed, you can checkout the git commit that you made when you created the original submitted version. Or, if using Overleaf, use the history to go back to that version.  
You will need the original version of the .tex file. If needed, you can checkout the git commit that you made when you created the original submitted version. Or, if using Overleaf, use the history to go back to that version.  


If you are using knitr, then you will need to create the .tex file from the .Rtex file. If you are using Overleaf + .Rtex, this is easy: the files are in a hidden spot, but can just be downloaded. Next to the 'Recompile' button in Overleaf is a button with tooltip 'Logs and output files'. Clicking this will make a button visible at the bottom right titled 'Other logs and files' -- if you hold down on the button, you'll be able to donate two key files: main.tex (the cached file Overleaf generated when it compiled your knitr code into the document text) and output.bbl. You will need both of these files not only for latexdiff, but also for uploading into the arXiv. Rename output.bbl to diff.bbl so that latexmk can find it.
If you are using knitr, then you will need to create the .tex file from the .Rtex file. If you are using Overleaf + .Rtex, this is easy: the files are in a hidden spot, but can just be downloaded. Next to the 'Recompile' button in Overleaf is a button with tooltip 'Logs and output files'. Clicking this will make a button visible at the bottom right titled 'Other logs and files' -- if you hold down on the button, you'll be able to download main.tex (the cached file Overleaf generated when it compiled your knitr code into the document text).


Save this .tex file as <code>orig.tex</code>.  
Save this .tex file as <code>orig.tex</code>.  

Latest revision as of 00:39, 12 February 2024

The Scenario[edit]

You've been given an R+R. Congrats! Often, it's either helpful or required to submit a version of your paper that shows what changed from the original version.

latexdiff[edit]

Fortunately, there is a tool designed for just this: latexdiff.

You will need the original version of the .tex file. If needed, you can checkout the git commit that you made when you created the original submitted version. Or, if using Overleaf, use the history to go back to that version.

If you are using knitr, then you will need to create the .tex file from the .Rtex file. If you are using Overleaf + .Rtex, this is easy: the files are in a hidden spot, but can just be downloaded. Next to the 'Recompile' button in Overleaf is a button with tooltip 'Logs and output files'. Clicking this will make a button visible at the bottom right titled 'Other logs and files' -- if you hold down on the button, you'll be able to download main.tex (the cached file Overleaf generated when it compiled your knitr code into the document text).

Save this .tex file as orig.tex.

Now, go back to the current version of the manuscript (e.g., by checking out the main branch in git). If your current file is called new.tex, then create the diff file with:

latexdiff orig.tex new.tex > diff.tex

Finally, you create the PDF of the diff with:

latexmk -f -pdf diff.tex