latexdiff
latexdiff copied to clipboard
Removing a line from tabular results in compile error
old.tex
\documentclass{book}
\usepackage{supertabular}
\usepackage{booktabs}
\begin{document}
\chapter{chapter1}
\begin{tabular}{lp{3em}p{3em}p{3em}}
\toprule
A & B & C \\
\midrule
1 & 2 & 3 \\
4 & 5 & 6 \\
\bottomrule
\end{tabular}
\end{document}
new.tex
\documentclass{book}
\usepackage{supertabular}
\usepackage{booktabs}
\begin{document}
\chapter{chapter1}
\begin{tabular}{lp{3em}p{3em}p{3em}}
\toprule
A & B & C \\
\midrule
1 & 2 & 3 \\
\bottomrule
\end{tabular}
\end{document}
latexdiff old.tex new.tex > diff-del.tex Results in:
\DIFdelbegin \DIFdel{4 }%DIFDELCMD < & %%%
\DIFdel{5 }%DIFDELCMD < & %%%
\DIFdel{6 }%DIFDELCMD < \\
%DIFDELCMD < %%%
\DIFdelend \bottomrule
While removing a line from the tabular breaks the layout for a normal table (without the bottomrule from booktabs), this breaks compilation because bottomrule needs the linebreak after the last line. So, my suggestion would be to keep the ampersands and newlines in place for the deleted area.
On the other hand this might create problems, if a whole column was deleted from one version to the other.
Also the basic tabular has this issue when using hline:
old.tex
\documentclass{book}
\begin{document}
\chapter{chapter1}
\begin{tabular}{l c r}
1 & 2 & 3 \\
\hline
\end{tabular}
\end{document}
new.tex
\documentclass{book}
\begin{document}
\chapter{chapter1}
\begin{tabular}{l c r}
1 & 2 & 3 \\
4 & 5 & 6 \\
\hline
\end{tabular}
\end{document}
Yes, tabular is a weakness - other have pointed out similar issues. I need to think of a way to deal with all the possibilities in a robust way.