9

I ran across an error using latexdiff that I have reduced to the following MWE. Given before and after files...

\documentclass{article}
\begin{document}
\thispagestyle{empty}
\begin{tabular}{ll}
A & B \\
C & D \\
E & F \\
\hline
\end{tabular}
\end{document}

and

\documentclass{article}
\begin{document}
\thispagestyle{empty}
\begin{tabular}{ll}
A & B \\
C & D \\
\hline
\end{tabular}
\end{document}

The resulting diff.tex file is shown below.

%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL revA.tex   Wed May 11 15:13:29 2016
%DIF ADD revB.tex   Wed May 11 15:13:32 2016
\documentclass{article}
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}                      %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}
\thispagestyle{empty}
\begin{tabular}{ll}
A & B \\
C & D \\
\DIFdelbegin \DIFdel{E }%DIFDELCMD < & %%%
\DIFdel{F }%DIFDELCMD < \\
%DIFDELCMD < %%%
\DIFdelend \hline
\end{tabular}
\end{document}

The diff.tex file won't compile. The console output is as follows...

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (MiKTeX 2.9 64-bit)
entering extended mode
(diff.tex
LaTeX2e <2015/01/01> patch level 2
Babel <3.9m> and hyphenation patterns for 69 languages loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"))
(C:\Users\jj79207\AppData\Roaming\MiKTeX\2.9\tex\latex\ulem\ulem.sty)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\color.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\00miktex\color.cfg")
("C:\Program Files\MiKTeX 2.9\tex\latex\pdftex-def\pdftex.def"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"))) (diff.aux)
(C:\Users\jj79207\AppData\Roaming\MiKTeX\2.9\tex\context\base\supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
! Misplaced \noalign.
\hline ->\noalign 
                  {\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet...
l.34 \DIFdelend \hline

? 

I don't have enough experience to understand the error message, but I do know that if I remove the \hline from each of the two input files then the diff compiles fine to produce the following output.

enter image description here

Are my input files somehow invalid? Is this a known bug? Are there any easy workarounds to keep the \hline without getting an error?

5
  • 4
    The problem is that the changes occur on the last line of the tabular environment. As a result, latexdiff inserts its' markup commands between the last \\ and the \hline, which leads to an error because \hline is supposed to occur directly after \\ which is no longer true because of the commands inserted by latexdiff. I don't see an easy way to fix this. When I use latexdiff I just let it compile with whatever errors are present (press r at the first error or use pdflatex -interaction=nonstopmode) and then use the output as a guide for what has changed.
    – user30471
    May 12, 2016 at 8:48
  • 1
    @Andrew: Thank you for your tip on forcing pdflatex to continue compilation. Up to now, I had only used latexdiff on simpler documents and found it invaluable in communicating changes. I'm sad to see that it is not as robust as I had hoped.
    – James
    May 12, 2016 at 11:03
  • 1
    Latexdiff is still pretty good. The problem is that TeX documents can be very complex and latexdiff is just doing some fancy pattern matching so it will fail occasionally. To catch issues like yours it would to need to parse the TeX code to some extent, which becomes an impossible task given the number of packages etc that are available. Another place where latexdiff sometimes struggles is with mathematics. I find that using --math-markup=whole or --math-markup=off sometimes helps.
    – user30471
    May 12, 2016 at 11:18
  • 2
    To my impression you are running into bug 5 of latexdiff. You are welcome to express your interest for getting this fixed in the bug report. Sep 13, 2016 at 9:48
  • 5
    I'm voting to close this question as off-topic because it's a reported bug of the software as detailed in comments
    – Moriambar
    Jun 8, 2017 at 22:04

0

Browse other questions tagged .