Debian Codegraph @

texmf-dist/source/latex/beamertheme-metropolis/beamerinnerthememetropolis.dtx

raw
1 % \iffalse meta-comment -------------------------------------------------------
2 % Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of
3 % contributors can be found at
4 %
5 % https://github.com/matze/mtheme/graphs/contributors
6 %
7 % and the original template was based on the HSRM theme by Benjamin Weiss.
8 %
9 % This work is licensed under a Creative Commons Attribution-ShareAlike 4.0
10 % International License (https://creativecommons.org/licenses/by-sa/4.0/).
11 % ------------------------------------------------------------------------- \fi
12 % \iffalse
13 %<*package>
14 \NeedsTeXFormat{LaTeX2e}
15 \ProvidesPackage{beamerinnerthememetropolis}[2017/01/23 Metropolis inner theme]
16 %</package>
17 % \fi
18 % \CheckSum{0}
19 % \StopEventually{}
20 % \iffalse
21 %<*package>
22 % ------------------------------------------------------------------------- \fi
23 %
24 % \subsection{\themename inner theme}
25 %
26 % A |beamer| inner theme dictates the style of the frame elements traditionally
27 % set in the ``body'' of each slide. These include:
28 %
29 % \begin{itemize}
30 % \item title, part, and section pages;
31 % \item itemize, enumerate, and description environments;
32 % \item block environments including theorems and proofs;
33 % \item figures and tables; and
34 % \item footnotes and plain text.
35 % \end{itemize}
36 %
37 %
38 %
39 % \subsubsection{Package dependencies}
40 %
41 % \begin{macrocode}
42 \RequirePackage{etoolbox}
43 \RequirePackage{keyval}
44 \RequirePackage{calc}
45 \RequirePackage{pgfopts}
46 \RequirePackage{tikz}
47 % \end{macrocode}
48 %
49 %
50 %
51 % \subsubsection{Options}
52 %
53 % \begin{macro}{sectionpage}
54 % Optionally add a slide marking the beginning of each section.
55 % \begin{macrocode}
56 \pgfkeys{
57 /metropolis/inner/sectionpage/.cd,
58 .is choice,
59 none/.code=\metropolis@disablesectionpage,
60 simple/.code={\metropolis@enablesectionpage
61 \setbeamertemplate{section page}[simple]},
62 progressbar/.code={\metropolis@enablesectionpage
63 \setbeamertemplate{section page}[progressbar]},
64 }
65 % \end{macrocode}
66 % \end{macro}
67 %
68 % \begin{macro}{subsectionpage}
69 % Optionally add a slide marking the beginning of each subsection.
70 % \begin{macrocode}
71 \pgfkeys{
72 /metropolis/inner/subsectionpage/.cd,
73 .is choice,
74 none/.code=\metropolis@disablesubsectionpage,
75 simple/.code={\metropolis@enablesubsectionpage
76 \setbeamertemplate{section page}[simple]},
77 progressbar/.code={\metropolis@enablesubsectionpage
78 \setbeamertemplate{section page}[progressbar]},
79 }
80 % \end{macrocode}
81 % \end{macro}
82 %
83 % \begin{macro}{\metropolis@inner@setdefaults}
84 % Set default values for inner theme options.
85 % \begin{macrocode}
86 \newcommand{\metropolis@inner@setdefaults}{
87 \pgfkeys{/metropolis/inner/.cd,
88 sectionpage=progressbar,
89 subsectionpage=none
90 }
91 }
92 % \end{macrocode}
93 % \end{macro}
94 %
95 %
96 %
97 % \subsubsection{Title page}
98 %
99 % \begin{macro}{title page}
100 % Template for the title page. Each element is only typset if it is defined
101 % by the user. If |\subtitle| is empty, for example, it won't leave a blank
102 % space on the title slide.
103 % \begin{macrocode}
104 \setbeamertemplate{title page}{
105 \begin{minipage}[b][\paperheight]{\textwidth}
106 \ifx\inserttitlegraphic\@empty\else\usebeamertemplate*{title graphic}\fi
107 \vfill%
108 \ifx\inserttitle\@empty\else\usebeamertemplate*{title}\fi
109 \ifx\insertsubtitle\@empty\else\usebeamertemplate*{subtitle}\fi
110 \usebeamertemplate*{title separator}
111 % \end{macrocode}
112 %
113 % Beamer's definition of |\insertauthor| is always nonempty, so we have
114 % to test another macro initialized by |\author{...}| to see if the user has
115 % defined an author. This solution was suggested by Enrico Gregorio in an
116 % answer to \href{https://tex.stackexchange.com/questions/241306/}{this
117 % Stack Exchange question}.
118 %
119 % \begin{macrocode}
120 \ifx\beamer@shortauthor\@empty\else\usebeamertemplate*{author}\fi
121 \ifx\insertdate\@empty\else\usebeamertemplate*{date}\fi
122 \ifx\insertinstitute\@empty\else\usebeamertemplate*{institute}\fi
123 \vfill
124 \vspace*{1mm}
125 \end{minipage}
126 }
127 % \end{macrocode}
128 % \end{macro}%
129 %
130 % Normal people should use |\maketitle| or |\titlepage| instead of using the
131 % |title page| beamer template directly. Beamer already defines these macros,
132 % but we patch them here to make the title page |[plain]| by default, remove
133 % |\@thanks|, and ensure the title frame number doesn't count.
134 %
135 % \begin{macro}{\maketitle}
136 % \begin{macro}{\titlepage}
137 %
138 % Inserts the title frame, or causes the current frame to use the
139 % |title page| template.
140 %
141 % \begin{macrocode}
142 \def\maketitle{%
143 \ifbeamer@inframe
144 \titlepage
145 \else
146 \frame[plain,noframenumbering]{\titlepage}
147 \fi
148 }
149 \def\titlepage{%
150 \usebeamertemplate{title page}
151 }
152 % \end{macrocode}
153 % \end{macro}
154 % \end{macro}
155 %
156 % \begin{macro}{title graphic}
157 % Set the title graphic in a zero-height box, so it doesn't change the
158 % position of other elements.
159 % \begin{macrocode}
160 \setbeamertemplate{title graphic}{
161 \vbox to 0pt {
162 \vspace*{2em}
163 \inserttitlegraphic%
164 }%
165 \nointerlineskip%
166 }
167 % \end{macrocode}
168 % \end{macro}
169 %
170 % \begin{macro}{title}
171 % Set the title on the title page.
172 % \begin{macrocode}
173 \setbeamertemplate{title}{
174 \raggedright%
175 \linespread{1.0}%
176 \inserttitle%
177 \par%
178 \vspace*{0.5em}
179 }
180 % \end{macrocode}
181 % \end{macro}
182 %
183 % \begin{macro}{subtitle}
184 % Set the subtitle on the title page.
185 % \begin{macrocode}
186 \setbeamertemplate{subtitle}{
187 \raggedright%
188 \insertsubtitle%
189 \par%
190 \vspace*{0.5em}
191 }
192 % \end{macrocode}
193 % \end{macro}
194 %
195 % \begin{macro}{title separator}
196 % Template to set the title graphic in a zero-height box. (It won't
197 % change the position of other elements.)
198 % \begin{macrocode}
199 \newlength{\metropolis@titleseparator@linewidth}
200 \setlength{\metropolis@titleseparator@linewidth}{0.4pt}
201 \setbeamertemplate{title separator}{
202 \begin{tikzpicture}
203 \fill[fg] (0,0) rectangle (\textwidth, \metropolis@titleseparator@linewidth);
204 \end{tikzpicture}%
205 \par%
206 }
207 % \end{macrocode}
208 % \end{macro}
209 %
210 % \begin{macro}{author}
211 % Set the author on the title page.
212 % \begin{macrocode}
213 \setbeamertemplate{author}{
214 \vspace*{2em}
215 \insertauthor%
216 \par%
217 \vspace*{0.25em}
218 }
219 % \end{macrocode}
220 % \end{macro}
221 %
222 % \begin{macro}{date}
223 % Set the date on the title page.
224 % \begin{macrocode}
225 \setbeamertemplate{date}{
226 \insertdate%
227 \par%
228 }
229 % \end{macrocode}
230 % \end{macro}
231 %
232 % \begin{macro}{institute}
233 % Set the institute on the title page.
234 % \begin{macrocode}
235 \setbeamertemplate{institute}{
236 \vspace*{3mm}
237 \insertinstitute%
238 \par%
239 }
240 % \end{macrocode}
241 % \end{macro}
242 %
243 %
244 %
245 % \subsubsection{Section page}
246 %
247 % \begin{macro}{section page}
248 %
249 % Template for the section title slide at the beginning of each section.
250 %
251 % \begin{macrocode}
252 \defbeamertemplate{section page}{simple}{
253 \begin{center}
254 \usebeamercolor[fg]{section title}
255 \usebeamerfont{section title}
256 \insertsectionhead\par
257 \ifx\insertsubsectionhead\@empty\else
258 \usebeamercolor[fg]{subsection title}
259 \usebeamerfont{subsection title}
260 \insertsubsectionhead
261 \fi
262 \end{center}
263 }
264 \defbeamertemplate{section page}{progressbar}{
265 \centering
266 \begin{minipage}{22em}
267 \raggedright
268 \usebeamercolor[fg]{section title}
269 \usebeamerfont{section title}
270 \insertsectionhead\\[-1ex]
271 \usebeamertemplate*{progress bar in section page}
272 \par
273 \ifx\insertsubsectionhead\@empty\else%
274 \usebeamercolor[fg]{subsection title}%
275 \usebeamerfont{subsection title}%
276 \insertsubsectionhead
277 \fi
278 \end{minipage}
279 \par
280 \vspace{\baselineskip}
281 }
282 \newcommand{\metropolis@disablesectionpage}{
283 \AtBeginSection{
284 % intentionally empty
285 }
286 }
287 \newcommand{\metropolis@enablesectionpage}{
288 \AtBeginSection{
289 \ifbeamer@inframe
290 \sectionpage
291 \else
292 \frame[plain,c,noframenumbering]{\sectionpage}
293 \fi
294 }
295 }
296 % \end{macrocode}
297 % \end{macro}
298 %
299 % \begin{macro}{subsection page}
300 %
301 % Template for the subsection title slide that can optionally be added to
302 % at the beginning of each subsection.
303 %
304 % \begin{macrocode}
305 \setbeamertemplate{subsection page}{%
306 \usebeamertemplate*{section page}
307 }
308 \newcommand{\metropolis@disablesubsectionpage}{
309 \AtBeginSubsection{
310 % intentionally empty
311 }
312 }
313 \newcommand{\metropolis@enablesubsectionpage}{
314 \AtBeginSubsection{
315 \ifbeamer@inframe
316 \subsectionpage
317 \else
318 \frame[plain,c,noframenumbering]{\subsectionpage}
319 \fi
320 }
321 }
322 % \end{macrocode}
323 % \end{macro}
324 %
325 % \begin{macro}{progress bar in section page}
326 %
327 % Template for the progress bar displayed by default on the section page.
328 % This code is duplicated in large part in the outer theme's template
329 % |progress bar in head/foot|.
330 %
331 % \begin{macrocode}
332 \newlength{\metropolis@progressonsectionpage}
333 \newlength{\metropolis@progressonsectionpage@linewidth}
334 \setlength{\metropolis@progressonsectionpage@linewidth}{0.4pt}
335 \setbeamertemplate{progress bar in section page}{
336 \setlength{\metropolis@progressonsectionpage}{%
337 \textwidth * \ratio{\insertframenumber pt}{\inserttotalframenumber pt}%
338 }%
339 \begin{tikzpicture}
340 \fill[bg] (0,0) rectangle (\textwidth, \metropolis@progressonsectionpage@linewidth);
341 \fill[fg] (0,0) rectangle (\metropolis@progressonsectionpage, \metropolis@progressonsectionpage@linewidth);
342 \end{tikzpicture}%
343 }
344 % \end{macrocode}
345 %
346 % The above code assumes that |\insertframenumber| is less than or equal to
347 % |\inserttotalframenumber|. However, this is not true on the first compile;
348 % in the absence of an |.aux| file, |\inserttotalframenumber| defaults to 1.
349 % This behaviour could cause fatal errors for long presentations, as
350 % |\metropolis@progressonsectionpage| would exceed \TeX's maximum length
351 % (16383.99999pt, roughly 5.75 metres or 18.9 feet).
352 % To avoid this, we increase the default value for |\inserttotalframenumber|;
353 % presentations with over 4000 slides will still break on first compile, but
354 % users in that situation likely have deeper problems to solve.
355 %
356 % \begin{macrocode}
357 \def\inserttotalframenumber{100}
358 % \end{macrocode}
359 % \end{macro}
360 %
361 %
362 %
363 % \subsubsection{Block environments}
364 %
365 %
366 % \begin{macro}{block}
367 % \begin{macro}{block alerted}
368 % \begin{macro}{block example}
369 %
370 % The three different block environments differ only in their colours.
371 % Rather than repeat the essentially the same template three times, we use
372 % the auxiliary macro |\metropolis@block| to define all three templates.
373 %
374 % \begin{macrocode}
375 \newlength{\metropolis@blocksep}
376 \newlength{\metropolis@blockadjust}
377 \setlength{\metropolis@blocksep}{0.75ex}
378 \setlength{\metropolis@blockadjust}{0.25ex}
379 \providecommand{\metropolis@strut}{%
380 \vphantom{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz()}%
381 }
382 \newcommand{\metropolis@block}[1]{
383 \par\vskip\medskipamount%
384 \setlength{\parskip}{0pt}
385 % \end{macrocode}
386 %
387 % If a background color is defined for the block title or body, we need to
388 % add a little bit of padding to the corresponding box. Ideally, this would
389 % be accomplished by setting |colsep=0.75ex|, which is intended to add
390 % ``color separation space'' only when the box has a colored background.
391 % Unfortunately, |colsep| also adds this separation if the background color
392 % is inherited, even if the inherited color is actually empty.
393 % (The technical reason for this boils down to the fact that the |\ifx|
394 % directive does not expand macros.)
395 %
396 % To achieve the correct spacing for |alertblock|s and |exampleblock|s
397 % as well as for normal blocks, we have to begin the |beamercolorbox|
398 % differently based on whether |block title| has an empty background.
399 %
400 % If the |block title| background is empty, or the user has explicitly
401 % removed the background from (e.g.) |block title alerted|, we just need to
402 % set a rightskip for a nice ragged-right block title.
403 %
404 % \begin{macrocode}
405 \ifbeamercolorempty[bg]{block title#1}{%
406 \begin{beamercolorbox}[rightskip=0pt plus 4em]{block title#1}}{%
407 \ifbeamercolorempty[bg]{block title}{%
408 \begin{beamercolorbox}[rightskip=0pt plus 4em]{block title#1}%
409 }%
410 % \end{macrocode}
411 %
412 % Otherwise, if the |block title| has a background, we set the padding based
413 % on |\metropolis@blockskip|. However, we have to visually compensate for
414 % the |\metropolis@strut| added to the block title (see below) by
415 % subtracting |\metropolis@blockadjust| from the top and bottom padding.
416 %
417 % \begin{macrocode}
418 {%
419 \begin{beamercolorbox}[
420 sep=\dimexpr\metropolis@blocksep-\metropolis@blockadjust\relax,
421 leftskip=\metropolis@blockadjust,
422 rightskip=\dimexpr\metropolis@blockadjust plus 4em\relax
423 ]{block title#1}%
424 }}%
425 % \end{macrocode}
426 %
427 % We can now set the contents of the |block title|. The zero-width but
428 % positive-height box |\metropolis@strut| ensures that the block title box
429 % has a consistent height, even if it lacks punctuation, ascenders, or
430 % descenders.
431 %
432 % \begin{macrocode}
433 \usebeamerfont*{block title#1}%
434 \metropolis@strut%
435 \insertblocktitle%
436 \metropolis@strut%
437 \end{beamercolorbox}%
438 % \end{macrocode}
439 %
440 % Next, we typeset the |block body|. This the code is similar to, but simpler
441 % than, the |block title| code since we don't need to adjust for any struts.
442 %
443 % \begin{macrocode}
444 \nointerlineskip%
445 \ifbeamercolorempty[bg]{block body#1}{%
446 \begin{beamercolorbox}[vmode]{block body#1}}{
447 \ifbeamercolorempty[bg]{block body}{%
448 \begin{beamercolorbox}[vmode]{block body#1}%
449 }{%
450 \begin{beamercolorbox}[sep=\metropolis@blocksep, vmode]{block body#1}%
451 \vspace{-\metropolis@parskip}
452 }}%
453 \usebeamerfont{block body#1}%
454 \setlength{\parskip}{\metropolis@parskip}%
455 }
456 % \end{macrocode}
457 %
458 % This concludes the auxiliary macro |\metropolis@block|. Finally,
459 % we define the block beamer templates using this macro.
460 %
461 % \begin{macrocode}
462 \setbeamertemplate{block begin}{\metropolis@block{}}
463 \setbeamertemplate{block alerted begin}{\metropolis@block{ alerted}}
464 \setbeamertemplate{block example begin}{\metropolis@block{ example}}
465 \setbeamertemplate{block end}{\end{beamercolorbox}\vspace*{0.2ex}}
466 \setbeamertemplate{block alerted end}{\end{beamercolorbox}\vspace*{0.2ex}}
467 \setbeamertemplate{block example end}{\end{beamercolorbox}\vspace*{0.2ex}}
468 % \end{macrocode}
469 % \end{macro}
470 % \end{macro}
471 % \end{macro}
472 %
473 %
474 %
475 % \subsubsection{Lists and floats}
476 %
477 % \begin{macrocode}
478 \setbeamertemplate{itemize items}{\textbullet}
479 \setbeamertemplate{caption label separator}{: }
480 \setbeamertemplate{caption}[numbered]
481 % \end{macrocode}
482 %
483 %
484 %
485 % \subsubsection{Footnotes}
486 % \begin{macrocode}
487 \setbeamertemplate{footnote}{%
488 \parindent 0em\noindent%
489 \raggedright
490 \usebeamercolor{footnote}\hbox to 0.8em{\hfil\insertfootnotemark}\insertfootnotetext\par%
491 }
492 % \end{macrocode}
493 %
494 %
495 %
496 % \subsubsection{Text and spacing settings}
497 %
498 % \begin{macrocode}
499 \newlength{\metropolis@parskip}
500 \setlength{\metropolis@parskip}{0.5em}
501 \setlength{\parskip}{\metropolis@parskip}
502 \linespread{1.15}
503 % \end{macrocode}
504 %
505 % By default, Beamer frames offer the |c| option to \textit{almost} vertically
506 % center the text, but the placement is a little too high. To fix this, we
507 % redefine the |c| option to equalize |\beamer@frametopskip| and
508 % |\beamer@framebottomskip|. This solution was suggested by Enrico Gregorio in
509 % an answer to \href{http://tex.stackexchange.com/questions/247826/}{this
510 % Stack Exchange question}.
511 %
512 % \begin{macrocode}
513 \define@key{beamerframe}{c}[true]{% centered
514 \beamer@frametopskip=0pt plus 1fill\relax%
515 \beamer@framebottomskip=0pt plus 1fill\relax%
516 \beamer@frametopskipautobreak=0pt plus .4\paperheight\relax%
517 \beamer@framebottomskipautobreak=0pt plus .6\paperheight\relax%
518 \def\beamer@initfirstlineunskip{}%
519 }
520 % \end{macrocode}
521 %
522 %
523 %
524 % \subsubsection{Standout frames}
525 %
526 % \themename offers a custom frame format with large, centered text and an
527 % inverted background. To use it, add the key |standout| to the frame:
528 % |\begin{frame}[standout] ... \end{frame}|.
529 %
530 % \begin{macro}{standout}
531 %
532 % Optional arguments to Beamer's frames are implemented using
533 % |\define@key| from the |keyval| package, which will execute code when the
534 % defined option is called. For the |standout| option, we begin a group,
535 % change the colors and fonts, and set a \centering alignment.
536 %
537 % \begin{macrocode}
538 \providebool{metropolis@standout}
539 \define@key{beamerframe}{standout}[true]{%
540 \booltrue{metropolis@standout}
541 \begingroup
542 \setkeys{beamerframe}{c}
543 \setkeys{beamerframe}{noframenumbering}
544 \ifbeamercolorempty[bg]{palette primary}{
545 \setbeamercolor{background canvas}{
546 use=palette primary,
547 bg=-palette primary.fg
548 }
549 }{
550 \setbeamercolor{background canvas}{
551 use=palette primary,
552 bg=palette primary.bg
553 }
554 }
555 \centering
556 \usebeamercolor[fg]{palette primary}
557 \usebeamerfont{standout}
558 }
559 % \end{macrocode}
560 %
561 % Then we just have to close the group after the standout slide is finished
562 % in order to restore the colours and fonts for the rest of the
563 % presentation. Unfortunately, we cannot use \AfterEndEnvironment{frame} for
564 % this (see \url{http://tex.stackexchange.com/questions/226319/}).
565 % Instead, we add the |\endgroup| to |\beamer@reseteecodes|, which is run
566 % exactly once at the end of each slide.
567 %
568 % \begin{macrocode}
569 \apptocmd{\beamer@reseteecodes}{%
570 \ifbool{metropolis@standout}{
571 \endgroup
572 \boolfalse{metropolis@standout}
573 }{}
574 }{}{}
575 % \end{macrocode}
576 % \end{macro}
577 %
578 % \subsubsection{Process package options}
579 %
580 % \begin{macrocode}
581 \metropolis@inner@setdefaults
582 \ProcessPgfPackageOptions{/metropolis/inner}
583 % \end{macrocode}
584 %
585 % \iffalse
586 %</package>
587 % \fi
588 % \Finale
589 \endinput