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)



\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
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{\texorpdfstring{\DIFdeltex{#1}}{}} %DIF PREAMBLE

\DIFdelbegin \DIFdel{Some text\mbox{%DIFAUXCMD
, and some more text.}


MWE for latexdiff




Some text \cite{reference}, and some more text.






latexdiff old.tex new.tex > diff.tex

  • 2
    I think the problem is not really the \hspace command, but rather an incompatibility of the packages/code added by latexdiff with the current LaTeX version. LaTeX underwent some internal changes recently. If you add \RequirePackage[2015/01/01]{latexrelease} as first line of diff.tex, then the file works as it is.
    – gernot
    Dec 9, 2020 at 14:48
  • 1
    It seems to be the ulem package. Removing \sout makes the file compilable.
    – gernot
    Dec 9, 2020 at 14:54
  • 1
    Many thanks @gernot; if you add that as an answer I'll happily accept it! In the actual document, I couldn't roll back because I need more recent features in amsmath, but your discovery that ulem is the thing to avoid means that I can just call latexdiff with -t CFONT (to avoid styles using ulem) and all is well.
    – Ant
    Dec 9, 2020 at 16:34
  • 1
    Done. Keep me updated (e.g. in the comment section here or below the answer) about your experience with the workaround. Maybe we are on the wrong track and the error is caused by something else.
    – gernot
    Dec 9, 2020 at 17:06
  • 2
    The corresponding bug report of latexdiff is github.com/ftilmann/latexdiff/issues/218 (it seems that this is fixed but might not have found its way to all distributions yet)
    – phispi
    Apr 29, 2022 at 8:49

2 Answers 2


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 version ulem 2019/11/18 pre-dating the changes in the LaTeX format.

The differences file produced by latexdiff loads ulem.sty and uses the command \sout (strike out), which leads to the error.

\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\providecommand{\DIFdeltex}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE

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.

  • 2
    Somehow removing "\hspace{0pt}" generated by latexdiff fixed this issue for me, before I found this great answer.
    – Parham
    Jan 10, 2021 at 10:34
  • I will hang this answer over my desk....many thanks!
    – Kassem
    Feb 4, 2021 at 4:30
  • 1
    In my document \RequirePackage[2019/11/18]{latexrelease} caused LaTeX to hang. Feb 22, 2021 at 3:16
  • @AnonymousPhysicist Well, this is a non-normal behavior of latexrelease. If you care, post a question or file a bug report at https://github.com/latex3/latex2e/issues
    – gernot
    Feb 22, 2021 at 11:49

Germot already provided a good answer. However, it was not entirely satisfactory. The -t CFONT option changes the formatting (it only uses colour, removing strike-out and underlining). And while setting the latexrelease version to 2019/11/18 worked fine with OP's MWE, it failed in a more complex document.

So I sought to get rid of the real culprit, the \hspace{0pt}.

Since v1.0.1, latexdiff encloses citation (and a few other things such as siunitx commands) in \mbox commands in order to circumvent incompatibilities with ulem styling (the \sout and \uwave used by default). However, this implies that line breaks no longer work within citations. This was fixed in v1.2.1 by adding the \hspace{0pt} after the \mbox. The changelog states that “change should not cause adverse behaviour otherwise”. Well, now it does!

My temporary fix was to edit the latexdiff source (texmf-dist/scripts/latexdiff/latexdiff.pl), and replace the \hspace{0pt} with a \hskip0pt. The resulting PDF is identical to the one obtained with older versions.

tl; dr:

Find script latexdiff.pl in your texlive installation directory¹, or executable latexdiff in your binaries directory and replace line 2734²:

push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hspace{0pt}$AUXCMD\n" );


push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hskip0pt$AUXCMD\n" );

¹ E.g. /usr/share/texmf-dist/scripts/latexdiff/latexdiff.pl.
² Assuming you have latexdiff v1.3.1.1.

  • 2
    Great answer, fixed /usr/bin/latexdiff (line 2680 in my version) with this and it now works again. Sep 2, 2021 at 11:05
  • Fantastic! Didn't know I could just hack it - Line 2836 in my case
    – Colin
    Dec 15, 2021 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.