8

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?

  • I had the same problem recently. See the answer here. – Māris Ozols May 13 '13 at 18:56
  • @MārisOzols you may have noticed that I specified that I'm using natbib which you do not. – elemakil May 13 '13 at 19:10
5

The solution offered by samcarter did not quite work for me. But I was successful by putting the following lines into the preamble:

\let\oldcite=\cite                                                              
\renewcommand{\cite}[1]{\textcolor[rgb]{.7,.7,.7}{\oldcite{#1}}}
4

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}

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.