程序包 xcolor 错误:未定义颜色“金色”

程序包 xcolor 错误:未定义颜色“金色”

当我使用 编译此文档时pdflatex,我的章节(以及节和小节)的标题分别是蓝色(此处定义为“azzurro”)和金色。

我希望所有标题和副标题都是黑色的。

这是文档:

    \documentclass[envcountsame,envcountchap]{svmono}

    %\usepackage[latin1]{inputenc}
     \usepackage[utf8]{inputenc}
     \usepackage{eurosym}
    \usepackage{makeidx}                % allows index generation
    \usepackage{graphicx}               % standard LaTeX graphics tool
    \usepackage{xtab}                   % when including figure files
    \usepackage{multicol}
    \usepackage{qtree}
    \usepackage{booktabs}
    \usepackage{latexsym}
     \usepackage{psfig}                  % used for the two-column index
     \usepackage[bottom]{footmisc}       % places footnotes at page bottom
    \usepackage[italian]{babel}
    \usepackage{my_listings}
    \usepackage[hyphens]{url}
    \usepackage{algorithm}
    \usepackage{algorithmic}
    \usepackage{multirow}
    \usepackage{xcolor}
    \usepackage{float}
     \usepackage{titlesec}
      \usepackage{csquotes}
       \usepackage{python}
      \usepackage{verbatim}
      \usepackage{eurosym}
      \usepackage[figuresright]{rotating}
     \usepackage{pdflscape}
\usepackage{tcolorbox}
%\setcounter{secnumdepth}{3}
%\setcounter{tocdepth}{3}
\makeatletter
\titleformat{\section}[display]%
  {\Large\bfseries\boldmath}{\color{azzurro}{\thesection}}{-1.1em}{\hspace{2em}\color{azzurro}}[{\titlerule[0pt]}]
\makeatother

\makeatletter
\titleformat{\subsection}[display]%
  {\large\bfseries\boldmath}{\color{gold}{\thesubsection}}{-1em}{\hspace{3em}\color{gold}}[{\titlerule[0pt]}]
\makeatother

\makeatletter
\titleformat{\subsubsection}[display]%
  {\normalsize\bfseries\boldmath}{\color{gold}{\thesubsubsection}}{-1em}{\color{gold}}[{\titlerule[0pt]}]
\makeatother

\definecolor{gold}{rgb}{0.64,0.54,0.29}
\definecolor{azzurro}{rgb}{0,0.29,0.57}

\def\lstlistlistingname{\textbf{Elenco dei listati}}
\addto\captionsitalian{\renewcommand{\contentsname}{\textbf{Indice}}}
\addto\captionsitalian{\renewcommand{\listfigurename}{\textbf{Elenco delle figure}}}


\makeatletter
\let\old@rule\@rule
\def\@rule[#1]#2#3{\textcolor{gold}{\old@rule[#1]{#2}{#3}}}
\makeatother

\setlength{\textwidth}{12.7cm}
\setlength{\textheight}{20.0cm}
\setlength{\oddsidemargin}{3.50cm}
\setlength {\evensidemargin}{-0.3cm}
\setlength {\topmargin}{-1cm}


\makeindex

\author{}

\date{13 marzo 2018}

\begin{document}


\pagenumbering{{\color{azzurro}Roman}}
%\include{frontespizio/frontespizio}
%\newpage\null\thispagestyle{empty}\newpage
%\include{dedica/dedica}
%\tableofcontents \listoffigures
%\lstlistoflistings

\pagenumbering{arabic} \setcounter{page}{1}

%\include{Introduzione/introduzione}
\include{01-IlCrowdsourcing/capitolo-01}
%\include{02-LaSentimentAnalysis/capitolo-02}
%\include{03-ProgettazioneDeiTaskDiBase/capitolo-03}
%\include{04-ImplementazioneDeiTaskDiBaseERisultati/capitolo-04}
%\include{05-ProgettazioneDeiTaskAvanzati/capitolo-05}
%\include{06-ImplementazioneDeiTaskAvanzatiERisultati/capitolo-06}
%\include{07-ConfrontoConApprocciCorrelati/capitolo-07}
%\include{08-DiscussioneInMeritoAll'attivitàSvolta/capitolo-08}

\nocite{*}
%\bibliography{Bibliografia/biblio}
\bibliographystyle{plain}
%\include{Ringraziamenti/ringraziamenti}
\end{document}

这样,文件就被编译成了如附图一样。

在此处输入图片描述

当我用“黑色”替换颜色时

\definecolor{black}{rgb}{0,0,0}

它给了我这些错误:

程序包 xcolor 错误:未定义颜色金色

程序包 xcolor 错误:未定义颜色 azzurro

我可以做什么?

答案1

注意,\color{azzurro}在 的定义中,您使用了(两次:一次用于计数器,另一次用于标题)\subsection

\makeatletter
\titleformat{\section}[display]%
  {\Large\bfseries\boldmath}{\color{azzurro}{\thesection}}{-1.1em}{\hspace{2em}\color{azzurro}}[{\titlerule[0pt]}]
\makeatother

因此只需替换azurroblack甚至删除\color{azzurro},因为这black是默认颜色。

在 的定义中执行相同操作\subsection

A不好但更快解决方案是保留定义,只将 RGB 值更改为名为 的颜色azurro,即\definecolor{azzurro}{rgb}{0,0,0}。这样,您将获得黑色的azurro

最后,您收到的错误Package xcolor Error: Undefined color gold是因为你更改了定义的颜色的名称(goldby black),但您仍在gold上面的代码中使用该颜色。这就是为什么未定义颜色错误。

相关内容