Style files for the pdc- macros 1.2 (1995/03/30)

1. Introduction

1.1. About the style files

This document describes a family of plain TEX style files for typesetting documents which are short enough not to need any fancy indexing or cross-references, but long enough to want numbered section headings and a table of contents.

A style file in this context means a definitions file that specifies the formatting of for a document: layout, choice of fonts, instructions for how to format lists, and so on. The style files use the macros defined in other definition files to supply most of the features they need. The document only needs one ‘\input’ command to set up most of the commands it needs.

1.2. No cross-references

Omitting cross-references is important because it means we can avoid having documents that have to be run through TEX more than once (the first time to generate a raw index or cross-reference file, the second to incorporate the references into the document). This greatly simplifies the macros.

So that the table of contents may be generated automatically without requiring a second pass, it is printed last in the file. It follows that the table of contents belongs at the end of the front matter of the document (on pages numbered in roman numerals), immediately before page 1. It is easiest if all the front matter is printed last. After the end of the document proper, put the front matter enclosed in \frontmatter … \endfrontmatter; this automatically switches to page numbering in roman numerals, and puts the table of contents at the end.

The file pdccmdoc.tex does documents using the Computer Modern fonts. There is a variant called pdccmlft.tex intended for ‘leaflets’ that are even shorter than the ‘docs’ produced with pdccmdoc.tex. Leaflets have no front matter section, no table of contents, and section headings are much less prominent—they should only be a few pages long at most. The Malvern

versions are called ma55doc.tex and ma55lft.tex.

1.3. About this document

The file that generates this printed documentation, pdcsty.dtx is a ‘documented TEX’ file. As well as briefly describing what the macros are for and how they work, it includes a complete listing of their definitions. The text of the definitions is also written to files in the current directory, generating fresh copies of the style files. This way this documentation and the files it describes are guaranteed to match.

The lines of all definitions are numbered continuously, even though only a subset of all the definition lines will go in each file.

2. Starting up

2.1. File identification

Nowadays, macro files start with some comments identifying the file, for the benefit of people wondering what the file is for. The macro file otherwise has no other comments, in the hope that this will let TEX read it in faster. (It should be possible for the identification comments to go after an \endinput at the close of the file, but the convention is to have them at the start.)

The following segment is common to the style files and the definiton files.

  1 % ⟨filename⟩ 1.2 1995/03/30 -- macros for short documents
  2 %%%@TeX-definition-file {
  3 %%% filename       = "⟨filename⟩",
  4 %%% version        = "1.2",
  5 %%% date           = "1995/03/30",
  6 %%% package        = "pdcmac 1.0",

 7 %%% author         = "P. Damian Cugley",
 8 %%% email          = "damian.cugley@comlab.ox.ac.uk",
 9 %%% address        = "Oxford University Computing Laboratory,
10 %%%                   Parks Road, Oxford  OX1 3QD, UK",
11 %%% codetable      = "USASCII",
12 %%% keywords       = "TeX, plain TeX, style file",
13 %%% supported      = "Maybe",

Computer Modern

14 %%% abstract       = "Top-level macro file for documents set in
15 %%%                   Computer Modern fonts.

Malvern

16 %%% abstract       = "Top-level macro file for documents set in
17 %%%                   Malvern 55, 56 and 75 fonts.
    pdclft.def, pdcdoc.def
18 %%% abstract       = "Sectioning macros for style files.
19 %%%                   This macro file was generated by running plain
20 %%%                   TeX on pdcsty.dtx",
21 %%% copyright      = "Copyright (c) 1991-1995 P. Damian Cugley",
22 %%% copying        = "DO NOT DISTRIBUTE THIS FILE.
23 %%%                   Distribute pdcsty.dtx only as part of the
24 %%%                   package it came in.",
    pdclft.def, pdcdoc.def
25 %%% dependencies   = ""

Computer Modern

26 %%% dependencies   = "pdcfmt2.tex, pdcfsel.tex, pdchyex.tex,
27 %%%                   pdcimth.tex, pdccmsub.tex, pdcmigr.tex,

Malvern

28 %%% dependencies   = "maamac.tex, pdcfmt2.tex, pdcfsel.tex,
29 %%%                   pdchyex.tex, pdcimth.tex, pdcmigr.tex,

PostScript fonts

30 %%% dependencies   = "pdcadobe.tex, pdcfmt2.tex, pdcfsel.tex,
31 %%%                   pdchyex.tex, pdcimth.tex, pdcmigr.tex,

Doc style files

32 %%%                   pdcoput5.tex, pdcdoc.def",

Lft style files

33 %%%                   pdcoput5.tex, pdclft.def",
34 %%%}

35

36 \message{1.2 <pdc 1995/03/30>}

37

This is followed immediately by a list of the macro files included by this format:

Style files

38 \input pdcimth
39 \input pdcmigr
40 \input pdcfmt2
41 \input pdchyex
42 \input pdcoput5
43 \input pdcfsel

Computer Modern

44 \input pdccmsub

Malvern

45 \input maamac

PostScript fonts

46 \input pdcadobe

3. Layout

3.1. Paper sizes

The section defining the paper size is at the very top of the file to make it easy for someone adapting the macros to American Letter size paper to find them.

Nevertheless, we set the top and bottom margins to be large enough that even if it is printed on American paper, nothing important will be cut off. This requires decent-sized margins at the top and bottom of pages (since the end of the page that will be lost depends on whether the printer driver has its real origin at top-left or bottom-left). The edge of the printing area is guessed at as being 7 mm from the edge of the paper.

47 \topmg=297mm \advance\topmg-11in \advance\topmg7mm
48 \botmg=\topmg
49 \advance\topmg\ht\strutbox \advance\topmg\headlineskip
50 \ifdim \topmg<20mm \topmg=20mm \fi
51 \ifdim \botmg<27mm \botmg=27mm \fi
52 \setpaper{210mm}{297mm}

The document has ‘tab-index’ headings, that is, headings go in a wide left margin to the left of the body text. The underlying structure is a grid is 4 cells wide, with the text spanning across the rightmost 3 cells. Definitions in the fonts section below specify that the text will be set ragged-right.

53 \setnkgrid{4}{3}
54 \colrule=0pt
55 \leftmargin=\gridwd \advance\leftmargin\colsep

The output routine’s \leftbox is set at the start of each page to make space for the left margin.

56 \everypage={\ifdim\leftmargin>0pt
57  \setbox\leftbox=\hbox to \gridwd{}\fi}

While we’re here, we customize some of the environments supplied by pdcFMT2:

58 \everyfootnote={\notefonts}
59 \everylinenum={\smallfonts}

Malvern

60 \def\footnotetextmark#1{{\rmsy#1}}
61 \def\footnotenotemark#1{{\rmsy#1}}
62 \everylinenum={\smallfonts}
63 \everytag={\bf}

4. Fonts

This section describes the fonts available in the document.

We introduce extra nicknames \bi for bold italic (used for the first mention of new techical terms), \mf for the METAFONT logo, \mfi for the METAFONT logo in italic (Something of an affectation) and \ttb for an ‘emphasized’ typewriter (usually it is best if this is slanted, not bold).

Style files

64 \autoloadfonts

The style files differ because of encoding schemes more than because of the particular fonts. For example, a style for Times Roman will work for Palatino too,if we change the names of the fonts used. To do this, a macro \basefontname may be defined before the style file is read in; if it isn’t defined it is given a default value.

4.1. Fonts for Computer Modern documents Computer Modern We use Computer Modern Sans Serif for the headings in CM documents. I have not put

much effort into making formulas work in headings.

65 \def\STYheadingT{%
66  \m{rm}{cmss}\m{mi}{cmmi}\m{sy}{cmsy}%
67  \f{it}{cmssi}\f{tt}{cmtt}\f{mf}{logo}\f{mfi}{logosl}%

68 }

69 \font\headingrm=cmss17 \font\headingit=cmssi17
70 \fontset{subheading}\STYheadingT{10 scaled 1200}{14pt}
71  {small}{tiny}
72 \fontset{heading}\STYheadingT{10 scaled 1728}{20pt}
73  {subheading}{small}

We use Computer Modern for body text.

74 \def\STYbodyT{\m{rm}{cmr}\m{it}{cmti}%
75  \m{bf}{cmbx}\@\f{bi}{cmbxti10}%
76  \m{mi}{cmmi}\m{sy}{cmsy}%
77  \@\f{mf}{logo10}\@\f{mfi}{logosl10}%
78  \f{tt}{cmtt}\@\f{ttb}{cmsltt10}%

79 }

80 \font\tinytt=cmtt8 at 7pt
81 \font\bodysy=cmsy10 at 12pt

4.2. Fonts for Malvern documents

Malvern

Headings are in Malvern 75. The maths fonts are scaled for expediency; I do not make much effort to make formulas work in headings.

82 \def\STYheadingT{%
83  \m{rm}{ma75a}\@\m{mi}{cmmi10}\@\m{sy}{cmsy10}%
84  \f{it}{ma76a}\@\f{tt}{cmtt10}\@\f{mf}{logo10}\@\f{mfi}{logosl10}%

85 }

86 \fontset{subheading}\STYheadingT{12}{14pt}{subheading}{subheading}
87 \fontset{heading}\STYheadingT{18}{20pt}{subheading}{subheading}

We use Malvern 55 for body text. The supplementary font with encoding B is added, with font nickname \rmsy.

88 \newfam\rmsyfam
89 \def\STYbodyT{%
90  \m{rm}{ma55a}\f{rmsy}{ma55b}\m{it}{ma56a}%
91  \m{bf}{ma75a}\f{bi}{ma76a}%
92  \m{mi}{cmmi}\m{sy}{cmsy}%
93  \@\f{mf}{logo10}\@\f{mfi}{logosl10}%
94  \f{tt}{cmtt}\f{tb}{cmsltt}%

95 }

There is no point using \loadfont on the maths symbol fonts, since they have to be loaded anyway the first time \bodyfonts is called.

96 \font\bodymi=cmmi10 scaled \magstep2
97 \font\bodysy=cmsy10 scaled \magstep2
98 \font\notemi=cmmi10 scaled \magstep1
99 \font\notesy=cmsy10 scaled \magstep1
100 \font\smallmi=cmmi10 scaled \magstephalf
101 \font\smallsy=cmsy10 scaled \magstephalf

4.3. Fonts for Times documents

PostScript fonts The big problem with PostScript fonts is what they are called; I shall be assuming that

Fontname 1.6* applies: fonts with afm2tfm’s variation on the TEX Text encoding are called ptmr and fonts with Adobe’s StandardRoman encoding are called ptmr0 (rather than rptmr).

This macro attempts to make it possible to guess the standard name for the italic variant of a given font. \KBcanonical{⟨tentative font name⟩} takes a font name which is formed from an upright name optionally followed by ‘i’ representing an italic variation. It returns the corresponding standard name. For example, ptmri is left unchanged, but phvri is changed to

phvro and phvrrni is changed to phvron.
102 \def\KBcanonical#1{%
103  \expcs\ifx{KB#1}\relax #1\else\csname KB#1\endcsname \fi

104 }

105 \ifx\KBadobe\UNDEFINED \def\KBadobe#1{\KBcanonical{#10}} \fi
106 \def\KBit#1{\KBcanonical{#1i}}
107 \def\KBbi#1{\KBbf{#1i}}
108 \def\KBbf#1{\expandafter\KBbfx#1.}
109 \def\KBbfx#1#2#3#4#5.{\KBcanonical{#1#2#3b#5}}

* Karl Berry, File Names for TEX Fonts 1.6 (ftp://ftp.umb.edu/pub/tex/fontname/).

110 \def\KBpagbr{pagdr}        \def\KBpagbri{pagdro}
111 \def\KBpbkbr{pbkdr}        \def\KBpbkbri{pbkdri}
112 \def\KBpagri{pagro}        \def\KBpagbi{pagbo}
113 \def\KBphvri{phvro}        \def\KBphvbi{phvbo}
114 \def\KBpcrri{pcrro}        \def\KBpcrbi{pcrbo}
115 \def\KBphvrrni{phvron}     \def\KBphvbrni{phvbon}
116 \def\KBphvrrn0{phvr0n}     \def\KBphvbrn0{phvb0n}
117 \def\KBphvrrni0{phvro0n}   \def\KBphvbrni0{phvbo0n}

Headings are in Helvetica. The maths fonts are scaled for expediency; I do not make much effort to make formulas work in headings.

118 \ifx\headingfontname\UNDEFINED \def\headingfontname{phvr} \fi
119 \ifx\headingttfontname\UNDEFINED \def\headingttfontname{pcrb} \fi
120 \def\STYheadingT{%
121  \@\f{rm}{\headingfontname}\@\m{mi}{cmmi10}\@\m{sy}{cmsy10}%
122  \@\f{asy}{psyr}%
123  \@\f{it}{\KBit\headingfontname}%
124  \@\f{tt}{\headingttfontname}\@\f{mf}{logo10}\@\f{mfi}{logosl10}%

125 }

126 \loadfont\bodysy{cmsy10 at 12pt}
127 \fontset{subheading}\STYheadingT{12}{14pt}{subheading}{subheading}
128 \fontset{heading}\STYheadingT{18}{20pt}{subheading}{subheading}

We use Times Roman by default for body text, and Courier for typewriter text. Adobe’s Symbol font is included, with font nickname \asy; a family called \asyfam has already been

created by pdcadobe.tex.
129 \ifx\bodyfontname\UNDEFINED \def\bodyfontname{ptmr} \fi
130 \ifx\bodyttfontname\UNDEFINED \def\bodyttfontname{pcrr} \fi
131 \def\STYbodyT{%
132  \@\m{rm}{\bodyfontname}\@\m{it}{\KBit\bodyfontname}%
133  \@\m{bf}{\KBbf\bodyfontname}\@\f{bi}{\KBbi\bodyfontname}%
134  \@\m{asy}{psyr}\m{mi}{cmmi}\m{sy}{cmsy}%
135  \@\f{mf}{logo10}\@\f{mfi}{logosl10}%
136  \@\f{tt}{\bodyttfontname}\@\f{tb}{\KBit\bodyttfontname}%

137 }

Finally the alphabet-switching commands defined for Malvern fonts are given dummy definitions.

138 \let\sc=\relax  \let\mc=\relax  \let\csc=\relax

4.4. Definitions common to all formats

Style files

139 \fontset{tiny}\STYbodyT{7}{9pt}{tiny}{tiny}
140 \fontset{small}\STYbodyT{9}{11pt}{tiny}{tiny}
141 \fontset{note}\STYbodyT{10}{12pt}{tiny}{tiny}
142 \fontset{body}\STYbodyT{12}{14pt}{small}{tiny}

The text is set left-justified (ragged-right). To make this work, the fontdimens that control word spacing are set to force interword spaces to all be the same width.

143 \def\everyloadfont#1#2{\fontdimen3#1=0pt \fontdimen4#1=0pt}
144 \rightskip=0pt plus 2em \tolerance=1000
145 \bodyfonts
146 {\tt \hyphenchar\font=-1 }

5. Simple sectioning

    pdclft.def

A ‘leaflet’ is divided into short sections, which may contain subsections (but usually will not). There may well be more than one section on a page.

The section number is held in two count registers, and printed (enclosed in \n{… }) with

the macro \thesecno:
147 \newcount\secno \newcount\subsecno

148 \def\thesecno{%
149  \n{%
150  \number\secno
151  \ifnum\subsecno>0
152  .\number\subsecno
153  \fi

154 }% 155 }

The section and subsection commands are implemented straightforwardly with macros from pdcfmt2.tex, since there is no need for marks or fiddling with table-of-contents files.

156 \def\section{
157  \global\advance\secno1 \global\subsecno0
158  \doheading\medskipamount{\subheadingfonts\thesecno\enspace}{}

159 }

160 \def\subsec{
161  \global\advance\subsecno1
162  \doheading\smallskipamount{\bodyfonts\thesecno\enspace}{}

163 }

The page header includes only the title of the file, which the user sets with the command

\majorheadline{⟨text⟩}
164 \newtoks\majorheadline
165 \expandafter\majorheadline
166  \expandafter{\expandafter\uppercase\expandafter{\jobname}}

All those \expandafters are to get the initial value in upper case.

The flag noheadline signals that the headline is to be omitted on this page (e.g., the title page). The twosided flag is set for two-sided binding.

167 \newif\ifnoheadline \newif\iftwosided
168 \headline{%
169  \ifnoheadline
170  \hfil
171  \else\iftwosided
172  \ifodd\pageno
173  \hfil \the\majorheadline \quad{\bf\folio}%
174  \else
175  {\bf\folio}\quad \the\majorheadline\hfil
176  \fi
177  \else
178  \hfil \the\majorheadline \quad{\bf\folio}%
179  \fi\fi

180 }

181 \footline{%
182  \ifnoheadline
183  \global\noheadlinefalse
184  \hfil{\bf\folio}\hfil
185  \else
186  \hfil
187  \fi

188 }

6. Sectioning in PDCCMDOC documents

    pdcdoc.def

Now a document is divided into sections, which are further divided into so-called subsecs and subsubsecs. (Division into subsubsecs should be done sparingly.)

The sections may be grouped into parts—or, to look at it another way, parts are a larger division of the document than sections, but sections are not numbered within part numbers. Each \part command should be almost immediately followed by \section.

6.1. Macros for section numbers

The part and section numbers are kept in TEX number registers, with corresponding ‘\the-’ macros to print the value formatted.

189 \newcount\partno

190 \def\thepartno{%
191  \ifcase\partno O\or I\or II\or III\or IV\or V\else
192  \expandafter\uppercase\expandafter{\romannumeral\partno}%
193  \fi

194 }

Formatted section and subsec numbers are generated by one macro \thesecno. It automatically omits (sub)subsec numbers if they are zero. The whole number is enclosed in \n{… } so that the formatting of numbers may be customized.

195 \newcount\secno \newcount\subsecno \newcount\subsubsecno
196 \def\thesecno{%
197  \n{%
198  \number\secno
199  \ifnum\subsecno>0
200  .\number\subsecno
201  \ifnum\subsubsecno>0
202  .\number\subsubsecno
203  \fi
204  \fi

205 }% 206 }

6.2. Parts

The \part macro takes one argument, the title. It sets a token register \majorheadline which is printed on the left page of two-sided documents.

The \majorheadline{⟨text⟩} command may be used immediately after a \part command if the part title is not suitable to go in the headline. This should also be used at the start of the document to the title of the document, if division into parts is not used.

207 \newtoks\majorheadline
208 \expandafter\majorheadline
209  \expandafter{\expandafter\uppercase\expandafter{\jobname}}
210 \def\part#1{%
211  \global\advance\partno1
212  \newpageheading{2\baselineskip}{\headingfonts}
213  {}{\thepartno.\quad#1}
214  \TOCwrite\TOCentrypart{\thepartno}{#1}

215 }

6.3. Section headings

Section headings will start on a new page if the current page is almost finished. The section heading is set across the full width of the page, including the margin usually used for tabindexed headings.

To force the next section to start a new page, do \sectionpenalty-10000 immediately before it.

216 \newcount\sectionpenalty
217 \def\sectionheading#1{
218  \par
219  \vskip 0pt plus 0.3\vsize
220  \penalty\sectionpenalty \sectionpenalty-200
221  \vskip 1\bigskipamount plus -0.3\vsize
222  \begingroup \advance\leftskip-\leftmargin
223  \parskip=0pt \parindent=0pt
224  \hyphenpenalty=10000 \exhyphenpenalty=500
225  \interlinepenalty=100
226  \headingfonts \nointerlineskip
227  \hbox{\hskip-\leftmargin
228  \vrule height 2pt depth 0pt width \leftmargin
229  \vrule height 2pt depth 0pt width \hsize}
230  #1\par
231  \nobreak\smallskip
232  \endgroup
233  \global\noindenttrue

234 }

As well as generating a heading, the section macro generates marks used for the page headings and a TOC entry. The marks are of the form in a way similar to that discussed in Chapter 23 of the TEXbook. More precisely, a mark is placed on either side of the section heading of the form

{⟨rhs⟩}{⟨lhs⟩}

where ⟨rhs⟩ is the section number that belongs on the right-hand page, reflecting the situation at the bottom of the page, whereas ⟨lhs⟩ is what belongs on following left-hand pages.

235 \newtoks\sectiontoks
236 \newif\ifsecno \secnotrue
237 \def\section#1{
238  \ifsecno
239  \global\advance\secno1 \global\subsecno0 \global\subsubsecno0
240  \fi
241  \toks0={#1}
242  \mark{{\the\sectiontoks}{\ifsecno\S\thesecno\space\fi\the\toks0 }}
243  \edef\tmp{\ifsecno\noexpand\S\the\secno\space\fi}
244  \global\sectiontoks\expandafter{\tmp#1}
245  \sectionheading{\ifsecno\thesecno\quad\fi #1}
246  \mark{{\the\sectiontoks}{\the\sectiontoks}}
247  \TOCwrite\TOCentrysection{\ifsecno\thesecno\fi}{#1}

248 }

Subsecs and subsubsecs use the \doheading macro defined in pdcfmt.tex. They do not appear in page headings, but may appear in the TOC.

249 \def\subsec#1{%
250  \ifsecno \global\advance\subsecno1  \global\subsubsecno0 \fi
251  \doheading\medskipamount{\subheadingfonts}{}
252  {\ifsecno\thesecno\quad\fi#1}
253  \TOCwrite\TOCentrysubsec{\ifsecno\thesecno\fi}{#1}

254 }

255 \def\subsubsec#1{%
256  \ifsecno \global\advance\subsubsecno+1 \fi
257  \doheading\smallskipamount{\rm}{}{\ifsecno\thesecno\quad\fi#1}
258  \TOCwrite\TOCentrysubsubsec{\ifsecno\thesecno\fi}{#1}

259 }

The headline and footline are controlled by two flags. The command \noheadlinetrue suppresses the headline for this page (e.g., a title page). The twosided flag says whether the document should be formatted for two-sided printing.

260 \newif\ifnoheadline
261 \newif\iftwosided
262 \footline={%
263  \ifnoheadline
264  \global\noheadlinefalse
265  \hfil\bodyfonts\n\folio\hfil
266  \else
267  \hfil
268  \fi

269 }

The headline varies according to whether it is a one-sided page, a left-hand page or a righthand page. On a one-sided page, it has the major headline (part or document title) at the left, and the section title of the first section on the page on the right with the folio. On a left-hand page, there is the folio and the major headline, and on a right-hand page there is the section title for the last section on the page, and the folio.

270 \headline={%
271  \ifnoheadline
272  \hfil
273  \else
274  \bodyfonts
275  \iftwosided
276  \ifodd\pageno
277  \hfil
278  \expandafter\firstoftwo\botmark\quad
279  {\bf\n\folio}%
280  \else

281  {\bf\n\folio}\quad
282  \the\majorheadline
283  \hfil
284  \fi
285  \else
286  \the\majorheadline
287  \hfil
288  \expandafter\secondoftwo\topmark\quad
289  {\bf\n\folio}%
290  \fi
291  \fi

292 }

293 \def\firstoftwo#1#2{#1}
294 \def\secondoftwo#1{}

7. Table of contents intrinsics

This section defines the macros used to generate a table of contents. The entries are written to a file ⟨jobname⟩.toc in the current directory. At the end of the manuscript this files is closed and then read to generate the table of contents.

Macros special to the TOC-generating section have names starting with ‘\TOC-’.

295 \newwrite\TOCfile
296 \openout\TOCfile=\jobname.toc

Entries in the TOC file are of the form

\TOCentry⟨foo⟩{⟨secno⟩}{⟨title⟩}{⟨folio⟩}

where \TOCentry⟨foo⟩ is a csname, ⟨secno⟩ is some automatically-generated section number like ‘1.2’, ⟨title⟩ is the section title as supplied by the user, and ⟨folio⟩ is the folio for this page, in arabic or lower-case roman numeral form.

They are generated with calls to \TOCwrite like this

                     \TOCwrite\TOCentry⟨foo⟩{⟨secno⟩}{⟨title⟩}

The ⟨secno⟩ is evaluated when \TOCwrite is called, whereas the ⟨title⟩ is carefully written without being expanded so that its expansion happens when the TOC file is read in. The ⟨folio⟩ is automatically appended when it is written.

297 \def\TOCwrite#1#2#3{%
298  \begingroup\def\n{\string\n}
299  \def\tmp{#3}%
300  \edef\tmp{\string#1{#2}{\expandafter\TOCtrim\meaning\tmp}}
301  \write\TOCfile\expandafter{\tmp{\folio}}\endgroup

302 }

303 \def\TOCtrim#1:->{}

Now we define all the ‘\TOCentry-’ macros.

304 \def\TOCentrypart#1#2#3{
305  \smallskip
306  \dimen0=\hsize \advance\dimen0\leftmargin
307  \moveleft\leftmargin\hbox to\dimen0{\strut\bf #1. #2\hfil}
308  \smallskip

309 }

310 \def\TOCentrysection#1#2#3{
311  \smallskip\noindent\llap{#1\kern1pc}%
312  {\bf \ignorespaces #2\quad\rm \n{#3}}\par

313 }

314 \def\TOCentrysubsec#1#2#3{
315  \ifvmode \noindent \else \quad \fi
316  {#1}~{\ignorespaces #2}

317 }

318 \def\TOCentrysubsubsec#1#2#3{}

8. Printing the front matter

The front matter of the document—the title page, preface, forword, etc.—must be printed last, with the table of contents at the end of the front matter; this is so that the table of contents may be accumulated during the TEXing of the file.* The front matter starts with the command \frontmatter and may contain \section commands. Such sections will be unnumbered and will not appear in the table of contents.

For a short document, a separate title page is probably excessive, and an abstract may be preferable to a preface. In this case the first page after \frontmatter could have the title of the document (with author etc.) followed by an abstract, any copyright information (or other small print), and the contents (generated by \endfrontmatter). In other words, something like this:

    \frontmatter

commands to print the title, etc.

      \abstract

the text of the abstract

      \endabstract

copyright information, etc.

    \endfrontmatter

For a longer document, there will be a separate title page and perhaps a preface.

    \frontmatter
      \titlepage

commands to print the title, etc.

      \splittitlepage

print copyright information, etc.

      \endtitlepage
      \section{Preface}

text of preface, etc.

    \endfrontmatter

The macro \splittitlepage marks the division between the title page (title recto, page i) and the back of the title page (title verso, page ii), which is where copyright information goes. On a one-sided document, the copyright information belongs on the title recto, because the title verso will be blank, so \splittitle instead does \vfill.

Setting \pageno nagative makes it print in roman numerals. Calling \secnofalse suppresses section numbering. The first page has no headline.

 319 \def\frontmatter{
 320  \write\TOCfile{\string\endinput}
 321  \write\TOCfile{\folio}
 322  \closeout\TOCfile
 323  \vfill\supereject
 324  \ifvoid\partialpage\else \null\vfill\eject \fi
 325  \beginthe{frontmatter}
 326  \pageno=-1 \secnofalse \noheadlinetrue
 327  \def\TOCwrite##1##2##3{}

328 }

The front matter is finshed off with the contents list, generated by \endfrontmatter. This reads the TOC file, which was closed at the end of the last page of the body of the document.

 329 \def\endfrontmatter{
 330  \section{Contents}
 331  \input\jobname.toc
 332  \vfill\supereject
 333  \endthe{frontmatter}

334 }

* It has a benefit for people reading the document with a browser: page 1 of the document is the first page of the DVI file, which makes selecting a given page easy, and the table of contents is at the very end, so the browsers ‘go to last page’ command can be used to find the table of contents quickly.

Here’s macros for generating the titlepage—it shoul;d enclose commands to generate the title, author and publisher information for the document. If it is used, it goes immediately after \frontmatter, so that the title page is page i.

335 \def\titlepage{
336  \vfill\eject
337  \beginthe{titlepage}
338  \noheadlinetrue
339  \def\splittitlepage{
340  \iftwosided \vfill\eject\null\vfill \else \vfill \fi

341 } 342 }

343 \def\endtitlepage{
344  \eject
345  \endthe{titlepage}

346 } This abstract environment doesn’t do anything fancy.

347 \def\abstract{
348  \smallskip
349  \beginthe{abstract}
350  \setbox\parbox\hbox to \gridwd{\subheadingfonts Abstract\hfil}
351  \noindenttrue \bodyfonts

352 }

353 \def\endabstract{
354  \smallskip
355  \endthe{abstract}

356 } This concludes the code that is included only in documents with TOC.

9. abbrevs

The definitions of \pt and \mm work only in maths mode.

357 \def\pt{\,{\rm pt}}
358 \def\mm{\,{\rm mm}}
359 \def\MF{{\ifdim\fontdimen1\font>0pt \mfi \else \mf \fi META}\-%
360  {\ifdim\fontdimen1\font>0pt \mfi \else \mf \fi FONT}}
361 \def\MSDOS{\leavevmode\hbox{MS-DOS}}

9.1. Program names with small caps

Some program names use small capitals in their names. For normal fonts there is no point trying to duplicate this, since small capitals aren’t common to all fonts. But small capitals come ‘for free’ with Malvern, so we might as well use them. The following definitions apply to Malvern A fonts.

Malvern

362 \def\PS{\csc{PostScript}}
363 \def\La{L\negthinspace\flushtop{\char"C1 }}

Computer Modern

364 \def\PS{PostScript}

Here’s a redefinition of \TeX. This adds a spacefactor 1000 to the end (so that TEX doesn’t apply its usual heuristic that a full stop following a capoital X isn’t a sentence end). It also loosens up the logo, producing ‘TEX’ rather than the usual ‘TEX’. This design is more forgiving of changes in font (for example, in sanserif it makes ‘TEX’ instead of ‘TEX’).

365 \def\TeX{T\kern-0.1em\lower0.5ex\hbox{E}X\spacefactor1000 }

The macro \dfn{...} formats a defining instance of a word or phrase (usually used the first time a new technical term is introduced). When generating an index with a command \index, this also adds the phrase to the index.

366 \begingroup\catcode` \|=12 \toks0={\endgroup
367  \def\dfn#1{\ifx\index\UNDEFINED\else\index{#1|INDdfn}\fi{\bi #1}}
368 } \the\toks0

Here’s a hack for using email-style emphasis using ‘asterisking’. Text enclosed in matching asterisks is emphasized.

369 \declareactivechar\* \def*#1*{{\it#1\/}}

When documenting computer progams it is useful to be able to present dialogues between the user and the computer, with the user’s commands distinguished by a slightly different font. Here we define \|⟨text⟩| so that it behaves like |⟨text⟩| except that \ttb is used instead of \tt. In maths mode it is still equivalent to \Vert.

370 \def\|{%
371  \relax\ifmmode
372  \Vert
373  \else
374  \begingroup
375  \ttb \setupverbatim
376  \catcode` \|=13 \let|\endgroup
377  \fi

378 }

10. Finally

The definitions common to all style files are read last, so that they can take account of

changes to \baselineskip.

Doc style files

379 \input pdcdoc.def

Lft style files

380 \input pdclft.def

And, at last, a file ⟨filename⟩.cfg is read, if it exists.

381 \def\inputifexists#1{%
382  \openin15=#1
383  \ifeof15 \else \input #1 \fi
384  \closein15

385 }

Style files

386 \inputifexists{⟨filename⟩.cfg}