# beamer / doc / beamerug-elements.tex

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