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