# Latexdiff error on changing chapter title

When I try to compile latexdiff output on two documents where the title of a chapter was changed, I get the following error:

! Missing number, treated as zero.
\protect


I tried to produce a minimal example, but this time the error is in a different place, so I might have deleted something important:

%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL kniha.tex      Mon Dec 26 22:18:16 2016
%DIF ADD ../kniha.tex   Mon Dec 26 20:26:53 2016
\documentclass[12pt,a4paper,oneside,openany]{book}

%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 FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF HYPERREF PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdel}[1]{\texorpdfstring{\DIFdeltex{#1}}{}} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}

\pagenumbering{alpha}

\end{document}


When I delete the pagenumbering line, the error disappears. What's happening here?

What should I do to have latexdiff produce a correct document?

I still don't know what's going on in the example above, but in my original problem, the solution was to change

\titleformat{\chapter}[hang]
%{\normalfont\huge\bfseries\raggedright}{}{0pt}{\thechapter/ }
{\huge\bfseries\raggedright}{\thechapter/ }{0pt}{}


to

\titleformat{\chapter}[hang]{\huge\bfseries\raggedright}{\thechapter/ }{0pt}{}


What I still don't understand is why the former didn't work with --allow-spaces. And why did the former version work for diffs that didn't change the chapter title (although there were other changes as well, I might have overlooked something important).

• --allow-spaces only works for spaces not embedded comments. Maybe you can pre-process and simply remove all comments from the text. – frederik Dec 27 '16 at 23:10
• For the second question: if there is no change latexdiff will preserve what's there. It will only get confused if curly braces are not matched. – frederik Dec 27 '16 at 23:11
• But latexdiff gets confused about a lot of stuff. It's useless on all but the most basic of documents. – JPi Jan 26 '17 at 13:53

I have something like this: \subsection{\DIFadd{Experimental results added}}, then it got error with MiKTeX.

I change it to this: \section*{\DIFadd{Experimental results added}} or \subsection*{\DIFadd{Experimental results added}}, then it's ok but no section numbers.

So I change it again: \section[]{\DIFadd{Experimental results added}} or \subsection[]{\DIFadd{Experimental results added}}.