I have run into a problem with the markup that latexdiff adds around \cite
commands. The MWE below, which is supposed to have been generated by latexdiff, doesn't compile because LaTeX doesn't recognise the closing brace for \DIFdel
:
ERROR: Extra }, or forgotten \endgroup.
The culprit is \hspace{0pt}
: commenting this out prevents this error.
I have solved my immediate problem by manually deleting the string \hspace{0pt}
from the difference file wherever it occurs, but obviously I'd rather not do this every time.
I have two questions: (1) why does LaTeX find a problem with the braces here in the first place, since they look matched to my human eyes (and to emacs!)? And (2) is there a way to prevent latexdiff from generating code that fails to compile in this way?
MWE for LaTeX (note that I've deleted most of the latexdiff preamble)
\documentclass{article}
\usepackage{hyperref}
% 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{\DIFdeltex}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF HYPERREF PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdel}[1]{\texorpdfstring{\DIFdeltex{#1}}{}} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF
\begin{document}
\DIFdelbegin \DIFdel{Some text\mbox{%DIFAUXCMD
\cite{reference}}\hspace{0pt}%DIFAUXCMD
, and some more text.}
\DIFdelend
\bibliography{my_bib}
\end{document}
MWE for latexdiff
old.tex
\documentclass{article}
\usepackage{hyperref}
\begin{document}
Some text \cite{reference}, and some more text.
\bibliography{my_bib}
\end{document}
new.tex
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\bibliography{my_bib}
\end{document}
latexdiff old.tex new.tex > diff.tex
Best Answer
This year (2020) LaTeX underwent some internal changes that introduce incompatibilities with some packages. It seems that
ulem.sty
is one of them, with the current versionulem 2019/11/18
pre-dating the changes in the LaTeX format.The differences file produced by
latexdiff
loadsulem.sty
and uses the command\sout
(strike out), which leads to the error.As a workaround, until the incomaptibility gets fixed, run
latexdiff
with the option-t CFONT
, which avoids the use of\sout
(proposed by @Ant in the comments).Alternatively, add
as the first line in the differences file. This will set back the LaTeX format to a state that is compatible.