# Color typo in underline text

Using soul package, I try to underline in black a text containing some words. One of the words is colored in grey.

\documentclass{article}
\usepackage{color}
\usepackage{soul}
\definecolor{Gray}{gray}{.5}
\begin{document}
\ul{Hello \textcolor{Gray}{this} is an example}
\end{document}


Produces the error: "Package soul Error: Reconstruction failed."
I tried a dirty solution:

\ul{Hello }\textcolor{Gray}{\ul{this}}\ul{ is an example}


which doesn't produce error, but underlines my text with a Gray line. I'd like to underline in black.

• Sorry, as there is no special environnement (except soul package in tags) I thought it was clear enought withou MWE. I edited to make it better for future use. thanks Aug 19, 2017 at 8:46

Package soul can support commands without and with one argument. \textcolor uses two arguments, therefore a new command is defined in the following example for \soulregister.

The different line color can be fixed by setting the color for the line explicitly using \setulcolor.

\documentclass{article}
\usepackage{color}
\usepackage{soul}

\definecolor{Gray}{gray}{.5}
\newcommand*{\ColorGray}{\textcolor{Gray}}
\soulregister{\ColorGray}{1}

\setulcolor{black}

\begin{document}
\ul{Hello \ColorGray{this} is an example}
\end{document}