Closing curly `}` and `\end{array}` are swapped inside (nested) `array`
Thanks for the great work on latexdiff! This is such an incredible project.
I've hit an issue when I use nested arrays with curly braces. Consider the file df.tex:
\documentclass{article}
\usepackage{amsmath,amsfonts,amssymb}
\begin{document}
\[\begin{array}{l}
{
\begin{array}{ll}
1 & 2 \\
3 & 4
\end{array}
}
\end{array}\]
\end{document}
When I run latexdiff df.tex df.tex, the output is:
% ... latexdiff preamble ...
\begin{document}
\[\begin{array}{l}
{
\begin{array}{ll}
1 & 2 \\
3 & 4
} % <- here
\end{array} % <- here
\end{array}\]
\end{document}
The closing curly brace } and the inner \end{array} are swapped. This example is extracted from a use case where I need to adjust arraystretch for the inner array. That is, I have the actual code like this:
\[\begin{array}{l}
{ \renewcommand{\arraystretch}{1.5}
\begin{array}{ll}
1 & 2 \\
3 & 4
\end{array}
}
\end{array}\]
I am not sure if this is related to #47 and #39. How do I work around the issue?
The version of latexdiff:
$ latexdiff --version
This is LATEXDIFF 1.3.2 (Algorithm::Diff 1.15 so, Perl v5.30.3)
(c) 2004-2021 F J Tilmann
I'm also facing this issue on 1.3.3. I've been working around it by replacing all occurrences of begin{array} in both versions of my files:
sed -i "" 's/\\begin{array}/\\array/g' paper.tex
sed -i "" 's/\\end{array}/\\endarray/g' paper.tex
and then some manual fixing because some of the \array commands end up in DIFadds and so don't match up.
The issue might also show up with gathered, but I haven't investigated it much more.
In case of changes the markup will possibly not be very fine-grained, but at least identical parts with nested arrays will no longer throw an error.