1

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

7
  • Maybe renewcommand would be better than newcommand? But I'm not that sure.
    – sztruks
    Commented Nov 12, 2015 at 21:45
  • It didn't change anything
    – jaam
    Commented Nov 13, 2015 at 23:30
  • Welcome! Please can you complete your code so we can compile it? That is much more helpful than a link to something somewhere else. Note that the code you post should produce precisely the error you are asking about, when we compile it to reproduce the issue.
    – cfr
    Commented Nov 19, 2015 at 0:29
  • Templates are not, generally, of very high quality. This one is no exception. It is loading packages which you probably don't need with options you probably don't want, including options which ought to be avoided generally. It is better to start with beamer and a theme and then customise things as you want, adding the packages you need. You can take from the template stuff which works for you and you use, discarding the non-working and useless-to-you.
    – cfr
    Commented Nov 19, 2015 at 0:45
  • The code you've posted gives errors. It will give errors in the template, too. I don't know what you mean by it 'should' work. It doesn't work. What else matters? The only way to get it to work is to rewrite the broken bits. The PDF you linked doesn't show the code works. The user may compile past the errors and produce output. If I add a frame, completing your code minimally, and ignore the errors, I get PDF output also. It doesn't show the code works. Only that it is not so broken that TeX cannot continue despite the errors.
    – cfr
    Commented Nov 19, 2015 at 0:49

1 Answer 1

5

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

9
  • I substituted \setbeamerfont{section title}{parent=title} ... \renewcommand{\comment}[1]{} in the file with the "Corrected templated code" from your answer, compiled it, and got ! LaTeX Error: Environment code undefined. Also, a pdf wasn't created (this was also the case with the previous error). Now there are a few options: (1) there is another bug in the template, (2) I'm doing something fundamentally wrong. [CONTINUED BELOW]
    – jaam
    Commented Nov 20, 2015 at 0:45
  • [CONTINUED FROM ABOVE] I've an idea about (2). Notice that the file is x.lagda; I compile it by naming it to x.lagda.tex first. However, according to this I should be doing agda --latex <file>.lagda; cd latex; <latex-compiler> <file>.tex. Since I don't have agda installed, I cannot try this but I suppose it wouldn't change anything. However, I may be wrong. I've also a question about your answer, where you say that the defaults are this and that. How do I know what the defaults are, i.e. where are they defined?
    – jaam
    Commented Nov 20, 2015 at 0:46
  • You can't compile it using agda if you don't have agda installed. On the other hand, if your document is really agda source i.e. x.agda is correct, then simply renaming it by adding a .tex extension won't make it compilable with LaTeX. You'd have to change the code. So, if it is actually LaTeX code, name it x.tex. If it is actually Agda code, either change it and rename it x.tex or install agda and compile as instructed. Does the code I posted work for you? I can't say what it might do in an alien environment. Obviously, if you are mixing it with Agda, expect failure.
    – cfr
    Commented Nov 20, 2015 at 1:11
  • @jaam If I do as you say and substitute my code for the relevant part of the code in the file you linked, I no longer get the errors caused by the code you asked about in the question. I do get other errors. Sure. But that's because the document has multiple, serious problems and probably depends on other code you've not input. For example, there's a line in the preamble indicating that a .fmt` file should be included (I guess) but I have no idea what that is about. The Agda page I linked to also explains some relevant points e.g. need to define code environment, additional characters etc.
    – cfr
    Commented Nov 20, 2015 at 1:22
  • If you really need to typeset that document - rather than treating it as a 'template' - email the author and ask for the missing code. Or try to remedy it using the stuff on the Agda page. Otherwise, it doesn't matter what errors the content of the document gives. If you just want it as a 'template' for your own slides, you just need the preamble stuff and then use standard Beamer environments etc. for your document content itself.
    – cfr
    Commented Nov 20, 2015 at 1:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .