12

I link a page using \href{url}{anchor text} in beamer. I followed this instruction How to change hyperlinks color {Lyx} to change the url color.

\hypersetup{urlcolor=blue}

It doesn't work. The following one works.

\usepackage{hyperref}
\hypersetup{
     colorlinks,
     urlcolor    = blue
}

However it changes url color not just hyperlinks, but section in navigation bars, as shown below.

enter image description here

How do I change hyperlinks' color only?


Here is a MWE.

\documentclass{beamer}
\usetheme{Warsaw}

\usepackage{hyperref}
\hypersetup{
     colorlinks,
     urlcolor    = blue
}
\usepackage{color}
\urlstyle{same}

%%% The title pape
\title{Title}

\author{Author}


\begin{document}

\begin{frame}[noframenumbering, plain]%[shrink=20]
    \titlepage
\end{frame}

\begin{frame}{Outline}
    \tableofcontents[currentsection, currentsubsection, sectionstyle=show/show, subsectionstyle=show/show/show]
\end{frame}


\section{section 1}
\begin{frame}[fragile]{URL color}
URL color: \href{http://example.com/}{Text 1}
\end{frame}

\section{section 2}
\begin{frame}[fragile]{URL color}
URL color: \href{http://example.com/}{Text 1}
\end{frame}

\end{document}

1 Answers1

21

Option colorlinks of package hyperref sets colors for all link types. Class beamer does not use this option, but uses option pdfborder to remove the link annotation rectangles.

The problem can be solved by using the special color . of package xcolor that refers to the current color:

\hypersetup{
  colorlinks,
  allcolors=.,
  urlcolor=blue,
}

First, the colors to all link types are set to the current color. Then, the color for URLs is set to blue.

Package xcolor is automatically loaded by class beamer.

Heiko Oberdiek
  • 271,626
  • This didn't work for me. :( My case is slightly different. I also included the option 'linkcolor=blue' of package 'hyperref'. Then, all links of the header and the footline become blue. How can avoid this? [EDIT: This is answered here: https://tex.stackexchange.com/questions/481025/prevent-hyperref-from-changing-the-color-of-section-and-subsection-hyperlinks ] – Vicent Sep 21 '19 at 23:32
  • This worked! Thanks! – katyhuff Mar 17 '21 at 01:33