[Tex/LaTex] How to gradient shade the background of a beamer section/subsection in head/foot

beamershading

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}
\useoutertheme{shadow}
\definecolor {Burgandy}{HTML}{660033}
\definecolor {Crimson}{HTML}{990033}
\definecolor {Orange}{HTML}{ff9933}

\usetheme{CambridgeUS}

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

\pgfdeclarehorizontalshading[titleleft,titlemiddle,titleright]
      {beamer@frametitleshade}{\paperheight}{
    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}

Best Answer

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}
\useoutertheme{shadow}
\usetheme{CambridgeUS}

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

\pgfdeclarehorizontalshading[titleleft,titlemiddle,titleright]
      {beamer@frametitleshade}{\paperheight}{
    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{%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
            \usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
            \usebeamerfont{title in head/foot}\insertshorttitle
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
            \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
            \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
        \end{beamercolorbox}%
        }%
        \beamer@tempdim=\ht\beamer@tempbox%
        \advance\beamer@tempdim by 4pt%
        \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
            \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
            \pgfusepath{clip}
            \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
        \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}

enter image description here


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

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

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

\pgfdeclarehorizontalshading[titleleft,titlemiddle,titleright]
      {beamer@frametitleshade}{\paperheight}{
    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{%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
            \usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
            \usebeamerfont{title in head/foot}\insertshorttitle
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
            \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
            \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
        \end{beamercolorbox}%
        }%
        \beamer@tempdim=\ht\beamer@tempbox%
        \advance\beamer@tempdim by 4pt%
        \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
            \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
            \pgfusepath{clip}
            \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
        \end{pgfpicture}
        \vskip-\beamer@tempdim%
        \box\beamer@tempbox%    
}%

\setbeamertemplate{headline}
{
    \leavevmode%
    \setbox\beamer@tempbox=\hbox{%
        \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,right]{section in head/foot}%
            \usebeamerfont{section in head/foot}\insertsectionhead\hspace*{2ex}
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,left]{subsection in head/foot}%
            \usebeamerfont{subsection in head/foot}\hspace*{2ex}\insertsubsectionhead
        \end{beamercolorbox}%
        }%
        \beamer@tempdim=\ht\beamer@tempbox%
        \advance\beamer@tempdim by 4pt%
        \vskip-\beamer@tempdim%
        \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
            \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
            \pgfusepath{clip}
            \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
        \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}

enter image description here