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
518 stars 73 forks source link

Closing curly `}` and `\end{array}` are swapped inside (nested) `array` #287

Open shhyou opened 1 year ago

shhyou commented 1 year ago

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