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
528 stars 74 forks source link

Removing gathered environment results in wrong nesting in latexdiff output #91

Open lucainnocenti opened 7 years ago

lucainnocenti commented 7 years ago

Consider the following two files:

old.tex:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\begin{gathered}
    a \\ b
\end{gathered}
\end{equation}

\end{document}

and new.tex:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\end{document}

Running latexdiff old.tex new.tex > diff.tex produces (with latexdiff 1.2.0, Windows 10):

diff.tex:

\documentclass{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL .\test_old.tex   Tue Mar 21 16:11:14 2017
%DIF ADD .\test_new.tex   Tue Mar 21 16:11:13 2017
\usepackage{amsmath}
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}                      %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}

 \DIFdelbegin \begin{displaymath}
\DIFdel{\begin{gathered}
    a }\\ \DIFdel{b
\end{gathered}
}\end{displaymath}
%DIFAUXCMD
%DIFDELCMD < 

%DIFDELCMD <  %%%
\DIFdelend\end{document}

Compiling diff.tex results in compilation errors, most likely due to way the gathered environment is split at the linebreak.

Is there a workaround for this?

alexpacini commented 7 years ago

+1. I have the same issue. A workaround is to surround manually with a blue color group (or a single \DIFdel / \DIFadd), but is quite annoying.