Making latexdiff play nicely with apacite

Latexdiff is a script that produces a word-by-word diff of two versions of a latex file that can be compiled to mark up additions and deletions.  It generally works well for me except for one important caveat: it doesn’t recognize the citation command syntax from apacite, the package I use to get APA-style citations.  Luckily, being open-source, I could just fork the repository and fix it.

Latexdiff uses a latex-aware difference algorithm that treats latex commands as single “words”. The problem is that apacite allows citations of the form

\cite<text before citation>{AuthorYear}

Normally, a \cite command is only followed by arguments in […] or {…}. Latexdiff sees the < and thinks that the command is over and it can safely split things.  But this results in the \cite command being separated from its arguments in the diff which then refuses to compile.

The fix is easy and should be incorporated into the next version that’s released. But in the meantime, if you’re suffering as I was you can clone my fix:

git clone git@github.com:kleinschmidt/latexdiff.git
cd latexdiff
git checkout anglebracket-cite-command
ln -s latexdiff /usr/local/bin/latexdiff   # or wherever you like

Advertisements



    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s



%d bloggers like this: