[Tex/LaTex] Highlight and Textcolor

colorhighlighting

I was following this question to highlight and color the text. It worked fine except for a few exceptions.

First, I checked SDrolet's suggestion in which the \color option didn't work for me. It colors the text until the end of the document instead of just coloring the words inside the enclosing braces. Then, I tried user11232's suggestion too. In this case, I am able to color the words inside the braces, but couldn't change the color of the text-box while using \hl.

Am I missing some packages or any options in packages?

Here is an example code using "xcolor" package

\documentclass{article}
\usepackage{hyperref}
\usepackage{xcolor}
%\usepackage{color,soul}
\begin{document}
\section{Random Text}
\begin{enumerate}
  \item Integer nibh magna, scelerisque sit amet gravida non. Suspendisse quis felis sed augue laoreet ultricies. \color{green}{Aliquam erat volutpat}. Aliquam a orci sit amet mauris rutrum volutpat id et turpis. Fusce tellus risus, sodales vitae augue sed, ullamcorper elementum nibh. Suspendisse sit amet ultricies leo. 
\end{enumerate}
\section{Random Text - 2}
\end{document}

and it's output.

Using "xcolor" package

Thank you in advance. Any help is much appreciated. 🙂

Best Answer

Making a parallel with, for example, how \bfseries and \textbf{} work, you should use

{\color{green} text to be colored, works until the group ends}. This 
is not colored anymore 

or

text text \textcolor{green}{green text} default color text. 

The first form will allow the color to extend between paragraphs, while the second one will throw an error.