2

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.

In Beamer: hyperlinks and short title colors

There is a proposed solution with shorttitle:

\makeatletter
\renewcommand\insertshorttitle[1][]{%
  \beamer@setupshort{#1}%
  \let\thanks=\@gobble%
  \ifnum\c@page=1%
  \hyperlinkpresentationend{\beamer@insertshort{\usebeamercolor*[fg]{title in head/foot}\beamer@shorttitle}}%
  \else%
  \hyperlinkpresentationstart{\beamer@insertshort{\usebeamercolor*[fg]{title in head/foot}\beamer@shorttitle}}%
  \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{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right,rightskip=1em]{section in head/foot}%
    \usebeamerfont{subsection in head/foot}\hspace*{2ex} \let\hyperlink\@secondoftwo\insertsectionhead
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,left,leftskip=1em]{subsection in head/foot}%
    \usebeamerfont{section in head/foot} \let\hyperlink\@secondoftwo\insertsubsectionhead \hspace*{2ex}
  \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}
  {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}}
  {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{\usebeamercolor*[fg]{section in head/foot}#1}}}
  {}{}
\patchcmd{\beamer@subsection}
  {\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{#1}}}
  {\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{\usebeamercolor*[fg]{subsection in head/foot}#1}}}
  {}{}
\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}

\beamertemplatenavigationsymbolsempty %hides navigation.
\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}

\hypersetup{colorlinks=true,urlcolor=blue,linkcolor = blue}
% link color causes the section, subsection, and title to fg (font color) to be blue
\frame{\titlepage}

\hypersetup{colorlinks=false,urlcolor=blue,linkcolor = white}
% link color causes the section, subsection, and title to fg (font color) to be white
\frame{\titlepage}

\end{document}

Preview: MWE

  • does the answer here: tex.stackexchange.com/questions/201727/… help you? – Nico Boni Sep 25 '14 at 8:22
  • 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
5

You can use

\hypersetup{colorlinks,urlcolor=blue}
\addtobeamertemplate{headline}{\hypersetup{linkcolor=.}}{}
\addtobeamertemplate{footline}{\hypersetup{linkcolor=.}}{}

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

enter image description here

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}

\beamertemplatenavigationsymbolsempty %hides navigation.

\hypersetup{colorlinks,urlcolor=blue}
\addtobeamertemplate{headline}{\hypersetup{linkcolor=.}}{}
\addtobeamertemplate{footline}{\hypersetup{linkcolor=.}}{}

\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}
0

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

So in your document:

\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}

\beamertemplatenavigationsymbolsempty %hides navigation.
\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}

enter image description here

  • 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

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.