5

Consider the following MWE

\documentclass[leqno]{beamer}

\usetheme{Madrid}
\usecolortheme{whale}

\usepackage{lmodern}
\hypersetup{colorlinks=true, allcolors=blue}

\title[Short title]{Title}
\author{John Doe}
\date{\today}

\begin{document}
\begin{frame}
  \begin{equation}
  \label{eq:foo}
      2 + 2 = 4
  \end{equation}

  Hyperlink: \ref{eq:foo}
\end{frame}
\end{document}

I want my short title foreground color to be white and my hyperlinks blue. However setting colorlinks=true, allcolors=blue also sets a blue color for the short title. I tried setting \setbeamercolor{title in head/foot}{fg=white} but it doesn't seem to have any effect.

enter image description here

I found this answer that apparently addresses the same/similar problem. In order to just change the color of the short title is it also necessary (an the only workaround available) to temporarily disable hyperref functionality in the footer?

petobens
  • 3,306
  • you can force a white color using \title[\color{white}Short title]{Title} (or \textcolor{}{}) It's not very elegant but shouldn't have any side effect – d-cmst Sep 17 '14 at 20:57
  • @dcmst thanks for your answer. I was in fact doing exactly that until now but also find that solution a bit dirty. If there isn't a more general yet simple solution then I'll stick to your workaround. – petobens Sep 17 '14 at 21:35

2 Answers2

5

You can change allcolors to the current color . inside the footline template using

\addtobeamertemplate{footline}{\hypersetup{allcolors=.}}{}

enter image description here

Code:

\documentclass[leqno]{beamer}

\usetheme{Madrid}
\usecolortheme{whale}

\usepackage{lmodern}
\hypersetup{colorlinks=true, allcolors=blue}
\addtobeamertemplate{footline}{\hypersetup{allcolors=.}}{}

\title[Short title]{Title}
\author{John Doe}
\date{\today}

\begin{document}
\begin{frame}
  \begin{equation}
  \label{eq:foo}
      2 + 2 = 4
  \end{equation}

  Hyperlink: \ref{eq:foo}
\end{frame}
\end{document}
esdd
  • 85,675
4

I'm not sure if there is some reason not to do this but very hasty testing suggests that hyperlinks work and the short title appears in white:

\documentclass[leqno]{beamer}

\usetheme{Madrid}
\usecolortheme{whale}

\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

\usepackage{lmodern}
\hypersetup{colorlinks=true, allcolors=blue}

\title[Short title]{Title}
\author{John Doe}
\date{\today}

\begin{document}
  \begin{frame}
    \titlepage
  \end{frame}

\begin{frame}
  \begin{equation}
  \label{eq:foo}
      2 + 2 = 4
  \end{equation}

  Hyperlink: \ref{eq:foo}
\end{frame}
\end{document}

[I added the title page just to check the hyperlinking actually did something.]

hyperlinked short title in white?

Updated to use samcarter's suggestion which enhances flexibility.

cfr
  • 198,882
  • 1
    Perhaps one could replace the \color{white} by \usebeamercolor*[fg]{title in head/foot} to make it more flexible – samcarter_is_at_topanswers.xyz Sep 18 '14 at 07:12
  • @samcarter You are quite right - thanks! I've updated the code. – cfr Sep 18 '14 at 14:35
  • Can this be achieved by patching the \insertshorttitle command with the etoolbox package? I tried \makeatletter \patchcmd{\insertshorttitle}{\beamer@shorttitle}{\usebeamercolor*[fg]{title in head/foot}\beamer@shorttitle}{}{} \makeatother but it didn't work. – petobens Oct 04 '14 at 04:17
  • @petobens I'm not sure why that wouldn't work. But beamer's code always seems complex and I always find it difficult to even trace what is doing what, even before trying to change it in some way. Why do you wish to do it that way particularly? That is, does renewing the command as I did cause side-effects? – cfr Oct 04 '14 at 09:36
  • @crf your solution works great. I was just wondering if it could be make a bit more compact by using etoolbox and just patching the \insertshorttitle command. Can you try patching it? Thanks! – petobens Oct 04 '14 at 14:01
  • @petobens OK. I've looked into this. etoolbox reports the command as patchable but if any search text is specified, it reports it as unpatchable. (You can use \tracingpatches in the preamble and \ifpatchable..., \ifpatchable*... to test this.) etoolbox suggests 3 possible reasons. Two of these are irrelevant since the problem occurs without specifying replacement text. So my guess is the remaining one: the macro may have been defined under a category code regime different from the current one. I know very little about cat codes. However, beamerbasedecode.sty may be interesting... – cfr Oct 04 '14 at 22:02
  • Personally, though, I do not think it is worth pursuing this if the only motivation is marginally more concise code. First, it will be a lot of work to save a little code. Second, you will need to adjust the category codes before patching the command, I think, and then readjust them after patching. I doubt that the result will be more compact than the code in my answer. – cfr Oct 04 '14 at 22:07
  • @petobens Maybe there is something in that file you could use to switch the cat codes back and forth. However, I don't understand it well enough to make use of it. You may be more insightful ;). – cfr Oct 04 '14 at 22:12
  • @cfr Thanks for looking into this! And for explaining why this might not work. I know almost nothing about cat codes so I can't provide any insight. Therefore I will stick to your code which works just fine. Thanks once again. – petobens Oct 04 '14 at 22:30
  • 1
    @cfr I've posted a follow-up question here. Thanks once again for looking into this. – petobens Oct 05 '14 at 21:35