The file booklet.dtx, a class to make simple booklets with L^{A}TEX 2ε.^{∗} It contains the code for booklet.cls

Nick Urbanik

28 January 96

Abstract

Contents

1 How to use this class 1 1.1 Purpose of this class . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Options available . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 The \ddleft option . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 The implementation 2 2.1 Producing the documentation . . . . . . . . . . . . . . . . . . . . . . 2 2.2 Identification part . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.3 Declaration of options . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.3.1 The oddleft option . . . . . . . . . . . . . . . . . . . . . . . 3 2.3.2 Pass all other options unchanged to article.cls . . . . . . . 5

2.4 Execution of options . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.5 Special class file commands . . . . . . . . . . . . . . . . . . . . . . . 6 2.6 Package loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1 How to use this class

The best way to see how to use this is by example. See the file learnc.tex for a complete example.

1.1 Purpose of this class

The purpose of this class is writing A5 sized pages for printing two to each A4 sheet. It gives a plain result, which looks a lot like my Assembly language primer booklet, but it can be adapted to other purposes.

The main purposes are producing small booklets which are stapled in the centre, and also for producing handouts that are not folded and stapled, although the gutter between the two columns is rather wide for that. See later about a proposed handout option.

∗This file has version number 2.0f, dated 28 January 96.

The file booklet.dtx, a class to make simple booklets with L^{A}TEX 2ε 2

1.2 Options available

Currently there is only one option available: the oddleft option, which organises oddleft the headers and footers so that the odd pages are on the left. This may be useful for small booklets.

Another useful option would be handout, which would provide the same format except that the gap in the middle is smaller. This would need to work with the oddleft option. The idea is that the pages would be printed two A5 pages to one A4 sheet in ten point type. These would not be intended for stapling in the middle like a booklet, but would be stapled in a corner, like normal handouts. The result would be much more readable than reduced 12 point, and would still be more readable than printing ten point printing all across an A4 page. The result would be easily readable but would require less paper. I haven’t written it yet: I’ll do it when the need becomes pressing.

1.3 The \ddleft option

The oddleft option arranges headers and footers so that the odd pages are on the left instead of on the right.

2 The implementation

2.1 Producing the documentation

Here is a short driver program that can be extracted with the L^{A}TEX 2εdocstrip program. It is not necessary to create a separate driver file from this, however; you can just run this file, booklet.dtx through L^{A}TEX 2ε.

1 ⟨∗driver⟩

 2 \ProvidesFile{booklet.drv}
 3 \documentclass[a4paper,twoside]{ltxdoc}
 4 \usepackage{a4,fancyheadings}

I have had problems with getting the correct \filedate and \fileversion from this file. I keep getting them from the file a4.sty. I believe the next line is supposed to fix such a problem, but it leaves them undefined.

 5 % \GetFileInfo{booklet.dtx}

This is definitely the wrong place to put \fileversion, \fileversion and \docdate, since it is hard to find them here, but at the moment it’s the only place where I can get them to work!

 6 \def\fileversion{2.0f}
 7 \def\filedate{28 January 96}
 8 \def\docdate{28 January 96}

These depend on the package fancyheadings. If you don’t have it, you may want to comment out these lines. You may prefer to comment out the line

\thispagestyle{empty} further down.
 9 \pagestyle{fancy} \lhead[\textbf{\upshape The file
10 \texttt{booklet.dtx}, a class to make simple booklets with
11 \LaTeXe}]{\textbf{\thepage}}
12 \rhead[\textbf{\thepage}]{\textbf{\upshape The file
13  \texttt{booklet.dtx}, a class to make simple booklets with
14  \LaTeXe}} \cfoot{}
15 \EnableCrossrefs   % Make a full index.
16 %\DisableCrossrefs % Make no index.
17 \CodelineIndex     % Index by line numbers rather than by page.

18 %\PageIndex        % index commands using page numbers.
19 \DoNotIndex{\textbf,\texttt,bfseries,\renewcommand,\providescommand}
20 \DoNotIndex{\filedate,\filename,\fileversion}
21 \DoNotIndex{\DoNotIndex,\arabic}
22 \DoNotIndex{\NeedsTeXFormat}
23 \RecordChanges     % Show change history.
24 %\OnlyDescription  % uncomment this to not format the code.
25 \title{The file \texttt{booklet.dtx}, a class to make simple booklets
26  with \LaTeXe.\thanks{This file has version number \fileversion,
27  dated \filedate.}\\[2pt]
28  It contains the code for \texttt{booklet.cls}}
29 \author{Nick Urbanik}
30 \date{\filedate}
31 \begin{document}
32 \thispagestyle{empty}
33 \maketitle
34 \providecommand{\Lenv}[1]{\textsf{#1}}
35 \providecommand{\pkg}[1]{\texttt{#1}}
36 \providecommand{\file}[1]{\texttt{#1}}
37 \DocInput{booklet.dtx}
38 \PrintIndex
39 \PrintChanges

Now tell the people what they need to do next to get the index and change list:

40 \typeout{Next, to make the index and changes list for this documentation:}
41 \typeout{2. makeindx -s gind.ist booklet}
42 \typeout{3. makeindx -s gglo.ist -o booklet.gls booklet.glo}
43 \typeout{Finally, run this file through LaTeX once more.}
44 \end{document}

45 ⟨/driver⟩

2.2 Identification part

46 ⟨∗class⟩

47 \NeedsTeXFormat{LaTeX2e}
48 \ProvidesClass{booklet}%
49  [1996/01/28 A class to make simple booklets]

2.3 Declaration of options

oddleft Currently there is only one option available: the oddleft option, which organises the headers and footers so that the odd pages are on the left. This may be useful for small booklets.

2.3.1 The oddleft option

L^{A}TEX classes generally assume that in a document produced with the twoside option the pages are numbered with odd-numbered pages on the right. This is okay for books, but for booklets sometimes it makes sense to have a cover, then pages numbered from 1 onwards, with page 1 on the left. Unfortunately, varioref still will not cope with this, but this option makes other things work okay.

50 \DeclareOption{oddleft}%
51 {%
52 \AtEndOfClass%
53 {%
54 % Now here I've changed the page setup to be similar to that for my
55 % assembly language primer, except that the left and right margins are

56 % exchanged, since here the odd-numbered pages are on the left, while
57 % in a book, the odd-numbered pages are on the right.

58 %

59 % This is what the documentation for the \pkg{vmargin} package has to say:
60 % \begin{quote}
61 % Two sided printing is supported, meaning that if on odd pages the left
62 % margin is, say, 30\,mm and the right margin is 20\,mm, it will be vice
63 % versa on even pages. This gives equal margins on the outer and the
64 % inner edge of the paper, as expected e.g. for a book.
65 % \end{quote}
66 % Here we are making an A5 booklet, obtained by folding A4 paper in half:
67 %    \begin{macrocode}
68 \setpapersize{A5}%
69 \setmarginsrb{20mm}% left For a book, the inner.  For oddleft, outer.
70  {9mm}% top
71  {13mm}% right For a book, the outer.  For oddleft, inner.
72  {10mm}% bottom
73  {12pt}% headheight---increase to stop fancyhead warn
74  {4mm}%  headsep
75  {0pt}%  footheight
76  {8mm}% footskip

Later note: it seems that the 8mm footskip is not a problem with the new footers; still, will check after examining the output.

            {13mm}% footskip

\headwidth
77 \renewcommand{\headwidth}{\textwidth}%

All changes to \textwidth to happen before here (I can’t remember whether this commandment comes from the documentation for fancyheadings or elsewhere).

News flash! It seems that it is critical to put this before redefining the \sectionmark and \subsectionmark, otherwise the new definitions are ignored!

78 \pagestyle{fancyplain}

Hey: this seems to work! A simple adaptation from my assembly language primer page setup. Note that it is essential to put the \pagestyle first, otherwise these are ignored!

79 \renewcommand*{\sectionmark}[1]%
80  {\markboth{\thesection\ \  #1}{\thesection\ \  #1}}
81 \renewcommand*{\subsectionmark}[1]{\markright{\thesubsection\ \ #1}}

This is the format of the \lhead and \rhead commands, for reference.

 \lhead[\fancyplain{plain LH-even}{normal LH-even}]
       {\fancyplain{plain LH-odd }{normal LH-odd}}
 \rhead[\fancyplain{plain RH-even}{normal RH-even}]%
       {\fancyplain{plain RH-odd }{normal RH-odd}}

We want the subsection number on the right hand page: that’s an even number in this arrangement.

82 \lhead[%
83  \fancyplain{}%
84  {%
85  \bfseries\rightmark%
86  }%
87  ]%

 88  {%
 89  \fancyplain{}%
 90  {%
 91  \rmfamily\bfseries \thepage%
 92  }%

93 }

 94 \rhead[%
 95  \fancyplain{}%
 96  {%
 97  \rmfamily\bfseries \thepage%
 98  }%
 99  ]%

100 {%

101  \fancyplain{}%

102 {%

103  \bfseries\leftmark%

104 }% 105 }%

We want the subsection number on the right hand page: that’s an even number in this arrangement.

106 \lfoot[%
107  \fancyplain{}%

108 {% 109 }% 110 ]% 111 {%

112  \fancyplain{\tiny\revision}%

113 {%

114  \tiny\revision%

115 }% 116 }

We want the section number on the left hand page: that’s an odd-numbered page in this arrangement.

117 \rfoot[%
118  \fancyplain{}%

119 {%

120  \tiny\revision%

121 }% 122 ]% 123 {%

124  \fancyplain{}%

125 {% 126 }% 127 } 128 }%

129 \typeout{^^JUsing the leftopen option^^J}

130 }

2.3.2 Pass all other options unchanged to article.cls

131 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

2.4 Execution of options

SHOULD WE USE \ExecuteOption{..} instead or as well as this? If see classes.dtx. \ExecuteOptions provides defaults that can be overridden.

132 \ProcessOptions

2.5 Special class file commands

Do we pass the default options here? Or in \PassOptionsToClass?

133 \LoadClass[a5paper,twoside]{article}

2.6 Package loading

134 \RequirePackage{%
135 vmargin,%
136 fancyheadings,%
137 %array,%
138 nick,%
139 varioref,%
140 %ifthen,%
141 %verbatim,%
142 rcs,%
143 %slidesec,%
144 %fancybox,%
145 %version,%
146 %alltt%

147 }

148 %\PassOptionsToClass{twoside}{article}

Now here I’ve changed the page setup to be similar to that for my assembly language primer, except that the left and right margins are exchanged, since here the oddnumbered pages are on the left, while in a book, the odd-numbered pages are on the right.

This is what the documentation for the vmargin package has to say:

Two sided printing is supported, meaning that if on odd pages the left margin is, say, 30 mm and the right margin is 20 mm, it will be vice versa on even pages. This gives equal margins on the outer and the inner edge of the paper, as expected e.g. for a book.

Here we are making an A5 booklet, obtained by folding A4 paper in half:

149 \setpapersize{A5}%
150 \setmarginsrb{13mm}% left For a book, the inner.  For oddleft, outer.
151  {9mm}% top
152  {20mm}% right For a book, the outer.  For oddleft, inner.
153  {10mm}% bottom
154  {12pt}% headheight---increase to stop fancyhead warn
155  {4mm}%  headsep
156  {0pt}%  footheight
157  {8mm}% footskip

Later note: it seems that the 8mm footskip is not a problem with the new footers; still, will check after examining the output.

            {13mm}% footskip

\headwidth
158 \renewcommand{\headwidth}{\textwidth}%

Revision control This uses the RCS revision control system and the macros \RCSRevision and \RCSDate to create a footer on the left page of the booklet. The macros must be defined in the source file for the booklet. Using RCS seems the simplest way to automate tracking document revisions.

\revision
159 \newcommand{\revision}{ver \RCSRevision{}%
160  ,\hspace{0.8ex} \RCSDate%

161 }

All changes to \textwidth to happen before here (I can’t remember whether this commandment comes from the documentation for fancyheadings or elsewhere).

News flash! It seems that it is critical to put this before redefining the \sectionmark and \subsectionmark, otherwise the new definitions are ignored!

162 \pagestyle{fancyplain}

Hey: this seems to work! A simple adaptation from my assembly language primer page setup. Note that it is essential to put the \pagestyle first, otherwise these are ignored!

163 \renewcommand*{\sectionmark}[1]%
164  {\markboth{\thesection\ \  #1}{\thesection\ \  #1}}
165 \renewcommand*{\subsectionmark}[1]{\markright{\thesubsection\ \ #1}}

This is the format of the \lhead and \rhead commands, for reference.

 \lhead[\fancyplain{plain LH-even}{normal LH-even}]
       {\fancyplain{plain LH-odd }{normal LH-odd}}
 \rhead[\fancyplain{plain RH-even}{normal RH-even}]%
       {\fancyplain{plain RH-odd }{normal RH-odd}}

We want the subsection number on the right hand page: that’s an even number in this arrangement.

166 \lhead[%
167  \fancyplain{}%

168 {%

169  \rmfamily\bfseries \thepage%

170 }% 171 ]% 172 {%

173  \fancyplain{}%

174 {%

175  \bfseries\rightmark%

176 }% 177 }

178 \rhead[%
179  \fancyplain{}%

180 {%

181  \bfseries\leftmark%

182 }% 183 ]% 184 {%

185  \fancyplain{}%

186 {%

187  \rmfamily\bfseries \thepage%

188 }% 189 }%

We want the subsection number on the right hand page: that’s an even number in this arrangement.

190 \lfoot[%
191  \fancyplain{}%

192 {%

193  \tiny\revision%

194 }% 195 ]% 196 {%

197  \fancyplain{\tiny\revision}%

198 {% 199 }% 200 }

We want the section number on the left hand page: that’s an odd-numbered page in this arrangement.

201 \rfoot[%
202  \fancyplain{}%

203 {% 204 }% 205 ]% 206 {%

207  \fancyplain{}%

208 {%

209  \tiny\revision%

210 }% 211 }

212 \cfoot{}
213 \typeout{^^JMaking a BOOKLET^^J}

214 ⟨/class⟩

215 \endinput

Index

The italic numbers denote the pages where the corresponding entry is described, numbers underlined point to the definition, all others indicate the places where it is used.

Symbols

\, . . . . . . . . . . . . . . . 62 \\ . . . . . . . . . . . . . . . 27

\␣ . . . . . 80, 81, 164, 165

A

 \AtEndOfClass . . . . . . 52

\author . . . . . . . . . . . 29

B

\begin . . . . . . 31, 60, 67

 \bfseries . . . . . . . .

85, 91, 97, 103, 169, 175, 181, 187

C

\cfoot . . . . . . . . 14, 212

                           \CodelineIndex . . . . . 17
                           \CurrentOption . . . . 131

D \date . . . . . . . . . . . . . 30 oddleft . . . . . . . . . 2, 3

                           \DeclareOption . 50, 131

\def . . . . . . . . . . . . . 6–8

                           \DisableCrossrefs . . 16

\docdate . . . . . . . . . . . 8 \DocInput . . . . . . . . . 37

                           \documentclass . . . . . . 3

E

                           \EnableCrossrefs . . . 15

\end . . . . . . . . . . . 44, 65 \endinput . . . . . . . . 215

F

                                                     \fancyplain . . 83, 89,

95, 101, 107, 112, 118, 124, 167, 173, 179, 185, 191, 197, 202, 207

\file . . . . . . . . . . . . . 36

G

                                                     \GetFileInfo . . . . . . . . 5

H

                                                     \headwidth . . . . \underline{77}, \underline{158}

\hspace . . . . . . . . . . 160

L \LaTeXe . . . . . 11, 14, 26 \leftmark …. 103, 181 \Lenv . . . . . . . . . . . . . 34 \lfoot . . . . . . . 106, 190 \lhead . . . . . . 9, 82, 166

\LoadClass . . . . . . . 133

M

\maketitle . . . . . . . . 33

\markboth . . . . . 80, 164

\markright . . . . 81, 165

N

\newcommand . . . . . . . 159

O

\OnlyDescription . . . 24

P

\PageIndex . . . . . . . . 18
\pagestyle . . 9, 78, 162
\PassOptionsToClass

. . . . . . . . 131, 148 \pkg . . . . . . . . . . . 35, 59

\PrintChanges . . . . . . 39
\PrintIndex . . . . . . . . 38
\ProcessOptions . . . 132
\providecommand . 34–36
\ProvidesClass . . . . . 48
\ProvidesFile . . . . . . . 2

R

\RCSDate . . . . . . . . . 160

\RCSRevision . . . . . . 159
\RecordChanges . . . . . 23
\RequirePackage . . . 134
\revision . . . . . . . .

. 112, 114, 120, \underline{159}, 193, 197, 209

\rfoot . . . . . . . 117, 201 \rhead . . . . . . 12, 94, 178

\rightmark . . . . 85, 175

\rmfamily 91, 97, 169, 187

S

\sectionmark . . . 79, 163

                          \setmarginsrb . . 69, 150
                          \setpapersize . . 68, 149
                          \subsectionmark 81, 165

T \textsf . . . . . . . . . . . 34

                          \textwidth . . . . 77, 158

\thanks . . . . . . . . . . . 26 \thepage . . . . . . . 11,

12, 91, 97, 169, 187

                          \thesection . . . . 80, 164
                          \thesubsection . 81, 165
                          \thispagestyle . . . . . 32

\tiny . . . . . 112, 114,

120, 193, 197, 209 \title . . . . . . . . . . . . 25 \typeout 40–43, 129, 213

U \upshape . . . . . . . . 9, 12

                          \usepackage . . . . . . . . . 4

Change History

v1.1 General: First release . . . . . . . . . . . 1