无法更改爱思唯尔风格的引文颜色

无法更改爱思唯尔风格的引文颜色

我希望默认更改 Elsevier 模板中引文的颜色,而无需修改样式表。这可能吗?以下是 MWE:

     \documentclass[authoryear,review,12pt,pdf]{elsarticle}
    \usepackage{color}
    \definecolor{DarkGreen}{rgb}{0.2,0.5,0.2} % to color links in references
   \usepackage[%
        pdftex,%
        colorlinks=true,%
        %citecolor=green, % =DarkGreen color of references
        citecolor=DarkGreen,
        hyperindex,%
        plainpages=false,%
        pagebackref=true,%
        bookmarksopen,%
        bookmarksnumbered %
          ]{hyperref}
   \hypersetup{citecolor=DarkGreen}
 \begin{document}
    A document with a citation \cite{abr1}. Some text written in   \textcolor{DarkGreen}{Dark green}.
 \bibliographystyle{elsarticle-harv}
\begin{thebibliography}{1}
\expandafter\ifx\csname natexlab\endcsname\relax\def\natexlab#1{#1}\fi
 \expandafter\ifx\csname url\endcsname\relax
  \def\url#1{\texttt{#1}}\fi
\expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi
 \bibitem[{Abramovitz and Stegun(1964)}]{abr1}
   Abramovitz, M., Stegun, I., 1964. Handbook of mathematical functions with
  formulas, graphs and mathematical tables. 55. {U}.{S}. {G}overnment
  {P}rinting {O}ffice, Washington, DC, {P}aperback edition published by
  {D}over, {N}ew {Y}ork.

\end{thebibliography}
\end{document}

可以看出,尽管 hyperref 包的参数中指定的颜色是深绿色,但引用却是蓝色的。

答案1

该类在文档开头elsarticle重新定义(以及其他几个)为,覆盖您在序言中所做的设置。您可以通过添加以下代码将更改附加到在文档开头执行的代码来覆盖此覆盖\@citecolorblue

\makeatletter
    \AtBeginDocument{\def\@citecolor{DarkGreen}}
\makeatother

到序言部分(使用DarkGreen您在 MWE 中定义的所需颜色)。结果(稍微清理了一下):

\documentclass[authoryear,review,12pt,pdf]{elsarticle}
\usepackage{color}
\definecolor{DarkGreen}{rgb}{0.2,0.5,0.2} % to color links in references
\usepackage[%
    pdftex,%
    colorlinks=true,%
    hyperindex,%
    plainpages=false,%
    pagebackref=true,%
    bookmarksopen,%
    bookmarksnumbered %
      ]{hyperref}

%Added:
\makeatletter
\AtBeginDocument{\def\@citecolor{DarkGreen}}
\makeatother

\begin{document}
A document with a citation \cite{abr1}. Some text written in   \textcolor{DarkGreen}{Dark green}.
\bibliographystyle{elsarticle-harv}
    \begin{thebibliography}{1}
        \expandafter\ifx\csname natexlab\endcsname\relax\def\natexlab#1{#1}\fi
        \expandafter\ifx\csname url\endcsname\relax
        \def\url#1{\texttt{#1}}\fi
        \expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi
        \bibitem[{Abramovitz and Stegun(1964)}]{abr1}
           Abramovitz, M., Stegun, I., 1964. Handbook of mathematical functions with
          formulas, graphs and mathematical tables. 55. {U}.{S}. {G}overnment
          {P}rinting {O}ffice, Washington, DC, {P}aperback edition published by
          {D}over, {N}ew {Y}ork.
    \end{thebibliography}
\end{document}

在此处输入图片描述

相关内容