I need more colours than the standard colours of the package xcolor. I have also tried the dvipsnames xcolor package but it didn't work. Every time when I tried to highlight a text with color from from the package, like ForestGreen, my text became black. I would like to have a color like in the image.
Can anyone please help me?
- 28,770
1 Answers
David Carlisle with his package color, which belongs to the graphics-bundle, is one of the forerunners when it comes to colour support in LaTeX. Many other packages build on it.
A starting point in learning about commands for typesetting text in colour might be section "3 Colour" of "Packages in the 'graphics' bundle" by David Carlisle and The LaTeX Project, often referenced as grfguide.pdf. Packages like xcolor, too, bring along the basic commands described there.
Probably the following example does help you?
\documentclass[a4paper]{article}
%\usepackage[dvipsnames,usenames]{color}
\usepackage[dvipsnames]{xcolor}
\newcommand\PassColors[2][black]{%
\fbox{%
\colorbox{#2}{\textcolor{#1}{%
\vbox to1cm{\vfill\hbox to 2.5cm{\hfill#2\hfill}\vfill}%
}}%
}\hskip.5em%
}%
\begin{document}
\enlargethispage{5mm}
\hrule height 0pt \vskip-4cm
{%
\large
\par\medskip\noindent
This is how you get colored text:
\fboxrule=3\fboxrule
\par\medskip\noindent
\verb|\fcolorbox{blue}{yellow}{\textcolor{red}{Test}}|: \fcolorbox{blue}{yellow}{\textcolor{red}{Test}}
\par\medskip\noindent
\verb|\colorbox{yellow}{\textcolor{red}{Test}}|: \colorbox{yellow}{\textcolor{red}{Test}}
\par\medskip\noindent
\verb|\textcolor{red}{Test}|: \textcolor{red}{Test}
\par\bigskip
}%
{%
\fboxsep=0ex
\fboxrule=2pt
\par\bigskip\noindent
{\large These are the colors provided by the option dvipsnames/according to dvips' color.pro:}
\par\medskip\noindent
\csname@for\endcsname\colors:=%
{{GreenYellow}},{{Yellow}},%
{{Goldenrod}},{{Dandelion}},{{Apricot}},{{Peach}},{{Melon}},{{YellowOrange}},{{Orange}},%
{{BurntOrange}},{{Bittersweet}},{{RedOrange}},{{Mahogany}},{{Maroon}},{{BrickRed}},%
{{Red}},{{OrangeRed}},{{RubineRed}},{{WildStrawberry}},{{Salmon}},{{CarnationPink}},%
{{Magenta}},{{VioletRed}},{{Rhodamine}},{{Mulberry}},{{RedViolet}},{{Fuchsia}},{{Lavender}},%
{{Thistle}},{{Orchid}},{{DarkOrchid}},{{Purple}},{{Plum}},{{Violet}},{{RoyalPurple}},%
{{BlueViolet}},{{Periwinkle}},{{CadetBlue}},{{CornflowerBlue}},{{MidnightBlue}},{{NavyBlue}},%
{{RoyalBlue}},{{Blue}},{{Cerulean}},{{Cyan}},{{ProcessBlue}},{{SkyBlue}},{{Turquoise}},%
{{TealBlue}},{{Aquamarine}},{{BlueGreen}},{{Emerald}},{{JungleGreen}},{{SeaGreen}},%
{{Green}},{{ForestGreen}},{{PineGreen}},{{LimeGreen}},{{YellowGreen}},{{SpringGreen}},%
{{OliveGreen}},{{RawSienna}},{{Sepia}},{{Brown}},{{Tan}},{{Gray}},{[White]{Black}},{{White}}%
\do{\expandafter\PassColors\colors}%
}%
\par\medskip\noindent
Note that when using the package \textbf{color} instead of the package \textbf{xcolor}, besides the option \textbf{dvipsnames}, after \textbf{dvipsnames} you also need to specify the option \textbf{usenames}.
\par\medskip\noindent
Note that document-classes like \textbf{beamer} and some packages internally load \textbf{xcolor} so that you need to specify options for \textbf{xcolor} already with the directives for loading these document-classes/packages.\
Otherwise you might get errors about option-clashes and the like where with online-platforms like overleaf you need to view the so-called "raw log" for taking notice. The "raw-log" is the .log-file provided by the LaTeX-compiler itself while the LaTeX-compiler is running and what people asking for .log-file wish to see.
\end{document}
- 28,770

xcolor-material,xcolor-solarized, andxkcdcolors? – Thérèse Nov 25 '21 at 17:07