Debian Codegraph @

texmf-dist/doc/latex/beamer/beamerug-elements.tex

raw
1 % !TeX root = beameruserguide.tex
2 % Copyright 2003-2007 by Till Tantau
3 % Copyright 2010 by Vedran Mileti\'c
4 % Copyright 2012,2014,2015 by Vedran Mileti\'c, Joseph Wright
5 % Copyright 2017,2018 by Louis Stuart, Joseph Wright
6 % Copyright 2020-2026 by Joseph Wright, samcarter
7 %
8 % This file may be distributed and/or modified
9 %
10 % 1. under the LaTeX Project Public License and/or
11 % 2. under the GNU Free Documentation License.
12 %
13 % See the file LICENSE.md for more details.
14
15 \section{Inner Themes, Outer Themes, and Templates}
16 \label{section-elements}
17
18 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.
19
20 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' point of view, there is no real difference between inner and outer themes.
21
22
23 \subsection{Inner Themes}
24
25 An inner theme installs templates that dictate how the following elements are typeset:
26 \begin{itemize}
27 \item Title and part pages.
28 \item Itemize environments.
29 \item Enumerate environments.
30 \item Description environments.
31 \item Block environments.
32 \item Theorem and proof environments.
33 \item Figures and tables.
34 \item Footnotes.
35 \item Bibliography entries.
36 \end{itemize}
37
38 In the following examples, the color themes |seahorse| and |rose| are used to show where and how background colors are honored. Furthermore, background colors have been specified for all elements that honor them in the default theme. In the default color theme, all of the large rectangular areas are transparent.
39
40 \begin{innerthemeexample}{default}
41 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.
42
43 In some cases the theme will honor 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 honored for the following elements:
44 \begin{itemize}
45 \item Title, author, institute, and date fields in the title page.
46 \item Block environments, both for the title and for the body.
47 \end{itemize}
48 This list may increase in the future.
49 \end{innerthemeexample}
50
51 \begin{innerthemeexample}{circles}
52 In this theme, |itemize| and |enumerate| items start with a small circle. Likewise, entries in the table of contents start with circles.
53 \end{innerthemeexample}
54
55 \begin{innerthemeexample}{rectangles}
56 In this theme, |itemize| and |enumerate| items and table of contents entries start with small rectangles.
57 \end{innerthemeexample}
58
59 \begin{innerthemeexample}[\oarg{options}]{rounded}
60 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:
61
62 \begin{itemize}
63 \item \declare{|shadow|} adds a shadow to all blocks.
64 \end{itemize}
65 \end{innerthemeexample}
66
67 \begin{innerthemeexample}{inmargin}
68 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.
69
70 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.
71
72 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.
73
74 This theme is a ``dirty'' 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.
75
76 Using columns inside this theme is problematic. Most of the time, the result will not be what you expect.
77
78 The indicators for the title page can be adjusted by redefining |\inserttitleindicator|, |\insertauthorindicator|, |\insertinstituteindicator| and |\insertdateindicator|.
79 \end{innerthemeexample}
80
81
82 \subsection{Outer Themes}
83
84 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:
85 \begin{itemize}
86 \item The head- and footline.
87 \item The sidebars.
88 \item The logo.
89 \item The frame title.
90 \end{itemize}
91
92 An outer theme will not specify how things like |itemize| environments should be rendered---that is the job of an inner theme.
93
94 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.
95
96 \begin{outerthemeexample}{default}
97 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 honors 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.
98 \end{outerthemeexample}
99
100 \begin{outerthemeexample}{infolines}
101 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.
102
103 The colors used in the headline and footline are drawn from |palette primary|, |palette secondary|, and |palette tertiary| (see Section~\ref{section-colors} for details on how to change these).
104 \end{outerthemeexample}
105
106 \begin{outerthemeexample}[\oarg{options}]{miniframes}
107 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|.
108
109 Below the navigation bar, a line is put showing the title of the current subsection. The color is drawn from |subsection in head/foot|.
110
111 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|.
112
113 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|.
114
115 \emph{Note:} Make sure the document is organized in the section-subsection-frame structure when using |miniframes| and |smoothbars| theme. Any frame without a |\section| or |\subsection| will bring unpredictable effects in the navigation bar.
116
117 The following \meta{options} can be given:
118 \begin{itemize}
119 \item \declare{|footline=empty|} suppresses the footline (default).
120 \item \declare{|footline=authorinstitute|} shows the author's name and the institute in the footline.
121 \item \declare{|footline=authortitle|} shows the author's name and the title in the footline.
122 \item \declare{|footline=institutetitle|} shows the institute and the title in the footline.
123 \item \declare{|footline=authorinstitutetitle|} shows the author's name, the institute, and the title in the footline.
124 \item \declare{|subsection=|\meta{true or false}} shows or suppresses line showing the subsection in the headline. It is shown by default. If the document does not use subsections, this option should be set |false|.
125 \end{itemize}
126 \end{outerthemeexample}
127
128 \begin{outerthemeexample}[\oarg{options}]{smoothbars}
129 This theme behaves very much like the |miniframes| theme, at least with respect to the headline. The only differences are that 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 that theme and then loading the |smoothbars| theme.
130
131 The following \meta{options} can be given:
132 \begin{itemize}
133 \item \declare{|subsection=|\meta{true or false}} shows or suppresses line showing the subsection in the headline. It is shown by default.
134 \end{itemize}
135 \end{outerthemeexample}
136
137 \begin{outerthemeexample}[\oarg{options}]{sidebar}
138 In this layout, a sidebar is shown that contains a small table of contents with the current section, subsection, or subsubsection highlighted. 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.
139
140 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).
141
142 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|.
143
144 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.''
145
146 The following \meta{options} may be given:
147 \begin{itemize}
148 \item
149 \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.
150 \item
151 \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.
152 \item
153 \declare{|hideallsubsections|} causes all subsections to be suppressed in the table of contents.
154 \item
155 \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.
156 \item
157 \declare{|right|} puts the sidebar of the right side.
158 \item
159 \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.
160 \end{itemize}
161 \end{outerthemeexample}
162
163 \begin{outerthemeexample}{split}
164 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.
165
166 The footline shows the author on the left and the talk's title on the right.
167
168 The colors are taken from |palette primary| and |palette quaternary|.
169 \end{outerthemeexample}
170
171 \begin{outerthemeexample}{shadow}
172 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.
173 \end{outerthemeexample}
174
175 \begin{outerthemeexample}[\oarg{options}]{tree}
176 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|.
177
178 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|.
179
180 The following \meta{options} may be given:
181 \begin{itemize}
182 \item
183 \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.
184 \end{itemize}
185 \end{outerthemeexample}
186
187 \begin{outerthemeexample}{smoothtree}
188 This layout is similar to the |tree| layout. The main difference is that the background colors change smoothly.
189 \end{outerthemeexample}
190
191
192 \subsection{Changing the Templates Used for Different Elements of a Presentation}
193 \label{section-templates}
194
195 This section explains how \beamer's template management works.
196
197 \subsubsection{Overview of Beamer's Template Management}
198
199 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.
200
201 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.
202
203 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|.
204
205 \example
206 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:
207
208 \begin{verbatim}
209 \begin{frame}
210 \begin{center}
211 \color{red}
212 \textbf{The Title of This Frame.}
213 \end{center}
214
215 Blah, blah.
216 \end{frame}
217 \end{verbatim}
218
219 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:
220
221 \begin{verbatim}
222 \setbeamertemplate{frametitle}
223 {
224 \centering
225 \color{red}
226 \textbf{\insertframetitle}
227 \par
228 }
229 \end{verbatim}
230 We can then use the following code to get the desired effect:
231 \begin{verbatim}
232 \begin{frame}
233 \frametitle{The Title of This Frame.}
234
235 Blah, blah.
236 \end{frame}
237 \end{verbatim}
238
239 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.
240
241 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 is 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.
242
243 \begin{verbatim}
244 \setbeamercolor{frametitle}{fg=red}
245 \setbeamertemplate{frametitle}
246 {
247 \centering
248 \textbf{\insertframetitle}
249 \par
250 }
251 \end{verbatim}
252
253 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:
254
255 \begin{verbatim}
256 \setbeamercolor{frametitle}{fg=red}
257 \setbeamerfont{frametitle}{series=\bfseries}
258 \setbeamertemplate{frametitle}
259 {
260 \centering
261 \insertframetitle\par
262 }
263 \end{verbatim}
264
265 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.
266
267 \articlenote
268 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.
269 \smallskip
270
271 Here are a few hints that might be helpful when you wish to set a template:
272 \begin{itemize}
273 \item
274 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 ``auxiliary'' templates.
275 \item
276 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.
277 \item
278 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.
279 \item
280 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.
281 \item
282 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.
283 \end{itemize}
284
285 \subsubsection{Using Beamer's Templates}
286
287 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.
288
289 \begin{command}{\usebeamertemplate\opt{|***|}\marg{element name}}
290 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.
291 \example
292 \begin{verbatim}
293 \setbeamertemplate{my template}{correct}
294 ...
295 Your answer is \usebeamertemplate{my template}.
296 \end{verbatim}
297
298 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.
299
300 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.
301
302 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.
303 \end{command}
304
305 \begin{command}{\ifbeamertemplateempty\marg{beamer template name}\marg{executed if empty}\marg{executed otherwise}}
306 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.
307 \end{command}
308
309 \begin{command}{\expandbeamertemplate\marg{beamer template name}}
310 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.
311 \end{command}
312
313 \subsubsection{Setting Beamer's Templates}
314
315 To set a \beamer-template, you can use the following command:
316
317 \begin{command}{\setbeamertemplate\marg{element name}\oarg{predefined option}\meta{args}}
318 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.
319
320 \example
321 \begin{verbatim}
322 \setbeamertemplate{answer}{correct}
323 ...
324 Your answer is \usebeamertemplate*{answer}.
325 \end{verbatim}
326
327 If you specify a \meta{predefined option}, this command behaves slightly differently. In this case, someone has used the command |\defbeamertemplate| to predefine 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.
328
329 \example
330 |\setbeamertemplate{bibliography item}[book]| causes the bibliography items to become little book icons. This command causes a subsequent call of |\usebeamertemplate{bibliography item}| to insert the predefined code for inserting a book.
331
332 Some predefined template options take parameters themselves. In such a case, the parameters are given as \meta{args}.
333
334 \example
335 The \meta{predefined option} |grid| for the template |background| takes an optional argument:
336 \begin{verbatim}
337 \setbeamertemplate{background}[grid][step=1cm]
338 \end{verbatim}
339
340 In the example, the second argument in square brackets is the optional argument.
341
342 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:
343 \begin{itemize}
344 \itemoption{grid}{\oarg{step options}} causes a light grid to be \dots
345 \end{itemize}
346 \end{command}
347
348 \begin{command}{\addtobeamertemplate\marg{element name}\marg{pre-text}\marg{post-text}}
349 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.
350
351 \example
352 The following commands have the same effect:
353
354 \begin{verbatim}
355 \setbeamertemplate{my template}{Hello world!}
356
357 \setbeamertemplate{my template}{world}
358 \addtobeamertemplate{my template}{Hello }{!}
359 \end{verbatim}
360
361 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.
362 \end{command}
363
364 \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}}}
365 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.
366
367 \example
368 |\defbeamertemplate{itemize item}{double arrow}{$\Rightarrow$}|
369
370 After the above command has been invoked, the following two commands will have the same effect:
371
372 \begin{verbatim}
373 \setbeamertemplate{itemize item}{$\Rightarrow$}
374 \setbeamertemplate{itemize item}[double arrow]
375 \end{verbatim}
376
377 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:
378
379 \begin{verbatim}
380 \defbeamertemplate{itemize item}{square}[1]{\hrule width #1 height #1}
381
382 %% The following have the same effect:
383 \setbeamertemplate{itemize item}[square]{3pt}
384 \setbeamertemplate{itemize item}{\hrule width 3pt height 3pt}
385 \end{verbatim}
386 As for the |\newcommand| command, you can also specify a \meta{default optional argument}:
387 \begin{verbatim}
388 \defbeamertemplate{itemize item}{square}[1][1ex]{\hrule width #1 height #1}
389
390 %% The following have the same effect:
391 \setbeamertemplate{itemize item}[square][3pt]
392 \setbeamertemplate{itemize item}{\hrule width 3pt height 3pt}
393
394 %% So do the following:
395 \setbeamertemplate{itemize item}[square]
396 \setbeamertemplate{itemize item}{\hrule width 1ex height 1ex}
397 \end{verbatim}
398
399 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|.
400
401 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.
402
403 \example
404 \begin{verbatim}
405 \defbeamertemplate{background canvas}{my shading}[2]
406 {
407 \pgfuseshading{myshading}% simple enough
408 }
409 [action]
410 {
411 \pgfdeclareverticalshading{myshading}{\the\paperwidth}
412 {color(0cm)=(#1); color(\the\paperheight)=(#2)}
413 }
414 ...
415
416 \setbeamertemplate{background canvas}[my shading]{red!10}{blue!10}
417 %% Defines the shading myshading right here. Subsequent calls to
418 %% \usebeamertemplate{background canvas} will yield
419 %% ``\pgfuseshading{myshading}''.
420 \end{verbatim}
421
422 \articlenote
423 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.
424
425 \example
426 |\defbeamertemplate{my template}{default}{something}| has no effect in |article| mode.
427
428 \example
429 |\defbeamertemplate<article>{my template}{default}{something}| has no effect in |presentation| modes, but has an effect in |article| mode.
430
431 \example
432 |\defbeamertemplate<all>{my template}{default}{something}| applies to all modes.
433 \end{command}
434
435 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:
436 \begin{command}{\defbeamertemplatealias\marg{element name}\marg{new predefined option name}\marg{existing predefined option name}}
437 Causes the two predefined options to have the same effect.
438 \end{command}
439
440 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.
441
442 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.
443
444 \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}}
445 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}.
446
447 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:
448
449 \example
450 The following is the typical, simple usage:
451
452 \begin{verbatim}
453 \defbeamertemplateparent{itemize items}{itemize item,itemize subitem,itemize subsubitem}
454 {}
455
456 %% The following command has the same effect as the three commands below:
457 \setbeamertemplate{itemize items}[circle]
458
459 \setbeamertemplate{itemize item}[circle] % actually, the ``empty'' argument is added
460 \setbeamertemplate{itemize subitem}[circle]
461 \setbeamertemplate{itemize subsubitem}[circle]
462 \end{verbatim}
463
464 \example
465 In the following case, an argument is passed to the children:
466
467 \begin{verbatim}
468 \defbeamertemplateparent{sections/subsections in toc shaded}
469 {section in toc shaded,subsection in toc shaded}[1][20]
470 {[#1]}
471
472 %% The following command has the same effect as the two commands below:
473 \setbeamertemplate{sections/subsections in toc shaded}[default][35]
474
475 \setbeamertemplate{section in toc shaded}[default][35]
476 \setbeamertemplate{subsection in toc shaded}[default][35]
477
478
479 %% Again:
480 \setbeamertemplate{sections/subsections in toc shaded}[default]
481
482 \setbeamertemplate{section in toc shaded}[default][20]
483 \setbeamertemplate{subsection in toc shaded}[default][20]
484 \end{verbatim}
485
486 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.
487
488 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.''
489 \end{command}