% $Header: /cvsroot/latex-beamer/latex-beamer/doc/beamerug-elements.tex,v 1.11 2004/11/01 16:18:44 tantau Exp $

% Copyright 2003, 2004 by Till Tantau <tantau@users.sourceforge.net>.
%
% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 2.


\section{Inner Themes, Outer Themes, and Templates}

\label{section-elements}

This section discusses the inner and outer themes that are
available in \beamer. These themes install certain \emph{templates}
for the different elements of a presentation. The template mechanism is 
explained at the end of the section.

Before we plunge into the details, let us agree on some terminology
for this section. In \beamer, an \emph{element} is part of a
presentation that is potentially typeset in some special way. Examples
of elements are frame titles, the author's name, or the footnote
sign. The appearance of every element is governed by a \emph{template}
for this element. Appropriate templates are installed by inner and
outer themes, where the \emph{inner} themes only install templates for
elements that are typically ``inside the main text,'' while \emph{outer}
themes install templates for elements ``around the main text.'' Thus,
from the templates's point of view, there is no real difference
between inner and outer themes. 



\subsection{Inner Themes}

An inner theme installs templates that dictate how the following
elements are typeset:
\begin{itemize}
\item Title and part pages.
\item Itemize environments.
\item Enumerate environments.
\item Description environments.
\item Block environments.
\item Theorem and proof environments.
\item Figures and tables.
\item Footnotes.
\item Bibliography entries.
\end{itemize}


In the following examples, the color themes |seahorse| and |rose| are
used to show where and how background colors are
honoured. Furthermore, background colors have been specified for all
elements that honour them in the default theme. In the default color
theme, all of the large rectangular areas are transparent.

\begin{innerthemeexample}{default}
  The default element theme is quite sober. The only extravagance is
  the fact that a little triangle is used in |itemize| environments
  instead of the usual dot.

  In some cases the theme will honour background color specifications
  for elements. For example, if you set the background color for block
  titles to green, block titles will have a green background. The
  background specifications are currently honoured for the following
  elements: 
  \begin{itemize}
  \item Title, author, institute, and date fields in the title
    page.
  \item Block environments, both for the title and for the body.
  \end{itemize}
  This list may increase in the future.
\end{innerthemeexample}

\begin{innerthemeexample}{circles}
  In this theme, |itemize| and |enumerate| items start with a small
  circle. Likewise, entries in the table of contents start with
  circles. 
\end{innerthemeexample}

\begin{innerthemeexample}{rectangles}
  In this theme, |itemize| and |enumerate| items and table of contents
  entries  start with small rectangles. 
\end{innerthemeexample}

\begin{innerthemeexample}[\oarg{options}]{rounded}
  In this theme, |itemize| and |enumerate| items and table of contents
  entries start with small balls. If a background is specified for
  blocks, then the corners of the background rectangles will be
  rounded off. The following \meta{options} may be given:

  \begin{itemize}
  \item \declare{|shadow|} adds a shadow to all blocks.
  \end{itemize}
\end{innerthemeexample}

\begin{innerthemeexample}{inmargin}
  The idea behind this theme is to have ``structuring'' information on
  the left and ``normal'' information on the right. To this end,
  blocks are redefined such that the block title is shown on the left
  and the block body is shown on the right.

  The code used to place text in the margin is a bit fragile. You may
  often need to adjust the spacing ``by hand,'' so use at your own risk.

  Itemize items are redefined such that they appear on the
  left. However, only the position is changed by changing some spacing
  parameters; the code used to draw the items is not changed
  otherwise. Because of this, you can load another inner theme first
  and then load this theme afterwards. 
  
  This theme is a ``dirty'' an inner theme since it messes with things
  that an inner theme should not mess with. In particular, it changes
  the width of the left sidebar to a large value. However, you can
  still use it together with most outer themes.

  Using columns inside this theme is problematic. Most of the time,
  the result will not be what you expect.
\end{innerthemeexample}




\subsection{Outer Themes}

An outer theme dictates (roughly) the overall layout of frames. It
specifies where any navigational elements should go (like a mini table
of contents or navigational mini frames) and what they should look
like. Typically, an outer theme specifies how the following elements
are rendered: 
\begin{itemize}
\item The head- and footline.
\item The sidebars.
\item The logo.
\item The frame title.  
\end{itemize}

An outer theme will not specify how things like |itemize| environments
should be rendered---that is the job of an inner theme.

In the following examples the color theme |seahorse| is
used. Since the default color theme leaves most backgrounds empty,
most of the outer themes look too unstructured with the default
color theme. 


\begin{outerthemeexample}{default}
  The default layout theme is the most sober and minimalistic theme
  around. It will flush left the frame title and it will not install
  any head- or footlines. However, even this theme honours the
  background color specified for the frame title. If a color is
  specified, a bar occupying the whole page width is put behind the
  frame title. A background color of the frame subtitle is ignored.
\end{outerthemeexample}

\begin{outerthemeexample}{infolines}
  This theme installs a headline showing the current section and the
  current subsection. It installs a footline showing the author's
  name, the institution, the presentation's title, the current date,
  and a frame count. This theme uses only little space.

  The colors used in the headline and footline are drawn from
  |palette primary|, |palette secondary|, and |primary tertiary| (see
  Section~\ref{section-colors} for details on how to change these).
\end{outerthemeexample}

\begin{outerthemeexample}[\oarg{options}]{miniframes}
  This theme installs a headline in which a horizontal navigational
  bar is shown. This bar contains one entry for each section of the
  presentation. Below each section entry, small circles are shown that
  represent the different frames in the section. The frames are
  arranged subsection-wise, that is, there is a line of frames for
  each subsection. If the class  option |compress| is given, the
  frames will instead be arranged in a single row for each
  section. The navigation bars draws its color from
  |section in head/foot|.

  Below the navigation bar, a line is put showing the title of the
  current subsection. The color is drawn from |subsection in head/foot|.

  At the bottom, two lines are put that contain information such as
  the author's name, the institution, or the paper's title. What is
  shown exactly is influenced by the \meta{options} given. The colors
  are drawn from the appropriate \beamer-colors like
  |author in head/foot|.

  At the top and bottom of both the head- and footline and between the
  navigation bar and the subsection name, separation lines are drawn
  \emph{if} the background color of |separation line| is set. This
  separation line will have a height of 3pt. You can get even more
  fine-grained control over the colors of the separation lines by
  setting appropriate colors like |lower separation line head|.

  The following \meta{options} can be given:
  \begin{itemize}
  \item \declare{|footline=empty|} suppressed the footline (default).
  \item \declare{|footline=authorinstitute|} shows the author's name
    and the institute in the footline.
  \item \declare{|footline=authortitle|} shows the author's name
    and the title in the footline.
  \item \declare{|footline=institutetitle|} shows the institute
    and the title in the footline.
  \item \declare{|footline=authorinstitutetitle|} shows the author's
    name, the institute, and the title in the footline.
  \item \declare{|subsection=|\meta{true or false}} shows or suppresses
    line showing the subsection in the headline. It is shown by
    default.
  \end{itemize}  
\end{outerthemeexample}

\begin{outerthemeexample}[\oarg{options}]{smoothbars}
  This theme behaves very much like the |miniframes| theme, at least
  with respect to the headline. There, the only difference is the
  smooth transitions are installed between the background colors of
  the navigation bar, the (optional) bar for the subsection name, and
  the background of the frame title. No footline is created. You can
  get the footlines of the |miniframes| theme by first loading the
  theme and then loading the |smoothbars| theme.

  The following \meta{options} can be given:
  \begin{itemize}
  \item \declare{|subsection=|\meta{true or false}} shows or suppresses
    line showing the subsection in the headline. It is shown by
    default.
  \end{itemize}  
\end{outerthemeexample}

\begin{outerthemeexample}[\oarg{options}]{sidebar}
  In this layout, a sidebar is shown that contains a small table of
  contents with the current section or subsection hilighted. The
  frame title is vertically centered in a rectangular area at the top
  that always occupies the same amount of space in all
  frames. Finally, the logo is shown in the ``corner'' resulting from
  the sidebar and the frame title rectangle.

  There are several ways of modifying the layout using the
  \meta{options}. If you set the width of the sidebar to 0pt, it is
  not shown, giving you a layout in which the frame title does not
  ``wobble'' since it always occupies the same amount of space on all
  slides. Conversely, if you set the height of the frame title
  rectangle to 0pt, the rectangular area is not used and the frame
  title is inserted normally (occupying as much space as needed on
  each slide).

  The background color of the sidebar is taken from |sidebar|, the
  background color of the frame title from |frametitle|, and the
  background color of the logo corner from |logo|.

  The colors of the entries in the table of contents are drawn from
  the \beamer-color |section in sidebar| and |section in sidebar current| as well as the
  corresponding \beamer-colors for subsections. If an entry does not
  fit on a single line it is automatically ``linebroken.'' 

  The following \meta{options} may be given:
  \begin{itemize}
  \item
    \declare{|height=|\meta{dimension}} specifies the height of the
    frame title rectangle. If it is set to 0pt, no frame title
    rectangle is created. Instead, the frame title is inserted
    normally into the frame. The default is 2.5 base line heights of
    the frame title font. Thus, there is about enough space for a
    two-line frame title plus a one-line subtitle.
  \item
    \declare{|hideothersubsections|} causes all subsections except
    those of the current section to be suppressed in the table of
    contents. This is useful if you have lots of subsections.
  \item
    \declare{|hideallsubsections|} causes all subsections to be
    suppressed in the table of contents.
  \item
    \declare{|left|} puts the sidebar on the left side. Note that in a
    left-to-right reading culture this is the side people look first. Note
    also that this table of contents is usually \emph{not} the most
    important part of the frame, so you do not necessarily want people
    to look at it first. Nevertheless, it is the default.
  \item
    \declare{|right|} puts the sidebar of the right side.
  \item
    \declare{|width=|\meta{dimension}} specifies the width of the
    sidebar. If it is set to 0pt, it is completely suppressed. The
    default is 2.5 base line heights of the frame title font.
  \end{itemize}
\end{outerthemeexample}

\begin{outerthemeexample}{split}
  This theme installs a headline in which, on the left, the sections
  of the talk are shown and, on the right, the subsections of the
  current section. If the class option |compress| has been given,
  the sections and subsections will be put in one line; normally there
  is one line per section or subsection.

  The footline shows the author on the left and the talk's title on
  the right.

  The colors are taken from |palette primary| and |palette fourth|.
\end{outerthemeexample}

\begin{outerthemeexample}{shadow}
  This layout theme extends the |split| theme by putting a horizontal
  shading behind the frame title and adding a little ``shadow'' at the
  bottom of the headline.
\end{outerthemeexample}

\begin{outerthemeexample}[\oarg{options}]{tree}
  In this layout, the headline contains three lines that show the
  title of the current talk, the current section in this talk, and the
  current subsection in the section. The colors are drawn from
  |title in head/foot|, |section in head/foot|, and
  |subsection in head/foot|.

  In addition, separation lines of height 3pt are shown above and
  below the three lines \emph{if} the background of |separation line|
  is set. More fine-grained control of the colors of these lines can
  be gained by setting |upper separation line head| and
  |lower separation line head|.

  The following \meta{options} may be given:
  \begin{itemize}
  \item
    \declare{|hooks|} causes little ``hooks'' to be drawn in front of
    the section and subsection entries. These are supposed to increase
    the tree-like appearance. 
  \end{itemize}
\end{outerthemeexample}

\begin{outerthemeexample}{smoothtree}
  This layout is similar to the |tree| layout. The main difference is
  that the background colors change smoothly.
\end{outerthemeexample}





\subsection{Changing the Templates Used for Different Elements of a Presentation}

\label{section-templates}

This section explains how \beamer's template management works.



\subsubsection{Overview of Beamer's Template Management}

If you only wish to modify the appearance of a single or few elements,
you do not need to create a whole new inner or outer theme. Instead,
you can modify the appropriate template. 

A template specifies how an element of a presentation is typeset. For 
example, the |frametitle| template dictates where the frame title is
put, which font is used, and so on.

As the name suggests, you specify a template by writing the exact
\LaTeX\ code you would also use when typesetting a single frame title
by hand. Only, instead of the actual title, you use the command
|\insertframetitle|.

\example
Suppose we would like to have the frame title typeset in
red, centered, and boldface. If we were to typeset a single frame
title by hand, it might be done like this:
\begin{verbatim}
\begin{frame}
  \begin{centering}
    \color{red}
    \textbf{The Title of This Frame.}
    \par
  \end{centering}

  Blah, blah.
\end{frame}
\end{verbatim}

In order to typeset the frame title in this way on all slides, in the
simplest case we can change the frame title template as follows:
\begin{verbatim}
\setbeamertemplate{frametitle}
{
  \begin{centering}
    \color{red}
    \textbf{\insertframetitle}
    \par
  \end{centering}
}
\end{verbatim}

We can then use the following code to get the desired effect:
\begin{verbatim}
\begin{frame}
  \frametitle{The Title of This Frame.}

  Blah, blah.
\end{frame}
\end{verbatim}
When rendering the frame, \beamer\ will use the code of the
frame title template to typeset the frame title and it will replace
every occurrence of |\insertframetitle| by the current frame
title.

We can take this example a step further. It would be nicer if we did
not have to ``hardwire'' the color of the frametitle, but if this
color could be specified independently of the code for the
template. This way, a color theme could change this color. Since this
a problem that is common to most templates, \beamer\ will
automatically setup the \beamer-color |frametitle| when the template
|frametitle| is used. Thus, we can remove the |\color{red}| command if
we set the \beamer-color |frametitle| to red at some point.
\begin{verbatim}
\setbeamercolor{frametitle}{fg=red}
\setbeamertemplate{frametitle}
{
  \begin{centering}
    \textbf{\insertframetitle}
    \par
  \end{centering}
}
\end{verbatim}
Next, we can also make the font ``themable.'' Just like the color, the
\beamer-font |frametitle| is installed before the |frametitle|
template is typeset. Thus, we should rewrite the code as follows:
\begin{verbatim}
\setbeamercolor{frametitle}{fg=red}
\setbeamerfont{frametitle}{series=\bfseries}
\setbeamertemplate{frametitle}
{
  \begin{centering}
    \insertframetitle\par
  \end{centering}
}
\end{verbatim}
Users, themes, or whoever can now easily change the color or font of
the frametitle without having to mess with the code used to typeset
it.

\articlenote
In |article| mode, most of the template mechanism is switched off and
has no effect. However, a few templates are also available. If this is
the case, it is specially indicated.
\smallskip

Here are a few hints that might be helpful when you wish to set a
template: 
\begin{itemize}
\item
  Usually, you might wish to copy code from an existing template. The
  code often takes care of some things that you may not yet have
  thought about. The default inner and outer themes might be useful 
  starting points. Also, the file |beamerbaseauxtemplates.sty|
  contains interesting ``auxilliary'' templates.
\item
  When copying code from another template and when inserting this code
  in the preamble of your document (not in another style file), you may
  have to ``switch on'' the at-character (|@|). To do so, add the
  command |\makeatletter| before the |\setbeamertemplate| command and the
  command |\makeatother| afterward.
\item
  Most templates having to do with the frame components (headlines,
  sidebars, etc.)\ can only be changed in the preamble. Other
  templates can be changed during the document.
\item
  The height of the headline and footline templates is calculated
  automatically. This is done by typesetting the templates and then
  ``having a look'' at their heights. This recalculation is done right
  at the beginning of the document, \emph{after} all packages have
  been loaded and even \emph{after} these have executed their
  |\AtBeginDocument| initialization. 
\item
  Getting the boxes right inside any template is often a bit of a
  hassle. You may wish to consult the \TeX\ book for the glorious
  details on ``Making Boxes.'' If your headline is simple, you might
  also try putting everything into a |pgfpicture| environment, which
  makes the placement easier.
\end{itemize}




\subsubsection{Using Beamer's Templates}

As a user of the \beamer\ class you typically do not ``use'' or
``invoke'' templates yourself, directly. For example, the frame title
template is automatically invoked by \beamer\ somewhere deep inside
the frame typesetting process. The same is true of most other
templates. However, if, for whatever reason, you wish to invoke a
template yourself, you can use the following command.

\begin{command}{\usebeamertemplate\opt{|***|}\marg{element name}}
  If none of the stars is given, the text of the \meta{element name}
  is directly inserted at the current position. This text should
  previously have been specified using the |\setbeamertemplate|
  command. No text is inserted if this command has not been called
  before.
  \example
\begin{verbatim}
\setbeamertemplate{my template}{correct}
...
Your answer is \usebeamertemplate{my template}.
\end{verbatim}

  If you add one star, three things happen. First, the template is put
  inside a \TeX-group, thereby limiting most side effects of commands
  used inside the template. Second, inside this group the
  \beamer-color named \meta{element name} is used and the foreground
  color is selected. Third, the \beamer-font \meta{element name} is
  also used. This one-starred version is usually the best version to
  use.

  If you add a second star, nearly the same happens as with only one
  star. However, in addition, the color is used with the command
  |\setbeamercolor*|. This causes the colors to be reset to the normal
  text color if no special foreground or background is specified by
  the \beamer-color \meta{element name}. Thus, in this twice-starred
  version, the color used for the template is guaranteed to be
  independent of the color that was currently in use when the template
  is used.

  Finally, adding a third star will also cause a star to be added to
  the |\setbeamerfont*| command. This causes the font used for the
  template also to be reset to normal text, unless the \beamer-font
  \meta{element name} specifies things differently. This three-star
  version is the ``most protected'' version available.
\end{command}

\begin{command}{\ifbeamertemplateempty\marg{beamer template
      name}\marg{executed if empty}\marg{executed otherwise}}
  This command checks whether a template is defined and set to a    
  non-empty text. If the text is empty or the template is not
  defined at all, \meta{executed if empty} is executed. Otherwise,
  \meta{executed otherwise} is executed. 
\end{command}

\begin{command}{\expandbeamertemplate\marg{beamer template name}}
  This command does the same as |\usebeamertemplate|\marg{beamer
    template name}. The difference is that this command performs a
  direct expansion and does not scan for a star. This is important
  inside, for example, an |\edef|. If you don't know the difference
  between |\def| and |\edef|, you won't need this command.
\end{command}

\subsubsection{Setting Beamer's Templates}

To set  a \beamer-template, you can use the following command:

\begin{command}{\setbeamertemplate\marg{element name}\oarg{predefined option}\meta{args}}
  In the simplest case, if no \meta{predefined option} is given, the
  \meta{args} must be a single argument and the text of the template
  \meta{element name} is setup to be this text. Upon later invocation
  of the template by the command |\usebeamertemplate| this text is
  used. 

  \example
\begin{verbatim}
\setbeamertemplate{answer}{correct}
...
Your answer is \usebeamertemplate*{answer}.
\end{verbatim}

  If you specify a \meta{predefined option}, this command behaves
  slightly differently. In this case, someone has used the command
  |\defbeamertemplate| to predefined a template for you. By giving the
  name of this predefined template as the optional parameter
  \meta{predefined option}, you cause the template \meta{element name}
  to be set to this template.

  \example |\setbeamertemplate{bibliography item}[book]| causes the
  bibliography items to become little book icons. This command cause a
  subsequent call of |\usebeamertemplate{bibliography item}| to insert
  the predefined code for inserting a book.

  Some predefined template options take parameters themselves. In such
  a case, the parameters are given as \meta{args}.

  \example
  The \meta{predefined option} |grid| for the template |background|
  takes an optional argument:
\begin{verbatim}
\setbeamertemplate{background}[grid][step=1cm]
\end{verbatim}
  In the example, the second argument in square brackets is the
  optional argument.

  In the descriptions of elements, if there are possible
  \meta{predefined option}, the description shows how the
  \meta{predefined option} can be used together with its arguments,
  but the |\setbeamertemplate{xxxx}| is omitted. Thus, the above
  example would be documented in the description of the |background|
  element like this:
  \begin{itemize}
    \itemoption{grid}{\oarg{step options}} causes a light grid to be
    \dots
  \end{itemize}
\end{command}

\begin{command}{\addtobeamertemplate\marg{element
      name}\marg{pre-text}\marg{post-text}}
  This command adds the \meta{pre-text} before the text that is
  currently installed as the template \meta{element name} and the
  \meta{post-text} after it. This allows you a limited form of
  modification of existing templates.

  \example The following commands have the same effect:
\begin{verbatim}
\setbeamertemplate{my template}{Hello world!}

\setbeamertemplate{my template}{world}
\addtobeamertemplate{my template}{Hello }{!}
\end{verbatim}

  If a new template is installed, any additions will be deleted. On
  the other hand, you can repeatedly use this command to add multiple
  things. 
\end{command}

\begin{command}{\defbeamertemplate\sarg{mode specification}\opt{|*|}%
    \marg{element name}\marg{predefined option}\\
    \oarg{argument number}\oarg{default optional argument}\marg{predefined
      text}\\
    \opt{|[action]|\marg{action command}}}
  This command installs a \emph{predefined option} for the template
  \meta{element name}. Once this command has been used, users can
  access the predefined template using the |\setbeamertemplate|
  command.

  \example
  |\defbeamertemplate{itemize item}{double arrow}{$\Rightarrow$}|

  After the above command has been invoked, the following two commands
  will have the same effect:
\begin{verbatim}
\setbeamertemplate{itemize item}{$\Rightarrow$}
\setbeamertemplate{itemize item}[double arrow]
\end{verbatim}

  Sometimes, a predefined template needs to get an argument when it is
  installed. Suppose, for example, we want to define a predefined
  template that draws a square as the itemize item and we want to make
  this size of this square configurable. In this case, we can specify
  the \meta{argument number} of the predefined option the same way one
  does for the |\newcommand| command:

\begin{verbatim}
\defbeamertemplate{itemize item}{square}[1]{\hrule width #1 height #1}

%% The following have the same effect:
\setbeamertemplate{itemize item}[square]{3pt}
\setbeamertemplate{itemize item}{\hrule width 3pt height 3pt}
\end{verbatim}

  As for the |\newcommand| command, you can also specify a
  \meta{default optional argument}:
  
\begin{verbatim}
\defbeamertemplate{itemize item}{square}[1][1ex]{\hrule width #1 height #1}

%% The following have the same effect:
\setbeamertemplate{itemize item}[square][3pt]
\setbeamertemplate{itemize item}{\hrule width 3pt height 3pt}

%% So do the following:
\setbeamertemplate{itemize item}[square]
\setbeamertemplate{itemize item}{\hrule width 1ex height 1ex}
\end{verbatim}

  The starred version of the command installs the predefined template
  option, but then immediately calls |\setbeamertemplate| for this
  option. This is useful for the default templates. If there are any
  arguments necessary, these are set to |\relax|.

  In certain cases, if a predefined template option is chosen, you do
  not only wish the template text to be installed, but certain extra
  ``actions'' must also be taken once. For example, a shading must be
  defined that should not be redefined every time the shading is used
  later on. To implement such ``actions,'' you can use the optional
  argument \meta{action} following the keyword |[action]|. Thus, after
  the normal use of the |\defbeamertemplate| you add the text
  |[action]| and then any commands that should be executed once when
  the \meta{predefined option} is selected by the |\setbeamertemplate|
  command.

  \example
\begin{verbatim}
\defbeamertemplate{background canvas}{my shading}[2]
{
  \pgfuseshading{myshading}% simple enough
}
[action]
{
  \pgfdeclareverticalshading{myshading}{\the\paperwidth}
  {color(0cm)=(#1); color(\the\paperheight)=(#2)}
}
...

\setbeamertemplate{background canvas}{myshading}{red!10}{blue!10}
%% Defines the shading myshading right here. Subsequent calls to
%% \usebeamertemplate{background canvas} will yield
%% ``\pgfuseshading{myshading}''.
\end{verbatim}
      
  \articlenote
  Normally, this command has no effect in |article| mode. However, if
  a \meta{mode specification} is given, this command is applied for
  the specified modes. Thus, this command behaves like the |\\|
  command, which also gets the implicit mode specification
  |<presentation>| if no other specification is given.

  \example |\defbeamertemplate{my template}{default}{something}| has no effect
  in |article| mode.

  \example |\defbeamertemplate<article>{my template}{default}{something}| has
  no effect in |presentation| modes, but has an effect in |article|
  mode.

  \example |\defbeamertemplate<all>{my template}{default}{something}| applies
  to all modes.  
\end{command}

It is often useful to have access to the same template option via
different names. For this, you can use the following command to create
aliases:
\begin{command}{\defbeamertemplatealias\marg{element name}\marg{new
      predefined option name}\marg{existing predefined option  name}}
  Causes the two predefined options to have the same effect.  
\end{command}

There is no inheritance relation among templates as there is for
colors and fonts. This is due to the fact the templates for one
element seldom make sense for another. However, sometimes certain
elements ``behave similarly'' and one would like a
|\setbeamertemplate| to apply to a whole set of templates via
inheritance. For example, one might want that
|\setbeamertemplate{items}[circle]| causes all items to use the
|circle| option, though the effects for the |itemize item| as opposed
to the |itemize subsubitem| as opposed to |enumerate item| must be
slightly different.

The \beamer-template mechanism implements a simple form of inheritance
via \emph{parent templates}. In element descriptions, parent templates
are indicated via a check mark in parentheses.

\begin{command}{\defbeamertemplateparent\marg{parent template
name}\oarg{predefined option name}\marg{child template
list}\\
\oarg{argument number}\oarg{default optional
argument}\marg{arguments for children}}
  The effect of this command is that whenever someone calls
  |\setbeamertemplate{|\meta{parent template name}|}{|\meta{args}|}|,
  the command |\setbeamertemplate{|\meta{child template
      name}|}{|\meta{args}|}| is called for each \meta{child
    template name} in the \meta{child template list}.

  The \meta{arguments for children} come into play if the
  |\setbeamertemplate| command is called with a predefined option name
  (not necessarily the same as the \meta{predefined option name},
  we'll come to that). If |\setbeamertemplate| is called with some
  predefined option name, the children are called with the
  \meta{arguments for children} instead. Let's look at two examples:
  
  \example The following is the typical, simple usage:
\begin{verbatim}
\defbeamertemplateparent{itemize items}{itemize item,itemize subitem,itemize subsubitem}
{}

%% The following command has the same effect as the three commands below:
\setbeamertemplate{itemize items}[circle]

\setbeamertemplate{itemite item}[circle] % actually, the ``empty'' argument is added
\setbeamertemplate{itemize subitem}[circle]
\setbeamertemplate{itemize subsubitem}[circle]
\end{verbatim}

  \example In the following case, an argument is passed to the
  children:
\begin{verbatim}
\defbeamertemplateparent{sections/subsections in toc shaded}
{section in toc shaded,subsection in toc shaded}[1][20]
{[#1]}

%% The following command has the same effect as the two commands below:
\setbeamertemplate{sections/subsection in toc shaded}[default][35]

\setbeamertemplate{section in toc shaded}[default][35]
\setbeamertemplate{subsection in toc shaded}[default][35]


%% Again:
\setbeamertemplate{sections/subsection in toc shaded}[default]

\setbeamertemplate{section in toc shaded}[default][20]
\setbeamertemplate{subsection in toc shaded}[default][20]
\end{verbatim}

  In detail, the following happens: When |\setbeamertemplate| is
  encountered for a parent template, \beamer\ first checks whether a
  predefined option follows. If not, a single argument is read and
  |\setbeamertemplate| is called for all children for this
  template. If there is a predefined template option set, \beamer\
  evaluates the \meta{argument for children}. It may contain
  parameters like |#1| or |#2|. These parameters are filled with the
  arguments that follow the call of |\setbeamertemplate| for the
  parent template. The number of arguments must be the number given
  as \meta{argument number}. An optional argument can also be
  specified in the usual way. Once the \meta{arguments for the
  children} have been computed, |\setbeamertemplate| is called for all
  children for the predefined template and with the computed
  arguments.

  You may wonder what happens when certain predefined options take a
  certain number of arguments, but another predefined option takes a
  different number of arguments. In this case, the above-described
  mechanism cannot differentiate between the predefined options and it
  is unclear which or even how many arguments should be contained in
  \meta{arguments for children}. For this reason, you can give the
  optional argument \meta{predefined option name} when calling
  |\defbeamertemplateparent|. If this optional argument is specified,
  the parenthood of the template applies only to this particular
  \meta{predefined option name}. Thus, if someone calls
  |\setbeamertemplate| for this \meta{predefined option name}, the
  given \meta{argument for children} is used. For other predefined
  option names a possibly different definition is used. You can
  imaging that leaving out the optional \meta{predefined option name}
  means ``this \meta{argument for children} applies to all predefined
  option names that have not been specially defined differently.''     
\end{command}





%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "beameruserguide"
%%% End: 
