summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/stex/source/extensions/notesslides.dtx
blob: ff06827660fcc9f11dd2fff7bd1af9f4311dfb6c (plain)
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
% \iffalse meta-comment
% A LaTeX Class for Semantic Lectures Slides (originally developed for Michael Kohlhase)
% Copyright (c) 2019 Michael Kohlhase, all rights reserved
%               this file is released under the
%               Gnu Library Public Licences (LGPL)
%
% The original of this file is in the public repository at 
% http://github.com/sLaTeX/sTeX/
% \fi
% 
% \iffalse
%
%<*driver>
\def\bibfolder#1{../../lib/bib/#1}
\input{../../doc/stex-docheader}

\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
% 
% \GetFileInfo{notesslides.cls}
% \MakeShortVerb{\|}
%
% \def\twin#1#2{\index{#1!#2}\index{#2!#1}}
% \def\twintoo#1#2{{#1 #2}\twin{#1}{#2}}
% \def\atwin#1#2#3{\index{#1!#2!#3}\index{#3!#2 (#1)}}
% \def\atwintoo#1#2#3{{#1 #2 #3}\atwin{#1}{#2}{#3}}
%
% \def\scsys#1{{{\sc #1}}\index{#1@{\sc #1}}}
% \def\stex{\hbox{\raisebox{-.5ex}S\kern-.5ex\TeX}}
% \def\sTeX{\stex}
% \def\cnxml{\scshape{CNXml}}
% \def\connexions{\scshape{Connexions}}
% \def\element#1{{\ttfamily{#1}}}
% \def\snippet#1{{\ttfamily{#1}}}
% \def\cnxlatex{CNX\LaTeX\xspace}
% \def\mathml{{\scshape{MathML}}\xspace}
% \def\omdoc{OMDoc\xspace}
% \def\activemath{{\scshape{ActiveMath}}\xspace}
% \def\textwarning{\includegraphics[width=1.2em]{stex-dangerous-bend}\xspace}
% 
% \title{NotesSlides -- Slides and Course Notes\thanks{Version {\fileversion}
% (last revised {\filedate})}}
%    \author{Michael Kohlhase\\
%            FAU Erlangen-N\"urnberg\\
%            \url{http://kwarc.info/kohlhase}}
% \maketitle
%
%\ifinfulldoc\else
% This is the documentation for the \pkg{notesslides} package.
% For a more high-level introduction, 
%  see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the
% \href{\basedocurl/stex.pdf}{full \sTeX documentation}.
%
% \input{../../doc/packages/stex-slides}
% \fi
%
% \begin{documentation}\label{pkg:notesslides:doc}
% \changes{3.1.0}{2022/02/28}{Added \detokenize{\libusetheme}}
%
% \end{documentation}
%
% \begin{implementation}\label{pkg:notesslides:impl}
% 
%\section{NotesSlides -- Implementation}\label{sec:impl}
%
%\subsection{Class and Package Options}\label{sec:impl:init}
%
% We define some Package Options and switches for the |notesslides| class and activate them
% by passing them on to |beamer.cls| and |omdoc.cls| and the |notesslides| package. We pass
% the |nontheorem| option to the |statements| package when we are not in notes mode, since
% the |beamer| package has its own (overlay-aware) theorem environments. 
%
%    \begin{macrocode}
%<*cls>
%<@@=notesslides>
\ProvidesExplClass{notesslides}{2022/05/24}{3.1.0}{notesslides Class}
\RequirePackage{l3keys2e}

\keys_define:nn{notesslides / cls}{
  class   .str_set_x:N = \c_@@_class_str,
  notes   .bool_set:N  = \c_@@_notes_bool ,
  slides  .code:n      = { \bool_set_false:N \c_@@_notes_bool },
  docopt  .str_set_x:N = \c_@@_docopt_str,
  unknown .code:n      = {
    \PassOptionsToPackage{\CurrentOption}{document-structure}
    \PassOptionsToClass{\CurrentOption}{beamer}
    \PassOptionsToPackage{\CurrentOption}{notesslides}
    \PassOptionsToPackage{\CurrentOption}{stex}
  }
}
\ProcessKeysOptions{ notesslides / cls }

\str_if_empty:NF \c_@@_class_str {
  \PassOptionsToPackage{class=\c_@@_class_str}{document-structure}
}

\exp_args:No \str_if_eq:nnT\c_@@_class_str{book}{
  \PassOptionsToPackage{defaulttopsect=part}{notesslides}
}
\exp_args:No \str_if_eq:nnT\c_@@_class_str{report}{
  \PassOptionsToPackage{defaulttopsect=part}{notesslides}
}

\RequirePackage{stex}
\stex_html_backend:T {
  \bool_set_true:N\c_@@_notes_bool
}

\bool_if:NTF \c_@@_notes_bool {
  \PassOptionsToPackage{notes=true}{notesslides}
  \message{notesslides.cls:~Formatting~course~materials~in~notes~mode}
}{
  \PassOptionsToPackage{notes=false}{notesslides}
  \message{notesslides.cls:~Formatting~course~materials~in~slides~mode}
}
%</cls>
%    \end{macrocode}
% now we do the same for the |notesslides| package. 
%    \begin{macrocode}
%<*package>
\ProvidesExplPackage{notesslides}{2022/05/24}{3.1.0}{notesslides Package}
\RequirePackage{l3keys2e}

\keys_define:nn{notesslides / pkg}{
  topsect         .str_set_x:N  = \c_@@_topsect_str,
  defaulttopsect  .str_set_x:N  = \c_@@_defaulttopsec_str,
  notes           .bool_set:N   = \c_@@_notes_bool ,
  slides          .code:n       = { \bool_set_false:N \c_@@_notes_bool },
  sectocframes    .bool_set:N   = \c_@@_sectocframes_bool ,
  frameimages     .bool_set:N   = \c_@@_frameimages_bool ,
  fiboxed         .bool_set:N   = \c_@@_fiboxed_bool ,
  noproblems      .bool_set:N   = \c_@@_noproblems_bool,
  unknown         .code:n       = {
    \PassOptionsToClass{\CurrentOption}{stex}
    \PassOptionsToClass{\CurrentOption}{tikzinput}
  }
}
\ProcessKeysOptions{ notesslides / pkg }

\RequirePackage{stex}
\stex_html_backend:T {
  \bool_set_true:N\c_@@_notes_bool
}

\newif\ifnotes
\bool_if:NTF \c_@@_notes_bool {
  \notestrue
}{
  \notesfalse
}

%    \end{macrocode}
% we give ourselves a macro |\@@topsect| that needs only be evaluated once, so that the
% |\ifdefstring| conditionals work below.
%    \begin{macrocode}
\str_if_empty:NTF \c_@@_topsect_str {
  \str_set_eq:NN \@@topsect \c_@@_defaulttopsec_str
}{
  \str_set_eq:NN \@@topsect \c_@@_topsect_str
}
\PassOptionsToPackage{topsect=\@@topsect}{document-structure}
%</package>
%    \end{macrocode}
%
% Depending on the options, we either load the |article|-based |document-structure| or the |beamer|
% class (and set some counters).
%    \begin{macrocode}
%<*cls>
\bool_if:NTF \c_@@_notes_bool {
  \str_if_empty:NT \c_@@_class_str {
    \str_set:Nn \c_@@_class_str {article}
  }
  \exp_after:wN\LoadClass\exp_after:wN[\c_@@_docopt_str]
    {\c_@@_class_str}
}{
  \LoadClass[10pt,notheorems,xcolor={dvipsnames,svgnames}]{beamer}
  \newcounter{Item}
  \newcounter{paragraph}
  \newcounter{subparagraph}
  \newcounter{Hfootnote}
}
\RequirePackage{document-structure}
%    \end{macrocode}
% now it only remains to load the |notesslides| package that does all the rest. 
%    \begin{macrocode}
\RequirePackage{notesslides}
%</cls>
%    \end{macrocode}
% 
% In |notes| mode, we also have to make the |beamer|-specific things available to
% |article| via the |beamerarticle| package. We use options to avoid loading theorem-like
% environments, since we want to use our own from the $\sTeX$ packages.  The first batch
% of packages we want are loaded on |notesslides.sty|. These are the general ones, we will
% load the \sTeX-specific ones after we have done some work (e.g. defined the counters
% |m*|). Only the |stex-logo| package is already needed now for the default theme.
%
%    \begin{macrocode}
%<*package>
\bool_if:NT \c_@@_notes_bool {
  \RequirePackage{a4wide}
  \RequirePackage{marginnote}
  \PassOptionsToPackage{usenames,dvipsnames,svgnames}{xcolor}
  \RequirePackage{mdframed}
  \RequirePackage[noxcolor,noamsthm]{beamerarticle}
  \RequirePackage[bookmarks,bookmarksopen,bookmarksnumbered,breaklinks,hidelinks]{hyperref}
}
\RequirePackage{stex-tikzinput}
\RequirePackage{etoolbox}
\RequirePackage{amssymb}
\RequirePackage{amsmath}
\RequirePackage{comment}
\RequirePackage{textcomp}
\RequirePackage{url}
\RequirePackage{graphicx}
\RequirePackage{pgf}
%    \end{macrocode}
% 
% \subsection{Notes and Slides}\label{sec:impl:noteslides}
%
% For the lecture notes cases, we also provide the |\usetheme| macro that would otherwise
% come from the the |beamer| class. While the latter loads
% |beamertheme|\meta{theme}{.sty}, the notes version loads
% |beamernotestheme|\meta{theme}|.sty|.\ednote{MK: This is not ideal, but I am not sure
% that I want to be able to provide the full theme functionality there.}
%    \begin{macrocode}
\bool_if:NT \c_@@_notes_bool {
  \renewcommand\usetheme[2][]{\usepackage[#1]{beamernotestheme#2}}
}


\NewDocumentCommand \libusetheme {O{} m} {
  \bool_if:NTF \c_@@_notes_bool {
    \libusepackage[#1]{beamernotestheme#2}
  }{
  \libusepackage[#1]{beamertheme#2}
  }
}

%    \end{macrocode}
% We define the sizes of slides in the notes. Somehow, we cannot get by with the same
% here. 
%
%    \begin{macrocode}
\newcounter{slide}
\newlength{\slidewidth}\setlength{\slidewidth}{13.5cm}
\newlength{\slideheight}\setlength{\slideheight}{9cm}
%    \end{macrocode}
% 
% \begin{environment}{note}
% The |note| environment is used to leave out text in the |slides| mode. It does not have
% a counterpart in OMDoc. So for course notes, we define the |note| environment to be a
% no-operation otherwise we declare the |note| environment as a comment via the |comment|
% package.
%    \begin{macrocode}
\bool_if:NTF \c_@@_notes_bool {
  \renewenvironment{note}{\ignorespaces}{}
}{
  \excludecomment{note}
}
%    \end{macrocode}
% \end{environment}
% 
% We first set up the slide boxes in |article| mode. We set up sizes and provide a
% box register for the frames and a counter for the slides.
% 
%    \begin{macrocode}
\bool_if:NT \c_@@_notes_bool {
  \newlength{\slideframewidth}
  \setlength{\slideframewidth}{1.5pt}
%    \end{macrocode}
% 
% \begin{environment}{frame}
%   We first define the keys. 
%    \begin{macrocode}
  \cs_new_protected:Nn \_@@_do_yes_param:Nn {
    \exp_args:Nx \str_if_eq:nnTF { \str_uppercase:n{ #2 } }{ yes }{
      \bool_set_true:N #1
    }{
      \bool_set_false:N #1
    }
  }
  \keys_define:nn{notesslides / frame}{
    label               .str_set_x:N  = \l_@@_frame_label_str,
    allowframebreaks    .code:n       = {
      \_@@_do_yes_param:Nn \l_@@_frame_allowframebreaks_bool { #1 }
    },
    allowdisplaybreaks  .code:n       = {
      \_@@_do_yes_param:Nn \l_@@_frame_allowdisplaybreaks_bool { #1 }
    },
    fragile             .code:n       = {
      \_@@_do_yes_param:Nn \l_@@_frame_fragile_bool { #1 }
    },
    shrink              .code:n       = {
      \_@@_do_yes_param:Nn \l_@@_frame_shrink_bool { #1 }
    },
    squeeze             .code:n       = {
      \_@@_do_yes_param:Nn \l_@@_frame_squeeze_bool { #1 }
    },
    t                   .code:n       = {
      \_@@_do_yes_param:Nn \l_@@_frame_t_bool { #1 }
    },
    unknown   .code:n       = {}
  }
  \cs_new_protected:Nn \_@@_frame_args:n {
    \str_clear:N \l_@@_frame_label_str
    \bool_set_true:N \l_@@_frame_allowframebreaks_bool
    \bool_set_true:N \l_@@_frame_allowdisplaybreaks_bool
    \bool_set_true:N \l_@@_frame_fragile_bool
    \bool_set_true:N \l_@@_frame_shrink_bool
    \bool_set_true:N \l_@@_frame_squeeze_bool
    \bool_set_true:N \l_@@_frame_t_bool
    \keys_set:nn { notesslides / frame }{ #1 }
  }
%    \end{macrocode}
% We define the environment, read them, and construct the slide number and label.
%    \begin{macrocode}
  \renewenvironment{frame}[1][]{
    \_@@_frame_args:n{#1}
    \sffamily
    \stepcounter{slide}
    \def\@currentlabel{\theslide}
    \str_if_empty:NF \l_@@_frame_label_str {
      \label{\l_@@_frame_label_str}
    }
%    \end{macrocode}
%   We redefine the |itemize| environment so that it looks more like the one in |beamer|. 
%    \begin{macrocode}
    \def\itemize@level{outer}
    \def\itemize@outer{outer}
    \def\itemize@inner{inner}
    \renewcommand\newpage{\addtocounter{framenumber}{1}}
    %\newcommand\metakeys@show@keys[2]{\marginnote{{\scriptsize ##2}}}
    \renewenvironment{itemize}{
      \ifx\itemize@level\itemize@outer
        \def\itemize@label{$\rhd$}
      \fi
      \ifx\itemize@level\itemize@inner
        \def\itemize@label{$\scriptstyle\rhd$}
      \fi
      \begin{list}
      {\itemize@label}
      {\setlength{\labelsep}{.3em}
       \setlength{\labelwidth}{.5em}
       \setlength{\leftmargin}{1.5em}
      }
      \edef\itemize@level{\itemize@inner}
    }{
      \end{list}
    }
%    \end{macrocode}
% We create the box with the |mdframed| environment from the equinymous package.
%    \begin{macrocode}
    \stex_html_backend:TF {
      \begin{stex_annotate_env}{frame}{}\vbox\bgroup
        \mdf@patchamsthm
    }{
      \begin{mdframed}[linewidth=\slideframewidth,skipabove=1ex,skipbelow=1ex,userdefinedwidth=\slidewidth,align=center]\sf
    }
  }{
    \stex_html_backend:TF {
      \miko@slidelabel\egroup\end{stex_annotate_env}
    }{\medskip\miko@slidelabel\end{mdframed}}
  }
%    \end{macrocode}
% \end{environment}
% 
% Now, we need to redefine the frametitle (we are still in course notes mode). 
% \begin{macro}{\frametitle}
%    \begin{macrocode}
  \renewcommand{\frametitle}[1]{
    \stex_document_title:n { #1 }
    {\Large\bf\sf\color{blue}{#1}}\medskip
  }
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pause}
%   \ednote{MK: fake it in notes mode for now}
%    \begin{macrocode}
\bool_if:NT \c_@@_notes_bool {
  \newcommand\pause{}
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{environment}{nparagraph}
%    \begin{macrocode}
\bool_if:NTF \c_@@_notes_bool {
  \newenvironment{nparagraph}[1][]{\begin{sparagraph}[#1]}{\end{sparagraph}}
}{
  \excludecomment{nparagraph}
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{nfragment}
%    \begin{macrocode}
\bool_if:NTF \c_@@_notes_bool {
  \newenvironment{nfragment}[2][]{\begin{sfragment}[#1]{#2}}{\end{sfragment}}
}{
  \excludecomment{nfragment}
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{ndefinition}
%    \begin{macrocode}
\bool_if:NTF \c_@@_notes_bool {
  \newenvironment{ndefinition}[1][]{\begin{sdefinition}[#1]}{\end{sdefinition}}
}{
  \excludecomment{ndefinition}
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{nassertion}
%    \begin{macrocode}
\bool_if:NTF \c_@@_notes_bool {
  \newenvironment{nassertion}[1][]{\begin{sassertion}[#1]}{\end{sassertion}}
}{
  \excludecomment{nassertion}
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{nsproof}
%    \begin{macrocode}
\bool_if:NTF \c_@@_notes_bool {
  \newenvironment{nproof}[2][]{\begin{sproof}[#1]{#2}}{\end{sproof}}
}{
  \excludecomment{nproof}
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{nexample}
%    \begin{macrocode}
\bool_if:NTF \c_@@_notes_bool {
  \newenvironment{nexample}[1][]{\begin{sexample}[#1]}{\end{sexample}}
}{
  \excludecomment{nexample}
}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\inputref@*skip}
% We customize the hooks for in |\inputref|. 
%    \begin{macrocode}
\def\inputref@preskip{\smallskip}
\def\inputref@postskip{\medskip}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\inputref*}
%    \begin{macrocode}
\let\orig@inputref\inputref
\def\inputref{\@ifstar\ninputref\orig@inputref}
\newcommand\ninputref[2][]{
  \bool_if:NT \c_@@_notes_bool {
    \orig@inputref[#1]{#2}
  }
}
%    \end{macrocode}
% \end{macro}
% 
% \subsection{Header and Footer Lines}\label{sec:impl:headfootlines}
%
% Now, we set up the infrastructure for the footer line of the slides, we use boxes for
% the logos, so that they are only loaded once, that considerably speeds up processing.
% 
% \begin{macro}{\setslidelogo}
% The default logo is the {\sTeX} logo. Customization can be done by |\setslidelogo{|\meta{logo name}|}|.
%    \begin{macrocode}
\newlength{\slidelogoheight}

\RequirePackage{graphicx}

\define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}}
\providecommand\mhgraphics[2][]{
  \def\Gin@mhrepos{}\setkeys{Gin}{#1}
  \includegraphics[#1]{\mhpath\Gin@mhrepos{#2}}
}



\bool_if:NTF \c_@@_notes_bool {
  \setlength{\slidelogoheight}{.4cm}
}{
  \setlength{\slidelogoheight}{.25cm}
}
\ifcsname slidelogo\endcsname\else
  \newsavebox{\slidelogo}
  \sbox{\slidelogo}{\sTeX}
\fi
\newrobustcmd{\setslidelogo}[2][]{
  \tl_if_empty:nTF{#1}{
    \sbox{\slidelogo}{\includegraphics[height=\slidelogoheight]{#2}}
  }{
    \sbox{\slidelogo}{\mhgraphics[height=\slidelogoheight,mhrepos=#1]{#2}}
  }
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setsource}
% |\source| stores the writer's name. By default it is {\it Michael Kohlhase} since he is the main user and designer of this package. |\setsource{|\meta{name}|}| can change the writer's name.
%    \begin{macrocode}
\def\source{Michael Kohlhase}% customize locally
\newrobustcmd{\setsource}[1]{\def\source{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setlicensing}
%   Now, we set up the copyright and licensing. By default we use the Creative Commons
%   Attribuition-ShareAlike license to strengthen the public domain. If package |hyperref|
%   is loaded, then we can attach a hyperlink to the license
%   logo. |\setlicensing[|\meta{url}|]{|\meta{logo name}|}| is used for customization,
%   where ||\meta{url}|| is optional.
%    \begin{macrocode}
\def\copyrightnotice{\footnotesize\copyright :\hspace{.3ex}{\source}}
\newsavebox{\cclogo}
\sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{stex-cc_somerights}}
\newif\ifcchref\cchreffalse
\AtBeginDocument{
  \@ifpackageloaded{hyperref}{\cchreftrue}{\cchreffalse}
}
\def\licensing{
  \ifcchref
    \href{http://creativecommons.org/licenses/by-sa/2.5/}{\usebox{\cclogo}}
  \else
    {\usebox{\cclogo}}
  \fi
}
\newrobustcmd{\setlicensing}[2][]{
  \def\@url{#1}
  \sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{#2}}
  \ifx\@url\@empty
    \def\licensing{{\usebox{\cclogo}}}
  \else
    \def\licensing{
      \ifcchref
      \href{#1}{\usebox{\cclogo}}
      \else
      {\usebox{\cclogo}}
      \fi
    }
  \fi
}
%    \end{macrocode}
% \end{macro} 
%
% \begin{macro}{\slidelabel}
% Now, we set up the slide label for the |article| mode.\ednote{see that we can use the themes for the slides some day. This is all fake.}
%    \begin{macrocode}
\newrobustcmd\miko@slidelabel{
  \vbox to \slidelogoheight{
    \vss\hbox to \slidewidth
    {\licensing\hfill\copyrightnotice\hfill\arabic{slide}\hfill\usebox{\slidelogo}}
  }
}
%    \end{macrocode}
% \end{macro}
% \subsection{Frame Images}\label{sec:impl:frameimage}
%
% \begin{macro}{\frameimage}
%   We have to make sure that the width is overwritten, for that we check the
%   |\Gin@ewidth| macro from the |graphicx| package. We also add the |label| key. 
%    \begin{macrocode}
\def\Gin@mhrepos{}
\define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}}
\define@key{Gin}{label}{\def\@currentlabel{\arabic{slide}}\label{#1}}
\newrobustcmd\frameimage[2][]{
  \stepcounter{slide}
  \bool_if:NT \c_@@_frameimages_bool {
    \def\Gin@ewidth{}\setkeys{Gin}{#1}
    \bool_if:NF \c_@@_notes_bool { \vfill }
    \begin{center}
      \bool_if:NTF \c_@@_fiboxed_bool {
        \fbox{
          \ifx\Gin@ewidth\@empty
            \ifx\Gin@mhrepos\@empty
              \mhgraphics[width=\slidewidth,#1]{#2}
            \else
              \mhgraphics[width=\slidewidth,#1,mhrepos=\Gin@mhrepos]{#2}
            \fi
          \else% Gin@ewidth empty
            \ifx\Gin@mhrepos\@empty
              \mhgraphics[#1]{#2}
            \else
              \mhgraphics[#1,mhrepos=\Gin@mhrepos]{#2}
            \fi
          \fi% Gin@ewidth empty
        }
      }{
        \ifx\Gin@ewidth\@empty
          \ifx\Gin@mhrepos\@empty
            \mhgraphics[width=\slidewidth,#1]{#2}
          \else
            \mhgraphics[width=\slidewidth,#1,mhrepos=\Gin@mhrepos]{#2}
          \fi
          \ifx\Gin@mhrepos\@empty
            \mhgraphics[#1]{#2}
          \else
            \mhgraphics[#1,mhrepos=\Gin@mhrepos]{#2}
          \fi
        \fi% Gin@ewidth empty
      }
     \end{center}
    \par\strut\hfill{\footnotesize Slide \arabic{slide}}%
    \bool_if:NF \c_@@_notes_bool { \vfill }
  }
} % ifmks@sty@frameimages
%    \end{macrocode}
% \end{macro}
% 
% \subsection{Colors and Highlighting}\label{sec:impl:highlighting}
%
% We first specify sans serif fonts as the default. 
%
%    \begin{macrocode}
\sffamily
%    \end{macrocode}
%
% Now, we set up an infrastructure for highlighting phrases in slides. Note that we use
% content-oriented macros for highlighting rather than directly using color markup. 
% The first thing to to is to adapt the green so that it is dark enough for most beamers
%    \begin{macrocode}
\AddToHook{begindocument}{
  \definecolor{green}{rgb}{0,.5,0}
  \definecolor{purple}{cmyk}{.3,1,0,.17}
}
%    \end{macrocode}
%
% We customize the |\defemph|, |\symrefemph|, |\compemph|, and |\titleemph| macros with
% colors. Furthermore we customize the |\__omtextlec| macro for the appearance of line end
% comments in |\lec|.
%
%    \begin{macrocode}
% \def\STpresent#1{\textcolor{blue}{#1}}
\def\defemph#1{{\textcolor{magenta}{#1}}}
\def\symrefemph#1{{\textcolor{cyan}{#1}}}
\def\compemph#1{{\textcolor{blue}{#1}}}
\def\titleemph#1{{\textcolor{blue}{#1}}}
\def\__omtext_lec#1{(\textcolor{green}{#1})}
%    \end{macrocode}
%
% I like to use the dangerous bend symbol for warnings, so we provide it here.
% \begin{macro}{\textwarning}
%   as the macro can be used quite often we put it into a box register, so that it is only
%   loaded once. 
%    \begin{macrocode}
\pgfdeclareimage[width=.8em]{miko@small@dbend}{stex-dangerous-bend}
\def\smalltextwarning{
  \pgfuseimage{miko@small@dbend}
  \xspace
}
\pgfdeclareimage[width=1.2em]{miko@dbend}{stex-dangerous-bend}
\newrobustcmd\textwarning{
  \raisebox{-.05cm}{\pgfuseimage{miko@dbend}}
  \xspace
}
\pgfdeclareimage[width=2.5em]{miko@big@dbend}{stex-dangerous-bend}
\newrobustcmd\bigtextwarning{
  \raisebox{-.05cm}{\pgfuseimage{miko@big@dbend}}
  \xspace
}
%    \end{macrocode}
% \end{macro}
% 
%    \begin{macrocode}
\newrobustcmd\putgraphicsat[3]{
  \begin{picture}(0,0)\put(#1){\includegraphics[#2]{#3}}\end{picture}
}
\newrobustcmd\putat[2]{
  \begin{picture}(0,0)\put(#1){#2}\end{picture}
}
%    \end{macrocode}
%
% \subsection{Sectioning}
%
% If the |sectocframes| option is set, then we make section frames. We first define
% counters for |part| and |chapter|, which |beamer.cls| does not have and we make the
% |section| counter which it does dependent on |chapter|. 
%    \begin{macrocode}
\stex_html_backend:F {
  \bool_if:NT \c_@@_sectocframes_bool {
    \str_if_eq:VnTF \@@topsect{part}{
      \newcounter{chapter}\counterwithin*{section}{chapter}
    }{
      \str_if_eq:VnT\@@topsect{chapter}{
        \newcounter{chapter}\counterwithin*{section}{chapter}
      }
    }
  }
}
%    \end{macrocode}
%
% We set the \DescribeMacro{\section@level}|\section@level| counter that governs
% sectioning according to the class options. We also introduce the sectioning counters
% accordingly. 
%
% \begin{macro}{\section@level}
%    \begin{macrocode}
\def\part@prefix{}
\@ifpackageloaded{document-structure}{}{
  \str_case:VnF \@@topsect {
    {part}{
      \int_set:Nn \l_document_structure_section_level_int {0}
      \def\thesection{\arabic{chapter}.\arabic{section}}
      \def\part@prefix{\arabic{chapter}.}
    }
    {chapter}{
      \int_set:Nn \l_document_structure_section_level_int {1}
      \def\thesection{\arabic{chapter}.\arabic{section}}
      \def\part@prefix{\arabic{chapter}.}
    }
  }{
    \int_set:Nn \l_document_structure_section_level_int {2}
    \def\part@prefix{}
  }
}

\bool_if:NF \c_@@_notes_bool { % only in slides
%    \end{macrocode}
% \end{macro}
%
% The new counters are used in the |sfragment| environment that choses the {\LaTeX}
% sectioning macros according to |\section@level|. 
% 
% \begin{environment}{sfragment}
%    \begin{macrocode}
  \renewenvironment{sfragment}[2][]{
    \__document_structure_sfragment_args:n { #1 }
    \int_incr:N \l_document_structure_section_level_int
    \bool_if:NT \c_@@_sectocframes_bool {
      \stepcounter{slide}
      \begin{frame}[noframenumbering]
      \vfill\Large\centering
      \red{
        \ifcase\l_document_structure_section_level_int\or
          \stepcounter{part}
          \def\@@label{{\omdoc@part@kw}~\Roman{part}}
          \def\currentsectionlevel{\omdoc@part@kw}
        \or
          \stepcounter{chapter}
          \def\@@label{{\omdoc@chapter@kw}~\arabic{chapter}}
          \def\currentsectionlevel{\omdoc@chapter@kw}
        \or
          \stepcounter{section}
          \def\@@label{\part@prefix\arabic{section}}
          \def\currentsectionlevel{\omdoc@section@kw}
        \or
          \stepcounter{subsection}
          \def\@@label{\part@prefix\arabic{section}.\arabic{subsection}}
          \def\currentsectionlevel{\omdoc@subsection@kw}
        \or
          \stepcounter{subsubsection}
          \def\@@label{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
          \def\currentsectionlevel{\omdoc@subsubsection@kw}
        \or
          \stepcounter{paragraph}
          \def\@@label{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}}
          \def\currentsectionlevel{\omdoc@paragraph@kw}
        \else
          \def\@@label{}
          \def\currentsectionlevel{\omdoc@paragraph@kw}
        \fi% end ifcase
        \@@label%\sref@label@id\@@label
        \quad #2%
      }%
      \vfill%
      \end{frame}%
    }
    \str_if_empty:NF \l__document_structure_sfragment_id_str {
      \stex_ref_new_doc_target:n\l__document_structure_sfragment_id_str
    }
  }{}
}
%    \end{macrocode}
% \end{environment}
%
% We set up a |beamer| template for theorems like ams style, but without a block
% environment.  
%    \begin{macrocode}
\def\inserttheorembodyfont{\normalfont}
%\bool_if:NF \c_@@_notes_bool {
%  \defbeamertemplate{theorem begin}{miko}
%  {\inserttheoremheadfont\inserttheoremname\inserttheoremnumber
%    \ifx\inserttheoremaddition\@empty\else\ (\inserttheoremaddition)\fi%
%    \inserttheorempunctuation\inserttheorembodyfont\xspace}
%  \defbeamertemplate{theorem end}{miko}{}
%    \end{macrocode}
% and we set it as the default one. 
%    \begin{macrocode}
%  \setbeamertemplate{theorems}[miko]
%    \end{macrocode}
% The following fixes an error I do not understand, this has something to do with
% beamer compatibility, which has similar definitions but only up to 1. 
%    \begin{macrocode}
%  \expandafter\def\csname Parent2\endcsname{}
%}

\AddToHook{begindocument}{ % this does not work for some reasone
  \setbeamertemplate{theorems}[ams style]
}
\bool_if:NT \c_@@_notes_bool {
  \renewenvironment{columns}[1][]{%
    \par\noindent%
    \begin{minipage}%
    \slidewidth\centering\leavevmode%
  }{%
    \end{minipage}\par\noindent%
  }%
  \newsavebox\columnbox%
  \renewenvironment<>{column}[2][]{%
    \begin{lrbox}{\columnbox}\begin{minipage}{#2}%
  }{%
    \end{minipage}\end{lrbox}\usebox\columnbox%
  }%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\bool_if:NTF \c_@@_noproblems_bool {
  \newenvironment{problems}{}{}
}{
  \excludecomment{problems}
}
%    \end{macrocode}
%
% \subsection{Excursions}\label{sec:impl:excursions}
%
% \begin{macro}{\excursion}
%  The excursion macros are very simple, we define a new internal macro |\excursionref| and
%  use it in |\excursion|, which is just an |\inputref| that checks if the new macro is
%  defined before formatting the file in the argument. 
%    \begin{macrocode}
\gdef\printexcursions{}
\newcommand\excursionref[2]{% label, text
  \bool_if:NT \c_@@_notes_bool {
    \begin{sparagraph}[title=Excursion]
      #2 \sref[fallback=the appendix]{#1}.
    \end{sparagraph}
  }
}
\newcommand\activate@excursion[2][]{
  \gappto\printexcursions{\inputref[#1]{#2}}
}
\newcommand\excursion[4][]{% repos, label, path, text
  \bool_if:NT \c_@@_notes_bool {
    \activate@excursion[#1]{#3}\excursionref{#2}{#4}
  }
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\excursiongroup}
%    \begin{macrocode}
\keys_define:nn{notesslides / excursiongroup }{
  id        .str_set_x:N  = \l_@@_excursion_id_str,
  intro     .tl_set:N     = \l_@@_excursion_intro_tl,
  mhrepos   .str_set_x:N  = \l_@@_excursion_mhrepos_str
}
\cs_new_protected:Nn \_@@_excursion_args:n {
  \tl_clear:N \l_@@_excursion_intro_tl
  \str_clear:N \l_@@_excursion_id_str
  \str_clear:N \l_@@_excursion_mhrepos_str
  \keys_set:nn {notesslides / excursiongroup }{ #1 }
}
\newcommand\excursiongroup[1][]{
  \_@@_excursion_args:n{ #1 }
  \ifdefempty\printexcursions{}% only if there are excursions
  {\begin{note}
    \begin{sfragment}[#1]{Excursions}%
      \ifdefempty\l_@@_excursion_intro_tl{}{
        \inputref[\l_@@_excursion_mhrepos_str]{
          \l_@@_excursion_intro_tl
        }
      }
      \printexcursions%
    \end{sfragment}
  \end{note}}
}
\ifcsname beameritemnestingprefix\endcsname\else\def\beameritemnestingprefix{}\fi
%</package>
%    \end{macrocode}
% \end{macro}
%
% \end{implementation}
% \ifinfulldoc\else\printbibliography\fi
\endinput
% \endinput
% Local Variables:
% mode: doctex
% TeX-master: t
% End: