7

I am using the following packages in my files Latex sources:

\usepackage{color}
\usepackage[table,xcdraw]{xcolor}
\usepackage[usenames, dvipsnames]{color}

\newcommand{\ricardo}[1]{\colorbox{ForestGreen}{\color{white}\textsf{\textbf{Ricardo}}} \textcolor{ForestGreen}{#1}}

And to mark my notes in the text, I use the command:

\ricardo{text....}

How should I do to make Latex display my notes correctly?

7

The xcolor package is an extension of the color package, so I don't understand why you loaded the color package twice along with the xcolor package. Moreover, according to page 7 of the xcolor documentation usenames is obsolete. I cleaned up the code to this:

\documentclass[11pt]{article}
\usepackage[dvipsnames,table,xcdraw]{xcolor}
\newcommand{\ricardo}[1]{\colorbox{ForestGreen}{\color{white}   \textsf{\textbf{Ricardo}}} \textcolor{ForestGreen}{#1}}
\begin{document}
\ricardo{This should work.}
\end{document}

and the resulting output compiles without a problem:

enter image description here

3
  • Thank​ you so much for your help @DJP, now it's all working! – ricardoramos Jan 22 '16 at 15:02
  • Given that `usenames' is obsolete, maybe this (\documentclass[usenames,dvipsnames]{beamer} ) should be changed at en.wikibooks.org/wiki/LaTeX/… ? – MycrofD Jun 5 '19 at 9:59
  • Indeed, in the documentation, mirror.utexas.edu/ctan/macros/latex/contrib/xcolor/xcolor.pdf, to use additional color like the one you wanna use, you have to add this option when you load the xcolor package. Check out the section 2.4.2 Additional sets of colors in the document. Simply put, to use it properly, you just need this line when load xcolor package: \usepackage[usenames, dvipsnames]{xcolor} – Jason Dec 10 '19 at 7:33
8

sorry I can't comment as I'm just a noob and I need reputation. I tried out the command in my document and it works perfect. Check the image below.

enter image description here

In my beamer, I had declared something like \documentclass[xcolor=dvipsnames]{beamer} while the document that I use based on tufte declares \usepackage{xcolor} in the .sty file.

Could you try renaming the third line of the code into \usepackage[usenames, dvipsnames]{xcolor} ?

3
  • Hello @crypto, I am using \documentclass[conference]{IEEEtran} I modified the third from \usepackage[usenames, dvipsnames]{color} to \usepackage{xcolor}, as your suggestion, but I keep getting the same error: Package xcolor Error: Undefined color ForestGreen. – ricardoramos Jan 22 '16 at 14:53
  • Just a small question. Could you try \usepackage[usenames, dvipsnames]{xcolor}? I don't happen to have an IEEEtran tex file to try it out. Have you installed the package xcolor? – crypto Jan 22 '16 at 14:56
  • You're welcome. Thank​ you so much for your help @crypto! – ricardoramos Jan 22 '16 at 15:03
2

A more general solution may simply be to define the color explicitly.

\definecolor{ForestGreen}{RGB}{34,139,34}

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.