1

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. :-)

  • Can you post a complete code example (including \documentclass and \begin{document) and so on? – Dr. Manuel Kuehner Mar 11 '17 at 19:24
1

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.

  • Great!!! That fixed the problem. Thank you so much. :-) – Nakini Mar 11 '17 at 20:23

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.