# elsarticle class: how to get coloured links without boxes?

I'm using the elsearticle class. At present the links (citations, equation references, etc) are put in coloured boxes and I'd rather have the links coloured without boxes. So I tried putting

\usepackage{hyperref}
\usepackage[hyperref]{xcolor}
\hypersetup{
urlcolor     = red, %Colour for external hyperlinks
citecolor   = red %Colour of citations
}


But this doesn't work, it turns the boxes off but turns the colour of all the links to blue. How can I make it work?

The class does

\AtBeginDocument{\@ifpackageloaded{hyperref}
\def\@anchorcolor{blue}
\def\@citecolor{blue}
\def\@filecolor{blue}
\def\@urlcolor{blue}
\def\@pagecolor{blue}
\begingroup
\@makeother\%
\@makeother\=%
\edef\x{%
\edef\noexpand\x{%
\endgroup
\noexpand\toks@{%
\catcode 96=\noexpand\the\catcode\noexpand\\relax
\catcode 61=\noexpand\the\catcode\noexpand\=\relax
}%
}%
\noexpand\x
}%
\x
\@makeother\
\@makeother\=
}{}}


so you need to override this:

\documentclass{elsarticle}
\usepackage{hyperref}
\usepackage[hyperref]{xcolor}

\makeatletter
\def\@anchorcolor{red}
\def\@citecolor{red}
\def\@filecolor{red}
\def\@urlcolor{red}
\def\@pagecolor{red}
\begingroup
\@makeother\%
\@makeother\=%
\edef\x{%
\edef\noexpand\x{%
\endgroup
\noexpand\toks@{%
\catcode 96=\noexpand\the\catcode\noexpand\\relax
\catcode 61=\noexpand\the\catcode\noexpand\=\relax
}%
}%
\noexpand\x
}%
\x
\@makeother\
\@makeother\=
}{}}
\makeatother

\begin{document}

\tableofcontents

\section{Test section}
\href{www.tex.stackexchange.com}{TeX.sx} \cite{test}

\begin{thebibliography}{9}
\bibitem{test} Author, Title, 2015
\end{thebibliography}

\end{document}


Or shorter, doing colorlinks=true in the preamble and the change for colors

\hypersetup{
urlcolor=red,
citecolor=red
}


in the body of the document:

\documentclass{elsarticle}
\usepackage{hyperref}
\usepackage[hyperref]{xcolor}

\hypersetup{
}

\begin{document}
\hypersetup{
urlcolor=red,
citecolor=red
}
\tableofcontents

\section{Test section}
\href{www.tex.stackexchange.com}{TeX.sx} \cite{test}

\begin{thebibliography}{9}
\bibitem{test} Author, Title, 2015
\end{thebibliography}

\end{document}


The result, showing red colorized links:

• Thanks. Any idea why they designed it like that? – C_Al Aug 27 '15 at 21:31
• @C_Al Most probably they wanted to enforce the blue color as an editorial decision. – Gonzalo Medina Aug 27 '15 at 23:39