--- /dev/null
+% \begin{meta-comment}
+%
+% $Id: strayman.dtx,v 1.1 2002/02/19 23:27:57 mdw Exp $
+%
+% Another rewrite of the tabular environment, and maths alignments
+%
+% (c) 1996 Mark Wooding
+%
+%----- Revision history -----------------------------------------------------
+%
+% $Log: strayman.dtx,v $
+% Revision 1.1 2002/02/19 23:27:57 mdw
+% Initial revision.
+%
+% Revision 1.8 1996/12/09 23:20:42 mdw
+% (\tab@setstrut): Fixed so that it uses \dimen\tw@ for the strut depth,
+% as advertised.
+%
+% Revision 1.7 1996/11/29 21:59:16 mdw
+% Fixed a little formatting mistake in a syntax diagram, and switched over
+% to the new syntax diagram commands on the grounds that they're slightly
+% less messy. Maybe.
+%
+% Revision 1.6 1996/11/19 20:54:33 mdw
+% Entered into RCS
+%
+%
+% \end{meta-comment}
+%
+% \begin{meta-comment} <general public licence>
+%%
+%% mdwtab package -- another rewrite of the tabular environment, etc.
+%% Copyright (c) 1996 Mark Wooding
+%%
+%% This program is free software; you can redistribute it and/or modify
+%% it under the terms of the GNU General Public License as published by
+%% the Free Software Foundation; either version 2 of the License, or
+%% (at your option) any later version.
+%%
+%% This program is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+%% GNU General Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License
+%% along with this program; if not, write to the Free Software
+%% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%%
+% \end{meta-comment}
+%
+% \begin{meta-comment} <Package preamble>
+%<+strayman>\NeedsTeXFormat{LaTeX2e}
+%<+strayman>\ProvidesClass{strayman}
+%<+strayman> [1996/03/26 1.05 Straylight document class]
+% \end{meta-comment}
+%
+% \CheckSum{2919}
+%% \CharacterTable
+%% {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
+%% 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
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%%
+%
+% \begin{meta-comment} <driver>
+%
+%<*driver>
+\documentclass[10pt,a4paper,times,cmtt]{strayman}
+\input{mdwtools}
+\usepackage{mdwlist}
+\describesclass{strayman}
+\title[The \strayman\ document class]
+ {The \strayman\footnote{The \strayman\ document class is currently %
+ at version \mdwfileinfo{strayman.cls}{version}, dated %
+ \mdwfileinfo{strayman.cls}{date}.} {} document class}
+\newenvironment{syndisplay}{\display\synshorts}{\enddisplay}
+\DeclareRobustCommand\strayman{\package{strayman}}
+\mdwdoc
+%</driver>
+%
+% \end{meta-comment}
+%
+% \chapter{About the \strayman\ document class}
+%
+% The standard \LaTeX\ document classes are all very well for simple
+% documents, but the style isn't appropriate for works like manuals.
+% The \strayman\ document class is an attempt to recitfy this situataion,
+% providing an attractive and distinctive style for Straylight documents.
+% The layout is based on an earlier style built for \emph{Impression}
+% documents, although many improvements have been made. This document
+% was typeset using \strayman, and it demonstrates the design far better
+% than I can describe it.
+%
+%
+% \section{Document class options}
+%
+% The document class provides many options, most of which are taken from
+% the standard \LaTeX\ classes.
+%
+% \begin{description}
+% \def\|{\ensuremath\vert}
+%
+% \item [\texttt{a4paper} \| \texttt{a5paper} \| \texttt{b5paper} \|
+% \texttt{letterpaper} \| \texttt{legalpaper} \|
+% \texttt{executivepaper}] Select the output paper size. Since
+% \strayman\ is intended to be used mainly for manuals, the default
+% size is |a5paper|.
+%
+% \item [\texttt{landscape}] Swaps the width and height of the paper.
+% Probably not much use, to be honest.
+%
+% \item [\texttt{9pt} \| \texttt{10pt} \| \texttt{11pt} \| \texttt{12pt}]
+% Selects the basic type size for the document. The |9pt| option is
+% nonstandard, but it is the default, since larger sizes don't work
+% well on A5~paper.
+%
+% \item [\texttt{text}] Sets up the page layout and fonts so that the
+% output can be converted fairly easily into a raw text file.
+%
+% \item [\texttt{oneside} \| \texttt{twoside}] Selects one- or two-sided
+% page layouts. Note that one-sided output doesn't look too good.
+%
+% \item [\texttt{draft} \| \texttt{final}] Select various options for draft
+% or final copy.
+%
+% \item [\texttt{titlepage} \| \texttt{notitlepage}] Selects whether
+% the |\maketitle| displays its output on a separate title page.
+%
+% \item [\texttt{openright} \| \texttt{openany}] Select whether chapters
+% start only on quarto pages, or any page. The default is |openright|.
+%
+% \item [\texttt{onecolumn} \| \texttt{twocolumn}] Choose whether the
+% main body text is set in one or two columns. Note that this uses
+% \LaTeX's built-in column handling, not the \package{multicol}
+% package.
+%
+% \item [\texttt{leqno}] Put the equation numbers on the left, not the
+% right.
+%
+% \item [\texttt{fleqn}] Typeset displayed equations left aligned.
+%
+% \item [\texttt{openbib}] Use the `open' style for the bibliography.
+%
+% \item [\texttt{article}] Change the formatting slightly, in a way more
+% suited to short documents.
+%
+% \item [\texttt{square} \| \texttt{rounded}] These options are passed
+% directly to the \package{syntax} package, when it's loaded.
+%
+% \item [\texttt{helvetica}] Typeset headings in the Helvetica font,
+% not in Computer Modern.
+%
+% \item [\texttt{palatino}] Typeset the main body text in Palatino, and
+% headings in Helvetica. The |\tt| font is changed to Courier, but
+% see the \texttt{cmtt} option.
+%
+% \item [\texttt{times}] Typeset the main body text in Times, and headings
+% in Helvetica. The |\tt| font is changed to Courier, but see the
+% \texttt{cmtt} option.
+%
+% \end{description}
+%
+%
+% \section{The \texttt{text} option}
+%
+% In order to facilitate creation of attractively formatted text files
+% from \LaTeX\ documents, \strayman\ provides a |text| option. This will
+% set up \emph{all} the fonts to be monospaced, in the same size. The page
+% size is set up to be a multiple of the character size. The command
+% \begin{syndisplay}
+% "dvi2tty -e-17" <filename>
+% \end{syndisplay}
+% appears to produce a reasonable output from a DVI file created in this
+% way. The output will need to be formatted and corrected slightly by hand
+% although there's a good deal less work to do than might be required
+% otherwise.
+%
+%
+% \section{That's it}
+%
+% That's all I'm writing for now. It's a document class. It defines the
+% style. What more do you expect?
+%
+%
+% \implementation
+%
+% \chapter{Implementation}
+%
+% \section{Options handling}
+%
+% From here on, a lot of the code is shamelessly borrowed from
+% \file{book.cls} and other places. This is what code re-use is for.
+%
+% This bit handles all the options on the |\documentclass| command, either
+% altering our own internal arguments, or loading other packages as
+% appropriate.
+%
+% \subsection{Set up some defaults}
+%
+% We create some variables to hold the settings, and initialise them to
+% sensible values.
+%
+% \begin{macrocode}
+%<*strayman>
+\newcommand\@ptsize{}
+\newif\if@restonecol\@restonecolfalse
+\newif\if@titlepage\@titlepagetrue
+\newif\if@openright\@openrighttrue
+\newif\if@openbib\@openbibfalse
+\newif\if@appendix\@appendixfalse
+\newif\if@article\@articlefalse
+\newif\if@offsetpages\@offsetpagestrue
+\newif\if@numbering\@numberingfalse
+\newif\if@herefloats\@herefloatstrue
+\newif\if@runinsubsubsec\@runinsubsubsecfalse
+\newdimen\pagesurround
+\let\headfam\rmfamily
+\let\pad@margin\@empty
+\def\@delayed{}
+\def\@delaycode#1{%
+ \expandafter\def\expandafter\@delayed\expandafter{\@delayed#1}%
+}
+% \end{macrocode}
+%
+% \subsection{Declare the options we support}
+%
+% This is just a tedious list of all the options.
+%
+% \begin{macrocode}
+\DeclareOption{a4paper}{%
+ \paperheight297mm%
+ \paperwidth210mm%
+ \pagesurround1in%
+}
+\DeclareOption{a5paper}{%
+ \paperheight210mm%
+ \paperwidth148mm%
+ \pagesurround12mm%
+}
+\DeclareOption{b5paper}{%
+ \paperheight250mm%
+ \paperwidth176mm%
+ \pagesurround1in%
+}
+\DeclareOption{letterpaper}{%
+ \paperheight11in%
+ \paperwidth8.5in%
+ \pagesurround1in%
+}
+\DeclareOption{legalpaper}{%
+ \paperheight14in%
+ \paperwidth8.5in%
+ \pagesurround1in%
+}
+\DeclareOption{executivepaper}{%
+ \paperheight10.5in%
+ \paperwidth7.25in%
+ \pagesurround1in%
+}
+\DeclareOption{landscape}{%
+ \@tempdima\paperheight%
+ \paperheight\paperwidth%
+ \paperwidth\@tempdima%
+}
+\DeclareOption{8pt}{\renewcommand\@ptsize{8pt}}
+\DeclareOption{9pt}{\renewcommand\@ptsize{9pt}}
+\DeclareOption{10pt}{\renewcommand\@ptsize{10pt}}
+\DeclareOption{11pt}{\renewcommand\@ptsize{11pt}}
+\DeclareOption{12pt}{\renewcommand\@ptsize{12pt}}
+\DeclareOption{text}{%
+ \renewcommand\@ptsize{text}%
+ \setbox\z@\hbox{\texttt{M\strut}}%
+ \newdimen\tt@chw\tt@chw\wd\z@%
+ \newdimen\tt@chh\tt@chh\ht\z@\advance\tt@chh\dp\z@%
+ \paperwidth77\tt@chw%
+ \paperheight60\tt@chh%
+ \raggedright%
+ \def\pad@margin{.}
+}
+\DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
+\DeclareOption{twoside}{\@twosidetrue \@mparswitchfalse \reversemarginpar}
+\DeclareOption{draft}{\overfullrule5\p@}
+\DeclareOption{final}{\overfullrule\z@}
+\DeclareOption{titlepage}{\@titlepagetrue}
+\DeclareOption{notitlepage}{\@titlepagefalse}
+\DeclareOption{openright}{\@openrighttrue}
+\DeclareOption{openany}{\@openrightfalse}
+\DeclareOption{onecolumn}{\@twocolumnfalse}
+\DeclareOption{twocolumn}{\@twocolumntrue}
+\DeclareOption{offsetpages}{\@offsetpagestrue}
+\DeclareOption{nooffsetpages}{\@offsetpagesfalse}
+\DeclareOption{herefloats}{\@herefloatstrue}
+\DeclareOption{noherefloats}{\@herefloatsfalse}
+\DeclareOption{leqno}{\input{leqno.clo}}
+\DeclareOption{fleqn}{\input{fleqn.clo}}
+\DeclareOption{openbib}{\@openbibtrue}
+\DeclareOption{article}{\@articletrue}
+\DeclareOption{numbering}{\@numberingtrue}
+\DeclareOption{nonumbering}{\@numberingfalse}
+\DeclareOption{runinsubsubsec}{\@runinsubsubsectrue}
+\DeclareOption{noruninsubsubsec}{\@runinsubsubsecfalse}
+% \end{macrocode}
+%
+% \subsection{Set up the options}
+%
+% We set up some default options, and then read the user's.
+%
+% \begin{macrocode}
+\ExecuteOptions{a5paper,8pt,twoside,onecolumn,final,openright}
+\ProcessOptions
+% \end{macrocode}
+%
+% If this is PDF\TeX\ then tell it the page bounds.
+%
+% \begin{macrocode}
+\@ifundefined{pdfpageheight}{
+ \relax
+}{
+ \pdfpageheight\paperheight
+ \pdfpagewidth\paperwidth
+}
+% \end{macrocode}
+%
+% \subsection{Read in the text size option}
+%
+% The text sizing is rather messy. We store this in a separate file. To
+% keep this stuff away from other classes, we use the file \emph{extension}
+% as the size specifier, rather than the filename, which is the normal
+% \LaTeX\ way of doing this. This is a \riscos\ thing mainly: I don't like
+% loads of directories cluttering up my disk, and it means that I can move
+% the whole of the \strayman\ stuff around as one directory.
+%
+% \begin{macrocode}
+\input{strayman.\@ptsize}
+%</strayman>
+% \end{macrocode}
+%
+% \section{Package loading}
+%
+% \begin{macrocode}
+%<*strayman>
+\RequirePackage{fancyhdr}
+\RequirePackage{multicol}
+\@delayed
+%</strayman>
+% \end{macrocode}
+%
+% \section{Page layout}
+%
+% This is largely the domain of the size option files.
+%
+% \begin{macrocode}
+%<*8pt|9pt|10pt|11pt|12pt|text>
+%<+8pt>\ProvidesFile{strayman.8pt}
+%<+9pt>\ProvidesFile{strayman.9pt}
+%<+10pt>\ProvidesFile{strayman.10pt}
+%<+11pt>\ProvidesFile{strayman.11pt}
+%<+12pt>\ProvidesFile{strayman.12pt}
+%<+text>\ProvidesFile{strayman.text}
+% \end{macrocode}
+%
+% \subsection{Font sizes}
+%
+% These are fairly standard, and mainly copied from the original size
+% options.
+%
+% \begin{macro}{\@setparskip}
+%
+% Because we separate paragraphs by vertical space, we need to vary this
+% gap when we change font size. This macro does the job.
+%
+% \begin{macrocode}
+\def\@setparskip{%
+ \relax\ifdim\parskip=\z@\else%
+ \parskip.67\baselineskip\@plus\p@\relax%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\normalsize}
+%
+% Defines the standard size of text in the document.
+%
+% \begin{macrocode}
+\renewcommand\normalsize{%
+%<*8pt>
+ \@setfontsize\normalsize\@viiipt\@xpt%
+ \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
+ \abovedisplayshortskip\z@\@plus3\p@%
+ \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+%</8pt>
+%<*9pt>
+ \@setfontsize\normalsize\@ixpt\@xipt%
+ \abovedisplayskip9\p@\@plus2\p@\@minus5\p@%
+ \abovedisplayshortskip\z@\@plus3\p@%
+ \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+%</9pt>
+%<*10pt>
+ \@setfontsize\normalsize\@xpt\@xiipt%
+ \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
+ \abovedisplayshortskip\z@\@plus3\p@%
+ \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+%</10pt>
+%<*11pt>
+ \@setfontsize\normalsize\@xipt{13.6}%
+ \abovedisplayskip11\p@\@plus3\p@\@minus6\p@%
+ \abovedisplayshortskip\z@\@plus3\p@%
+ \belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
+%</11pt>
+%<*12pt>
+ \@setfontsize\normalsize\@xiipt{14.5}%
+ \abovedisplayskip12\p@\@plus3\p@\@minus7\p@%
+ \abovedisplayshortskip\z@\@plus3\p@%
+ \belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
+%</12pt>
+%<*text>
+ \@setfontsize\normalsize\@xpt\@xiipt%
+ \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
+ \abovedisplayshortskip\z@\@plus3\p@%
+ \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+%</text>
+ \belowdisplayskip\abovedisplayskip%
+ \let\@listi\@listI%
+ \@setparskip%
+}
+\normalsize
+\parskip2ex\@plus\p@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\small}
+%
+% The |\small| size is defined with similar care to |\normalsize|. The
+% list defaults are altered to cope with our different value for |\parskip|.
+% We can then separate this out independently from the typesize.
+%
+% \begin{macrocode}
+%<+text>\let\small\normalsize
+%<*8pt|9pt|10pt|11pt|12pt>
+\newcommand\small{%
+%<*8pt>
+ \@setfontsize\small\@viipt{8.4}%
+ \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
+ \abovedisplayshortskip\z@\@plus2\p@%
+ \belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
+%</8pt>
+%<*9pt>
+ \@setfontsize\small\@viiipt{9.5}%
+ \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
+ \abovedisplayshortskip\z@\@plus2\p@%
+ \belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
+%</9pt>
+%<*10pt>
+ \@setfontsize\small\@ixpt{11}%
+ \abovedisplayskip8.5\p@\@plus3\p@\@minus4\p@%
+ \abovedisplayshortskip\z@\@plus2\p@%
+ \belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
+%</10pt>
+%<*11pt>
+ \@setfontsize\small\@xpt\@xiipt%
+ \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
+ \abovedisplayshortskip\z@\@plus3\p@%
+ \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+%</11pt>
+%<*12pt>
+ \@setfontsize\small\@xipt{13.6}%
+ \abovedisplayskip11\p@\@plus3\p@\@minus6\p@%
+ \abovedisplayshortskip\z@ \@plus3\p@%
+ \belowdisplayshortskip6.5\p@ \@plus3.5\p@\@minus3\p@%
+%</12pt>
+ \def\@listi{%
+ \leftmargin\leftmargini%
+ \topsep\z@%
+ \parsep\parskip%
+ \itemsep\z@%
+ }%
+ \belowdisplayskip\abovedisplayskip%
+ \@setparskip%
+}
+%</8pt|9pt|10pt|11pt|12pt>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\footnotesize}
+%
+% This is also defined with the meticulous care of |\normalsize|, and
+% altered in the same way as for |\small|.
+%
+% \begin{macrocode}
+%<+text>\let\footnotesize\normalsize
+%<*8pt|9pt|10pt|11pt|12pt>
+\newcommand\footnotesize{%
+%<*8pt>
+ \@setfontsize\footnotesize\@vipt\@viipt%
+ \abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
+ \abovedisplayshortskip\z@\@plus\p@%
+ \belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
+%</8pt>
+%<*9pt>
+ \@setfontsize\footnotesize\@viipt{8.4}%
+ \abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
+ \abovedisplayshortskip\z@\@plus\p@%
+ \belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
+%</9pt>
+%<*10pt>
+ \@setfontsize\footnotesize\@viiipt{9.5}%
+ \abovedisplayskip6\p@\@plus2\p@\@minus4\p@%
+ \abovedisplayshortskip\z@\@plus\p@%
+ \belowdisplayshortskip3\p@\@plus\p@\@minus2\p@%
+%</10pt>
+%<*11pt>
+ \@setfontsize\footnotesize\@ixpt{11}%
+ \abovedisplayskip8\p@\@plus2\p@\@minus4\p@%
+ \abovedisplayshortskip\z@\@plus\p@%
+ \belowdisplayshortskip4\p@\@plus2\p@\@minus2\p@%
+%</11pt>
+%<*12pt>
+ \@setfontsize\footnotesize\@xpt\@xiipt
+ \abovedisplayskip10\p@\@plus2\p@\@minus5\p@%
+ \abovedisplayshortskip\z@\@plus3\p@%
+ \belowdisplayshortskip6\p@\@plus3\p@\@minus3\p@%
+%</12pt>
+ \def\@listi{%
+ \leftmargin\leftmargini%
+ \topsep\z@%
+ \parsep\parskip%
+ \itemsep\z@%
+ }%
+ \belowdisplayskip\abovedisplayskip%
+ \@setparskip%
+}
+%</8pt|9pt|10pt|11pt|12pt>
+% \end{macrocode}
+% \end{macro}
+%
+% The other sizes are all much simpler. We introduce a new size,
+% |\listingsize|, which is used for the \env{listing} environment, to ensure
+% that 77 columns of text fit across an A5 sheet.
+%
+% \begin{macrocode}
+%<*8pt>
+\newcommand\scriptsize{\@setfontsize\scriptsize\@vpt\@vipt\@setparskip}
+\newcommand\tiny{\@setfontsize\tiny{4}\@vpt\@setparskip}
+\newcommand\large{\@setfontsize\large\@xpt\@xiipt\@setparskip}
+\newcommand\Large{\@setfontsize\Large\@xipt{13}\@setparskip}
+\newcommand\LARGE{\@setfontsize\LARGE\@xiipt\@xivpt\@setparskip}
+\newcommand\huge{\@setfontsize\huge\@xviipt{20}\@setparskip}
+\newcommand\Huge{\@setfontsize\Huge\@xxpt{26}\@setparskip}
+\newcommand\listingsize{\@setfontsize\listingsize\@viipt\@viiipt\@setparskip}
+%</8pt>
+%<*9pt>
+\newcommand\scriptsize{\@setfontsize\scriptsize\@vipt\@viipt\@setparskip}
+\newcommand\tiny{\@setfontsize\tiny\@vpt\@vipt\@setparskip}
+\newcommand\large{\@setfontsize\large\@xipt{13}\@setparskip}
+\newcommand\Large{\@setfontsize\Large\@xiipt{14.4}\@setparskip}
+\newcommand\LARGE{\@setfontsize\LARGE\@xivpt{17}\@setparskip}
+\newcommand\huge{\@setfontsize\huge\@xviipt{20}\@setparskip}
+\newcommand\Huge{\@setfontsize\Huge\@xxpt{26}\@setparskip}
+\newcommand\listingsize{\@setfontsize\listingsize\@viipt\@viiipt\@setparskip}
+%</9pt>
+%<*10pt>
+\newcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt\@setparskip}
+\newcommand\tiny{\@setfontsize\tiny\@vpt\@vipt\@setparskip}
+\newcommand\large{\@setfontsize\large\@xiipt{14}\@setparskip}
+\newcommand\Large{\@setfontsize\Large\@xivpt{18}\@setparskip}
+\newcommand\LARGE{\@setfontsize\LARGE\@xviipt{22}\@setparskip}
+\newcommand\huge{\@setfontsize\huge\@xxpt{25}\@setparskip}
+\newcommand\Huge{\@setfontsize\Huge\@xxvpt{30}\@setparskip}
+\newcommand\listingsize{\@setfontsize\listingsize\@viipt\@viiipt\@setparskip}
+%</10pt>
+%<*11pt>
+\newcommand\scriptsize{\@setfontsize\scriptsize\@viiipt{9.5}\@setparskip}
+\newcommand\tiny{\@setfontsize\tiny\@vipt\@viipt\@setparskip}
+\newcommand\large{\@setfontsize\large\@xiipt{14}\@setparskip}
+\newcommand\Large{\@setfontsize\Large\@xivpt{18}\@setparskip}
+\newcommand\LARGE{\@setfontsize\LARGE\@xviipt{22}\@setparskip}
+\newcommand\huge{\@setfontsize\huge\@xxpt{25}\@setparskip}
+\newcommand\Huge{\@setfontsize\Huge\@xxvpt{30}\@setparskip}
+\newcommand\listingsize{\@setfontsize\listingsize\@viiipt{9.5}\@setparskip}
+%</11pt>
+%<*12pt>
+\newcommand\scriptsize{\@setfontsize\scriptsize\@viiipt{9.5}\@setparskip}
+\newcommand\tiny{\@setfontsize\tiny\@vipt\@viipt\@setparskip}
+\newcommand\large{\@setfontsize\large\@xivpt{18}\@setparskip}
+\newcommand\Large{\@setfontsize\Large\@xviipt{22}\@setparskip}
+\newcommand\LARGE{\@setfontsize\LARGE\@xxpt{25}\@setparskip}
+\newcommand\huge{\@setfontsize\huge\@xxvpt{30}\@setparskip}
+\let\Huge\huge
+\newcommand\listingsize{\@setfontsize\listingsize\@viiipt{9.5}\@setparskip}
+%</12pt>
+%<*text>
+\def\scriptsize{\@setfontsize\scriptsize\@xpt\@xiipt\@setparskip}
+\let\tiny\scriptsize
+\let\large\scriptsize
+\let\Large\scriptsize
+\let\LARGE\scriptsize
+\let\huge\scriptsize
+\let\Huge\scriptsize
+\let\listingsize\scriptsize
+%
+\let\txt@selectfont\selectfont
+\def\selectfont{%
+ \fontfamily\ttdefault%
+ \fontseries{m}%
+ \fontshape{n}%
+ \txt@selectfont%
+}
+%</text>
+%</8pt|9pt|10pt|11pt|12pt|text>
+% \end{macrocode}
+%
+% \subsection{Paragraph layout}
+%
+% Here we define various paragraph layout parameters.
+%
+% First, set up the line separation parameters. |\baselineskip| is set
+% up by the individual size commands.
+%
+% \begin{macrocode}
+%<*strayman>
+\lineskip\p@
+\normallineskip\p@
+% \end{macrocode}
+%
+% We don't try to stretch the baselines apart:
+%
+% \begin{macrocode}
+\renewcommand\baselinestretch{}
+% \end{macrocode}
+%
+% We don't indent paragraphs at all; instead, we separate them with blank
+% lines. The vertical gap is worked out in the size command; we just clear
+% |\parindent|.
+%
+% \begin{macrocode}
+\parindent\z@
+% \end{macrocode}
+%
+% Set up some standard penalty values.
+%
+% \begin{macrocode}
+\@lowpenalty 51
+\@medpenalty 151
+\@highpenalty 301
+%</strayman>
+% \end{macrocode}
+%
+% \subsection{Page layout}
+%
+% Our layout is a bit different to the standard \LaTeX\ ones: we leave a lot
+% of space down the left hand side: this is reserved for headings and
+% marginal notes.
+%
+% Calculating the size of the space on the left, which we call |\leftindent|,
+% is complicated. We want to use as much of the width of the page as
+% possible, unlike the \LaTeX\ defaults, making sure that we can fit on
+% 77 columns of |\listingsize\tt| text. We also try to make space for a
+% reasonable amount of marginal text, although we don't worry too much if
+% that suffers.
+%
+% The calculation is done as follows. More than about 40\,mm of margin will
+% look very strange. We must have at least 104\,mm of main text, which
+% leaves 20\,mm for the notes on A5 paper (actually, 17\,mm, since we leave
+% 3\,mm gap between the notes and the main text). We divide the page
+% horizontally into $s$\,mm of left border, $m$\,mm of marginal notes,
+% $t$\,mm of body text, and another $s$\,mm of right border, giving
+% a total of $w$\,mm. The value $s$ is given to us by the parameter
+% |\pagesurround|.
+%
+% Articles look odd with a big gap down the side, so this is reduced when
+% necessary.
+%
+% We calculate the quantity~$m$ as $\min\bigl(40,17(w-2s-3)/121+3\bigr)$\@.
+% Then we calculate $t=w-m-24-3$.
+%
+% \begin{macrocode}
+%<*8pt|9pt|10pt|11pt|12pt|text>
+\newdimen\leftindent
+%<*8pt|9pt|10pt|11pt|12pt>
+\leftindent\paperwidth
+\if@offsetpages
+ \advance\leftindent-2\pagesurround
+ \advance\leftindent-3mm
+ \leftindent0.1405\leftindent
+ \advance\leftindent3mm
+ \ifdim\leftindent>40mm\relax
+ \leftindent40mm
+ \fi
+ \if@article\divide\leftindent\tw@\fi
+ \ifdim\leftindent<15mm\leftindent15mm\fi
+\else
+ \leftindent\z@
+\fi
+%</8pt|9pt|10pt|11pt|12pt>
+%<+text>\leftindent8\tt@chw
+% \end{macrocode}
+%
+% In two-column layouts, we prevent headings from being outdented, by
+% zeroing |\sectindent|. Chapter headings and suchlike are still outdented
+% as before. We do not support margin paragraphs in two-column layouts.
+%
+% \begin{macrocode}
+\newdimen\sectindent
+\if@twocolumn
+ \sectindent\z@
+\else
+ \sectindent\if@numbering\z@\else\if@article\else\tw@\fi\leftindent\fi
+\fi
+% \end{macrocode}
+%
+% Having set up the size of the margin, we can get on with the rest of the
+% setting up.
+%
+% First, we fix |\hoffset| and |\voffset| so we can work on the whole size
+% of the paper.
+%
+% \begin{macrocode}
+\advance\hoffset-1in
+\advance\voffset-1in
+% \end{macrocode}
+%
+% Now we can design the page layout in earnest. We begin with the vertical
+% layout.
+%
+% \begin{macrocode}
+%<+8pt>\topskip8\p@
+%<+9pt>\topskip9\p@
+%<+10pt>\topskip10\p@
+%<+11pt>\topskip11\p@
+%<+12pt>\topskip12\p@
+%<+text>\topskip\tt@chh
+%<-text>\topmargin\pagesurround
+%<+text>\topmargin\z@
+%<-text>\headheight12\p@
+%<+text>\headheight12\p@
+%<-text>\headsep.5\pagesurround
+%<+text>\headsep2\tt@chh
+%<+text>\advance\headsep-12\p@
+%<-text>\footskip12\p@
+%<-text>\advance\footskip.5\pagesurround
+%<+text>\footskip2\tt@chh
+\textheight\paperheight
+%<-text>\advance\textheight-24\p@
+%<-text>\advance\textheight-3\pagesurround
+%<+text>\advance\textheight-4\tt@chh
+% \end{macrocode}
+%
+% Now we define the horizontal layout.
+%
+% \begin{macrocode}
+\oddsidemargin\leftindent
+%<-text>\advance\oddsidemargin\pagesurround
+\evensidemargin\oddsidemargin
+\textwidth\paperwidth
+ \advance\textwidth-\oddsidemargin
+%<-text> \advance\textwidth-\pagesurround
+%<-text>\marginparsep3mm
+%<+text>\marginparsep\tt@chw
+\marginparwidth\leftindent
+ \advance\marginparwidth-\marginparsep
+% \end{macrocode}
+%
+% Setting |\maxdepth| is fairly simple. This looks odd, because normally
+% there's some messing for compatibility with \LaTeX~2.09.
+%
+% \begin{macrocode}
+\maxdepth.5\topskip
+\@maxdepth\maxdepth
+% \end{macrocode}
+%
+% Marginal notes need some setting up.
+%
+% \begin{macrocode}
+\marginparpush5\p@
+% \end{macrocode}
+%
+% Footnotes need some setting up now.
+%
+% \begin{macrocode}
+%<+8pt>\footnotesep5.8\p@
+%<+9pt>\footnotesep6.2\p@
+%<+10pt>\footnotesep6.65\p@
+%<+11pt>\footnotesep7.7\p@
+%<+12pt>\footnotesep8.4\p@
+%<+8pt>\setlength{\skip\footins}{7\p@\@plus4\p@\@minus2\p@}
+%<+9pt>\setlength{\skip\footins}{8\p@\@plus4\p@\@minus2\p@}
+%<+10pt>\setlength{\skip\footins}{9\p@\@plus4\p@\@minus2\p@}
+%<+11pt>\setlength{\skip\footins}{10\p@\@plus4\p@\@minus2\p@}
+%<+12pt>\setlength{\skip\footins}{10.8\p@\@plus4\p@\@minus2\p@}
+%</8pt|9pt|10pt|11pt|12pt|text>
+% \end{macrocode}
+%
+% \subsection{Float placement}
+%
+% First, we determine how we position the floats on the page.
+%
+% \begin{macrocode}
+%<*strayman>
+\setcounter{topnumber}{2}
+\renewcommand\topfraction{.7}
+\setcounter{bottomnumber}{1}
+\renewcommand\bottomfraction{.3}
+\setcounter{totalnumber}{3}
+\renewcommand\textfraction{.1}
+\renewcommand\floatpagefraction{.8}
+\setcounter{dbltopnumber}{2}
+\renewcommand\dbltopfraction{.7}
+\renewcommand\dblfloatpagefraction{.5}
+%</strayman>
+% \end{macrocode}
+%
+% Now we define the glue which surrounds floats.
+%
+% \begin{macrocode}
+%<*8pt|9pt|10pt|11pt|12pt>
+\floatsep12\p@\@plus2\p@\@minus2\p@
+\textfloatsep20\p@\@plus2\p@\@minus4\p@
+\dbltextfloatsep20\p@\@plus2\p@\@minus4\p@
+%<+8pt|9pt|10pt|11pt>\intextsep12\p@\@plus2\p@\@minus 2\p@
+%<+8pt|9pt|10pt|11pt>\dblfloatsep12\p@\@plus2\p@\@minus 2\p@
+%<+12pt>\intextsep14\p@\@plus4\p@\@minus 4\p@
+%<+12pt>\dblfloatsep14\p@\@plus2\p@\@minus 4\p@
+% \end{macrocode}
+%
+% We must now define the parameters for float pages and columns.
+%
+% \begin{macrocode}
+\@fptop0\p@\@plus 1fil
+%<+8pt|9pt|10pt|11pt>\@fpsep8\p@\@plus2fil
+%<+12pt>\@fpsep10\p@\@plus2fil
+\@fpbot0\p@\@plus 1fil
+%
+\@dblfptop0\p@\@plus 1fil
+%<+8pt|9pt|10pt|11pt>\@dblfpsep8\p@\@plus 2fil
+%<+12pt>\@dblfpsep10\p@\@plus2fil
+\@dblfpbot0\p@\@plus 1fil
+%</8pt|9pt|10pt|11pt|12pt>
+% \end{macrocode}
+%
+% \section{Headers and footers}
+%
+% This part defines the standard page styles. By default, \strayman\
+% imports \package{fancyheadings} and uses them, although this section is
+% retained in case anything actually needs the original \LaTeX-style
+% headings.
+%
+% \begin{macrocode}
+%<*strayman>
+\def\ps@headings{%
+\let\@oddfoot\@empty\let\@evenfoot\@empty
+\def\@evenhead{\thepage\hfil\slshape\leftmark}%
+\def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
+\let\@mkboth\markboth
+\def\chaptermark##1{\markboth {##1}{}}%
+\def\sectionmark##1{\markright {##1}}%
+}
+%
+\def\ps@myheadings{%
+ \let\@oddfoot\@empty\let\@evenfoot\@empty
+ \def\@evenhead{\thepage\hfil\slshape\leftmark}%
+ \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
+ \let\@mkboth\@gobbletwo
+ \let\chaptermark\@gobble
+ \let\sectionmark\@gobble
+}
+% \end{macrocode}
+%
+% \section{Titles}
+%
+% \begin{macro}{\maketitle}
+% This is a bit of a thorny issue at the moment. Really, these titles need
+% a complete rewrite. The |\maketitle| command will only be used for inside
+% front covers anyway. I'm wondering if it wouldn't be better just to use
+% special case code for each individual manual. Until a decision is made,
+% I'll leave this as it was in \package{book}.
+%
+% \begin{note}
+% This code is largely uncommented. It seems to be fairly straightforward,
+% and if I do need to change it, I'll probably start again from scratch
+% anyway.
+% \end{note}
+%
+% \begin{macrocode}
+\if@titlepage
+%
+ \newcommand\maketitle{%
+ \begin{titlepage}%
+ \let\footnotesize\small%
+ \let\footnoterule\relax%
+ \null\vfil%
+ \vskip 60\p@%
+ \begin{center}%
+ {\LARGE\@title\par}%
+ \vskip3em%
+ {%
+ \large%
+ \lineskip.75em%
+ \begin{tabular}[t]{c}%
+ \@author%
+ \end{tabular}%
+ \par%
+ }%
+ \vskip1.5em%
+ {\large \@date \par}% % Set date in \large size.
+ \end{center}%
+ \par%
+ \@thanks%
+ \vfil\null%
+ \end{titlepage}%
+ \setcounter{footnote}{0}%
+ \let\thanks\relax%
+ \let\maketitle\relax%
+ \gdef\@thanks{}%
+ \gdef\@author{}%
+ \gdef\@title{}%
+ }
+%
+\else
+%
+ \newcommand\maketitle{%
+ \par%
+ \begingroup%
+ \renewcommand\thefootnote{\fnsymbol{footnote}}%
+ \def\@makefnmark{\hb@xt@\z@{$\m@th^{\@thefnmark}$\hss}}%
+ \long\def\@makefntext##1{%
+ \parindent1em\noindent%
+ \hb@xt@1.8em{\hss$\m@th^{\@thefnmark}$}##1%
+ }%
+ \if@twocolumn%
+ \ifnum\col@number=\@ne%
+ \@maketitle%
+ \else%
+ \twocolumn[\@maketitle]%
+ \fi%
+ \else%
+ \newpage%
+ \global\@topnum\z@% % Prevents figures from going at top of page.
+ \@maketitle%
+ \fi%
+ \thispagestyle{plain}%
+ \@thanks%
+ \endgroup%
+ \setcounter{footnote}{0}%
+ \let\thanks\relax%
+ \let\maketitle\relax%
+ \let\@maketitle\relax%
+ \gdef\@thanks{}%
+ \gdef\@author{}%
+ \gdef\@title{}%
+ }
+%
+\fi
+%
+\def\@maketitle{%
+ \newpage%
+ \null%
+ \vskip2em%
+ \begin{center}%
+ {\LARGE\@title\par}%
+ \vskip1.5em%
+ {%
+ \large%
+ \lineskip.5em%
+ \begin{tabular}[t]{c}%
+ \@author%
+ \end{tabular}%
+ \par%
+ }%
+ \vskip 1em%
+ {\large\@date}%
+ \end{center}%
+ \par%
+ \vskip1.5em%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{titlepage}
+%
+% The \env{titlepage} environment typesets its contents on a title page.
+% The implementation is fairly straightforward: we just need to do some
+% fiddling with two-column layouts. We also add in some hacking to make
+% title pages centred properly, a bit like the \env{central} environment.
+%
+% \begin{macrocode}
+\newenvironment{titlepage}{%
+ \cleardoublepage%
+ \if@twocolumn%
+ \@restonecoltrue\onecolumn%
+ \else%
+ \@restonecolfalse\newpage%
+ \fi%
+ \centrepage%
+ \if@compatibility%
+ \setcounter{page}{0}%
+ \fi%
+}{%
+ \thispagestyle{empty}%
+ \if@restonecol%
+ \twocolumn%
+ \else%
+ \newpage%
+ \fi%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{macro}{\centrepage}
+%
+% Change the page layout to centre everything properly. We guard against
+% this sort of thing happening again by clearing |\leftindent| and
+% |\sectindent|. This should only be cleared after the page has been
+% finished, for obvious reasons.
+%
+% \begin{macrocode}
+\def\centrepage{%
+ \advance\oddsidemargin-\leftindent%
+ \advance\evensidemargin-\leftindent%
+ \advance\textwidth\leftindent%
+ \advance\linewidth\leftindent%
+ \advance\leftmargini0.5\leftindent%
+ \leftindent\z@%
+ \sectindent\z@%
+ \hsize\textwidth%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Sectioning commands}
+%
+% In \strayman, quite a lot of the sectioning is different. We
+% don't tend to number sections much. Also, the chapter heading style has
+% been completely rewritten (several times).
+%
+% \subsection{Setting up the counters}
+%
+% This is pretty simple stuff.
+%
+% \begin{macrocode}
+\newcommand\chaptermark[1]{}
+\setcounter{secnumdepth}{\if@numbering\if@runinsubsubsec2\else3\fi\else0\fi}
+\newcounter {part}
+\newcounter {chapter}
+\newcounter {section}[chapter]
+\newcounter {subsection}[section]
+\newcounter {subsubsection}[subsection]
+\newcounter {paragraph}[subsubsection]
+\newcounter {subparagraph}[paragraph]
+\renewcommand\thepart {\Roman{part}}
+\renewcommand\thechapter {\arabic{chapter}}
+\if@article
+ \renewcommand\thesection {\arabic{section}}
+\else
+ \renewcommand\thesection {\thechapter.\arabic{section}}
+\fi
+\renewcommand\thesubsection {\thesection.\arabic{subsection}}
+\renewcommand\thesubsubsection {\thesubsection .\arabic{subsubsection}}
+\renewcommand\theparagraph {\thesubsubsection.\arabic{paragraph}}
+\renewcommand\thesubparagraph {\theparagraph.\arabic{subparagraph}}
+% \end{macrocode}
+%
+% \subsection{Frontmatter, mainmatter and backmatter}
+%
+% We start off thinking we're in the main matter. The user ought to put a
+% |\frontmatter| command at the beginning of the document if this is not
+% correct, as it usually won't be.
+%
+% \begin{macrocode}
+\newif\if@mainmatter
+\@mainmattertrue
+\newcommand\frontmatter{%
+ \cleardoublepage%
+ \@mainmatterfalse%
+ \pagenumbering{roman}%
+}
+\newcommand\mainmatter{%
+ \cleardoublepage%
+ \@mainmattertrue%
+ \pagenumbering{arabic}%
+}
+\newcommand\backmatter{%
+ \if@openright%
+ \cleardoublepage%
+ \else%
+ \clearpage%
+ \fi%
+ \@mainmatterfalse%
+}
+% \end{macrocode}
+%
+% \subsection{Abstracts}
+%
+% \begin{environment}{abstract}
+%
+% The \env{abstract} environment reduces the type size and margins slightly.
+% Abstracts are placed on their own pages when the |titlepage| option is
+% enabled. The code is filched from the LaTeX article class.
+%
+% \begin{macrocode}
+\if@titlepage
+ \newenvironment{abstract}{%
+ \titlepage
+ \null\vfil
+ \@beginparpenalty\@lowpenalty
+ \begin{center}%
+ \bfseries \abstractname
+ \@endparpenalty\@M
+ \end{center}}%
+ {\par\vfil\null\endtitlepage}
+\else
+ \newenvironment{abstract}{%
+ \if@twocolumn
+ \section*{\abstractname}%
+ \else
+ \small
+ \list{}{%
+ \def\makelabel##1{%
+ \normalfont%
+ \fontseries{b}\fontfamily\headdefault\selectfont%
+ ##1%
+ }%
+ \labelsep1em\labelwidth\z@\itemindent\labelsep%
+ \rightmargin\leftmargin%
+ }
+ \item[\abstractname]%
+ \fi}
+ {\if@twocolumn\else\endlist\fi}
+\fi
+% \end{macrocode}
+% \end{environment}
+%
+% \subsection{Appendices}
+%
+% \begin{macro}{\appendix}
+%
+% This command sets everything up to typeset the appendix.
+%
+% \begin{macrocode}
+\newcommand\appendix{%
+ \par%
+ \setcounter{chapter}{0}%
+ \setcounter{section}{0}%
+ \renewcommand\@chapapp{\appendixname}%
+ \if@article%
+ \renewcommand\thesection{\Alph{section}}%
+ \else%
+ \renewcommand\thechapter{\Alph{chapter}}%
+ \fi%
+ \@appendixtrue%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Parts}
+%
+% Part headings are typeset on completely unadorned sheets, devoid of page
+% numbers and suchlike. Because of the strange page layout, we have to
+% put the part heading into a |central| environment. to stop the page looking
+% horribly lopsided.
+%
+% \begin{macro}{\part}
+%
+% The |\part| macro moves to an appropriate page, changes the pagestyle to
+% empty to switch off page numbering, and then calls |\@part| or |\@spart|
+% as appropriate, according to whether a \lit* was supplied. We put some
+% |\vfil| glue in, to vertically centre anything that these commands typeset,
+% and ensure printing in a single column.
+%
+% \begin{macrocode}
+\newcommand\part{%
+ \cleardoublepage%
+ \thispagestyle{empty}%
+ \if@twocolumn%
+ \onecolumn%
+ \@tempswatrue%
+ \else%
+ \@tempswafalse%
+ \fi%
+ \hbox{}\vfil%
+ \begin{centrepage}%
+ \secdef\@part\@spart%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\@part}
+%
+% This is where most of the part heading typesetting is done. We stick a
+% line in the contents file, clear the heading markers, and typeset the
+% heading in the biggest letters we can find. When we're done, we call
+% |\@endpart| to do some common cleaning up.
+%
+% \begin{macrocode}
+\def\@part[#1]#2{%
+ \ifnum\c@secnumdepth>-2\relax%
+ \refstepcounter{part}%
+ \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
+ \else%
+ \addcontentsline{toc}{part}{#1}%
+ \fi%
+ \markboth{}{}%
+ \centering%
+ \interlinepenalty\@M%
+ \reset@font%
+ \ifnum\c@secnumdepth>-2\relax%
+ \huge\bfseries\headfam\partname~\thepart%
+ \par%
+ \vskip20\p@
+ \fi%
+ \normalfont\Huge\bfseries\headfam#2\par%
+ \@endpart%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@spart}
+%
+% Here we typeset just the part heading: numbers have been suppressed. Also
+% we don't put things into the contents file. Otherwise, this is similar to
+% |\@part|.
+%
+% \begin{macrocode}
+\def\@spart#1{%
+ \centering%
+ \interlinepenalty\@M%
+ \reset@font%
+ \normalfont\Huge\bfseries\headfam#1\par%
+ \@endpart%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@endpart}
+%
+% This does the clearing up operation after a part has been typeset. We
+% insert the other |\vfil| glue to centre the heading, clear the other
+% side of the page, if printing two-sided, and return if necessary to
+% two-column printing.
+%
+% \begin{macrocode}
+\def\@endpart{%
+ \vfil\newpage%
+ \end{centrepage}%
+ \if@twoside%
+ \hbox{}%
+ \thispagestyle{empty}%
+ \newpage%
+ \fi%
+ \if@tempswa%
+ \twocolumn%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Chapters}
+%
+% The chapter typesetting has been more-or-less rewritten. We'll follow this
+% in a reasonable amount of detail.
+%
+% \begin{macro}{\@chapapp}
+%
+% Because |\appendix| needs to change what chapters are called, we add a
+% level of indirection through |\@chapapp|:
+%
+% \begin{macrocode}
+\newcommand\@chapapp{\chaptername}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\chapter}
+%
+% The |\chapter| command is the main dispatcher for chapters. We move to
+% an appropriate page, depending on the |openright| setting, suppress
+% headers, and then call |\@chapter| or |\@schapter| as appropriate.
+%
+% \begin{macrocode}
+\newcommand\chapter{%
+ \if@openright%
+ \cleardoublepage%
+ \else%
+ \clearpage%
+ \fi%
+ \thispagestyle{plain}%
+ \global\@topnum\z@%
+ \@afterindentfalse%
+ \secdef\@chapter\@schapter%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\@chapter}
+%
+% There's a lot of messing about to do, depending on whether we're in the
+% main matter and so on. We'll take this carefully.
+%
+% \begin{macrocode}
+\def\@chapter[#1]#2{%
+% \end{macrocode}
+%
+% The first thing to do is put a line in the contents table. We need to
+% check |secnumdepth| and the |mainmatter| flag for this: we should only
+% include a number if both these tests pass. In this case, we also type a
+% message on the terminal.
+%
+% \begin{macrocode}
+ \ifnum\c@secnumdepth>\m@ne%
+ \if@mainmatter%
+ \refstepcounter{chapter}%
+ \typeout{\@chapapp\space\thechapter.}%
+ \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
+ \else
+ \addcontentsline{toc}{chapter}{#1}%
+ \fi
+ \else
+ \addcontentsline{toc}{chapter}{#1}
+ \fi
+% \end{macrocode}
+%
+% Now we put a bit of space in the lists of figures and tables, and set up
+% the mark to put the chapter heading in the running header.
+% \begin{macrocode}
+ \chaptermark{#1}%
+ \addtocontents{lof}{\protect\addvspace{10\p@}}%
+ \addtocontents{lot}{\protect\addvspace{10\p@}}%
+% \end{macrocode}
+%
+% Finally, we need to decide how to typeset the chapter heading. On
+% single-column chapters, this is easy. On double-column formats, we need
+% to do horrid things with |\@topnewpage|.
+%
+% \begin{macrocode}
+ \if@twocolumn%
+ \@topnewpage[\@makechapterhead{%
+ \hb@xt@.5\leftindent{\thechapter\hfil}%
+ }{#2}]%
+ \else%
+ \@makechapterhead{%
+ \hb@xt@.5\leftindent{\thechapter\hfil}%
+ }{#2}%
+ \@afterheading%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@makechapterhead}
+%
+% This macro actually does the job of typesetting a chapter heading. Call
+% this routine as |\@makechapterhead{|\synt{number}|}{|\synt{title}|}|.
+% Here, \synt{number} is how to typeset the chapter number, and \synt{title}
+% is the rest of the title. To suppress the number, just leave \synt{number}
+% empty. The number is only typeset when it is correct to do so anyway.
+%
+% The spacing is rather awkward. We have to cope with two-column layouts,
+% which seem to require different spacing. In a double-column layout,
+% the title is normally one |\baselineskip| too high. Also, the space I
+% add at the bottom of the heading gets eaten in double-column chapters,
+% because I'm actually typesetting into a vbox which is floated to the top
+% by \LaTeX\ in a fairly horrid way. This can't really be worked around,
+% so we just make the space beneath the heading equal to |\dbltextfloatsep|,
+% which is what gets added anyway.
+%
+% The other snags are to do with the rule after the chapter heading.
+% Firstly, this is meant to be typeset into the left margin, like the
+% heading itself, which is a bit messy. More awkwardly, we have to be
+% careful not to let the depth of the line vary when the chapter heading has
+% descenders, although obviously we must lower the rule if the heading really
+% is very deep indeed.
+%
+%
+% We'll approach this a bit at a time.
+%
+% \begin{macrocode}
+\def\@makechapterhead#1#2{%
+ \begingroup% % Stop my hacking messing things up
+% \end{macrocode}
+%
+% First, the top spacing. This is divided into two parts, by an invisible
+% rule: the |\vskip| above the rule is eaten by \TeX\ if this is a genuine
+% new page, but put into the floating vbox if this is a two-column affair.
+% The second bit is added in both cases.
+%
+% \begin{macrocode}
+ \vskip\baselineskip% % This is gobbled in single column
+ \hrule\@height\z@% % Stops TeX from binning my vskips
+ \vskip32\p@% % Start chapters in a funny place
+% \end{macrocode}
+%
+% Now we actually typeset the heading. This is fairly simple: we must just
+% check that we need to typeset the number.
+%
+% \begin{macrocode}
+ \normalfont\Huge\bfseries\headfam% % Choose a nice font for it
+ \raggedright % Don't justify -- it looks nasty
+ \@hangfrom{\hskip-\leftindent}% % Start text at `real left margin'
+ \ifnum\c@secnumdepth>\m@ne% % Do we typeset chapter numbers?
+ \if@mainmatter% % Are we past the front matter?
+ #1% % Yes -- then typeset the number
+ \fi\fi% % Now back to normality
+ {#2}% % Typeset the actual chapter head
+ \par\nobreak% % Back to vmode again, please
+% \end{macrocode}
+%
+% The next tricky bit is the space before the ruleoff. We must be careful
+% here:
+%
+% \begin{itemize}
+%
+% \item We want the rule to be the right depth below the heading baseline,
+% regardless of whether the heading contains descenders: helpfully, \TeX\
+% omits |\baselineskip| glue before and after rules.
+%
+% \item We want the rule to always be below any oddly deep descenders that
+% a strange user might throw at us (e.g., horrid fractions or weird
+% |\vrule|s).
+%
+% \end{itemize}
+%
+% We accomplish this by scrutinising |\prevdepth| carefully.
+%
+% \begin{macrocode}
+ \@tempdima14\p@% % Be this low below the baseline
+ \advance\@tempdima-\prevdepth% % This is the actual skip then
+ \ifdim\@tempdima<8\p@% % Is this not enough skippage?
+ \@tempdima8\p@% % No: then skip some more
+ \fi%
+ \vskip\@tempdima% % Skip a bit below the title
+% \end{macrocode}
+%
+% Now we can set the rule. This needs a little care.
+%
+% \begin{macrocode}
+ \@tempskipa\textwidth% % Find the width of the column
+ \advance\@tempskipa\leftindent% % Add on the big lefthand gap
+ \nointerlineskip% % Don't add any more space please
+ \moveleft\leftindent\vbox{% % Shift something left by an amount
+ \hrule\@width\@tempskipa% % Typeset the rule nicely
+ }%
+ \nointerlineskip% % Don't leave a gap beneath it
+% \end{macrocode}
+%
+% Finally, we leave a gap. In two-column layouts this is done for us, and
+% \LaTeX\ gobbles this glue and replaces it with |\dbltextfloatsep|. To make
+% things consistent, this is the glue we use anyway.
+%
+% \begin{macrocode}
+ \nobreak% % This would be a bad place to break
+ \vspace{\dbltextfloatsep}% % Add in some extra glue beneath
+ \endgroup%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@makeschapterhead}
+%
+% This is now just a veneer onto |\@makechapterhead|. It's needed, because
+% other bits of \LaTeX\ call it.
+%
+% \begin{macrocode}
+\def\@makeschapterhead{%
+ \@makechapterhead{}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@schapter}
+%
+% This macro typesets a starred chapter heading. This is terribly simple,
+% compared to the sort of things we've been doing so far.
+%
+% \begin{macrocode}
+\def\@schapter#1{%
+ \if@twocolumn%
+ \@topnewpage[\@makeschapterhead{#1}]%
+ \else%
+ \@makeschapterhead{#1}%
+ \@afterheading%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{The other sectioning commands}
+%
+% These are all defined through |\@startsection|. They've been modified
+% to typeset sections and subsections hanging into the left margin, and to
+% moderate the amount of following space, due to the extra |\parskip| already
+% introduced.
+%
+% \begin{macrocode}
+\newcommand\section{%
+ \@startsection%
+ {section}% % Section name (for contents)
+ {1}% % Level number (for numbering)
+ {-.5\sectindent}% % Indentation of title
+ {-1.5ex\@plus-1ex\@minus-.2ex}% % Space after title (vert/horiz)
+ {.3ex\@plus.2ex}% % Space before title
+ {\reset@font\Large\bfseries\headfam}% How to typeset the title
+}
+\newcommand\subsection{%
+ \@startsection%
+ {subsection}%
+ {2}%
+ {-.25\sectindent}%
+ {-1.25ex\@plus-1ex\@minus-.2ex}%
+ {\p@\@plus.2ex}%
+ {\reset@font\large\bfseries\headfam}%
+}
+\if@runinsubsubsec
+\newcommand\subsubsection{%
+ \@startsection%
+ {subsubsection}%
+ {3}%
+ {\z@}%
+ {0pt\@plus1ex\@minus.2ex}%
+ {-1em}%
+ {\reset@font\normalsize\bfseries\headfam}%
+}
+\newcommand\paragraph{%
+ \@startsection%
+ {paragraph}%
+ {4}%
+ {\z@}%
+ {0pt\@plus.5ex\@minus.1ex}%
+ {-1em}%
+ {\reset@font\normalsize\bfseries\headfam}%
+}
+\newcommand\subparagraph{%
+ \@startsection%
+ {subparagraph}%
+ {5}%
+ {\parindent}%
+ {0pt\@plus.5ex\@minus.1ex}%
+ {-1em}%
+ {\reset@font\normalsize\bfseries\headfam}%
+}
+\else
+\newcommand\subsubsection{%
+ \@startsection%
+ {subsubsection}%
+ {3}%
+ {\z@}%
+ {-1.25ex\@plus-1ex\@minus-.2ex}%
+ {\p@\@plus.2ex}%
+ {\reset@font\normalsize\bfseries\headfam}%
+}
+\newcommand\paragraph{%
+ \@startsection%
+ {paragraph}%
+ {4}%
+ {\z@}%
+ {0pt\@plus1ex\@minus.2ex}%
+ {-1em}%
+ {\reset@font\normalsize\bfseries\headfam}%
+}
+\newcommand\subparagraph{%
+ \@startsection%
+ {subparagraph}%
+ {5}%
+ {\parindent}%
+ {0pt\@plus.5ex\@minus.1ex}%
+ {-1em}%
+ {\reset@font\normalsize\bfseries\headfam}%
+}
+\fi
+% \end{macrocode}
+%
+% \subsection{Section number formatting}
+%
+% \begin{macro}{\@seccntformat}
+%
+% The macro is given a section counter and must format it in some nice way.
+%
+% \begin{macrocode}
+\def\@seccntformat#1{%
+ \llap{\csname the#1\endcsname{\normalsize\quad}\hfil}%
+}
+%
+% \subsection{Top level sectioning}
+%
+% \begin{macro}{\@topsect}
+%
+% Articles are divided into sections; other documents are divided into
+% chapters. Things like the table of contents need to know which.
+%
+% \begin{macrocode}
+\if@article
+ \def\@topsect{\section*}
+\else
+ \let\@topsect\chapter
+\fi
+% \end{macrocode}
+%
+% \end{macro}
+%
+%
+% \section{List handling}
+%
+% A surprising number of \LaTeX's environments are defined in terms of
+% lists, many of which hide the fact by putting the entire text in one big
+% item.
+%
+% This part of the document class has to set up lots of list parameters.
+% This is largely the same as the standard classes, altered slightly to cope
+% with the different paragraph spacing.
+%
+% \subsection{General list parameters}
+%
+% Default left margins for lists:
+%
+% \begin{macrocode}
+\if@twocolumn
+ \leftmargini2em
+\else
+ \leftmargini2.2em
+\fi
+\leftmarginii2em
+\leftmarginiii1.87em
+\leftmarginiv1.7em
+\if@twocolumn
+ \leftmarginv.5em
+ \leftmarginvi.5em
+\else
+ \leftmarginv1em
+ \leftmarginvi1em
+\fi
+% \end{macrocode}
+%
+% Other spacing defaults:
+%
+% \begin{macrocode}
+\leftmargin\leftmargini
+\labelsep.5em
+\labelwidth\leftmargini
+\advance\labelwidth-\labelsep
+\partopsep\z@\@plus1\p@\@minus1\p@
+% \end{macrocode}
+%
+% Interline penalties:
+%
+% \begin{macrocode}
+\@beginparpenalty -\@lowpenalty
+\@endparpenalty -\@lowpenalty
+\@itempenalty -\@lowpenalty
+% \end{macrocode}
+%
+% Now we define the defaults for the list environments. These have managed
+% to migrate from the size options into the main document class.
+%
+% \begin{macrocode}
+\def\@listI{%
+ \leftmargin\leftmargini%
+ \parsep\parskip%
+ \topsep\z@%
+ \itemsep\z@%
+}
+\let\@listi\@listI
+\@listi\topsep\parskip%
+\def\@listii{%
+ \leftmargin\leftmarginii%
+ \labelwidth\leftmarginii%
+ \advance\labelwidth-\labelsep%
+}
+\def\@listiii{%
+ \leftmargin\leftmarginiii%
+ \labelwidth\leftmarginiii%
+ \advance\labelwidth-\labelsep%
+ \partopsep\p@\@plus\z@\@minus\p@%
+}
+\def\@listiv{%
+ \leftmargin\leftmarginiv%
+ \labelwidth\leftmarginiv%
+ \advance\labelwidth-\labelsep%
+}
+\def\@listv{%
+ \leftmargin\leftmarginv%
+ \labelwidth\leftmarginv%
+ \advance\labelwidth-\labelsep%
+}
+\def\@listvi{%
+ \leftmargin\leftmarginvi%
+ \labelwidth\leftmarginvi%
+ \advance\labelwidth-\labelsep%
+}
+% \end{macrocode}
+%
+% \subsection{Enumerated lists}
+%
+% We busily redefine all the counters for enumerated lists, and how to
+% typeset them.
+%
+% How to typeset the numbers:
+%
+% \begin{macrocode}
+\renewcommand\theenumi{\arabic{enumi}}
+\renewcommand\theenumii{\alph{enumii}}
+\renewcommand\theenumiii{\roman{enumiii}}
+\renewcommand\theenumiv{\Alph{enumiv}}
+% \end{macrocode}
+%
+% Typesetting the item labels:
+%
+% \begin{macrocode}
+\newcommand\labelenumi{\theenumi.}
+\newcommand\labelenumii{(\theenumii)}
+\newcommand\labelenumiii{\theenumiii.}
+\newcommand\labelenumiv{\theenumiv.}
+% \end{macrocode}
+%
+% And finally how to typeset references to the items:
+%
+% \begin{macrocode}
+\renewcommand\p@enumii{\theenumi}
+\renewcommand\p@enumiii{\theenumi(\theenumii)}
+\renewcommand\p@enumiv{\p@enumiii\theenumiii}
+% \end{macrocode}
+%
+% \subsection{Itemized lists}
+%
+% We set up the various bullet shapes for the itemized lists.
+%
+% \begin{macrocode}
+\newcommand\labelitemi{$\m@th\bullet$}
+\newcommand\labelitemii{\normalfont\bfseries --}
+\newcommand\labelitemiii{$\m@th\ast$}
+\newcommand\labelitemiv{$\m@th\cdot$}
+% \end{macrocode}
+%
+% \subsection{Description lists}
+%
+% This has been redefined a little to make it more sensible. The old version
+% had a weird |\hspace\labelsep| in the labelling macro. This has now been
+% added into the main list definition. You can now redefine
+% |\descriptionlabel| without fear of messing up the spacing.
+%
+% \begin{environment}{description}
+%
+% Here we set up the main list parameters. The label width is zeroed to
+% ensure that the text is always indented nicely.
+%
+% \begin{macrocode}
+\def\description{%
+ \list{}{%
+ \labelwidth\z@%
+ \itemindent-\leftmargin%
+ \advance\itemindent\labelsep%
+ \def\makelabel{\descriptionlabel}%
+ }%
+}
+\let\enddescription\endlist
+% \end{macrocode}
+%
+% \begin{macro}{\descriptionlabel}
+%
+% This typesets a description label. Redefine it the obvious way for
+% different exciting effects.
+%
+% \begin{macrocode}
+\def\descriptionlabel#1{\normalfont\bfseries #1}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{environment}
+%
+% \subsection{Other list-based environments}
+%
+% Several other standard environments are defined in terms of lists. These
+% are all dealt with here.
+%
+% \begin{environment}{verse}
+%
+% The \env{verse} environment is specially fiddled so that |\\| works as it
+% should. There's nothing else exciting about it.
+%
+% \begin{macrocode}
+\newenvironment{verse}{%
+ \let\\\@centercr%
+ \list{}{%
+ \itemsep\z@%
+ \itemindent-1.5em%
+ \listparindent\itemindent%
+ \rightmargin\leftmargin%
+ \advance\leftmargin1.5em%
+ }%
+ \item[]%
+}{%
+ \endlist%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{quotation}
+%
+% The \env{quotation} environment is a pretty standard display, except that
+% we kill off inter-paragraph space. The current definition means that
+% \env{quotation}s are typeset in normal indented-paragraph style, which
+% is inconsistent with the rest of the document style.
+%
+% \begin{macrocode}
+\newenvironment{quotation}{%
+ \list{}{%
+ \listparindent\z@%
+ \itemindent\listparindent%
+ \rightmargin\leftmargin%
+ }%
+ \item[]%
+}{%
+ \endlist%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{quote}
+%
+% This is even simpler. We just pull in the right margin a bit.
+%
+% \begin{macrocode}
+\newenvironment{quote}{%
+ \list{}{%
+ \rightmargin\leftmargin%
+ }%
+ \item[]%
+}{%
+ \endlist%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{display}
+%
+% The \env{display} environment is intended for any other displays which you
+% need to typeset. This is \emph{not} a standard environment.
+%
+% \begin{macrocode}
+\newenvironment{display}{%
+ \list{}{%
+ \leftmargin1em%
+ \rightmargin\leftmargin%
+ \labelsep\z@%
+ \labelwidth\z@%
+ }%
+ \item[]\relax%
+}{%
+ \endlist%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% And some quick hacking of the theorem environment.
+%
+% \section{Other parameters}
+%
+% We define some miscellaneous parameters for standard environments.
+%
+% \begin{macrocode}
+\arraycolsep5\p@
+\tabcolsep6\p@
+\arrayrulewidth.4\p@
+\doublerulesep2\p@
+\tabbingsep\labelsep
+\skip\@mpfootins\skip\footins
+\fboxsep3\p@
+\fboxrule.4\p@
+%
+\if@article
+ \renewcommand\theequation{\arabic{equation}}
+\else
+ \@addtoreset{equation}{chapter}
+ \renewcommand\theequation{\thechapter.\arabic{equation}}
+\fi
+% \end{macrocode}
+%
+% \section{Floats}
+%
+% Since raw \LaTeX\ doesn't actually define any floating objects, we have
+% to do some of the work here. This isn't actually terribly arduous. For
+% a float called \synt{float}, we have to define the following macros:
+%
+% \begin{description}
+% \let\descriptionlabel\relax
+%
+% \item[\texttt{\bslash fps@}\synt{float}] is the default float positioning
+% argument for the float type.
+%
+% \item[\texttt{\bslash ftype@}\synt{float}] is a flag bit for the float
+% type. This is used in \LaTeX's |\output| routine to identify floats of
+% this type.
+%
+% \item[\texttt{\bslash ext@}\synt{float}] is the file extension for the
+% list of these floats (e.g., \lit{lof} for figures).
+%
+% \item[\texttt{\bslash fnum@}\synt{float}] is a macro which generates the
+% caption number. For figures, this expands to `|Figure~\thefigure|'.
+%
+% \end{description}
+%
+% We must also define |\@makecaption|, which typesets a float caption in
+% an appropriate way, and an environment for each type of float.
+%
+% \subsection{Figures}
+%
+% This is all fairly straightforward stuff. First, we create a counter for
+% figures:
+%
+% \begin{macrocode}
+\newcounter{figure}[chapter]
+\if@article
+ \renewcommand\thefigure{\@arabic\c@figure}
+\else
+ \renewcommand\thefigure{\thechapter.\@arabic\c@figure}
+\fi
+% \end{macrocode}
+%
+% Now we define all the macros \LaTeX\ requires.
+%
+% \begin{macrocode}
+\if@herefloats\def\fps@figure{htbp}\else\def\fps@figure{tbp}\fi
+\def\ftype@figure{1}
+\def\ext@figure{lof}
+\def\fnum@figure{\figurename~\thefigure}
+% \end{macrocode}
+%
+% \begin{environment}{figure}
+% \begin{environment}{figure*}
+%
+% Finally, we create the \env{figure} and \env{figure$*$} environments.
+%
+% \begin{macrocode}
+\newenvironment{figure}{\@float{figure}}{\end@float}
+\newenvironment{figure*}{\@dblfloat{figure}}{\end@dblfloat}
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+%
+% \subsection{Tables}
+%
+% This is pretty similar to the figure handling.
+%
+% \begin{macrocode}
+\newcounter{table}[chapter]
+\if@article
+ \renewcommand\thetable{\@arabic\c@table}
+\else
+ \renewcommand\thetable{\thechapter.\@arabic\c@table}
+\fi
+%
+\if@herefloats\def\fps@table{htbp}\else\def\fps@table{tbp}\fi
+\def\ftype@table{2}
+\def\ext@table{lot}
+\def\fnum@table{\tablename~\thetable}
+%
+\newenvironment{table}{\@float{table}}{\end@float}
+\newenvironment{table*}{\@dblfloat{table}}{\end@dblfloat}
+% \end{macrocode}
+%
+% \subsection{Other float parameters}
+%
+% \begin{macro}{\@makecaption}
+%
+% The |\@makecaption| macro is called to display a float caption. It will
+% typeset its argument either centred in a box, if it is short enough, or
+% in a paragraph if it is longer than a line.
+%
+% \begin{macrocode}
+\newlength\abovecaptionskip
+\newlength\belowcaptionskip
+\abovecaptionskip10\p@
+\belowcaptionskip0\p@
+%
+\long\def\@makecaption#1#2{%
+ \vskip\abovecaptionskip%
+ \sbox\@tempboxa{#1: #2}%
+ \ifdim\wd\@tempboxa>\hsize%
+ #1: #2\par%
+ \else%
+ \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
+ \fi%
+ \vskip\belowcaptionskip%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Font commands}
+%
+% We allow the `old' font commands to do sensible \textsf{NFSS} things, since
+% we don't have any legacy documents. This means that we have proper
+% abbreviations for font changes. We also add |\nm| to return to a normal
+% font, whatever that may mean.
+%
+% \begin{macrocode}
+\DeclareOldFontCommand{\rm}{\rmfamily}{\mathrm}
+\DeclareOldFontCommand{\sf}{\sffamily}{\mathsf}
+\DeclareOldFontCommand{\tt}{\ttfamily}{\mathtt}
+\DeclareOldFontCommand{\bf}{\bfseries}{\mathbf}
+\DeclareOldFontCommand{\md}{\mdseries}{\@nomath\md}
+\DeclareOldFontCommand{\it}{\itshape}{\mathit}
+\DeclareOldFontCommand{\up}{\upshape}{\@nomath\up}
+\DeclareOldFontCommand{\sl}{\slshape}{\@nomath\sl}
+\DeclareOldFontCommand{\sc}{\scshape}{\@nomath\sc}
+\DeclareOldFontCommand{\nm}{\normalfont}{\mathnormal}
+% \end{macrocode}
+%
+% Now we define some special commands which only work in maths mode. It
+% seems that older versions of \LaTeX\ (in particular, that at Warwick
+% University) don't define these commands initially, so we'd better not
+% use |\renewcommand| after all. We also dispose of lots of messing with
+% |\protect| by using |\DeclareRobustCommand|.
+%
+% \begin{macrocode}
+\DeclareRobustCommand\cal{\@fontswitch{\relax}{\mathcal}}
+\DeclareRobustCommand\pmit{\@fontswitch{\relax}{\mathnormal}}
+% \end{macrocode}
+%
+% \section{Tables of contents}
+%
+% This section deals with tables of contents, and lists of figures.
+%
+% \subsection{Contents}
+%
+% First, we have to define some parameters.
+%
+% \begin{macrocode}
+\newcommand\@pnumwidth{2em}
+\newcommand\@tocrmarg {3em}
+\newcommand\@dotsep{4.5}
+\setcounter{tocdepth}{\if@runinsubsubsec1\else2\fi}
+% \end{macrocode}
+%
+% \begin{macro}{\tableofcontents}
+%
+% This is the main command for setting up tables of contents. We ensure
+% a single-page layout, put in the chapter heading, read in the contents
+% file, and then restore the old layout.
+%
+% \begin{macrocode}
+\newcommand\tableofcontents{%
+ \if@twocolumn%
+ \@restonecoltrue%
+ \onecolumn%
+ \else%
+ \@restonecolfalse%
+ \fi%
+ \@topsect\contentsname%
+ {\parskip\z@\@starttoc{toc}}%
+ \if@restonecol%
+ \twocolumn%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Each section type \synt{type} is typeset by a command |\l@|\synt{type}:
+% for example, the |\l@chapter| command typesets the entry for a chapter
+% heading.
+%
+% \begin{macro}{\l@part}
+%
+% This command is vaguely interesting. We'll explore in detail.
+%
+% \begin{macrocode}
+\def\l@part#1#2{%
+% \end{macrocode}
+%
+% We don't typeset the entry if |tocdepth| tells us not to. What kind of
+% stupid user is going to disable \emph{all} the contents items.
+%
+% \begin{macrocode}
+ \ifnum\c@tocdepth>-2\relax%
+% \end{macrocode}
+%
+% Before we start, we try to break above the title. Later, we'll disable
+% breaking afterwards. We then leave some vertical space.
+%
+% \begin{macrocode}
+ \addpenalty{-\@highpenalty}%
+ \addvspace{2.25em\@plus\p@}%
+% \end{macrocode}
+%
+% We open a group, to avoid messing other things up. The |\numberline|
+% macro, which numbers the entry on the left, typesets its argument in a box
+% of width |\@tempdima|, which we must set up. We then set up the values
+% of |\rightskip| and |\parfillskip| to avoid printing over the page number.
+% We also make |\interlinepenalty| infinite to suppress breaking pages in
+% the middle of the title.
+%
+% \begin{macrocode}
+ \begingroup%
+ \@tempdima3em%
+ \parindent\z@%
+ \rightskip\@pnumwidth%
+ \parfillskip-\@pnumwidth%
+ \interlinepenalty\@M
+% \end{macrocode}
+%
+% Time to typeset the actual title. This is fairly simple, apart from
+% a complicated mixture of glue and penalties, which handles a line break
+% right at the end of the title.
+%
+% \begin{macrocode}
+ {%
+ \leavevmode%
+ \large\bfseries {#1}%
+ \nobreak\hfil\penalty\@highpenalty\hbox{}\nobreak\hfil%
+ \hb@xt@\@pnumwidth{\hss #2}%
+ }%
+% \end{macrocode}
+%
+% Now we end the paragraph and suppress page breaking here.
+%
+% \begin{macrocode}
+ \par%
+ \nobreak%
+ \global\@nobreaktrue%
+ \everypar{\global\@nobreakfalse\everypar{}}%
+ \endgroup%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@artsw}
+%
+% Define a macro named after the first or second argument depending on
+% whether the document is an article.
+%
+% \begin{macrocode}
+\def\@artsw#1#2#3{%
+ \edef\@tempa{#1\if@article\noexpand#3\else\noexpand#2\fi}%
+ \@tempa%
+}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\l@chapter}
+%
+% This is terribly similar to the previous macro.
+%
+% \begin{macrocode}
+\@artsw\def\l@chapter\l@section#1#2{%
+ \ifnum\c@tocdepth >\m@ne%
+ \addpenalty{-\@highpenalty}%
+ \vskip1.0em\@plus\p@%
+ \setlength\@tempdima{2em}%
+ \begingroup%
+ \interlinepenalty\@M
+ \parindent\z@%
+ \rightskip\@pnumwidth%
+ \parfillskip-\@pnumwidth%
+ \leavevmode%
+ \bfseries%
+ \advance\leftskip\@tempdima%
+ \hskip-\leftskip%
+ {#1}%
+ \nobreak\hfil\penalty\@highpenalty\hbox{}\nobreak\hfil%
+ \hb@xt@\@pnumwidth{\hss #2}%
+ \par%
+ \penalty\@highpenalty%
+ \endgroup%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% The other types are all defined in terms of |\@dottedtocline|, which is
+% redefined beloew.
+%
+% \begin{macrocode}
+\@artsw\def\l@section\l@subsection{\@dottedtocline{1}{2em}{2.5em}}
+\@artsw\def\l@subsection\l@subsubsection{\@dottedtocline{2}{4.5em}{3.2em}}
+\@artsw\def\l@subsubsection\l@paragraph{\@dottedtocline{3}{7.7em}{4.1em}}
+\@artsw\def\l@paragraph\l@subparagraph{\@dottedtocline{4}{10.5em}{5em}}
+\@artsw\def\l@subparagraph\@tempa{\@dottedtocline{5}{12.5em}{6em}}
+% \end{macrocode}
+%
+% \begin{macro}{\@dottedtocline}
+%
+% This is actually a part of the \LaTeX\ kernel, although it's not quite
+% right the way it is. We've improved the handling of line breaks after the
+% title.
+%
+% \begin{macrocode}
+\def\@dottedtocline#1#2#3#4#5{%
+% \end{macrocode}
+%
+% We have to make sure that we're meant to typeset this contents entry.
+%
+% \begin{macrocode}
+ \ifnum#1>\c@tocdepth\else%
+% \end{macrocode}
+%
+% Now we add in a little stretchy space.
+%
+% \begin{macrocode}
+ \vskip\z@\@plus.2\p@%
+% \end{macrocode}
+%
+% Set up the paragraph layout now. We forbid page breaks in the middle of
+% the title.
+%
+% \begin{macrocode}
+ {%
+ \leftskip#2\relax%
+ \rightskip\@tocrmarg%
+ \parfillskip-\rightskip%
+ \parindent#2\relax%
+ \@afterindenttrue%
+ \interlinepenalty\@M%
+% \end{macrocode}
+%
+% Now we typeset the actual title.
+%
+% \begin{macrocode}
+ \leavevmode%
+ \@tempdima#3\relax%
+ \advance\leftskip\@tempdima%
+ \hbox{}%
+ \hskip-\leftskip%
+ {#4}%
+% \end{macrocode}
+%
+% This is the clever bit. After the actual title, we add the following
+% items:
+%
+% \begin{itemize}
+%
+% \item A |\nobreak| penalty, to stop a break from eating the glue.
+%
+% \item A glob of |\hfil| glue. If there's a line break after this glue,
+% the title is set flush left as a result of this. Otherwise, it is ignored
+% because the leaders are |\hfill|.
+%
+% \item A penalty. This is a reasonable place to break the line if
+% necessary.
+%
+% \item An empty |\hbox|. This stops the following glue from being discarded
+% at the beginning of a new line.
+%
+% \item Another |\nobreak|, which stops a break at the following glue item.
+%
+% \item The dotted |\leaders|, which have |\hfill| stretchiness. This forces
+% the page number to be flush right.
+%
+% \end{itemize}
+%
+% The net result of all this is we can now cope with a line break at the
+% end of the title, before the page number, which means that the dots are
+% put on the next line. The original \LaTeX\ version forced the last word
+% of the title onto the next line as well, which can cause underful boxes.
+%
+% \begin{macrocode}
+ \nobreak\hfil\penalty\@highpenalty\hbox{}\nobreak%
+ \leaders\hbox{$\m@th\mkern\@dotsep mu.\mkern\@dotsep mu$}\hfill%
+ \hb@xt@\@pnumwidth{\hfil\reset@font\rmfamily#5}\par%
+ }%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Lists of figures and tables}
+%
+% These macros are terribly similar to the other ones.
+%
+% \begin{macrocode}
+\newcommand\listoffigures{%
+ \if@twocolumn%
+ \@restonecoltrue\onecolumn%
+ \else%
+ \@restonecolfalse%
+ \fi%
+ \@topsect\listfigurename%
+ {\parskip\z@ \@starttoc{lof}}%
+ \if@restonecol\twocolumn\fi%
+}
+%
+\newcommand\l@figure{\@dottedtocline{1}{1.5em}{2.5em}}
+%
+\newcommand\listoftables{%
+ \if@twocolumn%
+ \@restonecoltrue\onecolumn%
+ \else%
+ \@restonecolfalse%
+ \fi%
+ \@topsect\listtablename%
+ {\parksip\z@ \@starttoc{lot}}%
+ \if@restonecol\twocolumn\fi%
+}
+%
+\let\l@table\l@figure
+% \end{macrocode}
+%
+% \section{Bibliography}
+%
+% This isn't actually terribly interesting.
+%
+% \begin{environment}{thebibliography}
+%
+% \begin{macrocode}
+\newdimen\bibindent
+\bibindent1.5em
+%
+\newenvironment{thebibliography}[1]{%
+ \@topsect\bibname%
+ \list{\@biblabel{\arabic{enumiv}}}%
+ {\settowidth\labelwidth{\@biblabel{#1}}%
+ \leftmargin\labelwidth%
+ \advance\leftmargin\labelsep%
+ \if@openbib%
+ \advance\leftmargin\bibindent%
+ \itemindent-\bibindent%
+ \listparindent\itemindent%
+ \parsep\z@%
+ \fi%
+ \usecounter{enumiv}%
+ \let\p@enumiv\@empty%
+ \renewcommand\theenumiv{\arabic{enumiv}}}%
+ \if@openbib%
+ \renewcommand\newblock{\par}%
+ \else%
+ \renewcommand\newblock{\hskip.11em\@plus.33em\@minus.07em}%
+ \fi%
+ \sloppy%
+ \clubpenalty4000%
+ \widowpenalty4000%
+ \sfcode`\.\@m%
+}{%
+ \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
+ \endlist%
+}
+%
+\newcommand\newblock{}
+% \end{macrocode}
+% \end{environment}
+%
+% \section{Index}
+%
+% Defines the \env{theindex} environment.
+%
+% \begin{environment}{theindex}
+%
+% The macros are fairly simple. We change to a two column layout, and
+% redefine |\item| appropriately.
+%
+% \begin{macrocode}
+\newenvironment{theindex}{%
+ \columnseprule\z@%
+ \columnsep35\p@%
+ \@topsect\indexname%
+ \if@twocolumn\else%
+ \begin{multicols}{2}%
+ \fi%
+ \parskip\z@\@plus.3\p@\relax%
+ \raggedright%
+ \let\item\@idxitem%
+}{%
+ \if@twocolumn\else%
+ \end{multicols}%
+ \fi%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% Now we define the item and spacing macros.
+%
+% \begin{macrocode}
+\newcommand\@idxitem {\par\hangindent 40\p@}
+\newcommand\subitem {\par\hangindent 40\p@ \hspace*{20\p@}}
+\newcommand\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
+\newcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}
+% \end{macrocode}
+%
+% \begin{macro}{\passim}
+%
+% The |passim| encapsulator is used to typeset the word `\textit{passim}'
+% after a page range.
+%
+% \begin{macrocode}
+\def\passim#1{#1 \textit{passim}} % Passim encapsulator for indices
+% \end{macrocode}
+% \end{macro}
+%
+% Other useful commands for indexing:
+%
+% \begin{description*}
+% \def\descriptionlabel#1{\ttfamily \bslash #1}
+%
+% \item[Term] typesets its argument in italics, and adds it to the index.
+%
+% \item[term] typesets its first argument in italics, and adds its second
+% to the index.
+%
+% \item[Index] typesets its argument normally, and adds it to the index.
+%
+% \end{description*}
+%
+% \begin{macrocode}
+\def\Term#1{\emph{#1}\index{#1}}
+\def\term#1{\emph{#1}\index}
+\def\Index#1{#1\index{#1}}
+% \end{macrocode}
+%
+% \section{Footnotes}
+%
+% \begin{macro}{\footnoterule}
+%
+% This macro typesets the rule above footnotes. This is a bit more complex
+% than the default: we try and typeset the rule to be at most 1\,in wide,
+% although if the column isn't wide enough, we use $4\over10$~of the
+% box width instead.
+%
+% \begin{macrocode}
+\def\footnoterule{%
+ \@tempdima.4\columnwidth%
+ \ifdim\@tempdima>1in\relax%
+ \@tempdima1in\relax%
+ \fi%
+ \kern-3\p@%
+ \hrule\@width\@tempdima%
+ \kern2.6\p@%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% We number footnotes within chapters:
+%
+% \begin{macrocode}
+\@addtoreset{footnote}{chapter}
+% \end{macrocode}
+%
+% \begin{macro}{\@makefntext}
+%
+% This is the macro which actually typesets a footnote. This is rather
+% complicated. It's based on example code from \file{classes.dtx} which
+% doesn't actually work properly.
+%
+% \begin{macrocode}
+\long\def\@makefntext#1{%
+% \end{macrocode}
+%
+% First, we redefine |\par| to set up the correct paragraph shape. This
+% is indented from the left margin by a small amount.
+%
+% \begin{macrocode}
+ \@setpar{%
+ \@@par%
+ \@tempdima\hsize%
+ \advance\@tempdima-1.6em%
+ \parshape\@ne1.6em\@tempdima%
+ }%
+% \end{macrocode}
+%
+% Now we set up some parameters so that \env{list} environments work properly
+% within the footnote. We also clear |\parindent| to prevent nasty
+% indentation. The |\par| sets up the paragraph shape for the next
+% paragraph: we're in vertical mode already, so it does nothing else.
+%
+% \begin{macrocode}
+ \advance\linewidth-1.6em%
+ \advance\@totalleftmargin1.6em%
+ \par%
+ \parindent\z@%
+% \end{macrocode}
+%
+% We leave vertical mode to stop the hbox created by |\llap| from being
+% stacked vertically. Then we typeset the footnote mark, and put in the
+% main text. Finally we leave some space afterwards, to space out the next
+% footnote.
+%
+% \begin{macrocode}
+ \leavevmode%
+ \llap{\@makefnmark\enspace}#1\par%
+ \vskip\parskip%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@makecol}
+%
+% The standard \LaTeX\ output routine messes up footnotes a bit, in my
+% opinion:
+% \begin{itemize}
+%
+% \item If a page is cut off short, because the next item won't fit (e.g.,
+% a section heading), then footnotes are added right below the end
+% of the text, which can look strange.
+%
+% \item Footnotes are displayed \emph{above} floats at the bottom of a page,
+% which also looks strange.
+%
+% \item The |\@makefntext| routine above needs to add vertical space between
+% footnotes, but this leaves a gap at the very bottom. We remove this
+% gap with an |\unskip|.
+%
+% \end{itemize}
+%
+% \begin{macrocode}
+\def\@makecol{%
+ \setbox\@outputbox \box\@cclv
+ \xdef\@freelist{\@freelist\@midlist}%
+ \global \let \@midlist \@empty
+ \@combinefloats
+ \ifvoid\footins \else
+ \setbox\@outputbox \vbox {%
+ \boxmaxdepth \@maxdepth
+ \unvbox \@outputbox
+ \vskip \skip\footins
+ \vfil
+ \footnoterule
+ \unvbox \footins
+ \unskip
+ }%
+ \fi
+ \ifvbox\@kludgeins
+ \@makespecialcolbox
+ \else
+ \setbox\@outputbox \vbox to\@colht {%
+ \@texttop
+ \dimen@ \dp\@outputbox
+ \unvbox \@outputbox
+ \vskip -\dimen@
+ \@textbottom
+ }%
+ \fi
+ \global \maxdepth \@maxdepth
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Tidying up}
+%
+% This section gathers together various other useful bits of standard
+% document class setting.
+%
+% \subsection{Item names}
+%
+% These commands typeset bits of text. They can then be redefined by
+% \package{babel} and suchlike.
+%
+% \begin{macrocode}
+\newcommand\contentsname{Contents}
+\newcommand\listfigurename{List of Figures}
+\newcommand\listtablename{List of Tables}
+\if@article\newcommand\bibname{References}
+\else\newcommand\bibname{Bibliography}\fi
+\newcommand\indexname{Index}
+\newcommand\figurename{Figure}
+\newcommand\tablename{Table}
+\newcommand\partname{Part}
+\newcommand\abstractname{Abstract}
+\newcommand\chaptername{Chapter}
+\newcommand\appendixname{Appendix}
+\newcommand\today{\number\day\space\ifcase\month\or
+ January\or February\or March\or April\or May\or June\or
+ July\or August\or September\or October\or November\or December\fi
+ \space\number\year}
+% \end{macrocode}
+%
+% \subsection{Final fiddling for two columns}
+%
+% \begin{macrocode}
+\columnsep10\p@
+\columnseprule\z@
+\pagestyle{headings}
+\pagenumbering{arabic} % Arabic page numbers
+\if@twocolumn
+ \twocolumn
+ \sloppy
+ \flushbottom
+\else
+ \onecolumn
+\fi
+% \end{macrocode}
+%
+% \section{The \protect\env{central} environment}
+%
+% Because of the strange layout of the pages, text which is centred using
+% normal \LaTeX\ commands is centred in the text area, not on the page,
+% which is undesirable for large headings, like part headings.
+%
+% \begin{environment}{central}
+%
+% The \env{central} environment typesets its contents centrally on the page.
+% It should only be used from outer vertical mode.
+%
+% The code just creates a box of the appropriate size and moves it into the
+% right place.
+%
+% \begin{macrocode}
+\newenvironment{central}{%
+ \par%
+ \vbox\bgroup\moveleft\leftindent\vbox\bgroup%
+ \textwidth\paperwidth%
+ \advance\textwidth-2\pagesurround\relax%
+ \hsize\textwidth%
+ \hrule\@height\z@\@depth\z@\@width\hsize%
+}{%
+ \egroup%
+ \egroup%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \section{Headers and footers}
+%
+% The \strayman\ class uses \package{fancyheadings} for its headers
+% and footers. This has already been included in the preamble. We now
+% need to fix a few problems with \package{fancyheadings} and set up some
+% macros.
+%
+% \begin{macro}{\title}
+%
+% We extend |\title|, and give it an optional argument. It can now specify
+% the document title as used by |\maketitle| and the running title for the
+% header separately.
+%
+% We store the running header in the macro |\@headertitle|, which is
+% initially empty.
+%
+% \begin{macrocode}
+\def\@headertitle{}
+% \end{macrocode}
+%
+% Now we define the |\title| macro, using |\@dblarg| to duplicate the
+% mandatory argument if the optional one is omitted.
+%
+% \begin{macrocode}
+\def\title{\@dblarg\title@i}
+\def\title@i[#1]#2{%
+ \gdef\@title{#2}%
+ \gdef\@headertitle{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\innerhead}
+% \begin{macro}{\innerfoot}
+%
+% We allow the user to specify an `inner heading' which is displayed on the
+% inside of the header on of each page. This can be used for security
+% classifications, for example. Any \package{fancyheadings} commands can
+% be used to control the header, which is expanded on each page.
+%
+% \begin{macrocode}
+\def\l@innerhead{}
+\def\r@innerhead{}
+\def\l@innerfoot{}
+\def\r@innerfoot{}
+\def\innerhead{\@dblarg\innerhead@i}
+\def\innerhead@i[#1]#2{%
+ \def\l@innerhead{#1}%
+ \def\r@innerhead{#2}%
+}
+\def\innerfoot{\@dblarg\innerfoot@i}
+\def\innerfoot@i[#1]#2{%
+ \def\l@innerfoot{#1}%
+ \def\r@innerfoot{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% The next step is to set up the headings:
+%
+% \begin{macrocode}
+\let\headrulewidth\z@
+\headwidth\textwidth
+ \advance\headwidth\leftindent
+\fancypagestyle{headings}{%
+ \fancyhf{}
+ \fancyhead[LE]{\bfseries\@headertitle}
+ \if@article\fancyhead[RO]{\rightmark}\else\fancyhead[RO]{\leftmark}\fi
+ \fancyhead[RE]{\l@innerhead} \fancyhead[LO]{\r@innerhead}
+ \fancyfoot[RE]{\l@innerfoot} \fancyfoot[LO]{\r@innerfoot}
+ \fancyfoot[LE,RO]{\thepage}
+}
+\fancypagestyle{plain}{%
+ \fancyhf{}%
+ \fancyfoot[RE]{\l@innerfoot} \fancyfoot[LO]{\r@innerfoot}
+ \fancyfoot[LE,RO]{\thepage}%
+}
+\let\ps@fancy\ps@@fancy
+% \end{macrocode}
+%
+% The \package{fancyheadings} package by default expects pages to be
+% symmetrical. We have to redefine the |\ps@fancy| macro to make it
+% work properly.
+%
+% \begin{macrocode}
+\def\@lodd{\ifodd\c@page\hss\else\relax\fi}
+\def\@rodd{\ifodd\c@page\relax\else\hss\fi}
+% \end{macrocode}
+%
+% Finally, we can choose the page style we want:
+%
+% \begin{macrocode}
+\pagestyle{headings}
+% \end{macrocode}
+%
+% \section{Parbox alteration}
+%
+% The standard \LaTeX\ |\parbox| command, and the \env{minipage} environment,
+% reset |\parskip| to zero, which is inconsistent with the document style.
+% We amend |\@arrayparboxrestore|, the macro which sets up the paragraph
+% style for parboxes.
+%
+% First, we define a macro explaining how the parbox should set the spacing.
+%
+% \begin{macrocode}
+\def\parboxparskip{2ex}
+% \end{macrocode}
+%
+% Next, we redefine the macro. This is taken directly from the \LaTeXe
+% source.
+%
+% \begin{macrocode}
+\def\@arrayparboxrestore{%
+ \let\par\@@par
+ \let\-\@dischyph
+ \let\'\@acci\let\`\@accii\let\=\@acciii
+ \parindent\z@ \parskip\z@
+ \everypar{\parskip\parboxparskip\everypar{}}%
+ \linewidth\hsize
+ \@totalleftmargin\z@
+ \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip
+ \parfillskip\@flushglue \lineskip\normallineskip
+ \baselineskip\normalbaselineskip
+ \@noskipsectrue% % The comp.text.tex gurus said it should be
+ \sloppy}
+% \end{macrocode}
+%
+%
+% \section{Other features}
+%
+% At the end is a miscellany of useful features.
+%
+% \subsection{Other typesetting conventions}
+%
+% Some items need typesetting in particular ways.
+%
+% \begin{macrocode}
+\let\key\textit
+\let\button\textbf
+\def\submenu{\ensuremath\Rightarrow}
+\let\name\relax
+\def\file#1{\mbox{\itshape #1\/}}
+% \end{macrocode}
+%
+% \subsection{And finally}
+%
+% \begin{macrocode}
+\sloppy
+\raggedbottom
+\def\riscos{RISC~OS}
+\hyphenpenalty1000
+%</strayman>
+% \end{macrocode}
+%
+% \Finale
+%
+\endinput