[Tex/LaTex] Underline text, change underline colors in consecutive sentences

colorsoul

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

Best Answer

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}
Related Question