Infra: Ignore boring files, and expunge old setup script.
[mdwslides] / mdwslides.dtx
CommitLineData
fb50dc45 1% \begin{meta-comment}
2%
3% $Id: mdwslides.dtx,v 1.1 2002/02/24 12:47:11 mdw Exp $
4%
5% Document class for slide sets
6%
7% (c) 2002 Mark Wooding
8%
9%----- Revision history -----------------------------------------------------
10%
11% $Log: mdwslides.dtx,v $
12% Revision 1.1 2002/02/24 12:47:11 mdw
13% Initial revision.
14%
15%
16% \end{meta-comment}
17%
18% \begin{meta-comment} <general public licence>
19%%
20%% mdwslides -- a document class for slide sets
21%% Copyright (c) 2002 Mark Wooding
22%%
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.
27%%
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.
32%%
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.
36%%
37% \end{meta-comment}
38%
39% \begin{meta-comment} <Package preamble>
40%<+mdwslides>\NeedsTeXFormat{LaTeX2e}
41%<+mdwslides>\ProvidesClass{mdwslides}
42%<+mdwslides> [2002/02/20 1.00 mdwslides]
43% \end{meta-comment}
44%
45% \CheckSum{479}
46%% \CharacterTable
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 \~}
61%%
62%
63% \begin{meta-comment} <driver>
64%
65%<*driver>
66\input{mdwtools}
67\title{The \package{mdwslides} document class}
68\mdwdoc
69%</driver>
70%
71% \end{meta-comment}
72%
73%^^A-------------------------------------------------------------------------
74% \section{User guide}
75%
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.
79%
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.
87%
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
92% \begin{quote}
93% \syntax{"\\xcalways"<anything>"\\x"}
94% \end{quote}
95% to have \synt{anything} recognized even in slides-only mode.
96%
97% \DescribeMacro\head
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.
101%
102% \DescribeMacro\resetseq
103% \DescribeMacro\seq
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
109% numbers.
110%
111%^^A-------------------------------------------------------------------------
112% \implementation
113% \section{Implementation}
114%
115% \subsection{Initial boilerplate}
116%
117% Pass options straight on. We don't have any of our own.
118%
119% \begin{macrocode}
120%<*mdwslides>
121\DeclareOption*{\PassOptionsToClass{\CurrentOption}{seminar}}
122\ProcessOptions
123\LoadClass{seminar}
124\RequirePackage{fancyhdr}
125% \end{macrocode}
126%
127% \subsection{Fixing some bugs}
128%
129% Cool as \package{seminar} undoubtedly is, it's also buggy. Here are some
130% fixes.
131%
132% \begin{macro}{\normalsize}
133%
134% Firstly, there's a very strange bug in the list formatting for notes. This
135% fixes it.
136%
137% \begin{macrocode}
138\def\@bugfix#1\let\@listi#2#3\@@%
139 {\def\normalsize{#1#3}}
140\expandafter\@bugfix\normalsize\@@
141% \end{macrocode}
142%
143% \end{macro}
144%
145% \begin{macro}{\slidebox@restore}
146%
147% Another list typesetting weirdness: too much top glue.
148%
149% \begin{macrocode}
150\toks@\expandafter{\slidebox@restore}
151\edef\slidebox@restore{\the\toks@\advance\topsep\parskip}
152% \end{macrocode}
153%
154% \end{macro}
155%
156% \begin{macro}{\outputloop@savedslides}
157% \begin{macro}{\output@savedslide}
158%
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.
161%
162% \begin{macrocode}
163\ifarticle
164 \def\@bugfix#1\penalty\z@#2\@@{\def\outputloop@savedslides{#1#2}}
165 \expandafter\@bugfix\outputloop@savedslides\@@
166 \toks@\expandafter{\output@savedslide}
167 \def\@strange@hack%
168 {\begingroup\output{\unvbox\@cclv}\penalty-\@M\endgroup}
169 \edef\output@savedslide{\noexpand\@strange@hack\the\toks@}
170\fi
171% \end{macrocode}
172%
173% \end{macro}
174% \end{macro}
175%
176% \begin{macro}{\@makeslide}
177%
178% Make sure that footnotes end up at the \emph{bottom} of a slide, rather
179% than just after the text.
180%
181% \begin{macrocode}
182\def\@makeslide{%
183 \setbox\@slidebox\vbox{%
184 \@begindvi % added 1997/04/15 SPQR
185 \unvbox\@cclv
186 \ifvoid\slide@footins\else
187 \vskip\skip\slide@footins
188 \vfil
189 \footnoterule
190 \unvbox\slide@footins
191 \unskip
192 \fi
193 \vskip\z@}}
194% \end{macrocode}
195%
196% \end{macro}
197%
198% \begin{macro}{\@makecol}
199%
200% And do the same thing for the main text.
201%
202% \begin{macrocode}
203\def\@makecol{%
204 \setbox\@outputbox \box\@cclv
205 \xdef\@freelist{\@freelist\@midlist}%
206 \global \let \@midlist \@empty
207 \@combinefloats
208 \ifvoid\footins \else
209 \setbox\@outputbox \vbox {%
210 \boxmaxdepth \@maxdepth
211 \unvbox \@outputbox
212 \vskip \skip\footins
213 \vfil
214 \footnoterule
215 \unvbox \footins
216 \unskip
217 }%
218 \fi
219 \ifvbox\@kludgeins
220 \@makespecialcolbox
221 \else
222 \setbox\@outputbox \vbox to\@colht {%
223 \@texttop
224 \dimen@ \dp\@outputbox
225 \unvbox \@outputbox
226 \vskip -\dimen@
227 \@textbottom
228 }%
229 \fi
230 \global \maxdepth \@maxdepth
231}
232% \end{macrocode}
233%
234% \end{macro}
235%
236% \subsection{Hacking \env{xcomment}}
237%
238% \begin{macro}{\xcalways}
239%
240% Unfortunately, this involves rewriting rather too much of the
241% \env{xcomment} code. Sigh.
242%
243% It also involves catcode fiddling. I need some code-12 versions of various
244% usually-magical characters. This is the traditional fiddling.
245%
246% \begin{macrocode}
247\begingroup
248\catcode`\!=12\catcode`\[=12\catcode`\]=12\catcode`\"=12
249\lccode`\!=`\\\lccode`\[=`\{\lccode`\]=`\}\lccode`\"=`\%
250\catcode`\~=\active\lccode`\~=`\^^M
251\lowercase{
252% \end{macrocode}
253%
254% This is the guts of the main \env{xcomment} loop.
255%
256% \begin{macrocode}
257 \gdef\xcomment@@@#1\@nil{%
258 \def\@tempa{#1}%
259 \ifx\@tempa\@empty
260 \let\next\xcomment@
261 \else
262 \def\next{\xcomment@@#1\@nil}%
263 \@testtrue
264 \xc@checkbegin#1\relax begin[]\relax\relax
265 \if@test
266 \xc@checkend#1\relax end[]\relax\relax
267 \if@test
268 \xc@checkinput#1\relax input[]\relax\relax
269 \if@test
270 \xc@checkinclude#1\relax include[]\relax\relax
271 \if@test
272 \xc@checkendinput#1\relax endinputss\relax\relax
273% \end{macrocode}
274%
275% Now, insert the new check for my macro.
276%
277% \begin{macrocode}
278 \if@test
279 \xc@checkalways#1\relax xcalwaysfoo!x\relax\relax
280% \end{macrocode}
281%
282% And finish off.
283%
284% \begin{macrocode}
285 \fi\fi\fi\fi\fi\fi
286 \next}
287% \end{macrocode}
288%
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.
292%
293% \begin{macrocode}
294 \gdef\xc@checkalways#1xcalways#2!x#3\relax#4\relax{%
295 \def\@tempa{#1}%
296 \ifx\@tempa\@empty%
297 \@testfalse%
298 \endgroup%
299 \toks@{#2}\rescan\toks@%
300 \def\next{\the\toks@\xc@always#3\@nil}%
301 \fi%
302 }
303% \end{macrocode}
304%
305% That's the end of the weird-catcode stuff.
306%
307% \begin{macrocode}
308}
309\endgroup
310% \end{macrocode}
311%
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.
314%
315% \begin{macrocode}
316\def\xc@always#1\@nil{\xc@begin#1}
317% \end{macrocode}
318%
319% And the version for slides'n'notes mode is trivial.
320%
321% \begin{macrocode}
322\def\xcalways#1\x{#1}
323% \end{macrocode}
324%
325% \end{macro}
326%
327% \subsection{Slide layout}
328%
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.
332%
333% \begin{macrocode}
334\slidewidth=260mm
335\slideheight=160mm
336% \end{macrocode}
337%
338% For notes, I like thin frames, uncentred, with slides just put wherever
339% they fit, dammit.
340%
341% \begin{macrocode}
342\slideplacement{here}
343\slideframewidth=1pt
344\centerslidesfalse
345% \end{macrocode}
346%
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
349% tight slides.
350%
351% \begin{macrocode}
352\def\slidefuzz{20pt}
353% \end{macrocode}
354%
355% Fiddle the margins around the actual slide content.
356%
357% \begin{macrocode}
358\def\slideleftmargin{15mm} \let\sliderightmargin=\slideleftmargin
359\def\slidetopmargin{15mm} \let\slidebottommargin=\slidetopmargin
360% \end{macrocode}
361%
362% Page tweaking for notes.
363%
364% \begin{macrocode}
365\ifarticle
366 \raggedbottom
367 \def\slide@clearpage{\if@nobreak\else\par\penalty\z@\fi}
368\fi
369% \end{macrocode}
370%
371% Finally, don't make tables bigger in slides. It just looks weird.
372%
373% \begin{macrocode}
374\def\slidearraystretch{1}
375% \end{macrocode}
376%
377% \subsection{Slide headings}
378%
379% \begin{macro}{\head}
380%
381% Very easy style hook, this.
382%
383% \begin{macrocode}
384\def\head#1{{\sffamily\bfseries\large #1}\par}
385% \end{macrocode}
386%
387% \end{macro}
388%
389% \begin{macro}{\seq}
390% \begin{macro}{\resetseq}
391%
392% Now for the sequence number stuff. Make a counter, write some macros.
393% Yawn.
394%
395% \begin{macrocode}
396\newcounter{sequence}
397\def\thesequence{\arabic{sequence}}
398\def\seq{\refstepcounter{sequence}\thesequence}
399\def\resetseq{\setcounter{sequence}{0}}
400% \end{macrocode}
401%
402% \end{macro}
403% \end{macro}
404%
405% \subsection{Headings for notes}
406%
407% \begin{macrocode}
408\ifarticle
409% \end{macrocode}
410%
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.
413%
414% \begin{macrocode}
415\fancyhf{}
416\fancyhead[LE]{\textbf{\nouppercase{\leftmark}}}
417\fancyhead[RO]{\textbf{\nouppercase{\rightmark}}}
418\fancyfoot[LE, RO]{\thepage}
419% \end{macrocode}
420%
421% No header rules, please.
422%
423% \begin{macrocode}
424\def\headrulewidth{\z@}
425% \end{macrocode}
426%
427% Plain pages have no headers, but still the page number in the footer.
428%
429% \begin{macrocode}
430\fancypagestyle{plain}{\fancyhead{}}
431% \end{macrocode}
432%
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.
436%
437% \begin{macrocode}
438\def\sectionmark#1{\markboth{\thesection.\ #1}{}}
439\def\subsectionmark#1{\markright{\thesubsection.\ #1}}
440% \end{macrocode}
441%
442% The |\emptyslide| command removes headings and so on from a slide. It does
443% nothing in slides'n'notes mode.
444%
445% \begin{macrocode}
446\let\emptyslide\relax
447% \end{macrocode}
448%
449% Similarly, topic declarations are ignored.
450%
451% \begin{macrocode}
452\let\topic\@gobble
453% \end{macrocode}
454%
455% Finally, switch to the fancy layout I've just defined.
456%
457% \begin{macrocode}
458\pagestyle{fancy}
459% \end{macrocode}
460%
461% \subsection{Headings and summary pages for slides}
462%
463% \begin{macrocode}
464\else
465% \end{macrocode}
466%
467% The section and subsection marks put up `\syntax{<section> [--
468% <subsection>]}' style stuff at the bottom of a slide.
469%
470% \begin{macrocode}
471\def\sectionmark#1{\markboth{#1}{}}
472\def\subsectionmark#1{\markright{ -- #1}}
473% \end{macrocode}
474%
475% \begin{macro}{\emptyslide}
476%
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
481% nicely.
482%
483% \begin{macrocode}
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}%
490% \end{macrocode}
491%
492% \end{macro}
493%
494% \begin{macro}{\@sect}
495% \begin{macro}{\@ssect}
496%
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.
500%
501% \begin{macrocode}
502\def\@sect#1#2#3#4#5#6[#7]#8{%
503 \ifnum #2>\c@secnumdepth\else%
504 \refstepcounter{#1}%
505 \fi%
506 \csname #1mark\endcsname{#7}%
507 \csname #1summary\endcsname{#7}%
508}
509\def\@ssect#1#2#3#4#5{\relax}
510% \end{macrocode}
511%
512% \end{macro}
513% \end{macro}
514%
515% \begin{macro}{\sm@toks}
516% \begin{macro}{\sm@count}
517%
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.
521%
522% \begin{macrocode}
523\newtoks\sm@toks
524\newcount\sm@count
525% \end{macrocode}
526%
527% \end{macro}
528% \end{macro}
529%
530% \begin{macro}{\sm@auxwrite}
531%
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.
535%
536% \begin{macrocode}
537\def\sm@auxwrite#1#2{\immediate\write\@auxout
538 {\noexpand\sm@entry{\the\sm@count}{#1}{#2}}}
539% \end{macrocode}
540%
541% \end{macro}
542%
543% \begin{macro}{\sectionsummary}
544%
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
547% entry.
548%
549% \begin{macrocode}
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}%
556}
557% \end{macrocode}
558%
559% \end{macro}
560%
561% \begin{macro}{\subsectionsummary}
562% \begin{macro}{\topic}
563%
564% The subsection and topic commands just write an entry to the |.aux| file.
565% \begin{macrocode}
566\def\subsectionsummary{\sm@auxwrite{subsection}}
567\def\topic{\sm@auxwrite{topic}}
568% \end{macrocode}
569%
570% \end{macro}
571% \end{macro}
572%
573% \begin{macro}{\sm@entry}
574%
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.
578%
579% \begin{macrocode}
580\def\sm@entry#1#2#3{%
581 \begingroup%
582 \let\protect\@unexpandable@protect%
583 \expandafter\ifx\csname sm@summary@#1\endcsname\relax%
584 \expandafter\let\csname sm@summary@#1\endcsname\@empty%
585 \fi%
586 \expandafter\xdef\csname sm@summary@#1\endcsname{%
587 \csname sm@summary@#1\endcsname%
588 \expandafter\protect\csname sm@do#2\endcsname{#3}%
589 }%
590 \endgroup%
591}
592% \end{macrocode}
593%
594% \end{macro}
595%
596% \begin{macro}{\sm@dosection}
597%
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.
600%
601% \begin{macrocode}
602\def\sm@dosection#1{%
603 \begingroup\slide%
604 \emptyslide%
605 \noindent\vadjust{}%
606 \vskip10\p@%
607 \centerline{\sffamily\bfseries\Large #1 -- overview}
608 \vskip10\p@%
609 \begingroup\itemize
610}
611% \end{macrocode}
612%
613% \end{macro}
614%
615% \begin{macro}{\sm@endsummary}
616%
617% Finish off a summary. This is called from |\sectionsummary|.
618%
619% \begin{macrocode}
620\def\sm@endsummary{\enditemize\endgroup\endslide\endgroup}
621% \end{macrocode}
622%
623% \end{macro}
624%
625% \begin{macro}{\sm@dosubsection}
626% \begin{macro}{\sm@dotopic}
627%
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.
630%
631% \begin{macrocode}
632\def\sm@dosubsection#1{\item\relax\@tempswatrue#1}
633\def\sm@dotopic#1{\if@tempswa:\@tempswafalse\else;\fi\space#1}
634% \end{macrocode}
635%
636% \end{macro}
637% \end{macro}
638%
639% \begin{macrocode}
640\fi
641% \end{macrocode}
642%
643% And that's all there is.
644%
645% \begin{macrocode}
646%</mdwslides>
647% \end{macrocode}
648%
649% \hfill Mark Wooding, \today
650%
651% \Finale
652\endinput