-
Notifications
You must be signed in to change notification settings - Fork 0
/
beamerswitch.dtx
3180 lines (3025 loc) · 104 KB
/
beamerswitch.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \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–2022 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>
\documentclass[%
beameroptions={ignorenonframetext,14pt},
articleoptions={a4paper,12pt},
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\inst{1}}
\institute{\inst{1}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: [email protected]
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-2022 by Alex Ball <[email protected]>
\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>
[2022/08/20 v1.9 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,raster}
\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
}
, documentation minted options=
{ breaklines
, fontsize=\small
, breakbefore=\{\[
, breakafter=/\}\]
, breakbeforesymbolpre={}
}
, 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
Replace the class \pkg{beamer} with \pkg{beamerswitch}.
Wrap any class options you have specified in braces and turn them into the
value of the \key{beameroptions} option:
\begin{tcbraster}[raster equal height=rows]
\begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
\documentclass[10pt]{beamer}
\end{dispListing*}
\begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
\documentclass[beameroptions={10pt}]{beamerswitch}
\end{dispListing*}
\end{tcbraster}
If you didn't specify any options, then give \key{beameroptions} a blank
value:
\begin{tcbraster}[raster equal height=rows]
\begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
\documentclass{beamer}
\end{dispListing*}
\begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
\documentclass[beameroptions={}]{beamerswitch}
\end{dispListing*}
\end{tcbraster}
If you only specified \key{ignorenonframetext}, then you don't
need \key{beameroptions}:
\begin{tcbraster}[raster equal height=rows]
\begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
\documentclass[ignorenonframetext]{beamer}
\end{dispListing*}
\begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
\documentclass{beamerswitch}
\end{dispListing*}
\end{tcbraster}
\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{tcbraster}[raster equal height=rows]
\begin{dispListing*}{title=Before,coltitle=black,fonttitle=\sffamily}
\documentclass[10pt]{beamer}
\usetheme{metropolis}
\title{Test presentation}
\begin{document}
\maketitle
\end{document}
\end{dispListing*}
\begin{dispListing*}{title=After,coltitle=black,fonttitle=\sffamily}
\documentclass[beameroptions={10pt}]{beamerswitch}
\mode<presentation>{%
\usetheme{metropolis}
}
\title{Test presentation}
\begin{document}
\maketitle
\end{document}
\end{dispListing*}
\end{tcbraster}
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 with \pkg{beamer}'s
\key{ignorenonframetext} option in place. 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{expl3}
\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{Passing options to the underlying classes}
\begin{docKey}{articleclass}{=\meta{class}}{default and initially \val{article}}
Selects the \meta{class} to use when in \key{article} mode.
\end{docKey}
\begin{docKey}{articleoptions}{=\marg{options}}{default and initially empty}
Passes the \meta{options} to the underlying class (selected by \key{articleclass})
when in \key{article} mode.
\end{docKey}
\begin{docKey}{beameroptions}{=\marg{options}}{default and initially \val{ignorenonframetext}}
Passes the \meta{options} to the \pkg{beamer} class when in \key{beamer},
\key{handout} or \key{trans} mode. Do not specify \val{handout} or \val{trans}
among the options as \pkg{beamerswitch} handles those for you. Note that the
default behaviour is to pass the \val{ignorenonframetext} option, so remember
to include it yourself if you start specifying other options.
\end{docKey}
\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}.
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*{\SpawnedLuaTeX}{\SpawnedCompiler -m lualatex} % needs v1.6.0+
\newcommand*{\SpawnedXeTeX}{\SpawnedCompiler -m xelatex}
\documentclass{beamerswitch}
\end{dispListing}
If you don't need the engine selection routine provided, you can replace it
by pre-defining \cs{BeamerswitchSpawn} to do whatever you need it to do instead:
\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}
\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{1}\textbar \val{1plus}\textbar \val{2}\textbar \val{3}\textbar \val{3plus}\textbar \val{4}\textbar \val{4plus}\textbar \val{6}\textbar \val{8}}{no default, initially \val{6}}
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 \val{2}, \val{3plus}, \val{4}
and \val{6} layouts are intended for slides in the usual 4:3 aspect ratio,
while the \val{3}, \val{4plus} and \val{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!]
\newcounter{subfig}%
\def\sfno{\rule[-\bigskipamount]{0pt}{1em}\stepcounter{subfig}(\alph{subfig})\space}%
\centering
\begin{minipage}[b]{11em}
\centering