Consider the following two simple .tex files:
test_old.tex:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$a \begin{pmatrix}a & b\end{pmatrix}$
\end{document}
and test_new.tex:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$a_2 \begin{pmatrix}a & b\end{pmatrix}$
\end{document}
Using latexdiff to highlight the differences between these two documents (using latexdiff 1.2.0 on windows 10) generates the following diff.tex file:
\documentclass{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL .\test_old.tex Tue Mar 21 15:42:30 2017
%DIF ADD .\test_new.tex Tue Mar 21 15:42:31 2017
\usepackage{amsmath}
%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}
%DIF < $\mathcal C\begin{pmatrix}a & b\end{pmatrix}$
\DIFdelbegin \DIFdel{$a \begin{pmatrix}a & b\end{pmatrix}$
}\DIFdelend %DIF > $\mathcal C_2 \begin{pmatrix}a & b\end{pmatrix}$
\DIFaddbegin \DIFadd{$a_2 \begin{pmatrix}a & b\end{pmatrix}$
}\DIFaddend
\end{document}
Compiling this file results in the following errors:
...\diff.tex:30: Forbidden control sequence found while scanning use of \UL@word. [}]
...\diff.tex:30: Paragraph ended before \UL@word was complete. [}]
...\diff.tex:34: Missing } inserted. [\end{document}]
What causes this? And how can I prevent it?
hyperref. Thanks for pointing out, I'll edithyperrefseems to only remove the very first error. I also tried to remove some parts of the code that seemed more unlikely to be causing issues. Most of the code is from the preamble added bylatexdiffnow, and I'm not sure what can I remove of that\stin math mode; then\DIFdelis used wrongly e.g. in the last equation, where it encloses\begin{gathered}; and at some pointulemfails too, though I haven't found out yet exactly where. As for not being sure about what can be removed: if the error still shows up, then the removed line wasn't responsible:-)latexdiffusually works decently enough (in my experience at least), so I'm wondering why all these errors now. In the case of thegatheredI guess the nesting error is not fixable simply redefining the macro is it? That would require fixing thelatexdiffscript itself.