[Tex/LaTex] Beamer template: Command already defined

beamer

I found a beamer template I want to use. However, it compiles with

! LaTeX Error: Command \beamer@@tmpop@section page@default already defined.
Or name \end… illegal, see p.192 of the manual.

The error may reside somewhere below. Can you find it?

\usecolortheme{crane}

\setbeamerfont{section title}{parent=title}
\setbeamercolor{section title}{parent=titlelike}
\defbeamertemplate*{section page}{default}[1][]
{
\centering
\begin{beamercolorbox}[sep=8pt,center,#1]{section title}
\usebeamerfont{section title}\insertsection\par
\end{beamercolorbox}
}
\newcommand*{\sectionpage}{\usebeamertemplate*{section page}}

\newcommand{\comment}[1]{}

%include polycode.fmt

\begin{document}
\title{Practical introduction to Agda}

EDIT: There's a witness that the template might work

Best Answer

Some of the code added by the template does nowt except causing errors so far as I can tell. Other parts do try to do something, but not in the right way. This means they cause errors and potentially make no difference, depending on what TeX does in response to the errors.

Let's see what it does...

\setbeamerfont{section title}{parent=title}

What is the default?

\setbeamerfont{section title}{size=\Large,parent=title}

OK. So this sets the section title in the same size font as the title of the presentation, rather than switching to \Large. This is OK if you want this.

\setbeamercolor{section title}{parent=titlelike}

What's the default?

\setbeamercolor{section title}{parent=titlelike}

So the code from the template does nothing. It is, however, harmless. It is just pointless.

\defbeamertemplate*{section page}{default}[1][]
{
\centering
\begin{beamercolorbox}[sep=8pt,center,#1]{section title}
\usebeamerfont{section title}\insertsection\par
\end{beamercolorbox}
}

What's the default?

\defbeamertemplate*{section page}{default}[1][]
{
  \begingroup
    \centering
    {\usebeamerfont{section name}\usebeamercolor[fg]{section name}\sectionname~\insertsectionnumber}
    \vskip1em\par
    \begin{beamercolorbox}[sep=12pt,center,#1]{part title}
      \usebeamerfont{section title}\insertsection\par
    \end{beamercolorbox}
  \endgroup
}

So the template omits any title defined by \part{}, if there is one, reduces the separation and eliminates the Section <Number> from above the section title. So this tries to do something. However, it does it in the wrong way and causes errors. Moreover, the errors mean that Beamer at least partially ignores the changes it tries to implement:

failed customisation

If you want these changes, do it effectively and avoid the errors:

\defbeamertemplate*{section page}{mine}[1][]
{
\centering
\begin{beamercolorbox}[sep=8pt,center,#1]{section title}
\usebeamerfont{section title}\insertsection\par
\end{beamercolorbox}
}
\usebeamertemplate{mine}

effective customisation

But do note that the template makes no attempt to alter the subsection title pages:

uncustomised page

So your presentation will be somewhat inconsistently formatted - perhaps that's part of the design.

\newcommand*{\sectionpage}{\usebeamertemplate*{section page}}

Here's the default:

\def\sectionpage{\usebeamertemplate*{section page}}

So, this code creates a new command with the same name as an existing command, which doesn't work as it causes an error, but which would do precisely the same as the original if it did work. Brilliant.

De-templated code:

\documentclass{beamer}
\usecolortheme{crane}
\newcommand{\comment}[1]{}
\begin{document}
  \title{Practical introduction to Agda}
  \begin{frame}
    \titlepage
  \end{frame}
  \section{Cooking without an Arga}
  \begin{frame}
    \sectionpage
  \end{frame}
  \subsection{The gas cooker}
  \begin{frame}
    \subsectionpage
  \end{frame}
\end{document}

De-templated output:

Agda & Arga

Corrected templated code:

\setbeamerfont{section title}{parent=title}
\defbeamertemplate*{section page}{mine}[1][]
{
\centering
\begin{beamercolorbox}[sep=8pt,center,#1]{section title}
\usebeamerfont{section title}\insertsection\par
\end{beamercolorbox}
}
\usebeamertemplate{mine}
\newcommand{\comment}[1]{}

Corrected (technically - not aesthetically) templated output:

inconsistency as design