-1

I would like to use the hyperref package to color citations only, but it seems that it colors every link.

For example here:

\documentclass{article}
    
\usepackage{hyperref}
\hypersetup{
    citecolor  = blue,
        colorlinks = true,
    }
    
\begin{document}
        
\tableofcontents
\section{This title should be in red in the TOC}
        
This citation \cite{a} is blue.
        
\begin{thebibliography}{99}
   \bibitem{a} Andros, Using hyperref for a citation, StackExchange, 2022.
\end{thebibliography}
        
\end{document} 

I would like the citation to be blue, but I don't want the items in the table of contents to be red.

Thanks

Andros
  • 3
  • 3

1 Answers1

0

I would not activate colorlinks with beamer. This can break the carefully constructed colour themes in sometimes very surprising places.

Instead you could change the text colour for the citation:

\documentclass{beamer}

\usetheme{metropolis}

\usepackage{xpatch}
\usepackage{xspace}

\makeatletter
\xpretocmd{\@citex}{\color{blue}}{}{}
\xapptocmd{\@citex}{\color{normal text.fg}\xspace}{}{}
\makeatother
\begin{document}
        
\begin{frame}
        
This citation \cite{a} is blue.
        
\begin{thebibliography}{99}
   \bibitem{a} Andros, Using hyperref for a citation, StackExchange, 2022.
\end{thebibliography}
        
\end{frame}        
\end{document} 
  • Thanks for that. Your example works fine, but it seems not to be working for me, and maybe that's because I am using BibLaTeX... – Andros Mar 17 '22 at 12:06
  • Of course that won't work with biblatex!!!!!!!!!!!!!!!! Why do you think I asked for a [mre] to see which code and packages you use???????????????????? – samcarter_is_at_topanswers.xyz Mar 17 '22 at 12:09
  • Sorry about that! But your solution works fine and I have switched to standard bibliography, thanks! – Andros Mar 17 '22 at 12:59