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 Options available . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

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

2.3.1 The oddleft option . . . . . . . . . . . . . . . . . . . . . . . 3 2.3.2 Allow other classes to be base classes . . . . . . . . . . . . . . 5 2.3.3 Pass all other options unchanged to .cls . . . . . . . . . . . 5

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

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 Options available

1.2

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ε.

∗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 ⟨∗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

There are no options for this class yet.

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-mumbered 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-numebred 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[%