latexdiff icon indicating copy to clipboard operation
latexdiff copied to clipboard

A problem with \newcommand

Open rsato64 opened this issue 7 years ago • 1 comments

I found a problem with \newcommand.

a.tex :

\begin{document}
\newcommand{\beq}{\begin{eqnarray}}
\newcommand{\eeq}{\end{eqnarray}}
\beq
e^{i\pi} + 1 = 0.
\eeq
\end{document}

latexdiff a.tex a.tex > diff.tex gives the following diff.tex :

\begin{document}
\newcommand{\beq}{\begin{eqnarray}\end{eqnarray}
\newcommand{\eeq}{}}
\beq
e^{i\pi} + 1 = 0.
\eeq
\end{document}

rsato64 avatar May 26 '18 20:05 rsato64

This is a a somewhat pathological case. You can fix this by moving the definitions into the preamble I think. Even if this wrong processing was fixed, latexdiff would still not understand \beq and \eeq as math delimiters, likely leading to problems if equations get more complex. To fix this somehow the content of \newcommand's needs to be protected against pre-processing - not really difficult to do but still taking some time. Because of the above mentioned workaround and remaining issues even after a fix for this construction I am currently not planning to implement this but will leave the issue open.

ftilmann avatar Jul 22 '18 11:07 ftilmann