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