latex-diff on Windows with Cygwin

less than 1 minute read

The Perl script latexdiff generates highlighted differences between two versions of a LaTeX document. This is required in submitting academic paper revisions.

  • Cygwin: setup-x86_64 -P perl texlive-binextra
  • Linux: apt install latexdiff

Then use script latexdiff_recursive.sh to execute recursively for all .tex files in the directory. This is useful for very large projects like Ph.D. thesis or journal article.

#!/bin/bash
# Runs latexdiff on every file in a directory
#
# Cygwin prereqs: 
# texlive-collection-bibtexextra texlive-collection-binextra perl
#
# Michael Hirsch

old=$1
new=$2
main=$3 #optional for compilation

flist=$(find -H $old -maxdepth 1 -type f -name "*.tex")


for f in ${flist[*]}; do
    b=${f##*/}   #$(basename $f)
    latexdiff $old/$b $new/$b > /tmp/$b
done

echo "output to /tmp"

if [[ -n $main ]]; then
  (
    cd /tmp
    pdflatex $main
    bibtex $main
    pdflatex $main
    pdflatex $main
  )
fi

Tags:

Categories:

Updated:

Leave a Comment