2ecc62a6f994e073db80843f63d9c664e8e7ce74
[doc/ips] / ips.cls
1 %%% -*-latex-*-
2 %%%
3 %%% Definitions for IPS course
4
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesClass{ips}[2001/10/02]
7
8 %%%----- Document class stuff -----------------------------------------------
9
10 \newif\ifipsslides \ipsslidesfalse
11 \newif\ifipsanswers \ipsanswerstrue
12 \InputIfFileExists{ips.cfg}\relax\relax
13
14 \ifipsslides
15 \PassOptionsToClass{a4, slidesonly}{seminar}
16 \else
17 \PassOptionsToClass{a4, article, twoside}{seminar}
18 \fi
19 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{seminar}}
20 \ProcessOptions
21 \LoadClass{seminar}
22
23 %%%----- Required packages --------------------------------------------------
24
25 \RequirePackage[palatino, helvetica, courier, maths=cmr]{mdwfonts}
26 \RequirePackage{fancyhdr}
27 \RequirePackage[T1]{fontenc}
28 \RequirePackage{mdwtab, mathenv, crypto, mdwthm, mdwmath}
29 \RequirePackage[within=section]{exercise}
30 \RequirePackage{amssymb}
31 \RequirePackage{url}
32
33 \ifx\pdfoutput\@@undefined
34 \PassOptionsToPackage{dvips}{xy}
35 \else
36 \ifarticle
37 \pdfpagewidth\paperwidth
38 \pdfpageheight\paperheight
39 \else
40 \pdfpagewidth\paperheight
41 \pdfpageheight\paperwidth
42 \fi
43 \fi
44 \RequirePackage[all]{xy}
45
46 %%%----- Miscellaneous settings ---------------------------------------------
47
48 \errorcontextlines=999
49
50 %%%----- Style choices ------------------------------------------------------
51
52 \renewcommand{\qedsymbol}{$\square$}
53 \def\hex#1{\texttt{0x#1}}
54 \let\emptystring\lambda
55 \let\epsilon\varepsilon
56 \let\phi\varphi
57 \let\emptyset\varnothing
58 \bibliographystyle{mdwalpha}
59 \sloppy
60
61 %%%----- Exercise typesetting -----------------------------------------------
62
63 \exctrcheck{section}{\answrite{\protect\subsection*{Section \thesection}}}
64
65 %%%----- Diagram typesetting ------------------------------------------------
66
67 \turnradius={4pt}
68
69 \def\ocat{
70 \setbox\z@\hbox{$\scriptstyle\|$}%
71 \dimen8\ht\z@\advance\dimen8\dp\z@%
72 \mathbin{\xy *=<\dimen8>[o][F]{\box\z@} \endxy}%
73 }
74
75 %%%------ Sectioning and headings -------------------------------------------
76
77 \ifarticle
78 \fancyhf{}
79 \fancyhead[LE]{\textbf{\nouppercase{\leftmark}}}
80 \fancyhead[RO]{\textbf{\nouppercase{\rightmark}}}
81 \fancyfoot[LE, RO]{\thepage}
82 \def\headrulewidth{\z@}
83 \fancypagestyle{plain}{\fancyhead{}}
84 \def\sectionmark#1{\markboth{\thesection.\ #1}{}}
85 \def\subsectionmark#1{\markright{\thesubsection.\ #1}}
86 \let\emptyslide\relax
87 \let\topic\@gobble
88 \pagestyle{fancy}
89 \else
90 \def\sectionmark#1{\markboth{#1}{}}
91 \def\subsectionmark#1{\markright{ -- #1}}
92 \newcount\@emptyslide
93 \newpagestyle{slide}%
94 {\ifnum\@emptyslide=\c@slide\else\textbf{\thetitle}\hfil\fi}%
95 {\ifnum\@emptyslide=\c@slide\else\leftmark\rightmark\hfil\theslide\fi}
96 \slidepagestyle{slide}
97 \def\emptyslide{\global\@emptyslide\c@slide}%
98 \def\@sect#1#2#3#4#5#6[#7]#8{%
99 \ifnum #2>\c@secnumdepth\else%
100 \refstepcounter{#1}%
101 \fi%
102 \csname #1mark\endcsname{#7}%
103 \csname #1summary\endcsname{#7}%
104 }
105 \def\@ssect#1#2#3#4#5{\relax}
106 \newtoks\sm@toks
107 \newcount\sm@count
108 \def\sm@auxwrite#1#2{\immediate\write\@auxout
109 {\noexpand\sm@entry{\the\sm@count}{#1}{#2}}}
110 \def\sectionsummary{%
111 \global\advance\sm@count\@ne%
112 \expandafter\let\expandafter\@next%
113 \csname sm@summary@\the\sm@count\endcsname%
114 \ifx\@next\relax\else\@next\sm@endsummary\fi%
115 \sm@auxwrite{section}%
116 }
117 \def\subsectionsummary{\sm@auxwrite{subsection}}
118 \def\sm@entry#1#2#3{%
119 \begingroup%
120 \let\protect\@unexpandable@protect%
121 \expandafter\ifx\csname sm@summary@#1\endcsname\relax%
122 \expandafter\let\csname sm@summary@#1\endcsname\@empty%
123 \fi%
124 \expandafter\xdef\csname sm@summary@#1\endcsname{%
125 \csname sm@summary@#1\endcsname%
126 \expandafter\protect\csname sm@do#2\endcsname{#3}%
127 }%
128 \endgroup%
129 }
130 \def\sm@dosection#1{%
131 \begingroup\slide%
132 \emptyslide%
133 \noindent\vadjust{}%
134 \vskip10\p@%
135 \centerline{\sffamily\bfseries\Large #1 -- overview}
136 \vskip10\p@%
137 \begingroup\itemize
138 }
139 \def\sm@endsummary{\enditemize\endgroup\endslide\endgroup}
140 \def\sm@dosubsection#1{\item\relax\@tempswatrue#1}
141 \def\sm@dotopic#1{\if@tempswa:\@tempswafalse\else;\fi\space#1}
142 \def\topic{\sm@auxwrite{topic}}
143 \fi
144
145 \def\head#1{{\sffamily\bfseries\large #1}\par}
146
147 %%%------ Page layout for notes ---------------------------------------------
148
149 \ifarticle
150 \raggedbottom
151 \def\slide@clearpage{\if@nobreak\else\par\penalty\z@\fi}
152 \fi
153
154 %%%----- Slide layout -------------------------------------------------------
155
156 \slidewidth=260mm
157 \slideheight=160mm
158
159 \slideplacement{here}
160 \slideframewidth=1pt
161 \centerslidesfalse
162
163 \def\slidefuzz{20pt}
164
165 \def\slideleftmargin{15mm} \let\sliderightmargin=\slideleftmargin
166 \def\slidetopmargin{15mm} \let\slidebottommargin=\slidetopmargin
167
168 \def\slidearraystretch{1}
169
170 %%%----- Hacking xcomment ---------------------------------------------------
171 %%%
172 %%% Supports \xcalways...\x which is an escape from the usual commenting.
173
174 \begingroup
175 \catcode`\!=12\catcode`\[=12\catcode`\]=12\catcode`\"=12
176 \lccode`\!=`\\\lccode`\[=`\{\lccode`\]=`\}\lccode`\"=`\%
177 \catcode`\~=\active\lccode`\~=`\^^M
178 \lowercase{
179 %%
180 %% Hack the main loop code
181 %%
182 \gdef\xcomment@@@#1\@nil{%
183 \def\@tempa{#1}%
184 \ifx\@tempa\@empty
185 \let\next\xcomment@
186 \else
187 \def\next{\xcomment@@#1\@nil}%
188 \@testtrue
189 \xc@checkbegin#1\relax begin[]\relax\relax
190 \if@test
191 \xc@checkend#1\relax end[]\relax\relax
192 \if@test
193 \xc@checkinput#1\relax input[]\relax\relax
194 \if@test
195 \xc@checkinclude#1\relax include[]\relax\relax
196 \if@test
197 \xc@checkendinput#1\relax endinputss\relax\relax
198 \if@test
199 \xc@checkalways#1\relax xcalwaysfoo!x\relax\relax
200 \fi\fi\fi\fi\fi\fi
201 \next}
202 %%
203 %% New command support
204 %%
205 \gdef\xc@checkalways#1xcalways#2!x#3\relax#4\relax{%
206 \def\@tempa{#1}%
207 \ifx\@tempa\@empty%
208 \@testfalse%
209 \endgroup%
210 \toks@{#2}\rescan\toks@%
211 \def\next{\the\toks@\xc@always#3\@nil}%
212 \fi%
213 }
214 }
215 \endgroup
216
217 \def\xc@always#1\@nil{\xc@begin#1}
218 \def\xcalways#1\x{#1}
219
220 %%%----- Bugfix -------------------------------------------------------------
221
222 \def\@bugfix#1\let\@listi#2#3\@@%
223 {\def\normalsize{#1#3}}
224 \expandafter\@bugfix\normalsize\@@
225
226 \toks@\expandafter{\slidebox@restore}
227 \edef\slidebox@restore{\the\toks@\advance\topsep\parskip}
228
229 \ifarticle
230 \def\@bugfix#1\penalty\z@#2\@@{\def\outputloop@savedslides{#1#2}}
231 \expandafter\@bugfix\outputloop@savedslides\@@
232 \toks@\expandafter{\output@savedslide}
233 \def\@strange@hack{\begingroup\output{\unvbox\@cclv}\penalty-\@M\endgroup}
234 \edef\output@savedslide{\noexpand\@strange@hack\the\toks@}
235 \fi
236
237 \def\@makeslide{%
238 \setbox\@slidebox\vbox{%
239 \@begindvi % added 1997/04/15 SPQR
240 \unvbox\@cclv
241 \ifvoid\slide@footins\else
242 \vskip\skip\slide@footins
243 \vfil
244 \footnoterule
245 \unvbox\slide@footins
246 \unskip
247 \fi
248 \vskip\z@}}
249
250 \def\@makecol{%
251 \setbox\@outputbox \box\@cclv
252 \xdef\@freelist{\@freelist\@midlist}%
253 \global \let \@midlist \@empty
254 \@combinefloats
255 \ifvoid\footins \else
256 \setbox\@outputbox \vbox {%
257 \boxmaxdepth \@maxdepth
258 \unvbox \@outputbox
259 \vskip \skip\footins
260 \vfil
261 \footnoterule
262 \unvbox \footins
263 \unskip
264 }%
265 \fi
266 \ifvbox\@kludgeins
267 \@makespecialcolbox
268 \else
269 \setbox\@outputbox \vbox to\@colht {%
270 \@texttop
271 \dimen@ \dp\@outputbox
272 \unvbox \@outputbox
273 \vskip -\dimen@
274 \@textbottom
275 }%
276 \fi
277 \global \maxdepth \@maxdepth
278 }
279
280 %%%----- That's all, folks --------------------------------------------------
281
282 \endinput