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

Changing content of \multicolumn causes a LaTeX error #289

Closed jtappin closed 4 months ago

jtappin commented 9 months ago

In a table containing a number of \multicolumn items in the header, completely changing the content of one results in an output file that reports a LaTeX error.

Original file:

  \begin{tabular}{lrrrrrrrr}
    \hline
    Instrument & $\lambda$ (nm) & $\log_2 N_{\mathrm{G}}$ &
    \multicolumn{2}{c}{Width (mm)}& \multicolumn{2}{c}{Pitch (\micron)}
    & \multicolumn{2}{c}{Ratio to Disk}\\
               & & & Min & Max & Min & Max & Min & Max\\
    \hline

Updated file:

  \begin{tabular}{lrrrrrrrr}
    \hline
    Instrument & $\lambda$ (nm) & $\log_2 N_{\mathrm{G}}$ &
    \multicolumn{2}{c}{Width (mm)}& \multicolumn{2}{c}{Pitch (\micron)}
    & \multicolumn{2}{c}{Grid margin}\\
               & & & Min & Max & Min & Max & Min & Max\\
    \hline

latexdiff output:

  \begin{tabular}{lrrrrrrrr}
    \hline
    Instrument & $\lambda$ (nm) & $\log_2 N_{\mathrm{G}}$ &
    \multicolumn{2}{c}{Width (mm)}& \multicolumn{2}{c}{Pitch (\micron)}
    & \DIFdelbeginFL %DIFDELCMD < \multicolumn{2}{c}{Ratio to Disk}%%%
\DIFdelendFL \DIFaddbeginFL \multicolumn{2}{c}{Grid margin}\DIFaddendFL \\
               & & & Min & Max & Min & Max & Min & Max\\
    \hline

pdflatex error:

! Misplaced \omit.
\multispan ->\omit 
                   \@multispan 
l.714 ...ddbeginFL \multicolumn{2}{c}{Grid margin}
                                                  \DIFaddendFL \\
? 

If I press return at the prompt, the resultant PDF file shows the new version only with no highlighting.

Running on Manjaro Linux with:

$ latexdiff --version
This is LATEXDIFF 1.3.3 (Algorithm::Diff 1.15 so, Perl v5.38.0)
  (c) 2004-2022 F J Tilmann
norbertroamsys commented 7 months ago

We have encountered this issue/bug too. Are there any plans to fix it in the future?

ftilmann commented 6 months ago

I just tested the example above. I cannot fully reproduce this, as for me it just compiles without an error but also the change is invisible. You (@jtappin) did not post a full MWE but just a snippet, and the context might have made the difference (e.g. \micron did not work for me and I had to replace with $\mu$. The problem with visibility is easy to fix. I just tried with latexdiff --append-textcmd=multicolumn and at least for the example it works. Most likely, this will be default from (future) 1.3.4 onwards but I need to do some testing first.

ftilmann commented 4 months ago

As show, this is now implemented. Hopefully it also fixes your problems although I never managed to reproduce them.