beamer add tag
TobiBS (imported from SE)
So while designing a beamer theme, I came across the neat solution to select page specific templates through the pagestyle (https://tex.stackexchange.com/questions/317938/theme-with-a-different-footline-for-the-titlepage/323638#323638). While this works for a lot of the templates, it does not work for the `frametitle` template, as you can see in my MWE:

    \documentclass{beamer}
    
    \defbeamertemplate*{frametitle}{regular}{Regular Frametitle}
    \defbeamertemplate{frametitle}{special}{Special Frametitle}
    
    \makeatletter
    \def\ps@navigation@sectionpage{%
    	\setbeamertemplate{headline}{Special Headline}
    	\setbeamertemplate{frametitle}[special]
    	\setbeamertemplate{footline}{Special Footline}
    }
    \makeatother
    
    \begin{document}
    \begin{frame}
    \frametitle{~}
    This page shall have the regular frametitle
    \end{frame}
    
    \begin{frame}
    \frametitle{~}
    This page shall have the special headline, frametitle and footline
    \makeatletter\thispagestyle{navigation@sectionpage}\makeatother
    \end{frame}
    
    \begin{frame}
    \frametitle{~}
    This page shall have the regular frametitle
    \end{frame}
    \end{document}

What I want to achieve is, that the framtitle is different through some sort of automatic for the slide that contains `\tableofcontents` and I therefore wanted to introduce a macro that selects a special page style and then ejects `\tableofcontents`. Maybe this is not the smartest solution, but is there another way to achieve the same behaviour for the `frametitle` as with this pagestyle selection?
Top Answer
samcarter
Changing the frametitle template with the pagestyle trick won't work, because at the time the pagestyle is evaluated it is already too late to change it. You can see the same problem with this simple example:

```
\documentclass{beamer}

\defbeamertemplate*{frametitle}{regular}{Regular Frametitle}
\defbeamertemplate{frametitle}{special}{Special Frametitle}

\begin{document}
\begin{frame}
\frametitle{~}
This page shall have the regular frametitle
\end{frame}

{
\setbeamertemplate{frametitle}[special]
\begin{frame}
\frametitle{~}
This page shall have the special frametitle
\end{frame}
}

{
\begin{frame}
\setbeamertemplate{frametitle}[special]
\frametitle{~}
This page shall have the special frametitle
\end{frame}
}

\begin{frame}
\frametitle{~}
This page shall have the regular frametitle
\end{frame}
\end{document}
```

An alternative approach could be to use a special frame option:

```
\documentclass[aspectratio=169]{beamer}

\defbeamertemplate*{frametitle}{regular}{Regular Frametitle}
\defbeamertemplate{frametitle}{special}{Special Frametitle}
\setbeamertemplate{headline}{}
\setbeamertemplate{footline}{}

\makeatletter
\providebool{specialframe}
\define@key{beamerframe}{special}[true]{
  \booltrue{specialframe}
  \begingroup
  \setbeamertemplate{headline}{Special Headline}
  \setbeamertemplate{frametitle}[special]
  \setbeamertemplate{footline}{Special Footline}
}

\apptocmd{\beamer@reseteecodes}{%
  \ifbool{specialframe}{%
    \endgroup
    \boolfalse{specialframe}
  }{}
}{}{}
\makeatother

\begin{document}

\begin{frame}
\frametitle{~}
This page shall have the regular frametitle
\end{frame}

\begin{frame}[special]
\frametitle{~}
This page shall have the special headline, frametitle and footline
\end{frame}

\begin{frame}
\frametitle{~}
This page shall have the regular frametitle
\end{frame}
\end{document}
```

You could even tie it to the `\tableofcontents` macro:

```
\documentclass[aspectratio=169]{beamer}

\defbeamertemplate*{frametitle}{regular}{Regular Frametitle}
\defbeamertemplate{frametitle}{special}{Special Frametitle}
\setbeamertemplate{headline}{}
\setbeamertemplate{footline}{}

\makeatletter
\providebool{specialframe}
\define@key{beamerframe}{special}[true]{
  \booltrue{specialframe}
  \begingroup
  \setbeamertemplate{headline}{Special Headline}
  \setbeamertemplate{frametitle}[special]
  \setbeamertemplate{footline}{Special Footline}
}

\apptocmd{\beamer@reseteecodes}{%
  \ifbool{specialframe}{%
    \endgroup
    \boolfalse{specialframe}
  }{}
}{}{}

\def\tableofcontents{%
  \begin{frame}[special]
  \@ifnextchar[{\beamer@tableofcontents}{\beamer@tableofcontents[]}
  \end{frame}
}
\makeatother

\begin{document}

\section{section name}

\begin{frame}
\frametitle{~}
This page shall have the regular frametitle
\end{frame}

\tableofcontents

\begin{frame}
\frametitle{~}
This page shall have the regular frametitle
\end{frame}
\end{document}
```

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.