9

This example fails to generate a valid .tex:

test.tex

\documentclass[a4paper]{report}
\begin{document}
\begin{description}
    \item[thing] explanation of thing
\end{description}
\end{document}

test_modified.tex

\documentclass[a4paper]{report}
\begin{document}
\begin{description}
    \item[A first thing] an explanation of first thing
\end{description}
\end{document}

Executing

latexdiff test.tex test_modified.tex > test_diff.tex  
pdflatex test_diff.tex

yields

! LaTeX Error: Something's wrong--perhaps a missing \item.                                            
l.25 ...

Here is the block of interest in the generated .tex:

\begin{document}
\begin{description}
    \DIFdelbegin %DIFDELCMD < \item[thing] %%%
\DIFdel{explanation of }\DIFdelend \DIFaddbegin \item[A first thing] \DIFadd{an explanation of first }\DIFaddend thing
\end{description}
\end{document}

So latexdiff has inserted code before the \item, and the compiler does not like it.

Now the manpage says latexdiff has options to exclude commands. I tried to add

--exclude-safecmd="\\\item"

in the command line invoking latexdiff, with no success.

Has anyone ever tweaked the options of latexdiff and could say how to circumvent the bug (e.g. tell latexdiff to skip this kind of environment)?

1 Answer 1

10

Ok, I spent some more time looking for a way to solve this, and the solution is to define a dummy command that does nothing:

\newcommand{\diffblock}[1]{#1}

Just put the whole description in this block:

\diffblock{
\begin{description}
    \item[A first thing] an explanation of first thing
\end{description}
}

And add --append-safecmd="diffblock" in the latexdiff options.

It understands it should treat it as a whole block and does not attempt to insert its own code inside the block.

2
  • I had to use --exclude-safecmd="diffblock" to get this working with an earlier version that did not have a \diffblock{} yet. Sep 7, 2016 at 15:04
  • 1
    However the same might also be achieved without defining a \diffblock command but adding description to the PICTUREENV via --config="PICTUREENV=(?:picture|figure|DIFnomarkup|descripti‌​on)[\w\d*@]*". See here. Moreover the problem seems to be gone in version 1.0.4. Sep 7, 2016 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .