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
\hspace
command, but rather an incompatibility of the packages/code added bylatexdiff
with the current LaTeX version. LaTeX underwent some internal changes recently. If you add\RequirePackage[2015/01/01]{latexrelease}
as first line ofdiff.tex
, then the file works as it is.ulem
package. Removing\sout
makes the file compilable.amsmath
, but your discovery thatulem
is the thing to avoid means that I can just call latexdiff with-t CFONT
(to avoid styles usingulem
) and all is well.