# Multiple horizontal shadings in Tree outer theme

Starting from Tree outer theme, I would like to add horizontal shading to each of the headlines line (as in Shadow outer theme), but a different shading for each line. Say, for a more striking example, blue to orange for document's title, purple to green for section, red to yellow for subsection, and black to gray for the frame title.

Taking inspiration from the answer given to a previous question of mine (and pasting the chunk on frame title from the Shadow theme file):

Tweaking infolines outer theme with horizontal shading

I typed the following code:

\documentclass{beamer}

\usepackage{tikz}

\useoutertheme{tree}
\usecolortheme{whale}
\usefonttheme{professionalfonts}

\setbeamercolor{frametitle}{fg=white,bg=}

color(0pt)=(blue);
color(\paperwidth)=(orange)
}

color(0pt)=(purple);
color(\paperwidth)=(green)
}

color(0pt)=(red);
color(\paperwidth)=(yellow)
}

color(0pt)=(black);
color(\paperwidth)=(gray)
}

\makeatletter
{
\leavevmode%
\end{beamercolorbox}
\setbox\beamer@tempbox=\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex,%
\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%
\setbox\beamer@tempbox=\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex,%
\ifbeamer@tree@showhooks
\ifdim\wd\beamer@tempbox>1pt%
\hskip2pt\raise1.9pt\hbox{\vrule width0.4pt height1.875ex\vrule width 5pt height0.4pt}%
\hskip1pt%
\fi%
\else%
\hskip6pt%
\fi%
\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%
\setbox\beamer@tempbox=\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex,%
\ifbeamer@tree@showhooks
\ifdim\wd\beamer@tempbox>1pt%
\hskip9.4pt\raise1.9pt\hbox{\vrule width0.4pt height1.875ex\vrule width 5pt height0.4pt}%
\hskip1pt%
\fi%
\else%
\hskip12pt%
\fi%
\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%
}

\setbeamertemplate{frametitle}
{%
\nointerlineskip%
\vskip-2pt%
\hbox{\leavevmode
\beamer@tempdim=\textwidth%
\hskip-\Gm@lmargin\hbox{%
\setbox\beamer@tempbox=\hbox{\begin{minipage}[b]{\paperwidth}%
\vbox{}\vskip-.75ex%
\leftskip0.3cm%
\rightskip0.3cm plus1fil\leavevmode
\insertframetitle%
\ifx\insertframesubtitle\@empty%
\strut\par%
\else
\par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
\fi%
\nointerlineskip
\vbox{}%
\end{minipage}}%
\beamer@tempdim=\ht\beamer@tempbox%
\begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim}
\usebeamercolor{frametitle right}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
\pgfusepath{clip}
\end{pgfpicture}
\hskip-\paperwidth%
\box\beamer@tempbox%
}%
\hskip-\Gm@rmargin%
}%
\nointerlineskip
\vskip-0.2pt
\vskip-2pt
}

\makeatother

\title{Title}
\author{Author}
\institute{Institute}
\date{Date}

\begin{document}

\section{Title of Section 1}
\subsection{Title of Subsection 1-1}

\begin{frame}
\frametitle{Frame Title}
Some text.
\end{frame}

\end{document}


Here's the result:

It's a good start, however notice that the height of the headlines is inconsistent. In particular, the subsection line is "cut short" just below its text. Also, there's that blank space below navigation symbols, I don't know where it comes from.

I surmise it has to do with the spacing below or above the shading pictures, or the beamer color boxes, but I don't know how to fine tune it...

• You are only distracting the audience or the reader. Also as a colorblind those transitions are just annoying :-) – percusse Nov 19 '17 at 19:37
• I know this template is obnoxiously ugly :-) I plan to use shades of only two colors in my final work. I picked colors that are very different from one another in this training example just to hunt for glitches. If one shading is out of place, I immediately spot it. – Magean Nov 19 '17 at 19:47

You can control the depth of the colour boxes with the parameter dp=1.125ex. To get more depth, increase it to e.g. 1.5.

As for the space between the navigation symbols and the bottom of the frame, this is your footline. Despite the fact that you set the colours to white/transparent it is still there. If you want to remove it: \setbeamertemplate{footline}{}

\documentclass{beamer}

\usepackage{tikz}

\useoutertheme{tree}
\usecolortheme{whale}
\usefonttheme{professionalfonts}

\setbeamercolor{frametitle}{fg=white,bg=}

color(0pt)=(blue);
color(\paperwidth)=(orange)
}

color(0pt)=(purple);
color(\paperwidth)=(green)
}

color(0pt)=(red);
color(\paperwidth)=(yellow)
}

color(0pt)=(black);
color(\paperwidth)=(gray)
}

\makeatletter
{
\leavevmode%
\end{beamercolorbox}
\setbox\beamer@tempbox=\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.5ex,%
\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%
\setbox\beamer@tempbox=\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.5ex,%
\ifbeamer@tree@showhooks
\ifdim\wd\beamer@tempbox>1pt%
\hskip2pt\raise1.9pt\hbox{\vrule width0.4pt height1.875ex\vrule width 5pt height0.4pt}%
\hskip1pt%
\fi%
\else%
\hskip6pt%
\fi%
\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%
\setbox\beamer@tempbox=\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.5ex,%
\ifbeamer@tree@showhooks
\ifdim\wd\beamer@tempbox>1pt%
\hskip9.4pt\raise1.9pt\hbox{\vrule width0.4pt height1.875ex\vrule width 5pt height0.4pt}%
\hskip1pt%
\fi%
\else%
\hskip12pt%
\fi%
\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%
}

\setbeamertemplate{frametitle}
{%
\nointerlineskip%
\vskip-2pt%
\hbox{\leavevmode
\beamer@tempdim=\textwidth%
\hskip-\Gm@lmargin\hbox{%
\setbox\beamer@tempbox=\hbox{\begin{minipage}[b]{\paperwidth}%
\vbox{}\vskip-.75ex%
\leftskip0.3cm%
\rightskip0.3cm plus1fil\leavevmode
\insertframetitle%
\ifx\insertframesubtitle\@empty%
\strut\par%
\else
\par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
\fi%
\nointerlineskip
\vbox{}%
\end{minipage}}%
\beamer@tempdim=\ht\beamer@tempbox%
\begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim}
\usebeamercolor{frametitle right}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
\pgfusepath{clip}
\end{pgfpicture}
\hskip-\paperwidth%
\box\beamer@tempbox%
}%
\hskip-\Gm@rmargin%
}%
\nointerlineskip
\vskip-0.2pt
\vskip-2pt
}

\makeatother

\setbeamertemplate{footline}{}

\title{Title}
\author{Author}
\institute{Institute}
\date{Date}

\begin{document}

\section{Title of Section 1}
\subsection{Title of Subsection 1-1}

\begin{frame}
\frametitle{Frame Title}
Some text.
\end{frame}

\end{document}


• Thanks, I'll toy around with that parameter. I also improved the result by adjusting the recurring \vskip0pt line and replacing 0 with something else (2.5 worked fine). – Magean Nov 19 '17 at 20:31