[Tex/LaTex] How to change hyperlinks’ color only

beamerhyperlinkhyperref

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}

Best Answer

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.