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