3

I wish to change the color by default of the citations in the Elsevier template without having to touch the style sheet. Is this possible? Here is a 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}

As can be seen, the citation comes out in blue, even though the color specified in the parameters of the hyperref package is Dark Green.

  • 3
    That seems to be deliberate from Elsevier (they overwrite any of your choices unless to place them elsewhere). So if you are writing an article for an Elsevier journal: do not change the link fonts. (Then you will not piss off the editors receiving the article) (pardon my language) – daleif Jun 15 '15 at 12:31
  • You could be right. But then some wish line numbers to appear, others prefer not... Even within the Elsevier community there seem to be a multiplicity of opinions. – Xavier_B Jun 15 '15 at 15:46
  • 1
    Such things are still not up to the author. Some like one font others another, but it is still the journals in house style that determines which font is actually used. It is really annoying when one have made a template for authors to use with explicit instructions, then to discover that some, thought they knew better, and then they changed the fonts, margins wherever. It is a waste of the journal editors time. – daleif Jun 15 '15 at 16:48
  • @daleif, Then maybe you can tell me how I am supposed to be able to make evident to the reviewers changes I have made to answer their queries and comments. Of course, a separate reply to the reviewers is also required, but it has become standard behaviour of the authors to make absolutely clear to the reviewers what changes have been made. And, as far as I can tell, this is not contemplated in the elsevier template. – Xavier_B Jun 26 '15 at 13:53
  • I'd make to markups for it, (1) a macro, lets call it \CHANGED which just calls \textcolor{red}{#1} and an environment equivalent CHANGEDenv that just issues \color{red} or some other color. Then mark what ever is changed with that. I tend to also add a marker in the margin (using marginnote so the changes are easier to find). If old and new text are needed, then you need something a bit more complicated. – daleif Jun 26 '15 at 14:03
0

The elsarticle class redefines \@citecolor (and several others) at the beginning of the document to blue, overriding the settings you are making in the preamble. You can override this override by appending the changes to the code executed at the beginning of the document by adding

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

to the preamble (with DarkGreen being the desired color you defined in your MWE). The result (cleaned up a bit):

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

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.