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