# How can I automatically have a frametitle on my agenda page in beamer?

Rephrased

I am still struggling with beamer. What I want to achieve is, that the agenda page automatically has the table of contents and writes Agenda at the exact same location as the section would be written, but without explicitly writing \section* or defining and empty {~} frametitle or similar.

This is my MWE:

\documentclass{beamer}

\defbeamertemplate*{frametitle}{regular}{%
\edef\agendatoken{!!!AGENDA!!!}%
\ifx\insertframetitle\agendatoken
Agenda%
\else
\insertsection\ \textbf{\insertframetitle}%
\fi}

\newcommand{\agendapage}{\frametitle{!!!AGENDA!!!}\tableofcontents}

\begin{document}
\begin{frame}
\agendapage
\end{frame}

\section{Section 1}
\begin{frame}
\frametitle{A frame}
This is a frame
\end{frame}

\section{Section 2}
\begin{frame}
\frametitle{And yet another page}
This is yet another frame
\end{frame}
\end{document}


And this is the visual result I want to achieve for the agenda page:

But it seems my string comparison between \insertframetitle and \agendatoken is going wrong. Can you help me fixing the comparison, so that with a special frametitle I achieve my desired behaviour?

## 1 Answer

I found a solution to my issue, which is not perfect, but should work well enough. Here is the code:

\documentclass{beamer}

\makeatletter
\defbeamertemplate*{frametitle}{regular}{%
\def\agendatoken{@special-frametitle-agenda}%
\ifx\agendatoken\beamer@shortframetitle
Agenda%
\else
\insertsection\ \textbf{\insertframetitle}%
\fi}
\newcommand{\agendapage}{\frametitle{@special-frametitle-agenda}\tableofcontents}
\makeatother

\begin{document}
\begin{frame}
\agendapage
\end{frame}

\section{Section 1}
\begin{frame}
\frametitle{A frame}
This is a frame

\end{frame}

\section{Section 2}
\begin{frame}
\frametitle{And yet another page}
This is yet another frame
\end{frame}
\end{document}


So the trick is basically to compare to \beamer@shortframetitle or \beamer@frametitle (safest would probably to check they are equal) instead of \insertframetitle, because there is more in there, then we can see, while \beamer@shortframetitle is only the text. Then our comparison works, too!