[Tex/LaTex] Latexdiff error on changing chapter title

latexdiff

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.
<to be read again> 
\protect 
l.1 ...DIFadd{S}\DIFaddend }

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}

\usepackage[unicode,colorlinks,ocgcolorlinks,breaklinks]{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{\DIFaddtex}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdeltex}[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 HYPERREF PREAMBLE %DIF PREAMBLE
\providecommand{\DIFadd}[1]{\texorpdfstring{\DIFaddtex{#1}}{#1}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{\texorpdfstring{\DIFdeltex{#1}}{}} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}

\pagenumbering{alpha}

\chapter{\DIFdelbegin \DIFdel{P}\DIFdelend \DIFaddbegin \DIFadd{S}\DIFaddend }

\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?

Best Answer

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).

Related Question