TransWikia.com

Package xcolor Error: Undefined color `ForestGreen'

TeX - LaTeX Asked on October 5, 2021

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?

3 Answers

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

Correct answer by DJP on October 5, 2021

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} ?

Answered by crypto on October 5, 2021

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

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

Answered by Bradley Evans on October 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP