Document Class refman for L^{A}TEX version 2e^{∗}

Copyright (C) 1988 by Hubert Partl Copyright (C) 1994-94 by Axel Kielhorn

1995/03/19

Contents

1 The docstrip modules 3

2 Initial Code 3

3 Declaration of Options 4 3.1 Setting Paper Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.2 Choosing the type size . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.3 Two-side or one-side printing . . . . . . . . . . . . . . . . . . . . . 5 3.4 Draft option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.5 Titlepage option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.6 openright option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.7 Twocolumn printing . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.8 Equation numbering on the left . . . . . . . . . . . . . . . . . . . . 6 3.9 Flush left displays . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.10 Open bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.11 User flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

4 Executing Options 7

5 Loading Packages 7

6 Document Layout 7 6.1 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 6.2 Paragraphing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6.3 Page Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

6.3.1 Vertical spacing . . . . . . . . . . . . . . . . . . . . . . . . . 9 6.3.2 The dimension of text . . . . . . . . . . . . . . . . . . . . . 9 6.3.3 Horizontal margins . . . . . . . . . . . . . . . . . . . . . . . 10 6.3.4 Vertical margins . . . . . . . . . . . . . . . . . . . . . . . . 11

∗This file has version number v1.9f, last revised 1995/03/19.

6.3.5 Float placement parameters . . . . . . . . . . . . . . . . . . 12 6.4 Page Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

6.4.1 Marking conventions . . . . . . . . . . . . . . . . . . . . . . 13 6.4.2 Defining the page styles . . . . . . . . . . . . . . . . . . . . 13

7 Document Markup 19 7.1 The title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 7.2 Chapters and Sections . . . . . . . . . . . . . . . . . . . . . . . . . 21

7.2.1 Building blocks . . . . . . . . . . . . . . . . . . . . . . . . . 21 7.2.2 Mark commands . . . . . . . . . . . . . . . . . . . . . . . . 21 7.2.3 Define Counters . . . . . . . . . . . . . . . . . . . . . . . . 22 7.2.4 Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 7.2.5 Chapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 7.2.6 Lower level headings . . . . . . . . . . . . . . . . . . . . . . 26

7.3 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 7.3.1 General List Parameters . . . . . . . . . . . . . . . . . . . . 27 7.3.2 Enumerate . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 7.3.3 Itemize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 7.3.4 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

7.4 Defining new environments . . . . . . . . . . . . . . . . . . . . . . 30 7.4.1 Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 7.4.2 Verse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 7.4.3 Quotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 7.4.4 Quote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 7.4.5 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 7.4.6 Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 7.4.7 Titlepage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 7.4.8 Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

7.5 Setting parameters for existing environments . . . . . . . . . . . . 33 7.5.1 Array and tabular . . . . . . . . . . . . . . . . . . . . . . . 33 7.5.2 Tabbing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 7.5.3 Minipage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 7.5.4 Framed boxes . . . . . . . . . . . . . . . . . . . . . . . . . . 34 7.5.5 Equation and eqnarray . . . . . . . . . . . . . . . . . . . . . 34

7.6 Floating objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 7.6.1 Figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 7.6.2 Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 7.6.3 Captions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

7.7 Font changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

8 Cross Referencing 38

8.1 Table of Contents, etc. . . . . . . . . . . . . . . . . . . . . . . . . . 38 8.1.1 Table of Contents . . . . . . . . . . . . . . . . . . . . . . . 38 8.1.2 List of figures . . . . . . . . . . . . . . . . . . . . . . . . . . 41 8.1.3 List of tables . . . . . . . . . . . . . . . . . . . . . . . . . . 42

8.2 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 8.3 The index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 8.4 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

9 New commands 45 9.1 Margin commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 9.2 Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 9.3 Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 9.4 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 9.5 Obsolete commands . . . . . . . . . . . . . . . . . . . . . . . . . . 48 9.6 Future commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

10 Initialization 49 10.1 Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 10.2 Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 10.3 Two column mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 10.4 The page style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 10.5 Single or double sided printing . . . . . . . . . . . . . . . . . . . . 50

1 The docstrip modules

The following modules are used in the implementation to direct docstrip in generating the external files:

refart produce the documentclass refart
refrep produce the documentclass refrep
driver produce a documentation driver file

2 Initial Code

In this part we define a few commands that are used later on.

\@ptsize This control sequence is used to store the second digit of the pointsize we are typesetting in. So, normally, it’s value is one of 0, 1 or 2.

1 ⟨∗refart | refrep⟩

2 \newcommand\@ptsize{}

\if@restonecol Only the index may be printed in twocolumn-layout, but this is not implemented yet. Nevertheless we provide the neccesary commands.

3 \newif\if@restonecol

\if@titlepage A switch to indicate if a titlepage has to be produced. For the refart document class the default is not to make a seperate titlepage.

4 \newif\if@titlepage

5 ⟨+refart⟩\@titlepagefalse 6 ⟨+refrep⟩\@titlepagetrue

\if@openright A switch to indicate if chapters must start on a right-hand page. The default for the refman class is no. There are no chapters in the refart class

7 ⟨+refrep⟩\newif\if@openright

\if@openbib A switch to indicate if the bibliography has to be produced in the “open” format. The default is to use a “closed” format.

 8 \newif\if@openbib
 9 \@openbibfalse

3 Declaration of Options

3.1 Setting Paper Sizes

The variables \paperwidth and \paperheight should reflect the physical paper size after trimming. For desk printer output this is usually the real paper size since there is no post-processing. Classes for real book production will probably add other paper sizes and additionally the production of crop marks for trimming. Since repbook does not exist now you may change the papersizes if needed.

10 \DeclareOption{a4paper}
11 {\setlength\paperheight {297mm}%
12  \setlength\paperwidth  {210mm}}
13 \DeclareOption{a5paper}
14 {\setlength\paperheight {210mm}%
15  \setlength\paperwidth  {148mm}}
16 \DeclareOption{b5paper}
17 {\setlength\paperheight {250mm}%
18  \setlength\paperwidth  {176mm}}
19 \DeclareOption{letterpaper}
20 {\setlength\paperheight {11in}%
21  \setlength\paperwidth  {8.5in}}
22 \DeclareOption{legalpaper}
23 {\setlength\paperheight {14in}%
24  \setlength\paperwidth  {8.5in}}
25 \DeclareOption{executivepaper}
26 {\setlength\paperheight {10.5in}%
27  \setlength\paperwidth  {7.25in}}

The option landscape switches the values of \paperheight and \paperwidth, assuming the dimensions were given for portrait paper.

28 \DeclareOption{landscape}
29 {\setlength\@tempdima   {\paperheight}%
30  \setlength\paperheight {\paperwidth}%
31  \setlength\paperwidth  {\@tempdima}}

The option square assigns the values of \paperwidth to \paperheight, which will result in a square layout. If you use landscape first you will get a square layout which uses the height of yo you original paper.

32 \DeclareOption{square}
33 {\setlength\paperheight {\paperwidth}}

3.2 Choosing the type size

The type size options are handled by defining \@ptsize to contain the last digit of the size in question and branching on \ifcase statements. This is done for historical reasons to stay compatible with other packages that use the \@ptsize variable to select special actions. It makes the declarations of size options less than 10pt difficult, although one can probably use 9 and 8 assuming that a class wont define both 8pt and 18pt options.

34 \DeclareOption{10pt}{\renewcommand\@ptsize{0}}
35 \DeclareOption{11pt}{\renewcommand\@ptsize{1}}
36 \DeclareOption{12pt}{\renewcommand\@ptsize{2}}

3.3 Two-side or one-side printing

For two-sided printing we use the switch \if@twoside. We set \if@mparswitch which does nothing now but is kept for compatibility reasons. It may vanish in the final 2.0 version.

37 \DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
38 \DeclareOption{twoside}{\@twosidetrue  \@mparswitchtrue}

3.4 Draft option

If the user requests draft we show any overfull boxes. We could probably add some more interesting stuff to this option.

39 \DeclareOption{draft}{\setlength\overfullrule{5pt}}
40 \DeclareOption{final}{\setlength\overfullrule{0pt}}

3.5 Titlepage option

A refman usually has no separate titlepage, but the user can request one.

41 \DeclareOption{titlepage}{\@titlepagetrue}
42 \DeclareOption{notitlepage}{\@titlepagefalse}

3.6 openright option

This option determines whether or not a chapter must start on a right-hand page and request one.

43 ⟨+refrep⟩\DeclareOption{openright}{\@openrighttrue} 44 ⟨+refrep⟩\DeclareOption{openany}{\@openrightfalse}

3.7 Twocolumn printing

Two-column is used in the index. There is no user command or option to request twocolumn printing. Therefore twocolumn will lead to an error message.

45 \DeclareOption{onecolumn}{\@twocolumnfalse}
46 \DeclareOption{twocolumn}{%

47 ⟨+refart⟩ \ClassError{Refart} 48 ⟨+refrep⟩ \ClassError{Refrep}

49  {There is no twocolumn layout in this class!}
50  {Can you imagine how twocolumn layout will look\MessageBreak
51  in this class? That's why!}
52  \@twocolumnfalse}

53 %

3.8 Equation numbering on the left

The option leqno can be used to get the equation numbers on the left side of the

equation. leqno.clo is defined in classes.dtx.
54 \DeclareOption{leqno}{\input{leqno.clo}}

3.9 Flush left displays

The option fleqn redefines the displayed math environmens in such a way that they come out flush left, with an indentation of \mathindent from the prevailing left margin.fleqn.clo is defined in classes.dtx.

55 \DeclareOption{fleqn}{\input{fleqn.clo}}

3.10 Open bibliography

The option openbib produces the “open” bibliography style, in which each block starts on a new line, and succeeding lines in a block are indented by \bibindent.

56 \DeclareOption{openbib}{\@openbibtrue}

3.11 User flags

There are some flags the user may change to control the behaviour of some commands:

\ifdescriptioncolon This switch controls whether there is a colon in the description item or not.

57 \newif\ifdescriptioncolon \descriptioncolontrue

\ifdescriptionleft This switch controls whether the description items are set left bound or right bound.

58 \newif\ifdescriptionleft  \descriptionleftfalse

\ifmaxipagerule This switch controls whether there is a rule at the beginning and end of a maxipage. This flag may later be used to select rules at other places (like part or chapter) as well.

59 \newif\ifmaxipagerule     \maxipageruletrue

4 Executing Options

Here we execute the default options to initialize certain variables.

60 ⟨∗refart⟩ 61 \ExecuteOptions{letterpaper,10pt,oneside,onecolumn,final} 62 ⟨/refart⟩ 63 ⟨∗refrep⟩ 64 \ExecuteOptions{letterpaper,10pt,oneside,onecolumn,final,openany} 65 ⟨/refrep⟩

The \ProcessOptions command causes the execution of the code for every option FOO which is declared and for which the user typed the FOO option in his \documentclass command. For every option BAR he typed, which is not declared, the option is assumed to be a global option. All options will be passed as document options to any \usepackage command in the document preamble.

66 \ProcessOptions

Now that all the options have been executed we can load the chosen class option file that contains all size dependent code. We are using the sizexx.clo Files from classes.dtx now and do the page layout caculation inside the class-file.

67 ⟨∗refart | refrep⟩ 68 \input{size1\@ptsize.clo} 69 ⟨/refart | refrep⟩

5 Loading Packages

The standard class files do not load additional packages.

6 Document Layout

In this section we are finally dealing with the nasty typographical details.

6.1 Fonts

L^{A}TEX offers the user commands to change the size of the font, relative to the ‘main’ size. Each relative size changing command \size executes the command \@setfontsize\size⟨font-size⟩⟨baselineskip⟩ where:

⟨font-size⟩ The absolute size of the font to use from now on.

⟨baselineskip⟩ The normal value of \baselineskip for the size of the font selected. (The actual value will be \baselinestretch * ⟨baselineskip⟩.)

A number of commands, defined in the L^{A}TEX kernel, shorten the following definitions and are used throughout. They are:

           \@vpt  5  \@vipt 6  \@viipt 7
           \@viiipt 8  \@ixpt 9  \@xpt  10
           \@xipt  10.95 \@xiipt 12 \@xivpt 14.4

...

\normalsize \@normalsize The user level command for the main size is \normalsize. Internally L^{A}TEX uses \@normalsize when it refers to the main size. \@normalsize will be defined to work like \normalsize if the latter is redefined from its default definition (that just issues an error message). Otherwise \@normalsize simply selects a 10pt/12pt size.

   See classes.dtx for documentaion on sizexx.clo

6.2 Paragraphing

\lineskip \normallineskip These parameters control TEX’s behaviour when two lines tend to come too close together.

70 ⟨∗refart | refrep⟩ 71 \setlength\lineskip{1\p@} 72 \setlength\normallineskip{1\p@}

\baselinestretch This is used as a multiplier for \baselineskip. The default is to not stretch the baselines.

73 \renewcommand\baselinestretch{}

\parskip \parindent \parskip gives extra vertical space between paragraphs and \parindent is the width of the paragraph indentation. The value of \parindent is set to 0.

74 \setlength\parskip{0.5\baselineskip \@plus 2\p@} 75 \setlength\parindent {\z@}

\@lowpenalty \@medpenalty \@highpenalty The commands \nopagebreak and \nolinebreak put in penalties to discourage

these breaks at the point they are put in. They use \@lowpenalty, \@medpenalty or \@highpenalty, dependent on their argument.

76 \@lowpenalty 51 77 \@medpenalty 151 78 \@highpenalty 301

\clubpenalty \widowpenalty These penalties are use to discourrage club and widow lines. Because we use their default values we only show them here, commented out.

79 % \clubpenalty 150 80 % \widowpenalty 150

\displaywidowpenalty \predisplaypenalty \postdisplaypenalty Discourrage (but not so much) widows in front of a math display and forbid breaking directly in front of a display. Allow break after a display without a penalty. Again the default values are used, therefore we only show them here.

81 % \displaywidowpenalty 50 82 % \predisplaypenalty 10000 83 % \postdisplaypenalty 0

\interlinepenalty Allow the breaking of a page in the middle of a paragraph.

84 % \interlinepenalty 0

\brokenpenalty We allow the breaking of a page after a hyphenated line.

85 % \brokenpenalty 100 86 ⟨/refart | refrep⟩

6.3 Page Layout

All margin dimensions are measured from a point one inch from the top and lefthand side of the page.

6.3.1 Vertical spacing

\headheight \headsep \topskip The \headheight is the height of the box that will contain the running head. The \headsep is the distance between the bottom of the running head and the top of the text. \topskip is the \baselineskip for the first line on a page. Only the definition of \headsep differs from sizexx and has to be changed.

87 ⟨∗refart | refrep⟩ 88 \setlength\headsep {\baselineskip}

6.3.2 The dimension of text

\fullwidth \textwidth \leftmarginwidth There is no need to supply a compatibility mode since the independend refman.sty

was never released to the public.

We will set the dimensions differently, taking into account the paper size for instance.

First, we calculate the maximum textwidth, which will fit on the selected paper and store it in \@tempdima.

89 \newdimen\leftmarginwidth 90 \newdimen\fullwidth

\emptyfoottopmargin
\emptyheadtopmargin

91 \newdimen\emptyfoottopmargin 92 \newdimen\emptyheadtopmargin

We define a macro to change the fraction of the part of \fullwidth that is occupied with text. There are no sanitychecks so make sure this is less or equal to 1.

\settextfraction

93 \newcommand\settextfraction[1]% 94 { 95 \setlength\@tempdima{\paperwidth} 96 \addtolength\@tempdima{-2in}

Now we can set the \textwidth, depending on whether we will be setting one or two columns.

97 \if@twocolumn 98 \setlength\textwidth{\@tempdima} 99 \else 100 \setlength\fullwidth{\@tempdima} 101 \@settopoint\fullwidth 102 \setlength\textwidth{#1\fullwidth} % This may change 103 \fi

Here we modify the width of the text a little to be a whole number of points.

104 \@settopoint\textwidth 105 \setlength\leftmarginwidth{\fullwidth} 106 \addtolength\leftmarginwidth{-\textwidth}

6.3.3 Horizontal margins

\oddsidemargin \evensidemargin \marginparwidth The values for \oddsidemargin and \marginparwidth will be set independing on

the status of the \if@twoside. (We have the same layout on odd and even pages.)

For one-sided printing we center the text on the page, by calculating the difference between textwidth and \paperwidth−2in. Half of that difference is than used for the margin. The amount of space that can be used for marginal notes is leftmarginwidth − marginparsep to which we add any ‘leftover’ space.

107 \setlength\@tempdima {\paperwidth} 108 \addtolength\@tempdima {-2in} 109 \addtolength\@tempdima {-\fullwidth} 110 \setlength\oddsidemargin {.5\@tempdima} 111 \addtolength\oddsidemargin {\leftmarginwidth} 112 \@settopoint\oddsidemargin

   Then \evensidemargin and \marginparwidth are set to \oddsidemargin.

\marginparwidth will be modified later.

113 \setlength\evensidemargin {\oddsidemargin} 114 \setlength\marginparwidth {\oddsidemargin}

\marginparsep \marginparpush The horizontal space between the main text and marginal notes is determined by \marginparsep (defined in sizexx), the minimum vertical separation between two marginal notes is controlled by \marginparpush which is set to 0 because we will have lots of margin notes. The width of the marginpar is reduced by marginparsep to produce flushleft pages.

115 \addtolength\marginparwidth {-\marginparsep} 116 \setlength\marginparpush{0\p@} 117 }

Now we call \settextfraction with the default value of 0.7

118 \settextfraction {0.7}

\textheight Now that we have computed the width of the text, we have to take care of the height. The \textheight is the height of text (including footnotes and figures, excluding running head and foot).

Again we compute this, depending on the papersize and depending on the baselineskip that is used, in order to have a whole number of lines on the page.

119 \setlength\@tempdima{\paperheight}

We leave at least a 1 inch margin on the top and the bottom of the page.

120 \addtolength\@tempdima{-2in}

The running headers and footers extend partly into the top and bottom margins.

121 \addtolength\@tempdima{-.5in}

Then we divide the result by the current \baselineskip and store this in the count register \@tempcnta, which then contains the number of lines that fit on this page.

122 \divide\@tempdima\baselineskip 123 \@tempcnta=\@tempdima

From this we can calculate the height of the text.

124 \setlength\textheight{\@tempcnta\baselineskip}

The first line on the page has a height of \topskip.

125 \advance\textheight by \topskip

6.3.4 Vertical margins

\topmargin The \topmargin is the distance between the top of ‘the printable area’ –which is 1 inch below the top of the paper– and the top of the box which contains the running head.

It can now be computed from the values set above.

126 \setlength\topmargin{\paperheight} 127 \addtolength\topmargin{-2in} 128 \addtolength\topmargin{-\headheight} 129 \addtolength\topmargin{-\headsep} 130 \addtolength\topmargin{-\textheight} 131 \addtolength\topmargin{-\footskip} % this might be wrong!

By changing the factor in the next line the complete page can be shifted vertically.

The contents of the page is shifted up or down by one \baselineskip depending on the pagestyle. Do not combine headings and footings in one document!

132 \addtolength\topmargin{-.5\topmargin} 133 \@settopoint\topmargin 134 \setlength\emptyfoottopmargin{\topmargin} 135 \addtolength\emptyfoottopmargin{\baselineskip} 136 \setlength\emptyheadtopmargin{\topmargin} 137 \addtolength\emptyheadtopmargin{-\baselineskip} 138 ⟨/refart | refrep⟩

6.3.5 Float placement parameters

All float parameters are given default values in the L^{A}TEX 2ε kernel. For this reason counters only need to be set with \setcounter and other parameters are set using

\renewcommand.

Limits for the placement of floating objects

\c@topnumber The topnumber counter holds the maximum number of floats that can appear on the top of a text page.

139 ⟨∗refart | refrep⟩ 140 \setcounter{topnumber}{2}

\topfraction This indicates the maximum part of a text page that can be occupied by floats at the top.

141 \renewcommand\topfraction{.7}

\c@bottomnumber The bottomnumber counter holds the maximum number of floats that can appear on the bottom of a text page.

142 \setcounter{bottomnumber}{1}

\bottomfraction This indicates the maximum part of a text page that can be occupied by floats at the bottom.

143 \renewcommand\bottomfraction{.3}

\c@totalnumber This indicates the maximum number of floats that can appear on any text page.

144 \setcounter{totalnumber}{3}

\textfraction This indicates the minimum part of a text page that has to be occupied by text.

145 \renewcommand\textfraction{.2}

\floatpagefraction This indicates the minimum part of a page that has to be occupied by floating objects before a ‘float page’ is produced.

146 \renewcommand\floatpagefraction{.5}

\c@dbltopnumber The dbltopnumber counter holds the maximum number of two column floats that can appear on the top of a two column text page.

147 \setcounter{dbltopnumber}{2}

\dbltopfraction This indicates the maximum part of a two column text page that can be occupied by two column floats at the top.

148 \renewcommand\dbltopfraction{.7}

\dblfloatpagefraction This indicates the minimum part of a page that has to be occupied by two column wide floating objects before a ‘float page’ is produced.

149 \renewcommand\dblfloatpagefraction{.5} 150 ⟨/refart | refrep⟩

6.4 Page Styles

The page style foo is defined by defining the command \ps@foo. This command should make only local definitions. There should be no stray spaces in the definition, since they could lead to mysterious extra spaces in the output (well, that’s something that should be always avoided).

\@evenhead \@oddhead \@evenfoot \@oddfoot The \ps@... command defines the macros \@oddhead, \@oddfoot, \@evenhead,

and \@evenfoot to define the running heads and feet—e.g., \@oddhead is the macro to produce the contents of the heading box for odd-numbered pages. It is called inside an \hbox of width \textwidth.

6.4.1 Marking conventions

To make headings determined by the sectioning commands, the page style defines

the commands \chaptermark, \sectionmark, . . . , where \chaptermark{⟨TEXT ⟩}

is called by \chapter to set a mark, and so on.

The \...mark commands and the \...head macros are defined with the help of the following macros. (All the \...mark commands should be initialized to no-ops.)

L^{A}TEX extends TEX’s \mark facility by producing two kinds of marks, a ‘left’ and a ‘right’ mark, using the following commands:

\markboth{⟨LEFT ⟩}{⟨RIGHT ⟩}: Adds both marks. \markright{⟨RIGHT ⟩}: Adds a ‘right’ mark.

\leftmark: Used in the \@oddhead, \@oddfoot, \@evenhead or \@evenfoot

macros, it gets the current ‘left’ mark. \leftmark works like TEX’s \botmark command.

\rightmark: Used in the \@oddhead, \@oddfoot, \@evenhead or \@evenfoot

macros, it gets the current ‘right’ mark. \rightmark works like TEX’s

\firstmark command.

The marking commands work reasonably well for right marks ‘numbered within’ left marks–e.g., the left mark is changed by a \chapter command and the right mark is changed by a \section command. However, it does produce somewhat anomalous results if two \markboth’s occur on the same page.

Commands like \tableofcontents that should set the marks in some page styles use a \@mkboth command, which is \let by the pagestyle command (\ps@...) to \markboth for setting the heading or to \@gobbletwo to do nothing.

151 % %%%\mark{{}{}}   % Initializes TeX's marks   <--- can vanish

6.4.2 Defining the page styles

The pagestyles empty is defined in latex.dtx.

\ps@plain We have to redefine plain to support twoside layout.

152 ⟨∗refart | refrep⟩ 153 \if@twoside 154 \def\ps@plain{% 155 \let\@mkboth\@gobbletwo 156 \let\@oddhead\@empty 157 \let\@evenhead\@empty 158 \def\@oddfoot{\reset@font\rmfamily\hfil\thepage} 159 \def\@evenfoot{\reset@font\rmfamily\thepage\hfil}} 160 \else 161 \def\ps@plain{% 162 \let\@mkboth\@gobbletwo 163 \let\@oddhead\@empty 164 \def\@oddfoot{\reset@font\rmfamily\hfil\thepage\hfil} 165 \let\@evenhead\@empty 166 \let\@evenfoot\@oddfoot} 167 \fi 168 % \end{macrocode} 169 % \end{macro} 170 % 171 % \begin{macro}{\ps@headings} 172 % The definition of the page style \pstyle{headings} has to be 173 % different for two sided printing than it is for one sided 174 % printing. 175 % 176 % \begin{macrocode} 177 \if@twoside 178 \def\ps@headings{%

The running feet are empty in this page style, the running head contains the page number and one of the marks.

179 \let\@oddfoot\@empty\let\@evenfoot\@empty 180 \def\@evenhead{\hss\vbox to \z@{\vss\hsize=\fullwidth 181 \hbox to \fullwidth{\thepage\hfil\slshape\leftmark} 182 \vskip 3\p@ \hrule}}% 183 \def\@oddhead{\hss\vbox to \z@{\vss\hsize=\fullwidth 184 \hbox to \fullwidth{{\slshape\rightmark}\hfil\thepage} 185 \vskip 3\p@ \hrule}}%

When using this page style, the contents of the running head is determined by the chapter and section titles. So we \let \@mkboth to \markboth.

186 \let\@mkboth\markboth

We shift the page one \baselineskip to the bottom to compensate for the headings.

187 \topmargin\emptyfoottopmargin 188 ⟨/refart | refrep⟩

For the refart document class we define \sectionmark to clear the right mark and put the number of the section (when it is numbered) and its title in the left mark. The rightmark is set by \subsectionmark to contain the subsection titles.

Note the use of ##1 for the parameter of the \sectionmark command, which will be defined when \ps@headings is executed.

189 ⟨∗refart⟩ 190 \def\sectionmark##1{% 191 \markboth {\ifnum \c@secnumdepth >\z@ 192 \thesection\hskip 1em\relax\fi 193 ##1}{}}% 194 \def\subsectionmark##1{% 195 \markright {\ifnum \c@secnumdepth >\@ne 196 \thesubsection\hskip 1em\relax \fi 197 ##1}}} 198 ⟨/refart⟩

In the refrep document class we use the \chaptermark and \sectionmark macros to fill the running heads.

Note the use of ##1 for the parameter of the \chaptermark command, which will be defined when \ps@headings is executed.

199 ⟨∗refrep⟩ 200 \def\chaptermark##1{% 201 \markboth {\ifnum \c@secnumdepth >\m@ne 202 \@chapapp\ \thechapter \ \fi 203 ##1}{}}% 204 \def\sectionmark##1{% 205 \markright {\ifnum \c@secnumdepth >\z@ 206 \thesection \ \fi 207 ##1}}} 208 ⟨/refrep⟩

The definition of \ps@headings for one sided printing can be much simpler, because we treat even and odd pages the same. Therefore we don’t need to define

 \@even....

209 ⟨∗refart | refrep⟩ 210 \else 211 \def\ps@headings{% 212 \let\@oddfoot\@empty 213 \def\@oddhead{\hss\vbox to \z@{\vss\hsize=\fullwidth 214 \hbox to \fullwidth{{\slshape\rightmark}\hfil\thepage} 215 \vskip 3\p@ \hrule}}% 216 \let\@mkboth\markboth 217 ⟨/refart | refrep⟩

We shift the page one \baselineskip to the bottom to compensate for the headings.

218  \topmargin\emptyfoottopmargin

We use \markright now instead of \markboth as we did for two sided printing.

219 ⟨∗refart⟩ 220 \def\sectionmark##1{% 221 \markright {\ifnum \c@secnumdepth >\m@ne 222 \thesection\hskip 1em\relax \fi 223 ##1}}} 224 ⟨/refart⟩ 225 ⟨∗refrep⟩ 226 \def\chaptermark##1{% 227 \markright {\ifnum \c@secnumdepth >\m@ne 228 \@chapapp\ \thechapter \ \fi 229 ##1}}} 230 ⟨/refrep⟩ 231 ⟨∗refart | refrep⟩ 232 \fi

\ps@footings The definition of the page style footings has to be different for two sided printing than it is for one sided printing.

233 \if@twoside 234 \def\ps@footings{%

The running head is empty in this page style, the running foot contains the page number and one of the marks.

235 \let\@oddhead\@empty\let\@evenhead\@empty 236 \def\@evenfoot{\hss\vbox to \z@{\vss\hsize=\fullwidth 237 \hrule \vskip 3\p@ 238 \hbox to \fullwidth{\thepage\hfil\slshape\leftmark}}}% 239 \def\@oddfoot{\hss\vbox to \z@{\vss\hsize=\fullwidth 240 \hrule \vskip 3\p@ 241 \hbox to \fullwidth{{\slshape\rightmark}\hfil\thepage}}}%

When using this page style, the contents of the running foot is determined by the chapter and section titles. So we \let \@mkboth to \markboth.

242 \let\@mkboth\markboth

We shift the page one \baselineskip to the top to compensate for the footings.

243 \topmargin\emptyheadtopmargin 244 ⟨/refart | refrep⟩

For the refart document class we define \sectionmark to clear the right mark and put the number of the section (when it is numbered) and its title in the left mark. The rightmark is set by \subsectionmark to contain the subsection titles.

Note the use of ##1 for the parameter of the \sectionmark command, which will be defined when \ps@headings is executed.

245 ⟨∗refart⟩ 246 \def\sectionmark##1{% 247 \markboth {\ifnum \c@secnumdepth >\z@ 248 \thesection\hskip 1em\relax\fi 249 ##1}{}}% 250 \def\subsectionmark##1{% 251 \markright {\ifnum \c@secnumdepth >\@ne 252 \thesubsection\hskip 1em\relax \fi 253 ##1}}} 254 ⟨/refart⟩

In the refrep document class we use the \chaptermark and \sectionmark macros to fill the running heads.

Note the use of ##1 for the parameter of the \chaptermark command, which will be defined when \ps@footings is executed.

255 ⟨∗refrep⟩ 256 \def\chaptermark##1{% 257 \markboth {\ifnum \c@secnumdepth >\m@ne 258 \@chapapp\ \thechapter \ \fi 259 ##1}{}}% 260 \def\sectionmark##1{% 261 \markright {\ifnum \c@secnumdepth >\z@ 262 \thesection \ \fi 263 ##1}}} 264 ⟨/refrep⟩

The definition of \ps@footings for one sided printing can be much simpler, because we treat even and odd pages the same. Therefore we don’t need to define

 \@even....

265 ⟨∗refart | refrep⟩ 266 \else 267 \def\ps@footings{% 268 \let\@oddhead\@empty 269 \def\@oddfoot{\hss\vbox to \z@{\vss\hsize=\fullwidth 270 \hrule \vskip 3\p@ 271 \hbox to \fullwidth{{\slshape\rightmark}\hfil\thepage}}}% 272 \let\@mkboth\markboth

We shift the page one \baselineskip to the top to compensate for the footings.

273 \topmargin\emptyheadtopmargin 274 ⟨/refart | refrep⟩

We use \markright now instead of \markboth as we did for two sided printing.

275 ⟨∗refart⟩ 276 \def\sectionmark##1{% 277 \markright {\ifnum \c@secnumdepth >\m@ne 278 \thesection\hskip 1em\relax \fi 279 ##1}}} 280 ⟨/refart⟩

281 ⟨∗refrep⟩ 282 \def\chaptermark##1{% 283 \markright {\ifnum \c@secnumdepth >\m@ne 284 \@chapapp\ \thechapter \ \fi 285 ##1}}} 286 ⟨/refrep⟩ 287 ⟨∗refart | refrep⟩ 288 \fi

\ps@myheadings The definition of the page style myheadings is fairly simple because the user determines the contents of the running head himself by using the \markboth and

 \markright commands.

289 \def\ps@myheadings{% 290 \let\@oddfoot\@empty\let\@evenfoot\@empty 291 \def\@evenhead{\hss\vbox to \z@{\vss\hsize=\fullwidth 292 \hbox to \fullwidth{\thepage\hfil\slshape\leftmark} 293 \vskip 3\p@ \hrule}}% 294 \def\@oddhead{\hss\vbox to \z@{\vss\hsize=\fullwidth 295 \hbox to \fullwidth{{\slshape\rightmark}\hfil\thepage} 296 \vskip 3\p@ \hrule}}%

We have to make sure that the marking commands that are used by the chapter and section headings are disabled. We do this \letting them to a macro that gobbles its argument(s).

297 \let\@mkboth\@gobbletwo 298 ⟨+refrep⟩ \let\chaptermark\@gobble 299 \let\sectionmark\@gobble 300 ⟨+refart⟩ \let\subsectionmark\@gobble

We shift the page one \baselineskip to the bottom to compensate for the headings.

301 \topmargin\emptyfoottopmargin 302 }

\ps@myfootings The definition of the page style myfootings is fairly simple because the user determines the contents of the running head himself by using the \markboth and

 \markright commands.

303 \def\ps@myfootings{% 304 \let\@oddhead\@empty\let\@evenhead\@empty 305 \def\@evenfoot{\hss\vbox to \z@{\vss\hsize=\fullwidth 306 \hrule \vskip 3\p@ 307 \hbox to \fullwidth{\thepage\hfil\slshape\leftmark}}}% 308 \def\@oddfoot{\hss\vbox to \z@{\vss\hsize=\fullwidth 309 \hrule \vskip 3\p@ 310 \hbox to \fullwidth{{\slshape\rightmark}\hfil\thepage}}}%

We have to make sure that the marking commands that are used by the chapter and section footings are disabled. We do this \letting them to a macro that gobbles its argument(s).

311 \let\@mkboth\@gobbletwo 312 ⟨+refrep⟩ \let\chaptermark\@gobble 313 \let\sectionmark\@gobble 314 ⟨+refart⟩ \let\subsectionmark\@gobble

We shift the page one \baselineskip to the top to compensate for the footings.

315 \topmargin\emptyheadtopmargin 316 }

7 Document Markup

7.1 The title

\title \author \date These three macros are provided by latex.dtx to provide information about the title, author(s) and date of the document. The information is stored away in internal control sequences. It is the task of the \maketitle command to use the information provided. The definitions of these macros are shown here for information.

317 % \newcommand\title[1]{\gdef\@title{#1}} 318 % \newcommand\author[1]{\gdef\@author{#1}} 319 % \newcommand\date[1]{\gdef\@date{#1}}

The \date macro gets today’s date by default.

320 % \gdef\@date{\today}

\maketitle The definition of \maketitle depends on whether a seperate title page is made. This is the default for the refman document class, but for the refart class it is optional.

When we are making a title page, we locally redefine \footnotesize and footnoterule to change the appearance of the footnotes that are produced by the \thanks command.

321 \if@titlepage 322 \newcommand\maketitle{\begin{titlepage}% 323 \let\footnotesize\small 324 \let\footnoterule\relax

We center the entire title vertically; the centering is set off a little by adding a \vskip. In compatibility mode the pagenumber is set to 0 to keep the behaviour of L^{A}TEX 2.09 style files

325 \null\vfil 326 \vskip 60\p@

Then we set the title, in a \LARGE font; leave a little space and set the author(s) in a \large font. We do this inside a tabular environment to get them in a single column. Before the date we leave a little whitespace again.

327 \begin{center}% 328 {\LARGE \@title \par}% 329 \vskip 3em% 330 {\large 331 \lineskip .75em% 332 \begin{tabular}[t]{c}% 333 \@author 334 \end{tabular}\par}% 335 \vskip 1.5em% 336 {\large \@date \par}% % Set date in \large size. 337 \end{center}\par

Then we call \@thanks to print the information that goes into the footnote and finish the page.

338 \@thanks 339 \vfil\null 340 \end{titlepage}%

We reset the footnote counter, disable \thanks and \maketitle and save some storage space by emptying the internal information macros.

341 \setcounter{footnote}{0}% 342 \let\thanks\relax\let\maketitle\relax 343 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}

When the title is not on a page of its own, the layout of the title is a little different. We use symbols to mark the footnotes and we have to deal with two column documents.

Therefore we first start a new group to keep changes local. Then we redefine \thefootnote to use \fnsymbol; and change \@makefnmark so that footnotemarks have zero width (to make the centering of the author names look better).

344 \else 345 \newcommand\maketitle{\par 346 \begingroup 347 \renewcommand\thefootnote{\fnsymbol{footnote}}% 348 \def\@makefnmark{\hbox to\z@{$\m@th^{\@thefnmark}$\hss}}% 349 \long\def\@makefntext##1{\parindent 1em\noindent 350 \hbox to1.8em{\hss$\m@th^{\@thefnmark}$}##1}%

If this is a twocolumn document we start a new page in twocolumn mode, with the title set to the full width of the text. The actual printing of the title information

is left to \@maketitle.

351 \if@twocolumn 352 \ifnum \col@number=\@ne 353 \@maketitle 354 \else 355 \twocolumn[\@maketitle]% 356 \fi 357 \else

When this is not a twocolumn document we just start a new page, prevent floating objects from appearing on the top of this page and print the title information.

358 \newpage 359 \global\@topnum\z@ % Prevents figures from going at top of page. 360 \@maketitle 361 \fi

This page gets a plain layout. We call \@thanks to produce the footnotes.

362 \thispagestyle{plain}\@thanks

Now we can close the group, reset the footnote counter, disable \thanks, \maketitle and \@maketitle and save some storage space by emptying the internal information macros.

363 \endgroup 364 \setcounter{footnote}{0}% 365 \let\thanks\relax 366 \let\maketitle\relax\let\@maketitle\relax 367 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}

\@maketitle This macro takes care of formatting the title information when we have no seperate

title page.

We always start a new page and put the title flushleft using a \Large bold font with thick rules above and below. Then we put the autor information flushright in slanted type. This title will allways show the date unless it is set to nothing, using the \date{} command.

368 \def\@maketitle{% 369 \newpage 370 \null 371 %\vskip 2em% 372 \longthickrule\vskip1.5em% 373 {\secshape \parskip\z@ \parindent\z@ 374 \Large\bfseries \@title \par}% 375 \vskip1.5em\longthickrule\vskip1.5em% 376 {\normalsize 377 \lineskip .5em% 378 \begin{flushright}% 379 {\slshape\@author\par} 380 \vskip 1em% 381 {\@date}% 382 \end{flushright}\par}% 383 \vskip 1.5em} 384 \fi

7.2 Chapters and Sections

7.2.1 Building blocks

The definitions in this part of the class file make use of two macros, \@startsection and \secdef, which are defined by latex.dtx. They are not described here, see the classes.dtx for more information.

7.2.2 Mark commands

\chaptermark \sectionmark \subsectionmark \subsubsectionmark \paragraphmark \subparagraphmark Default initializations of \...mark commands. These commands are used in the

definition of the page styles (see section 6.4.2) Most of them are already defined by latex.dtx, so they are only shown here.

385 ⟨+refrep⟩\newcommand\chaptermark[1]{} 386 % \newcommand\sectionmark[1]{} 387 % \newcommand\subsectionmark[1]{} 388 % \newcommand\subsubsectionmark[1]{} 389 % \newcommand\paragraphmark[1]{} 390 % \newcommand\subparagraphmark[1]{}

7.2.3 Define Counters

\c@secnumdepth The value of the counter secnumdepth gives the depth of the highest-level sectioning command that is to produce section numbers.

391 ⟨+refart⟩\setcounter{secnumdepth}{3} 392 ⟨+refrep⟩\setcounter{secnumdepth}{2}

\c@part \c@chapter \c@section \c@subsection \c@subsubsection \c@paragraph \c@subparagraph These counters are used for the section numbers. The macro \newcounter{⟨newctr⟩}[⟨oldctr⟩]

defines ⟨newctr⟩ to be a counter, which is reset to zero when counter ⟨oldctr⟩ is stepped. Counter ⟨oldctr⟩ must already be defined.

393 \newcounter {part} 394 ⟨+refart⟩\newcounter {section} 395 ⟨∗refrep⟩ 396 \newcounter {chapter} 397 \newcounter {section}[chapter] 398 ⟨/refrep⟩ 399 \newcounter {subsection}[section] 400 \newcounter {subsubsection}[subsection] 401 \newcounter {paragraph}[subsubsection] 402 \newcounter {subparagraph}[paragraph]

\thepart \thechapter \thesection \thesubsection \thesubsubsection \theparagraph \thesubparagraph For any counter CTR, \theCTR is a macro that defines the printed version of

counter CTR. It is defined in terms of the following macros:

\arabic{COUNTER} prints the value of COUNTER as an arabic numeral. \roman{COUNTER} prints the value of COUNTER as a lowercase roman num-

beral.

\Roman{COUNTER} prints the value of COUNTER as an uppercase roman numberal.

\alph{COUNTER} prints the value of COUNTER as a lowercase letter: 1 = a, 2 = b, etc.

\Alph{COUNTER} prints the value of COUNTER as an uppercase letter: 1 = A, 2 = B, etc.

403 \renewcommand\thepart {\Roman{part}} 404 ⟨+refart⟩\renewcommand\thesection {\arabic{section}} 405 ⟨∗refrep⟩ 406 \renewcommand\thechapter {\arabic{chapter}} 407 \renewcommand\thesection {\thechapter.\arabic{section}} 408 ⟨/refrep⟩ 409 \renewcommand\thesubsection {\thesection.\arabic{subsection}} 410 \renewcommand\thesubsubsection {\thesubsection .\arabic{subsubsection}} 411 \renewcommand\theparagraph {\thesubsubsection.\arabic{paragraph}} 412 \renewcommand\thesubparagraph {\theparagraph.\arabic{subparagraph}}

\@chapapp \@chapapp is initially defined to be empty. The \appendix command redefines it

to be ‘\appendixname’.

413 ⟨+refrep⟩\newcommand\@chapapp{}

7.2.4 Parts

\part The command to start a new part of our document.

In the refart class the definition of \part is rather simple; we start a new paragraph, add a little white space, suppress the indentation of the first paragraph and make use of \@secdef.

414 ⟨∗refart⟩ 415 \newcommand\part{\par 416 \addvspace{4ex}% 417 \@afterindentfalse 418 \secdef\@part\@spart} 419 ⟨/refart⟩

For the refrep class things are a bit different.

We start a new (righthand) page and use the plain.

420 ⟨∗refrep⟩ 421 \newcommand\part{\cleardoublepage 422 \thispagestyle{plain}%

When we are making a two column document, this will be a one column page. We use @tempswa to remember to switch back to two columns.

423 \if@twocolumn 424 \onecolumn 425 \@tempswatrue 426 \else 427 \@tempswafalse 428 \fi

We need an empty box to prevent the fil glue from disappearing.

429 \hbox{}\vfil

Here we use \secdef to indicate which commands to use to make the actual heading.

430 \secdef\@part\@spart} 431 ⟨/refrep⟩

\@part This macro does the actual formatting of the title of the part. Again the macro is differently defined for the refart document class than for the document class refrep.

When secnumdepth is larger than −1 for the document class refart or −2 for the document class refrep, we have a numbered part, otherwise it is unnumbered.

432 ⟨∗refart | refrep⟩ 433 \def\@part[#1]#2{% 434 ⟨+refart⟩ \ifnum \c@secnumdepth >\m@ne 435 ⟨+refrep⟩ \ifnum \c@secnumdepth >-2\relax 436 \refstepcounter{part}% 437 \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% 438 \else 439 \addcontentsline{toc}{part}{#1}% 440 \fi

We print the title flush left, we also prevent breaking between lines and reset the font.

441 \longrule\medskip 442 {\parindent \z@ \raggedright 443 \interlinepenalty \@M 444 \reset@font

When this is a numbered part we have to print the number and the title. The \nobreak should prevent a page break here.

445 \Large 446 ⟨+refart⟩ \ifnum \c@secnumdepth >\m@ne 447 ⟨+refrep⟩ \ifnum \c@secnumdepth >-2 \relax 448 \thepart.\quad 449 \fi 450 #2\par \medskip 451 \longrule\bigskip%

Then we empty the mark registers, leave some white space and call \@afterheading to takes care of suppressing the indentation.

452 \markboth{}{}\par}% 453 \nobreak 454 \vskip 3ex 455 \@afterheading} 456 ⟨/refart | refrep⟩

\@spart This macro does the actual formatting of the title of the part when the star form of the user command was used. In this case we never print a number. Otherwise the formatting is the same.

457 ⟨∗refart | refrep⟩ 458 \def\@spart#1{% 459 \longrule\medskip 460 {\parindent \z@ \raggedright 461 \interlinepenalty \@M 462 \reset@font 463 \Large #1\par}% 464 \medskip\longrule 465 \nobreak 466 \vskip 3ex 467 \@afterheading} 468 ⟨/refart | refrep⟩

7.2.5 Chapters

\chapter A chapter should always start on a new page therefore we start by calling \clearpage and setting the pagestyle for this page to plain.

469 ⟨∗refrep⟩ 470 \newcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi 471 \if@pageperchapter\setcounter{page}{1}\fi 472 \thispagestyle{plain}%

Then we prevent floats from appearing at the top of this page because it looks weird to see a floating object above a chapter title.

473 \global\@topnum\z@

Then we suppress the indentation of the first paragraph by setting the switch \@afterindent to false. We use \secdef to specify the macros to use for actually setting the chapter title.

474 \@afterindentfalse 475 \secdef\@chapter\@schapter}

\@chapter This macro is called when we have a numbered chapter. When secnumdepth is larger than −1 we display the chapter number. We also inform the user that a new chapter is about to be typeset by writing a message to the terminal.

476 \def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne 477 \refstepcounter{chapter}% 478 \typeout{\@chapapp\space\thechapter.}% 479 \addcontentsline{toc}{chapter}% 480 {\protect\numberline{\thechapter}#1}% 481 \else 482 \addcontentsline{toc}{chapter}{#1} 483 \fi

After having written an entry to the table of contents we store the (alternative) title of this chapter with \chaptermark and add some white space to the lists of figures and tables.

484 \chaptermark{#1}% 485 \addtocontents{lof}{\protect\addvspace{10\p@}}% 486 \addtocontents{lot}{\protect\addvspace{10\p@}}%

Then we call upon \@makechapterhead to format the actual chapter title. We have to do this in a special way when we are in twocolumn mode in order to have the chapter title use the entire \textwidth. In one column mode we call \@afterheading which takes care of suppressing the indentation.

487 \if@twocolumn 488 \@topnewpage[\@makechapterhead{#2}]% 489 \else 490 \@makechapterhead{#2}% 491 \@afterheading 492 \fi}

\@makechapterhead The macro above uses \@makechapterhead⟨text⟩ to format the heading of the

chapter.

We begin by leaving some white space. The we open a group in which we have a paragraph indent of 0pt, and in which we have the text set ragged right. We also reset the font.

493 \def\@makechapterhead#1{% 494 \longthickrule\bigskip% 495 {\parindent \z@ \secshape \reset@font \Large\bfseries

Then we check whether the number of the chapter has to be printed. If so we leave some whitespace between the chapternumber and its title.

496 \ifnum \c@secnumdepth >\m@ne 497 \@chapapp{} \thechapter.\quad 498 \fi

Now we set the title in a large bold font. We prevent a pagebreak at this point and leave some whitespace before the text begins.

499 #1\par} 500 \bigskip\longthickrule\bigskip 501 }

\@schapter This macro is called when we have an unnumbered chapter. It is much simpler than \@chapter because it only needs to typeset the chapter title.

502 \def\@schapter#1{\if@twocolumn 503 \@topnewpage[\@makeschapterhead{#1}]% 504 \else 505 \@makeschapterhead{#1}% 506 \@afterheading 507 \fi}

\@makeschapterhead The macro above uses \@makeschapterhead⟨text⟩to format the heading of the chapter. It is similar to \@makechapterhead except that it never has to print a chapter number.

508 \def\@makeschapterhead#1{% 509 \longthickrule\bigskip% 510 {\parindent \z@ \secshape \reset@font 511 \Large \bfseries #1\par} 512 \bigskip\longthickrule\bigskip 513 } 514 ⟨/refrep⟩

7.2.6 Lower level headings

\secshape

515 \newcommand\secshape{\leftskip=-\leftmarginwidth% 516 \rightskip=\@flushglue% 517 \hyphenpenalty=2000}

These commands all make use of \@startsection.

\section This gives a normal heading with white space above and below the heading, the title set in \large\bfseries, and no indentation on the first paragraph.

518 \newcommand\section{\@startsection {section}{1}{\z@}% 519 {-2ex \@plus -1ex \@minus -.2ex}% 520 {0.5ex \@plus .2ex}% 521 {\secshape\reset@font\large\bfseries}}

\subsection This gives a normal heading with white space above and below the heading, the title set in \large\bfseries, and no indentation on the first paragraph.

522 \newcommand\subsection{\@startsection{subsection}{2}{\z@}% 523 {-1.5ex\@plus -.5ex \@minus -.2ex}% 524 {0.5ex \@plus .2ex}% 525 {\secshape\reset@font\normalsize\bfseries}}

\subsubsection This gives a normal heading with white space above and below the heading, the title set in \normalsize\bfseries, and no indentation on the first paragraph.

526 \newcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% 527 {-1.5ex\@plus -.5ex \@minus -.2ex}% 528 {0.5ex \@plus .2ex}% 529 {\secshape\reset@font\normalsize\mdseries}}

\paragraph This gives a run-in heading with white space above and to the right of the heading,

the title set in \normalsize\bfseries.

530 \newcommand\paragraph{\@startsection{paragraph}{4}{\z@}% 531 {2ex\@plus 1ex \@minus .2ex}% 532 {-1em}% 533 {\reset@font\normalsize\bfseries}}

\subparagraph This gives an indented run-in heading with white space above and to the right of the heading, the title set in \normalsize\bfseries.

534 \newcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}% 535 {2ex \@plus 1ex \@minus .2ex}% 536 {-1em}% 537 {\reset@font\normalsize\bfseries}}

7.3 Lists

7.3.1 General List Parameters

The following commands are used to set the default values for the list environment’s parameters. See the L^{A}TEX manual for an explanation of the meanings of the parameters. Defaults for the list environment are set as follows. First,

\rightmargin, \listparindent and \itemindent are set to 0pt. Then, for a

Kth level list, the command \@listK is called, where ‘K’ denotes ‘i’, ’‘i’, ... , ‘vi’. (I.e., \@listiii is called for a third-level list.) By convention, \@listK should

set \leftmargin to \leftmarginK.
\leftmargin \leftmargini \leftmarginii \leftmarginiii \leftmarginiv \leftmarginv \leftmarginvi For efficiency, level-one list’s values are defined at top level, and \@listi is defined
to set only \leftmargin.

When we are in two column mode some of the margins are set somewhat smaller.

538 \if@twocolumn 539 \setlength\leftmargini {2em} 540 \else 541 \setlength\leftmargini {2.5em} 542 \fi

The following three are calculated so that they are larger than the sum of \labelsep and the width of the default labels (which are ‘(m)’, ‘vii.’ and ‘M.’).

543 \setlength\leftmarginii {2.2em} 544 \setlength\leftmarginiii {1.87em} 545 \setlength\leftmarginiv {1.7em} 546 \if@twocolumn 547 \setlength\leftmarginv {.5em} 548 \setlength\leftmarginvi {.5em} 549 \else 550 \setlength\leftmarginv {1em} 551 \setlength\leftmarginvi {1em} 552 \fi

Here we set the top level leftmargin.

553 \setlength\leftmargin {\leftmargini}

\labelsep \labelwidth \labelsep is the distance between the label and the text of an item; \labelwidth is the width of the label.

554 \setlength \labelsep {.5em} 555 \setlength \labelwidth{\leftmargini} 556 \addtolength\labelwidth{-\labelsep}

\@beginparpenalty \@endparpenalty These penalties are inserted before and after a list or paragraph environment. They are set to a bonus value to encourage page breaking at these points.

\@itempenalty This penalty is inserted between list items.

557 ⟨∗refart | refrep⟩ 558 \@beginparpenalty -\@lowpenalty 559 \@endparpenalty -\@lowpenalty 560 \@itempenalty -\@lowpenalty 561 ⟨/refart | refrep⟩

\@listI \@listi  \@listI defines top level and \@listi values of \leftmargin, \parsep, \topsep,
 and \itemsep

562 ⟨∗refart | refrep⟩ 563 \def\@listI{\leftmargin\leftmargini 564 \parsep \parskip 565 \topsep \z@ 566 \itemsep\z@} 567 \let\@listi\@listI

We have to initialise these parameters.

568 \@listi

\@listii \@listiii \@listiv \@listv \@listvi Here are the same macros for the higher level lists.

569 \def\@listii {\leftmargin\leftmarginii 570 \labelwidth\leftmarginii 571 \advance\labelwidth-\labelsep

572  \topsep  \z@

573  \parsep  \parskip

574 \itemsep \z@} 575 \def\@listiii{\leftmargin\leftmarginiii 576 \labelwidth\leftmarginiii 577 \advance\labelwidth-\labelsep

578  \topsep  \z@
579  \parsep  \parskip

580 \partopsep \z@ 581 \itemsep \topsep} 582 \def\@listiv {\leftmargin\leftmarginiv 583 \labelwidth\leftmarginiv 584 \advance\labelwidth-\labelsep} 585 \def\@listv {\leftmargin\leftmarginv 586 \labelwidth\leftmarginv 587 \advance\labelwidth-\labelsep} 588 \def\@listvi {\leftmargin\leftmarginvi 589 \labelwidth\leftmarginvi 590 \advance\labelwidth-\labelsep} 591 ⟨∗refart | refrep⟩

7.3.2 Enumerate

The enumerate environment uses four counters: enumi, enumii, enumiii and enumiv, where enumN controls the numbering of the Nth level enumeration.

\theenumi \theenumii \theenumiii \theenumiv The counters are already defined in latex.dtx, but their representation is changed here.

592 ⟨∗refart | refrep⟩ 593 \renewcommand\theenumi{\arabic{enumi}} 594 \renewcommand\theenumii{\alph{enumii}} 595 \renewcommand\theenumiii{\roman{enumiii}} 596 \renewcommand\theenumiv{\Alph{enumiv}}

\labelenumi \labelenumii \labelenumiii \labelenumiv The label for each item is generated by the commands \labelenumi ... \labelenumiv.

597 \newcommand\labelenumi{\theenumi.} 598 \newcommand\labelenumii{(\theenumii)} 599 \newcommand\labelenumiii{\theenumiii.} 600 \newcommand\labelenumiv{\theenumiv.}

\p@enumii \p@enumiii \p@enumiv The expansion of \p@enumN\theenumN defines the output of a \ref command

when referencing an item of the Nth level of an enumerated list.

601 \renewcommand\p@enumii{\theenumi} 602 \renewcommand\p@enumiii{\theenumi(\theenumii)} 603 \renewcommand\p@enumiv{\p@enumiii\theenumiii}

7.3.3 Itemize

\labelitemi \labelitemii \labelitemiii \labelitemiv Itemization is controlled by four commands: \labelitemi, \labelitemii,

\labelitemiii, and \labelitemiv, which define the labels of thevarious itemization levels: the symbols used are bullet, bold en-dash, asterisk and centred dot.

604 \newcommand\labelitemi{$\m@th\bullet$} 605 \newcommand\labelitemii{\normalfont\bfseries --} 606 \newcommand\labelitemiii{$\m@th\ast$} 607 \newcommand\labelitemiv{$\m@th\cdot$}

7.3.4 Description

\description \descriptionlabel The description environment is defined here – while the itemize and enumerate

environments are defined in latex.dtx.

To change the formatting of the label, you must redefine \descriptionlabel.

608 \newcommand\descriptionlabel[1]{% 609 \ifdescriptionleft\else \hfil\fi 610 \normalfont #1 \ifdescriptioncolon :\fi 611 \ifdescriptionleft \hfil \fi} 612 \newenvironment{description} 613 {\list{}{% 614 \labelsep\marginparsep 615 \labelwidth\leftmarginwidth 616 %\advance\labelwidth by \@totalleftmargin 617 \advance\labelwidth by \leftmargin 618 \advance\labelwidth by -\labelsep 619 \let\makelabel\descriptionlabel}} 620 {\endlist}

7.4 Defining new environments

7.4.1 Abstract

\abstract When we are producing a separate titlepage we also put the abstract on a page of its own. It will be centred vertically on the page.

621 \if@titlepage 622 \newenvironment{abstract}{% 623 \titlepage 624 \null\vfil 625 \begin{center} 626 \bfseries \abstractname 627 \end{center}} 628 {\par\vfil\null\endtitlepage}

When we are not making a seperate titlepage –the default for the refart document class– we have to check if we are in twocolumn mode. In that case the abstract is as a \section*, otherwise the quote environment is used to typeset the abstract.

629 \else 630 \newenvironment{abstract}{% 631 \if@twocolumn 632 \section*{\abstractname}% 633 \else 634 \small 635 \begin{center}% 636 {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}% 637 \end{center}% 638 \quote 639 \fi} 640 {\if@twocolumn\else\endquote\fi} 641 \fi

7.4.2 Verse

\verse The verse environment is defined by making clever use of the list environment’s parameters. The user types \\ to end a line. This is implemented by \let’ing \\

 equal \@centercr.

642 \newenvironment{verse} 643 {\let\\=\@centercr 644 \list{}{\itemsep \z@ 645 \itemindent -1.5em% 646 \listparindent\itemindent 647 \rightmargin \leftmargin 648 \advance\leftmargin 1.5em}% 649 \item[]} 650 {\endlist}

7.4.3 Quotation

\quotation The quotation environment is also defined by making clever use of the list environment’s parameters. The lines in the environment are set smaller than \textwidth. The first line of a paragraph inside this environment is indented.

651 \newenvironment{quotation} 652 {\list{}{\listparindent 1.5em% 653 \itemindent \listparindent 654 \rightmargin \leftmargin 655 \parsep \z@ \@plus\p@}% 656 \item[]} 657 {\endlist}

7.4.4 Quote

\quote The quote environment is like the quotation environment except that paragraphs are not indented.

658 \newenvironment{quote} 659 {\list{}{\rightmargin\leftmargin}% 660 \item[]} 661 {\endlist}

7.4.5 Example

\example The example environment is a verse environment with tt font which tries to avoid pagebrakes at the \begin{example}.

662 \newenvironment{example} 663 {\@beginparpenalty=\highpenalty 664 \let\\=\@centercr 665 \list{}{\itemsep \z@ 666 \itemindent -1.5em% 667 \listparindent\itemindent 668 \rightmargin \leftmargin 669 \advance\leftmargin 1.5em}% 670 \ttfamily 671 \item[]} 672 {\endlist}

7.4.6 Theorem

This document class does not define it’s own theorem environments, the defaults, supplied by latex.dtx are available.

7.4.7 Titlepage

\titlepage In the normal environments, the titlepage environment does nothing but start and end a page, and inhibit page numbers. It also resets the page number to zero. In two-column style, it still makes a one-column page.

673 \newenvironment{titlepage} 674 {\if@twocolumn 675 \@restonecoltrue\onecolumn 676 \else 677 \@restonecolfalse\newpage 678 \fi 679 \thispagestyle{empty}% 680 \setcounter{page}{1}} 681 {\if@restonecol\twocolumn \else \newpage \fi 682 \setcounter{page}{1}}

7.4.8 Appendix

\appendix The \appendix command is not really an environment, it is a macro that makes

some changes in the way things are done.

In the article document class the \appendix command must do the following:

• reset the section and subsection counters to zero,

• redefine \thesection to produce alphabetic appendix numbers.

683 ⟨∗refart⟩ 684 \newcommand\appendix{\par 685 \setcounter{section}{0}% 686 \setcounter{subsection}{0}% 687 \renewcommand\thesection{\Alph{section}}} 688 ⟨/refart⟩

In the report and book document classes the \appendix command must do the following:

• reset the chapter and section counters to zero,

• set \@chapapp to \appendixname (for messages),

• redefine the chapter counter to produce appendix numbers,

• possibly redefine the \chapter command if appendix titles and headings are to look different from chapter titles and headings.

689 ⟨∗refrep⟩ 690 \newcommand\appendix{\par 691 \setcounter{chapter}{0}% 692 \setcounter{section}{0}% 693 \renewcommand\@chapapp{\appendixname}% 694 \renewcommand\thechapter{\Alph{chapter}}} 695 ⟨/refrep⟩

7.5 Setting parameters for existing environments

7.5.1 Array and tabular

\arraycolsep The columns in an array environment are separated by 2\arraycolsep.

696 \setlength\arraycolsep{5\p@}

\tabcolsep The columns in an tabular environment are separated by 2\tabcolsep.

697 \setlength\tabcolsep{6\p@}

\arrayrulewidth The width of rules in the array and tabular environments is given by \arrayrulewidth.

698 \setlength\arrayrulewidth{.4\p@}

\doublerulesep The space between adjacent rules in the array and tabular environments is given

by \doublerulesep.

699 \setlength\doublerulesep{2\p@}

7.5.2 Tabbing

\tabbingsep This controls the space that the \' command puts in. (See L^{A}TEX manual for an explanation.)

700 \setlength\tabbingsep{\labelsep}

7.5.3 Minipage

\@minipagerestore The macro \@minipagerestore is called upon entry to a minipage environment to set up things that are to be handled differently inside a minipage environment. In the current styles, it does nothing.

\@mpfootins Minipages have their own footnotes; \skip\@mpfootins plays same rôle for footnotes in a minipage as \skip\footins does for ordinary footnotes.

701 \skip\@mpfootins = \skip\footins

7.5.4 Framed boxes

\fboxsep The space left by \fbox and \framebox between the box and the text in it.

\fboxrule The width of the rules in the box made by \fbox and \framebox.

702 \setlength\fboxsep{3\p@} 703 \setlength\fboxrule{.4\p@}

7.5.5 Equation and eqnarray

\theequation The equation counter will be reset at beginning of a new chapter and the equation

number will be prefixed by the chapter number.

This code must follow the \chapter definition, or more exactly the definition of the chapter counter.

704 ⟨+refart⟩\renewcommand\theequation{\arabic{equation}} 705 ⟨∗refrep⟩ 706 \@addtoreset{equation}{chapter} 707 \renewcommand\theequation{\thechapter.\arabic{equation}} 708 ⟨/refrep⟩

\jot \jot is the extra space added between lines of an eqnarray environment. The default value is used.

709 % \setlength\jot{3pt}

\@eqnnum The macro \@eqnnum defines how equation numbers are to appear in equations. Again the default is used.

710 % \def\@eqnnum{(\theequation)}

7.6 Floating objects

The file latex.dtx only defines a number of tools with which floating objects can be defined. This is done in the document class. It needs to define the following macros for each floating object of type TYPE (e.g., TYPE = figure).

\fps@TYPE The default placement specifier for floats of type TYPE.

\ftype@TYPE The type number for floats of type TYPE. Each TYPE has associated a unique positive TYPE number, which is a power of two. E.g., figures might have type number 1, tables type number 2, programs type number 4, etc.

\ext@TYPE The file extension indicating the file on which the contents list for float type TYPE is stored. For example, \ext@figure = ‘lof’.

\fnum@TYPE A macro to generate the figure number for a caption. For example,

     \fnum@TYPE == ‘Figure \thefigure’.

\@makecaption⟨num⟩⟨text⟩ A macro to make a caption, with ⟨num⟩ the value produced by \fnum@... and ⟨text⟩ the text of the caption. It can assume it’s in a \parbox of the appropriate width. This will be used for all floating objects.

The actual environment that implements a floating object such as a figure is defined using the macros \@float and \end@float, which are defined in latex.dtx.

An environment that implements a single column floating object is started with \@float{TYPE}[⟨placement⟩] of type TYPE with ⟨placement⟩ as the placement specifier. The default value of ⟨PLACEMENT ⟩ is defined by \fps@TYPE.

The environment is ended by \end@float. E.g., \figure == \@floatfigure,

\endfigure == \end@float.

7.6.1 Figure

Here is the implementation of the figure environment.

\c@figure First we have to allocate a counter to number the figures. In the report and book document classes the figures are numbered per chapter.

711 ⟨∗refart⟩ 712 \newcounter{figure} 713 \renewcommand\thefigure{\@arabic\c@figure} 714 ⟨/refart⟩ 715 ⟨∗refrep⟩ 716 \newcounter{figure}[chapter] 717 \renewcommand\thefigure{\thechapter.\@arabic\c@figure} 718 ⟨/refrep⟩

\fps@figure \ftype@figure \ext@figure \num@figure Here are the parameters for the floating objects of type ‘figure’.

719 \def\fps@figure{tbp} 720 \def\ftype@figure{1} 721 \def\ext@figure{lof} 722 \def\fnum@figure{\figurename~\thefigure}

figure figure* And the definition of the actual environment. The form with the * is used for double column figures.

723 \newenvironment{figure} 724 {\@float{figure}} 725 {\end@float} 726 \newenvironment{figure*} 727 {\@dblfloat{figure}} 728 {\end@dblfloat}

7.6.2 Table

Here is the implementation of the table environment. It is very much the same as the figure environment.

\c@table First we have to allocate a counter to number the tables. In the report and book document classes the tables are numbered per chapter.

729 ⟨∗refart⟩ 730 \newcounter{table} 731 \renewcommand\thetable{\@arabic\c@table} 732 ⟨/refart⟩ 733 ⟨∗refrep⟩ 734 \newcounter{table}[chapter] 735 \renewcommand\thetable{\thechapter.\@arabic\c@table} 736 ⟨/refrep⟩

\fps@table \ftype@table \ext@table \num@table Here are the parameters for the floating objects of type ‘table’.

737 \def\fps@table{tbp} 738 \def\ftype@table{2} 739 \def\ext@table{lot} 740 \def\fnum@table{\tablename~\thetable}

table table* And the definition of the actual environment. The form with the * is used for double column tables.

741 \newenvironment{table} 742 {\@float{table}} 743 {\end@float} 744 \newenvironment{table*} 745 {\@dblfloat{table}} 746 {\end@dblfloat}

7.6.3 Captions

\@makecaption The \caption command calls \@makecaption to format the caption of floating objects. It gets two arguments, ⟨number⟩, the number of the floating object and ⟨text⟩, the text of the caption. Usually ⟨number⟩ contains a string such as ‘Figure 3.2’. The macro can assume it is called inside a \parbox of right width, with

\normalsize.

\abovecaptionskip \belowcaptionskip These lengths contain the amount of white space to leave above and below the caption.

747 \newlength\abovecaptionskip 748 \newlength\belowcaptionskip 749 \setlength\abovecaptionskip{10\p@} 750 \setlength\belowcaptionskip{0\p@}

The definition of this macro is \long in order to allow more then one paragraph in a caption.

751 \long\def\@makecaption#1#2{% 752 \vskip\abovecaptionskip

We want to see if the caption fits on one line on the page, therefore we first typeset it in a temporary box.

753 \sbox\@tempboxa{#1: #2}%

We can the measure its width. It that is larger than the current \hsize we typeset the caption as an ordinary paragraph.

754 \ifdim \wd\@tempboxa >\hsize 755 #1: #2\par

If the caption fits, we center it.

756 \else 757 \global \@minipagefalse 758 \hbox to\hsize{\hfil\box\@tempboxa\hfil}% 759 \fi 760 \vskip\belowcaptionskip}

7.7 Font changing

Here we supply the declarative font changing commands that were common in L^{A}TEX version 2.09 and earlier. These commands work in text mode and in math mode. They are provided for compatibility, but one should start using the \text... and \math... commands instead. These commands are defined using \@newfontswitch, a command with three arguments: the user command to be defined; L^{A}TEX commands to execute in text mode and L^{A}TEX commands to execute in math mode.

\rm \tt \sf The commands to change the family. When in compatibility mode we select the ‘default’ font first, to get L^{A}TEX2.09 behviour.

761 \DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm} 762 \DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf} 763 \DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}

\bf The command to change to the bold series. One should use \mdseries to explicitly switch back to medium series.

764 \DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}

\sl \it \sc And the commands to change the shape of the font. The slanted and small caps shapes are not available by default as math alphabets, so those changes do nothing in math mode. One should use \upshape to explicitly change back to the upright shape.

765 \DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit} 766 \DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl} 767 \DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}

{\cal \atop \mit} The commands \cal and \mit should only be used in math mode, outside math mode they have no effect. Currently the New Font Selection Scheme defines these commands to generate warning messages. Therefore we have to define them ‘by hand’.

768 \DeclareRobustCommand*{\cal}{\@fontswitch{\relax}{\mathcal}} 769 \DeclareRobustCommand*{\mit}{\@fontswitch{\relax}{\mathnormal}}

8 Cross Referencing

8.1 Table of Contents, etc.

A \section command writes a \contentsline{section}{⟨title⟩}{⟨page⟩} com-

mand on the .toc file, where ⟨title⟩ contains the contents of the entry and ⟨page⟩ is the page number. If sections are being numbered, then ⟨title⟩ will be of the form \numberline{⟨num⟩}{⟨heading⟩} where ⟨num⟩ is the number produced by \thesection. Other sectioning commands work similarly.

A \caption command in a ‘figure’ environment writes

   \contentsline{figure}{\numberline{⟨num⟩}{ ⟨caption⟩}}{⟨page⟩}

on the .lof file, where ⟨num⟩ is the number produced by \thefigure and ⟨caption⟩ is the figure caption. It works similarly for a ‘table’ environment.

The command \contentsline{⟨name⟩} expands to \l@⟨name⟩. So, to specify

the table of contents, we must define \l@chapter, \l@section, \l@subsection,

... ; to specify the list of figures, we must define \l@figure; and so on. Most of these can be defined with the \@dottedtocline command, which works as follows.

\@dottedtocline{⟨level⟩}{⟨indent⟩}{⟨numwidth⟩}{⟨title⟩}{⟨page⟩}

⟨level⟩ An entry is produced only if⟨ level⟩ <= value of the tocdepth counter. Note, \chapter is level 0, \section is level 1, etc.

⟨indent⟩ The indentation from the outer left margin of the start of the contents line.

⟨numwidth⟩ The width of a box in which the section number is to go, if ⟨title⟩ includes a \numberline command.

\@pnumwidth \@tocrmarg \@dotsep This command uses the following three parameters, which are set with a \newcommand (so em’s can be used to make them depend upon the font).

\@pnumwidth The width of a box in which the page number is put.

\@tocrmarg The right margin for multiple line entries. One wants \@tocrmarg >

     or = \@pnumwidth

\@dotsep Separation between dots, in mu units. Should be defined as a number like 2 or 1.7

770 \newcommand\@pnumwidth{1.55em} 771 \newcommand\@tocrmarg {2.55em} 772 \newcommand\@dotsep{4.5} 773 ⟨+refart⟩\setcounter{tocdepth}{3} 774 ⟨+refrep⟩\setcounter{tocdepth}{2}

8.1.1 Table of Contents

\tableofcontents This macro is used to request that L^{A}TEX produces a table of contents. In the report and book document classes the tables of contents, figures etc. are always set in single-column style.

775 \newcommand\tableofcontents{% 776 ⟨∗refrep⟩ 777 \if@twocolumn 778 \@restonecoltrue\onecolumn 779 \else 780 \@restonecolfalse 781 \fi

The title is set using the \chapter* command, making sure that the running head –if one is required– contains the right information.

782 \chapter*{\contentsname 783 ⟨/refrep⟩ 784 ⟨+refart⟩ \section*{\contentsname 785 \@mkboth{\contentsname}{\contentsname}}%

The the actual table of contents is made by calling \@starttoc{toc}. After that we restore twocolumn mode if necessary.

786 \@starttoc{toc}% 787 \if@restonecol\twocolumn\fi 788 }

\l@part Each sectioning command needs an additional macro to format its entry in the table of contents, as described above. The macro for the entry for parts is defined in a special way.

First we make sure that if a pagebreak should occur, it occurs before this entry. Also a little whitespace is added and a group begun to keep changes local.

789 \newcommand\l@part[2]{% 790 \ifnum \c@tocdepth >-2\relax 791 ⟨+refart⟩ \addpenalty{\@secpenalty}% 792 ⟨+refrep⟩ \addpenalty{-\@highpenalty}% 793 \addvspace{2.25em \@plus\p@}% 794 \begingroup

The macro \numberline requires that the width of the box that holds the part number is stored in L^{A}TEX’s scratch register \@tempdima. Therefore we put it there.

795 \setlength\@tempdima{3em}%

The we set \parindent to 0pt and use \rightskip to leave enough room for the pagenumbers. To prevent overfull box messages the \parfillskip is set to a negative value.

796 \parindent \z@ \rightskip \@pnumwidth 797 \parfillskip -\@pnumwidth

Now we can set the entry, in a large bold font. We make sure to leave vertical mode, set the part title and add the pagenumber, set flush right.

798 {\leavevmode 799 \large \bfseries #1\hfil \hbox to\@pnumwidth{\hss #2}}\par

Prevent a pagebreak immediately after this entry, but use \everypar to reset the \if@nobreak switch. Finally we close the group.

800 \nobreak 801 \global\@nobreaktrue 802 \everypar{\global\@nobreakfalse\everypar{}} 803 \endgroup 804 \fi}

\l@chapter This macro formats the entries in the table of contents for chapters. It is very

similar to \l@part

First we make sure that if a pagebreak should occur, it occurs before this entry. Also a little whitespace is added and a group begun to keep changes local.

805 ⟨∗refrep⟩ 806 \newcommand\l@chapter[2]{% 807 \ifnum \c@tocdepth >\m@ne 808 \addpenalty{-\@highpenalty}% 809 \vskip 1.0em \@plus\p@

The macro \numberline requires that the width of the box that holds the part number is stored in L^{A}TEX’s scratch register \@tempdima. Therefore we put it there. We begin a group, and change some of the paragraph parameters.

810 \setlength\@tempdima{1.5em}% 811 \begingroup 812 \parindent \z@ \rightskip \@pnumwidth 813 \parfillskip -\@pnumwidth

Then we leave vertical mode and switch to a bold font.

814 \leavevmode \bfseries

Because we do not use \numberline here, we have do some fine tuning ‘by hand’, before we can set the entry. We discourage but not disallow a pagebreak immediately after a chapter entry.

815 \advance\leftskip\@tempdima 816 \hskip -\leftskip 817 #1\nobreak\hfil \nobreak\hbox to\@pnumwidth{\hss #2}\par 818 \penalty\@highpenalty 819 \endgroup 820 \fi} 821 ⟨/refrep⟩

\l@section In the article document class the entry in the table of contents for sections looks

much like the chapter entries for the report and book document classes.

First we make sure that if a pagebreak should occur, it occurs before this entry. Also a little whitespace is added and a group begun to keep changes local.

822 ⟨∗refart⟩ 823 \newcommand\l@section[2]{% 824 \ifnum \c@tocdepth >\z@ 825 \addpenalty{\@secpenalty}% 826 \addvspace{1.0em \@plus\p@}%

The macro \numberline requires that the width of the box that holds the part number is stored in L^{A}TEX’s scratch register \@tempdima. Therefore we put it there. We begin a group, and change some of the paragraph parameters.

827 \setlength\@tempdima{1.5em}% 828 \begingroup 829 \parindent \z@ \rightskip \@pnumwidth 830 \parfillskip -\@pnumwidth

Then we leave vertical mode and switch to a bold font.

831 \leavevmode \bfseries

Because we do not use \numberline here, we have do some fine tuning ‘by hand’, before we can set the entry. We discourage but not disallow a pagebreak immediately after a chapter entry.

832 \advance\leftskip\@tempdima 833 \hskip -\leftskip 834 #1\nobreak\hfil \nobreak\hbox to\@pnumwidth{\hss #2}\par 835 \endgroup 836 \fi} 837 ⟨/refart⟩

In the report and book document classes the definition for \l@section is much simpler.

838 ⟨∗refrep⟩ 839 \newcommand\l@section {\@dottedtocline{1}{1.5em}{2.3em}} 840 ⟨/refrep⟩

\l@subsection \l@subsubsection \l@paragraph \l@subparagraph All lower level entries are defined using the macro \@dottedtocline (see above).

841 ⟨∗refart⟩ 842 \newcommand\l@subsection {\@dottedtocline{2}{1.5em}{2.3em}} 843 \newcommand\l@subsubsection{\@dottedtocline{3}{3.8em}{3.2em}} 844 \newcommand\l@paragraph {\@dottedtocline{4}{7.0em}{4.1em}} 845 \newcommand\l@subparagraph {\@dottedtocline{5}{10em}{5em}} 846 ⟨/refart⟩ 847 ⟨∗refrep⟩ 848 \newcommand\l@subsection {\@dottedtocline{2}{3.8em}{3.2em}} 849 \newcommand\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}} 850 \newcommand\l@paragraph {\@dottedtocline{4}{10em}{5em}} 851 \newcommand\l@subparagraph {\@dottedtocline{5}{12em}{6em}} 852 ⟨/refrep⟩

8.1.2 List of figures

\listoffigures This macro is used to request that L^{A}TEX produces a list of figures. It is very

 similar to \tableofcontents.

853 \newcommand\listoffigures{% 854 ⟨∗refrep⟩ 855 \if@twocolumn 856 \@restonecoltrue\onecolumn 857 \else 858 \@restonecolfalse 859 \fi 860 \chapter*{\listfigurename 861 ⟨/refrep⟩ 862 ⟨+refart⟩ \section*{\listfigurename 863 \@mkboth{\listfigurename}% 864 {listfigurename}}% 865 \@starttoc{lof}% 866 ⟨+refrep⟩ \if@restonecol\twocolumn\fi 867 }

\l@figure This macro produces an entry in the list of figures.

868 \newcommand\l@figure{\@dottedtocline{1}{1.5em}{2.3em}}

8.1.3 List of tables

\listoftables This macro is used to request that L^{A}TEX produces a list of tables. It is very similar

to \tableofcontents.

869 \newcommand\listoftables{% 870 ⟨∗refrep⟩ 871 \if@twocolumn 872 \@restonecoltrue\onecolumn 873 \else 874 \@restonecolfalse 875 \fi 876 \chapter*{\listtablename 877 ⟨/refrep⟩ 878 ⟨+refart⟩ \section*{\listtablename 879 \@mkboth{\listtablename}{\listtablename}}% 880 \@starttoc{lot}% 881 ⟨+refrep⟩ \if@restonecol\twocolumn\fi 882 }

\l@table This macro produces an entry in the list of tables.

883 \let\l@table\l@figure

8.2 Bibliography

\bibindent The “open” bibliography format uses an indentation of \bibindent.

884 \newdimen\bibindent 885 \bibindent=1.5em

\thebibliography \newblock The ‘thebibliography’ environment executes the following commands:

   \renewcommand\newblock{\hskip .11em \@plus .33em \@minus .07em} –

Defines the “closed” format, where the blocks (major units of information) of an entry run together.

\sloppy – Used because it’s rather hard to do line breaks in bibliographies, \sfcode`\.=1000\relax – Causes a ‘.’ (period) not to produce an end-of-

sentence space.

The implementation of this environment is based on the generic list environment. It uses the enumiv counter internally to generate the labels of the list.

When an empty ‘thebijliography’ environment is found, a warning is issued.

886 \newcommand\newblock{} 887 \newenvironment{thebibliography}[1] 888 ⟨+refart⟩ {\section*{\refname 889 ⟨+refart⟩ \@mkboth{\refname}{\refname}}% 890 ⟨+refrep⟩ {\chapter*{\bibname 891 ⟨+refrep⟩ \@mkboth{\bibname}{\bibname}}% 892 \list{\@biblabel{\arabic{enumiv}}}% 893 {\settowidth\labelwidth{\@biblabel{#1}}% 894 \leftmargin\labelwidth 895 \advance\leftmargin\labelsep 896 \if@openbib 897 \advance\leftmargin\bibindent 898 \itemindent -\bibindent 899 \listparindent \itemindent 900 \parsep \z@ 901 \fi 902 \usecounter{enumiv}% 903 \let\p@enumiv\@empty 904 \renewcommand\theenumiv{\arabic{enumiv}}}% 905 \if@openbib 906 \renewcommand\newblock{\par} 907 \else 908 \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}% 909 \fi 910 \sloppy\clubpenalty4000\widowpenalty4000% 911 \sfcode‘\.=\@m} 912 {\def\@noitemerr{\@warning{Empty ‘thebibliography’ environment}}% 913 \endlist}

\@biblabel The label for a \bibitem[...] command is produced by this macro. The default from latex.dtx is used.

914 % \renewcommand\@biblabel[1]{[#1]\hfill} 915 %( \end{macrocode} 916 % \end{macro} 917 % 918 % \begin{macro}{\@cite} 919 % The output of the |\cite| command is produced by this macro. The 920 % default from \file{latex.dtx} is used. 921 % \begin{macrocode} 922 % \renewcommand\@cite[1]{[#1]}

8.3 The index

\theindex The environment ‘theindex’ can be used for indices. It makes an index with two columns, with each entry a seperate paragraph. At the user level the commands \item, \subitem and \subsubitem are used to produce index entries of various levels. When a new letter of the alphabet is encountered an amount of \indexspace white space can be added.

923 \newenvironment{theindex} 924 {\if@twocolumn 925 \@restonecolfalse 926 \else 927 \@restonecoltrue 928 \fi 929 \begin{fullpage} 930 \let\twocolumn\REF@twocolumn 931 \columnseprule \z@ 932 \columnsep 35\p@ 933 ⟨+refart⟩ \twocolumn[\section*{\indexname}]% 934 ⟨+refrep⟩ \twocolumn[\@makeschapterhead{\indexname}]% 935 \@mkboth{\indexname}% 936 {\indexname}% 937 \thispagestyle{plain}\parindent\z@ 938 \parskip\z@ \@plus .3\p@\relax 939 \let\item\@idxitem}

When the document continues after the index and it was a one column document we have to switch back to one column after the index.

940 {\end{fullpage}\if@restonecol\onecolumn\else\clearpage\fi}

\@idxitem \subitem \subsubitem Thsee macros are used to format the entries in the index.

941 \newcommand\@idxitem {\par\hangindent 40\p@} 942 \newcommand\subitem {\par\hangindent 40\p@ \hspace*{20\p@}} 943 \newcommand\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}

\indexspace The amount of white space that is inserted between ‘letter blocks’ in the index.

944 \newcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}

8.4 Footnotes

\footnoterule Usually, footnotes are separated from the main body of the text by a small rule. This rule is drawn by the macro \footnoterule. We have to make sure that the rule takes no vertical space (see plain.tex) so we compensate for the natural heigth of the rule of 0.4pt by adding the right amount of vertical skip.

To prevent the rule from colliding with the footnote we first add a little negative vertical skip, then we put the rule and make sure we end up at the same point where we begun this operation.

945 \renewcommand\footnoterule{% 946 \kern-3\p@ 947 \hrule width .4\columnwidth 948 \kern 2.6\p@}

\c@footnote Footnotes are numbered within chapters in the report and book document styles.

949 % \newcounter{footnote} 950 ⟨+refrep⟩\@addtoreset{footnote}{chapter}

\@makefntext The footnote mechanism of L^{A}TEX calls the macro \@makefntext to produce the actual footnote. The macro gets the text of the footnote as its argument and should use \@thefnmark as the mark of the footnote. The macro \@makefntextis called when effectively inside a \parbox of width \columnwidth (i.e., with \hsize

= \columnwidth).

An example of what can be achieved is given by the following piece of TEX code.

          \long\def\@makefntext#1{%
             \@setpar{\@@par
                      \@tempdima = \hsize
                      \advance\@tempdima-10\p@
                      \parshape \@ne 10\p@ \@tempdima}%
             \par
             \parindent 1em\noindent
             \hbox to \z@{\hss$\m@th^{\@thefnmark}$}#1}

The effect of this definition is that all lines of the footnote are indented by 10pt, while the first line of a new paragraph is indented by 1em. To change these dimensions, just substitute the desired value for ‘10pt’ (in both places) or ‘1em’. The mark is flushright against the footnote.

In these document classes we use a simpler macro, in which the footnote text is set like an ordinary text paragraph, with no indentation except on the first line of a paragraph, and the first line of the footnote. Thus, all the macro must do is set \parindent to the appropriate value for succeeding paragraphs and put the proper indentation before the mark.

951 \long\def\@makefntext#1{% 952 \@setpar{\@@par 953 \@tempdima = \hsize 954 \advance\@tempdima -1em 955 \parshape \@ne 1em \@tempdima}% 956 \par 957 \parindent 1em \noindent 958 \hbox to \z@{\hss\@makefnmark}#1}

\@makefnmark The footnote markers that are printed in the text to point to the footnotes should be produced by the macro \@makefnmark. We use the default definition for it.

959 %\def\@makefnmark{\hbox{$^{\@thefnmark}\m@th$}}

9 New commands

\@addmarginpar Redefine the \@addmarginpar command to only use the left margin.

960 \def\@addmarginpar{\@next\@marbox\@currlist{\@cons\@freelist\@marbox 961 \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne 962 \if@twocolumn 963 ( \if@firstcolumn \@tempcnta\m@ne \fi 964 \else 965 \@tempcnta\m@ne 966 \fi 967 \ifnum\@tempcnta <\z@ \global\setbox\@marbox\box\@currbox \fi 968 \@tempdima\@mparbottom 969 \advance\@tempdima -\@pageht 970 \advance\@tempdima\ht\@marbox 971 \ifdim\@tempdima >\z@ 972 \@@warning{Marginpar on page \thepage\space moved}% 973 \else 974 \@tempdima\z@ 975 \fi 976 \global\@mparbottom\@pageht 977 \global\advance\@mparbottom\@tempdima 978 \global\advance\@mparbottom\dp\@marbox 979 \global\advance\@mparbottom\marginparpush 980 \advance\@tempdima -\ht\@marbox 981 \global\setbox \@marbox 982 \vbox {\vskip \@tempdima \box \@marbox}% 983 \global \ht\@marbox \z@ 984 \global \dp\@marbox \z@ 985 \kern -\@pagedp 986 \nointerlineskip 987 \hbox to\columnwidth 988 {\ifnum \@tempcnta >\z@ 989 \hskip\columnwidth \hskip\marginparsep 990 \else 991 \hskip -\marginparsep \hskip -\marginparwidth 992 \fi 993 \box\@marbox \hss}% 994 \nointerlineskip 995 \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}}

9.1 Margin commands

\marginlable \attention \seealso This defines three commands to put information in the margin: \marginlabel buts the argument into a flushright marginpar, \attention puts !→ to the left of the text to mark an important piece of text and \seealso puts a → to the left oft the margin to mark a reference within the text.

996 \def\marginlabel#1{\mbox{}\marginpar{\raggedleft #1}\ignorespaces} 997 \def\attention{\mbox{}\marginpar{\raggedleft \large\bfseries ! 998 $\rightarrow$}} 999 \def\seealso#1{\mbox{}\marginpar{\small $\rightarrow$ #1}\ignorespaces}

9.2 Rules

\longrule \longthickrule These rules are used in several places, like the title, new parts and chapters and for maxi and fullpages.

1000 \def\longrule{\par\hbox to \linewidth{\hss 1001 \vrule width \fullwidth height 0.4\p@ depth \z@}\par} 1002 \def\longthickrule{\par\hbox to \linewidth{\hss 1003 \vrule width \fullwidth height 1.0\p@ depth \z@}\par}

9.3 Pages

\maxipage \fullpage The \maxipage is a minipage which uses the full width of the page with optional rules on the top and bottom. A maxipage can not split over pages. You can use it for wide tables, long math equations and the like. It can be used in floats.

The \fullpage changes the page layout such that normal text and all environments use the full width of the page. This will be used in the index. (Not implemented yet!)

1004 \newenvironment{maxipage}{\par 1005 \mbox{}\kern-\leftmarginwidth %\kern-\@totalleftmargin 1006 \begin{minipage}{\fullwidth} 1007 \medskip \ifmaxipagerule \hrule\medskip \fi 1008 \parskip = 0.5\baselineskip 1009 \def\marginpar{% 1010 ⟨+refart⟩ \ClassError{Refart} 1011 ⟨+refrep⟩ \ClassError{Refrep} 1012 {Marginpar not allowed within Maxipage.} 1013 {Where should I put them?\MessageBreak 1014 I’m using the full pagewidth.}}} 1015 {\par \vskip\parskip 1016 \medskip \ifmaxipagerule \hrule\medskip \fi 1017 \end{minipage}\par} 1018 \newenvironment{fullpage}{% 1019 \textwidth=\fullwidth 1020 \addtolength\oddsidemargin {-\leftmarginwidth} 1021 \setlength\evensidemargin{\oddsidemargin} 1022 \linewidth=\fullwidth 1023 \columnwidth=\fullwidth 1024 \clearpage 1025 \def\marginpar{% 1026 ⟨+refart⟩ \ClassError{Refart} 1027 ⟨+refrep⟩ \ClassError{Refrep} 1028 {Marginpar not allowed within Fullpage.} 1029 {Where should I put them? I’m already\MessageBreak 1030 using the whole page for text.}}} 1031 {\clearpage}

9.4 Miscellaneous

\condbreak \noparskip The \condbreak{length} controls pagebreaks: If less then length is left on this page it will be moved to the next page. Thus it will remain together, either on this page or on the next.

\noparskip removes the vertical parskip like \noindent removes the parindent.

1032 \def\condbreak#1{@vskip \z@ plus #1\pagebreak[3]\vskip \z@ plus -#1\relax} 1033 \def\noparskip{\vskip-\parskip}

\REF@twocolumn \twocolumn Since this layout does not support \twocolumn the command is disabled but saved in \REF@twocolumn. The saved version will be used in the index. This is still experimental! Don’t rely on it in future releases.

1034 \let\REF@twocolumn\twocolumn 1035 \def\twocolumn{% 1036 ⟨+refart⟩\ClassError{Refart} 1037 ⟨+refrep⟩\ClassError{Refrep} 1038 {Sorry, there is no twocolumn layout in this class} 1039 {Can you imagine how twocolumn layout will look?\MessageBreak 1040 That’s why!}}

9.5 Obsolete commands

Well, these comands are not really obsolete, but they are not implemented in this version and will not be implemented later unless there is popular demand.

\makeauthor: The author is printed when \maketitel is executed thus there is no need for this command.

\setleftmarginwidth has been used in version 1.1 to change the horizontal layout. I would prefer to set the leftmarginfraction instead but I’m still open to suggestions from users.

9.6 Future commands

The following commands are not yet implemented but sound like a good idea.

\pagebychapter This gives you a pagecount per chapter like 1-1, 1-2, 2-1. Since this is often requested and would be usefull in a reference manual style. \pageperchapter is only supported in refrep.cls

1041 ⟨+refrep⟩\newif\if@pageperchapter \@pageperchapterfalse 1042 ⟨+refrep⟩\newcommand{\pageperchapter} 1043 ⟨+refrep⟩ {\@pageperchaptertrue 1044 ⟨+refrep⟩ \renewcommand\@pnumwidth{2.55em} 1045 ⟨+refrep⟩ \@openrighttrue 1046 ⟨+refrep⟩ \renewcommand\thepage{% 1047 ⟨+refrep⟩ \ifnum \c@chapter = \z@ 1048 ⟨+refrep⟩ \arabic{page} 1049 ⟨+refrep⟩ \else 1050 ⟨+refrep⟩ \arabic{chapter} -- \arabic{page} 1051 ⟨+refrep⟩ \fi 1052 ⟨+refrep⟩ } 1053 ⟨+refrep⟩ }

\leftmarginfraction This provides an interface to change the horizontal layout. In this version the margin is set to 0.3 fullwidth, this may change in future versions.

10 Initialization

10.1 Words

\contentsname \listfigurename \listtablename \refname \bibname \indexname \figurename \tablename \partname \chaptername \appendixname \abstractname This document class is for documents prepared in the English language. To prepare

a version for another language, various English words must be replaced. All the English words that require replacement are defined below in command names.

1054 \newcommand\contentsname{Contents} 1055 \newcommand\listfigurename{List of Figures} 1056 \newcommand\listtablename{List of Tables} 1057 ⟨+refart⟩\newcommand\refname{References} 1058 ⟨+refrep⟩\newcommand\bibname{Bibliography} 1059 \newcommand\indexname{Index} 1060 \newcommand\figurename{Figure} 1061 \newcommand\tablename{Table} 1062 \newcommand\partname{Part} 1063 ⟨+refrep⟩\newcommand\chaptername{Chapter} 1064 \newcommand\appendixname{Appendix} 1065 \newcommand\abstractname{Abstract}

10.2 Date

\today This macro uses the TEX primitives \month, \day and \year to provide the date of the L^{A}TEX-run.

1066 \newcommand\today{\ifcase\month\or 1067 January\or February\or March\or April\or May\or June\or 1068 July\or August\or September\or October\or November\or December\fi 1069 \space\number\day, \number\year}

10.3 Two column mode

\columnsep This gives the distance between two columns in two column mode.

1070 \setlength\columnsep{10\p@}

\columnseprule This gives the width of the rule between two columns in two column mode. We have no visible rule.

1071 \setlength\columnseprule{0\p@}

10.4 The page style

We have plain pages in the document classes refart and refrep unless the user specified otherwise. We use arabic pagenumbers.

1072 \pagestyle{plain} 1073 \pagenumbering{arabic} % Arabic page numbers

10.5 Single or double sided printing

When the twoside option wasn’t specified, we don’t try to make each page as long as all the others.

1074 \if@twoside 1075 \else 1076 \raggedbottom 1077 \fi

When the twocolumn option was specified we call \twocolumn to activate this mode. We try to make each column as long as the others, but call sloppy to make our life easier.

1078 \if@twocolumn 1079 \twocolumn 1080 \sloppy 1081 \flushbottom

Normally we call \onecolumn to initiate typesetting in one column.

1082 \else 1083 \onecolumn 1084 \fi 1085 ⟨/refart | refrep⟩