chiark / gitweb /
strayman: Fix \topsep for sublists.
[strayman] / strayman.dtx
1 % \begin{meta-comment}
2 %
3 % $Id: strayman.dtx,v 1.4 2003/11/07 11:32:53 mdw Exp $
4 %
5 % Document class for Straylight manuals
6 %
7 % (c) 1996 Straylight
8 %
9 % \end{meta-comment}
10 %
11 % \begin{meta-comment} <general public licence>
12 %%
13 %% strayman -- a LaTeX document class for Straylight manuals
14 %% Copyright (c) 1996 Straylight
15 %%
16 %% This program is free software; you can redistribute it and/or modify
17 %% it under the terms of the GNU General Public License as published by
18 %% the Free Software Foundation; either version 2 of the License, or
19 %% (at your option) any later version.
20 %%
21 %% This program is distributed in the hope that it will be useful,
22 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
23 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 %% GNU General Public License for more details.
25 %%
26 %% You should have received a copy of the GNU General Public License
27 %% along with this program; if not, write to the Free Software
28 %% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 %%
30 % \end{meta-comment}
31 %
32 % \begin{meta-comment} <Package preamble>
33 %<+strayman>\NeedsTeXFormat{LaTeX2e}
34 %<+strayman>\ProvidesClass{strayman}
35 %<+strayman>              [2003/09/04 1.10 Straylight document class]
36 % \end{meta-comment}
37 %
38 % \CheckSum{3044}
39 %% \CharacterTable
40 %%  {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
41 %%   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
42 %%   Digits        \0\1\2\3\4\5\6\7\8\9
43 %%   Exclamation   \!     Double quote  \"     Hash (number) \#
44 %%   Dollar        \$     Percent       \%     Ampersand     \&
45 %%   Acute accent  \'     Left paren    \(     Right paren   \)
46 %%   Asterisk      \*     Plus          \+     Comma         \,
47 %%   Minus         \-     Point         \.     Solidus       \/
48 %%   Colon         \:     Semicolon     \;     Less than     \<
49 %%   Equals        \=     Greater than  \>     Question mark \?
50 %%   Commercial at \@     Left bracket  \[     Backslash     \\
51 %%   Right bracket \]     Circumflex    \^     Underscore    \_
52 %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
53 %%   Right brace   \}     Tilde         \~}
54 %%
55 %
56 % \begin{meta-comment} <driver>
57 %
58 %<*driver>
59 \documentclass[10pt,a4paper,book]{strayman}
60 \input{mdwtools}
61 \usepackage{mdwlist}
62 \describesclass{strayman}
63 \errorcontextlines\maxdimen
64 \title[The \strayman\ document class]
65       {The \strayman\footnote{The \strayman\ document class is currently %
66        at version \mdwfileinfo{strayman.cls}{version}, dated %
67        \mdwfileinfo{strayman.cls}{date}.} {} document class}
68 \newenvironment{syndisplay}{\display\synshorts}{\enddisplay}
69 \DeclareRobustCommand\strayman{\package{strayman}}
70 \mdwdoc
71 %</driver>
72 %
73 % \end{meta-comment}
74 %
75 % \chapter{About the \strayman\ document class}
76 %
77 % The standard \LaTeX\ document classes are all very well for simple
78 % documents, but the style isn't appropriate for works like manuals.
79 % The \strayman\ document class is an attempt to rectify this situation,
80 % providing an attractive and distinctive style for Straylight documents.
81 % The layout is based on an earlier style built for \emph{Impression}
82 % documents, although many improvements have been made.  This document
83 % was typeset using \strayman, and it demonstrates the design far better
84 % than I can describe it.
85 %
86 %
87 % \section{Document class options}
88 %
89 % The document class provides many options, most of which are taken from
90 % the standard \LaTeX\ classes.
91 %
92 % \begin{description}
93 % \def\|{\ensuremath\vert}
94 %
95 % \item [\texttt{a4paper} \| \texttt{a5paper} \| \texttt{b5paper} \|
96 %       \texttt{letterpaper} \| \texttt{legalpaper} \|
97 %       \texttt{executivepaper}]  Select the output paper size.  Since
98 %       \strayman\ is intended to be used mainly for manuals, the default
99 %       size is |a5paper|.
100 %
101 % \item [\texttt{landscape}]  Swaps the width and height of the paper.
102 %       Probably not much use, to be honest.
103 %
104 % \item [\texttt{9pt} \| \texttt{10pt} \| \texttt{11pt} \| \texttt{12pt}]
105 %       Selects the basic type size for the document.  The |9pt| option is
106 %       nonstandard, but it is the default, since larger sizes don't work
107 %       well on A5~paper.
108 %
109 % \item [\texttt{text}]  Sets up the page layout and fonts so that the
110 %       output can be converted fairly easily into a raw text file.
111 %
112 % \item [\texttt{oneside} \| \texttt{twoside}]  Selects one- or two-sided
113 %       page layouts.  Note that one-sided output doesn't look too good.
114 %
115 % \item [\texttt{draft} \| \texttt{final}]  Select various options for draft
116 %       or final copy.
117 %
118 % \item [\texttt{titlepage} \| \texttt{notitlepage}]  Selects whether
119 %       the |\maketitle| displays its output on a separate title page.
120 %
121 % \item [\texttt{openright} \| \texttt{openany}]  Select whether chapters
122 %       start only on quarto pages, or any page.  The default is |openright|.
123 %
124 % \item [\texttt{onecolumn} \| \texttt{twocolumn}]  Choose whether the
125 %       main body text is set in one or two columns.  Note that this uses
126 %       \LaTeX's built-in column handling, not the \package{multicol}
127 %       package.
128 %
129 % \item [\texttt{leqno}]  Put the equation numbers on the left, not the
130 %       right.
131 %
132 % \item [\texttt{fleqn}]  Typeset displayed equations left aligned.
133 %
134 % \item [\texttt{openbib}]  Use the `open' style for the bibliography.
135 %
136 % \item [\texttt{article}]  Change the formatting slightly, in a way more
137 %       suited to short documents.
138 %
139 % \item [\texttt{square} \| \texttt{rounded}]  These options are passed
140 %       directly to the \package{syntax} package, when it's loaded.
141 %
142 % \end{description}
143 %
144 %
145 % \section{The \texttt{text} option}
146 %
147 % In order to facilitate creation of attractively formatted text files
148 % from \LaTeX\ documents, \strayman\ provides a |text| option.  This will
149 % set up \emph{all} the fonts to be monospaced, in the same size.  The page
150 % size is set up to be a multiple of the character size.  The command
151 % \begin{syndisplay}
152 % "dvi2tty -e-17" <filename>
153 % \end{syndisplay}
154 % appears to produce a reasonable output from a DVI file created in this
155 % way.  The output will need to be formatted and corrected slightly by hand
156 % although there's a good deal less work to do than might be required
157 % otherwise.
158 %
159 %
160 % \section{That's it}
161 %
162 % That's all I'm writing for now.  It's a document class.  It defines the
163 % style.  What more do you expect?
164 %
165 %
166 % \implementation
167 %
168 % \chapter{Implementation}
169 %
170 % \section{Options handling}
171 %
172 % From here on, a lot of the code is shamelessly borrowed from
173 % \file{book.cls} and other places.  This is what code re-use is for.
174 %
175 % This bit handles all the options on the |\documentclass| command, either
176 % altering our own internal arguments, or loading other packages as
177 % appropriate.
178 %
179 % \subsection{Set up some defaults}
180 %
181 % We create some variables to hold the settings, and initialise them to
182 % sensible values.
183 %
184 %    \begin{macrocode}
185 %<*strayman>
186 \newcommand\@ptsize{}
187 \newif\if@restonecol\@restonecolfalse
188 \newif\if@titlepage\@titlepagefalse
189 \newif\if@openright\@openrighttrue
190 \newif\if@openbib\@openbibfalse
191 \newif\if@appendix\@appendixfalse
192 \newif\if@article\@articletrue
193 \newif\if@offsetpages\@offsetpagestrue
194 \newif\if@numbering\@numberingtrue
195 \newif\if@herefloats\@herefloatsfalse
196 \newif\if@runinsubsubsec\@runinsubsubsectrue
197 \newif\if@indentpar
198 \newdimen\pagesurround
199 \let\headfam\rmfamily
200 \let\pad@margin\@empty
201 \def\@delayed{}
202 \def\@delaycode#1{%
203   \expandafter\def\expandafter\@delayed\expandafter{\@delayed#1}%
204 }
205 %    \end{macrocode}
206 %
207 % \subsection{Declare the options we support}
208 %
209 % This is just a tedious list of all the options.
210 %
211 %    \begin{macrocode}
212 \DeclareOption{a4paper}{%
213   \paperheight297mm%
214   \paperwidth210mm%
215   \pagesurround1in%
216 }
217 \DeclareOption{a5paper}{%
218   \paperheight210mm%
219   \paperwidth148mm%
220   \pagesurround12mm%
221 }
222 \DeclareOption{b5paper}{%
223   \paperheight250mm%
224   \paperwidth176mm%
225   \pagesurround1in%
226 }
227 \DeclareOption{letterpaper}{%
228   \paperheight11in%
229   \paperwidth8.5in%
230   \pagesurround1in%
231 }
232 \DeclareOption{legalpaper}{%
233   \paperheight14in%
234   \paperwidth8.5in%
235   \pagesurround1in%
236 }
237 \DeclareOption{executivepaper}{%
238   \paperheight10.5in%
239   \paperwidth7.25in%
240   \pagesurround1in%
241 }
242 \DeclareOption{landscape}{%
243   \@tempdima\paperheight%
244   \paperheight\paperwidth%
245   \paperwidth\@tempdima%
246 }
247 \DeclareOption{8pt}{\renewcommand\@ptsize{8pt}}
248 \DeclareOption{9pt}{\renewcommand\@ptsize{9pt}}
249 \DeclareOption{10pt}{\renewcommand\@ptsize{10pt}}
250 \DeclareOption{11pt}{\renewcommand\@ptsize{11pt}}
251 \DeclareOption{12pt}{\renewcommand\@ptsize{12pt}}
252 \DeclareOption{text}{%
253   \renewcommand\@ptsize{text}%
254   \setbox\z@\hbox{\texttt{M\strut}}%
255   \newdimen\tt@chw\tt@chw\wd\z@%
256   \newdimen\tt@chh\tt@chh\ht\z@\advance\tt@chh\dp\z@%
257   \paperwidth77\tt@chw%
258   \paperheight60\tt@chh%
259   \raggedright%
260   \def\pad@margin{.}
261 }
262 \DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
263 \DeclareOption{twoside}{\@twosidetrue  \@mparswitchfalse \reversemarginpar}
264 \DeclareOption{draft}{\overfullrule5\p@}
265 \DeclareOption{final}{\overfullrule\z@}
266 \DeclareOption{titlepage}{\@titlepagetrue}
267 \DeclareOption{notitlepage}{\@titlepagefalse}
268 \DeclareOption{openright}{\@openrighttrue}
269 \DeclareOption{openany}{\@openrightfalse}
270 \DeclareOption{onecolumn}{\@twocolumnfalse}
271 \DeclareOption{twocolumn}{\@twocolumntrue}
272 \DeclareOption{offsetpages}{\@offsetpagestrue}
273 \DeclareOption{nooffsetpages}{\@offsetpagesfalse}
274 \DeclareOption{herefloats}{\@herefloatstrue}
275 \DeclareOption{noherefloats}{\@herefloatsfalse}
276 \DeclareOption{leqno}{\input{leqno.clo}}
277 \DeclareOption{fleqn}{\input{fleqn.clo}}
278 \DeclareOption{openbib}{\@openbibtrue}
279 \DeclareOption{article}{\@articletrue}
280 \DeclareOption{noarticle}{\@articlefalse}
281 \DeclareOption{numbering}{\@numberingtrue}
282 \DeclareOption{nonumbering}{\@numberingfalse}
283 \DeclareOption{runinsubsubsec}{\@runinsubsubsectrue}
284 \DeclareOption{noruninsubsubsec}{\@runinsubsubsecfalse}
285 \DeclareOption{indentpar}{\@indentpartrue}
286 \DeclareOption{noindentpar}{\@indentparfalse}
287 \DeclareOption{book}{\@titlepagetrue\@articlefalse}
288 %    \end{macrocode}
289 %
290 % \subsection{Set up the options}
291 %
292 % We set up some default options, and then read the user's.
293 %
294 %    \begin{macrocode}
295 \ExecuteOptions{a4paper,10pt,twoside,onecolumn,final}
296 \ProcessOptions
297 %    \end{macrocode}
298 %
299 % If this is PDF\TeX\ then tell it the page bounds.
300 %
301 %    \begin{macrocode}
302 \newif\ifpdfing\pdfingfalse
303 \if1\ifx\pdfoutput\@@undefined@@0\else\the\pdfoutput\fi
304   \pdfingtrue
305 \fi
306 \ifpdfing
307   \pdfpageheight\paperheight
308   \pdfpagewidth\paperwidth
309   \AtEndOfClass{%
310     \RequirePackage[%
311       pdftex, bookmarks = true, bookmarksnumbered = true, bookmarksdepth = 3,
312       colorlinks = true, linkcolor = blue, breaklinks = true]{hyperref}
313   }
314 \fi
315 %    \end{macrocode}
316 %
317 % \subsection{Read in the text size option}
318 %
319 % The text sizing is rather messy.  We store this in a separate file.  To
320 % keep this stuff away from other classes, we use the file \emph{extension}
321 % as the size specifier, rather than the filename, which is the normal
322 % \LaTeX\ way of doing this.  This is a \riscos\ thing mainly: I don't like
323 % loads of directories cluttering up my disk, and it means that I can move
324 % the whole of the \strayman\ stuff around as one directory.
325 %
326 %    \begin{macrocode}
327 \input{strayman.\@ptsize}
328 %</strayman>
329 %    \end{macrocode}
330 %
331 % \section{Package loading}
332 %
333 %    \begin{macrocode}
334 %<*strayman>
335 \RequirePackage{fancyhdr}
336 \RequirePackage{multicol}
337 \@delayed
338 %</strayman>
339 %    \end{macrocode}
340 %
341 % \section{Page layout}
342 %
343 % This is largely the domain of the size option files.
344 %
345 %    \begin{macrocode}
346 %<*8pt|9pt|10pt|11pt|12pt|text>
347 %<+8pt>\ProvidesFile{strayman.8pt}
348 %<+9pt>\ProvidesFile{strayman.9pt}
349 %<+10pt>\ProvidesFile{strayman.10pt}
350 %<+11pt>\ProvidesFile{strayman.11pt}
351 %<+12pt>\ProvidesFile{strayman.12pt}
352 %<+text>\ProvidesFile{strayman.text}
353 %    \end{macrocode}
354 %
355 % \subsection{Font sizes}
356 %
357 % These are fairly standard, and mainly copied from the original size
358 % options.
359 %
360 % \begin{macro}{\@setparskip}
361 %
362 % Because we separate paragraphs by vertical space, we need to vary this
363 % gap when we change font size.  This macro does the job.
364 %
365 %    \begin{macrocode}
366 \newskip\@parskip
367 \newdimen\@parshortfall
368 \def\@setparskip{%
369   \@parskip.67\baselineskip\@plus\p@\relax%
370   \ifdim\parskip=\z@\else\parskip\@parskip\relax\fi%
371   \@parshortfall\@parskip\advance\@parshortfall-\parskip%
372 }
373 \def\set@vsep#1{#1\@parshortfall\advance#1}
374 %    \end{macrocode}
375 % \end{macro}
376 %
377 % \begin{macro}{\normalsize}
378 %
379 % Defines the standard size of text in the document.
380 %
381 %    \begin{macrocode}
382 \renewcommand\normalsize{%
383 %<*8pt>
384   \@setfontsize\normalsize\@viiipt{9.6\p@}%
385   \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
386   \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
387   \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
388 %</8pt>
389 %<*9pt>
390   \@setfontsize\normalsize\@ixpt\@xipt%
391   \abovedisplayskip9\p@\@plus2\p@\@minus5\p@%
392   \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
393   \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
394 %</9pt>
395 %<*10pt>
396   \@setfontsize\normalsize\@xpt\@xiipt%
397   \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
398   \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
399   \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
400 %</10pt>
401 %<*11pt>
402   \@setfontsize\normalsize\@xipt{13.6}%
403   \abovedisplayskip11\p@\@plus3\p@\@minus6\p@%
404   \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
405   \set@vsep\belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
406 %</11pt>
407 %<*12pt>
408   \@setfontsize\normalsize\@xiipt{14.5}%
409   \abovedisplayskip12\p@\@plus3\p@\@minus7\p@%
410   \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
411   \set@vsep\belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
412 %</12pt>
413 %<*text>
414   \@setfontsize\normalsize\@xpt\@xiipt%
415   \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
416   \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
417   \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
418 %</text>
419   \belowdisplayskip\abovedisplayskip%
420   \let\@listi\@listI%
421   \@setparskip%
422 }
423 \normalsize
424 \if@indentpar
425   \parskip0pt\@plus\p@
426 \else
427   \parskip2ex\@plus\p@
428 \fi
429 %    \end{macrocode}
430 % \end{macro}
431 %
432 % \begin{macro}{\small}
433 %
434 % The |\small| size is defined with similar care to |\normalsize|.  The
435 % list defaults are altered to cope with our different value for |\parskip|.
436 % We can then separate this out independently from the typesize.
437 %
438 %    \begin{macrocode}
439 %<+text>\let\small\normalsize
440 %<*8pt|9pt|10pt|11pt|12pt>
441 \newcommand\small{%
442 %<*8pt>
443   \@setfontsize\small\@viipt{8.4}%
444   \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
445   \set@vsep\abovedisplayshortskip\z@\@plus2\p@%
446   \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
447 %</8pt>
448 %<*9pt>
449   \@setfontsize\small\@viiipt{9.5}%
450   \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
451   \set@vsep\abovedisplayshortskip\z@\@plus2\p@%
452   \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
453 %</9pt>
454 %<*10pt>
455   \@setfontsize\small\@ixpt{11}%
456   \abovedisplayskip8.5\p@\@plus3\p@\@minus4\p@%
457   \set@vsep\abovedisplayshortskip\z@\@plus2\p@%
458   \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
459 %</10pt>
460 %<*11pt>
461   \@setfontsize\small\@xpt\@xiipt%
462   \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
463   \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
464   \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
465 %</11pt>
466 %<*12pt>
467   \@setfontsize\small\@xipt{13.6}%
468   \abovedisplayskip11\p@\@plus3\p@\@minus6\p@%
469   \set@vsep\abovedisplayshortskip\z@ \@plus3\p@%
470   \set@vsep\belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
471 %</12pt>
472   \def\@listi{%
473     \leftmargin\leftmargini%
474     \topsep\@parshortfall%
475     \parsep\@parskip%
476     \itemsep\z@%
477   }%
478   \belowdisplayskip\abovedisplayskip%
479   \@setparskip%
480 }
481 %</8pt|9pt|10pt|11pt|12pt>
482 %    \end{macrocode}
483 % \end{macro}
484 %
485 % \begin{macro}{\footnotesize}
486 %
487 % This is also defined with the meticulous care of |\normalsize|, and
488 % altered in the same way as for |\small|.
489 %
490 %    \begin{macrocode}
491 %<+text>\let\footnotesize\normalsize
492 %<*8pt|9pt|10pt|11pt|12pt>
493 \newcommand\footnotesize{%
494 %<*8pt>
495   \@setfontsize\footnotesize\@vipt\@viipt%
496   \set@vsep\abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
497   \set@vsep\abovedisplayshortskip\z@\@plus\p@%
498   \set@vsep\belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
499 %</8pt>
500 %<*9pt>
501   \@setfontsize\footnotesize\@viipt{8.4}%
502   \set@vsep\abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
503   \set@vsep\abovedisplayshortskip\z@\@plus\p@%
504   \set@vsep\belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
505 %</9pt>
506 %<*10pt>
507   \@setfontsize\footnotesize\@viiipt{9.5}%
508   \set@vsep\abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
509   \set@vsep\abovedisplayshortskip\z@\@plus\p@%
510   \set@vsep\belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
511 %</10pt>
512 %<*11pt>
513   \@setfontsize\footnotesize\@ixpt{11}%
514   \set@vsep\abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
515   \set@vsep\abovedisplayshortskip\z@\@plus\p@%
516   \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
517 %</11pt>
518 %<*12pt>
519   \@setfontsize\footnotesize\@xpt\@xiipt
520   \set@vsep\abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
521   \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
522   \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
523 %</12pt>
524   \def\@listi{%
525     \leftmargin\leftmargini%
526     \topsep\@parshortfall%
527     \parsep\@parskip%
528     \itemsep\z@%
529   }%
530   \belowdisplayskip\abovedisplayskip%
531   \@setparskip%
532 }
533 %</8pt|9pt|10pt|11pt|12pt>
534 %    \end{macrocode}
535 % \end{macro}
536 %
537 % The other sizes are all much simpler.  We introduce a new size,
538 % |\listingsize|, which is used for the \env{listing} environment, to ensure
539 % that 77 columns of text fit across an A5 sheet.
540 %
541 %    \begin{macrocode}
542 %<*8pt>
543 \newcommand\scriptsize{\@setfontsize\scriptsize\@vpt\@vipt\@setparskip}
544 \newcommand\tiny{\@setfontsize\tiny{4}\@vpt\@setparskip}
545 \newcommand\large{\@setfontsize\large\@xpt\@xiipt\@setparskip}
546 \newcommand\Large{\@setfontsize\Large\@xipt{13}\@setparskip}
547 \newcommand\LARGE{\@setfontsize\LARGE\@xiipt\@xivpt\@setparskip}
548 \newcommand\huge{\@setfontsize\huge\@xviipt{20}\@setparskip}
549 \newcommand\Huge{\@setfontsize\Huge\@xxpt{26}\@setparskip}
550 %</8pt>
551 %<*9pt>
552 \newcommand\scriptsize{\@setfontsize\scriptsize\@vipt\@viipt\@setparskip}
553 \newcommand\tiny{\@setfontsize\tiny\@vpt\@vipt\@setparskip}
554 \newcommand\large{\@setfontsize\large\@xipt{13}\@setparskip}
555 \newcommand\Large{\@setfontsize\Large\@xiipt{14.4}\@setparskip}
556 \newcommand\LARGE{\@setfontsize\LARGE\@xivpt{17}\@setparskip}
557 \newcommand\huge{\@setfontsize\huge\@xviipt{20}\@setparskip}
558 \newcommand\Huge{\@setfontsize\Huge\@xxpt{26}\@setparskip}
559 %</9pt>
560 %<*10pt>
561 \newcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt\@setparskip}
562 \newcommand\tiny{\@setfontsize\tiny\@vpt\@vipt\@setparskip}
563 \newcommand\large{\@setfontsize\large\@xiipt{14}\@setparskip}
564 \newcommand\Large{\@setfontsize\Large\@xivpt{18}\@setparskip}
565 \newcommand\LARGE{\@setfontsize\LARGE\@xviipt{22}\@setparskip}
566 \newcommand\huge{\@setfontsize\huge\@xxpt{25}\@setparskip}
567 \newcommand\Huge{\@setfontsize\Huge\@xxvpt{30}\@setparskip}
568 %</10pt>
569 %<*11pt>
570 \newcommand\scriptsize{\@setfontsize\scriptsize\@viiipt{9.5}\@setparskip}
571 \newcommand\tiny{\@setfontsize\tiny\@vipt\@viipt\@setparskip}
572 \newcommand\large{\@setfontsize\large\@xiipt{14}\@setparskip}
573 \newcommand\Large{\@setfontsize\Large\@xivpt{18}\@setparskip}
574 \newcommand\LARGE{\@setfontsize\LARGE\@xviipt{22}\@setparskip}
575 \newcommand\huge{\@setfontsize\huge\@xxpt{25}\@setparskip}
576 \newcommand\Huge{\@setfontsize\Huge\@xxvpt{30}\@setparskip}
577 %</11pt>
578 %<*12pt>
579 \newcommand\scriptsize{\@setfontsize\scriptsize\@viiipt{9.5}\@setparskip}
580 \newcommand\tiny{\@setfontsize\tiny\@vipt\@viipt\@setparskip}
581 \newcommand\large{\@setfontsize\large\@xivpt{18}\@setparskip}
582 \newcommand\Large{\@setfontsize\Large\@xviipt{22}\@setparskip}
583 \newcommand\LARGE{\@setfontsize\LARGE\@xxpt{25}\@setparskip}
584 \newcommand\huge{\@setfontsize\huge\@xxvpt{30}\@setparskip}
585 \let\Huge\huge
586 %</12pt>
587 %<+8pt|9pt|10pt|11pt|12pt>\let\listingsize\footnotesize
588 %<*text>
589 \def\scriptsize{\@setfontsize\scriptsize\@xpt\@xiipt\@setparskip}
590 \let\tiny\scriptsize
591 \let\large\scriptsize
592 \let\Large\scriptsize
593 \let\LARGE\scriptsize
594 \let\huge\scriptsize
595 \let\Huge\scriptsize
596 \let\listingsize\scriptsize
597 %
598 \let\txt@selectfont\selectfont
599 \def\selectfont{%
600   \fontfamily\ttdefault%
601   \fontseries{m}%
602   \fontshape{n}%
603   \txt@selectfont%
604 }
605 %</text>
606 %</8pt|9pt|10pt|11pt|12pt|text>
607 %    \end{macrocode}
608 %
609 % \subsection{Paragraph layout}
610 %
611 % Here we define various paragraph layout parameters.
612 %
613 % First, set up the line separation parameters.  |\baselineskip| is set
614 % up by the individual size commands.
615 %
616 %    \begin{macrocode}
617 %<*strayman>
618 \lineskip\p@
619 \normallineskip\p@
620 %    \end{macrocode}
621 %
622 % We don't try to stretch the baselines apart:
623 %
624 %    \begin{macrocode}
625 \renewcommand\baselinestretch{}
626 %    \end{macrocode}
627 %
628 % Paragraph indentation is set up later.
629 %
630 % Set up some standard penalty values.
631 %
632 %    \begin{macrocode}
633 \@lowpenalty   51
634 \@medpenalty  151
635 \@highpenalty 301
636 %</strayman>
637 %    \end{macrocode}
638 %
639 % \subsection{Page layout}
640 %
641 % Our layout is a bit different to the standard \LaTeX\ ones: we leave a lot
642 % of space down the left hand side: this is reserved for headings and
643 % marginal notes.
644 %
645 % Calculating the size of the space on the left, which we call |\leftindent|,
646 % is complicated.  We want to use as much of the width of the page as
647 % possible, unlike the \LaTeX\ defaults, making sure that we can fit on
648 % 77 columns of |\listingsize\tt| text.  We also try to make space for a
649 % reasonable amount of marginal text, although we don't worry too much if
650 % that suffers.
651 %
652 % The calculation is done as follows.  More than about 40\,mm of margin will
653 % look very strange.  We must have at least 104\,mm of main text, which
654 % leaves 20\,mm for the notes on A5 paper (actually, 17\,mm, since we leave
655 % 3\,mm gap between the notes and the main text).  We divide the page
656 % horizontally into $s$\,mm of left border, $m$\,mm of marginal notes,
657 % $t$\,mm of body text, and another $s$\,mm of right border, giving
658 % a total of $w$\,mm.  The value $s$ is given to us by the parameter
659 % |\pagesurround|.
660 %
661 % Articles look odd with a big gap down the side, so this is reduced when
662 % necessary.
663 %
664 % We calculate the quantity~$m$ as $\min\bigl(40,17(w-2s-3)/121+3\bigr)$\@.
665 % Then we calculate $t=w-m-24-3$.
666 %
667 %    \begin{macrocode}
668 %<*8pt|9pt|10pt|11pt|12pt|text>
669 \newdimen\leftindent
670 %<*8pt|9pt|10pt|11pt|12pt>
671 \leftindent\paperwidth
672 \if@offsetpages
673   \advance\leftindent-2\pagesurround
674   \advance\leftindent-3mm
675   \leftindent0.1405\leftindent
676   \advance\leftindent3mm
677   \ifdim\leftindent>40mm\relax
678     \leftindent40mm
679   \fi
680   \if@article\divide\leftindent\tw@\fi
681   \ifdim\leftindent<15mm\leftindent15mm\fi
682 \else
683   \leftindent\z@
684 \fi
685 %</8pt|9pt|10pt|11pt|12pt>
686 %<+text>\leftindent8\tt@chw
687 %    \end{macrocode}
688 %
689 % In two-column layouts, we prevent headings from being outdented, by
690 % zeroing |\sectindent|.  Chapter headings and suchlike are still outdented
691 % as before.  We do not support margin paragraphs in two-column layouts.
692 %
693 %    \begin{macrocode}
694 \newdimen\sectindent
695 \if@twocolumn
696   \sectindent\z@
697 \else
698   \sectindent\if@numbering\z@\else\if@article\else\tw@\fi\leftindent\fi
699 \fi
700 %    \end{macrocode}
701 %
702 % Having set up the size of the margin, we can get on with the rest of the
703 % setting up.
704 %
705 % First, we fix |\hoffset| and |\voffset| so we can work on the whole size
706 % of the paper.
707 %
708 %    \begin{macrocode}
709 \advance\hoffset-1in
710 \advance\voffset-1in
711 %    \end{macrocode}
712 %
713 % Now we can design the page layout in earnest.  We begin with the vertical
714 % layout.
715 %
716 %    \begin{macrocode}
717 %<+8pt>\topskip8\p@
718 %<+9pt>\topskip9\p@
719 %<+10pt>\topskip10\p@
720 %<+11pt>\topskip11\p@
721 %<+12pt>\topskip12\p@
722 %<+text>\topskip\tt@chh
723 %<-text>\topmargin\pagesurround
724 %<+text>\topmargin\z@
725 %<-text>\headheight12\p@
726 %<+text>\headheight12\p@
727 %<-text>\headsep.5\pagesurround
728 %<+text>\headsep2\tt@chh
729 %<+text>\advance\headsep-12\p@
730 %<-text>\footskip12\p@
731 %<-text>\advance\footskip.5\pagesurround
732 %<+text>\footskip2\tt@chh
733 \textheight\paperheight
734 %<-text>\advance\textheight-24\p@
735 %<-text>\advance\textheight-3\pagesurround
736 %<+text>\advance\textheight-4\tt@chh
737 %    \end{macrocode}
738 %
739 % Now we define the horizontal layout.
740 %
741 %    \begin{macrocode}
742 \oddsidemargin\leftindent
743 %<-text>\advance\oddsidemargin\pagesurround
744 \evensidemargin\oddsidemargin
745 \textwidth\paperwidth
746   \advance\textwidth-\oddsidemargin
747 %<-text>  \advance\textwidth-\pagesurround
748 %<-text>\marginparsep3mm
749 %<+text>\marginparsep\tt@chw
750 \marginparwidth\leftindent
751   \advance\marginparwidth-\marginparsep
752 %    \end{macrocode}
753 %
754 % Setting |\maxdepth| is fairly simple.  This looks odd, because normally
755 % there's some messing for compatibility with \LaTeX~2.09.
756 %
757 %    \begin{macrocode}
758 \maxdepth.5\topskip
759 \@maxdepth\maxdepth
760 %    \end{macrocode}
761 %
762 % Marginal notes need some setting up.
763 %
764 %    \begin{macrocode}
765 \marginparpush5\p@
766 %    \end{macrocode}
767
768 % Footnotes need some setting up now.
769 %
770 %    \begin{macrocode}
771 %<+8pt>\footnotesep5.8\p@
772 %<+9pt>\footnotesep6.2\p@
773 %<+10pt>\footnotesep6.65\p@
774 %<+11pt>\footnotesep7.7\p@
775 %<+12pt>\footnotesep8.4\p@
776 %<+8pt>\setlength{\skip\footins}{7\p@\@plus4\p@\@minus2\p@}
777 %<+9pt>\setlength{\skip\footins}{8\p@\@plus4\p@\@minus2\p@}
778 %<+10pt>\setlength{\skip\footins}{9\p@\@plus4\p@\@minus2\p@}
779 %<+11pt>\setlength{\skip\footins}{10\p@\@plus4\p@\@minus2\p@}
780 %<+12pt>\setlength{\skip\footins}{10.8\p@\@plus4\p@\@minus2\p@}
781 %</8pt|9pt|10pt|11pt|12pt|text>
782 %    \end{macrocode}
783 %
784 % \subsection{Float placement}
785 %
786 % First, we determine how we position the floats on the page.
787 %
788 %    \begin{macrocode}
789 %<*strayman>
790 \setcounter{topnumber}{2}
791 \renewcommand\topfraction{.7}
792 \setcounter{bottomnumber}{1}
793 \renewcommand\bottomfraction{.3}
794 \setcounter{totalnumber}{3}
795 \renewcommand\textfraction{.1}
796 \renewcommand\floatpagefraction{.8}
797 \setcounter{dbltopnumber}{2}
798 \renewcommand\dbltopfraction{.7}
799 \renewcommand\dblfloatpagefraction{.5}
800 %</strayman>
801 %    \end{macrocode}
802 %
803 % Now we define the glue which surrounds floats.
804 %
805 %    \begin{macrocode}
806 %<*8pt|9pt|10pt|11pt|12pt>
807 \floatsep12\p@\@plus2\p@\@minus2\p@
808 \textfloatsep20\p@\@plus2\p@\@minus4\p@
809 \dbltextfloatsep20\p@\@plus2\p@\@minus4\p@
810 %<+8pt|9pt|10pt|11pt>\intextsep12\p@\@plus2\p@\@minus 2\p@
811 %<+8pt|9pt|10pt|11pt>\dblfloatsep12\p@\@plus2\p@\@minus 2\p@
812 %<+12pt>\intextsep14\p@\@plus4\p@\@minus 4\p@
813 %<+12pt>\dblfloatsep14\p@\@plus2\p@\@minus 4\p@
814 %    \end{macrocode}
815 %
816 % We must now define the parameters for float pages and columns.
817 %
818 %    \begin{macrocode}
819 \@fptop0\p@\@plus 1fil
820 %<+8pt|9pt|10pt|11pt>\@fpsep8\p@\@plus2fil
821 %<+12pt>\@fpsep10\p@\@plus2fil
822 \@fpbot0\p@\@plus 1fil
823 %
824 \@dblfptop0\p@\@plus 1fil
825 %<+8pt|9pt|10pt|11pt>\@dblfpsep8\p@\@plus 2fil
826 %<+12pt>\@dblfpsep10\p@\@plus2fil
827 \@dblfpbot0\p@\@plus 1fil
828 %</8pt|9pt|10pt|11pt|12pt>
829 %    \end{macrocode}
830 %
831 % \section{Headers and footers}
832 %
833 % This part defines the standard page styles.  By default, \strayman\
834 % imports \package{fancyheadings} and uses them, although this section is
835 % retained in case anything actually needs the original \LaTeX-style
836 % headings.
837 %
838 %    \begin{macrocode}
839 %<*strayman>
840 \def\ps@headings{%
841 \let\@oddfoot\@empty\let\@evenfoot\@empty
842 \def\@evenhead{\thepage\hfil\slshape\leftmark}%
843 \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
844 \let\@mkboth\markboth
845 \def\chaptermark##1{\markboth {\thechapter. ##1}{}}%
846 \def\sectionmark##1{\markright {\thesection. ##1}}%
847 }
848 %
849 \def\ps@myheadings{%
850   \let\@oddfoot\@empty\let\@evenfoot\@empty
851   \def\@evenhead{\thepage\hfil\slshape\leftmark}%
852   \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
853   \let\@mkboth\@gobbletwo
854   \let\chaptermark\@gobble
855   \let\sectionmark\@gobble
856 }
857 %    \end{macrocode}
858 %
859 % \section{Titles}
860 %
861 % \begin{macro}{\maketitle}
862 % This is a bit of a thorny issue at the moment.  Really, these titles need
863 % a complete rewrite.  The |\maketitle| command will only be used for inside
864 % front covers anyway.  I'm wondering if it wouldn't be better just to use
865 % special case code for each individual manual.  Until a decision is made,
866 % I'll leave this as it was in \package{book}.
867 %
868 % \begin{note}
869 % This code is largely uncommented.  It seems to be fairly straightforward,
870 % and if I do need to change it, I'll probably start again from scratch
871 % anyway.
872 % \end{note}
873 %
874 %    \begin{macrocode}
875 \if@titlepage
876 %
877   \newcommand\maketitle{%
878     \begin{titlepage}%
879       \let\footnotesize\small%
880       \let\footnoterule\relax%
881       \null\vfil%
882       \vskip 60\p@%
883       \begin{center}%
884         {\LARGE\@title\par}%
885         \vskip3em%
886         {%
887           \large%
888           \lineskip.75em%
889           \begin{tabular}[t]{c}%
890             \@author%
891           \end{tabular}%
892           \par%
893         }%
894         \vskip1.5em%
895         {\large \@date \par}%       % Set date in \large size.
896       \end{center}%
897       \par%
898       \@thanks%
899       \vfil\null%
900     \end{titlepage}%
901     \setcounter{footnote}{0}%
902     \let\thanks\relax%
903     \let\maketitle\relax%
904     \gdef\@thanks{}%
905     \gdef\@author{}%
906     \gdef\@title{}%
907   }
908 %
909 \else
910 %
911   \newcommand\maketitle{%
912     \par%
913     \begingroup%
914       \renewcommand\thefootnote{\fnsymbol{footnote}}%
915       \def\@makefnmark{\hb@xt@\z@{$\m@th^{\@thefnmark}$\hss}}%
916       \long\def\@makefntext##1{%
917         \parindent1em\noindent%
918         \hb@xt@1.8em{\hss$\m@th^{\@thefnmark}$}##1%
919       }%
920       \if@twocolumn%
921         \ifnum\col@number=\@ne%
922           \@maketitle%
923         \else%
924           \twocolumn[\@maketitle]%
925         \fi%
926       \else%
927         \newpage%
928         \global\@topnum\z@%   % Prevents figures from going at top of page.
929         \@maketitle%
930       \fi%
931       \thispagestyle{plain}%
932       \@thanks%
933     \endgroup%
934     \setcounter{footnote}{0}%
935     \let\thanks\relax%
936     \let\maketitle\relax%
937     \let\@maketitle\relax%
938     \gdef\@thanks{}%
939     \gdef\@author{}%
940     \gdef\@title{}%
941   }
942 %
943 \fi
944 %
945 \def\@maketitle{%
946   \newpage%
947   \null%
948   \vskip2em%
949   \begin{center}%
950     {\LARGE\@title\par}%
951     \vskip1.5em%
952     {%
953       \large%
954       \lineskip.5em%
955       \begin{tabular}[t]{c}%
956         \@author%
957       \end{tabular}%
958       \par%
959     }%
960     \vskip 1em%
961     {\large\@date}%
962   \end{center}%
963   \par%
964   \vskip1.5em%
965 }
966 %    \end{macrocode}
967 % \end{macro}
968 %
969 % \begin{environment}{titlepage}
970 %
971 % The \env{titlepage} environment typesets its contents on a title page. 
972 % The implementation is fairly straightforward: we just need to do some
973 % fiddling with two-column layouts.  We also add in some hacking to make
974 % title pages centred properly, a bit like the \env{central} environment.
975 %
976 %    \begin{macrocode}
977 \newenvironment{titlepage}{%
978   \cleardoublepage%
979   \if@twocolumn%
980     \@restonecoltrue\onecolumn%
981   \else%
982     \@restonecolfalse\newpage%
983   \fi%
984   \centrepage%
985   \if@compatibility%
986     \setcounter{page}{0}%
987   \fi%
988 }{%
989   \thispagestyle{empty}%
990   \if@restonecol%
991     \twocolumn%
992   \else%
993     \newpage%
994   \fi%
995 }
996 %    \end{macrocode}
997 % \end{environment}
998 %
999 % \begin{macro}{\centrepage}
1000 %
1001 % Change the page layout to centre everything properly.  We guard against
1002 % this sort of thing happening again by clearing |\leftindent| and
1003 % |\sectindent|.  This should only be cleared after the page has been
1004 % finished, for obvious reasons.
1005 %
1006 %    \begin{macrocode}
1007 \def\centrepage{%
1008   \advance\oddsidemargin-\leftindent%
1009   \advance\evensidemargin-\leftindent%
1010   \advance\textwidth\leftindent%
1011   \advance\linewidth\leftindent%
1012   \advance\leftmargini0.5\leftindent%
1013   \leftindent\z@%
1014   \sectindent\z@%
1015   \hsize\textwidth%
1016 }
1017 %    \end{macrocode}
1018 % \end{macro}
1019 %
1020 % \section{Sectioning commands}
1021 %
1022 % In \strayman, quite a lot of the sectioning is different.  We
1023 % don't tend to number sections much.  Also, the chapter heading style has
1024 % been completely rewritten (several times).
1025 %
1026 % \subsection{Setting up the counters}
1027 %
1028 % This is pretty simple stuff.
1029 %
1030 %    \begin{macrocode}
1031 \newcommand\chaptermark[1]{}
1032 \setcounter{secnumdepth}{\if@numbering\if@runinsubsubsec2\else3\fi\else0\fi}
1033 \newcounter {part}
1034 \newcounter {chapter}
1035 \newcounter {section}[chapter]
1036 \newcounter {subsection}[section]
1037 \newcounter {subsubsection}[subsection]
1038 \newcounter {paragraph}[subsubsection]
1039 \newcounter {subparagraph}[paragraph]
1040 \renewcommand\thepart          {\Roman{part}}
1041 \renewcommand\thechapter       {\arabic{chapter}}
1042 \if@article
1043   \renewcommand\thesection     {\arabic{section}}
1044 \else
1045   \renewcommand\thesection     {\thechapter.\arabic{section}}
1046 \fi
1047 \renewcommand\thesubsection    {\thesection.\arabic{subsection}}
1048 \renewcommand\thesubsubsection {\thesubsection .\arabic{subsubsection}}
1049 \renewcommand\theparagraph     {\thesubsubsection.\arabic{paragraph}}
1050 \renewcommand\thesubparagraph  {\theparagraph.\arabic{subparagraph}}
1051 %    \end{macrocode}
1052 %
1053 % \subsection{Frontmatter, mainmatter and backmatter}
1054 %
1055 % We start off thinking we're in the main matter.  The user ought to put a
1056 % |\frontmatter| command at the beginning of the document if this is not
1057 % correct, as it usually won't be.
1058 %
1059 %    \begin{macrocode}
1060 \newif\if@mainmatter
1061 \@mainmattertrue
1062 \newcommand\frontmatter{%
1063   \cleardoublepage%
1064   \@mainmatterfalse%
1065   \pagenumbering{roman}%
1066 }
1067 \newcommand\mainmatter{%
1068   \cleardoublepage%
1069   \@mainmattertrue%
1070   \pagenumbering{arabic}%
1071 }
1072 \newcommand\backmatter{%
1073   \if@openright%
1074     \cleardoublepage%
1075   \else%
1076     \clearpage%
1077   \fi%
1078   \@mainmatterfalse%
1079 }
1080 %    \end{macrocode}
1081 %
1082 % \subsection{Abstracts}
1083 %
1084 % \begin{environment}{abstract}
1085 %
1086 % The \env{abstract} environment reduces the type size and margins slightly.
1087 % Abstracts are placed on their own pages when the |titlepage| option is
1088 % enabled.  The code is filched from the LaTeX article class.
1089 %
1090 %    \begin{macrocode}
1091 \if@titlepage
1092   \newenvironment{abstract}{%
1093       \titlepage
1094       \null\vfil
1095       \@beginparpenalty\@lowpenalty
1096       \begin{center}%
1097         \bfseries \abstractname
1098         \@endparpenalty\@M
1099       \end{center}}%
1100      {\par\vfil\null\endtitlepage}
1101 \else
1102   \newenvironment{abstract}{%
1103       \if@twocolumn
1104         \section*{\abstractname}%
1105       \else
1106         \small
1107         \list{}{%
1108           \def\makelabel##1{%
1109             \normalfont%
1110             \fontseries{b}\fontfamily\headdefault\selectfont%
1111             ##1%
1112           }%
1113           \labelsep1em\labelwidth\z@\itemindent\labelsep%
1114           \rightmargin\leftmargin%
1115         }
1116         \item[\abstractname]%
1117       \fi}
1118       {\if@twocolumn\else\endlist\fi}
1119 \fi
1120 %    \end{macrocode}
1121 % \end{environment}
1122 %
1123 % \subsection{Appendices}
1124 %
1125 % \begin{macro}{\appendix}
1126 %
1127 % This command sets everything up to typeset the appendix.
1128 %
1129 %    \begin{macrocode}
1130 \newcommand\appendix{%
1131   \par%
1132   \setcounter{chapter}{0}%
1133   \setcounter{section}{0}%
1134   \renewcommand\@chapapp{\appendixname}%
1135   \if@article%
1136     \renewcommand\thesection{\Alph{section}}%
1137   \else%
1138     \renewcommand\thechapter{\Alph{chapter}}%
1139   \fi%
1140   \@appendixtrue%
1141 }
1142 %    \end{macrocode}
1143 % \end{macro}
1144 %
1145 % \subsection{Parts}
1146 %
1147 % Part headings are typeset on completely unadorned sheets, devoid of page
1148 % numbers and suchlike.  Because of the strange page layout, we have to
1149 % put the part heading into a |central| environment. to stop the page looking
1150 % horribly lopsided.
1151 %
1152 % \begin{macro}{\part}
1153 %
1154 % The |\part| macro moves to an appropriate page, changes the pagestyle to
1155 % empty to switch off page numbering, and then calls |\@part| or |\@spart|
1156 % as appropriate, according to whether a \lit* was supplied.  We put some
1157 % |\vfil| glue in, to vertically centre anything that these commands typeset,
1158 % and ensure printing in a single column.
1159 %
1160 %    \begin{macrocode}
1161 \newcommand\part{%
1162   \cleardoublepage%
1163   \thispagestyle{empty}%
1164   \if@twocolumn%
1165     \onecolumn%
1166     \@tempswatrue%
1167   \else%
1168     \@tempswafalse%
1169   \fi%
1170   \hbox{}\vfil%
1171   \begin{centrepage}%
1172   \secdef\@part\@spart%
1173 }
1174 %    \end{macrocode}
1175 %
1176 % \begin{macro}{\@part}
1177 %
1178 % This is where most of the part heading typesetting is done.  We stick a
1179 % line in the contents file, clear the heading markers, and typeset the
1180 % heading in the biggest letters we can find.  When we're done, we call
1181 % |\@endpart| to do some common cleaning up.
1182 %
1183 %    \begin{macrocode}
1184 \def\@part[#1]#2{%
1185   \ifnum\c@secnumdepth>-2\relax%
1186     \refstepcounter{part}%
1187     \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
1188   \else%
1189     \addcontentsline{toc}{part}{#1}%
1190   \fi%
1191   \markboth{}{}%
1192   \centering%
1193   \interlinepenalty\@M%
1194   \reset@font%
1195   \ifnum\c@secnumdepth>-2\relax%
1196     \huge\bfseries\headfam\partname~\thepart%
1197     \par%
1198     \vskip20\p@
1199   \fi%
1200   \normalfont\Huge\bfseries\headfam#2\par%
1201   \@endpart%
1202 }
1203 %    \end{macrocode}
1204 % \end{macro}
1205 %
1206 % \begin{macro}{\@spart}
1207 %
1208 % Here we typeset just the part heading: numbers have been suppressed.  Also
1209 % we don't put things into the contents file.  Otherwise, this is similar to
1210 % |\@part|.
1211 %
1212 %    \begin{macrocode}
1213 \def\@spart#1{%
1214   \centering%
1215   \interlinepenalty\@M%
1216   \reset@font%
1217   \normalfont\Huge\bfseries\headfam#1\par%
1218   \@endpart%
1219 }
1220 %    \end{macrocode}
1221 % \end{macro}
1222 %
1223 % \begin{macro}{\@endpart}
1224 %
1225 % This does the clearing up operation after a part has been typeset.  We
1226 % insert the other |\vfil| glue to centre the heading, clear the other
1227 % side of the page, if printing two-sided, and return if necessary to
1228 % two-column printing.
1229 %
1230 %    \begin{macrocode}
1231 \def\@endpart{%
1232   \vfil\newpage%
1233   \end{centrepage}%
1234   \if@twoside%
1235     \hbox{}%
1236     \thispagestyle{empty}%
1237     \newpage%
1238   \fi%
1239   \if@tempswa%
1240     \twocolumn%
1241   \fi%
1242 }
1243 %    \end{macrocode}
1244 % \end{macro}
1245 % \end{macro}
1246 %
1247 % \subsection{Chapters}
1248 %
1249 % The chapter typesetting has been more-or-less rewritten.  We'll follow this
1250 % in a reasonable amount of detail.
1251 %
1252 % \begin{macro}{\@chapapp}
1253 %
1254 % Because |\appendix| needs to change what chapters are called, we add a
1255 % level of indirection through |\@chapapp|:
1256 %
1257 %    \begin{macrocode}
1258 \newcommand\@chapapp{\chaptername}
1259 %    \end{macrocode}
1260 % \end{macro}
1261 %
1262 % \begin{macro}{\chapter}
1263 %
1264 % The |\chapter| command is the main dispatcher for chapters.  We move to
1265 % an appropriate page, depending on the |openright| setting, suppress
1266 % headers, and then call |\@chapter| or |\@schapter| as appropriate.
1267 %
1268 %    \begin{macrocode}
1269 \newcommand\chapter{%
1270   \if@openright%
1271     \cleardoublepage%
1272   \else%
1273     \clearpage%
1274   \fi%
1275   \thispagestyle{plain}%
1276   \global\@topnum\z@%
1277   \@afterindentfalse%
1278   \secdef\@chapter\@schapter%
1279 }
1280 %    \end{macrocode}
1281 %
1282 % \begin{macro}{\@chapter}
1283 %
1284 % There's a lot of messing about to do, depending on whether we're in the
1285 % main matter and so on.  We'll take this carefully.
1286 %
1287 %    \begin{macrocode}
1288 \def\@chapter[#1]#2{%
1289 %    \end{macrocode}
1290 %
1291 % The first thing to do is put a line in the contents table.  We need to
1292 % check |secnumdepth| and the |mainmatter| flag for this: we should only
1293 % include a number if both these tests pass.  In this case, we also type a
1294 % message on the terminal.
1295 %
1296 %    \begin{macrocode}
1297   \ifnum\c@secnumdepth>\m@ne%
1298     \if@mainmatter%
1299       \refstepcounter{chapter}%
1300       \typeout{\@chapapp\space\thechapter.}%
1301       \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
1302     \else
1303       \addcontentsline{toc}{chapter}{#1}%
1304     \fi
1305   \else
1306     \addcontentsline{toc}{chapter}{#1}
1307   \fi
1308 %    \end{macrocode}
1309 %
1310 % Now we put a bit of space in the lists of figures and tables, and set up
1311 % the mark to put the chapter heading in the running header.
1312 %    \begin{macrocode}
1313   \chaptermark{#1}%
1314   \addtocontents{lof}{\protect\addvspace{10\p@}}%
1315   \addtocontents{lot}{\protect\addvspace{10\p@}}%
1316 %    \end{macrocode}
1317 %
1318 % Finally, we need to decide how to typeset the chapter heading.  On
1319 % single-column chapters, this is easy.  On double-column formats, we need
1320 % to do horrid things with |\@topnewpage|.
1321 %
1322 %    \begin{macrocode}
1323   \if@twocolumn%
1324     \@topnewpage[\@makechapterhead{%
1325       \hb@xt@.5\leftindent{\thechapter\hfil}%
1326     }{#2}]%
1327   \else%
1328     \@makechapterhead{%
1329       \hb@xt@.5\leftindent{\thechapter\hfil}%
1330     }{#2}%
1331     \@afterheading%
1332   \fi%
1333 }
1334 %    \end{macrocode}
1335 % \end{macro}
1336 %
1337 % \begin{macro}{\@makechapterhead}
1338 %
1339 % This macro actually does the job of typesetting a chapter heading.  Call
1340 % this routine as |\@makechapterhead{|\synt{number}|}{|\synt{title}|}|.
1341 % Here, \synt{number} is how to typeset the chapter number, and \synt{title}
1342 % is the rest of the title.  To suppress the number, just leave \synt{number}
1343 % empty.  The number is only typeset when it is correct to do so anyway.
1344 %
1345 % The spacing is rather awkward.  We have to cope with two-column layouts,
1346 % which seem to require different spacing.  In a double-column layout,
1347 % the title is normally one |\baselineskip| too high.  Also, the space I
1348 % add at the bottom of the heading gets eaten in double-column chapters,
1349 % because I'm actually typesetting into a vbox which is floated to the top
1350 % by \LaTeX\ in a fairly horrid way.  This can't really be worked around,
1351 % so we just make the space beneath the heading equal to |\dbltextfloatsep|,
1352 % which is what gets added anyway.
1353 %
1354 % The other snags are to do with the rule after the chapter heading.
1355 % Firstly, this is meant to be typeset into the left margin, like the
1356 % heading itself, which is a bit messy.  More awkwardly, we have to be
1357 % careful not to let the depth of the line vary when the chapter heading has
1358 % descenders, although obviously we must lower the rule if the heading really
1359 % is very deep indeed.
1360 %
1361
1362 % We'll approach this a bit at a time.
1363 %
1364 %    \begin{macrocode}
1365 \def\@makechapterhead#1#2{%
1366   \begingroup%                          % Stop my hacking messing things up
1367 %    \end{macrocode}
1368 %
1369 % First, the top spacing.  This is divided into two parts, by an invisible
1370 % rule: the |\vskip| above the rule is eaten by \TeX\ if this is a genuine
1371 % new page, but put into the floating vbox if this is a two-column affair.
1372 % The second bit is added in both cases.
1373 %
1374 %    \begin{macrocode}
1375     \vskip\baselineskip%                % This is gobbled in single column
1376     \hrule\@height\z@%                  % Stops TeX from binning my vskips
1377     \vskip32\p@%                        % Start chapters in a funny place
1378 %    \end{macrocode}
1379 %
1380 % Now we actually typeset the heading.  This is fairly simple: we must just
1381 % check that we need to typeset the number.
1382 %
1383 %    \begin{macrocode}
1384     \normalfont\Huge\bfseries\headfam%  % Choose a nice font for it
1385     \raggedright                        % Don't justify -- it looks nasty
1386     \@hangfrom{\hskip-\leftindent}%     % Start text at `real left margin'
1387     \ifnum\c@secnumdepth>\m@ne%         % Do we typeset chapter numbers?
1388       \if@mainmatter%                   % Are we past the front matter?
1389         #1%                             % Yes -- then typeset the number
1390     \fi\fi%                             % Now back to normality
1391     {#2}%                               % Typeset the actual chapter head
1392     \par\nobreak%                       % Back to vmode again, please
1393 %    \end{macrocode}
1394 %
1395 % The next tricky bit is the space before the ruleoff.  We must be careful
1396 % here:
1397 %
1398 % \begin{itemize}
1399 %
1400 % \item We want the rule to be the right depth below the heading baseline,
1401 % regardless of whether the heading contains descenders: helpfully, \TeX\
1402 % omits |\baselineskip| glue before and after rules.
1403 %
1404 % \item We want the rule to always be below any oddly deep descenders that
1405 % a strange user might throw at us (e.g., horrid fractions or weird
1406 % |\vrule|s).
1407 %
1408 % \end{itemize}
1409 %
1410 % We accomplish this by scrutinising |\prevdepth| carefully.
1411 %
1412 %    \begin{macrocode}
1413     \@tempdima14\p@%                    % Be this low below the baseline
1414     \advance\@tempdima-\prevdepth%      % This is the actual skip then
1415     \ifdim\@tempdima<8\p@%              % Is this not enough skippage?
1416       \@tempdima8\p@%                   % No: then skip some more
1417     \fi%
1418     \vskip\@tempdima%                   % Skip a bit below the title
1419 %    \end{macrocode}
1420 %
1421 % Now we can set the rule.  This needs a little care.
1422 %
1423 %    \begin{macrocode}
1424     \@tempskipa\textwidth%              % Find the width of the column
1425     \advance\@tempskipa\leftindent%     % Add on the big lefthand gap
1426     \nointerlineskip%                   % Don't add any more space please
1427     \moveleft\leftindent\vbox{%         % Shift something left by an amount
1428       \hrule\@width\@tempskipa%         % Typeset the rule nicely
1429     }%
1430     \nointerlineskip%                   % Don't leave a gap beneath it
1431 %    \end{macrocode}
1432 %
1433 % Finally, we leave a gap.  In two-column layouts this is done for us, and
1434 % \LaTeX\ gobbles this glue and replaces it with |\dbltextfloatsep|.  To make
1435 % things consistent, this is the glue we use anyway.
1436 %
1437 %    \begin{macrocode}
1438     \nobreak%                           % This would be a bad place to break
1439     \vspace{\dbltextfloatsep}%          % Add in some extra glue beneath
1440   \endgroup%
1441 }
1442 %    \end{macrocode}
1443 % \end{macro}
1444 %
1445 % \begin{macro}{\@makeschapterhead}
1446 %
1447 % This is now just a veneer onto |\@makechapterhead|.  It's needed, because
1448 % other bits of \LaTeX\ call it.
1449 %
1450 %    \begin{macrocode}
1451 \def\@makeschapterhead{%
1452   \@makechapterhead{}
1453 }
1454 %    \end{macrocode}
1455 % \end{macro}
1456 %
1457 % \begin{macro}{\@schapter}
1458 %
1459 % This macro typesets a starred chapter heading.  This is terribly simple,
1460 % compared to the sort of things we've been doing so far.
1461 %
1462 %    \begin{macrocode}
1463 \def\@schapter#1{%
1464   \if@twocolumn%
1465     \@topnewpage[\@makeschapterhead{#1}]%
1466   \else%
1467     \@makeschapterhead{#1}%
1468     \@afterheading%
1469   \fi%
1470 }
1471 %    \end{macrocode}
1472 % \end{macro}
1473 % \end{macro}
1474 %
1475 % \subsection{The other sectioning commands}
1476 %
1477 % These are all defined through |\@startsection|.  They've been modified
1478 % to typeset sections and subsections hanging into the left margin, and to
1479 % moderate the amount of following space, due to the extra |\parskip| already
1480 % introduced.
1481 %
1482 %    \begin{macrocode}
1483 \def\@defsection#1#2#3#4#5#6{%
1484   \expandafter\newcommand\csname#1\endcsname{%
1485     \skip@#4\advance\skip@\ifdim\skip@<\z@-\fi\@parshortfall%
1486     \skip\tw@#5\relax\ifdim\skip\tw@>\z@\advance\skip\tw@\@parshortfall\fi%
1487     \@startsection%
1488       {#1}%
1489       {#2}%
1490       {#3}%
1491       \skip@
1492       {\skip\tw@}%
1493       {\reset@font#6\bfseries\headfam}%
1494   }%
1495 }
1496 \@defsection
1497     {section}%                          % Section name (for contents)
1498     {1}%                                % Level number (for numbering)
1499     {-.5\sectindent}%                   % Indentation of title
1500     {-1.5ex\@plus-1ex\@minus-.2ex}%     % Space after title (vert/horiz)
1501     {.3ex\@plus.2ex}%                   % Space before title
1502     {\reset@font\Large\bfseries\headfam}% How to typeset the title
1503 \@defsection
1504     {subsection}%
1505     {2}%
1506     {-.25\sectindent}%
1507     {-1.25ex\@plus-1ex\@minus-.2ex}%
1508     {\p@\@plus.2ex}%
1509     {\reset@font\large\bfseries\headfam}%
1510 \if@runinsubsubsec
1511 \@defsection
1512     {subsubsection}%
1513     {3}%
1514     {\z@}%
1515     {0pt\@plus1ex\@minus.2ex}%
1516     {-1em}%
1517     {\reset@font\normalsize\bfseries\headfam}%
1518 \@defsection
1519     {paragraph}%
1520     {4}%
1521     {\z@}%
1522     {0pt\@plus.5ex\@minus.1ex}%
1523     {-1em}%
1524     {\reset@font\normalsize\bfseries\headfam}%
1525 \@defsection
1526     {subparagraph}%
1527     {5}%
1528     {\parindent}%
1529     {0pt\@plus.5ex\@minus.1ex}%
1530     {-1em}%
1531     {\reset@font\normalsize\bfseries\headfam}%
1532 \else
1533 \@defsection
1534     {subsubsection}%
1535     {3}%
1536     {\z@}%
1537     {-1.25ex\@plus-1ex\@minus-.2ex}%
1538     {\p@\@plus.2ex}%
1539     {\reset@font\normalsize\bfseries\headfam}%
1540 \@defsection
1541     {paragraph}%
1542     {4}%
1543     {\z@}%
1544     {0pt\@plus1ex\@minus.2ex}%
1545     {-1em}%
1546     {\reset@font\normalsize\bfseries\headfam}%
1547 \@defsection
1548     {subparagraph}%
1549     {5}%
1550     {\parindent}%
1551     {0pt\@plus.5ex\@minus.1ex}%
1552     {-1em}%
1553     {\reset@font\normalsize\bfseries\headfam}%
1554 \fi
1555 %    \end{macrocode}
1556 %
1557 % \subsection{Section number formatting}
1558 %
1559 % \begin{macro}{\@seccntformat}
1560 %
1561 % The macro is given a section counter and must format it in some nice way.
1562 %
1563 %    \begin{macrocode}
1564 \def\@seccntformat#1{%
1565   \llap{\csname the#1\endcsname{\normalsize\quad}\hfil}%
1566 }
1567 %
1568 % \subsection{Top level sectioning}
1569 %
1570 % \begin{macro}{\@topsect}
1571 %
1572 % Articles are divided into sections; other documents are divided into
1573 % chapters.  Things like the table of contents need to know which.
1574 %
1575 %    \begin{macrocode}
1576 \if@article
1577   \def\@topsect@star{\section*}
1578   \let\@topsect\section
1579 \else
1580   \let\@topsect@star\chapter
1581   \let\@topsect\chapter
1582 \fi
1583 %    \end{macrocode}
1584 %
1585 % \end{macro}
1586 %
1587 %
1588 % \section{List handling}
1589 %
1590 % A surprising number of \LaTeX's environments are defined in terms of
1591 % lists, many of which hide the fact by putting the entire text in one big
1592 % item.
1593 %
1594 % This part of the document class has to set up lots of list parameters.
1595 % This is largely the same as the standard classes, altered slightly to cope
1596 % with the different paragraph spacing.
1597 %
1598 % \subsection{General list parameters}
1599 %
1600 % Default left margins for lists:
1601 %
1602 %    \begin{macrocode}
1603 \if@twocolumn
1604   \leftmargini2em
1605 \else
1606   \leftmargini2.2em
1607 \fi
1608 \leftmarginii2em
1609 \leftmarginiii1.87em
1610 \leftmarginiv1.7em
1611 \if@twocolumn
1612   \leftmarginv.5em
1613   \leftmarginvi.5em
1614 \else
1615   \leftmarginv1em
1616   \leftmarginvi1em
1617 \fi
1618 %    \end{macrocode}
1619 % And now we can set the paragraph indent.
1620 %    \begin{macrocode}
1621 \if@indentpar
1622   \parindent\leftmargini
1623 \else
1624   \parindent\z@
1625 \fi
1626 %    \end{macrocode}
1627 %
1628 % Other spacing defaults:
1629 %
1630 %    \begin{macrocode}
1631 \leftmargin\leftmargini
1632 \labelsep.5em
1633 \labelwidth\leftmargini
1634 \advance\labelwidth-\labelsep
1635 \partopsep\z@\@plus1\p@\@minus1\p@
1636 %    \end{macrocode}
1637 %
1638 % Interline penalties:
1639 %
1640 %    \begin{macrocode}
1641 \@beginparpenalty -\@lowpenalty
1642 \@endparpenalty   -\@lowpenalty
1643 \@itempenalty     -\@lowpenalty
1644 %    \end{macrocode}
1645 %
1646 % Now we define the defaults for the list environments.  These have managed
1647 % to migrate from the size options into the main document class.
1648 %
1649 %    \begin{macrocode}
1650 \def\@listI{%
1651   \leftmargin\leftmargini%
1652   \parsep\@parskip%
1653   \topsep\@parshortfall%
1654   \itemsep\z@%
1655 }
1656 \let\@listi\@listI
1657 \@listi%
1658 \def\@listii{%
1659   \topsep\z@\@plus\p@%
1660   \leftmargin\leftmarginii%
1661   \labelwidth\leftmarginii%
1662     \advance\labelwidth-\labelsep%
1663 }
1664 \def\@listiii{%
1665   \leftmargin\leftmarginiii%
1666   \labelwidth\leftmarginiii%
1667     \advance\labelwidth-\labelsep%
1668 %  \partopsep\p@\@plus\z@\@minus\p@%
1669 }
1670 \def\@listiv{%
1671   \leftmargin\leftmarginiv%
1672   \labelwidth\leftmarginiv%
1673     \advance\labelwidth-\labelsep%
1674 }
1675 \def\@listv{%
1676   \leftmargin\leftmarginv%
1677   \labelwidth\leftmarginv%
1678     \advance\labelwidth-\labelsep%
1679 }
1680 \def\@listvi{%
1681   \leftmargin\leftmarginvi%
1682   \labelwidth\leftmarginvi%
1683     \advance\labelwidth-\labelsep%
1684 }
1685 %    \end{macrocode}
1686 %
1687 % \subsection{Numbering things}
1688 %
1689 % \begin{macro}{\numberwithin}
1690 %
1691 % Does the obvious thing.  Optional argument gives numbering style.
1692 %
1693 %    \begin{macrocode}
1694 \def\numberwithin{\@testopt\nw@i\arabic}
1695 \def\nw@i[#1]#2#3{%
1696   \@addtoreset{#2}{#3}%
1697   \expandafter\xdef\csname the#2\endcsname{%
1698     \expandafter\noexpand\csname the#3\endcsname.%
1699     \noexpand#1{#2}}%
1700 }
1701 %    \end{macrocode}
1702 %
1703 % \end{macro}
1704 %
1705 % \begin{macro}{\removefromreset}
1706 %
1707 % Does the obvious thing.
1708 %
1709 %    \begin{macrocode}
1710 \def\removefromreset#1#2{%
1711   \begingroup%
1712   \def\@tempa{#1}%
1713   \toks@{}%
1714   \def\@elt##1{%
1715     \def\@tempb{##1}%
1716     \ifx\@tempa\@tempb%
1717     \else\toks@\expandafter{\the\toks@\@elt{##1}}%
1718     \fi%
1719   }
1720   \csname cl@#2\endcsname%
1721   \expandafter\xdef\csname cl@#2\endcsname{\the\toks@}%
1722   \endgroup%
1723 }
1724 %    \end{macrocode}
1725 %
1726 % \end{macro}
1727 %
1728 % \subsection{Enumerated lists}
1729 %
1730 % We busily redefine all the counters for enumerated lists, and how to
1731 % typeset them.
1732 %
1733 % How to typeset the numbers:
1734 %
1735 %    \begin{macrocode}
1736 \renewcommand\theenumi{\arabic{enumi}}
1737 \renewcommand\theenumii{\alph{enumii}}
1738 \renewcommand\theenumiii{\roman{enumiii}}
1739 \renewcommand\theenumiv{\Alph{enumiv}}
1740 %    \end{macrocode}
1741 %
1742 % Typesetting the item labels:
1743 %
1744 %    \begin{macrocode}
1745 \newcommand\labelenumi{\theenumi.}
1746 \newcommand\labelenumii{(\theenumii)}
1747 \newcommand\labelenumiii{\theenumiii.}
1748 \newcommand\labelenumiv{\theenumiv.}
1749 %    \end{macrocode}
1750 %
1751 % And finally how to typeset references to the items:
1752 %
1753 %    \begin{macrocode}
1754 \renewcommand\p@enumii{\theenumi}
1755 \renewcommand\p@enumiii{\theenumi(\theenumii)}
1756 \renewcommand\p@enumiv{\p@enumiii\theenumiii}
1757 %    \end{macrocode}
1758 %
1759 % \subsection{Itemized lists}
1760 %
1761 % We set up the various bullet shapes for the itemized lists.
1762 %
1763 %    \begin{macrocode}
1764 \newcommand\labelitemi{$\m@th\bullet$}
1765 \newcommand\labelitemii{\normalfont\bfseries --}
1766 \newcommand\labelitemiii{$\m@th\ast$}
1767 \newcommand\labelitemiv{$\m@th\cdot$}
1768 %    \end{macrocode}
1769 %
1770 % \subsection{Description lists}
1771 %
1772 % This has been redefined a little to make it more sensible.  The old version
1773 % had a weird |\hspace\labelsep| in the labelling macro.  This has now been
1774 % added into the main list definition.  You can now redefine
1775 % |\descriptionlabel| without fear of messing up the spacing.
1776 %
1777 % \begin{environment}{description}
1778 %
1779 % Here we set up the main list parameters.  The label width is zeroed to
1780 % ensure that the text is always indented nicely.
1781 %
1782 %    \begin{macrocode}
1783 \def\description{%
1784   \list{}{%
1785     \labelwidth\z@%
1786     \itemindent-\leftmargin%
1787     \advance\itemindent\labelsep%
1788     \def\makelabel{\descriptionlabel}%
1789   }%
1790 }
1791 \let\enddescription\endlist
1792 %    \end{macrocode}
1793 %
1794 % \begin{macro}{\descriptionlabel}
1795 %
1796 % This typesets a description label.  Redefine it the obvious way for
1797 % different exciting effects.
1798 %
1799 %    \begin{macrocode}
1800 \def\descriptionlabel#1{\normalfont\bfseries #1}
1801 %    \end{macrocode}
1802 %
1803 % \end{macro}
1804 % \end{environment}
1805 %
1806 % \subsection{Other list-based environments}
1807 %
1808 % Several other standard environments are defined in terms of lists.  These
1809 % are all dealt with here.
1810 %
1811 % \begin{environment}{verse}
1812 %
1813 % The \env{verse} environment is specially fiddled so that |\\| works as it
1814 % should.  There's nothing else exciting about it.
1815 %
1816 %    \begin{macrocode}
1817 \newenvironment{verse}{%
1818   \let\\\@centercr%
1819   \list{}{%
1820     \itemsep\z@%
1821     \itemindent-1.5em%
1822     \listparindent\itemindent%
1823     \rightmargin\leftmargin%
1824     \advance\leftmargin1.5em%
1825   }%
1826   \item[]%
1827 }{%
1828   \endlist%
1829 }
1830 %    \end{macrocode}
1831 % \end{environment}
1832 %
1833 % \begin{environment}{quotation}
1834 %
1835 % The \env{quotation} environment is a pretty standard display, except that
1836 % we kill off inter-paragraph space.  The current definition means that
1837 % \env{quotation}s are typeset in normal indented-paragraph style, which
1838 % is inconsistent with the rest of the document style.
1839 %
1840 %    \begin{macrocode}
1841 \newenvironment{quotation}{%
1842   \list{}{%
1843     \listparindent\z@%
1844     \itemindent\listparindent%
1845     \rightmargin\leftmargin%
1846   }%
1847   \item[]%
1848 }{%
1849   \endlist%
1850 }
1851 %    \end{macrocode}
1852 % \end{environment}
1853 %
1854 % \begin{environment}{quote}
1855 %
1856 % This is even simpler.  We just pull in the right margin a bit.
1857 %
1858 %    \begin{macrocode}
1859 \newenvironment{quote}{%
1860   \list{}{%
1861     \rightmargin\leftmargin%
1862   }%
1863   \item[]%
1864 }{%
1865   \endlist%
1866 }
1867 %    \end{macrocode}
1868 % \end{environment}
1869 %
1870 % \begin{environment}{display}
1871 %
1872 % The \env{display} environment is intended for any other displays which you
1873 % need to typeset.  This is \emph{not} a standard environment.
1874 %
1875 %    \begin{macrocode}
1876 \newenvironment{display}{%
1877   \list{}{%
1878     \leftmargin1em%
1879     \rightmargin\leftmargin%
1880     \labelsep\z@%
1881     \labelwidth\z@%
1882   }%
1883   \item[]\relax%
1884 }{%
1885   \endlist%
1886 }
1887 %    \end{macrocode}
1888 % \end{environment}
1889 %
1890 % And some quick hacking of the theorem environment.
1891 %
1892 % \section{Other parameters}
1893 %
1894 % We define some miscellaneous parameters for standard environments.
1895 %
1896 %    \begin{macrocode}
1897 \arraycolsep5\p@
1898 \tabcolsep6\p@
1899 \arrayrulewidth.4\p@
1900 \doublerulesep2\p@
1901 \tabbingsep\labelsep
1902 \skip\@mpfootins\skip\footins
1903 \fboxsep3\p@
1904 \fboxrule.4\p@
1905 %
1906 \if@article
1907   \renewcommand\theequation{\arabic{equation}}
1908 \else
1909   \@addtoreset{equation}{chapter}
1910   \renewcommand\theequation{\thechapter.\arabic{equation}}
1911 \fi
1912 %    \end{macrocode}
1913 %
1914 % \section{Floats}
1915 %
1916 % Since raw \LaTeX\ doesn't actually define any floating objects, we have
1917 % to do some of the work here.  This isn't actually terribly arduous.  For
1918 % a float called \synt{float}, we have to define the following macros:
1919 %
1920 % \begin{description}
1921 % \let\descriptionlabel\relax
1922 %
1923 % \item[\texttt{\bslash fps@}\synt{float}] is the default float positioning
1924 % argument for the float type.
1925 %
1926 % \item[\texttt{\bslash ftype@}\synt{float}] is a flag bit for the float
1927 % type.  This is used in \LaTeX's |\output| routine to identify floats of
1928 % this type.
1929 %
1930 % \item[\texttt{\bslash ext@}\synt{float}] is the file extension for the
1931 % list of these floats (e.g., \lit{lof} for figures).
1932 %
1933 % \item[\texttt{\bslash fnum@}\synt{float}] is a macro which generates the
1934 % caption number.  For figures, this expands to `|Figure~\thefigure|'.
1935 %
1936 % \end{description}
1937 %
1938 % We must also define |\@makecaption|, which typesets a float caption in
1939 % an appropriate way, and an environment for each type of float.
1940 %
1941 % \subsection{Figures}
1942 %
1943 % This is all fairly straightforward stuff.  First, we create a counter for
1944 % figures:
1945 %
1946 %    \begin{macrocode}
1947 \newcounter{figure}[chapter]
1948 \if@article
1949   \renewcommand\thefigure{\@arabic\c@figure}
1950 \else
1951   \renewcommand\thefigure{\thechapter.\@arabic\c@figure}
1952 \fi
1953 %    \end{macrocode}
1954 %
1955 % Now we define all the macros \LaTeX\ requires.
1956 %
1957 %    \begin{macrocode}
1958 \if@herefloats\def\fps@figure{htbp}\else\def\fps@figure{tbp}\fi
1959 \def\ftype@figure{1}
1960 \def\ext@figure{lof}
1961 \def\fnum@figure{\figurename~\thefigure}
1962 %    \end{macrocode}
1963 %
1964 % \begin{environment}{figure}
1965 % \begin{environment}{figure*}
1966 %
1967 % Finally, we create the \env{figure} and \env{figure$*$} environments.
1968 %
1969 %    \begin{macrocode}
1970 \newenvironment{figure}{\@float{figure}}{\end@float}
1971 \newenvironment{figure*}{\@dblfloat{figure}}{\end@dblfloat}
1972 %    \end{macrocode}
1973 % \end{environment}
1974 % \end{environment}
1975 %
1976 % \subsection{Tables}
1977 %
1978 % This is pretty similar to the figure handling.
1979 %
1980 %    \begin{macrocode}
1981 \newcounter{table}[chapter]
1982 \if@article
1983   \renewcommand\thetable{\@arabic\c@table}
1984 \else
1985   \renewcommand\thetable{\thechapter.\@arabic\c@table}
1986 \fi
1987 %
1988 \if@herefloats\def\fps@table{htbp}\else\def\fps@table{tbp}\fi
1989 \def\ftype@table{2}
1990 \def\ext@table{lot}
1991 \def\fnum@table{\tablename~\thetable}
1992 %
1993 \newenvironment{table}{\@float{table}}{\end@float}
1994 \newenvironment{table*}{\@dblfloat{table}}{\end@dblfloat}
1995 %    \end{macrocode}
1996 %
1997 % \subsection{Other float parameters}
1998 %
1999 % \begin{macro}{\@makecaption}
2000 %
2001 % The |\@makecaption| macro is called to display a float caption.  It will
2002 % typeset its argument either centred in a box, if it is short enough, or
2003 % in a paragraph if it is longer than a line.
2004 %
2005 %    \begin{macrocode}
2006 \newlength\abovecaptionskip
2007 \newlength\belowcaptionskip
2008 \abovecaptionskip10\p@
2009 \belowcaptionskip0\p@
2010 %
2011 \long\def\captionstyle#1#2{\itshape #1: #2}
2012 \long\def\@makecaption#1#2{%
2013   \vskip\abovecaptionskip%
2014   \sbox\@tempboxa{\captionstyle{#1}{#2}}%
2015   \ifdim\wd\@tempboxa>\hsize%
2016     \unhbox\@tempboxa\par%
2017   \else%
2018     \hb@xt@\hsize{\hfil\unhbox\@tempboxa\hfil}%
2019   \fi%
2020   \vskip\belowcaptionskip%
2021 }
2022 %    \end{macrocode}
2023 % \end{macro}
2024 %
2025 % \section{Font commands}
2026 %
2027 % We allow the `old' font commands to do sensible \textsf{NFSS} things, since
2028 % we don't have any legacy documents.  This means that we have proper
2029 % abbreviations for font changes.  We also add |\nm| to return to a normal
2030 % font, whatever that may mean.
2031 %
2032 %    \begin{macrocode}
2033 \DeclareOldFontCommand{\rm}{\rmfamily}{\mathrm}
2034 \DeclareOldFontCommand{\sf}{\sffamily}{\mathsf}
2035 \DeclareOldFontCommand{\tt}{\ttfamily}{\mathtt}
2036 \DeclareOldFontCommand{\bf}{\bfseries}{\mathbf}
2037 \DeclareOldFontCommand{\md}{\mdseries}{\@nomath\md}
2038 \DeclareOldFontCommand{\it}{\itshape}{\mathit}
2039 \DeclareOldFontCommand{\up}{\upshape}{\@nomath\up}
2040 \DeclareOldFontCommand{\sl}{\slshape}{\@nomath\sl}
2041 \DeclareOldFontCommand{\sc}{\scshape}{\@nomath\sc}
2042 \DeclareOldFontCommand{\nm}{\normalfont}{\mathnormal}
2043 %    \end{macrocode}
2044 %
2045 % Now we define some special commands which only work in maths mode.  It
2046 % seems that older versions of \LaTeX\ (in particular, that at Warwick
2047 % University) don't define these commands initially, so we'd better not
2048 % use |\renewcommand| after all.  We also dispose of lots of messing with
2049 % |\protect| by using |\DeclareRobustCommand|.
2050 %
2051 %    \begin{macrocode}
2052 \DeclareRobustCommand\cal{\@fontswitch{\relax}{\mathcal}}
2053 \DeclareRobustCommand\pmit{\@fontswitch{\relax}{\mathnormal}}
2054 %    \end{macrocode}
2055 %
2056 % \section{Tables of contents}
2057 %
2058 % This section deals with tables of contents, and lists of figures.
2059 %
2060 % \subsection{Contents}
2061 %
2062 % First, we have to define some parameters.
2063 %
2064 %    \begin{macrocode}
2065 \newcommand\@pnumwidth{2em}
2066 \newcommand\@tocrmarg {3em}
2067 \newcommand\@dotsep{4.5}
2068 \setcounter{tocdepth}{\if@runinsubsubsec1\else2\fi}
2069 %    \end{macrocode}
2070 %
2071 % \begin{macro}{\tableofcontents}
2072 %
2073 % This is the main command for setting up tables of contents.  We ensure
2074 % a single-page layout, put in the chapter heading, read in the contents
2075 % file, and then restore the old layout.
2076 %
2077 %    \begin{macrocode}
2078 \def\@tocthing#1#2{%
2079   \@ifnextchar[{\@tocthing@i{#1}{#2}}{\@tocthing@i{#1}{#2}[\relax][\relax]}%
2080 }
2081 \def\@tocthing@i#1#2[#3][#4]{%
2082   \if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\fi%
2083   \@topsect@star{#1}#3{\parskip\z@\@starttoc{#2}}#4%
2084   \if@restonecol\twocolumn\fi%
2085 }
2086 \newcommand\tableofcontents{\@tocthing\contentsname{toc}}
2087 %    \end{macrocode}
2088 % \end{macro}
2089 %
2090 % Each section type \synt{type} is typeset by a command |\l@|\synt{type}:
2091 % for example, the |\l@chapter| command typesets the entry for a chapter
2092 % heading.
2093 %
2094 % \begin{macro}{\l@part}
2095 %
2096 % This command is vaguely interesting.  We'll explore in detail.
2097 %
2098 %    \begin{macrocode}
2099 \def\l@part#1#2{%
2100 %    \end{macrocode}
2101 %
2102 % We don't typeset the entry if |tocdepth| tells us not to.  What kind of
2103 % stupid user is going to disable \emph{all} the contents items.
2104 %
2105 %    \begin{macrocode}
2106   \ifnum\c@tocdepth>-2\relax%
2107 %    \end{macrocode}
2108 %
2109 % Before we start, we try to break above the title.  Later, we'll disable
2110 % breaking afterwards.  We then leave some vertical space.
2111 %
2112 %    \begin{macrocode}
2113     \addpenalty{-\@highpenalty}%
2114     \addvspace{2.25em\@plus\p@}%
2115 %    \end{macrocode}
2116 %
2117 % We open a group, to avoid messing other things up.  The |\numberline|
2118 % macro, which numbers the entry on the left, typesets its argument in a box
2119 % of width |\@tempdima|, which we must set up.  We then set up the values
2120 % of |\rightskip| and |\parfillskip| to avoid printing over the page number.
2121 % We also make |\interlinepenalty| infinite to suppress breaking pages in
2122 % the middle of the title.
2123 %
2124 %    \begin{macrocode}
2125     \begingroup%
2126       \@tempdima3em%
2127       \parindent\z@%
2128       \rightskip\@pnumwidth%
2129       \parfillskip-\@pnumwidth%
2130       \interlinepenalty\@M
2131 %    \end{macrocode}
2132 %
2133 % Time to typeset the actual title.  This is fairly simple, apart from
2134 % a complicated mixture of glue and penalties, which handles a line break
2135 % right at the end of the title.
2136 %
2137 %    \begin{macrocode}
2138       {%
2139         \leavevmode%
2140         \large\bfseries {#1}%
2141         \nobreak\hfil\penalty\@highpenalty\hbox{}\nobreak\hfil%
2142         \hb@xt@\@pnumwidth{\hss #2}%
2143       }%
2144 %    \end{macrocode}
2145 %
2146 % Now we end the paragraph and suppress page breaking here.
2147 %
2148 %    \begin{macrocode}
2149       \par%
2150       \nobreak%
2151       \global\@nobreaktrue%
2152       \everypar{\global\@nobreakfalse\everypar{}}%
2153     \endgroup%
2154   \fi%
2155 }
2156 %    \end{macrocode}
2157 % \end{macro}
2158 %
2159 % \begin{macro}{\@artsw}
2160 %
2161 % Define a macro named after the first or second argument depending on
2162 % whether the document is an article.
2163 %
2164 %    \begin{macrocode}
2165 \def\@artsw#1#2#3{%
2166   \edef\@tempa{#1\if@article\noexpand#3\else\noexpand#2\fi}%
2167   \@tempa%
2168 }
2169 %    \end{macrocode}
2170 %
2171 % \end{macro}
2172 %
2173 % \begin{macro}{\l@chapter}
2174 %
2175 % This is terribly similar to the previous macro.
2176 %
2177 %    \begin{macrocode}
2178 \@artsw\def\l@chapter\l@section#1#2{%
2179   \ifnum\c@tocdepth >\m@ne%
2180     \addpenalty{-\@highpenalty}%
2181     \vskip1.0em\@plus\p@%
2182     \setlength\@tempdima{2em}%
2183     \begingroup%
2184       \interlinepenalty\@M
2185       \parindent\z@%
2186       \rightskip\@pnumwidth%
2187       \parfillskip-\@pnumwidth%
2188       \leavevmode%
2189       \bfseries%
2190       \advance\leftskip\@tempdima%
2191       \hskip-\leftskip%
2192       {#1}%
2193       \nobreak\hfil\penalty\@highpenalty\hbox{}\nobreak\hfil%
2194       \hb@xt@\@pnumwidth{\hss #2}%
2195       \par%
2196       \penalty\@highpenalty%
2197     \endgroup%
2198   \fi%
2199 }
2200 %    \end{macrocode}
2201 % \end{macro}
2202 %
2203 % The other types are all defined in terms of |\@dottedtocline|, which is
2204 % redefined beloew.
2205 %
2206 %    \begin{macrocode}
2207 \@artsw\def\l@section\l@subsection{\@dottedtocline{1}{2em}{2.5em}}
2208 \@artsw\def\l@subsection\l@subsubsection{\@dottedtocline{2}{4.5em}{3.2em}}
2209 \@artsw\def\l@subsubsection\l@paragraph{\@dottedtocline{3}{7.7em}{4.1em}}
2210 \@artsw\def\l@paragraph\l@subparagraph{\@dottedtocline{4}{10.5em}{5em}}
2211 \@artsw\def\l@subparagraph\@tempa{\@dottedtocline{5}{12.5em}{6em}}
2212 %    \end{macrocode}
2213 %
2214 % \begin{macro}{\@dottedtocline}
2215 %
2216 % This is actually a part of the \LaTeX\ kernel, although it's not quite
2217 % right the way it is.  We've improved the handling of line breaks after the 
2218 % title.
2219 %
2220 %    \begin{macrocode}
2221 \def\@dottedtocline#1#2#3#4#5{%
2222 %    \end{macrocode}
2223 %
2224 % We have to make sure that we're meant to typeset this contents entry.
2225 %
2226 %    \begin{macrocode}
2227   \ifnum#1>\c@tocdepth\else%
2228 %    \end{macrocode}
2229 %
2230 % Now we add in a little stretchy space.
2231 %
2232 %    \begin{macrocode}
2233     \vskip\z@\@plus.2\p@%
2234 %    \end{macrocode}
2235 %
2236 % Set up the paragraph layout now.  We forbid page breaks in the middle of
2237 % the title.
2238 %
2239 %    \begin{macrocode}
2240     {%
2241       \leftskip#2\relax%
2242       \rightskip\@tocrmarg%
2243       \parfillskip-\rightskip%
2244       \parindent#2\relax%
2245       \@afterindenttrue%
2246       \interlinepenalty\@M%
2247 %    \end{macrocode}
2248 %
2249 % Now we typeset the actual title.
2250 %
2251 %    \begin{macrocode}
2252       \leavevmode%
2253       \@tempdima#3\relax%
2254       \advance\leftskip\@tempdima%
2255       \hbox{}%
2256       \hskip-\leftskip%
2257       {#4}%
2258 %    \end{macrocode}
2259 %
2260 % This is the clever bit.  After the actual title, we add the following
2261 % items:
2262 %
2263 % \begin{itemize}
2264 %
2265 % \item A |\nobreak| penalty, to stop a break from eating the glue.
2266 %
2267 % \item A glob of |\hfil| glue.  If there's a line break after this glue,
2268 % the title is set flush left as a result of this.  Otherwise, it is ignored
2269 % because the leaders are |\hfill|.
2270 %
2271 % \item A penalty.  This is a reasonable place to break the line if
2272 % necessary.
2273 %
2274 % \item An empty |\hbox|.  This stops the following glue from being discarded
2275 % at the beginning of a new line.
2276 %
2277 % \item Another |\nobreak|, which stops a break at the following glue item.
2278 %
2279 % \item The dotted |\leaders|, which have |\hfill| stretchiness.  This forces
2280 % the page number to be flush right.
2281 %
2282 % \end{itemize}
2283 %
2284 % The net result of all this is we can now cope with a line break at the
2285 % end of the title, before the page number, which means that the dots are
2286 % put on the next line.  The original \LaTeX\ version forced the last word
2287 % of the title onto the next line as well, which can cause underful boxes.
2288 %
2289 %    \begin{macrocode}
2290       \nobreak\hfil\penalty\@highpenalty\hbox{}\nobreak%
2291       \leaders\hbox{$\m@th\mkern\@dotsep mu.\mkern\@dotsep mu$}\hfill%
2292       \hb@xt@\@pnumwidth{\hfil\reset@font\rmfamily#5}\par%
2293     }%
2294   \fi%
2295 }
2296 %    \end{macrocode}
2297 % \end{macro}
2298 %
2299 % \subsection{Lists of figures and tables}
2300 %
2301 % These macros are terribly similar to the other ones.
2302 %
2303 %    \begin{macrocode}
2304 \newcommand\listoffigures{\@tocthing\listfigurename{lof}}
2305 \newcommand\l@figure{\@dottedtocline{0}{0pt}{2em}}
2306 \newcommand\listoftables{\@tocthing\listtablename{lot}}
2307 \let\l@table\l@figure
2308 %    \end{macrocode}
2309 %
2310 % \section{Bibliography}
2311 %
2312 % This isn't actually terribly interesting.
2313 %
2314 % \begin{environment}{thebibliography}
2315 %
2316 %    \begin{macrocode}
2317 \newdimen\bibindent
2318 \bibindent1.5em
2319 %
2320 \newenvironment{thebibliography}[1]{%
2321   \@topsect\bibname%
2322   \list{\@biblabel{\arabic{enumiv}}}%
2323   {\settowidth\labelwidth{\@biblabel{#1}}%
2324   \leftmargin\labelwidth%
2325   \advance\leftmargin\labelsep%
2326   \if@openbib%
2327     \advance\leftmargin\bibindent%
2328     \itemindent-\bibindent%
2329     \listparindent\itemindent%
2330     \parsep\z@%
2331   \fi%
2332   \usecounter{enumiv}%
2333   \let\p@enumiv\@empty%
2334   \renewcommand\theenumiv{\arabic{enumiv}}}%
2335   \if@openbib%
2336     \renewcommand\newblock{\par}%
2337   \else%
2338     \renewcommand\newblock{\hskip.11em\@plus.33em\@minus.07em}%
2339   \fi%
2340   \sloppy%
2341   \clubpenalty4000%
2342   \widowpenalty4000%
2343   \sfcode`\.\@m%
2344 }{%
2345   \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
2346   \endlist%
2347 }
2348 %
2349 \newcommand\newblock{}
2350 %    \end{macrocode}
2351 % \end{environment}
2352 %
2353 % \section{Index}
2354 %
2355 % Defines the \env{theindex} environment.
2356 %
2357 % \begin{environment}{theindex}
2358 %
2359 % The macros are fairly simple.  We change to a two column layout, and
2360 % redefine |\item| appropriately.
2361 %
2362 %    \begin{macrocode}
2363 \newenvironment{theindex}{%
2364   \columnseprule\z@%
2365   \columnsep35\p@%
2366   \@topsect\indexname%
2367   \if@twocolumn\else%
2368     \begin{multicols}{2}%
2369   \fi%
2370   \parskip\z@\@plus.3\p@\relax%
2371   \raggedright%
2372   \let\item\@idxitem%
2373 }{%
2374   \if@twocolumn\else%
2375     \end{multicols}%
2376   \fi%
2377 }
2378 %    \end{macrocode}
2379 % \end{environment}
2380 %
2381 % Now we define the item and spacing macros.
2382 %
2383 %    \begin{macrocode}
2384 \newcommand\@idxitem  {\par\hangindent 40\p@}
2385 \newcommand\subitem   {\par\hangindent 40\p@ \hspace*{20\p@}}
2386 \newcommand\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
2387 \newcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}
2388 %    \end{macrocode}
2389 %
2390 % \begin{macro}{\passim}
2391 %
2392 % The |passim| encapsulator is used to typeset the word `\textit{passim}'
2393 % after a page range.
2394
2395 %    \begin{macrocode}
2396 \def\passim#1{#1 \textit{passim}}       % Passim encapsulator for indices
2397 %    \end{macrocode}
2398 % \end{macro}
2399 %
2400 % Other useful commands for indexing:
2401 %
2402 % \begin{description*}
2403 % \def\descriptionlabel#1{\ttfamily \bslash #1}
2404 %
2405 % \item[Term] typesets its argument in italics, and adds it to the index.
2406 %
2407 % \item[term] typesets its first argument in italics, and adds its second
2408 %   to the index.
2409 %
2410 % \item[Index] typesets its argument normally, and adds it to the index.
2411 %
2412 % \end{description*}
2413 %
2414 %    \begin{macrocode}
2415 \def\Term#1{\emph{#1}\index{#1}}
2416 \def\term#1{\emph{#1}\index}
2417 \def\Index#1{#1\index{#1}}
2418 %    \end{macrocode}
2419 %
2420 % \section{Footnotes}
2421 %
2422 % \begin{macro}{\footnoterule}
2423 %
2424 % This macro typesets the rule above footnotes.  This is a bit more complex
2425 % than the default: we try and typeset the rule to be at most 1\,in wide,
2426 % although if the column isn't wide enough, we use $4\over10$~of the
2427 % box width instead.
2428 %
2429 %    \begin{macrocode}
2430 \def\footnoterule{%
2431   \@tempdima.4\columnwidth%
2432   \ifdim\@tempdima>1in\relax%
2433     \@tempdima1in\relax%
2434   \fi%
2435   \kern-3\p@%
2436   \hrule\@width\@tempdima%
2437   \kern2.6\p@%
2438 }
2439 %    \end{macrocode}
2440 % \end{macro}
2441 %
2442 % We number footnotes within chapters:
2443 %
2444 %    \begin{macrocode}
2445 \@addtoreset{footnote}{chapter}
2446 %    \end{macrocode}
2447 %
2448 % \begin{macro}{\@makefntext}
2449 %
2450 % This is the macro which actually typesets a footnote.  This is rather
2451 % complicated.  It's based on example code from \file{classes.dtx} which
2452 % doesn't actually work properly.
2453 %
2454 %    \begin{macrocode}
2455 \long\def\@makefntext#1{%
2456 %    \end{macrocode}
2457 %
2458 % First, we redefine |\par| to set up the correct paragraph shape.  This
2459 % is indented from the left margin by a small amount.
2460 %
2461 %    \begin{macrocode}
2462   \@setpar{%
2463     \@@par%
2464     \@tempdima\hsize%
2465     \advance\@tempdima-1.6em%
2466     \parshape\@ne1.6em\@tempdima%
2467   }%
2468 %    \end{macrocode}
2469 %
2470 % Now we set up some parameters so that \env{list} environments work properly
2471 % within the footnote.  We also clear |\parindent| to prevent nasty
2472 % indentation.  The |\par| sets up the paragraph shape for the next
2473 % paragraph: we're in vertical mode already, so it does nothing else.
2474 %
2475 %    \begin{macrocode}
2476   \advance\linewidth-1.6em%
2477   \advance\@totalleftmargin1.6em%
2478   \par%
2479   \parindent\z@%
2480 %    \end{macrocode}
2481 %
2482 % We leave vertical mode to stop the hbox created by |\llap| from being
2483 % stacked vertically.  Then we typeset the footnote mark, and put in the
2484 % main text.  Finally we leave some space afterwards, to space out the next
2485 % footnote.
2486 %
2487 %    \begin{macrocode}
2488   \leavevmode%
2489   \llap{\@makefnmark\enspace}#1\par%
2490   \vskip\parskip%
2491 }
2492 %    \end{macrocode}
2493 % \end{macro}
2494 %
2495 % \begin{macro}{\@makecol}
2496 %
2497 % The standard \LaTeX\ output routine messes up footnotes a bit, in my
2498 % opinion:
2499 % \begin{itemize}
2500 %
2501 % \item If a page is cut off short, because the next item won't fit (e.g.,
2502 %       a section heading), then footnotes are added right below the end
2503 %       of the text, which can look strange.
2504 %
2505 % \item Footnotes are displayed \emph{above} floats at the bottom of a page,
2506 %       which also looks strange.
2507 %
2508 % \item The |\@makefntext| routine above needs to add vertical space between
2509 %       footnotes, but this leaves a gap at the very bottom.  We remove this
2510 %       gap with an |\unskip|.
2511 %
2512 % \end{itemize}
2513 %
2514 %    \begin{macrocode}
2515 \def\@makecol{%
2516    \setbox\@outputbox \box\@cclv
2517    \xdef\@freelist{\@freelist\@midlist}%
2518    \global \let \@midlist \@empty
2519    \@combinefloats
2520    \ifvoid\footins \else
2521      \setbox\@outputbox \vbox {%
2522        \boxmaxdepth \@maxdepth                   
2523        \unvbox \@outputbox
2524        \vskip \skip\footins
2525        \vfil
2526        \footnoterule
2527        \unvbox \footins
2528        \unskip
2529        }%
2530    \fi
2531    \ifvbox\@kludgeins
2532      \@makespecialcolbox
2533    \else
2534      \setbox\@outputbox \vbox to\@colht {%
2535        \@texttop
2536        \dimen@ \dp\@outputbox
2537        \unvbox \@outputbox
2538        \vskip -\dimen@
2539        \@textbottom
2540        }%
2541    \fi
2542    \global \maxdepth \@maxdepth
2543 }
2544 %    \end{macrocode}
2545 % \end{macro}
2546 %
2547 % \section{Tidying up}
2548 %
2549 % This section gathers together various other useful bits of standard
2550 % document class setting.
2551 %
2552 % \subsection{Item names}
2553 %
2554 % These commands typeset bits of text.  They can then be redefined by
2555 % \package{babel} and suchlike.
2556 %
2557 %    \begin{macrocode}
2558 \newcommand\contentsname{Contents}
2559 \newcommand\listfigurename{List of figures}
2560 \newcommand\listtablename{List of tables}
2561 \if@article\newcommand\bibname{References}
2562 \else\newcommand\bibname{Bibliography}\fi
2563 \newcommand\indexname{Index}
2564 \newcommand\figurename{Figure}
2565 \newcommand\tablename{Table}
2566 \newcommand\partname{Part}
2567 \newcommand\abstractname{Abstract}
2568 \newcommand\chaptername{Chapter}
2569 \newcommand\appendixname{Appendix}
2570 \newcommand\today{\number\day\space\ifcase\month\or
2571   January\or February\or March\or April\or May\or June\or
2572   July\or August\or September\or October\or November\or December\fi
2573   \space\number\year}
2574 %    \end{macrocode}
2575 %
2576 % \subsection{Final fiddling for two columns}
2577 %
2578 %    \begin{macrocode}
2579 \columnsep10\p@
2580 \columnseprule\z@
2581 \pagestyle{headings}
2582 \pagenumbering{arabic}      % Arabic page numbers
2583 \if@twocolumn
2584   \twocolumn
2585   \sloppy
2586   \flushbottom
2587 \else
2588   \onecolumn
2589 \fi
2590 %    \end{macrocode}
2591 %
2592 % \section{The \protect\env{central} environment}
2593 %
2594 % Because of the strange layout of the pages, text which is centred using
2595 % normal \LaTeX\ commands is centred in the text area, not on the page,
2596 % which is undesirable for large headings, like part headings.
2597 %
2598 % \begin{environment}{central}
2599 %
2600 % The \env{central} environment typesets its contents centrally on the page.
2601 % It should only be used from outer vertical mode.
2602 %
2603 % The code just creates a box of the appropriate size and moves it into the
2604 % right place.
2605 %
2606 %    \begin{macrocode}
2607 \newenvironment{central}{%
2608   \par%
2609   \vbox\bgroup\moveleft\leftindent\vbox\bgroup%
2610   \textwidth\paperwidth%
2611   \advance\textwidth-2\pagesurround\relax%
2612   \hsize\textwidth%
2613   \hrule\@height\z@\@depth\z@\@width\hsize%
2614 }{%
2615   \egroup%
2616   \egroup%
2617 }
2618 %    \end{macrocode}
2619 % \end{environment}
2620 %
2621 % \section{Headers and footers}
2622 %
2623 % The \strayman\ class uses \package{fancyheadings} for its headers
2624 % and footers.  This has already been included in the preamble.  We now
2625 % need to fix a few problems with \package{fancyheadings} and set up some
2626 % macros.
2627 %
2628 % \begin{macro}{\title}
2629 %
2630 % We extend |\title|, and give it an optional argument.  It can now specify
2631 % the document title as used by |\maketitle| and the running title for the
2632 % header separately.
2633 %
2634 % We store the running header in the macro |\@headertitle|, which is
2635 % initially empty.
2636 %
2637 %    \begin{macrocode}
2638 \def\@headertitle{}
2639 %    \end{macrocode}
2640 %
2641 % Now we define the |\title| macro, using |\@dblarg| to duplicate the
2642 % mandatory argument if the optional one is omitted.
2643 %
2644 %    \begin{macrocode}
2645 \def\title{\@dblarg\title@i}
2646 \def\title@i[#1]#2{%
2647   \gdef\@title{#2}%
2648   \gdef\@headertitle{#1}%
2649 }
2650 %    \end{macrocode}
2651 % \end{macro}
2652 %
2653 % \begin{macro}{\innerhead}
2654 % \begin{macro}{\innerfoot}
2655 %
2656 % We allow the user to specify an `inner heading' which is displayed on the
2657 % inside of the header on of each page.  This can be used for security
2658 % classifications, for example.  Any \package{fancyheadings} commands can
2659 % be used to control the header, which is expanded on each page.
2660 %
2661 %    \begin{macrocode}
2662 \def\l@innerhead{}
2663 \def\r@innerhead{}
2664 \def\l@innerfoot{}
2665 \def\r@innerfoot{}
2666 \def\innerhead{\@dblarg\innerhead@i}
2667 \def\innerhead@i[#1]#2{%
2668   \def\l@innerhead{#1}%
2669   \def\r@innerhead{#2}%
2670 }
2671 \def\innerfoot{\@dblarg\innerfoot@i}
2672 \def\innerfoot@i[#1]#2{%
2673   \def\l@innerfoot{#1}%
2674   \def\r@innerfoot{#2}%
2675 }
2676 %    \end{macrocode}
2677 % \end{macro}
2678 % \end{macro}
2679 %
2680 % The next step is to set up the headings:
2681 %
2682 %    \begin{macrocode}
2683 \let\headrulewidth\z@
2684 \headwidth\textwidth
2685   \advance\headwidth\leftindent
2686 \fancypagestyle{headings}{%
2687   \fancyhf{}
2688   \fancyhead[LE]{\bfseries\@headertitle}
2689   \if@article\fancyhead[RO]{\rightmark}\else\fancyhead[RO]{\leftmark}\fi
2690   \fancyhead[RE]{\l@innerhead} \fancyhead[LO]{\r@innerhead}
2691   \fancyfoot[RE]{\l@innerfoot} \fancyfoot[LO]{\r@innerfoot}
2692   \fancyfoot[LE,RO]{\thepage}
2693 }
2694 \fancypagestyle{plain}{%
2695   \fancyhf{}%
2696   \fancyfoot[RE]{\l@innerfoot} \fancyfoot[LO]{\r@innerfoot}
2697   \fancyfoot[LE,RO]{\thepage}%
2698 }
2699 \let\ps@fancy\ps@@fancy
2700 %    \end{macrocode}
2701 %
2702 % The \package{fancyheadings} package by default expects pages to be
2703 % symmetrical.  We have to redefine the |\ps@fancy| macro to make it
2704 % work properly.
2705 %
2706 %    \begin{macrocode}
2707 \def\@lodd{\ifodd\c@page\hss\else\relax\fi}
2708 \def\@rodd{\ifodd\c@page\relax\else\hss\fi}
2709 %    \end{macrocode}
2710 %
2711 % Finally, we can choose the page style we want:
2712 %
2713 %    \begin{macrocode}
2714 \pagestyle{headings}
2715 %    \end{macrocode}
2716 %
2717 % \section{Parbox alteration}
2718 %
2719 % The standard \LaTeX\ |\parbox| command, and the \env{minipage} environment,
2720 % reset |\parskip| to zero, which is inconsistent with the document style.
2721 % We amend |\@arrayparboxrestore|, the macro which sets up the paragraph
2722 % style for parboxes.
2723 %
2724 % First, we define a macro explaining how the parbox should set the spacing.
2725 %
2726 %    \begin{macrocode}
2727 \def\parboxparskip{2ex}
2728 %    \end{macrocode}
2729 %
2730 % Next, we redefine the macro.  This is taken directly from the \LaTeXe
2731 % source.
2732 %
2733 %    \begin{macrocode}
2734 \def\@arrayparboxrestore{%
2735   \let\par\@@par
2736   \let\-\@dischyph
2737   \let\'\@acci\let\`\@accii\let\=\@acciii
2738   \parindent\z@ \parskip\z@
2739   \everypar{\parskip\parboxparskip\everypar{}}%
2740   \linewidth\hsize
2741   \@totalleftmargin\z@ 
2742   \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip
2743   \parfillskip\@flushglue \lineskip\normallineskip
2744   \baselineskip\normalbaselineskip
2745   \@noskipsectrue%      % The comp.text.tex gurus said it should be
2746   \sloppy}
2747 %    \end{macrocode}
2748 %
2749 %
2750 % \section{Other features}
2751 %
2752 % At the end is a miscellany of useful features.
2753 %
2754 % \subsection{Other typesetting conventions}
2755 %
2756 % Some items need typesetting in particular ways.
2757 %
2758 %    \begin{macrocode}
2759 \let\key\textit
2760 \let\button\textbf
2761 \def\submenu{\ensuremath\Rightarrow}
2762 \let\name\relax
2763 \def\file#1{\mbox{\itshape #1\/}}
2764 %    \end{macrocode}
2765 %
2766 % \subsection{And finally}
2767 %
2768 %    \begin{macrocode}
2769 \sloppy
2770 \raggedbottom
2771 \def\riscos{RISC~OS}
2772 \hyphenpenalty1000
2773 %</strayman>
2774 %    \end{macrocode}
2775 %
2776 % \Finale
2777 %
2778 \endinput