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