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

Problem with alignat #251

Closed ahaselbacher closed 2 years ago

ahaselbacher commented 2 years ago

I've run into a problem running latexdiff on files containing alignat. With this file, called temp-old.tex

\documentclass{article}
\begin{document}
Hello this was a test.
\end{document} 

and temp.tex

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Hello this is a test.
\begin{alignat}{3}
  a& = b &\quad & \text{if} & \quad & x\ne y\\
  c& = d &      & \text{if} &       & x = y
\end{alignat}    
\end{document}

and running

latexdiff temp-old.tex temp.tex > diff.tex
pdflatex diff.tex

I get the error

! Missing number, treated as zero.
<to be read again> 
                   {
l.46 \DIFaddbegin \begin{alignat}{\DIFadd{3}}

This is not surprising because diff.tex contains

\DIFaddbegin \begin{alignat}{\DIFadd{3}}
  \DIFadd{a}& \DIFadd{= b }&\DIFadd{\quad }& \DIFadd{\text{if} }& \DIFadd{\quad }& \DIFadd{x\ne y}\\
  \DIFadd{c}& \DIFadd{= d }&      & \DIFadd{\text{if} }&       & \DIFadd{x = y
}\end{alignat}

When changed to

\DIFaddbegin \begin{alignat}{3}
  \DIFadd{a}& \DIFadd{= b }&\DIFadd{\quad }& \DIFadd{\text{if} }& \DIFadd{\quad }& \DIFadd{x\ne y}\\
  \DIFadd{c}& \DIFadd{= d }&      & \DIFadd{\text{if} }&       & \DIFadd{x = y
}\end{alignat}

everything works.

ahaselbacher commented 2 years ago

Btw, I'm running This is LATEXDIFF 1.3.1.1 (Algorithm::Diff 1.15 so, Perl v5.30.2) on Mac OS 11.6 with LaTeX2e <2021-06-01> patch level 1

ftilmann commented 2 years ago

Running this with --mathmode=FINE worked for me but might cause other problems. In any case it should be fixed properly with commit 5d7ebb4 . Thanks for reporting.