Skip to content

Instantly share code, notes, and snippets.

@parastuffs
Last active September 9, 2021 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parastuffs/f1cb636c175bb11e9556dac784d080ec to your computer and use it in GitHub Desktop.
Save parastuffs/f1cb636c175bb11e9556dac784d080ec to your computer and use it in GitHub Desktop.
How to use latexdiff with git

In a directory with git VCS: latexdiff-vc --git --flatten -r <rev-hash> full.tex where full.tex is the root tex file, including (or inputting) several subfiles or not.

You can then compile the resulting .tex file: pdflatex -shell-escape full-diff.tex

Note that the --pdf option is supposed to do it in one go, but the need for -shell-escape in my case makes the process fail.

If you simply want to generate a diff file with the previous commit in your tree, you can ommit rev-hash.

hspace causing problems

You might get an error where \hspace{0pt} causes problems. You can either

  1. Remove them all by hand from the resulting .tex
  2. Modify your latexdiff.pl source, in particular (line 2734 in version 1.3.1.1):
<       push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hspace{0pt}$AUXCMD\n" );
---
>       push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hskip0pt$AUXCMD\n" );

Comparing projects with a bibliography

Make sure the .bbl file is in your tree. If it's not in an earlier revision of your tree, you're screwed to generate a diff file with it. A workaround might be to remove the bibtex entries at the end of the diff file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment