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