latexdiff icon indicating copy to clipboard operation
latexdiff copied to clipboard

Contents of \else is displayed as removed when an \iftrue block is deleted

Open MBradbury opened this issue 3 years ago • 1 comments

If there is text contained within an \iftrue block and the \iftrue logic is then removed in an edit, latexdiff will display the contents of the else block as deleted. However, the contents of the produced document never contained the text in the else block. Ideally, latexdiff should not report that the document's contents have changed.

a.tex:

\documentclass{article}
\begin{document}
\iftrue
hello
\else
hi
\fi
\end{document}

b.tex:

\documentclass{article}
\begin{document}
hello
\end{document}

c.tex:

\begin{document}
\DIFdelbegin %DIFDELCMD < \iftrue
%DIFDELCMD < %%%
\DIFdel{hello
 }%DIFDELCMD < \else
%DIFDELCMD < %%%
\DIFdel{hi
}%DIFDELCMD < \fi
%DIFDELCMD <  %%%
\DIFdelend \DIFaddbegin \DIFadd{hello
 }\DIFaddend\end{document}

Version information (I'm using 4f17f7b188fdbd8f6477aaea4118d0416babf370 off master):

$ latexdiff --version
This is LATEXDIFF 1.3.3a (Algorithm::Diff 1.1903, Perl v5.30.0)
  (c) 2004-2022 F J Tilmann

MBradbury avatar Mar 14 '22 09:03 MBradbury

I can see the problem but this would be very difficult to fix as latexdiff would have to follow the whole logic of the conditional expressions. The promise of latexdiff is that it works with standard latex and ignores TeX commands such as the \if statements. Sorry about that.

ftilmann avatar Feb 18 '24 11:02 ftilmann