8

I want to underline consecutive sentences each with a different color within an italic text. So far, I have tried the soul package and can change the underline properties. However, I am having difficulties changing the underline color in consecutive sentences within an italic text.

Consider the following: I want each of the \ul's have a different color.

    \documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage{color,soul}

    \begin{document}

    \setul{0.5ex}{0.3ex}
    \definecolor{Green}{rgb}{0,1,0}
    \setulcolor{Green}

    \setul{0.5ex}{0.3ex}
    \definecolor{Red}{rgb}{1,0.0,0.0}
    \setulcolor{Red}

    \setul{0.5ex}{0.3ex}
    \definecolor{Blue}{rgb}{0,0.0,1}
    \setulcolor{Blue}

    \Large
    \textit{
      Ham followed now ecstatic use speaking exercise may repeated.
      \ul{Himself he evident oh greatly my on inhabit general concern}. 
      \ul{It earnest amongst he showing females so improve in picture. 
      Mrs can hundred its greater account}. 
      \ul{Distrusts daughters certainly suspected convinced our 
      perpetual him yet.} Words did noise taken right state are since.
    }

    \end{document}

This is my desired output:

enter image description here

6

Similar to using \ul to set the underline, you can also change the colour using \setulcolor{<colour>} within \textit:

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{color,soul}

\setul{0.5ex}{0.3ex}
\setulcolor{blue}

\begin{document}

\Large
\textit{
Ham followed now ecstatic use speaking exercise may repeated.
\ul{Himself he evident oh greatly my on inhabit general concern}. 
\setulcolor{red} 
\ul{It earnest amongst he showing females so improve in picture. 
Mrs can hundred its greater account}. 
\setulcolor{green}
\ul{Distrusts daughters certainly suspected convinced our 
perpetual him yet.} Words did noise taken right state are since.
}

\end{document}
|improve this answer|||||
  • 1
    Nice answer thanks. Now setulcolor must be incompatible with some packages, as your template worked for me but not when inserted in a larger project. However, I didn't need the color, so I'm not going to investigate. Just mentioning it in passing. – PatrickT Oct 10 '17 at 21:12

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.