3

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}
  • 1
    section in toc shaded means how the font colour etc. of the inactive sections is, this has nothing to do with a background gradient. – user36296 May 27 '16 at 17:44
2

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

  • 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
  • 1
    @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} {...} – user36296 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. – user36296 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

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.