1

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.

underlineInGray

  • 2
    Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. – Bobyandbob Aug 18 '17 at 17:42
  • 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 – mquantin Aug 19 '17 at 8:46
5

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}

Result

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.