Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've been pulling my hair out trying to get latexdiff to work with a mathematics document. It produces output that latex can't compile if one of the files is this:

\documentclass{amsart}
\begin{document}
    \begin{equation} \label{eq:Psi-action}
        2=1+1
    \end{equation}
\end{document}

and the other is this:

\documentclass{amsart}
\begin{document}
    yo
\end{document}

But I think it chokes on other things as well. Am I doing something wrong? Is anyone able to use latexdiff for mathematics documents more than a few lines long? If anyone is able to use it by making some easy changes to their LaTeX code, are there general guidelines about what kind of LaTeX code to avoid?

Update 1: It appears that latexdiff doesn't like things like "\big(". You can sort of get around this by changing every "\big(" to a "\left(".

Update 2: Here is another pair of files that breaks it:

\documentclass{amsart}
\begin{document}
    \begin{equation*}
        X_{[1],n} 
    \end{equation*}
\end{document}

and

\documentclass{amsart}
\begin{document}
    \begin{equation*}
        [1]X_{n}
    \end{equation*}
\end{document}

I had only a few such examples and was able to get around them by just commenting out the offending code, but it would be nice to know if there are any rules of thumb to avoid having to worry about it in the first place, like Andrew's helpful comment about Perl and line breaks.

share|improve this question
    
Yey for latexdiff (but I understand the hair pulling!) –  Yossi Farjoun Aug 5 '10 at 14:08
    
Unfortunately the parsing in latexdiff is based on complicated regular expressions, which means that it can choke on complex documents. This also means that the Perl version can make the difference between latexdiff working or not, as the default regular expression stack size was increased between Perl 5.8 and 5.10. Congratulations on successfully constructing a small example which breaks! Please send it to the author. –  András Salamon Aug 5 '10 at 16:47
    
Thanks. It's encouraging to know some people are able to get it to work. –  James Borger Aug 5 '10 at 21:30
    
@András: Is latexdiff still maintained by its author? The latest version is from over 5 years ago... –  YuppieNetworking May 20 '11 at 8:36
    
@YuppieNetworking: Frederik Tilmann didn't indicate it was abandonware when we exchanged email about a year ago. Also, Perl 5.10+ deals with more complex regular expressions than 5.8, so using a recent Perl might also help. –  András Salamon May 20 '11 at 15:49

1 Answer 1

up vote 7 down vote accepted

I can get the example that you gave to compile by moving the \label{eq:Psi-action} on to a line by itself:

\documentclass{amsart}
\begin{document}
    \begin{equation}
     \label{eq:Psi-action}
        2=1+1
    \end{equation}
\end{document}

Without that, what seemed to be happening was that it was recognising the \end{equation} as the end of a mathematics environment that was in one file but not the other, so it marked it up as \end{MATHMODE}. But for some reason it didn't spot the beginning of that environment so there was no corresponding \begin{MATHMODE}. Putting the \label on the new line seems to be enough to make it recognise the \begin{equation} once again.

Whilst doing a pretty fair job, latexdiff doesn't interpret TeX documents in the same way that TeX does. In particular, since latexdiff is a perl program, I imagine it works on a line-by-line basis, so new-lines are more important to latexdiff than to TeX. So if there are other things that are causing it to complain, try adding more new-lines to separate things so that latexdiff recognises them as separate.

And, of course, if it gets stuck on something else, ask again!

share|improve this answer
    
Thanks! I'll make the changes and see how it goes. ( I think I'll be back here soon, because I already tried commenting out all the \label{} commands and it choked on something else...) –  James Borger Aug 5 '10 at 21:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.