3 % $Id: mdwslides.dtx,v 1.1 2002/02/24 12:47:11 mdw Exp $
5 % Document class for slide sets
7 % (c) 2002 Mark Wooding
9 %----- Revision history -----------------------------------------------------
11 % $Log: mdwslides.dtx,v $
12 % Revision 1.1 2002/02/24 12:47:11 mdw
18 % \begin{meta-comment} <general public licence>
20 %% mdwslides -- a document class for slide sets
21 %% Copyright (c) 2002 Mark Wooding
23 %% This program is free software; you can redistribute it and/or modify
24 %% it under the terms of the GNU General Public License as published by
25 %% the Free Software Foundation; either version 2 of the License, or
26 %% (at your option) any later version.
28 %% This program is distributed in the hope that it will be useful,
29 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
30 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 %% GNU General Public License for more details.
33 %% You should have received a copy of the GNU General Public License
34 %% along with this program; if not, write to the Free Software
35 %% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39 % \begin{meta-comment} <Package preamble>
40 %<+mdwslides>\NeedsTeXFormat{LaTeX2e}
41 %<+mdwslides>\ProvidesClass{mdwslides}
42 %<+mdwslides> [2002/02/20 1.00 mdwslides]
47 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
48 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
49 %% Digits \0\1\2\3\4\5\6\7\8\9
50 %% Exclamation \! Double quote \" Hash (number) \#
51 %% Dollar \$ Percent \% Ampersand \&
52 %% Acute accent \' Left paren \( Right paren \)
53 %% Asterisk \* Plus \+ Comma \,
54 %% Minus \- Point \. Solidus \/
55 %% Colon \: Semicolon \; Less than \<
56 %% Equals \= Greater than \> Question mark \?
57 %% Commercial at \@ Left bracket \[ Backslash \\
58 %% Right bracket \] Circumflex \^ Underscore \_
59 %% Grave accent \` Left brace \{ Vertical bar \|
60 %% Right brace \} Tilde \~}
63 % \begin{meta-comment} <driver>
67 \title{The \package{mdwslides} document class}
73 %^^A-------------------------------------------------------------------------
74 % \section{User guide}
76 % Not a lot to say, really. It's a document class for sets of slides and
77 % their notes. I've based it on Timothy van Zandt's \package{seminar} class,
78 % but there are some important tweaks and bug fixes.
80 % \DescribeMacro\topic
81 % The most important new feature is that the sectioning commands create
82 % little summary pages automatically. Each |\section| is given a summary
83 % page. The subsections are listed one per line, with the topics covered in
84 % that subsection. A topic is introduced by saying
85 % \syntax{"\\topic{"<text>"}"}. This only has an effect in slides-only mode;
86 % it's ignored when typesetting notes.
88 % \DescribeMacro\xcalways
89 % The notes come out best if you put the sectioning commands outside of the
90 % slides. However, in order for a slides-only run to actually notice them,
91 % you need to mark them as `interesting'. You can write
93 % \syntax{"\\xcalways"<anything>"\\x"}
95 % to have \synt{anything} recognized even in slides-only mode.
98 % The heading at the top of a slide is typeset by saying
99 % \syntax{"\\head{"<text>"}"}. Headings come out in a large sans face by
100 % default. Feel free to redefine the command if you don't like that.
102 % \DescribeMacro\resetseq
104 % Maybe it's a deficiency on my part, but I tend to end up with several
105 % slides on the same subject, and rather than think of different headings I
106 % tend to number the successive slides. Say |\resetseq| before the heading
107 % of the first in a series and insert the number by saying |\seq|. Should it
108 % be necessary, you can label and make cross-references to |\seq|uence
111 %^^A-------------------------------------------------------------------------
113 % \section{Implementation}
115 % \subsection{Initial boilerplate}
117 % Pass options straight on. We don't have any of our own.
121 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{seminar}}
124 \RequirePackage{fancyhdr}
127 % \subsection{Fixing some bugs}
129 % Cool as \package{seminar} undoubtedly is, it's also buggy. Here are some
132 % \begin{macro}{\normalsize}
134 % Firstly, there's a very strange bug in the list formatting for notes. This
138 \def\@bugfix#1\let\@listi#2#3\@@%
139 {\def\normalsize{#1#3}}
140 \expandafter\@bugfix\normalsize\@@
145 % \begin{macro}{\slidebox@restore}
147 % Another list typesetting weirdness: too much top glue.
150 \toks@\expandafter{\slidebox@restore}
151 \edef\slidebox@restore{\the\toks@\advance\topsep\parskip}
156 % \begin{macro}{\outputloop@savedslides}
157 % \begin{macro}{\output@savedslide}
159 % I can't quite remember what this does, though I think it's trying to stop a
160 % bizarre loop condition in \package{seminar}'s fake output routine.
164 \def\@bugfix#1\penalty\z@#2\@@{\def\outputloop@savedslides{#1#2}}
165 \expandafter\@bugfix\outputloop@savedslides\@@
166 \toks@\expandafter{\output@savedslide}
168 {\begingroup\output{\unvbox\@cclv}\penalty-\@M\endgroup}
169 \edef\output@savedslide{\noexpand\@strange@hack\the\toks@}
176 % \begin{macro}{\@makeslide}
178 % Make sure that footnotes end up at the \emph{bottom} of a slide, rather
179 % than just after the text.
183 \setbox\@slidebox\vbox{%
184 \@begindvi % added 1997/04/15 SPQR
186 \ifvoid\slide@footins\else
187 \vskip\skip\slide@footins
190 \unvbox\slide@footins
198 % \begin{macro}{\@makecol}
200 % And do the same thing for the main text.
204 \setbox\@outputbox \box\@cclv
205 \xdef\@freelist{\@freelist\@midlist}%
206 \global \let \@midlist \@empty
208 \ifvoid\footins \else
209 \setbox\@outputbox \vbox {%
210 \boxmaxdepth \@maxdepth
222 \setbox\@outputbox \vbox to\@colht {%
224 \dimen@ \dp\@outputbox
230 \global \maxdepth \@maxdepth
236 % \subsection{Hacking \env{xcomment}}
238 % \begin{macro}{\xcalways}
240 % Unfortunately, this involves rewriting rather too much of the
241 % \env{xcomment} code. Sigh.
243 % It also involves catcode fiddling. I need some code-12 versions of various
244 % usually-magical characters. This is the traditional fiddling.
248 \catcode`\!=12\catcode`\[=12\catcode`\]=12\catcode`\"=12
249 \lccode`\!=`\\\lccode`\[=`\{\lccode`\]=`\}\lccode`\"=`\%
250 \catcode`\~=\active\lccode`\~=`\^^M
254 % This is the guts of the main \env{xcomment} loop.
257 \gdef\xcomment@@@#1\@nil{%
262 \def\next{\xcomment@@#1\@nil}%
264 \xc@checkbegin#1\relax begin[]\relax\relax
266 \xc@checkend#1\relax end[]\relax\relax
268 \xc@checkinput#1\relax input[]\relax\relax
270 \xc@checkinclude#1\relax include[]\relax\relax
272 \xc@checkendinput#1\relax endinputss\relax\relax
275 % Now, insert the new check for my macro.
279 \xc@checkalways#1\relax xcalwaysfoo!x\relax\relax
289 % Check to see whether the line contains the an |\xcalways| command. If so
290 % pull the contents out, rescan them, and continue grinding through stuff
291 % which is meant to be ignored.
294 \gdef\xc@checkalways#1xcalways#2!x#3\relax#4\relax{%
299 \toks@{#2}\rescan\toks@%
300 \def\next{\the\toks@\xc@always#3\@nil}%
305 % That's the end of the weird-catcode stuff.
312 % This little macro restarts the search for non-comment stuff where it left
313 % off. We need to gobble the magic end-marker from last time.
316 \def\xc@always#1\@nil{\xc@begin#1}
319 % And the version for slides'n'notes mode is trivial.
322 \def\xcalways#1\x{#1}
327 % \subsection{Slide layout}
329 % This slide size seems to fit reasonably nicely onto a laptop for video
330 % projection. I find that white-on-black shows up better than
331 % black-on-white, for some reason.
338 % For notes, I like thin frames, uncentred, with slides just put wherever
342 \slideplacement{here}
347 % I like to fit quite a lot onto a slide. I'm also not keen on automatic
348 % breaks. This shuts up the output routine and lets me get away with rather
355 % Fiddle the margins around the actual slide content.
358 \def\slideleftmargin{15mm} \let\sliderightmargin=\slideleftmargin
359 \def\slidetopmargin{15mm} \let\slidebottommargin=\slidetopmargin
362 % Page tweaking for notes.
367 \def\slide@clearpage{\if@nobreak\else\par\penalty\z@\fi}
371 % Finally, don't make tables bigger in slides. It just looks weird.
374 \def\slidearraystretch{1}
377 % \subsection{Slide headings}
379 % \begin{macro}{\head}
381 % Very easy style hook, this.
384 \def\head#1{{\sffamily\bfseries\large #1}\par}
389 % \begin{macro}{\seq}
390 % \begin{macro}{\resetseq}
392 % Now for the sequence number stuff. Make a counter, write some macros.
396 \newcounter{sequence}
397 \def\thesequence{\arabic{sequence}}
398 \def\seq{\refstepcounter{sequence}\thesequence}
399 \def\resetseq{\setcounter{sequence}{0}}
405 % \subsection{Headings for notes}
411 % The basic layout is fairly simple. Put headings on the left and right
412 % pages, and page numbers at the bottom, on the outside.
416 \fancyhead[LE]{\textbf{\nouppercase{\leftmark}}}
417 \fancyhead[RO]{\textbf{\nouppercase{\rightmark}}}
418 \fancyfoot[LE, RO]{\thepage}
421 % No header rules, please.
424 \def\headrulewidth{\z@}
427 % Plain pages have no headers, but still the page number in the footer.
430 \fancypagestyle{plain}{\fancyhead{}}
433 % Set the section heading on left hand pages, and the subsection on the
434 % right. This is done here to prevent the capsification which \LaTeX\
435 % insists on doing by default.
438 \def\sectionmark#1{\markboth{\thesection.\ #1}{}}
439 \def\subsectionmark#1{\markright{\thesubsection.\ #1}}
442 % The |\emptyslide| command removes headings and so on from a slide. It does
443 % nothing in slides'n'notes mode.
446 \let\emptyslide\relax
449 % Similarly, topic declarations are ignored.
455 % Finally, switch to the fancy layout I've just defined.
461 % \subsection{Headings and summary pages for slides}
467 % The section and subsection marks put up `\syntax{<section> [--
468 % <subsection>]}' style stuff at the bottom of a slide.
471 \def\sectionmark#1{\markboth{#1}{}}
472 \def\subsectionmark#1{\markright{ -- #1}}
475 % \begin{macro}{\emptyslide}
477 % Empty slides. The |\emptyslide| command says that this slide should have
478 % no numbers or section information. It's used for the summary pages. We
479 % remember the number of the to-be-empty slide, so that continuation slides
480 % don't get clobbered too. If a slide isn't meant to be empty, typeset it
484 \newcount\@emptyslide
485 \newpagestyle{slide}%
486 {\ifnum\@emptyslide=\c@slide\else\textbf{\thetitle}\hfil\fi}%
487 {\ifnum\@emptyslide=\c@slide\else\leftmark\rightmark\hfil\theslide\fi}
488 \slidepagestyle{slide}
489 \def\emptyslide{\global\@emptyslide\c@slide}%
494 % \begin{macro}{\@sect}
495 % \begin{macro}{\@ssect}
497 % The basic section handling gets rewritten here. It now typesets nothing,
498 % but updates counters correctly (so that references are correct) and issues
499 % the marking and summary commands.
502 \def\@sect#1#2#3#4#5#6[#7]#8{%
503 \ifnum #2>\c@secnumdepth\else%
506 \csname #1mark\endcsname{#7}%
507 \csname #1summary\endcsname{#7}%
509 \def\@ssect#1#2#3#4#5{\relax}
515 % \begin{macro}{\sm@toks}
516 % \begin{macro}{\sm@count}
518 % Summary handling proper starts here. The |\sm@count| register remembers
519 % which summary page this is. The first one is numbered~1. The token
520 % register is used when building summary pages, later on.
530 % \begin{macro}{\sm@auxwrite}
532 % The sectioning commands write stuff to the |.aux| file. This is how they
533 % do it. The first argument is the type of entry this is; the second is the
534 % text. The |\sm@entry| macro sorts out what to do on the way back.
537 \def\sm@auxwrite#1#2{\immediate\write\@auxout
538 {\noexpand\sm@entry{\the\sm@count}{#1}{#2}}}
543 % \begin{macro}{\sectionsummary}
545 % A section summary entry. If there's a summary that's been constructed for
546 % this section, then do it; otherwise don't. Then write a section heading
550 \def\sectionsummary{%
551 \global\advance\sm@count\@ne%
552 \expandafter\let\expandafter\@next%
553 \csname sm@summary@\the\sm@count\endcsname%
554 \ifx\@next\relax\else\@next\sm@endsummary\fi%
555 \sm@auxwrite{section}%
561 % \begin{macro}{\subsectionsummary}
562 % \begin{macro}{\topic}
564 % The subsection and topic commands just write an entry to the |.aux| file.
566 \def\subsectionsummary{\sm@auxwrite{subsection}}
567 \def\topic{\sm@auxwrite{topic}}
573 % \begin{macro}{\sm@entry}
575 % This is where summary pages are actually constructed. If the requested
576 % summary entry doesn't exist, make it empty. Then attach a call to the
577 % appropriate summary-building command.
580 \def\sm@entry#1#2#3{%
582 \let\protect\@unexpandable@protect%
583 \expandafter\ifx\csname sm@summary@#1\endcsname\relax%
584 \expandafter\let\csname sm@summary@#1\endcsname\@empty%
586 \expandafter\xdef\csname sm@summary@#1\endcsname{%
587 \csname sm@summary@#1\endcsname%
588 \expandafter\protect\csname sm@do#2\endcsname{#3}%
596 % \begin{macro}{\sm@dosection}
598 % Build the beginning of a summary page. Start a new slide; make it empty;
599 % write a heading at the top; and start a list of things.
602 \def\sm@dosection#1{%
607 \centerline{\sffamily\bfseries\Large #1 -- overview}
615 % \begin{macro}{\sm@endsummary}
617 % Finish off a summary. This is called from |\sectionsummary|.
620 \def\sm@endsummary{\enditemize\endgroup\endslide\endgroup}
625 % \begin{macro}{\sm@dosubsection}
626 % \begin{macro}{\sm@dotopic}
628 % A subsection entry starts a new item; a topic entry augments the current
629 % item, using the |\if@tempswa| switch to decide on punctuation.
632 \def\sm@dosubsection#1{\item\relax\@tempswatrue#1}
633 \def\sm@dotopic#1{\if@tempswa:\@tempswafalse\else;\fi\space#1}
643 % And that's all there is.
649 % \hfill Mark Wooding, \today