1

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?

1

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
-1

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

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.