Here is a minimal example showing the problem.
\documentclass[10pt]{article}
\usepackage[usenames,dvipsnames]{color}
\usepackage{soul}
%\soulregister{\ref}{1}
\begin{document}
\section*{x}\label{x}
\section*{y}
\hl{ Some text.
Section~\ref{x}.
}
\end{document}
I'm getting the error
LaTeX Warning: Reference `{x}' on page 0 undefined on input line 12.
! Argument of \ref has an extra }.
The problem is with \ref
. Commenting out the line beginning with "Subsection" makes the error disappear. \soulregister
is intended for font commands. I don't know if \ref
is a font command, but I could not get \soulregister
to fix the problem (see the commented line above).