# Problem using latexdiff and pdflatex with custom command

Using latexdiff I have the problem, that by adding new `\section`, I get the following error by trying to run pdflatex.

``````! Argument of \UL@word has an extra }.
<inserted text>
\par
``````

Here you can see the redefined `\section` command...

``````\renewcommand{\section}{%
\@startsection{section}%
{1}     % Structure level
{0mm}   % Indention
{2ex plus 1ex minus 1ex}            % Pre-Margin
{0.5ex plus 0.5ex minus 0.5ex}      % Post-Margin
}
\renewcommand{\subsection}{%
\@startsection{subsection}%
{2}     % Structure level
{0mm}   % Indention
{1.5ex plus 1ex minus 0.5ex}        % Pre-Margin
{0.3ex plus 0.3ex minus 0.3ex}      % Post-Margin
}
``````

How can I fix the problem? It would work for me also to ignore the changed section names.

-

(OPs answer, moved from the question.)

I thought it would be complexer, but I found a solution. Using `--exclude-textcmd` allows the ignoring of tags. It works now.

``````--exclude-textcmd="section,subsection"
``````
-

It's difficult without an MWE, but I would assume that the difficulty is with `hyperref`, which tries to include underlined/crossed out text as hyperlink given that it is part of a chapter.

The solution is to use `texorpdfstring`, which tells hyperref to use plain text for the hyperlinks. I can't remember the exact commands that `latexdiff` definds, but try something like that:

``````% Redefine these commands for chapter/sections and change below
\DeclareRobustCommand{\hsout}[1]{\texorpdfstring{\sout{#1}}{#1}}
\DeclareRobustCommand{\hwave}[1]{\texorpdfstring{\uwave{#1}}{#1}}

%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