[Tex/LaTex] Citation colour with Beamer + Hyperref + Natbib

beamercolorhyperrefnatbib

I'm using natbib for citation with a custom bibstyle. I'm working on a presentation using LaTeX beamer and for some reason the citation marker doesn't have the colour that is specified to hyperref. The citation marker is black instead of green. I'll give you a MWE:

\documentclass{beamer}
\hypersetup{
  colorlinks,
  citecolor=green,
  linkcolor=red
}

\usepackage{filecontents}
\begin{filecontents}{mybib.bib}
@ARTICLE{Bar2011,
  author = {F. Foo and F. Bar},
  title = {Foo and Bar},
  journal = {Journal of Foo},
  year = {2011},
  volume = {1},
  pages = {1--3}
}
\end{filecontents}

\usepackage[comma,numbers,sort&compress]{natbib}
\bibliographystyle{plain}

\begin{document}
Dummy referefence to~\cite{Bar2011}
\bibliography{mybib}
\end{document}

For the purpose of the MWE I have selected the plain bibstyle, however, changing that to something else (including the custom style I want to use) doesn't affect the label colour.

Is there any patch for this problem?

Best Answer

I do not remember where, but sometime ago, I found this workaround:

\documentclass{beamer}

\usepackage[comma,numbers,sort&compress]{natbib}
\bibliographystyle{plain}

\hypersetup{
    colorlinks,
    citecolor=green,
    linkcolor=red,
    backref=true
}

\let\oldbibitem=\bibitem
\renewcommand{\bibitem}[2][]{\label{#2}\oldbibitem[#1]{#2}}
\let\oldcite=\cite
\renewcommand\cite[1]{\hypersetup{linkcolor=green} \hyperlink{#1}{\oldcite{#1}}}
\let\oldcitep=\citep
\renewcommand\citep[1]{\hypersetup{linkcolor=green}\hyperlink{#1}{\oldcitep{#1}}}
\let\oldciteauthor=\citeauthor
\renewcommand\citeauthor[1]{\hypersetup{linkcolor=green}\hyperlink{#1}{\oldciteauthor{#1}}} 


\usepackage{filecontents}
\begin{filecontents}{mybib.bib}
    @ARTICLE{Bar2011,
        author = {F. Foo and F. Bar},
        title = {Foo and Bar},
        journal = {Journal of Foo},
        year = {2011},
        volume = {1},
        pages = {1--3}
    }
\end{filecontents}

\begin{document}
    Dummy referefence to~\cite{Bar2011}
    \bibliography{mybib}
\end{document}
Related Question