Changing color of cites with hypersetup not working
colorlinks
cannot be enabled, afterhyperref
is loaded. Set the option as package option:\usepackage[colorlinks]{hyperref}
The color
Violet
is undefined, this can be fixed, for example, by setting optionsvgnames
for packagexcolor
.As Augustin has already analyzed in his answer, class
elsarticle
defines the colors of all link types toblue
. This is done via\AtBeginDocument
. A later\AtBeginDocument
can again overwrite the color settings as shown in the following example.
Test file (unnecessary packages for MWE removed):
\documentclass[preprint,3p,twocolumn,authoryear]{elsarticle}
\usepackage[table,xcdraw,svgnames]{xcolor}
\usepackage{natbib}
\usepackage[colorlinks]{hyperref}
\AtBeginDocument{%
\hypersetup{
citecolor=Violet,
linkcolor=Red,
urlcolor=Magenta}}
\begin{document}
\begin{frontmatter}
\title{Article}
\end{frontmatter}
\section{Introduction}
I'm citing the cite \citep{Bishop}.
\section*{References}
\bibliography{biblio}
\bibliographystyle{elsarticle-harv}
\end{document}
Remark:
If you want to submit the article and the publisher requires the use of class elsarticle
, then the publisher might not want that the user changes the link colors and should be asked before submitting.
The problem is caused by the elsarticle
class which defines the colour of the links and prevents you from redefining them. If you change the style to article
everything will work.