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
513 stars 72 forks source link

\newcommand is mixed #237

Open impact27 opened 3 years ago

impact27 commented 3 years ago

1- Create a file (test.tex) with:

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}

\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}

\end{document}

2- latexdiff test.tex test.tex > diff.tex

I get:

\documentclass{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL old.tex   Tue Jul 20 08:47:56 2021
%DIF ADD old.tex   Tue Jul 20 08:47:56 2021
\usepackage[utf8]{inputenc}
%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}

\newcommand{\be}{\begin{equation}\end{equation}
\newcommand{\ee}{}}

\end{document}

Notice the \newcommand lines are mixed together.

This is LATEXDIFF 1.2.1  (Algorithm::Diff 1.15 so, Perl v5.30.0)
  (c) 2004-2017 F J Tilmann
ftilmann commented 2 years ago

You have discovered a way to fool latexdiff. In the current framework it's not that easy to fix. Can you move these definitions into the preamble? Alternatively, with --math-markup=3 it works. Thank you for your report, but the amount of effort to address this combined with it being quite an unusual setup, mean I will not address this in foreseeable future. As it's a bug I will leave the issue open, though (in case you are suprised to get a reaction so late. I was unable to allot much time to latexdiff in the last few months; I now try try to got through the backlog of issues and prioritise them)