# How do I gradient shade the background of a beamer section/subsection in head/foot?

Here is a reduced example of my code. I am attempting to restyle the background of the section in head/foot and subsection in head/foot in the CambridgeUS theme to a gradient background colour.

Right now the gradient background works if I were to specify say beamer@frametitleshade in my pgf declaration. I can't find and can't guess the correct keywords to get this to affect the background of the section in head/foot nor the subsection in head/foot, I've tried things like sectioninheadfootshade and variants.

\documentclass[hyperref={pdftex}]{beamer}
\definecolor {Burgandy}{HTML}{660033}
\definecolor {Crimson}{HTML}{990033}
\definecolor {Orange}{HTML}{ff9933}

\usetheme{CambridgeUS}

\colorlet{titleleft}{Burgandy}
\colorlet{titlemiddle}{Crimson}
\colorlet{titleright}{Orange}

color(0pt)=(titleleft);
color(0.6\paperwidth)=(titlemiddle);
color(\paperwidth)=(titleright)
}

\title[Short Title]{Long title}
\subtitle{Sub title}
\date{\today}

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

\begin{frame}{Slide 1}
Content
\end{frame}
\end{document}

• section in toc shaded means how the font colour etc. of the inactive sections is, this has nothing to do with a background gradient. – samcarter_is_at_topanswers.xyz May 27 '16 at 17:44

You can redefine the elements to use the same colour gradient as the frametitle. Please compare the following redefinition of the footline with the original one from beamerouterthemeinfolines.sty to see the changes. You can use the same approach to modify the headline.

One trick: The background of the colours has to be set to empty.

\documentclass[hyperref={pdftex}]{beamer}
\usetheme{CambridgeUS}

\colorlet{titleleft}{red}
\colorlet{titlemiddle}{orange}
\colorlet{titleright}{yellow}

color(0pt)=(titleleft);
color(0.6\paperwidth)=(titlemiddle);
color(\paperwidth)=(titleright)
}

\title[Short Title]{Long title}
\subtitle{Sub title}
\date{\today}
\author{test}

\setbeamercolor{author in head/foot}{parent=palette primary,bg=}
\setbeamercolor{title in head/foot}{parent=palette secondary,bg=}
\setbeamercolor{date in head/foot}{parent=palette tertiary,bg=}

\makeatletter
\setbeamertemplate{footline}
{
\leavevmode%
\setbox\beamer@tempbox=\hbox{%
\end{beamercolorbox}%
\end{beamercolorbox}%
\end{beamercolorbox}%
}%
\beamer@tempdim=\ht\beamer@tempbox%
\begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
\pgfusepath{clip}
\end{pgfpicture}
\vskip-\beamer@tempdim%
\box\beamer@tempbox%
}%
\makeatother

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

\section{ble}
\begin{frame}{Slide 1}
Content
\end{frame}
\end{document}


As the procrastination force is great in me, here also the headline

\documentclass[hyperref={pdftex}]{beamer}
\usetheme{CambridgeUS}

\colorlet{titleleft}{red}
\colorlet{titlemiddle}{orange}
\colorlet{titleright}{yellow}

color(0pt)=(titleleft);
color(0.6\paperwidth)=(titlemiddle);
color(\paperwidth)=(titleright)
}

\title[Short Title]{Long title}
\subtitle{Sub title}
\date{\today}
\author{test}

\setbeamercolor{author in head/foot}{parent=palette primary,bg=}
\setbeamercolor{title in head/foot}{parent=palette secondary,bg=}
\setbeamercolor{date in head/foot}{parent=palette tertiary,bg=}

\setbeamercolor{section in head/foot}{parent=palette primary,bg=}
\setbeamercolor{subsection in head/foot}{parent=palette secondary,bg=}

\makeatletter
\setbeamertemplate{footline}
{
\leavevmode%
\setbox\beamer@tempbox=\hbox{%
\end{beamercolorbox}%
\end{beamercolorbox}%
\end{beamercolorbox}%
}%
\beamer@tempdim=\ht\beamer@tempbox%
\begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
\pgfusepath{clip}
\end{pgfpicture}
\vskip-\beamer@tempdim%
\box\beamer@tempbox%
}%

{
\leavevmode%
\setbox\beamer@tempbox=\hbox{%
\end{beamercolorbox}%
\end{beamercolorbox}%
}%
\beamer@tempdim=\ht\beamer@tempbox%
\vskip-\beamer@tempdim%
\begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
\pgfusepath{clip}
\end{pgfpicture}
\vskip-\beamer@tempdim%
\box\beamer@tempbox%
\vskip0pt%
}
\makeatother

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

\section{ble}
\subsection{bla}
\begin{frame}{Slide 1}
Content
\end{frame}
\end{document}


• This causes me a small problem that I only want the headline changed, not the head and foot. My foot I've set differently using \setbeamercolor. – Stephen May 27 '16 at 18:19
• @Stephen Ah, sorry than I misunderstood your question, I guess I just read to many times the word "foot" :). To get rid of this footline just delete \setbeamertemplate{footline} {...} – samcarter_is_at_topanswers.xyz May 27 '16 at 18:23
• @Stephen And just to throw in my personal opinion, I would not make the headline the exact same colour gradient than the title. Now the frametitle looks strange because there is more space above than below and the section and subsection look strange, because the are squished at the top. Perhaps reverse the colour order for the headline to get some kind of separation. – samcarter_is_at_topanswers.xyz May 27 '16 at 18:28
• Yes, I am using a different frametitle for exactly the reason you pointed out. Once I have it working for me in my larger project I'll check accepted. – Stephen May 27 '16 at 19:21
• Can I use this shade in Berkeley theme? – Khaaba Jun 25 '17 at 7:18