Package xcolor Error: Undefined color `ForestGreen'
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.
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}
?
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:
A more general solution may simply be to define the color explicitly.
\definecolor{ForestGreen}{RGB}{34,139,34}