summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/mikoslides/mikoslides.dtx
blob: 3840ff87e4ed25ef7375e9e0290abc3ca7426a89 (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
% \iffalse meta-comment
% A LaTeX Class for Jacobs University Slides
% Copyright (c) 2007 Michael Kohlhase, all rights reserved
%               this file is released under the
%               Gnu Library Public Licences (LGPL)
%
% The development version of this file can be found at
% https://svn.kwarc.info/repos/kwarc/projects/stex/sty/mikoslides.dtx
% \fi
% 
% \iffalse
%<cls>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<cls>\ProvidesClass{mikoslides}[2010/06/25 v0.9 Jacobs slides]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{url,array,float}
\usepackage[show]{ed}
\makeindex
\floatstyle{boxed}
\newfloat{exfig}{thp}{lop}
\floatname{exfig}{Example}
\begin{document}\DocInput{mikoslides.dtx}\end{document}
%</driver>
% \fi
% 
% \CheckSum{317}
% 
% \changes{v0.1}{2005/12/06}{Initial Version}
% \changes{v0.2}{2006/01/11}{course notes back on seminar}
% \changes{v0.3}{2007/05/16}{changing to jacobs logo}
% \changes{v0.4}{2007/10/16}{re-basing the whole thing on beamer}
% \changes{v0.4}{2008/09/06}{moving line-end-comment to \texttt{omdoc.dtx}}
% \changes{v0.5}{2009/06/17}{eliminating mytwocolumns, this is better done by \texttt{beamer.cls}}
% \changes{v0.9}{2010/06/18}{this is almost done}
% 
% \GetFileInfo{mikoslides.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}
% \def\mathml{{\scshape{MathML}}}
% \def\latexml{\hbox{{\LaTeX}ML}}
% \def\omdoc{OMDoc}
% \def\activemath{{\scshape{ActiveMath}}}
% 
% \title{Slides and Course Notes for Jacobs University\thanks{Version {\fileversion}
% (last revised {\filedate})}}
%    \author{Michael Kohlhase\\
%            Jacobs University, Bremen\\
%            \url{http://kwarc.info/kohlhase}}
% \maketitle
%
% \begin{abstract}
%   We present a document class from which we can generate both course slides and course
%   notes in a transparent way. Furthermore, we present a set of {\latexml} bindings for
%   these, so that we can also generate {\omdoc}-based course materials, e.g. for
%   inclusion in the {\activemath} system.
% \end{abstract}
% \tableofcontents\newpage
%\section{Introduction}
% This Document class is derived from |beamer.cls|, specializes it with Jacobs stuff and
% adds a notes version that is more suited to printing than the one supplied by
% |beamer.cls|.
% 
%\section{The User Interface}\label{sec:user}
% \StopEventually{\newpage\PrintChanges}
%
%\section{The Implementation}\label{sec:impl}
%
%\subsection{Initialization and Class Options}\label{sec:impl:init}
%
% For the {\latexml} bindings, we make sure the right perl packages are loaded.
%
%    \begin{macrocode}
%<*ltxml>
# -*- CPERL -*-
package LaTeXML::Package::Pool;
use strict;
use LaTeXML::Package;
%</ltxml>
%    \end{macrocode}
%
% For {\LaTeX} we define some Package Options and switches for the |mikoslides| class and activate
% them by passing them on to |beamer.cls| the appropriate packages.
%
%    \begin{macrocode}
%<*cls>
\newif\ifnotes\notesfalse
\newif\ifproblems\problemstrue
\DeclareOption{notes}{\notestrue}
\DeclareOption{slides}{\notesfalse}
\DeclareOption{noproblems}{\problemsfalse}
\ifnotes\else\DeclareOption*{\PassOptionsToClass{\CurrentOption}{beamer}}\fi
\ProcessOptions
%</cls>
%<*ltxml>
RawTeX('\newif\ifnotes\notesfalse');
RawTeX('\newif\ifproblems\problemsfalse');
%</ltxml>
%    \end{macrocode}
%
% Depending on the options, we either load the |article|-based |omdoc| or the |beamer| class. In the first
% case, 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. 
%    \begin{macrocode}
%<*cls>
\ifnotes
\LoadClass{omdoc}
\RequirePackage{a4wide}
\RequirePackage[notheorems,noamsthm]{beamerarticle}
\else
\LoadClass[notheorems,noamsthm,10pt]{beamer}
\newcounter{Item}
\newcounter{paragraph}
\newcounter{subparagraph}
\newcounter{Hfootnote}
\usetheme{Jacobs}
\fi
%</cls>
%<*ltxml>
LoadClass('omdoc');
%</ltxml>
%    \end{macrocode}
% 
% now, we load the remaining packages for both versions. 
%
%    \begin{macrocode}
%<*cls>
\RequirePackage{stex}
\RequirePackage{latexml}
\RequirePackage{amssymb}
\RequirePackage{tikz}
\usepgflibrary{shapes}\usetikzlibrary{arrows}
\RequirePackage{url}
\RequirePackage{amsmath}
\RequirePackage{comment}
%</cls>
%<*ltxml>
RequirePackage('stex'); 
RequirePackage('latexml');
RequirePackage('amssymb');
RequirePackage('graphicx');
RequirePackage('tikz');
RequirePackage('amsmath');
%</ltxml>
%    \end{macrocode}
% \begin{oldpart}{we do not seem to load this any more, what to do
% there?}% The |etex.sty| package is needed in the {\LaTeX}, since it makes the extended the number
% of internal registers of the |etex| program available for processing. These tend to run
% out with {\sTeX} otherwise.
% \end{oldpart}
% 
% \subsection{Notes and Slides}\label{sec:impl:noteslides}
%
% We define the sizes of slides in the notes. Somehow, we cannot get by with the same
% here. 
%
%    \begin{macrocode}
%<*cls>
\newcounter{slide}
\newlength{\slidewidth}\setlength{\slidewidth}{13.5cm}
\newlength{\slideheight}\setlength{\slideheight}{9cm}
%</cls>
%<*ltxml>
DefRegister('\slidewidth'     => Dimension('13.5cm'));
DefRegister('\slideheight'     => Dimension('9cm'));
%</ltxml>
%    \end{macrocode}
% 
% 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{environment}{note}
%    \begin{macrocode}
%<*cls>
\ifnotes\renewenvironment{note}{}{}\else\excludecomment{note}\fi
%</cls>
%<*ltxml>
DefEnvironment('{note}','#body');
%</ltxml>
%    \end{macrocode}
% \end{environment}
% 
%
% the next step is to 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}
%<*cls>
\ifnotes
\newlength{\slideframewidth}\setlength{\slideframewidth}{2pt}
\newsavebox{\myframebox}
%</cls>
%    \end{macrocode}
% 
% \begin{environment}{frame}
%   For the |frame| environment we construct a |lrbox| in the |\myframebox| register that
%   we can later put into an |\fbox| so that it looks like a slide.  Furthermore, we
%   redefine the |itenize| environment so that it looks more like the one in |beamer| with
%   |Jacobs| theme.
%    \begin{macrocode}
%<*cls>
\renewenvironment{frame}[1][]%
{\stepcounter{slide}
\def\itemize@level{outer}
\def\itemize@outer{outer}
\def\itemize@inner{inner}
\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}}
 \noindent\hfill\begin{lrbox}{\myframebox}
   \begin{minipage}{\slidewidth}\sf}%
   {\miko@slidelabel\end{minipage}\end{lrbox}%
 \begin{center}\fbox{\usebox\myframebox}\end{center}\hfill}
%</cls>
%<*ltxml>
DefEnvironment('{frame}[]',
   "<omdoc:omgroup layout='slide' ?#locator(stex:srcref='#locator')()>"
  .  "#body\n"
  ."</omdoc:omgroup>\n\n",
 afterDigestBegin=>sub {
   $_[1]->setProperty(theory=>LookupValue('current_module')); });
%</ltxml>#$
%    \end{macrocode}
% \end{environment}
% 
% the next step is to set up the slide boxes in |article| mode.
% 
%    \begin{macrocode}
%<*cls>
\renewcommand{\frametitle}[1]{{\Large\bf\sf\color{blue}{#1}}}
\fi
\makeindex
%</cls>
%<*ltxml>
DefConstructor('\frametitle{}',
  "\n<omdoc:metadata ?#locator(stex:srcref='#locator')()><dc:title>#1</dc:title></omdoc:metadata>");
%</ltxml>
%    \end{macrocode}
% 
% We start by giving the {\latexml} binding for the |frame| environment from the |beamer|
% class. The |note| environment is used to blend out text in the |slides| mode. It does
% not have a counterpart in OMDoc.
%
%    \begin{macrocode}
%<*cls>
\ifproblems\newenvironment{problems}{}{}\else\excludecomment{problems}\fi
%</cls>
%<*ltxml>
DefEnvironment('{problems}','#body');
%</ltxml>
%    \end{macrocode}
%\ednote{subtitle is difficult to model in DC metadata. I guess that we want to collect
%the subtitle into dc:title}
%
% \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{macrocode}
%<*cls>
\newlength{\slidelogoheight}
\ifnotes\setlength{\slidelogoheight}{.4cm}\else\setlength{\slidelogoheight}{1cm}\fi
\newsavebox{\slidelogo}\sbox{\slidelogo}{\includegraphics[height=\slidelogoheight]{jacobs-logo}}
%    \end{macrocode}
% 
% Now, we set up the copyright and licensing, the copyright remains with the author, but
% we use the Creative Commons Attribuition-ShareAlike license to strengthen den public
% domain. Here the problem is that we want a hyperref on the CC logo, if hyperref is
% loaded, and otherwise not. As hyperref is always loaded, we have to find out at the
% beginning of the document whether it is, set up a switch, and later in the footer line
% decide what to do. 
%
%    \begin{macrocode}
\def\source{Michael Kohlhase}% customize locally
\def\copyrightnotice{\footnotesize\copyright:\hspace{.3ex}{\source}}
\newsavebox{\cclogo}\sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{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}
%    \end{macrocode}
% 
% 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{macro}{\slidelabel}
%    \begin{macrocode}
\newcommand{\miko@slidelabel}%
{\vbox to \slidelogoheight{\vss\hbox to \slidewidth%
{\licensing\hfill\copyrightnotice\hfill\arabic{slide}\hfill\usebox{\slidelogo}}}}
%</cls>
%    \end{macrocode}
% \end{macro}
% 
% \subsection{Colors and Highlighting}\label{sec:impl:highlighting}
%
% 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}
%<*cls>
\AtBeginDocument{\definecolor{green}{rgb}{0,.5,0}\definecolor{purple}{cmyk}{.3,1,0,.17}}
%    \end{macrocode}
%
% We customize the |\defemph|, |\notemph|, and |\stDMemph| macros with colors for the use
% in the |statements| package. Furthermore we customize the |\@@lec| macro for the
% appearance of line end comments in |\lec|.
%
%    \begin{macrocode}
\def\defemph#1{{\textcolor{magenta}{#1}}}
\def\notemph#1{{\textcolor{magenta}{#1}}}
\def\stDMemph#1{{\textcolor{blue}{#1}}}
\def\@@lec#1{(\textcolor{green}{#1})}
%</cls>
%<*ltxml>
#DefMacro('\defemph{}','{\textcolor{magenta}{#1}}');
#DefMacro('\notemph{}','{\textcolor{magenta}{#1}}');
%</ltxml>
%    \end{macrocode}
%
% I like to use the dangerous bend symbol for warnings, so we provide it here.
%    \begin{macrocode}
%<*cls>
\def\textwarning{\raisebox{-.05cm}{\includegraphics[width=1.2em]{dangerous-bend}}\xspace}
%</cls>
%<*ltxml>
DefMacro('\textwarning',"");
%</ltxml>
%    \end{macrocode}
% Now, we specialize the slide environment that we have implemented above or inherited
% from |seminar.cls| for some abbreviations, e.g. separator slides and title slides.
%    \begin{macrocode}
%<*cls>
\newenvironment{ttitle}{\begin{center}\LARGE\begin{tabular}{|c|}\hline}%
 {\\\hline\end{tabular}\end{center}\vspace{1ex minus 1ex}}
\newenvironment{ttitlejoint}[1]%
{\newbox\boxwith\setbox\boxwith\hbox{\begin{tabular}{c}{\em joint work with}\\#1\end{tabular}}%
\begin{center}\LARGE\begin{tabular}{c}\color{red}}%
{\\\box\boxwith\end{tabular}\end{center}%
\vspace{1ex minus 1ex}}
%</cls>
%<*ltxml>
DefEnvironment('{titleslide}',"");
DefEnvironment('{titleslide}',"<omdoc:omgroup ?#locator(stex:srcref='#locator')()>#body</omdoc:omgroup>");
DefEnvironment('{ttitle}', "\n<Title>#body</Title>");
%</ltxml>
%    \end{macrocode}
%
%    \begin{macrocode}
%      Must be first command on slide to make positioning work.
%<*cls>
\newcommand{\putgraphicsat}[3]{%
 \begin{picture}(0,0)\put(#1){\includegraphics[#2]{#3}}\end{picture}}
\newcommand{\putat}[2]{%
 \begin{picture}(0,0)\put(#1){#2}\end{picture}}
%</cls>
%<*ltxml>
%</ltxml>
%    \end{macrocode}
%
% \subsection{Miscellaneous}
%
% Some shortcuts that use math symbols but are not mathematical at all; in particular,
% they should not be translated by {\latexml}.
%
%    \begin{macrocode}
%<*cls>
\newcommand\hateq{\ensuremath{\hat=}}
\newcommand\textleadsto{\ensuremath{\leadsto}}
%</cls>
%<*ltxml>
DefConstructor('\hateq',"=\x{03C2}");
DefConstructor('\textleadsto',"=\x{219D}");
%</ltxml>
%    \end{macrocode}
%
% We need to disregard the columns macros introduced by the |beamer| class
%    \begin{macrocode}
%<*ltxml>
DefEnvironment('{columns}','#body');
DefEnvironment('{column}{}','#body');
%</ltxml>
%    \end{macrocode}
%
% We also need to deal with overlay specifications introduced by the |beamer|
% class.\ednote{this is just to keep latexml quiet, no real functionality here.}
%
% \ednote{Deyan: We reuse the CMP itemizations defined in the omdoc.cls.ltxml binding,
%   adjusting the parameters to be overlay-sensitive }
%    \begin{macrocode}
%<*ltxml>
DefConstructor('\uncover','#1');
#Define a Beamer Overlay Parameter type
 DefParameterType('BeamerOverlay', sub {
   my ($gullet) = @_;
   my $tok = $gullet->readXToken;
   if (ref $tok && ToString($tok) eq '<') {
     $gullet->readUntil(T_OTHER('>'));
   } else {
     $gullet->unread($tok) if ref $tok;
     undef; }},
     reversion=> sub {
 (T_OTHER('<'), $_[0]->revert, T_OTHER('>'));
       });

#Take the "from" field of the overlay range
sub overlayFrom {
  return "" unless defined $_[0];
  my $overlay=ToString($_[0]); $overlay =~ /^(\d+)/; $1;}

#Reuse the CMP itemizations, only adjust the \item constructors.
DefMacro('\beamer@group@item[] OptionalBeamerOverlay IfBeginFollows', sub {
  my($gullet,$tag,$overlay,$needwrapper)=@_;
  $overlay=$overlay||T_OTHER("");
  ( T_CS('\group@item@maybe@unwrap'),
    ($needwrapper ? (Invocation(T_CS('\beamer@group@item@wrap'),$tag,$overlay)->unlist) : ()) ); });
DefConstructor('\beamer@group@item@wrap {} OptionalBeamerOverlay',
       "<omdoc:omtext ?#locator(stex:srcref='#locator')() ?#2(overlay='&overlayFrom(#2)')()>"
       . "?#1(<dc:title>#1</dc:title>)()"
               . "<omdoc:CMP ?#locator(stex:srcref='#locator')()><omdoc:p ?#locator(stex:srcref='#locator')()>",
       beforeDigest=>sub {
 Let('\group@item@maybe@unwrap','\group@item@unwrap');
 #$_[0]->bgroup;
 useCMPItemizations();
 return; },
       properties=>sub{ RefStepItemCounter(); });


DefConstructor('\beamer@itemize@item[] OptionalBeamerOverlay',
       "<omdoc:li ?#locator(stex:srcref='#locator')() ?#2(overlay='&overlayFrom(#2)')() >"
     . "?#1(<dc:title ?#locator(stex:srcref='#locator')()>#1</dc:title>)()",
       properties=>sub{ RefStepItemCounter(); });
DefConstructor('\beamer@enumerate@item[] OptionalBeamerOverlay',
       "<omdoc:li ?#locator(stex:srcref='#locator')() ?#2(overlay='&overlayFrom(#2)')() >"
     . "?#1(<dc:title ?#locator(stex:srcref='#locator')()>#1</dc:title>)()",
       properties=>sub{ RefStepItemCounter(); });
DefConstructor('\beamer@description@item[] OptionalBeamerOverlay',
       "<omdoc:di ?#locator(stex:srcref='#locator')()  ?#2(overlay='&overlayFrom(#2)')() >"
       . "?#1(<omdoc:dt ?#locator(stex:srcref='#locator')()>#1</omdoc:dt>)()<omdoc:dd>", # trust di and dt to autoclose
       properties=>sub{ RefStepItemCounter(); });

#We ALWAYS use the beamer itemizations for the slides:
Let('\CMP@itemize@item'=>'\beamer@itemize@item');
Let('\CMP@enumerate@item'=> '\beamer@enumerate@item');
Let('\CMP@description@item'=> '\beamer@description@item');
Let('\group@item' =>'\beamer@group@item');
Let('\itemize@item'=>'\beamer@group@item');
Let('\enumerate@item'=>'\beamer@group@item');
Let('\description@item'=>'\beamer@group@item');
Let('\only'=>'\beamer@group@item');
%</ltxml>#$
%    \end{macrocode}
% Now, some things that are imported from the |pgf| and |beamer| packages: 
%    \begin{macrocode}
%<*ltxml>
DefMacro('\putgraphicsat{}{}{}','\mygraphics[#2]{#3}');
DefMacro('\putat{}{}','#2');
%</ltxml>
%    \end{macrocode}
% 
% \subsection{Finale}
%
% Finally, we set the slide body font to the sans serife, and we terminate the {\latexml}
% bindings file with a success mark for perl.
%    \begin{macrocode}
%<cls>\ifnotes\else\sf\fi
%<ltxml>1;
%    \end{macrocode}
% \Finale
\endinput

% \iffalse
%%% Local Variables: 
%%% mode: doctex
%%% TeX-master: t
%%% End: 
% \fi

% LocalWords:  mikoslides dtx beamer omdoc notheorems noamsthm beamerarticle
% LocalWords:  graphicx slidelabel stex latexml amssymb tikz url CPERL  amsmath
% LocalWords:  LoadClass RequirePackage DefRegister DefEnvironment omgroup rgb
% LocalWords:  afterDigestBegin setProperty LookupValue DefConstructor hyperref
% LocalWords:  cmyk lec DefMacro titleslide ttitle RawTeX metadata etoolbox
% LocalWords:  noproblems linkcolor bookmarksopen citecolor urlcolor colorlinks
% LocalWords:  breaklinks plainpages pdfpagelabels locator srcref