# Beamer - Use custom environment on TOC frames

I defined a environment slide based on frame to get rules beneath the headline and above the footer and get the section in the frametitle.

\newenvironment{slide}[1]
{\begin{frame}[environment=slide]
\frametitle{\textbf{\textcolor{black}{\insertsection}}\\#1\\\vspace*{-.38cm}\rule{1.12\textwidth}{0.08ex}}\vspace*{-.5cm}}
{\hfill\hspace*{-.8cm}\vspace*-.8cm}\color{itemizecolor}\rule{1.12\textwidth}{0.08ex}
\end{frame}}


I would now like to use this style on the TOC frames as well. Is there a way to tell latex to use this environment for TOC?

EDIT: On request, here is a MWE:

\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}

\definecolor{itemizecolor}{rgb}{0.18,0.22,0.60}
\newenvironment{slide}[1]
{\begin{frame}[environment=slide]
\frametitle{\textbf{\textcolor{black}{\insertsection}}\\#1\\\vspace*{-.38cm}\rule{1.12\textwidth}{0.08ex}}\vspace*{-.5cm}}
{\vfill\hspace*{-.8cm}\color{itemizecolor}\rule{1.12\textwidth}{0.08ex}
\end{frame}}

\begin{document}

%----------- titlepage ----------------------------------------------%
\begin{frame}[plain]
\titlepage
\end{frame}

%----------- slide --------------------------------------------------%
\begin{frame}{Inhalt}
\tableofcontents
\end{frame}

\section{Section}

\begin{slide}{slide title}
Test
Test

\end{slide}

\end{document}

• Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – samcarter_is_at_topanswers.xyz Dec 5 '15 at 14:38
• Supplied an MWE. – user3696412 Dec 5 '15 at 14:56

Am I missing something or why not simply write

\begin{slide}{Inhalt}
\tableofcontents
\end{slide}


That said, I myself would not define a custom environment as wrapper for a frame, because in my personal experience, this causes more problems than it solves. Why not using beamers own mechanism to modify the frametitle and place a line in the footer?

\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}

\definecolor{itemizecolor}{rgb}{0.18,0.22,0.60}

\setbeamertemplate{frametitle}{%
\textbf{\textcolor{black}{\insertsection}}\\%
\insertframetitle \\%
\vspace*{-.38cm}%
\rule{1.12\textwidth}{0.08ex}%
\vspace*{-.5cm}%
}

\setbeamertemplate{footline}{%
\usebeamercolor[fg]{frametitle}
\hspace{1cm}
\rule{1.12\textwidth}{0.08ex}%
\vspace*{0.2cm}
}

\begin{document}

%----------- titlepage ----------------------------------------------%
\begin{frame}[plain]
\titlepage
\end{frame}

%----------- slide --------------------------------------------------%
\begin{frame}{Inhalt}
\tableofcontents
\end{frame}

\section{Section}

\begin{frame}{slide title}
Test
Test
\end{frame}

\end{document}


• Thanks for the answer. It looks like a good approach to me, but it has stil some problems for me: 1: The header is indented. In my version, the header starts directly at the left, without the extra space. 2: The lines go completly to the right end of the frame. I would like them to have a symmetrical distance on both sides. 3: When I try to add frame numbers, they appear on the left instead of the right, sometimes the line is not plottet at all.... I wasn't able to figure out why exactly what happens. I have figured out a solution based on my attempt and will post it below soon. – user3696412 Dec 7 '15 at 18:08
• Oh and I totally forgot: Thanks for the tip with \begin{slide}{Inhalt} \tableofcontents \end{slide}. That solved my original issue perfectly. – user3696412 Dec 7 '15 at 18:25

Ok, after some time I got it all working, here is a fully worked example:

\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\newcommand{\btVFill}{\vskip0pt plus 1filll} % needed to push line to the bottom of the page

\newenvironment{slide} % wrapper for frame, wrting Section \\ Subsection in the header, adding lines below header and above footer
{\begin{frame}[environment=slide]
\frametitle{\textbf{\textcolor{black}{\insertsection}}\\\insertsubsection\\\vspace*{-.38cm}\rule{1.12\textwidth}{0.08ex}}}
{\btVFill\hspace*{-.8cm}\color{itemizecolor}\rule{1.12\textwidth}{0.08ex}
\end{frame}}

\defbeamertemplate{footline}{myframe number} % moving the frame numbers up a bit, too close to bottom by default
{
\hfill
\raisebox{-0.3cm}[0cm][.5cm]{% <--- change here
}

% some fumbling with the itemize symbols in toc etc., and genereal appereance - not strictly relevant for the problem, but maybe usefull for someone.

\definecolor{itemizecolor}{rgb}{0.18,0.22,0.60}
\defbeamertemplate{section in toc}{square unnumbered}{%
\leavevmode\leftskip=1.75ex%
\llap{{\color{itemizecolor}$\blacksquare$}}%
\kern1.5ex\inserttocsection\par}
\defbeamertemplate{subsection in toc}{square unnumbered}{%
\leavevmode\leftskip=4.6ex%
\llap{{\color{itemizecolor}$\blacksquare$}}%
\kern1.5ex\inserttocsubsection\par}

\usetheme{default}
\setbeamertemplate{enumerate items}[none]
\setbeamertemplate{itemize item}{\color{itemizecolor}$\blacksquare$}
\setbeamertemplate{section in toc}[square unnumbered]
\setbeamertemplate{subsection in toc}[square unnumbered]
\setbeamertemplate{footline}[myframe number]
\setbeamercolor{section in toc}{fg=Black}

% presentation boddy

\title{Interesting Topic}
\author{Ano Nym}

\begin{document}

% modified toc at start of each section
\AtBeginSection[]
{
\subsection*{Overview}
\begin{slide}
\tableofcontents[currentsection,hideothersubsections]
\end{slide}
}

\begin{frame}[plain]
\titlepage
\end{frame}

\subsection*{ }
\begin{slide}
\tableofcontents[subsectionstyle=hide]
\end{slide}

\section{Section1}
\subsection{subsec 1}
\begin{slide}
abc
\end{slide}
\subsection{subsec 2}
\begin{slide}
abc
\end{slide}
\section{Section 2}
\subsection{subsec 1}
\begin{slide}
abc
\end{slide}
\subsection{subsec 2}
\begin{slide}
abc
\end{slide}
\end{document}


Output: