strayman.dtx: Format part headings correctly in article mode.
[strayman] / strayman.dtx
CommitLineData
1ffa9044 1% \begin{meta-comment}
2%
186f3b71 3% $Id: strayman.dtx,v 1.4 2003/11/07 11:32:53 mdw Exp $
1ffa9044 4%
e8c85bbe 5% Document class for Straylight manuals
1ffa9044 6%
e8c85bbe 7% (c) 1996 Straylight
1ffa9044 8%
1ffa9044 9% \end{meta-comment}
10%
11% \begin{meta-comment} <general public licence>
12%%
e8c85bbe 13%% strayman -- a LaTeX document class for Straylight manuals
14%% Copyright (c) 1996 Straylight
1ffa9044 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}
c3f26ad3 35%<+strayman> [2003/09/04 1.10 Straylight document class]
1ffa9044 36% \end{meta-comment}
37%
35d0f966 38% \CheckSum{3167}
1ffa9044 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>
29384960 59\documentclass[10pt,a4paper,book,nohyperref]{strayman}
1ffa9044 60\input{mdwtools}
61\usepackage{mdwlist}
62\describesclass{strayman}
0ef5b158 63\errorcontextlines\maxdimen
1ffa9044 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.
8a0490fb 79% The \strayman\ document class is an attempt to rectify this situation,
1ffa9044 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%
1ffa9044 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
b8d14be9 188\newif\if@titlepage\@titlepagefalse
1ffa9044 189\newif\if@openright\@openrighttrue
190\newif\if@openbib\@openbibfalse
191\newif\if@appendix\@appendixfalse
b8d14be9 192\newif\if@article\@articletrue
1ffa9044 193\newif\if@offsetpages\@offsetpagestrue
b8d14be9
MW
194\newif\if@numbering\@numberingtrue
195\newif\if@herefloats\@herefloatsfalse
196\newif\if@runinsubsubsec\@runinsubsubsectrue
29384960 197\newif\if@hyperref\@hyperreftrue
0ef5b158 198\newif\if@indentpar
1ffa9044 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}
b8d14be9 281\DeclareOption{noarticle}{\@articlefalse}
1ffa9044 282\DeclareOption{numbering}{\@numberingtrue}
283\DeclareOption{nonumbering}{\@numberingfalse}
284\DeclareOption{runinsubsubsec}{\@runinsubsubsectrue}
285\DeclareOption{noruninsubsubsec}{\@runinsubsubsecfalse}
0ef5b158
MW
286\DeclareOption{indentpar}{\@indentpartrue}
287\DeclareOption{noindentpar}{\@indentparfalse}
b8d14be9 288\DeclareOption{book}{\@titlepagetrue\@articlefalse}
29384960
MW
289\DeclareOption{hyperref}{\@hyperreftrue}
290\DeclareOption{nohyperref}{\@hyperreffalse}
1ffa9044 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}
b8d14be9 298\ExecuteOptions{a4paper,10pt,twoside,onecolumn,final}
1ffa9044 299\ProcessOptions
300% \end{macrocode}
301%
302% If this is PDF\TeX\ then tell it the page bounds.
303%
304% \begin{macrocode}
b8d14be9
MW
305\newif\ifpdfing\pdfingfalse
306\if1\ifx\pdfoutput\@@undefined@@0\else\the\pdfoutput\fi
307 \pdfingtrue
308\fi
309\ifpdfing
1ffa9044 310 \pdfpageheight\paperheight
311 \pdfpagewidth\paperwidth
29384960
MW
312\fi
313\if@hyperref
b8d14be9
MW
314 \AtEndOfClass{%
315 \RequirePackage[%
29384960 316 bookmarks = true, bookmarksnumbered = true, bookmarksdepth = 3,
a6bb7088 317 colorlinks = true, linkcolor = blue, citecolor = blue, urlcolor = blue,
29384960 318 breaklinks = true]{hyperref}
b8d14be9 319 }
29384960
MW
320 \ifpdfing
321 \PassOptionsToPackage{pdftex}{hyperref}
322 \else
323 \PassOptionsToPackage{dvips}{hyperref}
324 \fi
b8d14be9 325\fi
1ffa9044 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}
0ef5b158
MW
377\newskip\@parskip
378\newdimen\@parshortfall
1ffa9044 379\def\@setparskip{%
0ef5b158
MW
380 \@parskip.67\baselineskip\@plus\p@\relax%
381 \ifdim\parskip=\z@\else\parskip\@parskip\relax\fi%
382 \@parshortfall\@parskip\advance\@parshortfall-\parskip%
1ffa9044 383}
0ef5b158 384\def\set@vsep#1{#1\@parshortfall\advance#1}
1ffa9044 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>
186f3b71 395 \@setfontsize\normalsize\@viiipt{9.6\p@}%
1ffa9044 396 \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
0ef5b158
MW
397 \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
398 \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
1ffa9044 399%</8pt>
400%<*9pt>
401 \@setfontsize\normalsize\@ixpt\@xipt%
402 \abovedisplayskip9\p@\@plus2\p@\@minus5\p@%
0ef5b158
MW
403 \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
404 \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
1ffa9044 405%</9pt>
406%<*10pt>
407 \@setfontsize\normalsize\@xpt\@xiipt%
408 \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
0ef5b158
MW
409 \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
410 \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
1ffa9044 411%</10pt>
412%<*11pt>
413 \@setfontsize\normalsize\@xipt{13.6}%
414 \abovedisplayskip11\p@\@plus3\p@\@minus6\p@%
0ef5b158
MW
415 \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
416 \set@vsep\belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
1ffa9044 417%</11pt>
418%<*12pt>
419 \@setfontsize\normalsize\@xiipt{14.5}%
420 \abovedisplayskip12\p@\@plus3\p@\@minus7\p@%
0ef5b158
MW
421 \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
422 \set@vsep\belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
1ffa9044 423%</12pt>
424%<*text>
425 \@setfontsize\normalsize\@xpt\@xiipt%
426 \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
0ef5b158
MW
427 \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
428 \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
1ffa9044 429%</text>
430 \belowdisplayskip\abovedisplayskip%
431 \let\@listi\@listI%
432 \@setparskip%
433}
434\normalsize
0ef5b158
MW
435\if@indentpar
436 \parskip0pt\@plus\p@
437\else
438 \parskip2ex\@plus\p@
439\fi
1ffa9044 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@%
0ef5b158
MW
456 \set@vsep\abovedisplayshortskip\z@\@plus2\p@%
457 \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
1ffa9044 458%</8pt>
459%<*9pt>
460 \@setfontsize\small\@viiipt{9.5}%
461 \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
0ef5b158
MW
462 \set@vsep\abovedisplayshortskip\z@\@plus2\p@%
463 \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
1ffa9044 464%</9pt>
465%<*10pt>
466 \@setfontsize\small\@ixpt{11}%
467 \abovedisplayskip8.5\p@\@plus3\p@\@minus4\p@%
0ef5b158
MW
468 \set@vsep\abovedisplayshortskip\z@\@plus2\p@%
469 \set@vsep\belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
1ffa9044 470%</10pt>
471%<*11pt>
472 \@setfontsize\small\@xpt\@xiipt%
473 \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
0ef5b158
MW
474 \set@vsep\abovedisplayshortskip\z@\@plus3\p@%
475 \set@vsep\belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
1ffa9044 476%</11pt>
477%<*12pt>
478 \@setfontsize\small\@xipt{13.6}%
479 \abovedisplayskip11\p@\@plus3\p@\@minus6\p@%
0ef5b158
MW
480 \set@vsep\abovedisplayshortskip\z@ \@plus3\p@%
481 \set@vsep\belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
1ffa9044 482%</12pt>
483 \def\@listi{%
484 \leftmargin\leftmargini%
0ef5b158
MW
485 \topsep\@parshortfall%
486 \parsep\@parskip%
1ffa9044 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%
0ef5b158
MW
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@%
1ffa9044 510%</8pt>
511%<*9pt>
512 \@setfontsize\footnotesize\@viipt{8.4}%
0ef5b158
MW
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@%
1ffa9044 516%</9pt>
517%<*10pt>
518 \@setfontsize\footnotesize\@viiipt{9.5}%
0ef5b158
MW
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@%
1ffa9044 522%</10pt>
523%<*11pt>
524 \@setfontsize\footnotesize\@ixpt{11}%
0ef5b158
MW
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@%
1ffa9044 528%</11pt>
529%<*12pt>
530 \@setfontsize\footnotesize\@xpt\@xiipt
0ef5b158
MW
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@%
1ffa9044 534%</12pt>
535 \def\@listi{%
536 \leftmargin\leftmargini%
0ef5b158
MW
537 \topsep\@parshortfall%
538 \parsep\@parskip%
1ffa9044 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}
1ffa9044 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}
1ffa9044 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}
1ffa9044 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}
1ffa9044 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
1ffa9044 597%</12pt>
c3f26ad3 598%<+8pt|9pt|10pt|11pt|12pt>\let\listingsize\footnotesize
1ffa9044 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%
0ef5b158 639% Paragraph indentation is set up later.
1ffa9044 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}
fddb126a 778%
1ffa9044 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
420183b8
MW
856\def\chaptermark##1{\markboth {\thechapter. ##1}{}}%
857\def\sectionmark##1{\markright {\thesection. ##1}}%
1ffa9044 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%
fddb126a 982% The \env{titlepage} environment typesets its contents on a title page.
1ffa9044 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}
35d0f966
MW
1172\if@article
1173 \newcommand\part{%
1174 \if@noskipsec\leavevmode\fi\par%
1175 \addvspace{4ex}%
1176 \@afterindentfalse
1177 \secdef\@part\@spart%
1178 }
1179\else
1180 \newcommand\part{%
1181 \cleardoublepage%
1182 \thispagestyle{empty}%
1183 \if@twocolumn%
1184 \onecolumn%
1185 \@tempswatrue%
1186 \else%
1187 \@tempswafalse%
1188 \fi%
1189 \hbox{}\vfil%
1190 \secdef\@part\@spart%
1191 }
1192\fi
1ffa9044 1193% \end{macrocode}
1194%
1195% \begin{macro}{\@part}
1196%
1197% This is where most of the part heading typesetting is done. We stick a
1198% line in the contents file, clear the heading markers, and typeset the
1199% heading in the biggest letters we can find. When we're done, we call
1200% |\@endpart| to do some common cleaning up.
1201%
1202% \begin{macrocode}
35d0f966
MW
1203\if@article
1204 \def\@part[#1]#2{%
1205 \ifnum\c@secnumdepth>\m@ne\relax%
1206 \refstepcounter{part}%
1207 \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
1208 \else%
1209 \addcontentsline{toc}{part}{#1}%
1210 \fi%
1211 \begingroup%
1212 \parindent\z@ \raggedright \interlinepenalty\@M%
1213 \reset@font\bfseries\headfam%
1214 \ifnum\c@secnumdepth>\m@ne%
1215 \Large\partname\nobreakspace\thepart \par\nobreak%
1216 \fi%
1217 \huge #2%
1218 \markboth{}{}\par%
1219 \endgroup%
1220 \nobreak \vskip3ex \@afterheading%
1221 }
1222\else
1223 \def\@part[#1]#2{%
1224 \ifnum\c@secnumdepth>-2\relax%
1225 \refstepcounter{part}%
1226 \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
1227 \else%
1228 \addcontentsline{toc}{part}{#1}%
1229 \fi%
1230 \markboth{}{}%
1231 \begin{centrepage}%
1232 \centering%
1233 \interlinepenalty\@M%
1234 \reset@font%
1235 \ifnum\c@secnumdepth>-2\relax%
1236 \huge\bfseries\headfam\partname~\thepart%
1237 \par%
1238 \vskip20\p@
1239 \fi%
1240 \normalfont\Huge\bfseries\headfam#2\par%
1241 \@endpart%
1242 }
1243\fi
1ffa9044 1244% \end{macrocode}
1245% \end{macro}
1246%
1247% \begin{macro}{\@spart}
1248%
1249% Here we typeset just the part heading: numbers have been suppressed. Also
1250% we don't put things into the contents file. Otherwise, this is similar to
1251% |\@part|.
1252%
1253% \begin{macrocode}
35d0f966
MW
1254\if@article
1255 \def\@spart#1{%
1256 \begingroup%
1257 \parindent\z@ \raggedright \interlinepenalty\@M%
1258 \reset@font\bfseries\headfam%
1259 \huge #1%
1260 \markboth{}{}\par%
1261 \endgroup%
1262 \nobreak \vskip3ex \@afterheading%
1263 }
1264\else
1265 \def\@spart#1{%
1266 \begin{centrepage}%
1267 \centering%
1268 \interlinepenalty\@M%
1269 \reset@font%
1270 \normalfont\Huge\bfseries\headfam#1\par%
1271 \@endpart%
1272 }
1273\fi
1ffa9044 1274% \end{macrocode}
1275% \end{macro}
1276%
1277% \begin{macro}{\@endpart}
1278%
1279% This does the clearing up operation after a part has been typeset. We
1280% insert the other |\vfil| glue to centre the heading, clear the other
1281% side of the page, if printing two-sided, and return if necessary to
1282% two-column printing.
1283%
1284% \begin{macrocode}
1285\def\@endpart{%
1286 \vfil\newpage%
1287 \end{centrepage}%
1288 \if@twoside%
1289 \hbox{}%
1290 \thispagestyle{empty}%
1291 \newpage%
1292 \fi%
1293 \if@tempswa%
1294 \twocolumn%
1295 \fi%
1296}
1297% \end{macrocode}
1298% \end{macro}
1299% \end{macro}
1300%
1301% \subsection{Chapters}
1302%
1303% The chapter typesetting has been more-or-less rewritten. We'll follow this
1304% in a reasonable amount of detail.
1305%
1306% \begin{macro}{\@chapapp}
1307%
1308% Because |\appendix| needs to change what chapters are called, we add a
1309% level of indirection through |\@chapapp|:
1310%
1311% \begin{macrocode}
1312\newcommand\@chapapp{\chaptername}
1313% \end{macrocode}
1314% \end{macro}
1315%
1316% \begin{macro}{\chapter}
1317%
1318% The |\chapter| command is the main dispatcher for chapters. We move to
1319% an appropriate page, depending on the |openright| setting, suppress
1320% headers, and then call |\@chapter| or |\@schapter| as appropriate.
1321%
1322% \begin{macrocode}
1323\newcommand\chapter{%
1324 \if@openright%
1325 \cleardoublepage%
1326 \else%
1327 \clearpage%
1328 \fi%
1329 \thispagestyle{plain}%
1330 \global\@topnum\z@%
1331 \@afterindentfalse%
1332 \secdef\@chapter\@schapter%
1333}
1334% \end{macrocode}
1335%
1336% \begin{macro}{\@chapter}
1337%
1338% There's a lot of messing about to do, depending on whether we're in the
1339% main matter and so on. We'll take this carefully.
1340%
1341% \begin{macrocode}
1342\def\@chapter[#1]#2{%
1343% \end{macrocode}
1344%
1345% The first thing to do is put a line in the contents table. We need to
1346% check |secnumdepth| and the |mainmatter| flag for this: we should only
1347% include a number if both these tests pass. In this case, we also type a
1348% message on the terminal.
1349%
1350% \begin{macrocode}
1351 \ifnum\c@secnumdepth>\m@ne%
1352 \if@mainmatter%
1353 \refstepcounter{chapter}%
1354 \typeout{\@chapapp\space\thechapter.}%
1355 \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
1356 \else
1357 \addcontentsline{toc}{chapter}{#1}%
1358 \fi
1359 \else
1360 \addcontentsline{toc}{chapter}{#1}
1361 \fi
1362% \end{macrocode}
1363%
1364% Now we put a bit of space in the lists of figures and tables, and set up
1365% the mark to put the chapter heading in the running header.
1366% \begin{macrocode}
1367 \chaptermark{#1}%
1368 \addtocontents{lof}{\protect\addvspace{10\p@}}%
1369 \addtocontents{lot}{\protect\addvspace{10\p@}}%
1370% \end{macrocode}
1371%
1372% Finally, we need to decide how to typeset the chapter heading. On
1373% single-column chapters, this is easy. On double-column formats, we need
1374% to do horrid things with |\@topnewpage|.
1375%
1376% \begin{macrocode}
1377 \if@twocolumn%
1378 \@topnewpage[\@makechapterhead{%
1379 \hb@xt@.5\leftindent{\thechapter\hfil}%
1380 }{#2}]%
1381 \else%
1382 \@makechapterhead{%
1383 \hb@xt@.5\leftindent{\thechapter\hfil}%
1384 }{#2}%
1385 \@afterheading%
1386 \fi%
1387}
1388% \end{macrocode}
1389% \end{macro}
1390%
1391% \begin{macro}{\@makechapterhead}
1392%
1393% This macro actually does the job of typesetting a chapter heading. Call
1394% this routine as |\@makechapterhead{|\synt{number}|}{|\synt{title}|}|.
1395% Here, \synt{number} is how to typeset the chapter number, and \synt{title}
1396% is the rest of the title. To suppress the number, just leave \synt{number}
1397% empty. The number is only typeset when it is correct to do so anyway.
1398%
1399% The spacing is rather awkward. We have to cope with two-column layouts,
1400% which seem to require different spacing. In a double-column layout,
1401% the title is normally one |\baselineskip| too high. Also, the space I
1402% add at the bottom of the heading gets eaten in double-column chapters,
1403% because I'm actually typesetting into a vbox which is floated to the top
1404% by \LaTeX\ in a fairly horrid way. This can't really be worked around,
1405% so we just make the space beneath the heading equal to |\dbltextfloatsep|,
1406% which is what gets added anyway.
1407%
1408% The other snags are to do with the rule after the chapter heading.
1409% Firstly, this is meant to be typeset into the left margin, like the
1410% heading itself, which is a bit messy. More awkwardly, we have to be
1411% careful not to let the depth of the line vary when the chapter heading has
1412% descenders, although obviously we must lower the rule if the heading really
1413% is very deep indeed.
1414%
fddb126a 1415%
1ffa9044 1416% We'll approach this a bit at a time.
1417%
1418% \begin{macrocode}
1419\def\@makechapterhead#1#2{%
1420 \begingroup% % Stop my hacking messing things up
1421% \end{macrocode}
1422%
1423% First, the top spacing. This is divided into two parts, by an invisible
1424% rule: the |\vskip| above the rule is eaten by \TeX\ if this is a genuine
1425% new page, but put into the floating vbox if this is a two-column affair.
1426% The second bit is added in both cases.
1427%
1428% \begin{macrocode}
1429 \vskip\baselineskip% % This is gobbled in single column
1430 \hrule\@height\z@% % Stops TeX from binning my vskips
1431 \vskip32\p@% % Start chapters in a funny place
1432% \end{macrocode}
1433%
1434% Now we actually typeset the heading. This is fairly simple: we must just
1435% check that we need to typeset the number.
1436%
1437% \begin{macrocode}
1438 \normalfont\Huge\bfseries\headfam% % Choose a nice font for it
1439 \raggedright % Don't justify -- it looks nasty
1440 \@hangfrom{\hskip-\leftindent}% % Start text at `real left margin'
1441 \ifnum\c@secnumdepth>\m@ne% % Do we typeset chapter numbers?
1442 \if@mainmatter% % Are we past the front matter?
1443 #1% % Yes -- then typeset the number
1444 \fi\fi% % Now back to normality
1445 {#2}% % Typeset the actual chapter head
1446 \par\nobreak% % Back to vmode again, please
1447% \end{macrocode}
1448%
1449% The next tricky bit is the space before the ruleoff. We must be careful
1450% here:
1451%
1452% \begin{itemize}
1453%
1454% \item We want the rule to be the right depth below the heading baseline,
1455% regardless of whether the heading contains descenders: helpfully, \TeX\
1456% omits |\baselineskip| glue before and after rules.
1457%
1458% \item We want the rule to always be below any oddly deep descenders that
1459% a strange user might throw at us (e.g., horrid fractions or weird
1460% |\vrule|s).
1461%
1462% \end{itemize}
1463%
1464% We accomplish this by scrutinising |\prevdepth| carefully.
1465%
1466% \begin{macrocode}
1467 \@tempdima14\p@% % Be this low below the baseline
1468 \advance\@tempdima-\prevdepth% % This is the actual skip then
1469 \ifdim\@tempdima<8\p@% % Is this not enough skippage?
1470 \@tempdima8\p@% % No: then skip some more
1471 \fi%
1472 \vskip\@tempdima% % Skip a bit below the title
1473% \end{macrocode}
1474%
1475% Now we can set the rule. This needs a little care.
1476%
1477% \begin{macrocode}
1478 \@tempskipa\textwidth% % Find the width of the column
1479 \advance\@tempskipa\leftindent% % Add on the big lefthand gap
1480 \nointerlineskip% % Don't add any more space please
1481 \moveleft\leftindent\vbox{% % Shift something left by an amount
1482 \hrule\@width\@tempskipa% % Typeset the rule nicely
1483 }%
1484 \nointerlineskip% % Don't leave a gap beneath it
1485% \end{macrocode}
1486%
1487% Finally, we leave a gap. In two-column layouts this is done for us, and
1488% \LaTeX\ gobbles this glue and replaces it with |\dbltextfloatsep|. To make
1489% things consistent, this is the glue we use anyway.
1490%
1491% \begin{macrocode}
1492 \nobreak% % This would be a bad place to break
1493 \vspace{\dbltextfloatsep}% % Add in some extra glue beneath
1494 \endgroup%
1495}
1496% \end{macrocode}
1497% \end{macro}
1498%
1499% \begin{macro}{\@makeschapterhead}
1500%
1501% This is now just a veneer onto |\@makechapterhead|. It's needed, because
1502% other bits of \LaTeX\ call it.
1503%
1504% \begin{macrocode}
1505\def\@makeschapterhead{%
1506 \@makechapterhead{}
1507}
1508% \end{macrocode}
1509% \end{macro}
1510%
1511% \begin{macro}{\@schapter}
1512%
1513% This macro typesets a starred chapter heading. This is terribly simple,
1514% compared to the sort of things we've been doing so far.
1515%
1516% \begin{macrocode}
1517\def\@schapter#1{%
1518 \if@twocolumn%
1519 \@topnewpage[\@makeschapterhead{#1}]%
1520 \else%
1521 \@makeschapterhead{#1}%
1522 \@afterheading%
1523 \fi%
1524}
1525% \end{macrocode}
1526% \end{macro}
1527% \end{macro}
1528%
1529% \subsection{The other sectioning commands}
1530%
1531% These are all defined through |\@startsection|. They've been modified
1532% to typeset sections and subsections hanging into the left margin, and to
1533% moderate the amount of following space, due to the extra |\parskip| already
1534% introduced.
1535%
1536% \begin{macrocode}
0ef5b158
MW
1537\def\@defsection#1#2#3#4#5#6{%
1538 \expandafter\newcommand\csname#1\endcsname{%
1539 \skip@#4\advance\skip@\ifdim\skip@<\z@-\fi\@parshortfall%
1540 \skip\tw@#5\relax\ifdim\skip\tw@>\z@\advance\skip\tw@\@parshortfall\fi%
1541 \@startsection%
1542 {#1}%
1543 {#2}%
1544 {#3}%
1545 \skip@
1546 {\skip\tw@}%
1547 {\reset@font#6\bfseries\headfam}%
1548 }%
1549}
1550\@defsection
1ffa9044 1551 {section}% % Section name (for contents)
1552 {1}% % Level number (for numbering)
1553 {-.5\sectindent}% % Indentation of title
1554 {-1.5ex\@plus-1ex\@minus-.2ex}% % Space after title (vert/horiz)
1555 {.3ex\@plus.2ex}% % Space before title
1556 {\reset@font\Large\bfseries\headfam}% How to typeset the title
0ef5b158 1557\@defsection
1ffa9044 1558 {subsection}%
1559 {2}%
1560 {-.25\sectindent}%
1561 {-1.25ex\@plus-1ex\@minus-.2ex}%
1562 {\p@\@plus.2ex}%
1563 {\reset@font\large\bfseries\headfam}%
1ffa9044 1564\if@runinsubsubsec
0ef5b158 1565\@defsection
1ffa9044 1566 {subsubsection}%
1567 {3}%
1568 {\z@}%
1569 {0pt\@plus1ex\@minus.2ex}%
1570 {-1em}%
1571 {\reset@font\normalsize\bfseries\headfam}%
0ef5b158 1572\@defsection
1ffa9044 1573 {paragraph}%
1574 {4}%
1575 {\z@}%
1576 {0pt\@plus.5ex\@minus.1ex}%
1577 {-1em}%
1578 {\reset@font\normalsize\bfseries\headfam}%
0ef5b158 1579\@defsection
1ffa9044 1580 {subparagraph}%
1581 {5}%
1582 {\parindent}%
1583 {0pt\@plus.5ex\@minus.1ex}%
1584 {-1em}%
1585 {\reset@font\normalsize\bfseries\headfam}%
1ffa9044 1586\else
0ef5b158 1587\@defsection
1ffa9044 1588 {subsubsection}%
1589 {3}%
1590 {\z@}%
1591 {-1.25ex\@plus-1ex\@minus-.2ex}%
1592 {\p@\@plus.2ex}%
1593 {\reset@font\normalsize\bfseries\headfam}%
0ef5b158 1594\@defsection
1ffa9044 1595 {paragraph}%
1596 {4}%
1597 {\z@}%
1598 {0pt\@plus1ex\@minus.2ex}%
1599 {-1em}%
1600 {\reset@font\normalsize\bfseries\headfam}%
0ef5b158 1601\@defsection
1ffa9044 1602 {subparagraph}%
1603 {5}%
1604 {\parindent}%
1605 {0pt\@plus.5ex\@minus.1ex}%
1606 {-1em}%
1607 {\reset@font\normalsize\bfseries\headfam}%
1ffa9044 1608\fi
1609% \end{macrocode}
1610%
1611% \subsection{Section number formatting}
1612%
1613% \begin{macro}{\@seccntformat}
1614%
1615% The macro is given a section counter and must format it in some nice way.
1616%
1617% \begin{macrocode}
1618\def\@seccntformat#1{%
1619 \llap{\csname the#1\endcsname{\normalsize\quad}\hfil}%
1620}
1621%
1622% \subsection{Top level sectioning}
1623%
1624% \begin{macro}{\@topsect}
1625%
1626% Articles are divided into sections; other documents are divided into
1627% chapters. Things like the table of contents need to know which.
1628%
1629% \begin{macrocode}
1630\if@article
c3f26ad3 1631 \def\@topsect@star{\section*}
1632 \let\@topsect\section
1ffa9044 1633\else
c3f26ad3 1634 \let\@topsect@star\chapter
1ffa9044 1635 \let\@topsect\chapter
1636\fi
1637% \end{macrocode}
1638%
1639% \end{macro}
1640%
1641%
1642% \section{List handling}
1643%
1644% A surprising number of \LaTeX's environments are defined in terms of
1645% lists, many of which hide the fact by putting the entire text in one big
1646% item.
1647%
1648% This part of the document class has to set up lots of list parameters.
1649% This is largely the same as the standard classes, altered slightly to cope
1650% with the different paragraph spacing.
1651%
1652% \subsection{General list parameters}
1653%
1654% Default left margins for lists:
1655%
1656% \begin{macrocode}
1657\if@twocolumn
1658 \leftmargini2em
1659\else
1660 \leftmargini2.2em
1661\fi
1662\leftmarginii2em
1663\leftmarginiii1.87em
1664\leftmarginiv1.7em
1665\if@twocolumn
1666 \leftmarginv.5em
1667 \leftmarginvi.5em
1668\else
1669 \leftmarginv1em
1670 \leftmarginvi1em
1671\fi
1672% \end{macrocode}
0ef5b158
MW
1673% And now we can set the paragraph indent.
1674% \begin{macrocode}
1675\if@indentpar
98945a11 1676 \parindent1.2em
0ef5b158
MW
1677\else
1678 \parindent\z@
1679\fi
1680% \end{macrocode}
1ffa9044 1681%
1682% Other spacing defaults:
1683%
1684% \begin{macrocode}
1685\leftmargin\leftmargini
1686\labelsep.5em
1687\labelwidth\leftmargini
1688\advance\labelwidth-\labelsep
1689\partopsep\z@\@plus1\p@\@minus1\p@
1690% \end{macrocode}
1691%
1692% Interline penalties:
1693%
1694% \begin{macrocode}
1695\@beginparpenalty -\@lowpenalty
1696\@endparpenalty -\@lowpenalty
1697\@itempenalty -\@lowpenalty
1698% \end{macrocode}
1699%
1700% Now we define the defaults for the list environments. These have managed
1701% to migrate from the size options into the main document class.
1702%
1703% \begin{macrocode}
1704\def\@listI{%
35f7eeda 1705 \ifvmode\else\@beginparpenalty\@M\fi%
1ffa9044 1706 \leftmargin\leftmargini%
0ef5b158 1707 \parsep\@parskip%
4ef1fb33 1708 \topsep\@parshortfall%
1ffa9044 1709 \itemsep\z@%
1710}
1711\let\@listi\@listI
b8d14be9 1712\@listi%
1ffa9044 1713\def\@listii{%
35f7eeda 1714 \ifvmode\else\@beginparpenalty\@M\fi%
2a8b8e43 1715 \topsep\z@\@plus\p@%
1ffa9044 1716 \leftmargin\leftmarginii%
1717 \labelwidth\leftmarginii%
1718 \advance\labelwidth-\labelsep%
1719}
1720\def\@listiii{%
35f7eeda 1721 \ifvmode\else\@beginparpenalty\@M\fi%
1ffa9044 1722 \leftmargin\leftmarginiii%
1723 \labelwidth\leftmarginiii%
1724 \advance\labelwidth-\labelsep%
c3f26ad3 1725% \partopsep\p@\@plus\z@\@minus\p@%
1ffa9044 1726}
1727\def\@listiv{%
35f7eeda 1728 \ifvmode\else\@beginparpenalty\@M\fi%
1ffa9044 1729 \leftmargin\leftmarginiv%
1730 \labelwidth\leftmarginiv%
1731 \advance\labelwidth-\labelsep%
1732}
1733\def\@listv{%
35f7eeda 1734 \ifvmode\else\@beginparpenalty\@M\fi%
1ffa9044 1735 \leftmargin\leftmarginv%
1736 \labelwidth\leftmarginv%
1737 \advance\labelwidth-\labelsep%
1738}
1739\def\@listvi{%
35f7eeda 1740 \ifvmode\else\@beginparpenalty\@M\fi%
1ffa9044 1741 \leftmargin\leftmarginvi%
1742 \labelwidth\leftmarginvi%
1743 \advance\labelwidth-\labelsep%
1744}
1745% \end{macrocode}
1746%
186f3b71 1747% \subsection{Numbering things}
1748%
1749% \begin{macro}{\numberwithin}
1750%
1751% Does the obvious thing. Optional argument gives numbering style.
1752%
1753% \begin{macrocode}
1754\def\numberwithin{\@testopt\nw@i\arabic}
1755\def\nw@i[#1]#2#3{%
1756 \@addtoreset{#2}{#3}%
1757 \expandafter\xdef\csname the#2\endcsname{%
1758 \expandafter\noexpand\csname the#3\endcsname.%
1759 \noexpand#1{#2}}%
1760}
1761% \end{macrocode}
1762%
1763% \end{macro}
1764%
1765% \begin{macro}{\removefromreset}
1766%
1767% Does the obvious thing.
1768%
1769% \begin{macrocode}
1770\def\removefromreset#1#2{%
1771 \begingroup%
1772 \def\@tempa{#1}%
1773 \toks@{}%
1774 \def\@elt##1{%
1775 \def\@tempb{##1}%
1776 \ifx\@tempa\@tempb%
1777 \else\toks@\expandafter{\the\toks@\@elt{##1}}%
1778 \fi%
1779 }
1780 \csname cl@#2\endcsname%
1781 \expandafter\xdef\csname cl@#2\endcsname{\the\toks@}%
1782 \endgroup%
1783}
1784% \end{macrocode}
1785%
1786% \end{macro}
1787%
1ffa9044 1788% \subsection{Enumerated lists}
1789%
1790% We busily redefine all the counters for enumerated lists, and how to
1791% typeset them.
1792%
1793% How to typeset the numbers:
1794%
1795% \begin{macrocode}
1796\renewcommand\theenumi{\arabic{enumi}}
1797\renewcommand\theenumii{\alph{enumii}}
1798\renewcommand\theenumiii{\roman{enumiii}}
1799\renewcommand\theenumiv{\Alph{enumiv}}
1800% \end{macrocode}
1801%
1802% Typesetting the item labels:
1803%
1804% \begin{macrocode}
1805\newcommand\labelenumi{\theenumi.}
1806\newcommand\labelenumii{(\theenumii)}
1807\newcommand\labelenumiii{\theenumiii.}
1808\newcommand\labelenumiv{\theenumiv.}
1809% \end{macrocode}
1810%
1811% And finally how to typeset references to the items:
1812%
1813% \begin{macrocode}
1814\renewcommand\p@enumii{\theenumi}
1815\renewcommand\p@enumiii{\theenumi(\theenumii)}
1816\renewcommand\p@enumiv{\p@enumiii\theenumiii}
1817% \end{macrocode}
1818%
1819% \subsection{Itemized lists}
1820%
1821% We set up the various bullet shapes for the itemized lists.
1822%
1823% \begin{macrocode}
1824\newcommand\labelitemi{$\m@th\bullet$}
1825\newcommand\labelitemii{\normalfont\bfseries --}
1826\newcommand\labelitemiii{$\m@th\ast$}
1827\newcommand\labelitemiv{$\m@th\cdot$}
1828% \end{macrocode}
1829%
1830% \subsection{Description lists}
1831%
1832% This has been redefined a little to make it more sensible. The old version
1833% had a weird |\hspace\labelsep| in the labelling macro. This has now been
1834% added into the main list definition. You can now redefine
1835% |\descriptionlabel| without fear of messing up the spacing.
1836%
1837% \begin{environment}{description}
1838%
1839% Here we set up the main list parameters. The label width is zeroed to
1840% ensure that the text is always indented nicely.
1841%
1842% \begin{macrocode}
1843\def\description{%
1844 \list{}{%
1845 \labelwidth\z@%
1846 \itemindent-\leftmargin%
1847 \advance\itemindent\labelsep%
1848 \def\makelabel{\descriptionlabel}%
1849 }%
1850}
1851\let\enddescription\endlist
1852% \end{macrocode}
1853%
1854% \begin{macro}{\descriptionlabel}
1855%
1856% This typesets a description label. Redefine it the obvious way for
1857% different exciting effects.
1858%
1859% \begin{macrocode}
1860\def\descriptionlabel#1{\normalfont\bfseries #1}
1861% \end{macrocode}
1862%
1863% \end{macro}
1864% \end{environment}
1865%
1866% \subsection{Other list-based environments}
1867%
1868% Several other standard environments are defined in terms of lists. These
1869% are all dealt with here.
1870%
1871% \begin{environment}{verse}
1872%
1873% The \env{verse} environment is specially fiddled so that |\\| works as it
1874% should. There's nothing else exciting about it.
1875%
1876% \begin{macrocode}
1877\newenvironment{verse}{%
1878 \let\\\@centercr%
1879 \list{}{%
1880 \itemsep\z@%
1881 \itemindent-1.5em%
1882 \listparindent\itemindent%
1883 \rightmargin\leftmargin%
1884 \advance\leftmargin1.5em%
1885 }%
1886 \item[]%
1887}{%
1888 \endlist%
1889}
1890% \end{macrocode}
1891% \end{environment}
1892%
1893% \begin{environment}{quotation}
1894%
1895% The \env{quotation} environment is a pretty standard display, except that
1896% we kill off inter-paragraph space. The current definition means that
1897% \env{quotation}s are typeset in normal indented-paragraph style, which
1898% is inconsistent with the rest of the document style.
1899%
1900% \begin{macrocode}
1901\newenvironment{quotation}{%
1902 \list{}{%
1903 \listparindent\z@%
1904 \itemindent\listparindent%
1905 \rightmargin\leftmargin%
1906 }%
1907 \item[]%
1908}{%
1909 \endlist%
1910}
1911% \end{macrocode}
1912% \end{environment}
1913%
1914% \begin{environment}{quote}
1915%
1916% This is even simpler. We just pull in the right margin a bit.
1917%
1918% \begin{macrocode}
1919\newenvironment{quote}{%
1920 \list{}{%
1921 \rightmargin\leftmargin%
1922 }%
1923 \item[]%
1924}{%
1925 \endlist%
1926}
1927% \end{macrocode}
1928% \end{environment}
1929%
1930% \begin{environment}{display}
1931%
1932% The \env{display} environment is intended for any other displays which you
1933% need to typeset. This is \emph{not} a standard environment.
1934%
1935% \begin{macrocode}
1936\newenvironment{display}{%
1937 \list{}{%
1938 \leftmargin1em%
1939 \rightmargin\leftmargin%
1940 \labelsep\z@%
1941 \labelwidth\z@%
1942 }%
1943 \item[]\relax%
1944}{%
1945 \endlist%
1946}
1947% \end{macrocode}
1948% \end{environment}
1949%
1950% And some quick hacking of the theorem environment.
1951%
1952% \section{Other parameters}
1953%
1954% We define some miscellaneous parameters for standard environments.
1955%
1956% \begin{macrocode}
1957\arraycolsep5\p@
1958\tabcolsep6\p@
1959\arrayrulewidth.4\p@
1960\doublerulesep2\p@
1961\tabbingsep\labelsep
1962\skip\@mpfootins\skip\footins
1963\fboxsep3\p@
1964\fboxrule.4\p@
1965%
1966\if@article
1967 \renewcommand\theequation{\arabic{equation}}
1968\else
1969 \@addtoreset{equation}{chapter}
1970 \renewcommand\theequation{\thechapter.\arabic{equation}}
1971\fi
1972% \end{macrocode}
1973%
1974% \section{Floats}
1975%
1976% Since raw \LaTeX\ doesn't actually define any floating objects, we have
1977% to do some of the work here. This isn't actually terribly arduous. For
1978% a float called \synt{float}, we have to define the following macros:
1979%
1980% \begin{description}
1981% \let\descriptionlabel\relax
1982%
1983% \item[\texttt{\bslash fps@}\synt{float}] is the default float positioning
1984% argument for the float type.
1985%
1986% \item[\texttt{\bslash ftype@}\synt{float}] is a flag bit for the float
1987% type. This is used in \LaTeX's |\output| routine to identify floats of
1988% this type.
1989%
1990% \item[\texttt{\bslash ext@}\synt{float}] is the file extension for the
1991% list of these floats (e.g., \lit{lof} for figures).
1992%
1993% \item[\texttt{\bslash fnum@}\synt{float}] is a macro which generates the
1994% caption number. For figures, this expands to `|Figure~\thefigure|'.
1995%
1996% \end{description}
1997%
1998% We must also define |\@makecaption|, which typesets a float caption in
1999% an appropriate way, and an environment for each type of float.
2000%
2001% \subsection{Figures}
2002%
2003% This is all fairly straightforward stuff. First, we create a counter for
2004% figures:
2005%
2006% \begin{macrocode}
2007\newcounter{figure}[chapter]
2008\if@article
2009 \renewcommand\thefigure{\@arabic\c@figure}
2010\else
2011 \renewcommand\thefigure{\thechapter.\@arabic\c@figure}
2012\fi
2013% \end{macrocode}
2014%
2015% Now we define all the macros \LaTeX\ requires.
2016%
2017% \begin{macrocode}
2018\if@herefloats\def\fps@figure{htbp}\else\def\fps@figure{tbp}\fi
2019\def\ftype@figure{1}
2020\def\ext@figure{lof}
2021\def\fnum@figure{\figurename~\thefigure}
2022% \end{macrocode}
2023%
2024% \begin{environment}{figure}
2025% \begin{environment}{figure*}
2026%
2027% Finally, we create the \env{figure} and \env{figure$*$} environments.
2028%
2029% \begin{macrocode}
2030\newenvironment{figure}{\@float{figure}}{\end@float}
2031\newenvironment{figure*}{\@dblfloat{figure}}{\end@dblfloat}
2032% \end{macrocode}
2033% \end{environment}
2034% \end{environment}
2035%
2036% \subsection{Tables}
2037%
2038% This is pretty similar to the figure handling.
2039%
2040% \begin{macrocode}
2041\newcounter{table}[chapter]
2042\if@article
2043 \renewcommand\thetable{\@arabic\c@table}
2044\else
2045 \renewcommand\thetable{\thechapter.\@arabic\c@table}
2046\fi
2047%
2048\if@herefloats\def\fps@table{htbp}\else\def\fps@table{tbp}\fi
2049\def\ftype@table{2}
2050\def\ext@table{lot}
2051\def\fnum@table{\tablename~\thetable}
2052%
2053\newenvironment{table}{\@float{table}}{\end@float}
2054\newenvironment{table*}{\@dblfloat{table}}{\end@dblfloat}
2055% \end{macrocode}
2056%
2057% \subsection{Other float parameters}
2058%
2059% \begin{macro}{\@makecaption}
2060%
2061% The |\@makecaption| macro is called to display a float caption. It will
2062% typeset its argument either centred in a box, if it is short enough, or
2063% in a paragraph if it is longer than a line.
2064%
2065% \begin{macrocode}
2066\newlength\abovecaptionskip
2067\newlength\belowcaptionskip
2068\abovecaptionskip10\p@
2069\belowcaptionskip0\p@
2070%
c3f26ad3 2071\long\def\captionstyle#1#2{\itshape #1: #2}
1ffa9044 2072\long\def\@makecaption#1#2{%
2073 \vskip\abovecaptionskip%
c3f26ad3 2074 \sbox\@tempboxa{\captionstyle{#1}{#2}}%
1ffa9044 2075 \ifdim\wd\@tempboxa>\hsize%
c3f26ad3 2076 \unhbox\@tempboxa\par%
1ffa9044 2077 \else%
c3f26ad3 2078 \hb@xt@\hsize{\hfil\unhbox\@tempboxa\hfil}%
1ffa9044 2079 \fi%
2080 \vskip\belowcaptionskip%
2081}
2082% \end{macrocode}
2083% \end{macro}
2084%
2085% \section{Font commands}
2086%
2087% We allow the `old' font commands to do sensible \textsf{NFSS} things, since
2088% we don't have any legacy documents. This means that we have proper
2089% abbreviations for font changes. We also add |\nm| to return to a normal
2090% font, whatever that may mean.
2091%
2092% \begin{macrocode}
2093\DeclareOldFontCommand{\rm}{\rmfamily}{\mathrm}
2094\DeclareOldFontCommand{\sf}{\sffamily}{\mathsf}
2095\DeclareOldFontCommand{\tt}{\ttfamily}{\mathtt}
2096\DeclareOldFontCommand{\bf}{\bfseries}{\mathbf}
2097\DeclareOldFontCommand{\md}{\mdseries}{\@nomath\md}
2098\DeclareOldFontCommand{\it}{\itshape}{\mathit}
2099\DeclareOldFontCommand{\up}{\upshape}{\@nomath\up}
2100\DeclareOldFontCommand{\sl}{\slshape}{\@nomath\sl}
2101\DeclareOldFontCommand{\sc}{\scshape}{\@nomath\sc}
2102\DeclareOldFontCommand{\nm}{\normalfont}{\mathnormal}
2103% \end{macrocode}
2104%
2105% Now we define some special commands which only work in maths mode. It
2106% seems that older versions of \LaTeX\ (in particular, that at Warwick
2107% University) don't define these commands initially, so we'd better not
2108% use |\renewcommand| after all. We also dispose of lots of messing with
2109% |\protect| by using |\DeclareRobustCommand|.
2110%
2111% \begin{macrocode}
2112\DeclareRobustCommand\cal{\@fontswitch{\relax}{\mathcal}}
2113\DeclareRobustCommand\pmit{\@fontswitch{\relax}{\mathnormal}}
2114% \end{macrocode}
2115%
2116% \section{Tables of contents}
2117%
2118% This section deals with tables of contents, and lists of figures.
2119%
2120% \subsection{Contents}
2121%
2122% First, we have to define some parameters.
2123%
2124% \begin{macrocode}
2125\newcommand\@pnumwidth{2em}
2126\newcommand\@tocrmarg {3em}
2127\newcommand\@dotsep{4.5}
2128\setcounter{tocdepth}{\if@runinsubsubsec1\else2\fi}
2129% \end{macrocode}
2130%
2131% \begin{macro}{\tableofcontents}
2132%
2133% This is the main command for setting up tables of contents. We ensure
2134% a single-page layout, put in the chapter heading, read in the contents
2135% file, and then restore the old layout.
2136%
2137% \begin{macrocode}
c3f26ad3 2138\def\@tocthing#1#2{%
2139 \@ifnextchar[{\@tocthing@i{#1}{#2}}{\@tocthing@i{#1}{#2}[\relax][\relax]}%
2140}
2141\def\@tocthing@i#1#2[#3][#4]{%
2142 \if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\fi%
2143 \@topsect@star{#1}#3{\parskip\z@\@starttoc{#2}}#4%
2144 \if@restonecol\twocolumn\fi%
1ffa9044 2145}
c3f26ad3 2146\newcommand\tableofcontents{\@tocthing\contentsname{toc}}
1ffa9044 2147% \end{macrocode}
2148% \end{macro}
2149%
2150% Each section type \synt{type} is typeset by a command |\l@|\synt{type}:
2151% for example, the |\l@chapter| command typesets the entry for a chapter
2152% heading.
2153%
2154% \begin{macro}{\l@part}
2155%
2156% This command is vaguely interesting. We'll explore in detail.
2157%
2158% \begin{macrocode}
2159\def\l@part#1#2{%
2160% \end{macrocode}
2161%
2162% We don't typeset the entry if |tocdepth| tells us not to. What kind of
2163% stupid user is going to disable \emph{all} the contents items.
2164%
2165% \begin{macrocode}
2166 \ifnum\c@tocdepth>-2\relax%
2167% \end{macrocode}
2168%
2169% Before we start, we try to break above the title. Later, we'll disable
2170% breaking afterwards. We then leave some vertical space.
2171%
2172% \begin{macrocode}
2173 \addpenalty{-\@highpenalty}%
2174 \addvspace{2.25em\@plus\p@}%
2175% \end{macrocode}
2176%
2177% We open a group, to avoid messing other things up. The |\numberline|
2178% macro, which numbers the entry on the left, typesets its argument in a box
2179% of width |\@tempdima|, which we must set up. We then set up the values
2180% of |\rightskip| and |\parfillskip| to avoid printing over the page number.
2181% We also make |\interlinepenalty| infinite to suppress breaking pages in
2182% the middle of the title.
2183%
2184% \begin{macrocode}
2185 \begingroup%
2186 \@tempdima3em%
2187 \parindent\z@%
2188 \rightskip\@pnumwidth%
2189 \parfillskip-\@pnumwidth%
2190 \interlinepenalty\@M
2191% \end{macrocode}
2192%
2193% Time to typeset the actual title. This is fairly simple, apart from
2194% a complicated mixture of glue and penalties, which handles a line break
2195% right at the end of the title.
2196%
2197% \begin{macrocode}
2198 {%
2199 \leavevmode%
2200 \large\bfseries {#1}%
2201 \nobreak\hfil\penalty\@highpenalty\hbox{}\nobreak\hfil%
2202 \hb@xt@\@pnumwidth{\hss #2}%
2203 }%
2204% \end{macrocode}
2205%
2206% Now we end the paragraph and suppress page breaking here.
2207%
2208% \begin{macrocode}
2209 \par%
2210 \nobreak%
2211 \global\@nobreaktrue%
2212 \everypar{\global\@nobreakfalse\everypar{}}%
2213 \endgroup%
2214 \fi%
2215}
2216% \end{macrocode}
2217% \end{macro}
2218%
2219% \begin{macro}{\@artsw}
2220%
2221% Define a macro named after the first or second argument depending on
2222% whether the document is an article.
2223%
2224% \begin{macrocode}
2225\def\@artsw#1#2#3{%
2226 \edef\@tempa{#1\if@article\noexpand#3\else\noexpand#2\fi}%
2227 \@tempa%
2228}
2229% \end{macrocode}
2230%
2231% \end{macro}
2232%
2233% \begin{macro}{\l@chapter}
2234%
2235% This is terribly similar to the previous macro.
2236%
2237% \begin{macrocode}
2238\@artsw\def\l@chapter\l@section#1#2{%
2239 \ifnum\c@tocdepth >\m@ne%
2240 \addpenalty{-\@highpenalty}%
2241 \vskip1.0em\@plus\p@%
2242 \setlength\@tempdima{2em}%
2243 \begingroup%
2244 \interlinepenalty\@M
2245 \parindent\z@%
2246 \rightskip\@pnumwidth%
2247 \parfillskip-\@pnumwidth%
2248 \leavevmode%
2249 \bfseries%
2250 \advance\leftskip\@tempdima%
2251 \hskip-\leftskip%
2252 {#1}%
2253 \nobreak\hfil\penalty\@highpenalty\hbox{}\nobreak\hfil%
2254 \hb@xt@\@pnumwidth{\hss #2}%
2255 \par%
2256 \penalty\@highpenalty%
2257 \endgroup%
2258 \fi%
2259}
2260% \end{macrocode}
2261% \end{macro}
2262%
2263% The other types are all defined in terms of |\@dottedtocline|, which is
2264% redefined beloew.
2265%
2266% \begin{macrocode}
2267\@artsw\def\l@section\l@subsection{\@dottedtocline{1}{2em}{2.5em}}
2268\@artsw\def\l@subsection\l@subsubsection{\@dottedtocline{2}{4.5em}{3.2em}}
2269\@artsw\def\l@subsubsection\l@paragraph{\@dottedtocline{3}{7.7em}{4.1em}}
2270\@artsw\def\l@paragraph\l@subparagraph{\@dottedtocline{4}{10.5em}{5em}}
2271\@artsw\def\l@subparagraph\@tempa{\@dottedtocline{5}{12.5em}{6em}}
2272% \end{macrocode}
2273%
2274% \begin{macro}{\@dottedtocline}
2275%
2276% This is actually a part of the \LaTeX\ kernel, although it's not quite
fddb126a 2277% right the way it is. We've improved the handling of line breaks after the
1ffa9044 2278% title.
2279%
2280% \begin{macrocode}
2281\def\@dottedtocline#1#2#3#4#5{%
2282% \end{macrocode}
2283%
2284% We have to make sure that we're meant to typeset this contents entry.
2285%
2286% \begin{macrocode}
2287 \ifnum#1>\c@tocdepth\else%
2288% \end{macrocode}
2289%
2290% Now we add in a little stretchy space.
2291%
2292% \begin{macrocode}
2293 \vskip\z@\@plus.2\p@%
2294% \end{macrocode}
2295%
2296% Set up the paragraph layout now. We forbid page breaks in the middle of
2297% the title.
2298%
2299% \begin{macrocode}
2300 {%
2301 \leftskip#2\relax%
2302 \rightskip\@tocrmarg%
2303 \parfillskip-\rightskip%
2304 \parindent#2\relax%
2305 \@afterindenttrue%
2306 \interlinepenalty\@M%
2307% \end{macrocode}
2308%
2309% Now we typeset the actual title.
2310%
2311% \begin{macrocode}
2312 \leavevmode%
2313 \@tempdima#3\relax%
2314 \advance\leftskip\@tempdima%
2315 \hbox{}%
2316 \hskip-\leftskip%
2317 {#4}%
2318% \end{macrocode}
2319%
2320% This is the clever bit. After the actual title, we add the following
2321% items:
2322%
2323% \begin{itemize}
2324%
2325% \item A |\nobreak| penalty, to stop a break from eating the glue.
2326%
2327% \item A glob of |\hfil| glue. If there's a line break after this glue,
2328% the title is set flush left as a result of this. Otherwise, it is ignored
2329% because the leaders are |\hfill|.
2330%
2331% \item A penalty. This is a reasonable place to break the line if
2332% necessary.
2333%
2334% \item An empty |\hbox|. This stops the following glue from being discarded
2335% at the beginning of a new line.
2336%
2337% \item Another |\nobreak|, which stops a break at the following glue item.
2338%
2339% \item The dotted |\leaders|, which have |\hfill| stretchiness. This forces
2340% the page number to be flush right.
2341%
2342% \end{itemize}
2343%
2344% The net result of all this is we can now cope with a line break at the
2345% end of the title, before the page number, which means that the dots are
2346% put on the next line. The original \LaTeX\ version forced the last word
2347% of the title onto the next line as well, which can cause underful boxes.
2348%
2349% \begin{macrocode}
2350 \nobreak\hfil\penalty\@highpenalty\hbox{}\nobreak%
2351 \leaders\hbox{$\m@th\mkern\@dotsep mu.\mkern\@dotsep mu$}\hfill%
2352 \hb@xt@\@pnumwidth{\hfil\reset@font\rmfamily#5}\par%
2353 }%
2354 \fi%
2355}
2356% \end{macrocode}
2357% \end{macro}
2358%
2359% \subsection{Lists of figures and tables}
2360%
2361% These macros are terribly similar to the other ones.
2362%
2363% \begin{macrocode}
c3f26ad3 2364\newcommand\listoffigures{\@tocthing\listfigurename{lof}}
2365\newcommand\l@figure{\@dottedtocline{0}{0pt}{2em}}
2366\newcommand\listoftables{\@tocthing\listtablename{lot}}
1ffa9044 2367\let\l@table\l@figure
2368% \end{macrocode}
2369%
2370% \section{Bibliography}
2371%
2372% This isn't actually terribly interesting.
2373%
2374% \begin{environment}{thebibliography}
2375%
2376% \begin{macrocode}
2377\newdimen\bibindent
2378\bibindent1.5em
2379%
2380\newenvironment{thebibliography}[1]{%
2381 \@topsect\bibname%
2382 \list{\@biblabel{\arabic{enumiv}}}%
2383 {\settowidth\labelwidth{\@biblabel{#1}}%
2384 \leftmargin\labelwidth%
2385 \advance\leftmargin\labelsep%
2386 \if@openbib%
2387 \advance\leftmargin\bibindent%
2388 \itemindent-\bibindent%
2389 \listparindent\itemindent%
2390 \parsep\z@%
2391 \fi%
2392 \usecounter{enumiv}%
2393 \let\p@enumiv\@empty%
2394 \renewcommand\theenumiv{\arabic{enumiv}}}%
2395 \if@openbib%
2396 \renewcommand\newblock{\par}%
2397 \else%
2398 \renewcommand\newblock{\hskip.11em\@plus.33em\@minus.07em}%
2399 \fi%
2400 \sloppy%
2401 \clubpenalty4000%
2402 \widowpenalty4000%
2403 \sfcode`\.\@m%
2404}{%
2405 \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
2406 \endlist%
2407}
2408%
2409\newcommand\newblock{}
2410% \end{macrocode}
2411% \end{environment}
2412%
2413% \section{Index}
2414%
2415% Defines the \env{theindex} environment.
2416%
2417% \begin{environment}{theindex}
2418%
2419% The macros are fairly simple. We change to a two column layout, and
2420% redefine |\item| appropriately.
2421%
2422% \begin{macrocode}
2423\newenvironment{theindex}{%
2424 \columnseprule\z@%
2425 \columnsep35\p@%
2426 \@topsect\indexname%
2427 \if@twocolumn\else%
2428 \begin{multicols}{2}%
2429 \fi%
2430 \parskip\z@\@plus.3\p@\relax%
2431 \raggedright%
2432 \let\item\@idxitem%
2433}{%
2434 \if@twocolumn\else%
2435 \end{multicols}%
2436 \fi%
2437}
2438% \end{macrocode}
2439% \end{environment}
2440%
2441% Now we define the item and spacing macros.
2442%
2443% \begin{macrocode}
2444\newcommand\@idxitem {\par\hangindent 40\p@}
2445\newcommand\subitem {\par\hangindent 40\p@ \hspace*{20\p@}}
2446\newcommand\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
2447\newcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}
2448% \end{macrocode}
2449%
2450% \begin{macro}{\passim}
2451%
2452% The |passim| encapsulator is used to typeset the word `\textit{passim}'
2453% after a page range.
fddb126a 2454%
1ffa9044 2455% \begin{macrocode}
2456\def\passim#1{#1 \textit{passim}} % Passim encapsulator for indices
2457% \end{macrocode}
2458% \end{macro}
2459%
2460% Other useful commands for indexing:
2461%
2462% \begin{description*}
2463% \def\descriptionlabel#1{\ttfamily \bslash #1}
2464%
2465% \item[Term] typesets its argument in italics, and adds it to the index.
2466%
2467% \item[term] typesets its first argument in italics, and adds its second
2468% to the index.
2469%
2470% \item[Index] typesets its argument normally, and adds it to the index.
2471%
2472% \end{description*}
2473%
2474% \begin{macrocode}
2475\def\Term#1{\emph{#1}\index{#1}}
2476\def\term#1{\emph{#1}\index}
2477\def\Index#1{#1\index{#1}}
2478% \end{macrocode}
2479%
2480% \section{Footnotes}
2481%
2482% \begin{macro}{\footnoterule}
2483%
2484% This macro typesets the rule above footnotes. This is a bit more complex
2485% than the default: we try and typeset the rule to be at most 1\,in wide,
2486% although if the column isn't wide enough, we use $4\over10$~of the
2487% box width instead.
2488%
2489% \begin{macrocode}
2490\def\footnoterule{%
2491 \@tempdima.4\columnwidth%
2492 \ifdim\@tempdima>1in\relax%
2493 \@tempdima1in\relax%
2494 \fi%
2495 \kern-3\p@%
2496 \hrule\@width\@tempdima%
2497 \kern2.6\p@%
2498}
2499% \end{macrocode}
2500% \end{macro}
2501%
2502% We number footnotes within chapters:
2503%
2504% \begin{macrocode}
2505\@addtoreset{footnote}{chapter}
2506% \end{macrocode}
2507%
2508% \begin{macro}{\@makefntext}
2509%
2510% This is the macro which actually typesets a footnote. This is rather
2511% complicated. It's based on example code from \file{classes.dtx} which
2512% doesn't actually work properly.
2513%
2514% \begin{macrocode}
2515\long\def\@makefntext#1{%
2516% \end{macrocode}
2517%
2518% First, we redefine |\par| to set up the correct paragraph shape. This
2519% is indented from the left margin by a small amount.
2520%
2521% \begin{macrocode}
2522 \@setpar{%
2523 \@@par%
2524 \@tempdima\hsize%
2525 \advance\@tempdima-1.6em%
2526 \parshape\@ne1.6em\@tempdima%
2527 }%
2528% \end{macrocode}
2529%
2530% Now we set up some parameters so that \env{list} environments work properly
2531% within the footnote. We also clear |\parindent| to prevent nasty
2532% indentation. The |\par| sets up the paragraph shape for the next
2533% paragraph: we're in vertical mode already, so it does nothing else.
2534%
2535% \begin{macrocode}
2536 \advance\linewidth-1.6em%
2537 \advance\@totalleftmargin1.6em%
2538 \par%
2539 \parindent\z@%
2540% \end{macrocode}
2541%
2542% We leave vertical mode to stop the hbox created by |\llap| from being
2543% stacked vertically. Then we typeset the footnote mark, and put in the
2544% main text. Finally we leave some space afterwards, to space out the next
2545% footnote.
2546%
2547% \begin{macrocode}
2548 \leavevmode%
2549 \llap{\@makefnmark\enspace}#1\par%
2550 \vskip\parskip%
2551}
2552% \end{macrocode}
2553% \end{macro}
2554%
2555% \begin{macro}{\@makecol}
2556%
2557% The standard \LaTeX\ output routine messes up footnotes a bit, in my
2558% opinion:
2559% \begin{itemize}
2560%
2561% \item If a page is cut off short, because the next item won't fit (e.g.,
2562% a section heading), then footnotes are added right below the end
2563% of the text, which can look strange.
2564%
2565% \item Footnotes are displayed \emph{above} floats at the bottom of a page,
2566% which also looks strange.
2567%
2568% \item The |\@makefntext| routine above needs to add vertical space between
2569% footnotes, but this leaves a gap at the very bottom. We remove this
2570% gap with an |\unskip|.
2571%
2572% \end{itemize}
2573%
2574% \begin{macrocode}
2575\def\@makecol{%
2576 \setbox\@outputbox \box\@cclv
2577 \xdef\@freelist{\@freelist\@midlist}%
2578 \global \let \@midlist \@empty
2579 \@combinefloats
2580 \ifvoid\footins \else
2581 \setbox\@outputbox \vbox {%
fddb126a 2582 \boxmaxdepth \@maxdepth
1ffa9044 2583 \unvbox \@outputbox
2584 \vskip \skip\footins
2585 \vfil
2586 \footnoterule
2587 \unvbox \footins
2588 \unskip
2589 }%
2590 \fi
2591 \ifvbox\@kludgeins
2592 \@makespecialcolbox
2593 \else
2594 \setbox\@outputbox \vbox to\@colht {%
2595 \@texttop
2596 \dimen@ \dp\@outputbox
2597 \unvbox \@outputbox
2598 \vskip -\dimen@
2599 \@textbottom
2600 }%
2601 \fi
2602 \global \maxdepth \@maxdepth
2603}
2604% \end{macrocode}
2605% \end{macro}
2606%
2607% \section{Tidying up}
2608%
2609% This section gathers together various other useful bits of standard
2610% document class setting.
2611%
2612% \subsection{Item names}
2613%
2614% These commands typeset bits of text. They can then be redefined by
2615% \package{babel} and suchlike.
2616%
2617% \begin{macrocode}
2618\newcommand\contentsname{Contents}
c3f26ad3 2619\newcommand\listfigurename{List of figures}
2620\newcommand\listtablename{List of tables}
1ffa9044 2621\if@article\newcommand\bibname{References}
2622\else\newcommand\bibname{Bibliography}\fi
2623\newcommand\indexname{Index}
2624\newcommand\figurename{Figure}
2625\newcommand\tablename{Table}
2626\newcommand\partname{Part}
2627\newcommand\abstractname{Abstract}
2628\newcommand\chaptername{Chapter}
2629\newcommand\appendixname{Appendix}
2630\newcommand\today{\number\day\space\ifcase\month\or
2631 January\or February\or March\or April\or May\or June\or
2632 July\or August\or September\or October\or November\or December\fi
2633 \space\number\year}
2634% \end{macrocode}
2635%
2636% \subsection{Final fiddling for two columns}
2637%
2638% \begin{macrocode}
2639\columnsep10\p@
2640\columnseprule\z@
2641\pagestyle{headings}
2642\pagenumbering{arabic} % Arabic page numbers
2643\if@twocolumn
2644 \twocolumn
2645 \sloppy
2646 \flushbottom
2647\else
2648 \onecolumn
2649\fi
2650% \end{macrocode}
2651%
2652% \section{The \protect\env{central} environment}
2653%
2654% Because of the strange layout of the pages, text which is centred using
2655% normal \LaTeX\ commands is centred in the text area, not on the page,
2656% which is undesirable for large headings, like part headings.
2657%
2658% \begin{environment}{central}
2659%
2660% The \env{central} environment typesets its contents centrally on the page.
2661% It should only be used from outer vertical mode.
2662%
2663% The code just creates a box of the appropriate size and moves it into the
2664% right place.
2665%
2666% \begin{macrocode}
2667\newenvironment{central}{%
2668 \par%
2669 \vbox\bgroup\moveleft\leftindent\vbox\bgroup%
2670 \textwidth\paperwidth%
2671 \advance\textwidth-2\pagesurround\relax%
2672 \hsize\textwidth%
2673 \hrule\@height\z@\@depth\z@\@width\hsize%
2674}{%
2675 \egroup%
2676 \egroup%
2677}
2678% \end{macrocode}
2679% \end{environment}
2680%
2681% \section{Headers and footers}
2682%
2683% The \strayman\ class uses \package{fancyheadings} for its headers
2684% and footers. This has already been included in the preamble. We now
2685% need to fix a few problems with \package{fancyheadings} and set up some
2686% macros.
2687%
2688% \begin{macro}{\title}
2689%
2690% We extend |\title|, and give it an optional argument. It can now specify
2691% the document title as used by |\maketitle| and the running title for the
2692% header separately.
2693%
2694% We store the running header in the macro |\@headertitle|, which is
2695% initially empty.
2696%
2697% \begin{macrocode}
2698\def\@headertitle{}
2699% \end{macrocode}
2700%
2701% Now we define the |\title| macro, using |\@dblarg| to duplicate the
2702% mandatory argument if the optional one is omitted.
2703%
2704% \begin{macrocode}
2705\def\title{\@dblarg\title@i}
2706\def\title@i[#1]#2{%
2707 \gdef\@title{#2}%
2708 \gdef\@headertitle{#1}%
2709}
2710% \end{macrocode}
2711% \end{macro}
2712%
2713% \begin{macro}{\innerhead}
2714% \begin{macro}{\innerfoot}
2715%
2716% We allow the user to specify an `inner heading' which is displayed on the
2717% inside of the header on of each page. This can be used for security
2718% classifications, for example. Any \package{fancyheadings} commands can
2719% be used to control the header, which is expanded on each page.
2720%
2721% \begin{macrocode}
2722\def\l@innerhead{}
2723\def\r@innerhead{}
2724\def\l@innerfoot{}
2725\def\r@innerfoot{}
2726\def\innerhead{\@dblarg\innerhead@i}
2727\def\innerhead@i[#1]#2{%
2728 \def\l@innerhead{#1}%
2729 \def\r@innerhead{#2}%
2730}
2731\def\innerfoot{\@dblarg\innerfoot@i}
2732\def\innerfoot@i[#1]#2{%
2733 \def\l@innerfoot{#1}%
2734 \def\r@innerfoot{#2}%
2735}
2736% \end{macrocode}
2737% \end{macro}
2738% \end{macro}
2739%
2740% The next step is to set up the headings:
2741%
2742% \begin{macrocode}
2743\let\headrulewidth\z@
2744\headwidth\textwidth
2745 \advance\headwidth\leftindent
2713c178 2746\fancyhfoffset[LE,LO]{\leftindent}
1ffa9044 2747\fancypagestyle{headings}{%
2748 \fancyhf{}
2749 \fancyhead[LE]{\bfseries\@headertitle}
2750 \if@article\fancyhead[RO]{\rightmark}\else\fancyhead[RO]{\leftmark}\fi
2751 \fancyhead[RE]{\l@innerhead} \fancyhead[LO]{\r@innerhead}
2752 \fancyfoot[RE]{\l@innerfoot} \fancyfoot[LO]{\r@innerfoot}
2753 \fancyfoot[LE,RO]{\thepage}
2754}
2755\fancypagestyle{plain}{%
2756 \fancyhf{}%
2757 \fancyfoot[RE]{\l@innerfoot} \fancyfoot[LO]{\r@innerfoot}
2758 \fancyfoot[LE,RO]{\thepage}%
2759}
2760\let\ps@fancy\ps@@fancy
2761% \end{macrocode}
2762%
2763% The \package{fancyheadings} package by default expects pages to be
2764% symmetrical. We have to redefine the |\ps@fancy| macro to make it
2765% work properly.
2766%
2767% \begin{macrocode}
2768\def\@lodd{\ifodd\c@page\hss\else\relax\fi}
2769\def\@rodd{\ifodd\c@page\relax\else\hss\fi}
2770% \end{macrocode}
2771%
2772% Finally, we can choose the page style we want:
2773%
2774% \begin{macrocode}
2775\pagestyle{headings}
2776% \end{macrocode}
2777%
2778% \section{Parbox alteration}
2779%
2780% The standard \LaTeX\ |\parbox| command, and the \env{minipage} environment,
2781% reset |\parskip| to zero, which is inconsistent with the document style.
2782% We amend |\@arrayparboxrestore|, the macro which sets up the paragraph
2783% style for parboxes.
2784%
2785% First, we define a macro explaining how the parbox should set the spacing.
2786%
2787% \begin{macrocode}
2788\def\parboxparskip{2ex}
2789% \end{macrocode}
2790%
2791% Next, we redefine the macro. This is taken directly from the \LaTeXe
2792% source.
2793%
2794% \begin{macrocode}
2795\def\@arrayparboxrestore{%
2796 \let\par\@@par
2797 \let\-\@dischyph
2798 \let\'\@acci\let\`\@accii\let\=\@acciii
2799 \parindent\z@ \parskip\z@
2800 \everypar{\parskip\parboxparskip\everypar{}}%
2801 \linewidth\hsize
fddb126a 2802 \@totalleftmargin\z@
1ffa9044 2803 \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip
2804 \parfillskip\@flushglue \lineskip\normallineskip
2805 \baselineskip\normalbaselineskip
2806 \@noskipsectrue% % The comp.text.tex gurus said it should be
2807 \sloppy}
2808% \end{macrocode}
2809%
2810%
2811% \section{Other features}
2812%
2813% At the end is a miscellany of useful features.
2814%
2815% \subsection{Other typesetting conventions}
2816%
2817% Some items need typesetting in particular ways.
2818%
2819% \begin{macrocode}
2820\let\key\textit
2821\let\button\textbf
2822\def\submenu{\ensuremath\Rightarrow}
2823\let\name\relax
2824\def\file#1{\mbox{\itshape #1\/}}
2825% \end{macrocode}
2826%
2827% \subsection{And finally}
2828%
2829% \begin{macrocode}
2830\sloppy
2831\raggedbottom
2832\def\riscos{RISC~OS}
2833\hyphenpenalty1000
2834%</strayman>
2835% \end{macrocode}
2836%
2837% \Finale
2838%
2839\endinput