summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/beamer-contrib/beamerswitch/beamerswitch.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/beamer-contrib/beamerswitch/beamerswitch.dtx')
-rw-r--r--macros/latex/contrib/beamer-contrib/beamerswitch/beamerswitch.dtx2931
1 files changed, 2931 insertions, 0 deletions
diff --git a/macros/latex/contrib/beamer-contrib/beamerswitch/beamerswitch.dtx b/macros/latex/contrib/beamer-contrib/beamerswitch/beamerswitch.dtx
new file mode 100644
index 0000000000..c61a227ede
--- /dev/null
+++ b/macros/latex/contrib/beamer-contrib/beamerswitch/beamerswitch.dtx
@@ -0,0 +1,2931 @@
+% \iffalse meta-comment
+%<*internal>
+\iffalse
+%</internal>
+%<*readme>
+# beamerswitch: Convenient mode selection in Beamer documents
+
+This class is a wrapper around the [beamer](http://ctan.org/pkg/beamer) class to
+make it easier to use the same document to generate the different forms of the
+presentation: the slides themselves, an abbreviated slide set for transparencies
+or online reference, an n-up handout version, and a transcript or set of notes
+using the `article` class.
+
+## Installation
+
+### Dependencies
+
+To compile the documentation you will need to have the
+[minted](http://ctan.org/pkg/minted) package working, which in turn relies on
+Python 2.6+ and Pygments. See the documentation of that package for details.
+
+There is an example file that demonstrates the features of the class. The class
+itself depends only on packages easily available through TeX distributions and
+CTAN. One feature relies on [latexmk](http://ctan.org/pkg/latexmk) though you
+can work around that if you have the patience.
+
+Note that the zip file on the
+[Releases](https://github.com/alex-ball/beamerswitch/releases) page on GitHub
+contains all the files you need, pre-compiled. You can also avoid the hassle by
+installing the class from your TeX distribution's package manager.
+
+### Managed way
+
+The latest stable release of the beamerswitch class has been packaged for
+TeX Live and MiKTeX. If you are running TeX Live and have `tlmgr`
+installed, you can install the package simply by running
+`tlmgr install beamerswitch`. If you are running MiKTeX, you can install the
+package by running `mpm --install=beamerswitch`. Both `tlmgr` and `mpm` have
+GUI versions that you might find friendlier.
+
+### Automated way
+
+A makefile is provided which you can use with the Make utility:
+
+ * Running `make beamerswitch.cls` just generates the class file (and a few
+ others).
+ * Running `make` generates the class file and documentation.
+ * Running `make inst` generates and installs the files to your home TeX tree.
+ (To undo, run `make uninst`.)
+ * Running `make install` generates and installs the files to the local TeX
+ tree. (To undo, run `make uninstall`.)
+ * Running `make clean` removes auxiliary files from the working directory.
+ * Running `make distclean` removes the generated from the working directory
+ files as well.
+
+### Manual way
+
+To install the class from scratch, follow these instructions. If you have
+downloaded the zip file from the [Releases] page on GitHub, you can skip the
+first three steps.
+
+ 1. Run `tex beamerswitch.dtx` to generate the class file and the example file
+ `beamerswitch-example.tex`. (You can safely skip this step if you are
+ confident about step 2.)
+
+ 2. Compile `beamerswitch.dtx` with your favourite version of LaTeX with shell
+ escape enabled (as required by `minted` for typesetting the listings). You
+ will also need to run it through `makeindex`. This will generate the main
+ documentation (DVI or PDF).
+
+ 3. Compile `beamerswitch-example.tex` with your favourite version of LaTeX. If
+ you enable shell escape and have `latexmk` installed you will end up with
+ another four documents (DVI or PDF). Otherwise you will get one.
+
+ 4. To install the files, create the following folders in your chosen TeX tree
+ and copy the files across as shown (read `.pdf` as `.dvi` if that is what
+ you generated):
+ - `source/latex/beamerswitch`:
+ `beamerswitch.dtx`,
+ (`beamerswitch.ins`)
+ - `tex/latex/beamerswitch`:
+ `beamerswitch.cls`
+ - `doc/latex/beamerswitch`:
+ `beamerswitch.pdf`,
+ `beamerswitch-example.tex`,
+ `beamerswitch-example.pdf`,
+ `beamerswitch-example-article.pdf`,
+ `beamerswitch-example-handout.pdf`,
+ `beamerswitch-example-trans.pdf`
+
+ 5. You may then have to update your installation's file name database
+ before TeX and friends can see the files.
+
+## Licence
+
+Copyright 2016–2019 Alex Ball.
+
+This work consists of the file beamerswitch.dtx and a Makefile.
+
+This work may be distributed and/or modified under the conditions of the
+[LaTeX Project Public License (LPPL)](http://www.latex-project.org/lppl.txt),
+either version 1.3c of this license or (at your option) any later version.
+
+This work is "maintained" (as per LPPL maintenance status) by
+[Alex Ball](http://alexball.me.uk/).
+
+%</readme>
+%<*example>
+\PassOptionsToClass{a4paper,12pt}{article}
+\PassOptionsToClass{14pt}{beamer}
+\documentclass[also={trans,handout,article}]{beamerswitch}
+\handoutlayout{nup=3plus,border=1pt}
+\articlelayout{maketitle,frametitles=none}
+\usepackage[british]{babel}
+\mode<article>{
+ \usepackage[hmargin=3cm,vmargin=2.5cm]{geometry}
+}
+\mode<presentation>{
+ \usefonttheme{professionalfonts}
+}
+\mode<handout>{
+ \usecolortheme{dove}
+}
+\usepackage{libertine}
+
+\title{A demonstration of the \textsf{beamerswitch} class}
+\subtitle{Testing features}
+\author{Alex Ball}
+\institute{University of Life}
+\date{1 September 2016}
+\subject{A LaTeX class}
+\keywords{CTAN, literate programming}
+
+\begin{document}
+ \begin{frame}
+ \maketitle
+ \end{frame}
+
+ This very brief demonstration shows how to use the \textsf{beamerswitch} class.
+ It allows easy switching between four \textsf{beamer} modes:
+
+ \begin{frame}{Beamer modes}
+ \begin{itemize}[<+->]
+ \item \textbf{beamer:} regular slides
+ \item \textbf{trans:} slides suitable for printing on transparencies
+ \item \textbf{handout:} slides suitable for printing on paper
+ \item \textbf{article:} transcript, paper, notes or other article-style
+ document based on the slides
+ \end{itemize}
+ \end{frame}
+
+ Notice how the text outside frames is only shown in article mode. Also,
+
+ \begin{frame}{Features shown in this example}
+ \begin{itemize}[<+->]
+ \item Different class options are passed to the \textsf{beamer} and
+ \textsf{article} classes.
+ \item The `trans' and `handout' versions do not have the intermediate
+ slides used by the `beamer' version for uncovering content.
+ \item The handout has three slides to a page with room for handwritten
+ notes at the side, and is in black and white.
+ \end{itemize}
+
+ \uncover<+->{See the source code of this example to see how it was done.}
+ \end{frame}
+
+ This PDF also has title and author information saved in the metadata (look
+ at the properties in your PDF viewer).
+
+ Happy {\LaTeX}ing!
+\end{document}
+%</example>
+%<*internal>
+\fi
+\def\nameofplainTeX{plain}
+\ifx\fmtname\nameofplainTeX\else
+ \expandafter\begingroup
+\fi
+%</internal>
+%<*install>
+\input docstrip.tex
+\keepsilent
+\askforoverwritefalse
+\preamble
+----------------------------------------------------------------
+beamerswitch --- Convenient mode selection in Beamer documents
+Author: Alex Ball
+E-mail: ab318@bath.ac.uk
+License: Released under the LaTeX Project Public License v1.3c or later
+See: http://www.latex-project.org/lppl.txt
+----------------------------------------------------------------
+
+\endpreamble
+\postamble
+
+Copyright (C) 2016-2019 by Alex Ball <ab318@bath.ac.uk>
+\endpostamble
+
+\usedir{tex/latex/\jobname}
+\generate{
+ \file{\jobname.cls}{\from{\jobname.dtx}{class}}
+}
+\usedir{doc/latex/\jobname}
+\generate{
+ \file{\jobname-example.tex}{\from{\jobname.dtx}{example}}
+}
+%</install>
+%<install>\endbatchfile
+%<*internal>
+\usedir{source/latex/\jobname}
+\generate{
+ \file{\jobname.ins}{\from{\jobname.dtx}{install}}
+}
+\nopreamble\nopostamble
+\usedir{doc/latex/\jobname}
+\generate{
+ \file{README.md}{\from{\jobname.dtx}{readme}}
+}
+\ifx\fmtname\nameofplainTeX
+ \expandafter\endbatchfile
+\else
+ \expandafter\endgroup
+\fi
+%</internal>
+%<*driver>
+\ProvidesFile{beamerswitch.dtx}
+%</driver>
+%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<class>\ProvidesClass{beamerswitch}
+%<*class>
+ [2019/06/06 v1.6 Convenient mode selection in Beamer documents]
+%</class>
+%<*driver>
+\documentclass[12pt]{article}
+% Page Layout
+\usepackage[a4paper,hmargin=30mm,vmargin=25mm,nohead]{geometry}
+% Typography
+\usepackage[charter,expert]{mathdesign}
+\makeatletter
+\def\hrulefill{\leavevmode\leaders \hrule height \rulethickness \hfill\kern\z@}
+\makeatother
+\usepackage{iftex}
+\ifPDFTeX
+ \usepackage[utf8]{inputenc}
+ \usepackage[T1]{fontenc}
+ \usepackage[scaled=0.96,sups]{XCharter}
+ \usepackage[scaled=0.95,tabular]{sourcesanspro}
+ \usepackage[varl,varqu]{zi4}
+\else
+ \usepackage{fontspec}
+ \setmainfont
+ [Scale=0.96
+ ,Ligatures=TeX
+ ]%
+ {XCharter}
+ \setsansfont
+ [Scale=MatchLowercase
+ ,Ligatures=TeX
+ ,StylisticSet=4
+ ,BoldFont={Source Sans Pro Bold}
+ ,ItalicFont={Source Sans Pro Italic}
+ ,BoldItalicFont={Source Sans Pro Bold Italic}
+ ]%
+ {Source Sans Pro}
+ \setmonofont
+ [Scale=MatchLowercase
+ ,RawFeature={extend=0.83}
+ ,BoldFont={Source Code Pro Bold}
+ ,BoldItalicFont={Source Code Pro Bold}
+ ,AutoFakeSlant=0.2
+ ,ItalicFeatures={StylisticSet=2,StylisticSet=3}
+ ,BoldItalicFeatures={FakeSlant=0.2,StylisticSet=2,StylisticSet=3}
+ ]%
+ {Source Code Pro}
+\fi
+% Improving the look of the documentation
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{6pt plus 2pt minus 1pt}
+\usepackage{multicol}
+\usepackage{enumitem}
+\setlist[itemize]{%
+ topsep={6pt plus 2pt minus 1pt},%
+ partopsep={0pt plus 0.05em},%
+ itemsep={0.2em plus 0.05em minus 0.05em},%
+ parsep={0pt plus 0.05em},%
+}
+\usepackage[bookmarks,raiselinks,pageanchor,hyperindex,colorlinks]{hyperref}
+\usepackage{etoolbox}
+\usepackage{tcolorbox,doc}
+\makeatletter
+\renewenvironment{theglossary}{%
+ \bgroup
+ \glossary@prologue
+ \GlossaryParms \let\item\@idxitem \ignorespaces
+}{%
+ \egroup
+}
+\makeatother
+\tcbuselibrary{documentation,breakable,minted}
+\colorlet{Option}{violet}
+\colorlet{Command}{red!75!black}
+\colorlet{Environment}{blue!75!black}
+\colorlet{Value}{olive!75!black}
+\colorlet{Color}{cyan!75!black}
+\tcbset
+ { listing engine=minted
+ , minted options=
+ { breaklines
+ , fontsize=\footnotesize
+ , linenos
+ , numbersep=20pt
+ , firstnumber=last
+ }
+ , index format=pgf
+ , color command=Command
+ , color environment=Environment
+ , color key=Option
+ , color value=Value
+ , color color=Color
+ , colbacktitle=ExampleFrame!33!ExampleBack
+ }
+\renewcommand{\theFancyVerbLine}{\footnotesize\itshape\color{gray}\arabic{FancyVerbLine}}
+\let\tcbcs=\cs
+\renewcommand*{\cs}[1]{\textcolor{Command}{\tcbcs{#1}}}
+\def\sqbrackets#1{%
+ \texttt{\textcolor{Option}{[}#1\textcolor{Option}{]}}}
+\def\brackets#1{%
+ \texttt{\textcolor{Environment}{\char`\{}#1\textcolor{Environment}{\char`\}}}}
+\def\marg#1{%
+ \textcolor{Environment}{\ttfamily\char`\{}\meta{#1}\textcolor{Environment}{\ttfamily\char`\}}}
+\newcommand*{\env}[1]{\textcolor{Environment}{\ttfamily #1}}
+\newcommand*{\key}[1]{\textcolor{Option}{\ttfamily #1}}
+\newcommand*{\val}[1]{\textcolor{Value}{\ttfamily #1}}
+
+\makeatletter
+\renewenvironment{macro}[1]{%
+ \StrSubstitute{#1}{\detokenize{@}}{"@}[\MyName]%
+ \edef\saved@macroname{\expandafter\string\csname #1\endcsname}%
+ \let\saved@indexname\saved@macroname
+ \index{\MyName @\tcbIndexPrintComC {\MyName}|(emph}%
+}{%
+ \ifdef{\MyName}{}{%
+ \errmessage{You have closed a macro environment you have not opened on \the\inputlineno.}%
+ }
+ \index{\MyName @\tcbIndexPrintComC {\MyName}|)}%
+}
+\renewenvironment{environment}[1]{%
+ \StrSubstitute{#1}{\detokenize{@}}{"@}[\MyName]%
+ \edef\saved@macroname{#1}%
+ \let\saved@indexname\saved@macroname
+ \index{\MyName @\tcbIndexPrintEnvCA {\MyName}|(emph}%
+ \index{Environments!\MyName @\tcbIndexPrintEnvC {\MyName}|(emph}%
+}{%
+ \ifdef{\MyName}{}{%
+ \errmessage{You have closed an environment environment you have not opened on \the\inputlineno.}%
+ }
+ \index{Environments!\MyName @\tcbIndexPrintEnvC {\MyName}|)}%
+ \index{\MyName @\tcbIndexPrintEnvCA {\MyName}|)}%
+}
+\makeatother
+\newenvironment{optionkey}[1]{%
+ \def\MyName{#1}%
+ \index{\MyName@\tcbIndexPrintKeyCA {\MyName}|(emph}%
+ \index{Keys!\MyName@\tcbIndexPrintKeyC {\MyName}|(emph}%
+}{%
+ \ifdef{\MyName}{}{%
+ \errmessage{You have closed an optionkey environment you have not opened on \the\inputlineno.}%
+ }
+ \index{Keys!\MyName@\tcbIndexPrintKeyC {\MyName}|)}%
+ \index{\MyName@\tcbIndexPrintKeyCA {\MyName}|)}%
+}
+\newenvironment{optionvalue}[1]{%
+ \def\MyName{#1}%
+ \index{\MyName@\tcbIndexPrintValCA {\MyName}|(emph}%
+ \index{Values!\MyName@\tcbIndexPrintValC {\MyName}|(emph}%
+}{%
+ \ifdef{\MyName}{}{%
+ \errmessage{You have closed an optionvalue environment you have not opened on \the\inputlineno.}%
+ }
+ \index{Values!\MyName@\tcbIndexPrintValC {\MyName}|)}%
+ \index{\MyName@\tcbIndexPrintValCA {\MyName}|)}%
+}
+\makeatletter
+\newcommand{\resetmintedformat}{%
+ % Comments
+ \expandafter\def\csname PYGdefault@tok@c\endcsname{\let\PYGdefault@it=\textit\def\PYGdefault@tc####1{\textcolor{gray}{####1}}}
+ % Command sequences
+ \expandafter\def\csname PYGdefault@tok@k\endcsname{\def\PYGdefault@tc####1{\textcolor{Command}{####1}}}
+ % Optional arguments
+ \expandafter\def\csname PYGdefault@tok@na\endcsname{\def\PYGdefault@tc####1{\textcolor{Option}{####1}}}
+ % Braces
+ \expandafter\def\csname PYGdefault@tok@nb\endcsname{\def\PYGdefault@tc####1{\textcolor{Environment}{####1}}}
+}
+\apptocmd{\minted@checkstyle}{\resetmintedformat}{}{}
+\makeatother
+\newcommand{\pkg}[1]{\href{http://www.ctan.org/pkg/#1}{\textsf{#1}}}
+\MakeShortVerb{\|}
+\makeatletter
+\let\PrintMacroName\@gobble
+\let\PrintEnvName\@gobble
+\renewenvironment{tcb@manual@entry}{\begin{list}{}{%
+ \setlength{\topsep}{0pt}
+ \setlength{\partopsep}{0pt}
+ \setlength{\leftmargin}{\kvtcb@doc@left}%
+ \setlength{\itemindent}{0pt}%
+ \setlength{\itemsep}{0pt}%
+ \setlength{\parsep}{0pt}%
+ \setlength{\rightmargin}{\kvtcb@doc@right}%
+ }\item}{\end{list}}
+\makeatother
+% This bit inspired by ydoc
+\makeatletter
+\newwrite\ydocwrite
+\def\ydocfname{\jobname.tcbtemp}
+\def\ydoc@catcodes{%
+ \let\do\@makeother
+ \dospecials
+ \catcode`\\=\active
+ \catcode`\^^M=\active
+ \catcode`\ =\active
+}
+\def\macrocode{%
+ \begingroup
+ \ydoc@catcodes
+ \macro@code
+}
+\def\endmacrocode{}
+\begingroup
+\endlinechar\m@ne
+\@firstofone{%
+\catcode`\|=0\relax
+\catcode`\(=1\relax
+\catcode`\)=2\relax
+\catcode`\*=14\relax
+\catcode`\{=12\relax
+\catcode`\}=12\relax
+\catcode`\ =12\relax
+\catcode`\%=12\relax
+\catcode`\\=\active
+\catcode`\^^M=\active
+\catcode`\ =\active
+}*
+|gdef|macro@code#1^^M% \end{macrocode}(*
+|endgroup|expandafter|macro@@code|expandafter(|ydoc@removeline#1|noexpand|lastlinemacro)*
+)*
+|gdef|ydoc@removeline#1^^M(|noexpand|firstlinemacro)*
+|gdef|ydoc@defspecialmacros(*
+|def^^M(|noexpand|newlinemacro)*
+|def (|noexpand|spacemacro)*
+|def\(|noexpand|bslashmacro)*
+)*
+|gdef|ydoc@defrevspecialmacros(*
+|def|newlinemacro(|noexpand^^M)*
+|def|spacemacro(|noexpand )*
+|def|bslashmacro(|noexpand\)*
+)*
+|endgroup
+\def\macro@@code#1{%
+ {\ydoc@defspecialmacros
+ \xdef\themacrocode{#1}}%
+ \PrintMacroCode
+ \end{macrocode}%
+}
+\def\PrintMacroCode{%
+ \begingroup
+ \let\firstlinemacro\empty
+ \let\lastlinemacro\empty
+ \def\newlinemacro{^^J}%
+ \let\bslashmacro\bslash
+ \let\spacemacro\space
+ \immediate\openout\ydocwrite=\ydocfname\relax
+ \immediate\write\ydocwrite{\themacrocode}%
+ \immediate\closeout\ydocwrite
+ \let\input\@input
+ \tcbinputlisting{breakable,listing only,docexample,listing file=\ydocfname}%
+ \endgroup
+}
+\makeatother
+
+\DisableCrossrefs
+\makeindex
+\RecordChanges
+\begin{document}
+
+\GetFileInfo{\jobname.dtx}
+\DoNotIndex{\documentclass,\newcommand,\newenvironment}
+
+\title{\textsf{beamerswitch} --- Convenient mode selection in Beamer documents}
+\author{Alex Ball}
+\date{Class \fileversion\ --- \filedate}
+
+\maketitle
+
+\begin{absquote}
+This class is a wrapper around the \pkg{beamer} class to make it easier to use the
+same document to generate the different forms of the presentation: the slides
+themselves, an abbreviated slide set for transparencies or online reference,
+an n-up handout version, and a transcript or set of notes using the \pkg{article}
+class.
+
+To contact the author about this package, please visit the GitHub
+page where the code is hosted: \url{https://github.com/alex-ball/beamerswitch}.
+\end{absquote}
+
+\changes{v1.2}{2016/05/22}{Add `Quick start guide' section.}
+\section{Quick start guide}
+
+Here are the key facts:
+
+\begin{itemize}
+\item
+ The \pkg{beamerswitch} class makes it easier to switch between
+ \pkg{beamer} modes.
+\item
+ It is aimed at you if you want to generate handouts from your
+ presentation, whether printouts of your slides or something more like a paper
+ or article.
+\item
+ It is \emph{not} a drop-in replacement for \pkg{beamer}.
+\end{itemize}
+
+If you have an existing \pkg{beamer} presentation and want convert it to use
+\pkg{beamerswitch} instead, here's what you need to do.
+
+\begin{enumerate}
+\item
+ Have you specified class options other than \key{ignorenonframetext}?
+ If so, start by rewriting your \cs{documentclass} line in terms of
+ \cs{PassOptionsToClass} -- note that the optional argument (in square
+ brackets) becomes mandatory (in curly braces):
+
+ \begin{multicols}{2}
+\begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
+\documentclass[10pt]{beamer}
+\end{dispListing*}
+ \columnbreak
+\begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
+\PassOptionsToClass{10pt}{beamer}
+\end{dispListing*}
+ \end{multicols}
+
+ Then add `\cs{documentclass}\brackets{beamerswitch}' directly below.
+
+ Otherwise, simply replace your \cs{documentclass} line with the
+ \texttt{beamerswitch} one.
+
+\item
+ If you did \emph{not} specify \key{ignorenonframetext} as one of your
+ \pkg{beamer} options, add a `\cs{mode}\texttt{<all>}' line directly after
+ `\cs{begin}\brackets{document}'.
+
+\item
+ Wrap any preamble content intended only for your slides (like \cs{usetheme}
+ or \cs{usepackage} commands) with `\cs{mode}\texttt{<presentation>}\meta{\dots}'
+ or something more specific, as required.
+\end{enumerate}
+
+In summary, here is an example:
+
+\begin{multicols}{2}
+\begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
+\documentclass[10pt]{beamer}
+
+
+\usetheme{metropolis}
+
+\title{Test presentation}
+\begin{document}
+
+ \maketitle
+\end{document}
+\end{dispListing*}
+ \columnbreak
+\begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
+\PassOptionsToClass{10pt}{beamer}
+\documentclass{beamerswitch}
+\mode<presentation>{%
+ \usetheme{metropolis}
+}
+\title{Test presentation}
+\begin{document}
+\mode<all>
+ \maketitle
+\end{document}
+\end{dispListing*}
+\end{multicols}
+
+At this point the document should compile exactly as before.
+
+If you intend to use article mode at all, I strongly suggest that you
+proceed by converting your document body so it that works without the
+`\cs{mode}\texttt{<all>}' line. That means making sure all slide content is in
+a \env{frame} environment, new command definitions are moved to the preamble,
+and so on.
+
+Lastly, read through the rest of this manual and see what \pkg{beamerswitch} can
+do for you!
+
+\section{Introduction}
+
+With \pkg{beamer}, it is possible to typeset the same document code in different
+ways to get different effects. The result you get depends on a potentially
+confusing mix of options, modes, and indeed classes.
+
+Beamer has five modes for typesetting content. There are three modes that
+produce regular slides:
+
+\begin{itemize}
+\item
+ The \key{beamer} mode relates to the normal, default slide set.
+\item
+ The \key{trans} class option switches to the mode of the same name. It is
+ intended for transparencies, but is really just an alternative mode that
+ ignores `bare' overlay specifications.
+\item
+ The \key{handout} class option switches to the mode of the same name. It is
+ intended for print-friendly versions, but is really just another alternative
+ mode that ignores `bare' overlay specifications.
+\end{itemize}
+
+The \pkg{beamer} manual shows how to use \key{handout} mode in conjunction
+with \pkg{pgfpages} to get several slides on a single side of A4 (or Letter)
+paper.
+
+Beamer can also produce a double-height or double-width slide set, with the
+intention that each half will be shown on a different display (e.g.\@ one for
+the audience, one for the speaker). There are three variations of this,
+activated using \cs{setbeameroption}:
+
+\begin{itemize}
+\item
+ \key{show notes on second screen} uses the second screen for text marked up
+ using \cs{note}\marg{text}.
+\item
+ \key{second mode text on second screen} uses the second screen for showing
+ the slide typeset in \key{second} mode rather than \key{beamer}. Unlike
+ \key{trans} and \key{handout}, \key{second} responds to `bare' overlay
+ specifications.
+\item
+ \key{previous slide on second screen}, uses the second screen either for
+ showing the previous slide or, if the slide has the \key{typeset second}
+ option set, for showing the current slide typeset in \key{second} mode.
+\end{itemize}
+
+The final variation is to use a different class altogether, such as
+\pkg{article}, in conjunction with \pkg{beamerarticle}. In this case the content
+is set free-flowing in \key{article} mode, without any of the frame furniture.
+
+The \pkg{beamer} manual suggests coping with all these variations by having the
+document code in one file, and using it as input to other files that each set up
+a different mode of operation. This is fine but a bit of a fiddle. It would be
+nice to be able to get the same effect using a single file and, ideally, a
+single command invocation.
+
+The \pkg{beamerswitch} class addresses this issue by acting as a wrapper around
+the various options, and providing a common interface for switching between
+modes. More specifically, it has three main functions:
+
+\begin{enumerate}
+\item
+ To provide more choice of handout-mode layouts than \pkg{pgfpages} gives you
+ out-of-the-box. Additionally, I hope you will find the method for selecting
+ them more memorable.
+\item
+ To enable you to switch to \key{article} mode with a simple change of class
+ option, instead of having to fiddle with commented-out \cs{documentclass} and
+ \cs{usepackage} lines.
+\item
+ To allow you to override the \pkg{beamer} mode from the command line, by
+ choosing a given jobname suffix. Primarily this is to allow you to generate
+ the different versions programmatically. Indeed, the class provides facilities
+ for generating multiple versions with a single command.
+\end{enumerate}
+
+\section{Dependencies}
+
+To use \pkg{beamerswitch}, you will need to have the following packages available
+and reasonably up to date on your system. All of these ship with recent \TeX\
+distributions.
+
+\begin{multicols}{3}
+ \begin{itemize}
+ \item \pkg{beamer}
+ \item \pkg{etoolbox}
+ \item \pkg{hyperref}
+ \item \pkg{iftex}
+ \item \pkg{pgf}
+ \item \pkg{shellesc}
+ \item \pkg{xkeyval}
+ \item \pkg{xstring}
+ \end{itemize}
+\end{multicols}
+
+One feature of the class uses \pkg{latexmk} by default, though you can configure
+it to use something else if you need or want to.
+
+\section{Loading the class}
+
+The class is loaded in the usual way:
+
+\begin{tcolorbox}[docexample,fontupper=\small]
+\cs{documentclass}\oarg{options}\brackets{beamerswitch}
+\end{tcolorbox}
+
+The various options are described below.
+
+\subsection{Choosing the mode of the current run}
+
+The \pkg{beamerswitch} class, as explained above, does not do much itself but
+rather helps you to switch between \pkg{beamer} modes, specifically
+\key{article}, \key{beamer}, \key{trans} and \key{handout}. Note that it loads
+\pkg{beamer} with the \key{ignorenonframetext} option, so that text outside
+frames is only shown in \key{article} mode.
+
+The normal way of choosing the mode is to use the respective class options.
+
+\begin{docKey}{article}{}{no value, initially unset}
+ Switches to \key{article} mode, which uses the \pkg{article} class and
+ resembles a normal article.
+\end{docKey}
+
+\begin{docKey}{beamer}{}{no value, initially set}
+ Switches to \key{beamer} mode, which uses the \pkg{beamer} class and
+ resembles a normal slideshow.
+\end{docKey}
+
+\begin{docKey}{handout}{}{no value, initially unset}
+ Switches to \key{handout} mode, which uses the \pkg{beamer} class but uses a
+ different series of overlay specifications. It resembles a set of printed
+ pages with multiple slides shown on each page.
+\end{docKey}
+
+\begin{docKey}{trans}{}{no value, initially unset}
+ Switches to \key{trans} mode, which uses the \pkg{beamer} class and
+ resembles a normal slideshow, but uses a different series of overlay
+ specifications.
+\end{docKey}
+
+There is, however, a sneaky second way of setting the mode that overrides the
+first, and that is to use the \cs{jobname}. By default, this is the name of your
+\LaTeX\ file minus the \texttt{.tex} extension, but you can set it to something
+else when you run \LaTeX. If you set the \cs{jobname} to end in one of the
+following suffixes, the mode will automatically switch:
+
+\begin{itemize}
+ \item \texttt{-article} will switch to \key{article} mode.
+ \item \texttt{-handout} will switch to \key{handout} mode.
+ \item \texttt{-slides} will switch to \key{beamer} mode.
+ \item \texttt{-trans} will switch to \key{trans} mode.
+\end{itemize}
+
+The idea is that you can keep your source document the same, but by running
+\LaTeX\ with an alternative \cs{jobname}, you can get a different version out
+with a meaningfully different file name.
+
+Of course, you may not want to use those suffixes. Perhaps you want them in
+German; perhaps your document's file name already ends in one of them; perhaps
+`article' or `trans' doesn't describe what you're using those modes for. The
+suffixes are provided by the following commands:
+
+\begin{docCommand}{ArticleSuffix}{}
+ Holds the \cs{jobname} suffix that triggers \key{article} mode.
+\end{docCommand}
+
+\begin{docCommand}{BeamerSuffix}{}
+ Holds the \cs{jobname} suffix that triggers \key{beamer} mode.
+\end{docCommand}
+
+\begin{docCommand}{HandoutSuffix}{}
+ Holds the \cs{jobname} suffix that triggers \key{handout} mode.
+\end{docCommand}
+
+\begin{docCommand}{TransSuffix}{}
+ Holds the \cs{jobname} suffix that triggers \key{trans} mode.
+\end{docCommand}
+
+The CamelCase is an admittedly rather obscure signal to you that, if you want to
+change them to something else, you should do so via \cs{newcommand} before
+loading the class:
+
+\begin{dispListing}
+\newcommand*{\ArticleSuffix}{-script}
+\documentclass{beamerswitch}
+\end{dispListing}
+
+\subsection{Using more than one mode at once}
+
+Another handy feature of the class is that it can spawn parallel compilations,
+so you could in theory generate all four versions from a single command. It
+achieves this magic by escaping to the shell and running \pkg{latexmk}. Thus
+for it to work you need to run \LaTeX\ with shell escape enabled and you need
+\pkg{latexmk} to be installed.
+
+\begin{docKey}{alsoarticle}{}{no value, initially unset}
+ Spawns a new compilation process in \key{article} mode.
+\end{docKey}
+
+\begin{docKey}{alsobeamer}{}{no value, initially unset}
+ Spawns a new compilation process in \key{beamer} mode.
+\end{docKey}
+
+\begin{docKey}{alsohandout}{}{no value, initially unset}
+ Spawns a new compilation process in \key{handout} mode.
+\end{docKey}
+
+\begin{docKey}{alsotrans}{}{no value, initially unset}
+ Spawns a new compilation process in \key{trans} mode.
+\end{docKey}
+
+\begin{docKey}{also}{=\marg{comma-separated list of modes}}{no default, initially empty}
+ Spawns compilation processes in each of the specified modes. Note that the
+ list has to be wrapped in braces, and only the four aforementioned modes are
+ recognized.
+\end{docKey}
+
+If you would rather use a tool other than \pkg{latexmk} to managed your spawned
+compilation processes, it is possible to do that. Bear in mind, though, that
+\pkg{beamerswitch} is not clever enough to spot if you have already compiled the
+other version on a previous run so you have to take care of that yourself. The
+command that does the business is this:
+
+\changes{v1.1}{2016/08/19}{Improve documentation of \cs{BeamerswitchSpawn}, \cs{handoutlayout} and \cs{articlelayout}.}
+\begin{docCommand}{BeamerswitchSpawn}{\marg{suffix}}
+ Spawns a new compilation process with \meta{suffix} appended to the
+ \cs{jobname}.
+\end{docCommand}
+
+By default, \cs{BeamerswitchSpawn} checks which \LaTeX\ engine you are running,
+and then runs the matching one of \cs{SpawnedPDFTeX}, \cs{SpawnedXeTeX},
+\cs{SpawnedLuaTeX}, or if all the tests fail, \cs{SpawnedTeX}, with the converted
+\cs{jobname}. These commands all add an engine-selecting option to a base
+command, \cs{SpawnedCompiler}, which by default is \pkg{latexmk} with synctex
+enabled, shell escape disabled and interaction set to batch mode. See the
+\hyperref[sec:switching]{Implementation} section below for details.
+
+Any of these commands can be pre-defined to something else, depending on what
+you want to do. So, for example, if you want to change the base \pkg{latexmk}
+options, pre-define \cs{SpawnedCompiler} to \texttt{latexmk} plus your chosen
+options:
+
+\begin{dispListing}
+\newcommand*{\SpawnedCompiler}{%
+ latexmk -silent -shell-escape -interaction=nonstopmode}
+\documentclass{beamerswitch}
+\end{dispListing}
+
+If you want to switch to using \texttt{rubber}, say, pre-define
+\cs{SpawnedPDFTeX} and friends accordingly (perhaps taking advantage of
+\cs{SpawnedCompiler} to reduce repetition):
+
+\begin{dispListing}
+\newcommand*{\SpawnedCompiler}{rubber -q --synctex}
+\newcommand*{\SpawnedPDFTeX}{\SpawnedCompiler -m pdftex}
+\newcommand*{\SpawnedXeTeX}{\SpawnedCompiler -m xelatex}
+\documentclass{beamerswitch}
+\end{dispListing}
+
+If you don't need the engine selection routine provided, simply pre-define
+\cs{BeamerswitchSpawn} to do whatever you need it to do:
+
+\begin{dispListing}
+\newcommand*{\BeamerswitchSpawn}[1]{%
+ \ShellEscape{... -jobname=\jobname#1 \jobname}%
+}
+\documentclass{beamerswitch}
+\end{dispListing}
+
+If you want to use \pkg{arara} to compile everything, the class options won't
+help you as \pkg{arara} does not let you change \cs{jobname}s on the command line.
+That's no problem, though, because you can do it manually within your list of
+directives:
+
+\begin{dispListing}
+% arara: lualatex
+% arara: lualatex: { options: "-jobname beamerswitch-example-article" }
+% arara: lualatex: { options: "-jobname beamerswitch-example-handout" }
+% arara: lualatex: { options: "-jobname beamerswitch-example-trans" }
+\documentclass{beamerswitch}
+\end{dispListing}
+
+\subsection{Improving compatibility}
+
+\begin{docKey}{nohyperref}{}{no value, initially unset}
+ 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
+ caught out. To protect you from this, \pkg{beamerswitch} \emph{does} load
+ \pkg{hyperref} in \key{article} mode, with the pleasing side effect that
+ \cs{subject} and \cs{keywords} then work as intended instead of throwing
+ errors.
+
+ \medskip
+ To achieve this, the class has to load \pkg{hyperref} quite early on, which
+ can cause trouble with certain other packages. If you would rather
+ load \pkg{hyperref} yourself at a different point, use this option.
+\end{docKey}
+
+\begin{docKey}{textinst}{}{no value, initially unset}
+ In all modes, patches the \cs{inst} command so that it prints its argument
+ using \cs{textsuperscript} instead of a mathematical superscript. This helps
+ avoid unnecessary font changes.
+\end{docKey}
+
+\section{Setting the layout of the handouts}
+
+The class provides a simplified interface to the \pkg{pgfpages} package. By
+default, it prints six slides to a side of A4 paper, but you can change this by
+using the following command in the preamble.
+
+\begin{docCommand}{handoutlayout}{\marg{options}}
+ Configures the layout of the page when using \key{handout} mode. It has no
+ effect in other modes. The available \meta{options} are listed below.
+\end{docCommand}
+
+\begin{docKey}{paper}{=\meta{paper size}}{no default, initially \val{a4paper}}
+ Selects the size of paper to use for \key{handout} mode. The value is passed
+ directly to \pkg{pgfpages}, so consult the documentation of that package for
+ the allowed values. You can find them under the documentation for the
+ \key{resize to} layout.
+\end{docKey}
+
+\begin{docKey}{nup}{=\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}}
+ Selects how many slides are shown on a single page in \key{handout} mode.
+ The `plus' layouts leave blank space for recipients to make handwritten notes
+ 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 \docValue{2},
+ \docValue{3plus}, \docValue{4} and \docValue{6} layouts are intended for
+ slides in the usual 4:3 aspect ratio, while the \docValue{3}, \docValue{4plus}
+ and \docValue{8} layouts are intended for widescreen slides.
+\end{docKey}
+
+\newtcolorbox{pseudopage}[1][]%
+{sharp corners
+ ,width=7.1em
+ ,halign=flush center
+ ,height=10em
+ ,valign=center
+ ,size=fbox
+ ,boxrule=0.5mm
+ ,colback=yellow!5
+ ,#1
+}
+\newtcolorbox{pseudoslide}[1][]%
+{nobeforeafter
+ ,width=3em
+ ,halign=flush center
+ ,height=2.25em
+ ,valign=center
+ ,size=fbox
+ ,boxrule=0.5mm
+ ,colframe=ExampleFrame
+ ,colback=ExampleBack
+ ,#1
+}
+\newtcolorbox{pseudowideslide}[1][]%
+{nobeforeafter
+ ,width=3em
+ ,halign=flush center
+ ,height=1.69em
+ ,valign=center
+ ,size=fbox
+ ,boxrule=0.5mm
+ ,colframe=ExampleFrame
+ ,colback=ExampleBack
+ ,#1
+}
+\begin{figure}[t!]
+ \centering
+ \begin{minipage}[b]{11em}
+ \centering
+ \begin{pseudopage}
+ \begin{pseudoslide}[width=6em,height=4.5em]
+ \texttt{1}
+ \end{pseudoslide}\par\smallskip
+ \begin{pseudoslide}[width=6em,height=4.5em]
+ \texttt{2}
+ \end{pseudoslide}
+ \end{pseudopage}
+ \par
+ (a) \key{nup}=\val{2}
+ \end{minipage}
+ \begin{minipage}[b]{11em}
+ \centering
+ \begin{pseudopage}
+ \begin{pseudowideslide}[width=4.89em,height=2.75em]
+ \texttt{1}
+ \end{pseudowideslide}
+ \par\smallskip
+ \begin{pseudowideslide}[width=4.89em,height=2.75em]
+ \texttt{2}
+ \end{pseudowideslide}
+ \par\smallskip
+ \begin{pseudowideslide}[width=4.89em,height=2.75em]
+ \texttt{3}
+ \end{pseudowideslide}
+ \end{pseudopage}
+ \par
+ (b) \key{nup}=\val{3}
+ \end{minipage}
+ \begin{minipage}[b]{11em}
+ \centering
+ \begin{pseudopage}[halign=flush left]
+ \begin{pseudoslide}\texttt{1}\end{pseudoslide}
+ \par\medskip
+ \begin{pseudoslide}\texttt{2}\end{pseudoslide}
+ \par\medskip
+ \begin{pseudoslide}\texttt{3}\end{pseudoslide}
+ \end{pseudopage}
+ \par
+ (c) \key{nup}=\val{3plus}
+ \end{minipage}
+ \par\bigskip
+ \begin{minipage}[b]{11em}
+ \centering
+ \begin{pseudopage}[width=10em,height=7.1em]
+ \begin{pseudoslide}[width=4em,height=3em]
+ \texttt{1}
+ \end{pseudoslide}\enspace
+ \begin{pseudoslide}[width=4em,height=3em]
+ \texttt{2}
+ \end{pseudoslide}\par\smallskip
+ \begin{pseudoslide}[width=4em,height=3em]
+ \texttt{3}
+ \end{pseudoslide}\enspace
+ \begin{pseudoslide}[width=4em,height=3em]
+ \texttt{4}
+ \end{pseudoslide}
+ \end{pseudopage}
+ \par
+ (d) \key{nup}=\val{4}
+ \end{minipage}
+ \begin{minipage}[b]{11em}
+ \centering
+ \begin{pseudopage}[halign=flush left]
+ \begin{pseudowideslide}\texttt{1}\end{pseudowideslide}
+ \par\medskip
+ \begin{pseudowideslide}\texttt{2}\end{pseudowideslide}
+ \par\medskip
+ \begin{pseudowideslide}\texttt{3}\end{pseudowideslide}
+ \par\medskip
+ \begin{pseudowideslide}\texttt{4}\end{pseudowideslide}
+ \end{pseudopage}
+ \par
+ (e) \key{nup}=\val{4plus}
+ \end{minipage}
+ \begin{minipage}[b]{11em}
+ \centering
+ \begin{pseudopage}
+ \begin{pseudoslide}\texttt{1}\end{pseudoslide}
+ \begin{pseudoslide}\texttt{2}\end{pseudoslide}
+ \par\medskip
+ \begin{pseudoslide}\texttt{3}\end{pseudoslide}
+ \begin{pseudoslide}\texttt{4}\end{pseudoslide}
+ \par\medskip
+ \begin{pseudoslide}\texttt{5}\end{pseudoslide}
+ \begin{pseudoslide}\texttt{6}\end{pseudoslide}
+ \end{pseudopage}
+ \par
+ (f) \key{nup}=\val{6}
+ \end{minipage}
+ \par\bigskip
+ \begin{minipage}[b]{11em}
+ \centering
+ \begin{pseudopage}
+ \begin{pseudowideslide}\texttt{1}\end{pseudowideslide}
+ \begin{pseudowideslide}\texttt{2}\end{pseudowideslide}
+ \par\medskip
+ \begin{pseudowideslide}\texttt{3}\end{pseudowideslide}
+ \begin{pseudowideslide}\texttt{4}\end{pseudowideslide}
+ \par\medskip
+ \begin{pseudowideslide}\texttt{5}\end{pseudowideslide}
+ \begin{pseudowideslide}\texttt{6}\end{pseudowideslide}
+ \par\medskip
+ \begin{pseudowideslide}\texttt{7}\end{pseudowideslide}
+ \begin{pseudowideslide}\texttt{8}\end{pseudowideslide}
+ \end{pseudopage}
+ \par
+ (g) \key{nup}=\val{8}
+ \end{minipage}
+ \par
+ \caption{Handout layouts provided by \pkg{beamerswitch}}
+ \label{fig:layouts}
+\end{figure}
+
+\begin{docKey}{pnos}{}{no value, initially unset}
+ Adds page numbers to the bottom of each page. The number appears at a distance
+ of \cs{handoutpnobaseline} (initially 5mm) from the bottom edge of the page.
+ You can change this before calling \cs{handoutlayout}, if you like, using the
+ usual mechanisms (e.g.\@ \cs{setlength}).
+\end{docKey}
+
+\begin{docKey}{border}{=\meta{length}}{default 0.4pt, initially 0pt}
+ Puts a rectangular border of thickness \meta{length} around each slide.
+\end{docKey}
+
+\begin{docKey}{margin}{=\meta{length}}{default 0pt, initially 5mm}
+ Sets how much extra space to leave around each slide on the page. To achieve
+ this it uses the \key{border shrink} option from \pkg{pgfpages}. If you add
+ page numbers, this value will increase if necessary to prevent the number
+ colliding with the slides, so treat it as a minimum.
+\end{docKey}
+
+\begin{docKey}{align}{}{no value, initially unset}
+ When \key{margin} is non-zero, the effective page margins are approximately
+ half the size of the gaps between slides (some additional white space comes
+ from preserving the aspect ratio of the slides). When set, this option tweaks
+ the positions of the slides so that the page margins are approximately the
+ same as the interior gaps.
+\end{docKey}
+
+\section{Changing the look of article mode}
+
+Some additional options can be set by using the following command in the
+preamble.
+
+\begin{docCommand}{articlelayout}{\marg{options}}
+ Configures the appearance of \key{article} mode. It has no effect in other
+ modes. The available \meta{options} are listed below.
+\end{docCommand}
+
+\begin{docKey}{frametitles}{=\val{para}\textbar\val{margin}\textbar\val{none}}{no default, initially \val{para}}
+ In \key{article} mode, affects how frame titles are printed. By default,
+ \pkg{beamerarticle} prints them as paragraph headings, represented by
+ the value \docValue{para}. To have them printed in the margin (using
+ \cs{marginpar}), use \docValue{margin}. To omit them altogether, use the value
+ \docValue{none}.
+\end{docKey}
+
+\begin{docKey}{maketitle}{}{no value, initially unset}
+ In \key{article} mode, adjusts the \cs{maketitle} routine:
+ \begin{itemize}
+ \item
+ The title is printed closer to the top margin.
+ \item
+ The subtitle is shown joined to the title using a colon (rather than on a
+ new line).
+ \item
+ The institute is shown directly beneath the author name, similar to the
+ \pkg{beamer} layout, so you can use \cs{inst} just as in \pkg{beamer} to tie
+ authors to their affiliations.
+ \end{itemize}
+
+ If you have \pkg{xparse} (and hence \pkg{expl3}) installed, the class will
+ detect cases where your title ends in a character like `?' and will not add a
+ colon to it in that case. You can also suppress the colon manually with the
+ following code (add it \emph{after} using \cs{title} if automatic detection is
+ in effect):
+
+\begin{dispListing}
+\toggletrue{titlepunct}
+\end{dispListing}
+\end{docKey}
+
+\section{Tips for further configuration}
+
+There are some other ways to customize the behaviour of the various modes.
+
+You can use the standard \LaTeX\ methods for customizing how the \pkg{article}
+and \pkg{beamer} classes are loaded:
+
+\begin{dispListing}
+\PassOptionsToClass{a4paper,11pt}{article} % for article mode
+\PassOptionsToClass{utf8}{beamer} % for beamer, handout, trans modes
+\documentclass{beamerswitch}
+\end{dispListing}
+
+And of course there is the standard \pkg{beamer} way of passing different
+options to different modes:
+
+\begin{dispListing}
+\documentclass{beamerswitch}
+\mode<article>{
+ \usepackage[utf8]{inputenc}
+}
+\mode<beamer>{
+ \setbeameroption{second mode text on second screen}
+}
+\end{dispListing}
+
+\section{Feedback}
+
+I hope you find this class useful. Please report any bugs and add any
+suggestions for improvements or new features to the
+\href{https://github.com/alex-ball/beamerswitch/issues}{Issue Tracker} on GitHub.
+
+\StopEventually{^^A
+ \PrintChanges
+ \printindex
+}
+
+\newpage
+\section{Implementation}\label{sec:implementation}
+
+\setcounter{FancyVerbLine}{18}%
+\DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+% \iffalse
+%<*class>
+% \fi
+%
+% \subsection{Dependencies}
+%
+% We use the following packages:
+% \begin{itemize}
+% \item
+% \pkg{xkeyval} with \pkg{xkvltxp} for setting options
+% \item
+% \pkg{etoolbox} for command patches and list processing
+% \item
+% \pkg{xstring} for comparisons
+% \item
+% \pkg{shellesc} for running parallel compilations
+% \item
+% \pkg{iftex} for determining which engine to use
+% \end{itemize}
+%
+% \begin{macrocode}
+\RequirePackage{xkeyval,xkvltxp,etoolbox,xstring,shellesc,iftex}
+% \end{macrocode}
+%
+% \subsection{Class options}
+%
+% We recognize four main modes of operation: `beamer', `trans', `handout', and
+% `article'.
+%
+% \begin{optionkey}{beamer}
+% The \key{beamer} option triggers beamer mode.
+%
+% \begin{macrocode}
+\define@boolkey[DC]{beamerswitch}{beamer}[true]{%
+ \ifbool{DC@beamerswitch@beamer}{%
+ \setkeys[DC]{beamerswitch}{trans=false}
+ \setkeys[DC]{beamerswitch}{handout=false}
+ \setkeys[DC]{beamerswitch}{article=false}
+ }{}%
+}
+% \end{macrocode}
+% \end{optionkey}
+%
+% \begin{optionkey}{trans}
+% The \key{trans} option triggers trans mode.
+%
+% \begin{macrocode}
+\define@boolkey[DC]{beamerswitch}{trans}[true]{%
+ \ifbool{DC@beamerswitch@trans}{%
+ \setkeys[DC]{beamerswitch}{beamer=false}
+ \setkeys[DC]{beamerswitch}{handout=false}
+ \setkeys[DC]{beamerswitch}{article=false}
+ }{}%
+}
+% \end{macrocode}
+% \end{optionkey}
+%
+% \begin{optionkey}{handout}
+% The \key{handout} option triggers handout mode.
+%
+% \begin{macrocode}
+\define@boolkey[DC]{beamerswitch}{handout}[true]{%
+ \ifbool{DC@beamerswitch@handout}{%
+ \setkeys[DC]{beamerswitch}{beamer=false}
+ \setkeys[DC]{beamerswitch}{trans=false}
+ \setkeys[DC]{beamerswitch}{article=false}
+ }{}%
+}
+% \end{macrocode}
+% \end{optionkey}
+%
+% \begin{optionkey}{article}
+% The \key{article} option triggers article mode.
+%
+% \begin{macrocode}
+\define@boolkey[DC]{beamerswitch}{article}[true]{%
+ \ifbool{DC@beamerswitch@article}{%
+ \setkeys[DC]{beamerswitch}{beamer=false}
+ \setkeys[DC]{beamerswitch}{trans=false}
+ \setkeys[DC]{beamerswitch}{handout=false}
+ }{}%
+}
+% \end{macrocode}
+% \end{optionkey}
+%
+% \begin{optionkey}{also}
+% \begin{optionkey}{alsobeamer}
+% \begin{optionkey}{alsotrans}
+% \begin{optionkey}{alsohandout}
+% \begin{optionkey}{alsoarticle}
+% \begin{macro}{beamerswitch@SetAlso}
+% The \key{also} option allows the user to specify a set of alternative modes
+% to typeset in parallel, in a comma-separated list. Alternatively, the user
+% can specify the Boolean \key{also*} options directly.
+%
+% \begin{macrocode}
+\define@boolkey[DC]{beamerswitch}{alsobeamer}[true]{}
+\define@boolkey[DC]{beamerswitch}{alsotrans}[true]{}
+\define@boolkey[DC]{beamerswitch}{alsohandout}[true]{}
+\define@boolkey[DC]{beamerswitch}{alsoarticle}[true]{}
+\newcommand{\beamerswitch@SetAlso}[1]{%
+ \key@ifundefined[DC]{beamerswitch}{also#1}{%
+ \ClassWarning{beamerswitch}{`#1' is not a valid value for option `also'}%
+ }{%
+ \setkeys[DC]{beamerswitch}{also#1}%
+ }%
+}
+\define@key[DC]{beamerswitch}{also}{%
+ \forcsvlist{\beamerswitch@SetAlso}{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{optionkey}
+% \end{optionkey}
+% \end{optionkey}
+% \end{optionkey}
+% \end{optionkey}
+%
+% \begin{optionkey}{nohyperref}
+% The \key{nohyperref} option stops the class from loading the \pkg{hyperref}
+% package in article mode.
+%
+% \begin{macrocode}
+\define@boolkey[DC]{beamerswitch}{nohyperref}[true]{}
+% \end{macrocode}
+% \end{optionkey}
+%
+% \begin{optionkey}{textinst}
+% The \key{textinst} option adjusts the superscript used for institution
+% markers.
+%
+% \begin{macrocode}
+\define@boolkey[DC]{beamerswitch}{textinst}[true]{}
+% \end{macrocode}
+% \end{optionkey}
+%
+% The default behaviour is to use beamer mode only.
+%
+% \begin{macrocode}
+\setkeys[DC]{beamerswitch}{beamer=true,alsobeamer=false,alsotrans=false,%
+ alsohandout=false,alsoarticle=false}
+% \end{macrocode}
+%
+% Now we process the options given by the user.
+%
+% \begin{macrocode}
+\ProcessOptionsX[DC]<beamerswitch>
+% \end{macrocode}
+%
+% \subsection{Jobname-based mode switching}\label{sec:switching}
+%
+% \begin{macro}{BeamerSuffix}
+% \begin{macro}{TransSuffix}
+% \begin{macro}{HandoutSuffix}
+% \begin{macro}{ArticleSuffix}
+% We define some default values for the special suffixes.
+%
+% \begin{macrocode}
+\providecommand*{\BeamerSuffix}{-slides}
+\providecommand*{\TransSuffix}{-trans}
+\providecommand*{\HandoutSuffix}{-handout}
+\providecommand*{\ArticleSuffix}{-article}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{BeamerswitchSpawn}
+% \changes{v1.3}{2017/12/10}{Decompose \cs{BeamerswitchSpawn} into further configurable macros.}
+% \begin{macro}{SpawnedTeX}
+% \begin{macro}{SpawnedPDFTeX}
+% \begin{macro}{SpawnedXeTeX}
+% \begin{macro}{SpawnedLuaTeX}
+% \begin{macro}{SpawnedCompiler}
+% We provide a special routine for spawning new \LaTeX\ processes. We allow
+% for the possibility of the user overriding this routine with another one,
+% perhaps using a different automation tool; it should take one argument, being
+% the jobname suffix.
+%
+% \begin{macrocode}
+\providecommand{\SpawnedCompiler}{latexmk -silent -synctex=1 -interaction=batchmode }
+\providecommand{\SpawnedTeX}{\SpawnedCompiler}
+\providecommand{\SpawnedPDFTeX}{\SpawnedCompiler -pdf }
+\providecommand{\SpawnedLuaTeX}{\SpawnedCompiler -pdflua }
+\providecommand{\SpawnedXeTeX}{\SpawnedCompiler -pdfxe }
+\providecommand{\BeamerswitchSpawn}[1]{%
+ \ifbool{PDFTeX}{%
+ \ShellEscape{\SpawnedPDFTeX -jobname=\jobname#1 \jobname}
+ }{%
+ \ifbool{LuaTeX}{%
+ \ShellEscape{\SpawnedLuaTeX -jobname=\jobname#1 \jobname}
+ }{%
+ \ifbool{XeTeX}{%
+ \ShellEscape{\SpawnedXeTeX -jobname=\jobname#1 \jobname}
+ }{%
+ \ShellEscape{\SpawnedTeX -jobname=\jobname#1 \jobname}
+ }%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{JobName}
+% \changes{v1.6}{2019/06/06}{Fix bug triggered by spaces in job names.}
+% We check for special jobnames and use them to override the above mode-related
+% options. In certain circumstances, the jobname is wrapped in quote marks, so
+% in that case we strip them off before running the tests.
+%
+% \begin{macrocode}
+\IfBeginWith*{\jobname}{"}{%
+ \IfEndWith*{\jobname}{"}{%
+ \StrGobbleLeft{\jobname}{1}[\JobName]%
+ \StrGobbleRight{\JobName}{1}[\JobName]%
+ }{\let\JobName\jobname}%
+}{\let\JobName\jobname}
+% \end{macrocode}
+% \end{macro}
+%
+% Now we run the tests. Note that the \key{also*} options are only acted upon
+% if the all the tests fail.
+%
+% \begin{macrocode}
+\IfEndWith*{\JobName}{\BeamerSuffix}{%
+ \setkeys[DC]{beamerswitch}{beamer=true}
+}{%
+ \IfEndWith*{\JobName}{\TransSuffix}{%
+ \setkeys[DC]{beamerswitch}{trans=true}
+ }{%
+ \IfEndWith*{\JobName}{\HandoutSuffix}{%
+ \setkeys[DC]{beamerswitch}{handout=true}
+ }{%
+ \IfEndWith*{\JobName}{\ArticleSuffix}{%
+ \setkeys[DC]{beamerswitch}{article=true}
+ }{%
+ \ifbool{DC@beamerswitch@alsobeamer}{%
+ \BeamerswitchSpawn{\BeamerSuffix}%
+ }{}
+ \ifbool{DC@beamerswitch@alsotrans}{%
+ \BeamerswitchSpawn{\TransSuffix}%
+ }{}
+ \ifbool{DC@beamerswitch@alsohandout}{%
+ \BeamerswitchSpawn{\HandoutSuffix}%
+ }{}
+ \ifbool{DC@beamerswitch@alsoarticle}{%
+ \BeamerswitchSpawn{\ArticleSuffix}%
+ }{}
+ }%
+ }%
+ }%
+}%
+% \end{macrocode}
+%
+% \subsection{Setting up modes}
+%
+% For article mode, we load the \pkg{article} class and the \pkg{beamerarticle}
+% support package. Apologies for anyone hoping for \pkg{scrartcl} or
+% \pkg{memoir} alternatives.
+%
+% \begin{macrocode}
+\ifbool{DC@beamerswitch@article}{%
+ \LoadClass{article}
+ \RequirePackage{beamerarticle}
+% \end{macrocode}
+%
+% It seems as though \pkg{beamerarticle} expects \pkg{hyperref} to be loaded,
+% but doesn't actually do it itself. So we oblige, using the default options
+% specified by \pkg{beamer}.
+%
+% \begin{macrocode}
+ \ifbool{DC@beamerswitch@nohyperref}{}{%
+ \RequirePackage[bookmarks=true,%
+ bookmarksopen=true,%
+ pdfborder={0 0 0},%
+ pdfhighlight={/N},%
+ linkbordercolor={.5 .5 .5}]{hyperref}%
+ }
+% \end{macrocode}
+%
+% While \pkg{beamer} takes care of adding presentation metadata to the PDF
+% properties, \pkg{beamerarticle} misses the title and author properties. (It
+% does manage to set the subject and keywords, though.) We achieve parity with
+% some additional \cs{hypersetup}. Note that \pkg{beamerarticle} appends the
+% subtitle to \cs{@title} with a linebreak and this does odd things in the
+% context of \key{pdftitle}, so we fix it with \cs{pdfstringdefDisableCommands}.
+%
+% \begin{macrocode}
+ \AtBeginDocument{%
+ \@ifpackageloaded{hyperref}{%
+ \pdfstringdefDisableCommands{\def\\<#1>#2{ - #2}}
+ \begingroup
+ \hypersetup{pdftitle={\@title}}%
+ \def\and{\unskip, }%
+ \let\thanks=\@gobble
+ \let\inst=\@gobble
+ \hypersetup{pdfauthor={\@author}}%
+ \endgroup
+ }{}%
+ }
+}{%
+% \end{macrocode}
+%
+%
+% For the presentation modes, we load the \pkg{beamer} class with appropriate
+% options. Since we are targeting users wanting different versions of their
+% presentations with the same code, we activate \key{ignorenonframetext}.
+%
+% \begin{macrocode}
+ \ifbool{DC@beamerswitch@handout}{%
+ \LoadClass[ignorenonframetext,handout]{beamer}
+% \end{macrocode}
+%
+% Handout mode lays multiple slides out on a single page. For this we use
+% \pkg{pgfpages}. The actual configuration is handled later.
+%
+% \begin{macrocode}
+ \RequirePackage{pgfpages}
+% \end{macrocode}
+%
+% We also activate \key{ignorenonframetext} for the other two modes.
+%
+% \begin{macrocode}
+ }{%
+ \ifbool{DC@beamerswitch@trans}{%
+ \LoadClass[ignorenonframetext,trans]{beamer}
+ }{%
+ \LoadClass[ignorenonframetext]{beamer}
+ }%
+ }
+}
+% \end{macrocode}
+%
+% \subsection{Mode-independent layout}
+%
+% We implement the option that formats institution markers in text mode rather
+% than math mode.
+%
+% \begin{macrocode}
+\ifbool{DC@beamerswitch@textinst}{%
+ \def\beamer@insttitle#1{\textsuperscript{#1}}
+ \def\beamer@instinst#1{\textsuperscript{#1}\ignorespaces}
+}{}
+% \end{macrocode}
+%
+% \subsection{Handout layout}
+%
+% \begin{optionkey}{paper}
+% \begin{macro}{beamerswitch@handoutpaper}
+% In theory it would be nice to anticipate the paper size that the article mode
+% would use, and pass that as an option to \cs{pgfpagesuselayout} but as that's
+% unlikely to be clean code, we settle here for setting it with an option.
+%
+% \begin{macrocode}
+\def\beamerswitch@handoutpaper{a4paper}
+\define@key[HL]{beamerswitch}{paper}{%
+ \def\beamerswitch@handoutpaper{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{optionkey}
+%
+% \begin{optionkey}{nup}
+% \begin{optionvalue}{2}
+% \begin{optionvalue}{3}
+% \begin{optionvalue}{3plus}
+% \begin{optionvalue}{4}
+% \begin{optionvalue}{4plus}
+% \begin{optionvalue}{6}
+% \begin{optionvalue}{8}
+% The \key{nup} option specifies how many slides to include per page.
+% The `plus' keyword indicates a layout with additional gaps for writing.
+%
+% \begin{macrocode}
+\newcounter{beamerswitch@nupcase}
+\setcounter{beamerswitch@nupcase}{5}
+\define@choicekey+[HL]{beamerswitch}{nup}[\val\nr]{2, 3, 3plus, 4, 4plus, 6, 8}{%
+ \setcounter{beamerswitch@nupcase}{\nr}
+}{%
+ \ClassWarning{beamerswitch}{Value of `nup' not recognized.
+ Allowed values are 2, 3, 3plus, 4, 4plus, 6, and 8.}%
+}
+% \end{macrocode}
+% \end{optionvalue}
+% \end{optionvalue}
+% \end{optionvalue}
+% \end{optionvalue}
+% \end{optionvalue}
+% \end{optionvalue}
+% \end{optionvalue}
+% \end{optionkey}
+%
+% \begin{optionkey}{border}
+% \begin{macro}{beamerswitch@Border}
+% \changes{v1.5}{2019/01/28}{Remove empty frames from end of handout.}
+% The \key{borders} option switches on borders around the slides on handout
+% pages (and gaps where slides would appear if there were enough). The value
+% is used to set the width of the border.
+%
+% This is implemented as a PGF drawing command, which is initially set up to do
+% nothing but gets filled out if the option is selected. As part of this, we
+% calculate the number of the current slide (|handoutpno| gives the current page
+% number minus one; \cs{beamerswitch@nup} is the number of slides per page;
+% and \cs{pgf@cpn} gives the count of the current slide on the current page).
+% If this exceeds the total number of slides, we suppress the border.
+%
+% \begin{macrocode}
+\newcommand*{\beamerswitch@Border}{\relax}
+\define@key[HL]{beamerswitch}{border}[0.4pt]{%
+ \RequirePackage{pgf}%
+ \ifdimcomp{#1}{>}{0pt}{%
+ \renewcommand*{\beamerswitch@Border}{%
+ \ifnumcomp{(\value{handoutpno} * \beamerswitch@nup) + \the\pgf@cpn}%
+ {>}{\beamer@endpageofdocument}{%
+ \relax
+ }{%
+ \pgfsetlinewidth{#1}\pgfstroke
+ }%
+ }%
+ }{%
+ \renewcommand*{\beamerswitch@Border}{\relax}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{optionkey}
+%
+% \begin{optionkey}{margin}
+% \changes{v1.4}{2018/08/29}{Make margins around slides a configurable size}
+% \begin{macro}{beamerswitch@margin}
+% The \key{margin} option controls how much white space is added around each
+% slide on handout pages. It corresponds to the \texttt{border shrink} option
+% of \cs{pgfpagesuselayout}.
+%
+% \begin{macrocode}
+\newlength{\beamerswitch@margin}
+\setlength{\beamerswitch@margin}{5mm}
+\define@key[HL]{beamerswitch}{margin}[0pt]{%
+ \setlength{\beamerswitch@margin}{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{optionkey}
+%
+% \begin{optionkey}{align}
+% The \key{align} option chooses whether to rejig the positions of the slides
+% on the page so that the effective page margin is the same as, rather than
+% half, the space between adjacent slides.
+%
+% \begin{macrocode}
+\define@boolkey[HL]{beamerswitch}{align}[true]{}
+% \end{macrocode}
+% \end{optionkey}
+%
+% \begin{optionkey}{pnos}
+% \begin{macro}{handoutpnobaseline}
+% The \key{pnos} option switches on page numbers for handout pages. The height
+% at which the baseline of the number sits, relative to the bottom edge of the
+% paper, is given by the length \cs{handoutpnobaseline}.
+%
+% \begin{macrocode}
+\newlength{\handoutpnobaseline}
+\setlength{\handoutpnobaseline}{5mm}
+\newcounter{handoutpno}
+\define@boolkey[HL]{beamerswitch}{pnos}[true]{}
+% \end{macrocode}
+% \end{macro}
+% \end{optionkey}
+%
+% \begin{macro}{beamerswitch@footer}
+% In order to implement the page numbers, we need to add a hook to the
+% \pkg{pgfpages} shipout routine.
+%
+% \begin{macrocode}
+\def\beamerswitch@footer{}
+\patchcmd{\pgfpages@buildshipoutbox}{%
+ \pgfsys@endpicture
+}{%
+ \beamerswitch@footer\pgfsys@endpicture
+}{}{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{handoutlayout}
+% \begin{macro}{beamerswitch@pnoadjust}
+% We set up the \cs{handoutlayout} command for applying these options.
+%
+% The hook \cs{beamerswitch@footer} is used to step the page number
+% counter |handoutpno|; if page numering is active, it also places the
+% number on the page centered and \cs{handoutpnobaseline} up from the
+% bottom.
+%
+% The length \cs{beamerswitch@pnoadjust} is, conceptually, the height
+% of the page number. When page numbers are active, the margin around
+% slides is automatically increased to guarantee that the top of the
+% page number will not be higher than the bottom of the lowest slide.
+% Currently this does not account for extra whitespace arising from
+% aspect ratio issues. When the \key{align} option is active, the margin
+% at the bottom of the page is increased, but to save a register we
+% make the adjustment to \cs{beamerswitch@pnoadjust} instead of a copy
+% of \cs{beamerswitch@margin}.
+%
+% \begin{macrocode}
+\newlength{\beamerswitch@pnoadjust}
+\newcommand*{\handoutlayout}[1]{%
+ \only<handout>{%
+ \setlength{\beamerswitch@pnoadjust}{1em}%
+ \setkeys[HL]{beamerswitch}{#1}%
+ \ifbool{HL@beamerswitch@pnos}{%
+ \def\beamerswitch@footer{%
+ \stepcounter{handoutpno}%
+ \setbox0\vbox{\makebox[0pt][c]{\arabic{handoutpno}}}%
+ \pgfsys@beginscope
+ \pgflowlevel{\pgftransformshift{%
+ \pgfpoint{.5\pgfphysicalwidth}{\handoutpnobaseline}}}%
+ \wd0=0pt%
+ \dp0=-\ht0%
+ \pgfsys@hbox0%
+ \pgfsys@endscope
+ }%
+ \ifbool{HL@beamerswitch@align}{%
+ \ifcase\value{beamerswitch@nupcase}\relax
+ \addtolength{\beamerswitch@pnoadjust}{-0.333\beamerswitch@margin}%
+ \or
+ \addtolength{\beamerswitch@pnoadjust}{-0.5\beamerswitch@margin}%
+ \or
+ \addtolength{\beamerswitch@pnoadjust}{-0.5\beamerswitch@margin}%
+ \or
+ \addtolength{\beamerswitch@pnoadjust}{-0.333\beamerswitch@margin}%
+ \or
+ \addtolength{\beamerswitch@pnoadjust}{-0.6\beamerswitch@margin}%
+ \or
+ \addtolength{\beamerswitch@pnoadjust}{-0.5\beamerswitch@margin}%
+ \or
+ \addtolength{\beamerswitch@pnoadjust}{-0.6\beamerswitch@margin}%
+ \fi
+ }{}%
+ \ifdimcomp{\beamerswitch@margin}{<}%
+ {\handoutpnobaseline + \beamerswitch@pnoadjust}{%
+ \setlength{\beamerswitch@margin}%
+ {\the\dimexpr\handoutpnobaseline + \beamerswitch@pnoadjust\relax}%
+ }{}%
+ }{%
+ \def\beamerswitch@footer{\stepcounter{handoutpno}}%
+ }%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{beamerswitch@nup}
+% The value of the \key{nup} option is used both to select the layout
+% and set the value of \cs{beamerswitch@nup}. The latter is used to
+% suppress unwanted borders and check if \cs{handoutlayout} has been
+% called.
+%
+% \begin{macrocode}
+ \ifcase\value{beamerswitch@nupcase}\relax
+ \def\beamerswitch@nup{2}%
+ \pgfpagesuselayout{1 by 2}[\beamerswitch@handoutpaper,%
+ border shrink=\the\beamerswitch@margin]%
+ \or
+ \def\beamerswitch@nup{3}%
+ \pgfpagesuselayout{1 by 3}[\beamerswitch@handoutpaper,%
+ border shrink=\the\beamerswitch@margin]%
+ \or
+ \def\beamerswitch@nup{3}%
+ \pgfpagesuselayout{1 by 3 narrow}[\beamerswitch@handoutpaper,%
+ border shrink=\the\beamerswitch@margin]%
+ \or
+ \def\beamerswitch@nup{4}%
+ \pgfpagesuselayout{2 by 2}[\beamerswitch@handoutpaper,%
+ landscape,border shrink=\the\beamerswitch@margin]%
+ \or
+ \def\beamerswitch@nup{4}%
+ \pgfpagesuselayout{1 by 4 narrow}[\beamerswitch@handoutpaper,%
+ border shrink=\the\beamerswitch@margin]%
+ \or
+ \def\beamerswitch@nup{6}%
+ \pgfpagesuselayout{2 by 3}[\beamerswitch@handoutpaper,%
+ border shrink=\the\beamerswitch@margin]%
+ \or
+ \def\beamerswitch@nup{8}%
+ \pgfpagesuselayout{2 by 4}[\beamerswitch@handoutpaper,%
+ border shrink=\the\beamerswitch@margin]%
+ \fi
+ }%
+}
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+% We initialize the class with the defaults set above.
+%
+% \begin{macrocode}
+\AtEndPreamble{%
+ \ifdef{\beamerswitch@nup}{}{%
+ \handoutlayout{}%
+ }%
+}
+% \end{macrocode}
+%
+% Though \pkg{pgfpages} defines some perfectly fine layouts, we need to add
+% configurability to the existing ones and provide some new ones.
+%
+% The `1 by 2' layout is similar to the normal \key{2 on 1} layout.
+%
+% \begin{macrocode}
+\mode<handout>{%
+ \pgfpagesdeclarelayout{1 by 2}
+ {
+ \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
+ \edef\pgfpageoptionwidth{\the\paperheight}
+ \def\pgfpageoptionborder{0pt}
+ \def\pgfpageoptionfirstshipout{1}
+ }
+ {
+ \pgfpagesphysicalpageoptions
+ {%
+ logical pages=2,%
+ physical height=\pgfpageoptionheight,%
+ physical width=\pgfpageoptionwidth,%
+ current logical shipout=\pgfpageoptionfirstshipout%
+ }
+ \ifdim\paperheight>\paperwidth\relax
+ % put side-by-side
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}{.5\pgfphysicalheight}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}{.5\pgfphysicalheight}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}%
+ }%
+ }%
+ \else
+ % stack on top of one another
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ \fi
+ }
+% \end{macrocode}
+%
+% The `1 by 3' layout is similar to the `1 by 2', but with an extra row.
+%
+% \begin{macrocode}
+ \pgfpagesdeclarelayout{1 by 3}
+ {
+ \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
+ \edef\pgfpageoptionwidth{\the\paperheight}
+ \def\pgfpageoptionborder{0pt}
+ \def\pgfpageoptionfirstshipout{1}
+ }
+ {
+ \pgfpagesphysicalpageoptions
+ {%
+ logical pages=3,%
+ physical height=\pgfpageoptionheight,%
+ physical width=\pgfpageoptionwidth,%
+ current logical shipout=\pgfpageoptionfirstshipout%
+ }
+ \ifdim\paperheight>\paperwidth\relax
+ % put side-by-side
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.167\pgfphysicalwidth + 0.5\beamerswitch@margin}{.5\pgfphysicalheight}%
+ }{%
+ \pgfpoint{.167\pgfphysicalwidth}{.5\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=\pgfphysicalheight,%
+ center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight}%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.833\pgfphysicalwidth - 0.5\beamerswitch@margin}{.5\pgfphysicalheight}%
+ }{%
+ \pgfpoint{.833\pgfphysicalwidth}{.5\pgfphysicalheight}%
+ }%
+ }%
+ \else
+ % stack on top of one another
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.5\pgfphysicalwidth}{.833\pgfphysicalheight - 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.5\pgfphysicalwidth}{.833\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight}%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.5\pgfphysicalwidth}{.167\pgfphysicalheight + 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.5\pgfphysicalwidth}{.167\pgfphysicalheight}%
+ }%
+ }%
+ \fi
+ }
+% \end{macrocode}
+%
+% The `1 by 3 narrow' layout is like the `1 by 3' layout but restricted to the
+% left (or top) half of the page.
+%
+% \begin{macrocode}
+ \pgfpagesdeclarelayout{1 by 3 narrow}
+ {
+ \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
+ \edef\pgfpageoptionwidth{\the\paperheight}
+ \def\pgfpageoptionborder{0pt}
+ \def\pgfpageoptionfirstshipout{1}
+ }
+ {
+ \pgfpagesphysicalpageoptions
+ {%
+ logical pages=3,%
+ physical height=\pgfpageoptionheight,%
+ physical width=\pgfpageoptionwidth,%
+ current logical shipout=\pgfpageoptionfirstshipout%
+ }
+ \ifdim\paperheight>\paperwidth\relax
+ % put side-by-side
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.167\pgfphysicalwidth + 0.5\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.167\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight - 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.833\pgfphysicalwidth - 0.5\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.833\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \else
+ % stack on top of one another
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.5\beamerswitch@margin}%
+ {.833\pgfphysicalheight - 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.833\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.5\beamerswitch@margin}{.5\pgfphysicalheight}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.5\beamerswitch@margin}%
+ {.167\pgfphysicalheight + 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.167\pgfphysicalheight}%
+ }%
+ }%
+ \fi
+ }
+% \end{macrocode}
+%
+% The `2 by 2' layout is similar to the normal \key{4 on 1} layout.
+%
+% \begin{macrocode}
+ \pgfpagesdeclarelayout{2 by 2}
+ {
+ \edef\pgfpageoptionheight{\the\paperheight}
+ \edef\pgfpageoptionwidth{\the\paperwidth}
+ \edef\pgfpageoptionborder{0pt}
+ }
+ {
+ \pgfpagesphysicalpageoptions
+ {%
+ logical pages=4,%
+ physical height=\pgfpageoptionheight,%
+ physical width=\pgfpageoptionwidth%
+ }
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{4}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
+ {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ }
+% \end{macrocode}
+%
+% The `1 by 4 narrow' layout puts four slides in a column on the left half of
+% the page (or in a row on the top half).
+%
+% \begin{macrocode}
+ \pgfpagesdeclarelayout{1 by 4 narrow}
+ {
+ \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
+ \edef\pgfpageoptionwidth{\the\paperheight}
+ \def\pgfpageoptionborder{0pt}
+ \def\pgfpageoptionfirstshipout{1}
+ }
+ {
+ \pgfpagesphysicalpageoptions
+ {%
+ logical pages=4,%
+ physical height=\pgfpageoptionheight,%
+ physical width=\pgfpageoptionwidth,%
+ current logical shipout=\pgfpageoptionfirstshipout%
+ }
+ \ifdim\paperheight>\paperwidth\relax
+ % put side-by-side
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.125\pgfphysicalwidth + 0.6\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.125\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.375\pgfphysicalwidth + 0.2\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.375\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.625\pgfphysicalwidth - 0.2\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.625\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{4}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.875\pgfphysicalwidth - 0.6\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.875\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \else
+ % stack on top of one another
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.875\pgfphysicalheight - 0.6\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.875\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.625\pgfphysicalheight - 0.2\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.625\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25 \pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.375\pgfphysicalheight + 0.2\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.375\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{4}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25 \pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.125\pgfphysicalheight + 0.6\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.125\pgfphysicalheight}%
+ }%
+ }%
+ \fi
+ }
+% \end{macrocode}
+%
+% The `2 by 3' layout positions the slides as three rows of two slides each.
+%
+% \begin{macrocode}
+ \pgfpagesdeclarelayout{2 by 3}
+ {
+ \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
+ \edef\pgfpageoptionwidth{\the\paperheight}
+ \def\pgfpageoptionborder{0pt}
+ \def\pgfpageoptionfirstshipout{1}
+ }
+ {
+ \pgfpagesphysicalpageoptions
+ {%
+ logical pages=6,%
+ physical height=\pgfpageoptionheight,%
+ physical width=\pgfpageoptionwidth,%
+ current logical shipout=\pgfpageoptionfirstshipout%
+ }
+ \ifdim\paperheight>\paperwidth\relax
+ % put side-by-side
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.167\pgfphysicalwidth + 0.5\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.167\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheigh - 0.333\beamerswitch@margint}%
+ }{%
+ \pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.833\pgfphysicalwidth - 0.5\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.833\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{4}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.167\pgfphysicalwidth + 0.5\beamerswitch@margin}%
+ {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.167\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{5}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{6}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.333\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.833\pgfphysicalwidth - 0.5\beamerswitch@margin}%
+ {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.833\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ \else
+ % stack on top of one another
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.833\pgfphysicalheight - 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.833\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
+ {.833\pgfphysicalheight - 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.833\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}{.5\pgfphysicalheight}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{4}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}{.5\pgfphysicalheight}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{5}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.167\pgfphysicalheight + 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.167\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{6}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.333\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
+ {.167\pgfphysicalheight + 0.5\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.167\pgfphysicalheight}%
+ }%
+ }%
+ \fi
+ }
+% \end{macrocode}
+%
+% The `2 by 4' layout layout positions the slides as four rows of two slides each.
+%
+% \begin{macrocode}
+ \pgfpagesdeclarelayout{2 by 4}
+ {
+ \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
+ \edef\pgfpageoptionwidth{\the\paperheight}
+ \def\pgfpageoptionborder{0pt}
+ \def\pgfpageoptionfirstshipout{1}
+ }
+ {
+ \pgfpagesphysicalpageoptions
+ {%
+ logical pages=8,%
+ physical height=\pgfpageoptionheight,%
+ physical width=\pgfpageoptionwidth,%
+ current logical shipout=\pgfpageoptionfirstshipout%
+ }
+ \ifdim\paperheight>\paperwidth\relax
+ % put side-by-side
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.125\pgfphysicalwidth + 0.6\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.125\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.375\pgfphysicalwidth + 0.2\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.375\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.625\pgfphysicalwidth - 0.2\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.625\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{4}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.875\pgfphysicalwidth - 0.6\beamerswitch@margin}%
+ {.75\pgfphysicalheight - 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.875\pgfphysicalwidth}{.75\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{5}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.125\pgfphysicalwidth + 0.6\beamerswitch@margin}%
+ {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.125\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{6}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.375\pgfphysicalwidth + 0.2\beamerswitch@margin}%
+ {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.375\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{7}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.625\pgfphysicalwidth - 0.2\beamerswitch@margin}%
+ {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.625\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{8}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.25\pgfphysicalwidth,%
+ resized height=.5\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.875\pgfphysicalwidth - 0.6\beamerswitch@margin}%
+ {.25\pgfphysicalheight + 0.333\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.875\pgfphysicalwidth}{.25\pgfphysicalheight}%
+ }%
+ }%
+ \else
+ % stack on top of one another
+ \pgfpageslogicalpageoptions{1}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.875\pgfphysicalheight - 0.6\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.875\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{2}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
+ {.875\pgfphysicalheight - 0.6\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.875\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{3}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.625\pgfphysicalheight - 0.2\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.625\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{4}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25\pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
+ {.625\pgfphysicalheight - 0.2\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.625\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{5}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25 \pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.375\pgfphysicalheight + 0.2\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.375\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{6}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25 \pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
+ {.375\pgfphysicalheight + 0.2\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.375\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{7}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25 \pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.25\pgfphysicalwidth + 0.333\beamerswitch@margin}%
+ {.125\pgfphysicalheight + 0.6\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.25\pgfphysicalwidth}{.125\pgfphysicalheight}%
+ }%
+ }%
+ \pgfpageslogicalpageoptions{8}
+ {%
+ border shrink=\pgfpageoptionborder,%
+ border code=\beamerswitch@Border,%
+ resized width=.5\pgfphysicalwidth,%
+ resized height=.25 \pgfphysicalheight,%
+ center=\ifbool{HL@beamerswitch@align}{%
+ \pgfpoint{.75\pgfphysicalwidth - 0.333\beamerswitch@margin}%
+ {.125\pgfphysicalheight + 0.6\beamerswitch@margin}%
+ }{%
+ \pgfpoint{.75\pgfphysicalwidth}{.125\pgfphysicalheight}%
+ }%
+ }%
+ \fi
+ }
+}
+% \end{macrocode}
+%
+% \subsection{Article layout}
+%
+% We provide some options for configuring the appearance of article mode.
+%
+% \changes{v1.1}{2016/08/19}{Fix \key{maketitle} and \key{textinst} options.}
+% \begin{optionkey}{maketitle}
+% The \key{maketitle} option triggers adjustments in how the title block is
+% printed.
+%
+% \begin{macrocode}
+\define@boolkey[AL]{beamerswitch}{maketitle}[true]{}
+% \end{macrocode}
+% \end{optionkey}
+%
+% One will be to join the title and subtitle with a colon. There is an edge case
+% where, if the user provides a title that ends in `!' or `?' \emph{and}
+% provides a subtitle while this option is in effect, they will end up with
+% clashing punctuation in the middle of the displayed title (`!:' or `?:'). We
+% therefore introduce a toggle that, if set true, suppresses the additional
+% colon.
+%
+% \begin{macrocode}
+\newtoggle{titlepunct}
+% \end{macrocode}
+%
+% \begin{macro}{bsw@punct@test}
+% Of course, we would rather not bother the user with this, so we introduce a
+% command for testing the title for final punctuation.
+%
+% The only way I can seem to do this is by switching to \pkg{expl3} syntax.
+% Rather than introduce extra hard dependencies to cope with what will probably
+% be quite a rare issue, we make the dependency soft: it will only be applied
+% if \pkg{xparse} is available. If there is demand for it, we could introduce
+% a class option to switch this code on or off, but let's see how we go.
+%
+% \begin{macrocode}
+\IfFileExists{xparse.sty}{\@tempswatrue}{\@tempswafalse}
+\if@tempswa
+ \RequirePackage{xparse}
+ \ExplSyntaxOn
+ \NewDocumentCommand{\bsw@punct@test}{m}{\l_bsw_punct_test:n {#1}}
+ \cs_new_protected:Nn \l_bsw_punct_test:n
+ {
+ \str_case_x:nnTF { \str_item:nn {#1} {-1} }
+ {
+ { , } { }
+ { ; } { }
+ { : } { }
+ { . } { }
+ { ! } { }
+ { ? } { }
+ }
+ { \global\toggletrue{titlepunct} }
+ { \global\togglefalse{titlepunct} }
+ }
+ \ExplSyntaxOff
+% \end{macrocode}
+%
+% We insert this test into the definitions for \cs{title} introduced by
+% \pkg{beamer}\slash\pkg{beamerarticle}.
+%
+% \begin{macrocode}
+ \mode<article>{%
+ \renewcommand{\title}[2][]{\beamer@origtitle{#2}\bsw@punct@test{#2}}
+ }
+ \mode<presentation>{%
+ \long\def\beamer@title[#1]#2{%
+ \def\inserttitle{#2}%
+ \def\beamer@shorttitle{#1}%
+ \bsw@punct@test{#2}%
+ }
+ }
+\else
+ \wlog{Beamerswitch: Auto-detection of title punctuation not available.}
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{optionkey}{frametitles}
+% \begin{optionvalue}{para}
+% \begin{optionvalue}{margin}
+% \begin{optionvalue}{none}
+% \begin{macro}{beamerswitch@articleframetitles}
+% We offer some alternatives for handling frame titles in article mode.
+% \begin{itemize}
+% \item
+% \val{para} is what \pkg{beamerarticle} normally does.
+% \item
+% \val{margin} puts the frame titles in the margin.
+% \item
+% \val{none} gets rid of them entirely.
+% \end{itemize}
+%
+% \begin{macrocode}
+\define@choicekey+[AL]{beamerswitch}{frametitles}{para, margin, none}{%
+ \def\beamerswitch@articleframetitles{#1}%
+}{%
+ \ClassWarning{beamerswitch}{Value of `frametitles' not recognized.
+ Allowed values are para, margin, and none.}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{optionvalue}
+% \end{optionvalue}
+% \end{optionvalue}
+% \end{optionkey}
+%
+% \begin{macro}{articlelayout}
+% We provide a command for setting these options.
+%
+% \begin{macrocode}
+\newcommand{\articlelayout}[1]{%
+ \setkeys[AL]{beamerswitch}{#1}%
+% \end{macrocode}
+%
+% The following options are mode specific.
+%
+% \begin{macrocode}
+ \mode<article>{%
+% \end{macrocode}
+%
+% Personally I find slide titles somewhat intrusive in article mode. They can
+% easily end up duplicating section headings in running text, or captions in
+% figures. You may have other ideas, so we keep this behaviour configurable.
+%
+% \begin{optionvalue}{margin}
+% \begin{optionvalue}{none}
+% \begin{optionvalue}{para}
+% The \val{margin} value is implemented using \cs{marginpar}.
+%
+% \begin{macrocode}
+ \ifcsstring{beamerswitch@articleframetitles}{margin}{%
+ \setbeamertemplate{frametitle}{%
+ \marginpar[%
+ \raggedleft\noindent\emshape\textbf{\insertframetitle}\par
+ \noindent\insertframesubtitle\par
+ ]{%
+ \raggedright\noindent\emshape\textbf{\insertframetitle}\par
+ \noindent\insertframesubtitle\par
+ }%
+ }
+ }{%
+ \ifcsstring{beamerswitch@articleframetitles}{none}{%
+ \setbeamertemplate{frametitle}{}
+ }{%
+ \ifcsstring{beamerswitch@articleframetitles}{para}{%
+ \setbeamertemplate{frametitle}[default]
+ }{}%
+ }%
+ }
+% \end{macrocode}
+% \end{optionvalue}
+% \end{optionvalue}
+% \end{optionvalue}
+%
+% This is where we make our adjustments to \cs{maketitle}. We start by joining
+% the subtitle to the title by means of a colon instead of a newline.
+%
+% \begin{macrocode}
+ \ifbool{AL@beamerswitch@maketitle}{%
+ \renewcommand{\subtitle}[2][]{%
+ \def\insertsubtitle{##2}\gappto\@title{\iftoggle{titlepunct}{}{:} ##2}%
+ }
+% \end{macrocode}
+%
+% We add support for printing the institute information.
+%
+% \begin{macrocode}
+ \ifundef{\beamer@originstitute}{%
+ \renewcommand{\institute}[2][]{\def\insertinstitute{##2}}%
+ }{%
+ \renewcommand{\institute}[2][]{%
+ \def\insertinstitute{##2}\beamer@originstitute{##2}}%
+ }%
+% \end{macrocode}
+%
+% \changes{v1.1}{2016/08/19}{Remove personal customizations from \key{maketitle} code.}
+% Our first change to \cs{maketitle} itself is to remove the initial vertical
+% space.
+%
+% \begin{macrocode}
+ \def\@maketitle{%
+ \newpage
+ \null
+ \begin{center}%
+ \let\footnote\thanks
+ {\LARGE \@title \par}%
+ \vskip 1.5em%
+ {%
+ \large\lineskip .5em%
+ \begin{tabular}[t]{c}%
+ \@author
+ \end{tabular}\par
+ }%
+% \end{macrocode}
+%
+% The other is to add in a row for the institute information.
+%
+% \begin{macrocode}
+ \ifdefvoid{\insertinstitute}{}{%
+ {%
+ \normalsize\lineskip .5em%
+ \begin{tabular}[t]{c}%
+ \insertinstitute
+ \end{tabular}\par
+ }%
+ }%
+ \vskip 1em%
+ {\large \@date}%
+ \end{center}%
+ \par\vskip 1.5em%
+ }%
+ }{}%
+ }%
+% \end{macrocode}
+%
+% For consistency, if the \key{maketitle} option has been passed, we change the
+% PDF metadata in the other modes to use the colon convention for joining the
+% title and subtitle.
+%
+% \begin{macrocode}
+ \mode<presentation>{%
+ \ifbool{AL@beamerswitch@maketitle}{%
+ \ifbool{beamer@autopdfinfo}{%
+ \patchcmd{\beamer@firstminutepatches}{%
+ \inserttitle\ifx\insertsubtitle\@empty\else\ - \insertsubtitle\fi
+ }{%
+ \inserttitle\ifx\insertsubtitle\@empty\else\iftoggle{titlepunct}{}{:} \insertsubtitle\fi
+ }{}{}%
+ }{}%
+ }{}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% There is no more.
+%
+% \begin{macrocode}
+\endinput
+% \end{macrocode}
+% \iffalse
+%</class>
+% \fi
+%\Finale