ftilmann / latexdiff

Compares two latex files and marks up significant differences between them. Releases on www.ctan.org and mirrors
GNU General Public License v3.0
514 stars 72 forks source link

CTRADITIONAL fails with changes in formulas (without --math-markup=off) #183

Open jbrea opened 4 years ago

jbrea commented 4 years ago

I really like CTRADITIONAL, and I know I can use it with --math-markup=off. But it would be awesome, if I could use it also for all formulas. Here is a minimal example:

% tmp1.tex
\documentclass{article}
\begin{document}
\[ x = a_1 \]
\end{document}
% tmp2.tex
\documentclass{article}
\begin{document}
\[ x = b_2 \]
\end{document}

When I run pdflatex on the diff I get

! Missing $ inserted.
<inserted text> 
                $
l.46 \[ x = \DIFdelbegin \DIFdel{b_3 }
                                      \DIFdelend \DIFaddbegin \DIFadd{a_1 }\...
ftilmann commented 4 years ago

Unfortunately, I believe footnotes in display equations simply don't work, so this cannot easily be achieved. So I don't really see a way to address this, sorry

jbrea commented 4 years ago

What about using \footnotemark and \footnotetext? Or would this require too many changes (I have no clue about the internals of latexdiff)?

ftilmann commented 4 years ago

Yes, this would probably be possible, but not easy to implement - one would have to keep a running tally of deleted parts in maths environments, and then add the \footnotetext later, and also keep track of the correct numbering. Timewise, I probably won't be able to tackle this. Always happy to accept appropriate pull requests, though

adinriv commented 4 years ago

I ran into this problem now. The solution is to protect the text within the \DIFdel when inside a math environment. So, in the previous example you should do a \DIFdel{$b_3 $} instead of simply passing the parameter. However, I'm not sure if you know when you are inside of a math environment to do something like this.