Debian Codegraph @

texmf-dist/source/latex/beamerswitch/beamerswitch.dtx

raw
1 % \iffalse meta-comment
2 %<*internal>
3 \iffalse
4 %</internal>
5 %<*readme>
6 # beamerswitch: Convenient mode selection in Beamer documents
7
8 This class is a wrapper around the [beamer](http://ctan.org/pkg/beamer) class to
9 make it easier to use the same document to generate the different forms of the
10 presentation: the slides themselves, an abbreviated slide set for transparencies
11 or online reference, an n-up handout version, and a transcript or set of notes
12 using the `article` class.
13
14 ## Installation
15
16 ### Dependencies
17
18 To compile the documentation you will need to have the
19 [minted](http://ctan.org/pkg/minted) package working, which in turn relies on
20 Python 2.6+ and Pygments. See the documentation of that package for details.
21
22 There is an example file that demonstrates the features of the class. The class
23 itself depends only on packages easily available through TeX distributions and
24 CTAN. One feature relies on [latexmk](http://ctan.org/pkg/latexmk) though you
25 can work around that if you have the patience.
26
27 Note that the zip file on the
28 [Releases](https://github.com/alex-ball/beamerswitch/releases) page on GitHub
29 contains all the files you need, pre-compiled. You can also avoid the hassle by
30 installing the class from your TeX distribution's package manager.
31
32 ### Managed way
33
34 The latest stable release of the beamerswitch class has been packaged for
35 TeX Live and MiKTeX. If you are running TeX Live and have `tlmgr`
36 installed, you can install the package simply by running
37 `tlmgr install beamerswitch`. If you are running MiKTeX, you can install the
38 package by running `mpm --install=beamerswitch`. Both `tlmgr` and `mpm` have
39 GUI versions that you might find friendlier.
40
41 ### Automated way
42
43 A makefile is provided which you can use with the Make utility:
44
45 * Running `make beamerswitch.cls` just generates the class file (and a few
46 others).
47 * Running `make` generates the class file and documentation.
48 * Running `make inst` generates and installs the files to your home TeX tree.
49 (To undo, run `make uninst`.)
50 * Running `make install` generates and installs the files to the local TeX
51 tree. (To undo, run `make uninstall`.)
52 * Running `make clean` removes auxiliary files from the working directory.
53 * Running `make distclean` removes the generated from the working directory
54 files as well.
55
56 ### Manual way
57
58 To install the class from scratch, follow these instructions. If you have
59 downloaded the zip file from the [Releases] page on GitHub, you can skip the
60 first three steps.
61
62 1. Run `tex beamerswitch.dtx` to generate the class file and the example file
63 `beamerswitch-example.tex`. (You can safely skip this step if you are
64 confident about step 2.)
65
66 2. Compile `beamerswitch.dtx` with your favourite version of LaTeX with shell
67 escape enabled (as required by `minted` for typesetting the listings). You
68 will also need to run it through `makeindex`. This will generate the main
69 documentation (DVI or PDF).
70
71 3. Compile `beamerswitch-example.tex` with your favourite version of LaTeX. If
72 you enable shell escape and have `latexmk` installed you will end up with
73 another four documents (DVI or PDF). Otherwise you will get one.
74
75 4. To install the files, create the following folders in your chosen TeX tree
76 and copy the files across as shown (read `.pdf` as `.dvi` if that is what
77 you generated):
78 - `source/latex/beamerswitch`:
79 `beamerswitch.dtx`,
80 (`beamerswitch.ins`)
81 - `tex/latex/beamerswitch`:
82 `beamerswitch.cls`
83 - `doc/latex/beamerswitch`:
84 `beamerswitch.pdf`,
85 `beamerswitch-example.tex`,
86 `beamerswitch-example.pdf`,
87 `beamerswitch-example-article.pdf`,
88 `beamerswitch-example-handout.pdf`,
89 `beamerswitch-example-trans.pdf`
90
91 5. You may then have to update your installation's file name database
92 before TeX and friends can see the files.
93
94 ## Licence
95
96 Copyright 2016–2022 Alex Ball.
97
98 This work consists of the file beamerswitch.dtx and a Makefile.
99
100 This work may be distributed and/or modified under the conditions of the
101 [LaTeX Project Public License (LPPL)](http://www.latex-project.org/lppl.txt),
102 either version 1.3c of this license or (at your option) any later version.
103
104 This work is "maintained" (as per LPPL maintenance status) by
105 [Alex Ball](http://alexball.me.uk/).
106
107 %</readme>
108 %<*example>
109 \documentclass[%
110 beameroptions={ignorenonframetext,14pt},
111 articleoptions={a4paper,12pt},
112 also={trans,handout,article}]{beamerswitch}
113 \handoutlayout{nup=3plus,border=1pt}
114 \articlelayout{maketitle,frametitles=none}
115 \usepackage[british]{babel}
116 \mode<article>{
117 \usepackage[hmargin=3cm,vmargin=2.5cm]{geometry}
118 }
119 \mode<presentation>{
120 \usefonttheme{professionalfonts}
121 }
122 \mode<handout>{
123 \usecolortheme{dove}
124 }
125 \usepackage{libertine}
126
127 \title{A demonstration of the \textsf{beamerswitch} class}
128 \subtitle{Testing features}
129 \author{Alex Ball\inst{1}}
130 \institute{\inst{1}University of Life}
131 \date{1 September 2016}
132 \subject{A LaTeX class}
133 \keywords{CTAN, literate programming}
134
135 \begin{document}
136 \begin{frame}
137 \maketitle
138 \end{frame}
139
140 This very brief demonstration shows how to use the \textsf{beamerswitch} class.
141 It allows easy switching between four \textsf{beamer} modes:
142
143 \begin{frame}{Beamer modes}
144 \begin{itemize}[<+->]
145 \item \textbf{beamer:} regular slides
146 \item \textbf{trans:} slides suitable for printing on transparencies
147 \item \textbf{handout:} slides suitable for printing on paper
148 \item \textbf{article:} transcript, paper, notes or other article-style
149 document based on the slides
150 \end{itemize}
151 \end{frame}
152
153 Notice how the text outside frames is only shown in article mode. Also,
154
155 \begin{frame}{Features shown in this example}
156 \begin{itemize}[<+->]
157 \item Different class options are passed to the \textsf{beamer} and
158 \textsf{article} classes.
159 \item The `trans' and `handout' versions do not have the intermediate
160 slides used by the `beamer' version for uncovering content.
161 \item The handout has three slides to a page with room for handwritten
162 notes at the side, and is in black and white.
163 \end{itemize}
164
165 \uncover<+->{See the source code of this example to see how it was done.}
166 \end{frame}
167
168 This PDF also has title and author information saved in the metadata (look
169 at the properties in your PDF viewer).
170
171 Happy {\LaTeX}ing!
172 \end{document}
173 %</example>
174 %<*internal>
175 \fi
176 \def\nameofplainTeX{plain}
177 \ifx\fmtname\nameofplainTeX\else
178 \expandafter\begingroup
179 \fi
180 %</internal>
181 %<*install>
182 \input docstrip.tex
183 \keepsilent
184 \askforoverwritefalse
185 \preamble
186 ----------------------------------------------------------------
187 beamerswitch --- Convenient mode selection in Beamer documents
188 Author: Alex Ball
189 E-mail: [email protected]
190 License: Released under the LaTeX Project Public License v1.3c or later
191 See: http://www.latex-project.org/lppl.txt
192 ----------------------------------------------------------------
193
194 \endpreamble
195 \postamble
196
197 Copyright (C) 2016-2022 by Alex Ball <[email protected]>
198 \endpostamble
199
200 \usedir{tex/latex/\jobname}
201 \generate{
202 \file{\jobname.cls}{\from{\jobname.dtx}{class}}
203 }
204 \usedir{doc/latex/\jobname}
205 \generate{
206 \file{\jobname-example.tex}{\from{\jobname.dtx}{example}}
207 }
208 %</install>
209 %<install>\endbatchfile
210 %<*internal>
211 \usedir{source/latex/\jobname}
212 \generate{
213 \file{\jobname.ins}{\from{\jobname.dtx}{install}}
214 }
215 \nopreamble\nopostamble
216 \usedir{doc/latex/\jobname}
217 \generate{
218 \file{README.md}{\from{\jobname.dtx}{readme}}
219 }
220 \ifx\fmtname\nameofplainTeX
221 \expandafter\endbatchfile
222 \else
223 \expandafter\endgroup
224 \fi
225 %</internal>
226 %<*driver>
227 \ProvidesFile{beamerswitch.dtx}
228 %</driver>
229 %<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
230 %<class>\ProvidesClass{beamerswitch}
231 %<*class>
232 [2022/08/20 v1.9 Convenient mode selection in Beamer documents]
233 %</class>
234 %<*driver>
235 \documentclass[12pt]{article}
236 % Page Layout
237 \usepackage[a4paper,hmargin=30mm,vmargin=25mm,nohead]{geometry}
238 % Typography
239 \usepackage[charter,expert]{mathdesign}
240 \makeatletter
241 \def\hrulefill{\leavevmode\leaders \hrule height \rulethickness \hfill\kern\z@}
242 \makeatother
243 \usepackage{iftex}
244 \ifPDFTeX
245 \usepackage[utf8]{inputenc}
246 \usepackage[T1]{fontenc}
247 \usepackage[scaled=0.96,sups]{XCharter}
248 \usepackage[scaled=0.95,tabular]{sourcesanspro}
249 \usepackage[varl,varqu]{zi4}
250 \else
251 \usepackage{fontspec}
252 \setmainfont
253 [Scale=0.96
254 ,Ligatures=TeX
255 ]%
256 {XCharter}
257 \setsansfont
258 [Scale=MatchLowercase
259 ,Ligatures=TeX
260 ,StylisticSet=4
261 ,BoldFont={Source Sans Pro Bold}
262 ,ItalicFont={Source Sans Pro Italic}
263 ,BoldItalicFont={Source Sans Pro Bold Italic}
264 ]%
265 {Source Sans Pro}
266 \setmonofont
267 [Scale=MatchLowercase
268 ,RawFeature={extend=0.83}
269 ,BoldFont={Source Code Pro Bold}
270 ,BoldItalicFont={Source Code Pro Bold}
271 ,AutoFakeSlant=0.2
272 ,ItalicFeatures={StylisticSet=2,StylisticSet=3}
273 ,BoldItalicFeatures={FakeSlant=0.2,StylisticSet=2,StylisticSet=3}
274 ]%
275 {Source Code Pro}
276 \fi
277 % Improving the look of the documentation
278 \setlength{\parindent}{0pt}
279 \setlength{\parskip}{6pt plus 2pt minus 1pt}
280 \usepackage{multicol}
281 \usepackage{enumitem}
282 \setlist[itemize]{%
283 topsep={6pt plus 2pt minus 1pt},%
284 partopsep={0pt plus 0.05em},%
285 itemsep={0.2em plus 0.05em minus 0.05em},%
286 parsep={0pt plus 0.05em},%
287 }
288 \usepackage[bookmarks,raiselinks,pageanchor,hyperindex,colorlinks]{hyperref}
289 \usepackage{etoolbox}
290 \usepackage{tcolorbox,doc}
291 \makeatletter
292 \renewenvironment{theglossary}{%
293 \bgroup
294 \glossary@prologue
295 \GlossaryParms \let\item\@idxitem \ignorespaces
296 }{%
297 \egroup
298 }
299 \makeatother
300 \tcbuselibrary{documentation,breakable,minted,raster}
301 \colorlet{Option}{violet}
302 \colorlet{Command}{red!75!black}
303 \colorlet{Environment}{blue!75!black}
304 \colorlet{Value}{olive!75!black}
305 \colorlet{Color}{cyan!75!black}
306 \tcbset
307 { listing engine=minted
308 , minted options=
309 { breaklines
310 , fontsize=\footnotesize
311 , linenos
312 , numbersep=20pt
313 , firstnumber=last
314 }
315 , documentation minted options=
316 { breaklines
317 , fontsize=\small
318 , breakbefore=\{\[
319 , breakafter=/\}\]
320 , breakbeforesymbolpre={}
321 }
322 , index format=pgf
323 , color command=Command
324 , color environment=Environment
325 , color key=Option
326 , color value=Value
327 , color color=Color
328 , colbacktitle=ExampleFrame!33!ExampleBack
329 }
330 \renewcommand{\theFancyVerbLine}{\footnotesize\itshape\color{gray}\arabic{FancyVerbLine}}
331 \let\tcbcs=\cs
332 \renewcommand*{\cs}[1]{\textcolor{Command}{\tcbcs{#1}}}
333 \def\sqbrackets#1{%
334 \texttt{\textcolor{Option}{[}#1\textcolor{Option}{]}}}
335 \def\brackets#1{%
336 \texttt{\textcolor{Environment}{\char`\{}#1\textcolor{Environment}{\char`\}}}}
337 \def\marg#1{%
338 \textcolor{Environment}{\ttfamily\char`\{}\meta{#1}\textcolor{Environment}{\ttfamily\char`\}}}
339 \newcommand*{\env}[1]{\textcolor{Environment}{\ttfamily #1}}
340 \newcommand*{\key}[1]{\textcolor{Option}{\ttfamily #1}}
341 \newcommand*{\val}[1]{\textcolor{Value}{\ttfamily #1}}
342
343 \makeatletter
344 \renewenvironment{macro}[1]{%
345 \StrSubstitute{#1}{\detokenize{@}}{"@}[\MyName]%
346 \edef\saved@macroname{\expandafter\string\csname #1\endcsname}%
347 \let\saved@indexname\saved@macroname
348 \index{\MyName @\tcbIndexPrintComC {\MyName}|(emph}%
349 }{%
350 \ifdef{\MyName}{}{%
351 \errmessage{You have closed a macro environment you have not opened on \the\inputlineno.}%
352 }
353 \index{\MyName @\tcbIndexPrintComC {\MyName}|)}%
354 }
355 \renewenvironment{environment}[1]{%
356 \StrSubstitute{#1}{\detokenize{@}}{"@}[\MyName]%
357 \edef\saved@macroname{#1}%
358 \let\saved@indexname\saved@macroname
359 \index{\MyName @\tcbIndexPrintEnvCA {\MyName}|(emph}%
360 \index{Environments!\MyName @\tcbIndexPrintEnvC {\MyName}|(emph}%
361 }{%
362 \ifdef{\MyName}{}{%
363 \errmessage{You have closed an environment environment you have not opened on \the\inputlineno.}%
364 }
365 \index{Environments!\MyName @\tcbIndexPrintEnvC {\MyName}|)}%
366 \index{\MyName @\tcbIndexPrintEnvCA {\MyName}|)}%
367 }
368 \makeatother
369 \newenvironment{optionkey}[1]{%
370 \def\MyName{#1}%
371 \index{\MyName@\tcbIndexPrintKeyCA {\MyName}|(emph}%
372 \index{Keys!\MyName@\tcbIndexPrintKeyC {\MyName}|(emph}%
373 }{%
374 \ifdef{\MyName}{}{%
375 \errmessage{You have closed an optionkey environment you have not opened on \the\inputlineno.}%
376 }
377 \index{Keys!\MyName@\tcbIndexPrintKeyC {\MyName}|)}%
378 \index{\MyName@\tcbIndexPrintKeyCA {\MyName}|)}%
379 }
380 \newenvironment{optionvalue}[1]{%
381 \def\MyName{#1}%
382 \index{\MyName@\tcbIndexPrintValCA {\MyName}|(emph}%
383 \index{Values!\MyName@\tcbIndexPrintValC {\MyName}|(emph}%
384 }{%
385 \ifdef{\MyName}{}{%
386 \errmessage{You have closed an optionvalue environment you have not opened on \the\inputlineno.}%
387 }
388 \index{Values!\MyName@\tcbIndexPrintValC {\MyName}|)}%
389 \index{\MyName@\tcbIndexPrintValCA {\MyName}|)}%
390 }
391 \makeatletter
392 \newcommand{\resetmintedformat}{%
393 % Comments
394 \expandafter\def\csname PYGdefault@tok@c\endcsname{\let\PYGdefault@it=\textit\def\PYGdefault@tc####1{\textcolor{gray}{####1}}}
395 % Command sequences
396 \expandafter\def\csname PYGdefault@tok@k\endcsname{\def\PYGdefault@tc####1{\textcolor{Command}{####1}}}
397 % Optional arguments
398 \expandafter\def\csname PYGdefault@tok@na\endcsname{\def\PYGdefault@tc####1{\textcolor{Option}{####1}}}
399 % Braces
400 \expandafter\def\csname PYGdefault@tok@nb\endcsname{\def\PYGdefault@tc####1{\textcolor{Environment}{####1}}}
401 }
402 \apptocmd{\minted@checkstyle}{\resetmintedformat}{}{}
403 \makeatother
404 \newcommand{\pkg}[1]{\href{http://www.ctan.org/pkg/#1}{\textsf{#1}}}
405 \MakeShortVerb{\|}
406 \makeatletter
407 \let\PrintMacroName\@gobble
408 \let\PrintEnvName\@gobble
409 \renewenvironment{tcb@manual@entry}{\begin{list}{}{%
410 \setlength{\topsep}{0pt}
411 \setlength{\partopsep}{0pt}
412 \setlength{\leftmargin}{\kvtcb@doc@left}%
413 \setlength{\itemindent}{0pt}%
414 \setlength{\itemsep}{0pt}%
415 \setlength{\parsep}{0pt}%
416 \setlength{\rightmargin}{\kvtcb@doc@right}%
417 }\item}{\end{list}}
418 \makeatother
419 % This bit inspired by ydoc
420 \makeatletter
421 \newwrite\ydocwrite
422 \def\ydocfname{\jobname.tcbtemp}
423 \def\ydoc@catcodes{%
424 \let\do\@makeother
425 \dospecials
426 \catcode`\\=\active
427 \catcode`\^^M=\active
428 \catcode`\ =\active
429 }
430 \def\macrocode{%
431 \begingroup
432 \ydoc@catcodes
433 \macro@code
434 }
435 \def\endmacrocode{}
436 \begingroup
437 \endlinechar\m@ne
438 \@firstofone{%
439 \catcode`\|=0\relax
440 \catcode`\(=1\relax
441 \catcode`\)=2\relax
442 \catcode`\*=14\relax
443 \catcode`\{=12\relax
444 \catcode`\}=12\relax
445 \catcode`\ =12\relax
446 \catcode`\%=12\relax
447 \catcode`\\=\active
448 \catcode`\^^M=\active
449 \catcode`\ =\active
450 }*
451 |gdef|macro@code#1^^M% \end{macrocode}(*
452 |endgroup|expandafter|macro@@code|expandafter(|ydoc@removeline#1|noexpand|lastlinemacro)*
453 )*
454 |gdef|ydoc@removeline#1^^M(|noexpand|firstlinemacro)*
455 |gdef|ydoc@defspecialmacros(*
456 |def^^M(|noexpand|newlinemacro)*
457 |def (|noexpand|spacemacro)*
458 |def\(|noexpand|bslashmacro)*
459 )*
460 |gdef|ydoc@defrevspecialmacros(*
461 |def|newlinemacro(|noexpand^^M)*
462 |def|spacemacro(|noexpand )*
463 |def|bslashmacro(|noexpand\)*
464 )*
465 |endgroup
466 \def\macro@@code#1{%
467 {\ydoc@defspecialmacros
468 \xdef\themacrocode{#1}}%
469 \PrintMacroCode
470 \end{macrocode}%
471 }
472 \def\PrintMacroCode{%
473 \begingroup
474 \let\firstlinemacro\empty
475 \let\lastlinemacro\empty
476 \def\newlinemacro{^^J}%
477 \let\bslashmacro\bslash
478 \let\spacemacro\space
479 \immediate\openout\ydocwrite=\ydocfname\relax
480 \immediate\write\ydocwrite{\themacrocode}%
481 \immediate\closeout\ydocwrite
482 \let\input\@input
483 \tcbinputlisting{breakable,listing only,docexample,listing file=\ydocfname}%
484 \endgroup
485 }
486 \makeatother
487
488 \DisableCrossrefs
489 \makeindex
490 \RecordChanges
491 \begin{document}
492
493 \GetFileInfo{\jobname.dtx}
494 \DoNotIndex{\documentclass,\newcommand,\newenvironment}
495
496 \title{\textsf{beamerswitch} --- Convenient mode selection in Beamer documents}
497 \author{Alex Ball}
498 \date{Class \fileversion\ --- \filedate}
499
500 \maketitle
501
502 \begin{absquote}
503 This class is a wrapper around the \pkg{beamer} class to make it easier to use the
504 same document to generate the different forms of the presentation: the slides
505 themselves, an abbreviated slide set for transparencies or online reference,
506 an n-up handout version, and a transcript or set of notes using the \pkg{article}
507 class.
508
509 To contact the author about this package, please visit the GitHub
510 page where the code is hosted: \url{https://github.com/alex-ball/beamerswitch}.
511 \end{absquote}
512
513 \changes{v1.2}{2016/05/22}{Add `Quick start guide' section.}
514 \section{Quick start guide}
515
516 Here are the key facts:
517
518 \begin{itemize}
519 \item
520 The \pkg{beamerswitch} class makes it easier to switch between
521 \pkg{beamer} modes.
522 \item
523 It is aimed at you if you want to generate handouts from your
524 presentation, whether printouts of your slides or something more like a paper
525 or article.
526 \item
527 It is \emph{not} a drop-in replacement for \pkg{beamer}.
528 \end{itemize}
529
530 If you have an existing \pkg{beamer} presentation and want convert it to use
531 \pkg{beamerswitch} instead, here's what you need to do.
532
533 \begin{enumerate}
534 \item
535 Replace the class \pkg{beamer} with \pkg{beamerswitch}.
536
537 Wrap any class options you have specified in braces and turn them into the
538 value of the \key{beameroptions} option:
539
540 \begin{tcbraster}[raster equal height=rows]
541 \begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
542 \documentclass[10pt]{beamer}
543 \end{dispListing*}
544 \begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
545 \documentclass[beameroptions={10pt}]{beamerswitch}
546 \end{dispListing*}
547 \end{tcbraster}
548
549 If you didn't specify any options, then give \key{beameroptions} a blank
550 value:
551
552 \begin{tcbraster}[raster equal height=rows]
553 \begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
554 \documentclass{beamer}
555 \end{dispListing*}
556 \begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
557 \documentclass[beameroptions={}]{beamerswitch}
558 \end{dispListing*}
559 \end{tcbraster}
560
561 If you only specified \key{ignorenonframetext}, then you don't
562 need \key{beameroptions}:
563
564 \begin{tcbraster}[raster equal height=rows]
565 \begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
566 \documentclass[ignorenonframetext]{beamer}
567 \end{dispListing*}
568 \begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
569 \documentclass{beamerswitch}
570 \end{dispListing*}
571 \end{tcbraster}
572
573 \item
574 Wrap any preamble content intended only for your slides (like \cs{usetheme}
575 or \cs{usepackage} commands) with `\cs{mode}\texttt{<presentation>}\meta{\dots}'
576 or something more specific, as required.
577 \end{enumerate}
578
579 In summary, here is an example:
580
581 \begin{tcbraster}[raster equal height=rows]
582 \begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
583 \documentclass[10pt]{beamer}
584
585
586 \usetheme{metropolis}
587
588 \title{Test presentation}
589 \begin{document}
590 \maketitle
591 \end{document}
592 \end{dispListing*}
593 \begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
594 \documentclass[beameroptions={10pt}]{beamerswitch}
595 \mode<presentation>{%
596 \usetheme{metropolis}
597 }
598 \title{Test presentation}
599 \begin{document}
600 \maketitle
601 \end{document}
602 \end{dispListing*}
603 \end{tcbraster}
604
605 At this point the document should compile exactly as before.
606
607 If you intend to use article mode at all, I strongly suggest that you
608 proceed by converting your document body so it that works with \pkg{beamer}'s
609 \key{ignorenonframetext} option in place. That means making sure all slide
610 content is in a \env{frame} environment, new command definitions are moved
611 to the preamble, and so on.
612
613 Lastly, read through the rest of this manual and see what \pkg{beamerswitch} can
614 do for you!
615
616 \section{Introduction}
617
618 With \pkg{beamer}, it is possible to typeset the same document code in different
619 ways to get different effects. The result you get depends on a potentially
620 confusing mix of options, modes, and indeed classes.
621
622 Beamer has five modes for typesetting content. There are three modes that
623 produce regular slides:
624
625 \begin{itemize}
626 \item
627 The \key{beamer} mode relates to the normal, default slide set.
628 \item
629 The \key{trans} class option switches to the mode of the same name. It is
630 intended for transparencies, but is really just an alternative mode that
631 ignores `bare' overlay specifications.
632 \item
633 The \key{handout} class option switches to the mode of the same name. It is
634 intended for print-friendly versions, but is really just another alternative
635 mode that ignores `bare' overlay specifications.
636 \end{itemize}
637
638 The \pkg{beamer} manual shows how to use \key{handout} mode in conjunction
639 with \pkg{pgfpages} to get several slides on a single side of A4 (or Letter)
640 paper.
641
642 Beamer can also produce a double-height or double-width slide set, with the
643 intention that each half will be shown on a different display (e.g.\@ one for
644 the audience, one for the speaker). There are three variations of this,
645 activated using \cs{setbeameroption}:
646
647 \begin{itemize}
648 \item
649 \key{show notes on second screen} uses the second screen for text marked up
650 using \cs{note}\marg{text}.
651 \item
652 \key{second mode text on second screen} uses the second screen for showing
653 the slide typeset in \key{second} mode rather than \key{beamer}. Unlike
654 \key{trans} and \key{handout}, \key{second} responds to `bare' overlay
655 specifications.
656 \item
657 \key{previous slide on second screen}, uses the second screen either for
658 showing the previous slide or, if the slide has the \key{typeset second}
659 option set, for showing the current slide typeset in \key{second} mode.
660 \end{itemize}
661
662 The final variation is to use a different class altogether, such as
663 \pkg{article}, in conjunction with \pkg{beamerarticle}. In this case the content
664 is set free-flowing in \key{article} mode, without any of the frame furniture.
665
666 The \pkg{beamer} manual suggests coping with all these variations by having the
667 document code in one file, and using it as input to other files that each set up
668 a different mode of operation. This is fine but a bit of a fiddle. It would be
669 nice to be able to get the same effect using a single file and, ideally, a
670 single command invocation.
671
672 The \pkg{beamerswitch} class addresses this issue by acting as a wrapper around
673 the various options, and providing a common interface for switching between
674 modes. More specifically, it has three main functions:
675
676 \begin{enumerate}
677 \item
678 To provide more choice of handout-mode layouts than \pkg{pgfpages} gives you
679 out-of-the-box. Additionally, I hope you will find the method for selecting
680 them more memorable.
681 \item
682 To enable you to switch to \key{article} mode with a simple change of class
683 option, instead of having to fiddle with commented-out \cs{documentclass} and
684 \cs{usepackage} lines.
685 \item
686 To allow you to override the \pkg{beamer} mode from the command line, by
687 choosing a given jobname suffix. Primarily this is to allow you to generate
688 the different versions programmatically. Indeed, the class provides facilities
689 for generating multiple versions with a single command.
690 \end{enumerate}
691
692 \section{Dependencies}
693
694 To use \pkg{beamerswitch}, you will need to have the following packages available
695 and reasonably up to date on your system. All of these ship with recent \TeX\
696 distributions.
697
698 \begin{multicols}{3}
699 \begin{itemize}
700 \item \pkg{beamer}
701 \item \pkg{etoolbox}
702 \item \pkg{hyperref}
703 \item \pkg{iftex}
704 \item \pkg{pgf}
705 \item \pkg{shellesc}
706 \item \pkg{xkeyval}
707 \item \pkg{xstring}
708 \end{itemize}
709 \end{multicols}
710
711 One feature of the class uses \pkg{latexmk} by default, though you can configure
712 it to use something else if you need or want to.
713
714 \section{Loading the class}
715
716 The class is loaded in the usual way:
717
718 \begin{tcolorbox}[docexample,fontupper=\small]
719 \cs{documentclass}\oarg{options}\brackets{beamerswitch}
720 \end{tcolorbox}
721
722 The various options are described below.
723
724 \subsection{Passing options to the underlying classes}
725
726 \begin{docKey}{articleclass}{=\meta{class}}{default and initially \val{article}}
727 Selects the \meta{class} to use when in \key{article} mode.
728 \end{docKey}
729
730 \begin{docKey}{articleoptions}{=\marg{options}}{default and initially empty}
731 Passes the \meta{options} to the underlying class (selected by \key{articleclass})
732 when in \key{article} mode.
733 \end{docKey}
734
735 \begin{docKey}{beameroptions}{=\marg{options}}{default and initially \val{ignorenonframetext}}
736 Passes the \meta{options} to the \pkg{beamer} class when in \key{beamer},
737 \key{handout} or \key{trans} mode. Do not specify \val{handout} or \val{trans}
738 among the options as \pkg{beamerswitch} handles those for you. Note that the
739 default behaviour is to pass the \val{ignorenonframetext} option, so remember
740 to include it yourself if you start specifying other options.
741 \end{docKey}
742
743
744 \subsection{Choosing the mode of the current run}
745
746 The \pkg{beamerswitch} class, as explained above, does not do much itself but
747 rather helps you to switch between \pkg{beamer} modes, specifically
748 \key{article}, \key{beamer}, \key{trans} and \key{handout}.
749
750 The normal way of choosing the mode is to use the respective class options.
751
752 \begin{docKey}{article}{}{no value, initially unset}
753 Switches to \key{article} mode, which uses the \pkg{article} class and
754 resembles a normal article.
755 \end{docKey}
756
757 \begin{docKey}{beamer}{}{no value, initially set}
758 Switches to \key{beamer} mode, which uses the \pkg{beamer} class and
759 resembles a normal slideshow.
760 \end{docKey}
761
762 \begin{docKey}{handout}{}{no value, initially unset}
763 Switches to \key{handout} mode, which uses the \pkg{beamer} class but uses a
764 different series of overlay specifications. It resembles a set of printed
765 pages with multiple slides shown on each page.
766 \end{docKey}
767
768 \begin{docKey}{trans}{}{no value, initially unset}
769 Switches to \key{trans} mode, which uses the \pkg{beamer} class and
770 resembles a normal slideshow, but uses a different series of overlay
771 specifications.
772 \end{docKey}
773
774 There is, however, a sneaky second way of setting the mode that overrides the
775 first, and that is to use the \cs{jobname}. By default, this is the name of your
776 \LaTeX\ file minus the \texttt{.tex} extension, but you can set it to something
777 else when you run \LaTeX. If you set the \cs{jobname} to end in one of the
778 following suffixes, the mode will automatically switch:
779
780 \begin{itemize}
781 \item \texttt{-article} will switch to \key{article} mode.
782 \item \texttt{-handout} will switch to \key{handout} mode.
783 \item \texttt{-slides} will switch to \key{beamer} mode.
784 \item \texttt{-trans} will switch to \key{trans} mode.
785 \end{itemize}
786
787 The idea is that you can keep your source document the same, but by running
788 \LaTeX\ with an alternative \cs{jobname}, you can get a different version out
789 with a meaningfully different file name.
790
791 Of course, you may not want to use those suffixes. Perhaps you want them in
792 German; perhaps your document's file name already ends in one of them; perhaps
793 `article' or `trans' doesn't describe what you're using those modes for. The
794 suffixes are provided by the following commands:
795
796 \begin{docCommand}{ArticleSuffix}{}
797 Holds the \cs{jobname} suffix that triggers \key{article} mode.
798 \end{docCommand}
799
800 \begin{docCommand}{BeamerSuffix}{}
801 Holds the \cs{jobname} suffix that triggers \key{beamer} mode.
802 \end{docCommand}
803
804 \begin{docCommand}{HandoutSuffix}{}
805 Holds the \cs{jobname} suffix that triggers \key{handout} mode.
806 \end{docCommand}
807
808 \begin{docCommand}{TransSuffix}{}
809 Holds the \cs{jobname} suffix that triggers \key{trans} mode.
810 \end{docCommand}
811
812 The CamelCase is an admittedly rather obscure signal to you that, if you want to
813 change them to something else, you should do so via \cs{newcommand} before
814 loading the class:
815
816 \begin{dispListing}
817 \newcommand*{\ArticleSuffix}{-script}
818 \documentclass{beamerswitch}
819 \end{dispListing}
820
821 \subsection{Using more than one mode at once}
822
823 Another handy feature of the class is that it can spawn parallel compilations,
824 so you could in theory generate all four versions from a single command. It
825 achieves this magic by escaping to the shell and running \pkg{latexmk}. Thus
826 for it to work you need to run \LaTeX\ with shell escape enabled and you need
827 \pkg{latexmk} to be installed.
828
829 \begin{docKey}{alsoarticle}{}{no value, initially unset}
830 Spawns a new compilation process in \key{article} mode.
831 \end{docKey}
832
833 \begin{docKey}{alsobeamer}{}{no value, initially unset}
834 Spawns a new compilation process in \key{beamer} mode.
835 \end{docKey}
836
837 \begin{docKey}{alsohandout}{}{no value, initially unset}
838 Spawns a new compilation process in \key{handout} mode.
839 \end{docKey}
840
841 \begin{docKey}{alsotrans}{}{no value, initially unset}
842 Spawns a new compilation process in \key{trans} mode.
843 \end{docKey}
844
845 \begin{docKey}{also}{=\marg{comma-separated list of modes}}{no default, initially empty}
846 Spawns compilation processes in each of the specified modes. Note that the
847 list has to be wrapped in braces, and only the four aforementioned modes are
848 recognized.
849 \end{docKey}
850
851 If you would rather use a tool other than \pkg{latexmk} to managed your spawned
852 compilation processes, it is possible to do that. Bear in mind, though, that
853 \pkg{beamerswitch} is not clever enough to spot if you have already compiled the
854 other version on a previous run so you have to take care of that yourself. The
855 command that does the business is this:
856
857 \changes{v1.1}{2016/08/19}{Improve documentation of \cs{BeamerswitchSpawn}, \cs{handoutlayout} and \cs{articlelayout}.}
858 \begin{docCommand}{BeamerswitchSpawn}{\marg{suffix}}
859 Spawns a new compilation process with \meta{suffix} appended to the
860 \cs{jobname}.
861 \end{docCommand}
862
863 By default, \cs{BeamerswitchSpawn} checks which \LaTeX\ engine you are running,
864 and then runs the matching one of \cs{SpawnedPDFTeX}, \cs{SpawnedXeTeX},
865 \cs{SpawnedLuaTeX}, or if all the tests fail, \cs{SpawnedTeX}, with the converted
866 \cs{jobname}. These commands all add an engine-selecting option to a base
867 command, \cs{SpawnedCompiler}, which by default is \pkg{latexmk} with synctex
868 enabled, shell escape disabled and interaction set to batch mode. See the
869 \hyperref[sec:switching]{Implementation} section below for details.
870
871 Any of these commands can be pre-defined to something else, depending on what
872 you want to do. So, for example, if you want to change the base \pkg{latexmk}
873 options, pre-define \cs{SpawnedCompiler} to \texttt{latexmk} plus your chosen
874 options:
875
876 \begin{dispListing}
877 \newcommand*{\SpawnedCompiler}{%
878 latexmk -silent -shell-escape -interaction=nonstopmode}
879 \documentclass{beamerswitch}
880 \end{dispListing}
881
882 If you want to switch to using \texttt{rubber}, say, pre-define
883 \cs{SpawnedPDFTeX} and friends accordingly (perhaps taking advantage of
884 \cs{SpawnedCompiler} to reduce repetition):
885
886 \begin{dispListing}
887 \newcommand*{\SpawnedCompiler}{rubber -q --synctex}
888 \newcommand*{\SpawnedPDFTeX}{\SpawnedCompiler -m pdftex}
889 \newcommand*{\SpawnedLuaTeX}{\SpawnedCompiler -m lualatex} % needs v1.6.0+
890 \newcommand*{\SpawnedXeTeX}{\SpawnedCompiler -m xelatex}
891 \documentclass{beamerswitch}
892 \end{dispListing}
893
894 If you don't need the engine selection routine provided, you can replace it
895 by pre-defining \cs{BeamerswitchSpawn} to do whatever you need it to do instead:
896
897 \begin{dispListing}
898 \newcommand*{\BeamerswitchSpawn}[1]{%
899 \ShellEscape{... -jobname=\jobname#1 \jobname}%
900 }
901 \documentclass{beamerswitch}
902 \end{dispListing}
903
904 If you want to use \pkg{arara} to compile everything, the class options won't
905 help you as \pkg{arara} does not let you change \cs{jobname}s on the command line.
906 That's no problem, though, because you can do it manually within your list of
907 directives:
908
909 \begin{dispListing}
910 % arara: lualatex
911 % arara: lualatex: { options: "-jobname beamerswitch-example-article" }
912 % arara: lualatex: { options: "-jobname beamerswitch-example-handout" }
913 % arara: lualatex: { options: "-jobname beamerswitch-example-trans" }
914 \documentclass{beamerswitch}
915 \end{dispListing}
916
917 \subsection{Improving compatibility}
918
919 \begin{docKey}{nohyperref}{}{no value, initially unset}
920 The \pkg{beamer} class loads \pkg{hyperref} for you, but when you switch to \key{article} mode, \pkg{beamerarticle} doesn't, so it is easy for you to get
921 caught out. To protect you from this, \pkg{beamerswitch} \emph{does} load
922 \pkg{hyperref} in \key{article} mode, with the pleasing side effect that
923 \cs{subject} and \cs{keywords} then work as intended instead of throwing
924 errors.
925
926 \medskip
927 To achieve this, the class has to load \pkg{hyperref} quite early on, which
928 can cause trouble with certain other packages. If you would rather
929 load \pkg{hyperref} yourself at a different point, use this option.
930 \end{docKey}
931
932 \section{Setting the layout of the handouts}
933
934 The class provides a simplified interface to the \pkg{pgfpages} package. By
935 default, it prints six slides to a side of A4 paper, but you can change this by
936 using the following command in the preamble.
937
938 \begin{docCommand}{handoutlayout}{\marg{options}}
939 Configures the layout of the page when using \key{handout} mode. It has no
940 effect in other modes. The available \meta{options} are listed below.
941 \end{docCommand}
942
943 \begin{docKey}{paper}{=\meta{paper size}}{no default, initially \val{a4paper}}
944 Selects the size of paper to use for \key{handout} mode. The value is passed
945 directly to \pkg{pgfpages}, so consult the documentation of that package for
946 the allowed values. You can find them under the documentation for the
947 \key{resize to} layout.
948 \end{docKey}
949
950 \begin{docKey}{nup}{=\val{1}\textbar \val{1plus}\textbar \val{2}\textbar \val{3}\textbar \val{3plus}\textbar \val{4}\textbar \val{4plus}\textbar \val{6}\textbar \val{8}}{no default, initially \val{6}}
951 Selects how many slides are shown on a single page in \key{handout} mode.
952 The `plus' layouts leave blank space for recipients to make handwritten notes
953 next to each slide. The effects of the various values are shown in Figure~\ref{fig:layouts} on page~\pageref{fig:layouts}. Note that the \val{2}, \val{3plus}, \val{4}
954 and \val{6} layouts are intended for slides in the usual 4:3 aspect ratio,
955 while the \val{3}, \val{4plus} and \val{8} layouts are intended for widescreen
956 slides.
957 \end{docKey}
958
959 \newtcolorbox{pseudopage}[1][]%
960 {sharp corners
961 ,width=7.1em
962 ,halign=flush center
963 ,height=10em
964 ,valign=center
965 ,size=fbox
966 ,boxrule=0.5mm
967 ,colback=yellow!5
968 ,#1
969 }
970 \newtcolorbox{pseudoslide}[1][]%
971 {nobeforeafter
972 ,width=3em
973 ,halign=flush center
974 ,height=2.25em
975 ,valign=center
976 ,size=fbox
977 ,boxrule=0.5mm
978 ,colframe=ExampleFrame
979 ,colback=ExampleBack
980 ,#1
981 }
982 \newtcolorbox{pseudowideslide}[1][]%
983 {nobeforeafter
984 ,width=3em
985 ,halign=flush center
986 ,height=1.69em
987 ,valign=center
988 ,size=fbox
989 ,boxrule=0.5mm
990 ,colframe=ExampleFrame
991 ,colback=ExampleBack
992 ,#1
993 }
994 \begin{figure}[t!]
995 \newcounter{subfig}%
996 \def\sfno{\rule[-\bigskipamount]{0pt}{1em}\stepcounter{subfig}(\alph{subfig})\space}%
997 \centering
998 \begin{minipage}[b]{11em}
999 \centering
1000 \begin{pseudopage}[width=10em,height=7.1em]
1001 \begin{pseudoslide}[width=8em,height=6em]
1002 \texttt{1}
1003 \end{pseudoslide}
1004 \end{pseudopage}
1005 \par
1006 \sfno\key{nup}=\docValue{1}
1007 \end{minipage}
1008 \begin{minipage}[b]{11em}
1009 \centering
1010 \begin{pseudopage}
1011 \begin{pseudoslide}[width=6em,height=4.5em]
1012 \texttt{1}
1013 \end{pseudoslide}\par\smallskip
1014 \vbox to 4.5em{}
1015 \end{pseudopage}
1016 \par
1017 \sfno\key{nup}=\docValue{1plus}
1018 \end{minipage}
1019 \begin{minipage}[b]{11em}
1020 \centering
1021 \begin{pseudopage}
1022 \begin{pseudoslide}[width=6em,height=4.5em]
1023 \texttt{1}
1024 \end{pseudoslide}\par\smallskip
1025 \begin{pseudoslide}[width=6em,height=4.5em]
1026 \texttt{2}
1027 \end{pseudoslide}
1028 \end{pseudopage}
1029 \par
1030 \sfno\key{nup}=\docValue{2}
1031 \end{minipage}
1032 \begin{minipage}[b]{11em}
1033 \centering
1034 \begin{pseudopage}
1035 \begin{pseudowideslide}[width=4.89em,height=2.75em]
1036 \texttt{1}
1037 \end{pseudowideslide}
1038 \par\smallskip
1039 \begin{pseudowideslide}[width=4.89em,height=2.75em]
1040 \texttt{2}
1041 \end{pseudowideslide}
1042 \par\smallskip
1043 \begin{pseudowideslide}[width=4.89em,height=2.75em]
1044 \texttt{3}
1045 \end{pseudowideslide}
1046 \end{pseudopage}
1047 \par
1048 \sfno\key{nup}=\docValue{3}
1049 \end{minipage}
1050 \begin{minipage}[b]{11em}
1051 \centering
1052 \begin{pseudopage}[halign=flush left]
1053 \begin{pseudoslide}\texttt{1}\end{pseudoslide}
1054 \par\medskip
1055 \begin{pseudoslide}\texttt{2}\end{pseudoslide}
1056 \par\medskip
1057 \begin{pseudoslide}\texttt{3}\end{pseudoslide}
1058 \end{pseudopage}
1059 \par
1060 \sfno\key{nup}=\docValue{3plus}
1061 \end{minipage}
1062 \begin{minipage}[b]{11em}
1063 \centering
1064 \begin{pseudopage}[width=10em,height=7.1em]
1065 \begin{pseudoslide}[width=4em,height=3em]
1066 \texttt{1}
1067 \end{pseudoslide}\enspace
1068 \begin{pseudoslide}[width=4em,height=3em]
1069 \texttt{2}
1070 \end{pseudoslide}\par\smallskip
1071 \begin{pseudoslide}[width=4em,height=3em]
1072 \texttt{3}
1073 \end{pseudoslide}\enspace
1074 \begin{pseudoslide}[width=4em,height=3em]
1075 \texttt{4}
1076 \end{pseudoslide}
1077 \end{pseudopage}
1078 \par
1079 \sfno\key{nup}=\docValue{4}
1080 \end{minipage}
1081 \begin{minipage}[b]{11em}
1082 \centering
1083 \begin{pseudopage}[halign=flush left]
1084 \begin{pseudowideslide}\texttt{1}\end{pseudowideslide}
1085 \par\medskip
1086 \begin{pseudowideslide}\texttt{2}\end{pseudowideslide}
1087 \par\medskip
1088 \begin{pseudowideslide}\texttt{3}\end{pseudowideslide}
1089 \par\medskip
1090 \begin{pseudowideslide}\texttt{4}\end{pseudowideslide}
1091 \end{pseudopage}
1092 \par
1093 \sfno\key{nup}=\docValue{4plus}
1094 \end{minipage}
1095 \begin{minipage}[b]{11em}
1096 \centering
1097 \begin{pseudopage}
1098 \begin{pseudoslide}\texttt{1}\end{pseudoslide}
1099 \begin{pseudoslide}\texttt{2}\end{pseudoslide}
1100 \par\medskip
1101 \begin{pseudoslide}\texttt{3}\end{pseudoslide}
1102 \begin{pseudoslide}\texttt{4}\end{pseudoslide}
1103 \par\medskip
1104 \begin{pseudoslide}\texttt{5}\end{pseudoslide}
1105 \begin{pseudoslide}\texttt{6}\end{pseudoslide}
1106 \end{pseudopage}
1107 \par
1108 \sfno\key{nup}=\docValue{6}
1109 \end{minipage}
1110 \begin{minipage}[b]{11em}
1111 \centering
1112 \begin{pseudopage}
1113 \begin{pseudowideslide}\texttt{1}\end{pseudowideslide}
1114 \begin{pseudowideslide}\texttt{2}\end{pseudowideslide}
1115 \par\medskip
1116 \begin{pseudowideslide}\texttt{3}\end{pseudowideslide}
1117 \begin{pseudowideslide}\texttt{4}\end{pseudowideslide}
1118 \par\medskip
1119 \begin{pseudowideslide}\texttt{5}\end{pseudowideslide}
1120 \begin{pseudowideslide}\texttt{6}\end{pseudowideslide}
1121 \par\medskip
1122 \begin{pseudowideslide}\texttt{7}\end{pseudowideslide}
1123 \begin{pseudowideslide}\texttt{8}\end{pseudowideslide}
1124 \end{pseudopage}
1125 \par
1126 \sfno\key{nup}=\docValue{8}
1127 \end{minipage}
1128 \\
1129 \caption{Handout layouts provided by \pkg{beamerswitch}}
1130 \label{fig:layouts}
1131 \end{figure}
1132
1133 \begin{docKey}{pnos}{}{no value, initially unset}
1134 Adds page numbers to the bottom of each page. The number appears at a distance
1135 of \cs{handoutpnobaseline} (initially 5mm) from the bottom edge of the page.
1136 You can change this before calling \cs{handoutlayout}, if you like, using the
1137 usual mechanisms (e.g.\@ \cs{setlength}).
1138 \end{docKey}
1139
1140 \begin{docKey}{border}{=\meta{length}}{default 0.4pt, initially 0pt}
1141 Puts a rectangular border of thickness \meta{length} around each slide.
1142 \end{docKey}
1143
1144 \begin{docKey}{margin}{=\meta{length}}{default 0pt, initially 5mm}
1145 Sets how much extra space to leave around each slide on the page. To achieve
1146 this it uses the \key{border shrink} option from \pkg{pgfpages}. If you add
1147 page numbers, this value will increase if necessary to prevent the number
1148 colliding with the slides, so treat it as a minimum.
1149 \end{docKey}
1150
1151 \begin{docKey}{align}{}{no value, initially unset}
1152 When \key{margin} is non-zero, the effective page margins are approximately
1153 half the size of the gaps between slides (some additional white space comes
1154 from preserving the aspect ratio of the slides). When set, this option tweaks
1155 the positions of the slides so that the page margins are approximately the
1156 same as the interior gaps.
1157 \end{docKey}
1158
1159 \section{Changing the look of article mode}
1160
1161 Some additional options can be set by using the following command in the
1162 preamble.
1163
1164 \begin{docCommand}{articlelayout}{\marg{options}}
1165 Configures the appearance of \key{article} mode. It has no effect in other
1166 modes. The available \meta{options} are listed below.
1167 \end{docCommand}
1168
1169 \begin{docKey}{frametitles}{=\val{para}\textbar\val{margin}\textbar\val{none}}{no default, initially \val{para}}
1170 In \key{article} mode, affects how frame titles are printed. By default,
1171 \pkg{beamerarticle} prints them as paragraph headings, represented by
1172 the value \docValue{para}. To have them printed in the margin (using
1173 \cs{marginpar}), use \docValue{margin}. To omit them altogether, use the value
1174 \docValue{none}.
1175 \end{docKey}
1176
1177 \begin{docKey}{maketitle}{}{no value, initially unset}
1178 In \key{article} mode, adjusts the \cs{maketitle} routine:
1179 \begin{itemize}
1180 \item
1181 The title is printed closer to the top margin.
1182 \item
1183 The subtitle is shown joined to the title using a colon (rather than on a
1184 new line).
1185 \item
1186 The institute is shown directly beneath the author name, similar to the
1187 \pkg{beamer} layout, so you can use \cs{inst} just as in \pkg{beamer} to tie
1188 authors to their affiliations.
1189 \end{itemize}
1190
1191 If you have \pkg{xparse} (and hence \pkg{expl3}) installed, the class will
1192 detect cases where your title ends in a character like `?' and will not add a
1193 colon to it in that case. You can also suppress the colon manually with the
1194 following code (add it \emph{after} using \cs{title} if automatic detection is
1195 in effect):
1196
1197 \begin{dispListing}
1198 \toggletrue{titlepunct}
1199 \end{dispListing}
1200 \end{docKey}
1201
1202 \begin{docKey}{instbreak}{=\meta{definition}}{no default, initially \cs{linebreak}}
1203 In \key{article} mode, defines how \cs{and} is rendered when
1204 \cs{insertinstitute} is used (such when the \key{maketitle} option is
1205 active). Another good \meta{definition} to use might be \cs{quad}.
1206 \end{docKey}
1207
1208
1209 \section{Tips for further configuration}
1210
1211 There are some other ways to customize the behaviour of the various modes.
1212
1213 You can use the standard \LaTeX\ methods for customizing how the \pkg{article}
1214 and \pkg{beamer} classes are loaded, if you don't like the class facilities for
1215 doing this:
1216
1217 \begin{dispListing}
1218 \PassOptionsToClass{a4paper,11pt}{article} % for article mode
1219 \PassOptionsToClass{utf8}{beamer} % for beamer, handout, trans modes
1220 \documentclass{beamerswitch}
1221 \end{dispListing}
1222
1223 And of course there is the standard \pkg{beamer} way of passing different
1224 options to different modes:
1225
1226 \begin{dispListing}
1227 \documentclass{beamerswitch}
1228 \mode<article>{
1229 \usepackage[utf8]{inputenc}
1230 }
1231 \mode<beamer>{
1232 \setbeameroption{second mode text on second screen}
1233 }
1234 \end{dispListing}
1235
1236 \section{Feedback}
1237
1238 I hope you find this class useful. Please report any bugs and add any
1239 suggestions for improvements or new features to the
1240 \href{https://github.com/alex-ball/beamerswitch/issues}{Issue Tracker} on GitHub.
1241
1242 \StopEventually{^^A
1243 \newpage
1244 \PrintChanges
1245 \printindex
1246 }
1247
1248 \newpage
1249 \section{Implementation}\label{sec:implementation}
1250
1251 \setcounter{FancyVerbLine}{18}%
1252 \DocInput{\jobname.dtx}
1253 \end{document}
1254 %</driver>
1255 % \fi
1256 % \iffalse
1257 %<*class>
1258 % \fi
1259 %
1260 % \subsection{Dependencies}
1261 %
1262 % We use the following packages:
1263 % \begin{itemize}
1264 % \item
1265 % \pkg{xkeyval} with \pkg{xkvltxp} for setting options
1266 % \item
1267 % \pkg{etoolbox} for command patches and list processing
1268 % \item
1269 % \pkg{xstring} for comparisons
1270 % \item
1271 % \pkg{shellesc} for running parallel compilations
1272 % \item
1273 % \pkg{iftex} for determining which engine to use
1274 % \item
1275 % \pkg{expl3} for cleaning options passed onward to underlying classes.
1276 % \end{itemize}
1277 %
1278 % \begin{macrocode}
1279 \RequirePackage{xkeyval,xkvltxp,etoolbox,xstring,shellesc,iftex,expl3}
1280 % \end{macrocode}
1281 %
1282 % \subsection{Class options}
1283 %
1284 % We recognize four main modes of operation: `beamer', `trans', `handout', and
1285 % `article'.
1286 %
1287 % \begin{optionkey}{beamer}
1288 % The \key{beamer} option triggers beamer mode.
1289 %
1290 % \begin{macrocode}
1291 \define@boolkey[DC]{beamerswitch}{beamer}[true]{%
1292 \ifbool{DC@beamerswitch@beamer}{%
1293 \setkeys[DC]{beamerswitch}{trans=false}
1294 \setkeys[DC]{beamerswitch}{handout=false}
1295 \setkeys[DC]{beamerswitch}{article=false}
1296 }{}%
1297 }
1298 % \end{macrocode}
1299 % \end{optionkey}
1300 %
1301 % \begin{optionkey}{trans}
1302 % The \key{trans} option triggers trans mode.
1303 %
1304 % \begin{macrocode}
1305 \define@boolkey[DC]{beamerswitch}{trans}[true]{%
1306 \ifbool{DC@beamerswitch@trans}{%
1307 \setkeys[DC]{beamerswitch}{beamer=false}
1308 \setkeys[DC]{beamerswitch}{handout=false}
1309 \setkeys[DC]{beamerswitch}{article=false}
1310 }{}%
1311 }
1312 % \end{macrocode}
1313 % \end{optionkey}
1314 %
1315 % \begin{optionkey}{handout}
1316 % The \key{handout} option triggers handout mode.
1317 %
1318 % \begin{macrocode}
1319 \define@boolkey[DC]{beamerswitch}{handout}[true]{%
1320 \ifbool{DC@beamerswitch@handout}{%
1321 \setkeys[DC]{beamerswitch}{beamer=false}
1322 \setkeys[DC]{beamerswitch}{trans=false}
1323 \setkeys[DC]{beamerswitch}{article=false}
1324 }{}%
1325 }
1326 % \end{macrocode}
1327 % \end{optionkey}
1328 %
1329 % \begin{optionkey}{article}
1330 % The \key{article} option triggers article mode.
1331 %
1332 % \begin{macrocode}
1333 \define@boolkey[DC]{beamerswitch}{article}[true]{%
1334 \ifbool{DC@beamerswitch@article}{%
1335 \setkeys[DC]{beamerswitch}{beamer=false}
1336 \setkeys[DC]{beamerswitch}{trans=false}
1337 \setkeys[DC]{beamerswitch}{handout=false}
1338 }{}%
1339 }
1340 % \end{macrocode}
1341 % \end{optionkey}
1342 %
1343 % \begin{optionkey}{also}
1344 % \begin{optionkey}{alsobeamer}
1345 % \begin{optionkey}{alsotrans}
1346 % \begin{optionkey}{alsohandout}
1347 % \begin{optionkey}{alsoarticle}
1348 % \begin{macro}{beamerswitch@SetAlso}
1349 % The \key{also} option allows the user to specify a set of alternative modes
1350 % to typeset in parallel, in a comma-separated list. Alternatively, the user
1351 % can specify the Boolean \key{also*} options directly.
1352 %
1353 % \begin{macrocode}
1354 \define@boolkey[DC]{beamerswitch}{alsobeamer}[true]{}
1355 \define@boolkey[DC]{beamerswitch}{alsotrans}[true]{}
1356 \define@boolkey[DC]{beamerswitch}{alsohandout}[true]{}
1357 \define@boolkey[DC]{beamerswitch}{alsoarticle}[true]{}
1358 \newcommand{\beamerswitch@SetAlso}[1]{%
1359 \key@ifundefined[DC]{beamerswitch}{also#1}{%
1360 \ClassWarning{beamerswitch}{`#1' is not a valid value for option `also'}%
1361 }{%
1362 \setkeys[DC]{beamerswitch}{also#1}%
1363 }%
1364 }
1365 \define@key[DC]{beamerswitch}{also}{%
1366 \forcsvlist{\beamerswitch@SetAlso}{#1}%
1367 }
1368 % \end{macrocode}
1369 % \end{macro}
1370 % \end{optionkey}
1371 % \end{optionkey}
1372 % \end{optionkey}
1373 % \end{optionkey}
1374 % \end{optionkey}
1375 %
1376 % \changes{v1.8}{2021/04/12}{Add \key{beameroptions} option.}
1377 % \begin{optionkey}{beameroptions}
1378 %
1379 % The \key{beameroptions} will passed to the \pkg{beamer} class.
1380 %
1381 % \begin{macrocode}
1382 \define@cmdkey[DC]{beamerswitch}{beameroptions}[ignorenonframetext]{}
1383 % \end{macrocode}
1384 % \end{optionkey}
1385 %
1386 % \changes{v1.9}{2022/08/20}{Add \key{articleclass} option.}
1387 % \begin{optionkey}{articleclass}
1388 %
1389 % The \key{articleclass} option allows the class used for article mode
1390 % to be customized.
1391 %
1392 % \begin{macrocode}
1393 \define@cmdkey[DC]{beamerswitch}{articleclass}[article]{}
1394 % \end{macrocode}
1395 % \end{optionkey}
1396 %
1397 % \changes{v1.8}{2021/04/12}{Add \key{articleoptions} option.}
1398 % \begin{optionkey}{articleoptions}
1399 %
1400 % The \key{articleoptions} will passed to the class used for
1401 % \key{article} mode.
1402 %
1403 % \begin{macrocode}
1404 \define@cmdkey[DC]{beamerswitch}{articleoptions}[]{}
1405 % \end{macrocode}
1406 % \end{optionkey}
1407 %
1408 % \begin{optionkey}{nohyperref}
1409 % The \key{nohyperref} option stops the class from loading the \pkg{hyperref}
1410 % package in article mode.
1411 %
1412 % \begin{macrocode}
1413 \define@boolkey[DC]{beamerswitch}{nohyperref}[true]{}
1414 % \end{macrocode}
1415 % \end{optionkey}
1416 %
1417 % \changes{v1.8}{2021/04/12}{Deprecate redundant \key{textinst} option.}
1418 % \begin{optionkey}{textinst}
1419 % The \key{textinst} option enforces \cs{textsuperscript} for institution
1420 % markers. Recent versions of \pkg{beamer} do this by default.
1421 %
1422 % \begin{macrocode}
1423 \define@boolkey[DC]{beamerswitch}{textinst}[true]{}
1424 % \end{macrocode}
1425 % \end{optionkey}
1426 %
1427 % The default behaviour is to use beamer mode only.
1428 %
1429 % \begin{macrocode}
1430 \setkeys[DC]{beamerswitch}{beamer=true,alsobeamer=false,alsotrans=false,%
1431 alsohandout=false,alsoarticle=false,beameroptions,articleclass,%
1432 articleoptions}
1433 % \end{macrocode}
1434 %
1435 % Now we process the options given by the user.
1436 %
1437 % \begin{macrocode}
1438 \ProcessOptionsX[DC]<beamerswitch>
1439 % \end{macrocode}
1440 %
1441 % We remove problematic whitespace from \key{articleoptions} and
1442 % \key{beameroptions}.
1443 %
1444 % \begin{macrocode}
1445 \ExplSyntaxOn
1446 \tl_replace_all:Nnn \cmdDC@beamerswitch@articleoptions { ,~ } { , }
1447 \tl_replace_all:Nnn \cmdDC@beamerswitch@beameroptions { ,~ } { , }
1448 \ExplSyntaxOff
1449 % \end{macrocode}
1450 %
1451 % \subsection{Jobname-based mode switching}\label{sec:switching}
1452 %
1453 % \begin{macro}{BeamerSuffix}
1454 % \begin{macro}{TransSuffix}
1455 % \begin{macro}{HandoutSuffix}
1456 % \begin{macro}{ArticleSuffix}
1457 % We define some default values for the special suffixes.
1458 %
1459 % \begin{macrocode}
1460 \providecommand*{\BeamerSuffix}{-slides}
1461 \providecommand*{\TransSuffix}{-trans}
1462 \providecommand*{\HandoutSuffix}{-handout}
1463 \providecommand*{\ArticleSuffix}{-article}
1464 % \end{macrocode}
1465 % \end{macro}
1466 % \end{macro}
1467 % \end{macro}
1468 % \end{macro}
1469 %
1470 % \begin{macro}{BeamerswitchSpawn}
1471 % \changes{v1.3}{2017/12/10}{Decompose \cs{BeamerswitchSpawn} into further configurable macros.}
1472 % \begin{macro}{SpawnedTeX}
1473 % \begin{macro}{SpawnedPDFTeX}
1474 % \begin{macro}{SpawnedXeTeX}
1475 % \begin{macro}{SpawnedLuaTeX}
1476 % \begin{macro}{SpawnedCompiler}
1477 % We provide a special routine for spawning new \LaTeX\ processes. We allow
1478 % for the possibility of the user overriding this routine with another one,
1479 % perhaps using a different automation tool; it should take one argument, being
1480 % the jobname suffix.
1481 %
1482 % \begin{macrocode}
1483 \providecommand{\SpawnedCompiler}{latexmk -silent -synctex=1 -interaction=batchmode }
1484 \providecommand{\SpawnedTeX}{\SpawnedCompiler}
1485 \providecommand{\SpawnedPDFTeX}{\SpawnedCompiler -pdf }
1486 \providecommand{\SpawnedLuaTeX}{\SpawnedCompiler -pdflua }
1487 \providecommand{\SpawnedXeTeX}{\SpawnedCompiler -pdfxe }
1488 \providecommand{\BeamerswitchSpawn}[1]{%
1489 \ifbool{PDFTeX}{%
1490 \ShellEscape{\SpawnedPDFTeX -jobname=\jobname#1 \jobname}
1491 }{%
1492 \ifbool{LuaTeX}{%
1493 \ShellEscape{\SpawnedLuaTeX -jobname=\jobname#1 \jobname}
1494 }{%
1495 \ifbool{XeTeX}{%
1496 \ShellEscape{\SpawnedXeTeX -jobname=\jobname#1 \jobname}
1497 }{%
1498 \ShellEscape{\SpawnedTeX -jobname=\jobname#1 \jobname}
1499 }%
1500 }%
1501 }%
1502 }
1503 % \end{macrocode}
1504 % \end{macro}
1505 % \end{macro}
1506 % \end{macro}
1507 % \end{macro}
1508 % \end{macro}
1509 % \end{macro}
1510 %
1511 % \begin{macro}{JobName}
1512 % \changes{v1.6}{2019/06/06}{Fix bug triggered by spaces in job names.}
1513 % We check for special jobnames and use them to override the above mode-related
1514 % options. In certain circumstances, the jobname is wrapped in quote marks, so
1515 % in that case we strip them off before running the tests.
1516 %
1517 % \begin{macrocode}
1518 \IfBeginWith*{\jobname}{"}{%
1519 \IfEndWith*{\jobname}{"}{%
1520 \StrGobbleLeft{\jobname}{1}[\JobName]%
1521 \StrGobbleRight{\JobName}{1}[\JobName]%
1522 }{\let\JobName\jobname}%
1523 }{\let\JobName\jobname}
1524 % \end{macrocode}
1525 % \end{macro}
1526 %
1527 % Now we run the tests. Note that the \key{also*} options are only acted upon
1528 % if the all the tests fail.
1529 %
1530 % \begin{macrocode}
1531 \IfEndWith*{\JobName}{\BeamerSuffix}{%
1532 \setkeys[DC]{beamerswitch}{beamer=true}
1533 }{%
1534 \IfEndWith*{\JobName}{\TransSuffix}{%
1535 \setkeys[DC]{beamerswitch}{trans=true}
1536 }{%
1537 \IfEndWith*{\JobName}{\HandoutSuffix}{%
1538 \setkeys[DC]{beamerswitch}{handout=true}
1539 }{%
1540 \IfEndWith*{\JobName}{\ArticleSuffix}{%
1541 \setkeys[DC]{beamerswitch}{article=true}
1542 }{%
1543 \ifbool{DC@beamerswitch@alsobeamer}{%
1544 \BeamerswitchSpawn{\BeamerSuffix}%
1545 }{}
1546 \ifbool{DC@beamerswitch@alsotrans}{%
1547 \BeamerswitchSpawn{\TransSuffix}%
1548 }{}
1549 \ifbool{DC@beamerswitch@alsohandout}{%
1550 \BeamerswitchSpawn{\HandoutSuffix}%
1551 }{}
1552 \ifbool{DC@beamerswitch@alsoarticle}{%
1553 \BeamerswitchSpawn{\ArticleSuffix}%
1554 }{}
1555 }%
1556 }%
1557 }%
1558 }%
1559 % \end{macrocode}
1560 %
1561 % \subsection{Setting up modes}
1562 %
1563 % \begin{macro}{beamer@insttitle}
1564 % \begin{macro}{beamer@andtitle}
1565 % \begin{macro}{beamer@instinst}
1566 % \begin{macro}{beamer@andinst}
1567 % For article mode, we load the class selected by the \key{articleclass}
1568 % option and require the \pkg{beamerarticle} support package.
1569 % We also add some beamer base macros that are needed for the
1570 % \cs{insertinstitute} command.
1571 %
1572 % \begin{macrocode}
1573 \ifbool{DC@beamerswitch@article}{%
1574 \PassOptionsToClass{\cmdDC@beamerswitch@articleoptions}{%
1575 \cmdDC@beamerswitch@articleclass}
1576 \LoadClass{\cmdDC@beamerswitch@articleclass}
1577 \RequirePackage{beamerarticle}
1578 \def\beamer@insttitle#1{\textsuperscript{#1}}
1579 \def\beamer@andtitle{\quad}
1580 \def\beamer@instinst#1{\textsuperscript{#1}\ignorespaces}
1581 \def\beamer@andinst{\linebreak}
1582 % \end{macrocode}
1583 % \end{macro}
1584 % \end{macro}
1585 % \end{macro}
1586 % \end{macro}
1587 %
1588 % It seems as though \pkg{beamerarticle} expects \pkg{hyperref} to be loaded,
1589 % but doesn't actually do it itself. So we oblige, using the default options
1590 % specified by \pkg{beamer}.
1591 %
1592 % \begin{macrocode}
1593 \ifbool{DC@beamerswitch@nohyperref}{}{%
1594 \RequirePackage[bookmarks=true,%
1595 bookmarksopen=true,%
1596 pdfborder={0 0 0},%
1597 pdfhighlight={/N},%
1598 linkbordercolor={.5 .5 .5}]{hyperref}%
1599 }
1600 % \end{macrocode}
1601 %
1602 % While \pkg{beamer} takes care of adding presentation metadata to the PDF
1603 % properties, \pkg{beamerarticle} misses the title and author properties. (It
1604 % does manage to set the subject and keywords, though.) We achieve parity with
1605 % some additional \cs{hypersetup}. Note that \pkg{beamerarticle} appends the
1606 % subtitle to \cs{@title} with a linebreak and this does odd things in the
1607 % context of \key{pdftitle}, so we fix it with \cs{pdfstringdefDisableCommands}.
1608 %
1609 % \begin{macrocode}
1610 \AtBeginDocument{%
1611 \@ifpackageloaded{hyperref}{%
1612 \pdfstringdefDisableCommands{\def\\<#1>#2{ - #2}}
1613 \begingroup
1614 \hypersetup{pdftitle={\@title}}%
1615 \def\and{\unskip, }%
1616 \let\thanks=\@gobble
1617 \let\inst=\@gobble
1618 \hypersetup{pdfauthor={\@author}}%
1619 \endgroup
1620 }{}%
1621 }
1622 }{%
1623 % \end{macrocode}
1624 %
1625 % For the presentation modes, we load the \pkg{beamer} class with the
1626 % appropriate mode option as well those chosen using \key{beameroptions}.
1627 %
1628 % Handout mode lays multiple slides out on a single page. For this we use
1629 % \pkg{pgfpages}. The actual configuration is handled later.
1630 %
1631 % \begin{macrocode}
1632 \ifbool{DC@beamerswitch@handout}{%
1633 \PassOptionsToClass{\cmdDC@beamerswitch@beameroptions}{beamer}
1634 \LoadClass[handout]{beamer}
1635 \RequirePackage{pgfpages}
1636 }{%
1637 \ifbool{DC@beamerswitch@trans}{%
1638 \PassOptionsToClass{\cmdDC@beamerswitch@beameroptions}{beamer}
1639 \LoadClass[trans]{beamer}
1640 }{%
1641 \PassOptionsToClass{\cmdDC@beamerswitch@beameroptions}{beamer}
1642 \LoadClass{beamer}
1643 }%
1644 }
1645 }
1646 % \end{macrocode}
1647 %
1648 % \subsection{Mode-independent layout}
1649 %
1650 % \begin{macro}{beamer@insttitle}
1651 % \begin{macro}{beamer@instinst}
1652 % We implement the option that formats institution markers in text mode rather
1653 % than math mode in older versions of \pkg{beamer}.
1654 %
1655 % \begin{macrocode}
1656 \ifbool{DC@beamerswitch@textinst}{%
1657 \def\beamer@insttitle#1{\textsuperscript{#1}}
1658 \def\beamer@instinst#1{\textsuperscript{#1}\ignorespaces}
1659 }{}
1660 % \end{macrocode}
1661 % \end{macro}
1662 % \end{macro}
1663 %
1664 % \begin{macro}{handoutlayout}
1665 % \subsection{Handout layout}
1666 %
1667 % \begin{optionkey}{paper}
1668 % \begin{macro}{beamerswitch@handoutpaper}
1669 % In theory it would be nice to anticipate the paper size that the article mode
1670 % would use, and pass that as an option to \cs{pgfpagesuselayout} but as that's
1671 % unlikely to be clean code, we settle here for setting it with an option.
1672 %
1673 % \begin{macrocode}
1674 \def\beamerswitch@handoutpaper{a4paper}
1675 \define@key[HL]{beamerswitch}{paper}{%
1676 \def\beamerswitch@handoutpaper{#1}%
1677 }
1678 % \end{macrocode}
1679 % \end{macro}
1680 % \end{optionkey}
1681 %
1682 % \begin{optionkey}{nup}
1683 % \begin{optionvalue}{1}
1684 % \begin{optionvalue}{1plus}
1685 % \begin{optionvalue}{2}
1686 % \begin{optionvalue}{3}
1687 % \begin{optionvalue}{3plus}
1688 % \begin{optionvalue}{4}
1689 % \begin{optionvalue}{4plus}
1690 % \begin{optionvalue}{6}
1691 % \begin{optionvalue}{8}
1692 % \changes{v1.7}{2020/06/06}{Add \key{nup}!=\val{1} option.}
1693 % \changes{v1.7}{2020/06/06}{Add \key{nup}!=\val{1plus} option.}
1694 % The \key{nup} option specifies how many slides to include per page.
1695 % The `plus' keyword indicates a layout with additional gaps for writing.
1696 %
1697 % \begin{macrocode}
1698 \newcounter{beamerswitch@nupcase}
1699 \setcounter{beamerswitch@nupcase}{7}
1700 \define@choicekey+[HL]{beamerswitch}{nup}[\val\nr]{1, 1plus, 2, 3, 3plus, 4, 4plus, 6, 8}{%
1701 \setcounter{beamerswitch@nupcase}{\nr}
1702 }{%
1703 \ClassWarning{beamerswitch}{Value of `nup' not recognized.
1704 Allowed values are 1, 1plus, 2, 3, 3plus, 4, 4plus, 6, and 8.}%
1705 }
1706 % \end{macrocode}
1707 % \end{optionvalue}
1708 % \end{optionvalue}
1709 % \end{optionvalue}
1710 % \end{optionvalue}
1711 % \end{optionvalue}
1712 % \end{optionvalue}
1713 % \end{optionvalue}
1714 % \end{optionvalue}
1715 % \end{optionvalue}
1716 % \end{optionkey}
1717 %
1718 % \begin{optionkey}{border}
1719 % \begin{macro}{beamerswitch@Border}
1720 % \changes{v1.5}{2019/01/28}{Remove empty frames from end of handout.}
1721 % The \key{borders} option switches on borders around the slides on handout
1722 % pages (and gaps where slides would appear if there were enough). The value
1723 % is used to set the width of the border.
1724 %
1725 % This is implemented as a PGF drawing command, which is initially set up to do
1726 % nothing but gets filled out if the option is selected. As part of this, we
1727 % calculate the number of the current slide (|handoutpno| gives the current page
1728 % number minus one; \cs{beamerswitch@nup} is the number of slides per page;
1729 % and \cs{pgf@cpn} gives the count of the current slide on the current page).
1730 % If this exceeds the total number of slides, we suppress the border.
1731 %
1732 % \begin{macrocode}
1733 \newcommand*{\beamerswitch@Border}{\relax}
1734 \define@key[HL]{beamerswitch}{border}[0.4pt]{%
1735 \RequirePackage{pgf}%
1736 \ifdimcomp{#1}{>}{0pt}{%
1737 \renewcommand*{\beamerswitch@Border}{%
1738 \ifnumcomp{(\value{handoutpno} * \beamerswitch@nup) + \the\pgf@cpn}%
1739 {>}{\beamer@endpageofdocument}{%
1740 \relax
1741 }{%
1742 \pgfsetlinewidth{#1}\pgfstroke
1743 }%
1744 }%
1745 }{%
1746 \renewcommand*{\beamerswitch@Border}{\relax}%
1747 }%
1748 }
1749 % \end{macrocode}
1750 % \end{macro}
1751 % \end{optionkey}
1752 %
1753 % \begin{optionkey}{margin}
1754 % \changes{v1.4}{2018/08/29}{Make margins around slides a configurable size.}
1755 % \begin{macro}{beamerswitch@margin}
1756 % The \key{margin} option controls how much white space is added around each
1757 % slide on handout pages. It corresponds to the \texttt{border shrink} option
1758 % of \cs{pgfpagesuselayout}.
1759 %
1760 % \begin{macrocode}
1761 \newlength{\beamerswitch@margin}
1762 \setlength{\beamerswitch@margin}{5mm}
1763 \define@key[HL]{beamerswitch}{margin}[0pt]{%
1764 \setlength{\beamerswitch@margin}{#1}%
1765 }
1766 % \end{macrocode}
1767 % \end{macro}
1768 % \end{optionkey}
1769 %
1770 % \begin{optionkey}{align}
1771 % The \key{align} option chooses whether to rejig the positions of the slides
1772 % on the page so that the effective page margin is the same as, rather than
1773 % half, the space between adjacent slides.
1774 %
1775 % \begin{macrocode}
1776 \define@boolkey[HL]{beamerswitch}{align}[true]{}
1777 % \end{macrocode}
1778 % \end{optionkey}
1779 %
1780 % \begin{optionkey}{pnos}
1781 % \begin{macro}{handoutpnobaseline}
1782 % The \key{pnos} option switches on page numbers for handout pages. The height
1783 % at which the baseline of the number sits, relative to the bottom edge of the
1784 % paper, is given by the length \cs{handoutpnobaseline}.
1785 %
1786 % \begin{macrocode}
1787 \newlength{\handoutpnobaseline}
1788 \setlength{\handoutpnobaseline}{5mm}
1789 \newcounter{handoutpno}
1790 \define@boolkey[HL]{beamerswitch}{pnos}[true]{}
1791 % \end{macrocode}
1792 % \end{macro}
1793 % \end{optionkey}
1794 %
1795 % \begin{macro}{beamerswitch@footer}
1796 % In order to implement the page numbers, we need to add a hook to the
1797 % \pkg{pgfpages} shipout routine.
1798 %
1799 % \begin{macrocode}
1800 \def\beamerswitch@footer{}
1801 \patchcmd{\pgfpages@buildshipoutbox}{%
1802 \pgfsys@endpicture
1803 }{%
1804 \beamerswitch@footer\pgfsys@endpicture
1805 }{}{}
1806 % \end{macrocode}
1807 % \end{macro}
1808 %
1809 % \begin{macro}{beamerswitch@pnoadjust}
1810 % We set up the \cs{handoutlayout} command for applying these options.
1811 %
1812 % The hook \cs{beamerswitch@footer} is used to step the page number
1813 % counter |handoutpno|; if page numering is active, it also places the
1814 % number on the page centered and \cs{handoutpnobaseline} up from the
1815 % bottom.
1816 %
1817 % The length \cs{beamerswitch@pnoadjust} is, conceptually, the height
1818 % of the page number. When page numbers are active, the margin around
1819 % slides is automatically increased to guarantee that the top of the
1820 % page number will not be higher than the bottom of the lowest slide.
1821 % Currently this does not account for extra whitespace arising from
1822 % aspect ratio issues. When the \key{align} option is active, the margin
1823 % at the bottom of the page is increased, but to save a register we
1824 % make the adjustment to \cs{beamerswitch@pnoadjust} instead of a copy
1825 % of \cs{beamerswitch@margin}.
1826 %
1827 % \begin{macrocode}
1828 \newlength{\beamerswitch@pnoadjust}
1829 \newcommand*{\handoutlayout}[1]{%
1830 \only<handout>{%
1831 \setlength{\beamerswitch@pnoadjust}{1em}%
1832 \setkeys[HL]{beamerswitch}{#1}%
1833 \ifbool{HL@beamerswitch@pnos}{%
1834 \def\beamerswitch@footer{%
1835 \stepcounter{handoutpno}%
1836 \setbox0\vbox{\makebox[0pt][c]{\arabic{handoutpno}}}%
1837 \pgfsys@beginscope
1838 \pgflowlevel{\pgftransformshift{%
1839 \pgfpoint{.5\pgfphysicalwidth}{\handoutpnobaseline}}}%
1840 \wd0=0pt%
1841 \dp0=-\ht0%
1842 \pgfsys@hbox0%
1843 \pgfsys@endscope
1844 }%
1845 \ifbool{HL@beamerswitch@align}{%
1846 \ifcase\value{beamerswitch@nupcase}\relax
1847 \relax
1848 \or
1849 \addtolength{\beamerswitch@pnoadjust}{-0.333\beamerswitch@margin}%
1850 \or
1851 \addtolength{\beamerswitch@pnoadjust}{-0.333\beamerswitch@margin}%
1852 \or
1853 \addtolength{\beamerswitch@pnoadjust}{-0.5\beamerswitch@margin}%
1854 \or
1855 \addtolength{\beamerswitch@pnoadjust}{-0.5\beamerswitch@margin}%
1856 \or
1857 \addtolength{\beamerswitch@pnoadjust}{-0.333\beamerswitch@margin}%
1858 \or
1859 \addtolength{\beamerswitch@pnoadjust}{-0.6\beamerswitch@margin}%
1860 \or
1861 \addtolength{\beamerswitch@pnoadjust}{-0.5\beamerswitch@margin}%
1862 \or
1863 \addtolength{\beamerswitch@pnoadjust}{-0.6\beamerswitch@margin}%
1864 \fi
1865 }{}%
1866 \ifdimcomp{\beamerswitch@margin}{<}%
1867 {\handoutpnobaseline + \beamerswitch@pnoadjust}{%
1868 \setlength{\beamerswitch@margin}%
1869 {\the\dimexpr\handoutpnobaseline + \beamerswitch@pnoadjust\relax}%
1870 }{}%
1871 }{%
1872 \def\beamerswitch@footer{\stepcounter{handoutpno}}%
1873 }%
1874 % \end{macrocode}
1875 % \end{macro}
1876 %
1877 % \begin{macro}{beamerswitch@nup}
1878 % The value of the \key{nup} option is used both to select the layout
1879 % and set the value of \cs{beamerswitch@nup}. The latter is used to
1880 % suppress unwanted borders and check if \cs{handoutlayout} has been
1881 % called.
1882 %
1883 % \begin{macrocode}
1884 \ifcase\value{beamerswitch@nupcase}\relax
1885 \def\beamerswitch@nup{1}%
1886 \pgfpagesuselayout{1 by 1}[\beamerswitch@handoutpaper,%
1887 landscape,border shrink=\the\beamerswitch@margin]%
1888 \or
1889 \def\beamerswitch@nup{1}%
1890 \pgfpagesuselayout{1 by 1 narrow}[\beamerswitch@handoutpaper,%
1891 border shrink=\the\beamerswitch@margin]%
1892 \or
1893 \def\beamerswitch@nup{2}%
1894 \pgfpagesuselayout{1 by 2}[\beamerswitch@handoutpaper,%
1895 border shrink=\the\beamerswitch@margin]%
1896 \or
1897 \def\beamerswitch@nup{3}%
1898 \pgfpagesuselayout{1 by 3}[\beamerswitch@handoutpaper,%
1899 border shrink=\the\beamerswitch@margin]%
1900 \or
1901 \def\beamerswitch@nup{3}%
1902 \pgfpagesuselayout{1 by 3 narrow}[\beamerswitch@handoutpaper,%
1903 border shrink=\the\beamerswitch@margin]%
1904 \or
1905 \def\beamerswitch@nup{4}%
1906 \pgfpagesuselayout{2 by 2}[\beamerswitch@handoutpaper,%
1907 landscape,border shrink=\the\beamerswitch@margin]%
1908 \or
1909 \def\beamerswitch@nup{4}%
1910 \pgfpagesuselayout{1 by 4 narrow}[\beamerswitch@handoutpaper,%
1911 border shrink=\the\beamerswitch@margin]%
1912 \or
1913 \def\beamerswitch@nup{6}%
1914 \pgfpagesuselayout{2 by 3}[\beamerswitch@handoutpaper,%
1915 border shrink=\the\beamerswitch@margin]%
1916 \or
1917 \def\beamerswitch@nup{8}%
1918 \pgfpagesuselayout{2 by 4}[\beamerswitch@handoutpaper,%
1919 border shrink=\the\beamerswitch@margin]%
1920 \fi
1921 }%
1922 }
1923 % \end{macrocode}
1924 %\end{macro}
1925 %\end{macro}
1926 %
1927 % We initialize the class with the defaults set above.
1928 %
1929 % \begin{macrocode}
1930 \AtEndPreamble{%
1931 \ifdef{\beamerswitch@nup}{}{%
1932 \handoutlayout{}%
1933 }%
1934 }
1935 % \end{macrocode}
1936 %
1937 % Though \pkg{pgfpages} defines some perfectly fine layouts, we need to add
1938 % configurability to the existing ones and provide some new ones.
1939 %
1940 % \changes{v1.7}{2020/06/06}{Add `1 by 1' layout.}
1941 % The `1 by 1' layout has a single slide per page.
1942 %
1943 % \begin{macrocode}
1944 \mode<handout>{%
1945 \pgfpagesdeclarelayout{1 by 1}
1946 {
1947 \edef\pgfpageoptionheight{\the\paperheight}
1948 \edef\pgfpageoptionwidth{\the\paperwidth}
1949 \edef\pgfpageoptionborder{0pt}
1950 \def\pgfpageoptionfirstshipout{1}
1951 }
1952 {
1953 \pgfpagesphysicalpageoptions
1954 {%
1955 logical pages=1,%
1956 physical height=\pgfpageoptionheight,%
1957 physical width=\pgfpageoptionwidth,%
1958 current logical shipout=\pgfpageoptionfirstshipout%
1959 }
1960 \pgfpageslogicalpageoptions{1}
1961 {%
1962 border shrink=\pgfpageoptionborder,%
1963 border code=\beamerswitch@Border,%
1964 resized width=\pgfphysicalwidth,%
1965 resized height=\pgfphysicalheight,%
1966 center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight}%
1967 }%
1968 }%
1969 % \end{macrocode}
1970 %
1971 % \changes{v1.7}{2020/06/06}{Add `1 by 1 narrow' layout.}
1972 % The `1 by 1 narrow' layout is similar to the normal \key{2 on 1} layout, but
1973 % there is a notes area instead of the second slide.
1974 %
1975 % \begin{macrocode}
1976 \pgfpagesdeclarelayout{1 by 1 narrow}
1977 {
1978 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
1979 \edef\pgfpageoptionwidth{\the\paperheight}
1980 \def\pgfpageoptionborder{0pt}
1981 \def\pgfpageoptionfirstshipout{1}
1982 }
1983 {
1984 \pgfpagesphysicalpageoptions
1985 {%
1986 logical pages=1,%
1987 physical height=\pgfpageoptionheight,%
1988 physical width=\pgfpageoptionwidth,%
1989 current logical shipout=\pgfpageoptionfirstshipout%
1990 }
1991 \ifdim\paperheight>\paperwidth\relax
1992 % put side-by-side
1993 \pgfpageslogicalpageoptions{1}
1994 {%
1995 border shrink=\pgfpageoptionborder,%
1996 border code=\beamerswitch@Border,%
1997 resized width=.5\pgfphysicalwidth,%
1998 resized height=\pgfphysicalheight,%
1999 center=\ifbool{HL@beamerswitch@align}{%
2000 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}{.5\pgfphysicalheight}%
2001 }{%
2002 \pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
2003 }%
2004 }%
2005 \else
2006 % stack on top of one another
2007 \pgfpageslogicalpageoptions{1}
2008 {%
2009 border shrink=\pgfpageoptionborder,%
2010 border code=\beamerswitch@Border,%
2011 resized width=\pgfphysicalwidth,%
2012 resized height=.5\pgfphysicalheight,%
2013 center=\ifbool{HL@beamerswitch@align}{%
2014 \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2015 }{%
2016 \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
2017 }%
2018 }%
2019 \fi
2020 }
2021 % \end{macrocode}
2022 %
2023 % The `1 by 2' layout is similar to the normal \key{2 on 1} layout.
2024 %
2025 % \begin{macrocode}
2026 \pgfpagesdeclarelayout{1 by 2}
2027 {
2028 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
2029 \edef\pgfpageoptionwidth{\the\paperheight}
2030 \def\pgfpageoptionborder{0pt}
2031 \def\pgfpageoptionfirstshipout{1}
2032 }
2033 {
2034 \pgfpagesphysicalpageoptions
2035 {%
2036 logical pages=2,%
2037 physical height=\pgfpageoptionheight,%
2038 physical width=\pgfpageoptionwidth,%
2039 current logical shipout=\pgfpageoptionfirstshipout%
2040 }
2041 \ifdim\paperheight>\paperwidth\relax
2042 % put side-by-side
2043 \pgfpageslogicalpageoptions{1}
2044 {%
2045 border shrink=\pgfpageoptionborder,%
2046 border code=\beamerswitch@Border,%
2047 resized width=.5\pgfphysicalwidth,%
2048 resized height=\pgfphysicalheight,%
2049 center=\ifbool{HL@beamerswitch@align}{%
2050 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}{.5\pgfphysicalheight}%
2051 }{%
2052 \pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
2053 }%
2054 }%
2055 \pgfpageslogicalpageoptions{2}
2056 {%
2057 border shrink=\pgfpageoptionborder,%
2058 border code=\beamerswitch@Border,%
2059 resized width=.5\pgfphysicalwidth,%
2060 resized height=\pgfphysicalheight,%
2061 center=\ifbool{HL@beamerswitch@align}{%
2062 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}{.5\pgfphysicalheight}%
2063 }{%
2064 \pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}%
2065 }%
2066 }%
2067 \else
2068 % stack on top of one another
2069 \pgfpageslogicalpageoptions{1}
2070 {%
2071 border shrink=\pgfpageoptionborder,%
2072 border code=\beamerswitch@Border,%
2073 resized width=\pgfphysicalwidth,%
2074 resized height=.5\pgfphysicalheight,%
2075 center=\ifbool{HL@beamerswitch@align}{%
2076 \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2077 }{%
2078 \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
2079 }%
2080 }%
2081 \pgfpageslogicalpageoptions{2}
2082 {%
2083 border shrink=\pgfpageoptionborder,%
2084 border code=\beamerswitch@Border,%
2085 resized width=\pgfphysicalwidth,%
2086 resized height=.5\pgfphysicalheight,%
2087 center=\ifbool{HL@beamerswitch@align}{%
2088 \pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2089 }{%
2090 \pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight}%
2091 }%
2092 }%
2093 \fi
2094 }
2095 % \end{macrocode}
2096 %
2097 % The `1 by 3' layout is similar to the `1 by 2', but with an extra row.
2098 %
2099 % \begin{macrocode}
2100 \pgfpagesdeclarelayout{1 by 3}
2101 {
2102 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
2103 \edef\pgfpageoptionwidth{\the\paperheight}
2104 \def\pgfpageoptionborder{0pt}
2105 \def\pgfpageoptionfirstshipout{1}
2106 }
2107 {
2108 \pgfpagesphysicalpageoptions
2109 {%
2110 logical pages=3,%
2111 physical height=\pgfpageoptionheight,%
2112 physical width=\pgfpageoptionwidth,%
2113 current logical shipout=\pgfpageoptionfirstshipout%
2114 }
2115 \ifdim\paperheight>\paperwidth\relax
2116 % put side-by-side
2117 \pgfpageslogicalpageoptions{1}
2118 {%
2119 border shrink=\pgfpageoptionborder,%
2120 border code=\beamerswitch@Border,%
2121 resized width=.333\pgfphysicalwidth,%
2122 resized height=\pgfphysicalheight,%
2123 center=\ifbool{HL@beamerswitch@align}{%
2124 \pgfpoint{.167\pgfphysicalwidth + 0.5\beamerswitch@margin}{.5\pgfphysicalheight}%
2125 }{%
2126 \pgfpoint{.167\pgfphysicalwidth}{.5\pgfphysicalheight}%
2127 }%
2128 }%
2129 \pgfpageslogicalpageoptions{2}
2130 {%
2131 border shrink=\pgfpageoptionborder,%
2132 border code=\beamerswitch@Border,%
2133 resized width=.333\pgfphysicalwidth,%
2134 resized height=\pgfphysicalheight,%
2135 center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight}%
2136 }%
2137 \pgfpageslogicalpageoptions{3}
2138 {%
2139 border shrink=\pgfpageoptionborder,%
2140 border code=\beamerswitch@Border,%
2141 resized width=.333\pgfphysicalwidth,%
2142 resized height=\pgfphysicalheight,%
2143 center=\ifbool{HL@beamerswitch@align}{%
2144 \pgfpoint{.833\pgfphysicalwidth - 0.5\beamerswitch@margin}{.5\pgfphysicalheight}%
2145 }{%
2146 \pgfpoint{.833\pgfphysicalwidth}{.5\pgfphysicalheight}%
2147 }%
2148 }%
2149 \else
2150 % stack on top of one another
2151 \pgfpageslogicalpageoptions{1}
2152 {%
2153 border shrink=\pgfpageoptionborder,%
2154 border code=\beamerswitch@Border,%
2155 resized width=\pgfphysicalwidth,%
2156 resized height=.333\pgfphysicalheight,%
2157 center=\ifbool{HL@beamerswitch@align}{%
2158 \pgfpoint{.5\pgfphysicalwidth}{.833\pgfphysicalheight - 0.5\beamerswitch@margin}%
2159 }{%
2160 \pgfpoint{.5\pgfphysicalwidth}{.833\pgfphysicalheight}%
2161 }%
2162 }%
2163 \pgfpageslogicalpageoptions{2}
2164 {%
2165 border shrink=\pgfpageoptionborder,%
2166 border code=\beamerswitch@Border,%
2167 resized width=\pgfphysicalwidth,%
2168 resized height=.333\pgfphysicalheight,%
2169 center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight}%
2170 }%
2171 \pgfpageslogicalpageoptions{3}
2172 {%
2173 border shrink=\pgfpageoptionborder,%
2174 border code=\beamerswitch@Border,%
2175 resized width=\pgfphysicalwidth,%
2176 resized height=.333\pgfphysicalheight,%
2177 center=\ifbool{HL@beamerswitch@align}{%
2178 \pgfpoint{.5\pgfphysicalwidth}{.167\pgfphysicalheight + 0.5\beamerswitch@margin}%
2179 }{%
2180 \pgfpoint{.5\pgfphysicalwidth}{.167\pgfphysicalheight}%
2181 }%
2182 }%
2183 \fi
2184 }
2185 % \end{macrocode}
2186 %
2187 % The `1 by 3 narrow' layout is like the `1 by 3' layout but restricted to the
2188 % left (or top) half of the page.
2189 %
2190 % \begin{macrocode}
2191 \pgfpagesdeclarelayout{1 by 3 narrow}
2192 {
2193 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
2194 \edef\pgfpageoptionwidth{\the\paperheight}
2195 \def\pgfpageoptionborder{0pt}
2196 \def\pgfpageoptionfirstshipout{1}
2197 }
2198 {
2199 \pgfpagesphysicalpageoptions
2200 {%
2201 logical pages=3,%
2202 physical height=\pgfpageoptionheight,%
2203 physical width=\pgfpageoptionwidth,%
2204 current logical shipout=\pgfpageoptionfirstshipout%
2205 }
2206 \ifdim\paperheight>\paperwidth\relax
2207 % put side-by-side
2208 \pgfpageslogicalpageoptions{1}
2209 {%
2210 border shrink=\pgfpageoptionborder,%
2211 border code=\beamerswitch@Border,%
2212 resized width=.333\pgfphysicalwidth,%
2213 resized height=.5\pgfphysicalheight,%
2214 center=\ifbool{HL@beamerswitch@align}{%
2215 \pgfpoint{.167\pgfphysicalwidth + 0.5\beamerswitch@margin}%
2216 {.75\pgfphysicalheight - 0.5\beamerswitch@margin}%
2217 }{%
2218 \pgfpoint{.167\pgfphysicalwidth}{.75\pgfphysicalheight}%
2219 }%
2220 }%
2221 \pgfpageslogicalpageoptions{2}
2222 {%
2223 border shrink=\pgfpageoptionborder,%
2224 border code=\beamerswitch@Border,%
2225 resized width=.333\pgfphysicalwidth,%
2226 resized height=.5\pgfphysicalheight,%
2227 center=\ifbool{HL@beamerswitch@align}{%
2228 \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight - 0.5\beamerswitch@margin}%
2229 }{%
2230 \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
2231 }%
2232 }%
2233 \pgfpageslogicalpageoptions{3}
2234 {%
2235 border shrink=\pgfpageoptionborder,%
2236 border code=\beamerswitch@Border,%
2237 resized width=.333\pgfphysicalwidth,%
2238 resized height=.5\pgfphysicalheight,%
2239 center=\ifbool{HL@beamerswitch@align}{%
2240 \pgfpoint{.833\pgfphysicalwidth - 0.5\beamerswitch@margin}%
2241 {.75\pgfphysicalheight - 0.5\beamerswitch@margin}%
2242 }{%
2243 \pgfpoint{.833\pgfphysicalwidth}{.75\pgfphysicalheight}%
2244 }%
2245 }%
2246 \else
2247 % stack on top of one another
2248 \pgfpageslogicalpageoptions{1}
2249 {%
2250 border shrink=\pgfpageoptionborder,%
2251 border code=\beamerswitch@Border,%
2252 resized width=.5\pgfphysicalwidth,%
2253 resized height=.333\pgfphysicalheight,%
2254 center=\ifbool{HL@beamerswitch@align}{%
2255 \pgfpoint{.25\pgfphysicalwidth + 0.5\beamerswitch@margin}%
2256 {.833\pgfphysicalheight - 0.5\beamerswitch@margin}%
2257 }{%
2258 \pgfpoint{.25\pgfphysicalwidth}{.833\pgfphysicalheight}%
2259 }%
2260 }%
2261 \pgfpageslogicalpageoptions{2}
2262 {%
2263 border shrink=\pgfpageoptionborder,%
2264 border code=\beamerswitch@Border,%
2265 resized width=.5\pgfphysicalwidth,%
2266 resized height=.333\pgfphysicalheight,%
2267 center=\ifbool{HL@beamerswitch@align}{%
2268 \pgfpoint{.25\pgfphysicalwidth + 0.5\beamerswitch@margin}{.5\pgfphysicalheight}%
2269 }{%
2270 \pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
2271 }%
2272 }%
2273 \pgfpageslogicalpageoptions{3}
2274 {%
2275 border shrink=\pgfpageoptionborder,%
2276 border code=\beamerswitch@Border,%
2277 resized width=.5\pgfphysicalwidth,%
2278 resized height=.333\pgfphysicalheight,%
2279 center=\ifbool{HL@beamerswitch@align}{%
2280 \pgfpoint{.25\pgfphysicalwidth + 0.5\beamerswitch@margin}%
2281 {.167\pgfphysicalheight + 0.5\beamerswitch@margin}%
2282 }{%
2283 \pgfpoint{.25\pgfphysicalwidth}{.167\pgfphysicalheight}%
2284 }%
2285 }%
2286 \fi
2287 }
2288 % \end{macrocode}
2289 %
2290 % The `2 by 2' layout is similar to the normal \key{4 on 1} layout.
2291 %
2292 % \begin{macrocode}
2293 \pgfpagesdeclarelayout{2 by 2}
2294 {
2295 \edef\pgfpageoptionheight{\the\paperheight}
2296 \edef\pgfpageoptionwidth{\the\paperwidth}
2297 \edef\pgfpageoptionborder{0pt}
2298 }
2299 {
2300 \pgfpagesphysicalpageoptions
2301 {%
2302 logical pages=4,%
2303 physical height=\pgfpageoptionheight,%
2304 physical width=\pgfpageoptionwidth%
2305 }
2306 \pgfpageslogicalpageoptions{1}
2307 {%
2308 border shrink=\pgfpageoptionborder,%
2309 border code=\beamerswitch@Border,%
2310 resized width=.5\pgfphysicalwidth,%
2311 resized height=.5\pgfphysicalheight,%
2312 center=\ifbool{HL@beamerswitch@align}{%
2313 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2314 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2315 }{%
2316 \pgfpoint{.25\pgfphysicalwidth}{.75\pgfphysicalheight}%
2317 }%
2318 }%
2319 \pgfpageslogicalpageoptions{2}
2320 {%
2321 border shrink=\pgfpageoptionborder,%
2322 border code=\beamerswitch@Border,%
2323 resized width=.5\pgfphysicalwidth,%
2324 resized height=.5\pgfphysicalheight,%
2325 center=\ifbool{HL@beamerswitch@align}{%
2326 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
2327 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2328 }{%
2329 \pgfpoint{.75\pgfphysicalwidth}{.75\pgfphysicalheight}%
2330 }%
2331 }%
2332 \pgfpageslogicalpageoptions{3}
2333 {%
2334 border shrink=\pgfpageoptionborder,%
2335 border code=\beamerswitch@Border,%
2336 resized width=.5\pgfphysicalwidth,%
2337 resized height=.5\pgfphysicalheight,%
2338 center=\ifbool{HL@beamerswitch@align}{%
2339 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2340 {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2341 }{%
2342 \pgfpoint{.25\pgfphysicalwidth}{.25\pgfphysicalheight}%
2343 }%
2344 }%
2345 \pgfpageslogicalpageoptions{4}
2346 {%
2347 border shrink=\pgfpageoptionborder,%
2348 border code=\beamerswitch@Border,%
2349 resized width=.5\pgfphysicalwidth,%
2350 resized height=.5\pgfphysicalheight,%
2351 center=\ifbool{HL@beamerswitch@align}{%
2352 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
2353 {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2354 }{%
2355 \pgfpoint{.75\pgfphysicalwidth}{.25\pgfphysicalheight}%
2356 }%
2357 }%
2358 }
2359 % \end{macrocode}
2360 %
2361 % The `1 by 4 narrow' layout puts four slides in a column on the left half of
2362 % the page (or in a row on the top half).
2363 %
2364 % \begin{macrocode}
2365 \pgfpagesdeclarelayout{1 by 4 narrow}
2366 {
2367 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
2368 \edef\pgfpageoptionwidth{\the\paperheight}
2369 \def\pgfpageoptionborder{0pt}
2370 \def\pgfpageoptionfirstshipout{1}
2371 }
2372 {
2373 \pgfpagesphysicalpageoptions
2374 {%
2375 logical pages=4,%
2376 physical height=\pgfpageoptionheight,%
2377 physical width=\pgfpageoptionwidth,%
2378 current logical shipout=\pgfpageoptionfirstshipout%
2379 }
2380 \ifdim\paperheight>\paperwidth\relax
2381 % put side-by-side
2382 \pgfpageslogicalpageoptions{1}
2383 {%
2384 border shrink=\pgfpageoptionborder,%
2385 border code=\beamerswitch@Border,%
2386 resized width=.25\pgfphysicalwidth,%
2387 resized height=.5\pgfphysicalheight,%
2388 center=\ifbool{HL@beamerswitch@align}{%
2389 \pgfpoint{.125\pgfphysicalwidth + 0.6\beamerswitch@margin}%
2390 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2391 }{%
2392 \pgfpoint{.125\pgfphysicalwidth}{.75\pgfphysicalheight}%
2393 }%
2394 }%
2395 \pgfpageslogicalpageoptions{2}
2396 {%
2397 border shrink=\pgfpageoptionborder,%
2398 border code=\beamerswitch@Border,%
2399 resized width=.25\pgfphysicalwidth,%
2400 resized height=.5\pgfphysicalheight,%
2401 center=\ifbool{HL@beamerswitch@align}{%
2402 \pgfpoint{.375\pgfphysicalwidth + 0.2\beamerswitch@margin}%
2403 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2404 }{%
2405 \pgfpoint{.375\pgfphysicalwidth}{.75\pgfphysicalheight}%
2406 }%
2407 }%
2408 \pgfpageslogicalpageoptions{3}
2409 {%
2410 border shrink=\pgfpageoptionborder,%
2411 border code=\beamerswitch@Border,%
2412 resized width=.25\pgfphysicalwidth,%
2413 resized height=.5\pgfphysicalheight,%
2414 center=\ifbool{HL@beamerswitch@align}{%
2415 \pgfpoint{.625\pgfphysicalwidth - 0.2\beamerswitch@margin}%
2416 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2417 }{%
2418 \pgfpoint{.625\pgfphysicalwidth}{.75\pgfphysicalheight}%
2419 }%
2420 }%
2421 \pgfpageslogicalpageoptions{4}
2422 {%
2423 border shrink=\pgfpageoptionborder,%
2424 border code=\beamerswitch@Border,%
2425 resized width=.25\pgfphysicalwidth,%
2426 resized height=.5\pgfphysicalheight,%
2427 center=\ifbool{HL@beamerswitch@align}{%
2428 \pgfpoint{.875\pgfphysicalwidth - 0.6\beamerswitch@margin}%
2429 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2430 }{%
2431 \pgfpoint{.875\pgfphysicalwidth}{.75\pgfphysicalheight}%
2432 }%
2433 }%
2434 \else
2435 % stack on top of one another
2436 \pgfpageslogicalpageoptions{1}
2437 {%
2438 border shrink=\pgfpageoptionborder,%
2439 border code=\beamerswitch@Border,%
2440 resized width=.5\pgfphysicalwidth,%
2441 resized height=.25\pgfphysicalheight,%
2442 center=\ifbool{HL@beamerswitch@align}{%
2443 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2444 {.875\pgfphysicalheight - 0.6\beamerswitch@margin}%
2445 }{%
2446 \pgfpoint{.25\pgfphysicalwidth}{.875\pgfphysicalheight}%
2447 }%
2448 }%
2449 \pgfpageslogicalpageoptions{2}
2450 {%
2451 border shrink=\pgfpageoptionborder,%
2452 border code=\beamerswitch@Border,%
2453 resized width=.5\pgfphysicalwidth,%
2454 resized height=.25\pgfphysicalheight,%
2455 center=\ifbool{HL@beamerswitch@align}{%
2456 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2457 {.625\pgfphysicalheight - 0.2\beamerswitch@margin}%
2458 }{%
2459 \pgfpoint{.25\pgfphysicalwidth}{.625\pgfphysicalheight}%
2460 }%
2461 }%
2462 \pgfpageslogicalpageoptions{3}
2463 {%
2464 border shrink=\pgfpageoptionborder,%
2465 border code=\beamerswitch@Border,%
2466 resized width=.5\pgfphysicalwidth,%
2467 resized height=.25 \pgfphysicalheight,%
2468 center=\ifbool{HL@beamerswitch@align}{%
2469 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2470 {.375\pgfphysicalheight + 0.2\beamerswitch@margin}%
2471 }{%
2472 \pgfpoint{.25\pgfphysicalwidth}{.375\pgfphysicalheight}%
2473 }%
2474 }%
2475 \pgfpageslogicalpageoptions{4}
2476 {%
2477 border shrink=\pgfpageoptionborder,%
2478 border code=\beamerswitch@Border,%
2479 resized width=.5\pgfphysicalwidth,%
2480 resized height=.25 \pgfphysicalheight,%
2481 center=\ifbool{HL@beamerswitch@align}{%
2482 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2483 {.125\pgfphysicalheight + 0.6\beamerswitch@margin}%
2484 }{%
2485 \pgfpoint{.25\pgfphysicalwidth}{.125\pgfphysicalheight}%
2486 }%
2487 }%
2488 \fi
2489 }
2490 % \end{macrocode}
2491 %
2492 % The `2 by 3' layout positions the slides as three rows of two slides each.
2493 %
2494 % \begin{macrocode}
2495 \pgfpagesdeclarelayout{2 by 3}
2496 {
2497 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
2498 \edef\pgfpageoptionwidth{\the\paperheight}
2499 \def\pgfpageoptionborder{0pt}
2500 \def\pgfpageoptionfirstshipout{1}
2501 }
2502 {
2503 \pgfpagesphysicalpageoptions
2504 {%
2505 logical pages=6,%
2506 physical height=\pgfpageoptionheight,%
2507 physical width=\pgfpageoptionwidth,%
2508 current logical shipout=\pgfpageoptionfirstshipout%
2509 }
2510 \ifdim\paperheight>\paperwidth\relax
2511 % put side-by-side
2512 \pgfpageslogicalpageoptions{1}
2513 {%
2514 border shrink=\pgfpageoptionborder,%
2515 border code=\beamerswitch@Border,%
2516 resized width=.333\pgfphysicalwidth,%
2517 resized height=.5\pgfphysicalheight,%
2518 center=\ifbool{HL@beamerswitch@align}{%
2519 \pgfpoint{.167\pgfphysicalwidth + 0.5\beamerswitch@margin}%
2520 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2521 }{%
2522 \pgfpoint{.167\pgfphysicalwidth}{.75\pgfphysicalheight}%
2523 }%
2524 }%
2525 \pgfpageslogicalpageoptions{2}
2526 {%
2527 border shrink=\pgfpageoptionborder,%
2528 border code=\beamerswitch@Border,%
2529 resized width=.333\pgfphysicalwidth,%
2530 resized height=.5\pgfphysicalheight,%
2531 center=\ifbool{HL@beamerswitch@align}{%
2532 \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheigh - 0.333\beamerswitch@margint}%
2533 }{%
2534 \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
2535 }%
2536 }%
2537 \pgfpageslogicalpageoptions{3}
2538 {%
2539 border shrink=\pgfpageoptionborder,%
2540 border code=\beamerswitch@Border,%
2541 resized width=.333\pgfphysicalwidth,%
2542 resized height=.5\pgfphysicalheight,%
2543 center=\ifbool{HL@beamerswitch@align}{%
2544 \pgfpoint{.833\pgfphysicalwidth - 0.5\beamerswitch@margin}%
2545 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2546 }{%
2547 \pgfpoint{.833\pgfphysicalwidth}{.75\pgfphysicalheight}%
2548 }%
2549 }%
2550 \pgfpageslogicalpageoptions{4}
2551 {%
2552 border shrink=\pgfpageoptionborder,%
2553 border code=\beamerswitch@Border,%
2554 resized width=.333\pgfphysicalwidth,%
2555 resized height=.5\pgfphysicalheight,%
2556 center=\ifbool{HL@beamerswitch@align}{%
2557 \pgfpoint{.167\pgfphysicalwidth + 0.5\beamerswitch@margin}%
2558 {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2559 }{%
2560 \pgfpoint{.167\pgfphysicalwidth}{.25\pgfphysicalheight}%
2561 }%
2562 }%
2563 \pgfpageslogicalpageoptions{5}
2564 {%
2565 border shrink=\pgfpageoptionborder,%
2566 border code=\beamerswitch@Border,%
2567 resized width=.333\pgfphysicalwidth,%
2568 resized height=.5\pgfphysicalheight,%
2569 center=\ifbool{HL@beamerswitch@align}{%
2570 \pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2571 }{%
2572 \pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight}%
2573 }%
2574 }%
2575 \pgfpageslogicalpageoptions{6}
2576 {%
2577 border shrink=\pgfpageoptionborder,%
2578 border code=\beamerswitch@Border,%
2579 resized width=.333\pgfphysicalwidth,%
2580 resized height=.5\pgfphysicalheight,%
2581 center=\ifbool{HL@beamerswitch@align}{%
2582 \pgfpoint{.833\pgfphysicalwidth - 0.5\beamerswitch@margin}%
2583 {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2584 }{%
2585 \pgfpoint{.833\pgfphysicalwidth}{.25\pgfphysicalheight}%
2586 }%
2587 }%
2588 \else
2589 % stack on top of one another
2590 \pgfpageslogicalpageoptions{1}
2591 {%
2592 border shrink=\pgfpageoptionborder,%
2593 border code=\beamerswitch@Border,%
2594 resized width=.5\pgfphysicalwidth,%
2595 resized height=.333\pgfphysicalheight,%
2596 center=\ifbool{HL@beamerswitch@align}{%
2597 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2598 {.833\pgfphysicalheight - 0.5\beamerswitch@margin}%
2599 }{%
2600 \pgfpoint{.25\pgfphysicalwidth}{.833\pgfphysicalheight}%
2601 }%
2602 }%
2603 \pgfpageslogicalpageoptions{2}
2604 {%
2605 border shrink=\pgfpageoptionborder,%
2606 border code=\beamerswitch@Border,%
2607 resized width=.5\pgfphysicalwidth,%
2608 resized height=.333\pgfphysicalheight,%
2609 center=\ifbool{HL@beamerswitch@align}{%
2610 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
2611 {.833\pgfphysicalheight - 0.5\beamerswitch@margin}%
2612 }{%
2613 \pgfpoint{.75\pgfphysicalwidth}{.833\pgfphysicalheight}%
2614 }%
2615 }%
2616 \pgfpageslogicalpageoptions{3}
2617 {%
2618 border shrink=\pgfpageoptionborder,%
2619 border code=\beamerswitch@Border,%
2620 resized width=.5\pgfphysicalwidth,%
2621 resized height=.333\pgfphysicalheight,%
2622 center=\ifbool{HL@beamerswitch@align}{%
2623 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}{.5\pgfphysicalheight}%
2624 }{%
2625 \pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
2626 }%
2627 }%
2628 \pgfpageslogicalpageoptions{4}
2629 {%
2630 border shrink=\pgfpageoptionborder,%
2631 border code=\beamerswitch@Border,%
2632 resized width=.5\pgfphysicalwidth,%
2633 resized height=.333\pgfphysicalheight,%
2634 center=\ifbool{HL@beamerswitch@align}{%
2635 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}{.5\pgfphysicalheight}%
2636 }{%
2637 \pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}%
2638 }%
2639 }%
2640 \pgfpageslogicalpageoptions{5}
2641 {%
2642 border shrink=\pgfpageoptionborder,%
2643 border code=\beamerswitch@Border,%
2644 resized width=.5\pgfphysicalwidth,%
2645 resized height=.333\pgfphysicalheight,%
2646 center=\ifbool{HL@beamerswitch@align}{%
2647 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2648 {.167\pgfphysicalheight + 0.5\beamerswitch@margin}%
2649 }{%
2650 \pgfpoint{.25\pgfphysicalwidth}{.167\pgfphysicalheight}%
2651 }%
2652 }%
2653 \pgfpageslogicalpageoptions{6}
2654 {%
2655 border shrink=\pgfpageoptionborder,%
2656 border code=\beamerswitch@Border,%
2657 resized width=.5\pgfphysicalwidth,%
2658 resized height=.333\pgfphysicalheight,%
2659 center=\ifbool{HL@beamerswitch@align}{%
2660 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
2661 {.167\pgfphysicalheight + 0.5\beamerswitch@margin}%
2662 }{%
2663 \pgfpoint{.75\pgfphysicalwidth}{.167\pgfphysicalheight}%
2664 }%
2665 }%
2666 \fi
2667 }
2668 % \end{macrocode}
2669 %
2670 % The `2 by 4' layout layout positions the slides as four rows of two slides each.
2671 %
2672 % \begin{macrocode}
2673 \pgfpagesdeclarelayout{2 by 4}
2674 {
2675 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
2676 \edef\pgfpageoptionwidth{\the\paperheight}
2677 \def\pgfpageoptionborder{0pt}
2678 \def\pgfpageoptionfirstshipout{1}
2679 }
2680 {
2681 \pgfpagesphysicalpageoptions
2682 {%
2683 logical pages=8,%
2684 physical height=\pgfpageoptionheight,%
2685 physical width=\pgfpageoptionwidth,%
2686 current logical shipout=\pgfpageoptionfirstshipout%
2687 }
2688 \ifdim\paperheight>\paperwidth\relax
2689 % put side-by-side
2690 \pgfpageslogicalpageoptions{1}
2691 {%
2692 border shrink=\pgfpageoptionborder,%
2693 border code=\beamerswitch@Border,%
2694 resized width=.25\pgfphysicalwidth,%
2695 resized height=.5\pgfphysicalheight,%
2696 center=\ifbool{HL@beamerswitch@align}{%
2697 \pgfpoint{.125\pgfphysicalwidth + 0.6\beamerswitch@margin}%
2698 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2699 }{%
2700 \pgfpoint{.125\pgfphysicalwidth}{.75\pgfphysicalheight}%
2701 }%
2702 }%
2703 \pgfpageslogicalpageoptions{2}
2704 {%
2705 border shrink=\pgfpageoptionborder,%
2706 border code=\beamerswitch@Border,%
2707 resized width=.25\pgfphysicalwidth,%
2708 resized height=.5\pgfphysicalheight,%
2709 center=\ifbool{HL@beamerswitch@align}{%
2710 \pgfpoint{.375\pgfphysicalwidth + 0.2\beamerswitch@margin}%
2711 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2712 }{%
2713 \pgfpoint{.375\pgfphysicalwidth}{.75\pgfphysicalheight}%
2714 }%
2715 }%
2716 \pgfpageslogicalpageoptions{3}
2717 {%
2718 border shrink=\pgfpageoptionborder,%
2719 border code=\beamerswitch@Border,%
2720 resized width=.25\pgfphysicalwidth,%
2721 resized height=.5\pgfphysicalheight,%
2722 center=\ifbool{HL@beamerswitch@align}{%
2723 \pgfpoint{.625\pgfphysicalwidth - 0.2\beamerswitch@margin}%
2724 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2725 }{%
2726 \pgfpoint{.625\pgfphysicalwidth}{.75\pgfphysicalheight}%
2727 }%
2728 }%
2729 \pgfpageslogicalpageoptions{4}
2730 {%
2731 border shrink=\pgfpageoptionborder,%
2732 border code=\beamerswitch@Border,%
2733 resized width=.25\pgfphysicalwidth,%
2734 resized height=.5\pgfphysicalheight,%
2735 center=\ifbool{HL@beamerswitch@align}{%
2736 \pgfpoint{.875\pgfphysicalwidth - 0.6\beamerswitch@margin}%
2737 {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
2738 }{%
2739 \pgfpoint{.875\pgfphysicalwidth}{.75\pgfphysicalheight}%
2740 }%
2741 }%
2742 \pgfpageslogicalpageoptions{5}
2743 {%
2744 border shrink=\pgfpageoptionborder,%
2745 border code=\beamerswitch@Border,%
2746 resized width=.25\pgfphysicalwidth,%
2747 resized height=.5\pgfphysicalheight,%
2748 center=\ifbool{HL@beamerswitch@align}{%
2749 \pgfpoint{.125\pgfphysicalwidth + 0.6\beamerswitch@margin}%
2750 {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2751 }{%
2752 \pgfpoint{.125\pgfphysicalwidth}{.25\pgfphysicalheight}%
2753 }%
2754 }%
2755 \pgfpageslogicalpageoptions{6}
2756 {%
2757 border shrink=\pgfpageoptionborder,%
2758 border code=\beamerswitch@Border,%
2759 resized width=.25\pgfphysicalwidth,%
2760 resized height=.5\pgfphysicalheight,%
2761 center=\ifbool{HL@beamerswitch@align}{%
2762 \pgfpoint{.375\pgfphysicalwidth + 0.2\beamerswitch@margin}%
2763 {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2764 }{%
2765 \pgfpoint{.375\pgfphysicalwidth}{.25\pgfphysicalheight}%
2766 }%
2767 }%
2768 \pgfpageslogicalpageoptions{7}
2769 {%
2770 border shrink=\pgfpageoptionborder,%
2771 border code=\beamerswitch@Border,%
2772 resized width=.25\pgfphysicalwidth,%
2773 resized height=.5\pgfphysicalheight,%
2774 center=\ifbool{HL@beamerswitch@align}{%
2775 \pgfpoint{.625\pgfphysicalwidth - 0.2\beamerswitch@margin}%
2776 {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2777 }{%
2778 \pgfpoint{.625\pgfphysicalwidth}{.25\pgfphysicalheight}%
2779 }%
2780 }%
2781 \pgfpageslogicalpageoptions{8}
2782 {%
2783 border shrink=\pgfpageoptionborder,%
2784 border code=\beamerswitch@Border,%
2785 resized width=.25\pgfphysicalwidth,%
2786 resized height=.5\pgfphysicalheight,%
2787 center=\ifbool{HL@beamerswitch@align}{%
2788 \pgfpoint{.875\pgfphysicalwidth - 0.6\beamerswitch@margin}%
2789 {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
2790 }{%
2791 \pgfpoint{.875\pgfphysicalwidth}{.25\pgfphysicalheight}%
2792 }%
2793 }%
2794 \else
2795 % stack on top of one another
2796 \pgfpageslogicalpageoptions{1}
2797 {%
2798 border shrink=\pgfpageoptionborder,%
2799 border code=\beamerswitch@Border,%
2800 resized width=.5\pgfphysicalwidth,%
2801 resized height=.25\pgfphysicalheight,%
2802 center=\ifbool{HL@beamerswitch@align}{%
2803 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2804 {.875\pgfphysicalheight - 0.6\beamerswitch@margin}%
2805 }{%
2806 \pgfpoint{.25\pgfphysicalwidth}{.875\pgfphysicalheight}%
2807 }%
2808 }%
2809 \pgfpageslogicalpageoptions{2}
2810 {%
2811 border shrink=\pgfpageoptionborder,%
2812 border code=\beamerswitch@Border,%
2813 resized width=.5\pgfphysicalwidth,%
2814 resized height=.25\pgfphysicalheight,%
2815 center=\ifbool{HL@beamerswitch@align}{%
2816 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
2817 {.875\pgfphysicalheight - 0.6\beamerswitch@margin}%
2818 }{%
2819 \pgfpoint{.75\pgfphysicalwidth}{.875\pgfphysicalheight}%
2820 }%
2821 }%
2822 \pgfpageslogicalpageoptions{3}
2823 {%
2824 border shrink=\pgfpageoptionborder,%
2825 border code=\beamerswitch@Border,%
2826 resized width=.5\pgfphysicalwidth,%
2827 resized height=.25\pgfphysicalheight,%
2828 center=\ifbool{HL@beamerswitch@align}{%
2829 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2830 {.625\pgfphysicalheight - 0.2\beamerswitch@margin}%
2831 }{%
2832 \pgfpoint{.25\pgfphysicalwidth}{.625\pgfphysicalheight}%
2833 }%
2834 }%
2835 \pgfpageslogicalpageoptions{4}
2836 {%
2837 border shrink=\pgfpageoptionborder,%
2838 border code=\beamerswitch@Border,%
2839 resized width=.5\pgfphysicalwidth,%
2840 resized height=.25\pgfphysicalheight,%
2841 center=\ifbool{HL@beamerswitch@align}{%
2842 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
2843 {.625\pgfphysicalheight - 0.2\beamerswitch@margin}%
2844 }{%
2845 \pgfpoint{.75\pgfphysicalwidth}{.625\pgfphysicalheight}%
2846 }%
2847 }%
2848 \pgfpageslogicalpageoptions{5}
2849 {%
2850 border shrink=\pgfpageoptionborder,%
2851 border code=\beamerswitch@Border,%
2852 resized width=.5\pgfphysicalwidth,%
2853 resized height=.25 \pgfphysicalheight,%
2854 center=\ifbool{HL@beamerswitch@align}{%
2855 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2856 {.375\pgfphysicalheight + 0.2\beamerswitch@margin}%
2857 }{%
2858 \pgfpoint{.25\pgfphysicalwidth}{.375\pgfphysicalheight}%
2859 }%
2860 }%
2861 \pgfpageslogicalpageoptions{6}
2862 {%
2863 border shrink=\pgfpageoptionborder,%
2864 border code=\beamerswitch@Border,%
2865 resized width=.5\pgfphysicalwidth,%
2866 resized height=.25 \pgfphysicalheight,%
2867 center=\ifbool{HL@beamerswitch@align}{%
2868 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
2869 {.375\pgfphysicalheight + 0.2\beamerswitch@margin}%
2870 }{%
2871 \pgfpoint{.75\pgfphysicalwidth}{.375\pgfphysicalheight}%
2872 }%
2873 }%
2874 \pgfpageslogicalpageoptions{7}
2875 {%
2876 border shrink=\pgfpageoptionborder,%
2877 border code=\beamerswitch@Border,%
2878 resized width=.5\pgfphysicalwidth,%
2879 resized height=.25 \pgfphysicalheight,%
2880 center=\ifbool{HL@beamerswitch@align}{%
2881 \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
2882 {.125\pgfphysicalheight + 0.6\beamerswitch@margin}%
2883 }{%
2884 \pgfpoint{.25\pgfphysicalwidth}{.125\pgfphysicalheight}%
2885 }%
2886 }%
2887 \pgfpageslogicalpageoptions{8}
2888 {%
2889 border shrink=\pgfpageoptionborder,%
2890 border code=\beamerswitch@Border,%
2891 resized width=.5\pgfphysicalwidth,%
2892 resized height=.25 \pgfphysicalheight,%
2893 center=\ifbool{HL@beamerswitch@align}{%
2894 \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
2895 {.125\pgfphysicalheight + 0.6\beamerswitch@margin}%
2896 }{%
2897 \pgfpoint{.75\pgfphysicalwidth}{.125\pgfphysicalheight}%
2898 }%
2899 }%
2900 \fi
2901 }
2902 }
2903 % \end{macrocode}
2904 %
2905 % \begin{macro}{articlelayout}
2906 % \subsection{Article layout}
2907 %
2908 % We provide some options for configuring the appearance of article mode.
2909 %
2910 % \changes{v1.1}{2016/08/19}{Fix \key{maketitle} and \key{textinst} options.}
2911 % \begin{optionkey}{maketitle}
2912 % The \key{maketitle} option triggers adjustments in how the title block is
2913 % printed.
2914 %
2915 % \begin{macrocode}
2916 \define@boolkey[AL]{beamerswitch}{maketitle}[true]{}
2917 % \end{macrocode}
2918 % \end{optionkey}
2919 %
2920 % One will be to join the title and subtitle with a colon. There is an edge case
2921 % where, if the user provides a title that ends in `!' or `?' \emph{and}
2922 % provides a subtitle while this option is in effect, they will end up with
2923 % clashing punctuation in the middle of the displayed title (`!:' or `?:'). We
2924 % therefore introduce a toggle that, if set true, suppresses the additional
2925 % colon.
2926 %
2927 % \begin{macrocode}
2928 \newtoggle{titlepunct}
2929 % \end{macrocode}
2930 %
2931 % \begin{macro}{bsw@punct@test}
2932 % \changes{v1.6.1}{2020/01/20}{Update expl3 syntax.}
2933 % Of course, we would rather not bother the user with this, so we introduce a
2934 % command for testing the title for final punctuation.
2935 %
2936 % The only way I can seem to do this is by switching to \pkg{expl3} syntax.
2937 % Rather than introduce extra hard dependencies to cope with what will probably
2938 % be quite a rare issue, we make the dependency soft: it will only be applied
2939 % if \pkg{xparse} is available. If there is demand for it, we could introduce
2940 % a class option to switch this code on or off, but let's see how we go.
2941 %
2942 % \begin{macrocode}
2943 \IfFileExists{xparse.sty}{\@tempswatrue}{\@tempswafalse}
2944 \if@tempswa
2945 \RequirePackage{xparse}
2946 \ExplSyntaxOn
2947 \NewDocumentCommand{\bsw@punct@test}{m}{\l_bsw_punct_test:n {#1}}
2948 \cs_new_protected:Nn \l_bsw_punct_test:n
2949 {
2950 \str_case_e:nnTF { \str_item:nn {#1} {-1} }
2951 {
2952 { , } { }
2953 { ; } { }
2954 { : } { }
2955 { . } { }
2956 { ! } { }
2957 { ? } { }
2958 }
2959 { \global\toggletrue{titlepunct} }
2960 { \global\togglefalse{titlepunct} }
2961 }
2962 \ExplSyntaxOff
2963 % \end{macrocode}
2964 %
2965 % We insert this test into the definitions for \cs{title} introduced by
2966 % \pkg{beamer}\slash\pkg{beamerarticle}.
2967 %
2968 % \begin{macrocode}
2969 \mode<article>{%
2970 \renewcommand{\title}[2][]{\beamer@origtitle{#2}\bsw@punct@test{#2}}
2971 }
2972 \mode<presentation>{%
2973 \long\def\beamer@title[#1]#2{%
2974 \def\inserttitle{#2}%
2975 \def\beamer@shorttitle{#1}%
2976 \bsw@punct@test{#2}%
2977 }
2978 }
2979 \else
2980 \wlog{Beamerswitch: Auto-detection of title punctuation not available.}
2981 \fi
2982 % \end{macrocode}
2983 % \end{macro}
2984 %
2985 % \begin{optionkey}{frametitles}
2986 % \begin{optionvalue}{para}
2987 % \begin{optionvalue}{margin}
2988 % \begin{optionvalue}{none}
2989 % \begin{macro}{beamerswitch@articleframetitles}
2990 % We offer some alternatives for handling frame titles in article mode.
2991 % \begin{itemize}
2992 % \item
2993 % \val{para} is what \pkg{beamerarticle} normally does.
2994 % \item
2995 % \val{margin} puts the frame titles in the margin.
2996 % \item
2997 % \val{none} gets rid of them entirely.
2998 % \end{itemize}
2999 %
3000 % \begin{macrocode}
3001 \define@choicekey+[AL]{beamerswitch}{frametitles}{para, margin, none}{%
3002 \def\beamerswitch@articleframetitles{#1}%
3003 }{%
3004 \ClassWarning{beamerswitch}{Value of `frametitles' not recognized.
3005 Allowed values are para, margin, and none.}%
3006 }
3007 % \end{macrocode}
3008 % \end{macro}
3009 % \end{optionvalue}
3010 % \end{optionvalue}
3011 % \end{optionvalue}
3012 % \end{optionkey}
3013 %
3014 % \changes{v1.8}{2021/04/12}{Add \key{instbreak} option.}
3015 % \begin{optionkey}{instbreak}
3016 % \begin{macro}{beamerswitch@andinst}
3017 % We offer an easy way of customizing how institutes are strung together.
3018 %
3019 % \begin{macrocode}
3020 \let\beamerswitch@andinst\beamer@andinst
3021 \define@key[AL]{beamerswitch}{instbreak}{%
3022 \def\beamerswitch@andinst{#1}%
3023 }
3024 % \end{macrocode}
3025 % \end{macro}
3026 % \end{optionkey}
3027 %
3028 % We provide a command for setting these options.
3029 %
3030 % \begin{macrocode}
3031 \newcommand{\articlelayout}[1]{%
3032 \setkeys[AL]{beamerswitch}{#1}%
3033 % \end{macrocode}
3034 %
3035 % The following options are mode specific.
3036 %
3037 % \begin{macrocode}
3038 \mode<article>{%
3039 % \end{macrocode}
3040 %
3041 % Personally I find slide titles somewhat intrusive in article mode. They can
3042 % easily end up duplicating section headings in running text, or captions in
3043 % figures. You may have other ideas, so we keep this behaviour configurable.
3044 %
3045 % \begin{optionvalue}{margin}
3046 % \begin{optionvalue}{none}
3047 % \begin{optionvalue}{para}
3048 % The \val{margin} value is implemented using \cs{marginpar}.
3049 %
3050 % \begin{macrocode}
3051 \ifcsstring{beamerswitch@articleframetitles}{margin}{%
3052 \setbeamertemplate{frametitle}{%
3053 \marginpar[%
3054 \raggedleft\noindent\itshape\textbf{\insertframetitle}\par
3055 \noindent\insertframesubtitle\par
3056 ]{%
3057 \raggedright\noindent\itshape\textbf{\insertframetitle}\par
3058 \noindent\insertframesubtitle\par
3059 }%
3060 }
3061 }{%
3062 \ifcsstring{beamerswitch@articleframetitles}{none}{%
3063 \setbeamertemplate{frametitle}{}
3064 }{%
3065 \ifcsstring{beamerswitch@articleframetitles}{para}{%
3066 \setbeamertemplate{frametitle}[default]
3067 }{}%
3068 }%
3069 }
3070 % \end{macrocode}
3071 % \end{optionvalue}
3072 % \end{optionvalue}
3073 % \end{optionvalue}
3074 %
3075 % This is where the \key{instbreak} option takes effect.
3076 %
3077 % \begin{macrocode}
3078 \let\beamer@andinst\beamerswitch@andinst
3079 % \end{macrocode}
3080 %
3081 % This is where we make our adjustments to \cs{maketitle}. We start by joining
3082 % the subtitle to the title by means of a colon instead of a newline.
3083 %
3084 % \begin{macrocode}
3085 \ifbool{AL@beamerswitch@maketitle}{%
3086 \renewcommand{\subtitle}[2][]{%
3087 \def\insertsubtitle{##2}\gappto\@title{\iftoggle{titlepunct}{}{:} ##2}%
3088 }
3089 % \end{macrocode}
3090 %
3091 % We add support for printing the institute information.
3092 %
3093 % \begin{macrocode}
3094 \ifundef{\beamer@originstitute}{%
3095 \renewcommand{\institute}[2][]{%
3096 \def\insertinstitute{\def\inst{\beamer@instinst}\def\and{\beamer@andinst}##2}}%
3097 }{%
3098 \renewcommand{\institute}[2][]{%
3099 \def\insertinstitute{\def\inst{\beamer@instinst}\def\and{\beamer@andinst}##2}%
3100 \beamer@originstitute{##2}}%
3101 }%
3102 % \end{macrocode}
3103 %
3104 % \changes{v1.1}{2016/08/19}{Remove personal customizations from \key{maketitle} code.}
3105 % Our first change to \cs{maketitle} itself is to remove the initial vertical
3106 % space.
3107 %
3108 % \begin{macrocode}
3109 \def\@maketitle{%
3110 \newpage
3111 \null
3112 \begin{center}%
3113 \let\footnote\thanks
3114 {\LARGE \@title \par}%
3115 \vskip 1.5em%
3116 {%
3117 \large\lineskip .5em%
3118 % \end{macrocode}
3119 %
3120 % \changes{v1.8}{2021/04/12}{Ensure proper rendering of \cs{inst} and \cs{and}
3121 % in \cs{author}.}
3122 % The second is to add the beamer definitions for \cs{inst} and \cs{and} in the
3123 % author row.
3124 %
3125 % \begin{macrocode}
3126 \begin{tabular}[t]{c}%
3127 \def\inst{\beamer@insttitle}\def\and{\beamer@andtitle}%
3128 \@author
3129 \end{tabular}\par
3130 }%
3131 % \end{macrocode}
3132 %
3133 % The third is to add in a row for the institute information.
3134 %
3135 % \begin{macrocode}
3136 \ifdefvoid{\insertinstitute}{}{%
3137 {%
3138 \normalsize\lineskip .5em%
3139 \insertinstitute\par
3140 }%
3141 }%
3142 \vskip 1em%
3143 {\large \@date}%
3144 \end{center}%
3145 \par\vskip 1.5em%
3146 }%
3147 }{}%
3148 }%
3149 % \end{macrocode}
3150 %
3151 % For consistency, if the \key{maketitle} option has been passed, we change the
3152 % PDF metadata in the other modes to use the colon convention for joining the
3153 % title and subtitle.
3154 %
3155 % \begin{macrocode}
3156 \mode<presentation>{%
3157 \ifbool{AL@beamerswitch@maketitle}{%
3158 \ifbool{beamer@autopdfinfo}{%
3159 \patchcmd{\beamer@firstminutepatches}{%
3160 \inserttitle\ifx\insertsubtitle\@empty\else\ - \insertsubtitle\fi
3161 }{%
3162 \inserttitle\ifx\insertsubtitle\@empty\else\iftoggle{titlepunct}{}{:} \insertsubtitle\fi
3163 }{}{}%
3164 }{}%
3165 }{}%
3166 }%
3167 }
3168 % \end{macrocode}
3169 % \end{macro}
3170 %
3171 % There is no more.
3172 %
3173 % \begin{macrocode}
3174 \endinput
3175 % \end{macrocode}
3176 % \iffalse
3177 %</class>
3178 % \fi
3179 %\Finale