如何获得比标准 xcolor 颜色更多的颜色?

如何获得比标准 xcolor 颜色更多的颜色?

我需要的颜色比 xcolor 包的标准颜色还要多。我也尝试过 dvipsnames xcolor 包,但是没有用。每次我尝试用包中的颜色(如 ForestGreen)突出显示文本时,文本都会变黑。我想要一种像图片中的颜色。有人能帮帮我吗?在此处输入图片描述

答案1

大卫·卡莱尔和他的包裹颜色属于 graphics-bundle,是 LaTeX 色彩支持的先驱之一。许多其他软件包都以它为基础。

学习彩色文本排版命令的起点可能是David Carlisle 和 LaTeX 项目编写的“图形包中的软件包”中的“3 颜色”部分,通常引用为 grfguide.pdf。类似这样的软件包彩色,也带上那里描述的基本命令。

下面的例子可能对你有帮助吗?

在此处输入图片描述

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

相关内容