# Beamer: drawing a rectangle that does not overlay the navigation bar

I am trying to draw a blue filled rectangle on half of the slide space. However, I do not want it to overlay the navigation bar. The following figures illustrate the current situation:

The title page

The first slide of the first section. I would like the navigation bar to appear in this one.

The content of the first section

Here follows an MWE for this case

    \documentclass{beamer}

% To make the navigation bullets appear
\usepackage{remreset}
\makeatletter
\@removefromreset{subsection}{section}
\makeatother
\setcounter{subsection}{1}

\useoutertheme[subsection=false]{smoothbars}

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

\setbeamercovered{transparent}
\setbeamercovered{invisible} %No transparent layers

\usepackage{tikz}
\usepackage{pdfrender}

\title{My Presentation}
\author[My short name]{\bfseries My name}
\institute{University}
\date[19/05/15]{\today}

\begin{document}
{
\frame{ % This is the title slide where I'd like to highlight the sections
\frametitle{}
\setbeamertemplate{footline}{}
\maketitle
}
}

\section{First section}
{
\setbeamertemplate{footline}{}
\frame{
\begin{tikzpicture}[remember picture,overlay]
\fill[blue]
([yshift=0pt]current page.west) rectangle (current page.north east);
\node[anchor=center]
at ([yshift=10pt,xshift=0pt]current page.center)
{\parbox[t]{\textwidth}{\centering%
\usebeamerfont{author}\textcolor{white}{%
\textpdfrender{
TextRenderingMode=FillStroke,
FillColor=white,
LineWidth=.1ex,
}{\insertsection}}}};
\end{tikzpicture}
}
}
\frame{\frametitle{My Frame Title}}\frame{}

\section{Second section}
{
\setbeamertemplate{footline}{}
\frame{
\begin{tikzpicture}[remember picture,overlay]
\fill[blue]
([yshift=0pt]current page.west) rectangle (current page.north east);
\node[anchor=center]
at ([yshift=10pt,xshift=0pt]current page.center)
{\parbox[t]{\textwidth}{\centering%
\usebeamerfont{author}\textcolor{white}{%
\textpdfrender{
TextRenderingMode=FillStroke,
FillColor=white,
LineWidth=.1ex,
}{\insertsection}}}};
\end{tikzpicture}
}
}
\frame{}\frame{}\frame{}

\section{Third section}
{
\setbeamertemplate{footline}{}
\frame{
\begin{tikzpicture}[remember picture,overlay]
\fill[blue]
([yshift=0pt]current page.west) rectangle (current page.north east);
\node[anchor=center]
at ([yshift=10pt,xshift=0pt]current page.center)
{\parbox[t]{\textwidth}{\centering%
\usebeamerfont{author}\textcolor{white}{%
\textpdfrender{
TextRenderingMode=FillStroke,
FillColor=white,
LineWidth=.1ex,
}{\insertsection}}}};
\end{tikzpicture}
}
}\frame{}\frame{}\frame{}

\section{Conclusion}
\frame{}
\end{document}


Does someone knows how to proceed in this case?

Best, Humberto

In order to not have your rectangle cover the header on your slide, you can add a yshift=-\headheight to your rectangle. The code in the first section would then look like:

\section{First section}
{
\setbeamertemplate{footline}{}
\frame{
\begin{tikzpicture}[remember picture,overlay]
\fill[blue]
([yshift=0pt]current page.west) rectangle ([yshift=-\headheight]current page.north east);
\node[anchor=center]
at ([yshift=10pt,xshift=0pt]current page.center)
{\parbox[t]{\textwidth}{\centering%
\usebeamerfont{author}\textcolor{white}{%
\textpdfrender{
TextRenderingMode=FillStroke,
FillColor=white,
LineWidth=.1ex,
}{\insertsection}}}};
\end{tikzpicture}
}
}


This will shift the top of the rectangle down and uncover the header. This is what I get with that code:

If you want that the rectangle is shown only on section frames, you can use \AtBeginSection command which defines how section frames are defined.

And as your rectangle covers the headline, you can place the rectangle on background which is drawn before headline.

This way you don't have to insert the code for every section page.

In following code, please note that lines from \setbeamertemplate{background} to \end{frame} inside \AtBeginSection command are inserted into a local scope { }. Otherwise the background is used in all frames.

Probably a better solution would be to define a new background with \defbeamertemplate and later on call it with \usebeamertemplate inside \AtBeginSection but I do not know how to do it.

\documentclass{beamer}

% To make the navigation bullets appear
\usepackage{remreset}
\makeatletter
\@removefromreset{subsection}{section}
\makeatother
\setcounter{subsection}{1}

\useoutertheme[subsection=false]{smoothbars}

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

\setbeamercovered{transparent}
\setbeamercovered{invisible} %No transparent layers

\AtBeginSection[]{%
{\setbeamertemplate{background}{
\begin{tikzpicture}[remember picture,overlay]
\fill[blue]
([yshift=0pt]current page.west) rectangle (current page.north east);
\node[anchor=center]
at ([yshift=10pt,xshift=0pt]current page.center)
{\parbox[t]{\textwidth}{\centering%
\usebeamerfont{author}\textcolor{white}{%
\textpdfrender{
TextRenderingMode=FillStroke,
FillColor=white,
LineWidth=.1ex,
}{\insertsection}}}};
\end{tikzpicture}}
\begin{frame}
\end{frame}}
}

\usepackage{tikz}
\usepackage{pdfrender}

\title{My Presentation}
\author[My short name]{\bfseries My name}
\institute{University}
\date[19/05/15]{\today}

\begin{document}
{
\frame{ % This is the title slide where I'd like to highlight the sections
\frametitle{}
\setbeamertemplate{footline}{}
\maketitle
}
}

\section{First section}

\frame{\frametitle{My Frame Title}}
\frame{}\frame{}

\section{Second section}
\frame{}\frame{}\frame{}

\section{Third section}
\frame{}\frame{}\frame{}

\section{Conclusion}
\frame{}
\end{document}


2nd version: with \defbeamertemplate

Now I've understood how to use a \defbeamertemplate. This command serves to define templates and assign them a name for further references.

In previous code, \AtBeginSection could be replaced with:

\defbeamertemplate{background}{blue half}{
\begin{tikzpicture}[remember picture,overlay]
\fill[blue]
([yshift=0pt]current page.west) rectangle (current page.north east);
\node[anchor=center]
at ([yshift=10pt,xshift=0pt]current page.center)
{\parbox[t]{\textwidth}{\centering%
\usebeamerfont{author}\textcolor{white}{%
\textpdfrender{
TextRenderingMode=FillStroke,
FillColor=white,
LineWidth=.1ex,
}{\insertsection}}}};
\end{tikzpicture}}

\AtBeginSection[]{%
{\setbeamertemplate{background}[blue half]
\begin{frame}
\end{frame}

where, \defbeamertemplate{background}{blue half}{...} defines a template for backgorund called blue half which is later on used in \AtBeginSection with \setbeamertemplate{background}[blue half]. Please, note [] for introducing name and that the change is locally applied with {...} help.