# Changing URL colors in headline / footline of beamer template

## Problem:

I need to have URLs via \href{}{} be colored in blue text in the presentation. However, using \hypersetup{colorlinks=true,linkcolor = blue} changes the text in the section, subsection text in the headline, and the title text in the footline. These changes are problematic given the background color of the areas are blue.

## Need:

I would really appreciate a better modification for section and subsection on the order of the first possible solution with the \renewcommand\insertshortitle or at least a pointer in the direction I should go.

The goal is to be able to use the modification to create a beamer theme.

## Possible fixes (sorta):

I've found a few ideas and have implemented them with varying success found is to disable auto-coloring links. This has lead me to do \textcolor{blue}{\href{}{}}, which is not ideal.

There is a proposed solution with shorttitle:

\makeatletter
\renewcommand\insertshorttitle[1][]{%
\beamer@setupshort{#1}%
\let\thanks=\@gobble%
\ifnum\c@page=1%
\else%
\fi}
\makeatother


I have not been able to make this work with \insertsectionhead and \insertsubsectionhead. I would prefer this alternative to defining a new method for \href's.

There was another idea on how to disable linking here: How to remove link from title in foot

The main idea was to use: \let\hyperlink\@secondoftwo to suppress the creation of the link.

I marked it up using headline

\setbeamertemplate{headline}
{
\leavevmode%
\hbox{%
\end{beamercolorbox}%
\end{beamercolorbox}}%
\vskip0pt%
}


However, this approach appends secondoftwo to the section and subsection strings.

The last option I have come across and implemented seems to have resolve the issue with the only downside being I have to include a new package (etoolbox). The idea came from:

errors with MakeUppercase and Beamer's insertsectionhead

\usepackage{etoolbox}
\makeatletter
\patchcmd{\beamer@section}
{}{}
\patchcmd{\beamer@subsection}
{}{}
\makeatother


## MWE (visual of what's wrong)

\documentclass{beamer}

%normal
\usepackage{color}
\usepackage{beamerthemebars}
\usepackage{lmodern}
\usetheme{AnnArbor}
\usecolortheme{wolverine}

\setbeamercolor{palette tertiary}{bg=blue,fg=white}
\setbeamercolor{palette secondary}{bg=gray,fg=white}
\setbeamercolor{palette primary}{bg=pink,fg=white}

\usepackage{hyperref}
\usepackage{amssymb,amsmath}

\author[Coatless]{Lack of Coat}
\institute[Uni]{Uni All}
\date[Date]{\today}
\title[Title]{Fake Presentation}
\begin{document}

\section{Section naught}
\subsection{Subsection Ya}

% link color causes the section, subsection, and title to fg (font color) to be blue
\frame{\titlepage}

% link color causes the section, subsection, and title to fg (font color) to be white
\frame{\titlepage}

\end{document}


Preview:

• Sadly, that addresses only the footline title issue. I tried marking that differently to account for section and subsection in the headline to no avail. – coatless Sep 25 '14 at 8:47
• I'm not clear whether you have answered this in the question with the etoolbox solution or not. Is there some reason you don't want to post that solution as an answer? – cfr Sep 29 '14 at 22:56
• I did post the solution using etoolbox. However, the etoolbox solution is really a work around. I would really like a better solution that can be incorporated into a beamer theme. – coatless Oct 1 '14 at 15:05

You can use

\hypersetup{colorlinks,urlcolor=blue}


to set the linkcolor to the current color . inside the templates headline and footline.

Code:

\documentclass[]{beamer}

\usepackage{beamerthemebars}
\usepackage{lmodern}
\usetheme{AnnArbor}
\usecolortheme{wolverine}

\setbeamercolor{palette tertiary}{bg=blue,fg=white}
\setbeamercolor{palette secondary}{bg=gray,fg=white}
\setbeamercolor{palette primary}{bg=pink,fg=white}

\author[Coatless]{Lack of Coat}
\institute[Uni]{Uni All}
\date[Date]{\today}
\title[Title]{Fake Presentation}

\begin{document}

\section{Section naught}
\subsection{Subsection Ya}

\frame{\titlepage}

\begin{frame}{First Frame}
\href{http://tex.stackexchange.com/}{StackExchange}
\end{frame}
\end{document}


Additionally there is shorter possibility if only URLs should be colored:

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


Similar question is here.

Define a new macro \newhref, where you can specify text color, or have the default color (e.g. blue)

\newcommand{\newhref}[3][blue]{\href{#2}{\textcolor{#1}{#3}}}


and use it like

\newhref{https://tex.stackexchange.com/}{StackExchange} % to get the default (blue) link - 2nd line

\newhref[red]{https://tex.stackexchange.com/}{StackExchange} % to get red link - 1st line


\documentclass{beamer}

\usepackage{color}
\usepackage{beamerthemebars}
\usepackage{lmodern}
\usetheme{AnnArbor}
\usecolortheme{wolverine}

\setbeamercolor{palette tertiary}{bg=blue,fg=white}
\setbeamercolor{palette secondary}{bg=gray,fg=white}
\setbeamercolor{palette primary}{bg=pink,fg=white}

\usepackage{hyperref}
\usepackage{amssymb}
\usepackage{amsmath}

% HERE IS THE DEFINITION
\newcommand{\newhref}[3][blue]{\href{#2}{\textcolor{#1}{#3}}}

\author[Coatless]{Lack of Coat}
\institute[Uni]{Uni All}
\date[Date]{\today}
\title[Title]{Fake Presentation}

\begin{document}

\section{Section naught}
\subsection{Subsection Ya}

% HERE IS THE TEXT
\newhref[red]{https://tex.stackexchange.com/}{StackExchange}

\newhref{https://tex.stackexchange.com/}{StackExchange}

\frame{\titlepage}

\end{document}


• While this is an option, I would really prefer avoiding the definition of a new \href command in favor of resolving the way how links are assigned in the headline of beamer. – coatless Sep 25 '14 at 9:25