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