Sunteți pe pagina 1din 26

The chletter Document Class


Boris Oriet
http://boris.oriet.net
September 17, 2010

Contents
1 Introduction 3

2 Example sources 3
2.1 A standard letter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 A customized letter . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Compatibility 8
3.1 Compatibility with the LATEX 2ε letter class . . . . . . . . . . . . . 8
3.2 Compatibility with other LATEX 2ε classes . . . . . . . . . . . . . . 8
3.3 Compatibility with older versions of chletter . . . . . . . . . . . . . 8
3.4 Compatibility with upcoming versions of chletter . . . . . . . . . . 8
3.5 Compatibility with other packages . . . . . . . . . . . . . . . . . . 8

4 Basic configuration 9
4.1 Class options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 Page layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.3 The letter environment . . . . . . . . . . . . . . . . . . . . . . . . 11
4.3.1 Letter layout commands . . . . . . . . . . . . . . . . . . . . 11
4.3.2 Page breaking control . . . . . . . . . . . . . . . . . . . . . 11
4.3.3 Letter counter . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.3.4 Letter markup commands . . . . . . . . . . . . . . . . . . . 12
4.3.5 Main letter commands . . . . . . . . . . . . . . . . . . . . . 12
4.3.6 Letter foot commands . . . . . . . . . . . . . . . . . . . . . 14
4.4 Sectioning commands . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.5 Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.6 Paragraph values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
∗ This document corresponds to chletter v2.0, dated 2010/10/10.

1
5 Implementation and advanced configuration 15
5.1 Initial code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.1.1 Declaring options . . . . . . . . . . . . . . . . . . . . . . . . 15
5.1.2 Executing options . . . . . . . . . . . . . . . . . . . . . . . 16
5.1.3 Loading packages . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2 Document layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2.1 Letter counter . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2.2 Letter dimensions . . . . . . . . . . . . . . . . . . . . . . . 16
5.2.3 Paragraphing . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2.4 Page layout . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.2.5 Title layout . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.2.6 Column separation . . . . . . . . . . . . . . . . . . . . . . . 18
5.2.7 Page styles . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3 Document markup . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3.1 Default matter . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3.2 Global declarations . . . . . . . . . . . . . . . . . . . . . . . 20
5.3.3 The letter environment . . . . . . . . . . . . . . . . . . . 21
5.3.4 Page breaking control . . . . . . . . . . . . . . . . . . . . . 22
5.3.5 The generic letter commands . . . . . . . . . . . . . . . . . 22
5.3.6 Sections and paragraphs . . . . . . . . . . . . . . . . . . . . 23
5.3.7 Environments . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.3.8 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.4 Setting the defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.4.1 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.4.2 Array, Tabular, Tabbing, Minipage, Equation . . . . . . . . 24
5.4.3 Framed boxes . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.4.4 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.4.5 Letter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.4.6 Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.4.7 Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.4.8 Page and numbering styles . . . . . . . . . . . . . . . . . . 26
5.5 Applying the class options . . . . . . . . . . . . . . . . . . . . . . . 26
5.5.1 Letterhead layout . . . . . . . . . . . . . . . . . . . . . . . . 26
5.5.2 Signature layout . . . . . . . . . . . . . . . . . . . . . . . . 26
5.5.3 Two column mode . . . . . . . . . . . . . . . . . . . . . . . 26
5.6 Later initializations . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

2
1 Introduction
The chletter class is suited for typesetting letters with letterhead corresponding to
the swiss norm SN 0101301 .

This class is mostly compatible with the standard LATEX 2ε classes. It is not limited
to letters and may be used as a generic document class.

Its basic usage is very simple and user friendly. It is appropriate to quickly typeset
casual documents and letters.

It is however highly configurable and may be used within complex setups to provide
automated letters composition.

The chletter code is very compact and highly optimized, droping the obsolete
legacy (namely LATEX 2.09) for the sake of efficiency.

2 Example sources
The following examples describe the normal usage of the chletter class. Basically,
the chletter class behaves much like the standard letter class. The letter below will
compile with both classes, although the output won’t be exactly the same.

2.1 A standard letter


\documentclass{chletter}
\name{My name}
\address{My address\\My city}
\begin{document}
\begin{letter}{Name\\Address\\City}
\opening{Salutation,}
This is a very plain and simple letter.
\closing{Valediction.}
\end{letter}
\end{document}

1 http://www.poste.ch/post-pm-briefe-schweiz.pdf

3
My name April 1st, 2010
My address
My city

Name
Address
City

Salutation,

This is a very plain and simple letter.


Valediction.

My name

Figure 1: Standard letter output by chletter.

4
2.2 A customized letter
This example provides a good overview of the different class options and macros.
This document won’t compile with the standard letter class.
\documentclass[leftwin,leftsig]{chletter}
\setlength\addressmargin{320pt}
\makemark
\makelabels
\location{My enterprise}
\name{My name}
\return{My name, My address, My city}
\address{My address\\My city}
\telephone{My phone\\My email}
\date{Here, \today}
\signature{My signature\\\footnotesize My position}
\begin{document}
\begin{letter}{Name\\Address\\City}
\textbf{\object{About the \textsf{chletter} document class}}
\opening{Dear \toname,}
The \texttt{leftwin} option selects a left windowed cover.\\
The \texttt{leftsig} option places the signature against the left margin.\\
\texttt{makemark} adds a fold mark for C6/5 covers.\\
\texttt{makelabels} adds page with only the return and recipient’s addresses.\\
The date field is customized, so is the signature.\\
A return address is specified.\\
The salutation contains the recipient’s name.
\closing{Yours truly,}
\encl{Enclosures}
\cc{Other recipients}
\ps{P. S.}{Post Scriptum}
\end{letter}
\end{document}

5
My enterprise
My name
My address
My city
My phone
My email
My name, My address, My city

Name
Address
City

Here, April 1st, 2010

About the chletter document class

Dear Name,
The leftwin option selects a left windowed cover.
The leftsig option places the signature against the left margin.
makemark adds a fold mark for C6/5 covers.
makelabels adds page with only the return and recipient’s addresses.
The date field is customized, so is the signature.
A return address is specified.
The salutation contains the recipient’s name.

Yours truly,

My signature
My position

encl Enclosures

cc Other recipients
P. S. Post Scriptum

Figure 2: Customized letter output by chletter.

6
My name, My address, My city

Name
Address
City

Figure 3: Cover page output by chletter.

7
3 Compatibility
The chletter class is based upon the standard classes of the LATEX 2ε distribution.
It is mostly compatible with any type of document founded on these classes.

3.1 Compatibility with the LATEX 2ε letter class


The chletter class is “source compatible” (ascending) with the standard letter class.
Usually a file which compiles with letter will recompile straight forward with chlet-
ter. There are however some functional differencies, which are described in the
following sections.

3.2 Compatibility with other LATEX 2ε classes


The chletter class is largely “source compatible” (ascending) with other standard
LATEX 2ε classes. It doesn’t implement the sectioning mecanism, but accepts the
related commands (\section for example). Some commands behave differently
(\maketitle for example). Obvsiously, any command specific to the chletter class
will prevent compilation with other classes.

3.3 Compatibility with older versions of chletter


The chletter class has been completely overhauled between these two versions.
The new code is far more compact and efficient, so is its usage (the commands
no more have a plethora of optional arguments). The versions of the class are
largely “source compatible,” given the deprecated commands are not used: \conc
(replaced by \object), \letterindent, \letterskip, \fromheight (replaced by
\titletopheight, \toheight (replaced by \titlemidheight) and \stockheight
(replaced by \titlebotheight). To add a “compilability” layer, the following
code can be inserted in the preamble:
\newcommand\conc[2]{\object{#2}}
\let\letterindent\parindent
\let\letterskip\parskip
\let\fromheight\titletopheight
\let\toheight\titlemidheight
\let\stockheight\titlebotheight

3.4 Compatibility with upcoming versions of chletter


The chletter class is now considered mature and won’t evolve further (the code is
frozen). The class has been thoroughly tested, and there is no known deficiencies.

3.5 Compatibility with other packages


The chletter class is generic in the sense that it doesn’t rely on anything but the
LATEX 2ε kernel. There is no known command clash with any package.

8
4 Basic configuration
The default values used by the chletter class are balanced for casual writing of
simple articles (the class can eventually replace the standard article class) and,
obviously, letters. Nevertheless this class is highly configurable and customizable.

4.1 Class options


The chletter class accepts the options provided by the LATEX 2ε default classes.
These options are: a4paper, a5paper, b5paper, letterpaper, legalpaper,
executivepaper, landscape, 10pt, 11pt, 12pt, oneside, twoside, draft, final,
leqno, fleqn, onecolumn, twocolumn. The defaults are: a4paper, 10pt, oneside,
final, onecolumn.

lefwin The chletter class provides two additionnal options to modify the layout of the
leftsig letters. leftwin places the recipient’s address to the left of the letterhead rather
than to the right (the latter is the default and the standard in Switzerland).
leftsig aligns the signature field with the left margin rather than with the right
address field.

4.2 Page layout


\textwidth The default page layout provided by the class leaves more place for the text than
\textheight the standard classes. The default values are:
\oddsidemargin
\textwidth \paperwidth-144pt
\evensidemargin
\textheight \paperheight-216pt
\oddsidemargin 36pt
\evensidemargin 0pt

The space between the left border of the page and the main text is therefore 108pt
(for a single sided document). The header and footer space are 36pt each; so the
default layout gives 108pt between the top of the page and the main text, and
equally 108pt between the main text and the bottom of the page.

\titletopheight These values are used within the letter environment for the layout of the letter-
\titlemidheight head. Please note that everything is related to the LATEX origin, which is 72pt,
\titlebotheight 72pt from the top left corner of the page. The \titlemargin and \titlewidth
\titlemargin values are independant from the \oddsidemargin and \evensidemargin values.
\titlewidth These values are visually presented on next page. The default values are set fol-
\addressmargin lowing the swiss standards for letterhead:
\titletopheight 72pt
\titlemidheight 72pt
\titlebotheight 72pt
\titlemargin 0pt
\titlewidth \paperwidth-144pt
\addressmargin 264pt

9
6
 titlewidth - 72pt
 72pt - addressmargin -
?
fromname date 6
fromaddress
titletopheight

?
toname 6
toaddress
titlemidheight

?
6
titlebotheight

?
salutation

text

valediction

signature

 longindentation - indentedwidth -

 textwidth -

Figure 4: The default chletter layout.

10
4.3 The letter environment
The letter environment performs some special actions in the scope of writing let-
ters. At its beginning, it generates the letterhead taking in account its arguments
ans some previously defined values (see below). The letter environment takes
in account some global options, for example twocolumn... so yes, it is possible
to write two column letters! At its closing, the letter environment generates a
cover page if needed (see below).

letter The letter environment takes one mandatory argument : the recipient’s address.
The address should be formatted with newline markers (\\) as in the standard
letter class. The argument is “tokenized” in \toname and \toaddress, which
can be used in the letter body. The “token separator” is the first encountered \\ .

There is an optional argument to specify if the letter is to be indented [i] or not


[n] where [n] is the default. Please note that this option will alter the formatting
of general LATEX lists and chletter \ps, \cc and \encl commands (see next page).

It is possible to open multiple letter environments within a single document.


Some global values may be shared between each letter (see next page).

A standard usage is:


\begin{letter}[i]{Toname\\ToAddressFirstLine\\...\\ToAddressLastLine}
...
\end{letter}

4.3.1 Letter layout commands


These commands alter the appearance of the letterhead and are usually put in the
preamble, eventually between multiple letter environments.

\makelabels Unlike the standard letter class, this macro doesn’t involve a complex mecanism
using the .aux file to build a labels page (the main reason why the standard class
is fragile). Anyway, the chletter class provides a mean to generate dedicated cover
pages. The \makelabels command will set a flag which is checked at the closing
of the letter environment. The default behaviour is to put the recipient’s address
and, as requested by the swiss post, the return address above it, separated by a
line. \makelabels doesn’t take any argument.

\makemark This macro will add a thin line at the left side of the page to help folding a C6/5
letter. \makemark doesn’t take any argument.

4.3.2 Page breaking control


These commands are intented to (try to) control the place where a page break
occur. They may be used anywhere in a document.

\stopbreaks \stopbreaks will try to prevent all page breaks after its invocation.

\startbreaks \startbreaks cancels the behaviour of \stopbreaks.

11
4.3.3 Letter counter
\theletter At each new letter environment opened, this counter is incremented.

4.3.4 Letter markup commands


The commands described here are mainly used in the preamble (but they may be
used anywhere in the document) to fill some values which are to be used to build
the letterhead and some special fields. They are commonly used in letter classes.
\name The values stored by these commands are respectively: \fromname, \fromaddress,
\address \fromlocation, \telephonenum, and \returnaddress. These values are used to
\location build the expeditor’s address fields:
\telephone \name{My Name}
\return \address{My Street\\My City}
\return{My Return Address}

\date The date field (stored in the standard \@date) could be set up by, for example:
\today \date{Here, \today}

\signature The value stored by this macro is \fromsig, which is used by the \closing com-
mand to output the signature field (see below).

Please note that \fromname and \fromsig values default to \@author (initialized
by LATEX, modified by the standard \author command). The \@date field defaults
to \today, which will be localized by a linguistic package (babel or polyglossia).

To prevent any value from appearing, it has to be emptied by the corresponding


command, for example: \date{}.

These macros can contain anything that fits in a \parbox, including some special
stuff (using dedicated packages): \location{\includegraphics{mylogo.pdf}}

Any of the values stored by these commands can be retrieved anywhere in the
letter: I, \fromname, declare...

4.3.5 Main letter commands


These commands are usually used within a letter environment, but they may be
used at document level for special purpose. They are mainly formatting com-
mands, although they usually store their value for later use.

\object This command will simply output the text given in its argument. The \object
command stores its argument in \@title and actually outputs it. If the argument
is empty, the \object command will output the value of \@title previously set
by a \title command:
\title{Answer to your previous letter}
...
\begin{document}
\begin{letter}{...}
\object{}

12
Please note that the following code is functionally equivalent (the \@title value
set by both methods is global (available outside of the current letter environment):
\begin{document}
\begin{letter}{...}
\object{Answer to your previous letter}

\opening This command outputs the text given in its argument (adding some vertical space
after it):
\opening{Dear Sir,}

It stores its argument in \salutation for further use. \salutation can also
be defined before and be output by an invocation of \opening with an empty
argument:
\renewcommand{\salutation}{Dear Sir,}
...
\begin{document}
\begin{letter}{...}
\opening{}

\closing This command outputs the text given in its argument (adding some vertical space
around it) and generates the signature field:
\closing{Yours sincerely,}

The signature field placement can be altered by previous invocation of leftsig


as a class option. The signature field will contain the value defined by:
• \fromsig (set by \signature{...}) in the first place;

• \fromname (set by \name{...}) if no \signature given;


• \@author (set by \author{...}) if no \name given (eventually empty).

This macro stores its argument in \valediction for later use. \valediction can
also be defined before and be output by an invocation of \closing with an empty
argument:
\renewcommand{\valediction}{Yours sincerely,}
\begin{document}
\begin{letter}{...}
...
\closing{}

Be aware of the locality of macros. \salutation and \valediction values are


local to the current letter environment if defined within the environment (usually
by \opening and \closing commands), global otherwise. Please look at the LATEX
documentation for further explanations.

13
4.3.6 Letter foot commands
Some formatting commands are intented to be used at the end of the letter (al-
though they can be used anywhere in the document, even outside of a letter
environment—just as any formatting command provided by the chletter class).

\ps This command is generic in the sense that it is nothing but a shortcut for a LATEX
list. It takes two mandatory arguments. The text contained in the arguments is
output as an indented paragraph. The indentation margin is set by the standard
LATEX \leftmargin value (which defaults to 18pt at document level, 0pt after
the \closing of a default letter and 36pt after the \closing of an indented [i]
letter). Here is an example use:
\ps{P.S.}{This is a post scriptum}

\encl This command is a shortcut for \ps{\enclname}{...} and takes one mandatory
argument. Regular use is:
\encl{1. Your previous letter\\2. My Curriculum Vit\ae}

\cc This command is a shortcut for \ps{\ccname}{...} and takes one mandatory
argument. Regular use is:
\cc{1. First other recipient\\2. Second other recipient}

\enclname and \ccname are set to {encl}, respectively {cc} by default. They
will be adjusted by a linguistic package (babel or polyglossia).

4.4 Sectioning commands


section The class is intented to write short documents (mainly letters!), so the sectioning
subsection mecanism is minimalist (no automatic table of contents generation). The stock sec-
subsubsection tioning commands are here: section, subsection, subsubsection, paragraph,
paragraph subparagraph, but are merely formating commands which select some text style
subparagraph and vertical space. As usual, these commands take one mandatory argument.

4.5 Environments
description These environments are available and behave as ordinary in the chletter class.
verse The default list values (at document level) are:\labelsep6pt, \labelwidth12pt,
quotation \leftmargin18pt. Please note that \labelwidth and \labelsep are redefined by
quote a \closing command to: \leftmargin2\parindent, \labelwidth3\labelwidth.

4.6 Paragraph values


\parindent \parindent and \parskip respectively default to 18pt and 9pt at document level.
\parskip If a letter environment is called with the default [n] option, \parindent is kept
at its previous value. With the [i] option, \parindent is locally set to 0 (zero).
Please note that the value of \parindent after a \closing command will alter
the layout of LATEX lists (in fact \ps, \encl and \cc are lists).

14
5 Implementation and advanced configuration
Appart from the options described until now, it is possible (and allowed!) to
“hook” into certain pieces of the class code. This enables a degree of customization
and extensibility. It would be quite straightforward to add, for example, mail
merging features through a dedicated package. While describing the class code,
we will discuss some of the interesting “hook eye” the chletter class provides to
the advanced user.

The code is structured in the very same manner as the LATEX 2ε standard document
classes. See classes.dtx and letter.dtx for further information.

5.1 Initial code


The chletter class is LATEX 2ε only. Anyway, who uses 2.09 nowadays?
1 \NeedsTeXFormat{LaTeX2e}
2 \ProvidesClass{chletter}[2010/04/01 v2.0 Swiss Letter document class]

5.1.1 Declaring options


There are only two specific options: leftwin and leftsig, according to the general
format of the letter (left or right cover window, left or right signature). All other
options are borrowed from the standard document classes (dropping the specifics).
3 ⟨∗chletter⟩
4 \DeclareOption{a4paper}{\paperheight297mm\paperwidth210mm}
5 \DeclareOption{a5paper}{\paperheight210mm\paperwidth148mm}
6 \DeclareOption{b5paper}{\paperheight250mm\paperwidth176mm}
7 \DeclareOption{letterpaper}{\paperheight11in\paperwidth8.5in}
8 \DeclareOption{legalpaper}{\paperheight14in\paperwidth8.5in}
9 \DeclareOption{executivepaper}{\paperheight10.5in\paperwidth7.25in}
10 \DeclareOption{landscape}
11 {\@tempdima\paperheight
12 \paperheight\paperwidth
13 \paperwidth\@tempdima}
14 \DeclareOption{10pt}{\def\@ptsize{0}}
15 \DeclareOption{11pt}{\def\@ptsize{1}}
16 \DeclareOption{12pt}{\def\@ptsize{2}}
17 \DeclareOption{oneside}{\@twosidefalse\@mparswitchfalse}
18 \DeclareOption{twoside}{\@twosidetrue\@mparswitchtrue}
19 \DeclareOption{draft}{\overfullrule5\p@}
20 \DeclareOption{final}{\overfullrule0\p@}
21 \DeclareOption{leqno}{\input{leqno.clo}}
22 \DeclareOption{fleqn}{\input{fleqn.clo}}
23 \DeclareOption{onecolumn}{\@twocolumnfalse\@leftsigfalse}
24 \DeclareOption{twocolumn}{\@twocolumntrue\@leftsigtrue}
25 \DeclareOption{leftwin}{\@leftwintrue}
26 \DeclareOption{leftsig}{\@leftsigtrue}

We define the booleans associated with the new options.


27 \newif\if@leftwin
28 \newif\if@leftsig

15
5.1.2 Executing options
Swiss letters are written on A4 paper. Default font size is 10pt, like in other
standard classes. Other switches are set at kernel’s level.
29 \ExecuteOptions{a4paper,10pt}
30 \ProcessOptions
Loading this .clo file leads to a lot of redundancy. But we want compatibility.
31 \input{size1\@ptsize.clo}

5.1.3 Loading packages


The chletter class does not load additional packages.

5.2 Document layout


This class tries to provide quite a universal layout, not only suitable for letters,
but also for other types of short documents. There are anyway some values specific
to letters (especially the letterhead).

5.2.1 Letter counter


Each time a letter is created (through the letter environment), this counter is
incremented.
32 \newcounter{letter}

5.2.2 Letter dimensions


All these dimensions are related to the letterhead. The title matter is vertically
divided in three strips, each one with its own height.
33 \newdimen\titlehead
34 \newdimen\titletopheight
35 \newdimen\titlemidheight
36 \newdimen\titlebotheight

37 \newdimen\titlemargin
38 \newdimen\titlewidth
39 \newdimen\addressmargin
40 \newdimen\addresswidth
41 \newdimen\longindentation
42 \newdimen\indentedwidth

5.2.3 Paragraphing
We prefer inter paragraph skips in a letter. Swiss letters are rarely indented but
the letter environement offers an option to do so. Thus indentation is enabled
at the document level.
43 \normallineskip\z@
44 \parskip9\p@
45 \parindent18\p@

16
5.2.4 Page layout
All margin dimensions are measured from a point one inch (actually 72pt and not
72bp) from the top and lefthand side of the page.
We assume nothing fancy in the header and footer. So 12pt (more or less one
line) are reserved, with 24pt spacing before, respectively after, the main text.
46 \headheight12\p@
47 \headsep24\p@
48 \footskip36\p@
We remove 1in (72pt) at each side, plus 36pt horizontally (corresponding to the
additional margin, see below) and 72pt vertically (corresponding to the header
and footer, see above).
49 \textwidth\paperwidth
50 \advance\textwidth-180\p@
51 \textheight\paperheight
52 \advance\textheight-216\p@
The leftside margin of the odd pages is set to 108pt (more or less 4cm). Sizes of
the marginal notes are adapted to quite small margins. Top margin (which also
alters the title position) is set to zero.
53 \oddsidemargin36\p@
54 \evensidemargin\z@
55 \marginparwidth48\p@
56 \marginparsep6\p@
57 \marginparpush6\p@

58 \topmargin\z@
The footnotes values are somewhat larger than the default. They are adapted to
the kind of document this class is intented for.
59 \footnotesep12\p@
60 \skip\footins12\p@

5.2.5 Title layout


What we call ‘title’ here is the letterhead, with the addresses fields and all this
kind of stuff. Title is always placed on an odd page and always at a precisely
specified position.

\titlehead The vertical position of the title is controled by the \titlehead value (by analogy
with \headheight which sets the first baseline of the running head) and the space
between the title and the main text by \titlebotheight (see below).
61 \titlehead12\p@

\titlewidth The title (letterhead or cover) field is divided into three strips, each one containing
\titletopheight some material. For example, the first field could contain the sender’s address, the
\titlemidheight second one the recipient’s address and the third one the letter’s date. The default
\titlebotheight values are tuned for swiss windowed envelopes.

17
62 \titlewidth\paperwidth
63 \advance\titlewidth-144\p@
64 \titletopheight72\p@
65 \titlemidheight72\p@
66 \titlebotheight72\p@

\titlemargin Please note that \addressmargin is relative to \titlemargin, the latter set to
\addressmargin zero, so the title is placed at 1in (72pt) from the lefthand side of the page.
67 \titlemargin0\p@
68 \addressmargin264\p@

5.2.6 Column separation


\columnsep This is tricky! The idea is to align the columns with the letterhead fields. In a
default letter, the second column will align with the recipient’s address and the
date. For A4 paper and default chletter margins, \columnsep is around 38pt.
69 \columnsep2\addressmargin
70 \advance\columnsep-2\oddsidemargin
71 \advance\columnsep-\textwidth

5.2.7 Page styles


The default page styles are here, but their layout differ from the standard classes.
72\def\ps@plain%
73{\let\@oddhead\@empty
74 \let\@evenhead\@empty
75 \def\@oddfoot{\footnotesize\hfil\pagename~\thepage}
76 \def\@evenfoot{\footnotesize\pagename~\thepage\hfil}}

77\def\ps@firstpage%
78{\let\@oddhead\@empty
79 \let\@evenhead\@empty
80 \def\@oddfoot{\footnotesize\leftmark\hfil\rightmark}
81 \def\@evenfoot{\footnotesize\rightmark\hfil\leftmark}}

82\def\ps@headings%
83{\def\@oddhead{\footnotesize\headtoname~\toname\hfil\pagename~\thepage}
84 \def\@evenhead{\footnotesize\pagename~\thepage\hfil}
85 \def\@oddfoot{\footnotesize\leftmark\hfil\rightmark}
86 \def\@evenfoot{\footnotesize\rightmark\hfil\leftmark}}

87\def\ps@myheadings%
88{\def\@oddhead{\footnotesize\leftmark\hfil\rightmark}
89 \def\@evenhead{\footnotesize\rightmark\hfil\leftmark}
90 \def\@oddfoot{\footnotesize\hfil\pagename~\thepage}
91 \def\@evenfoot{\footnotesize\pagename~\thepage\hfil}}

5.3 Document markup


5.3.1 Default matter
The following pieces of code are very interesting for those who want to completely
customize the letter appearance. Basically, the following macros contain definition
of some matter which is to be put in the letterhead or signature field.

18
\leftwin The default layout of the letterhead is defined here, according to the class option
\rightwin leftwin which calls either \rightwin (not set, default) or \leftwin (when set).
\titletopmatter, \titlemidmatter and \titlebotmatter are three horizontal
strips which may contain anything that fits in a \parbox.
\splitfield{...}{...} is used to cut these strips into two columns, the second
one placed at \addressmargin from the lefthand side of the letterhead. So we
would be able to define a \titletopmatter{\splitfield{...}{...}} which is
the case here. See below for further explanations.
92 \def\leftwin
93 {\def\titletopmatter%
94 {\splitfield
95 {}
96 {\fromlocation\par
97 \fromname\par
98 \fromaddress\par
99 \telephonenum}}
100 \def\titlemidmatter%
101 {\returnaddress\par
102 \toname\par
103 \toaddress}
104 \def\titlebotmatter%
105 {\splitfield{}{\@date}}}

106 \def\rightwin
107 {\def\titletopmatter%
108 {\splitfield
109 {\fromlocation\par
110 \fromname\par
111 \fromaddress\par
112 \telephonenum}
113 {\@date}}
114 \def\titlemidmatter%
115 {\splitfield
116 {}
117 {\returnaddress\par
118 \toname\par
119 \toaddress}}
120 \def\titlebotmatter%
121 {}}

\leftsig These macros are called by the corresponding class option. They define the
\rightsig \closingmatter which is output by the \closing command. \closingmatter
can contain any piece of text or code. Please note that some list values are altered
here (\leftmargin and \labelwidth). See below for further explanations.
122 \def\leftsig
123 {\def\closingmatter%
124 {\leftmargin2\parindent
125 \vskip4\bigskipamount
126 \ps{}{\fromsig}
127 \vskip\bigskipamount
128 \labelwidth3\labelwidth
129 \advance\labelwidth-\labelsep}}

19
130 \def\rightsig
131 {\def\closingmatter%
132 {\leftmargin\longindentation
133 \vskip4\bigskipamount
134 \ps{}{\fromsig}
135 \vskip\bigskipamount
136 \leftmargin2\parindent
137 \labelwidth3\labelwidth
138 \advance\labelwidth-\labelsep}}
Please note the crafty use of the \ps command. \leftmargin and \labelwidth
values are changed after the \closing command (which calls the \closingmatter
defined here).

5.3.2 Global declarations


\name These macros are defined in the same way as the standard letter class. The layout
\signature of \telephonenum (small text) and \returnaddress (underlined small text) are
\address specific to this class. Please note that the default contents of these fields will be
\location defined later.
\telephone 139 \long\def\name#1{\def\fromname{#1}}
\return 140 \long\def\signature#1{\def\fromsig{#1}}
141 \long\def\location#1{\def\fromlocation{#1}}
142 \long\def\address#1{\def\fromaddress{#1}}
143 \long\def\telephone#1{\def\telephonenum{\vtop{\footnotesize#1}}}
144 \long\def\return#1{\def\returnaddress{\underbar{\textsuperscript{#1}}}}

\splitfield The letterhead is divided in three vertically stacked strips of \titlewidth width.
The purpose of this command is to divide a strip in two columns, the first one
of \addressmargin width, the second one of \addresswidth width, the latter
value being computed on the fly. These columns are parboxes. The letterhead
may contain text or graphics (a logo for example), so we have to cope with the
relative vertical placement of text and imported pictures (see \includegraphics
command from the dedicated packages), hence the specifics (\hbox and \strut) in
the definitions of the parboxes. The \splitfield command takes two arguments,
which can be anything that fits in a parbox.
145\long\def\splitfield#1#2%
146{\addresswidth\titlewidth\advance\addresswidth-\addressmargin
147 \parbox[b][\baselineskip][t]{\addressmargin}{\hb@xt@\z@{}{#1}\strut}%
148 \parbox[b][\baselineskip][t]{\addresswidth}{\hb@xt@\z@{}{#2}\strut}}

\makemark The \makemark command alters the \titlerule macro, which causes a line to
\titlerule be added between the letterhead and the main text. The default \titlerule is
defined later.
149 \def\makemark{\def\titlerule%
150 {\hrule\@width6\fboxsep\@height\fboxrule}}

\makelabels The \makelabels command defines a \startlabels macro, which causes cover
\startlabels pages to be added at the end of each letter. This acts as a boolean flag, true if
\@empty or containig some code, false if \@null. If \startlabels is defined, it
has to contain the layout of the cover (see \maketitle below).
151 \def\makelabels{\def\startlabels%
152 {\let\titletopmatter\@empty\let\titlebotmatter\@empty\let\titlerule\@empty}}

20
\maketitle These commands actually output the letterhead stuff (\maketitle is the user level
\@maketitle command, \@maketitle contains the internals). \maketitle is always called at
the opening of the letter envrionment, and at its closing if the \startlabels
flag is not \@null. It doesn’t take any argument, but outputs the content of
\titletopmatter, \titlemidmatter, \titlebotmatter in three horizontal strips
stacked vertically. These strips have respective heights of \titletopheight,
\titlemidheight, \titlebotheight and are always placed on a new odd page at
an absolute position given by \titlehead and \titlemargin. The width of the
strips is given by \titlewidth. A \titlerule is added at the end of the letter-
head. Some dedicated mecanism cope with the \twoside and \twocolumns cases
(the letterhead is always issued on a new odd page). Please note that \maketitle
can be used outside of a letter environment, exactly like in the standard classes.
153 \def\maketitle%
154 {\clearpage
155 \if@twoside\ifodd\c@page\else\thispagestyle{empty}\hb@xt@\z@{}\clearpage\fi\fi
156 \if@twocolumn\twocolumn[\@maketitle\leavevmode\vskip-\topskip]
157 \else\vbox{\@parboxrestore\@maketitle}\vskip-\parskip\fi}
158 \def\@maketitle%
159 {\vskip-\topmargin\vskip\titlehead\vskip-\headheight\vskip-\headsep\vskip-\baselineskip
160 \leftskip\titleleftmargin\advance\leftskip-\oddsidemargin
161 \rightskip\textwidth\advance\rightskip-\paperwidth\advance\rightskip-\titlemargin
162 \parbox[t][\titlemidheight]{\titlewidth}{\hb@xt@\z@{}\titletopmatter\strut}\par
163 \parbox[t][\titlemidheight]{\titlewidth}{\hb@xt@\z@{}\titlemidmatter\strut}\par
164 \parbox[t][\titlebotheight]{\titlewidth}{\hb@xt@\z@{}\titlebotmatter\strut}\par
165 \leftskip-\oddsidemargin\advance\leftskip-72\p@
166 \parbox[b][\z@]{\paperwidth}{\titlerule}\par}

5.3.3 The letter environment


letter The letter environment is the central part of the chletter class. Being an environ-
ment, it involves some locality (see LATEX 2ε kernel documentation); for example a
\parindent value defined within the environment won’t alter the document level
value. \parindent is set in the environment by the [i] (default is [n]) option.
At its opening, the letter environment splits its mandatory argument in two
fields, \toname and \toaddress. If the argument is empty (\begin{letter}{}),
the \toname and \toaddress values won’t be modified and thus may be defined
before the opening of the environment, hence the easy mail merging extension. The
\pagestyle of the first letter page is set to firstpage and the letter counter is
incremented, while the page and footnote counters are reset.
167 \newenvironment{letter}[2][n]%
168 {\ifx#1n\parindent\z@\fi
169 \ifx\@null#2\else\@processto#2\\@@@
170 \ifx\@empty\toaddress\else\@processto#2@@@\fi\fi
171 \maketitle\thispagestyle{firstpage}
172 \setcounter{page}\@ne\setcounter{footnote}\z@\stepcounter{letter}}

At its closing, the letter environment checks for the definition of \startlabels.
If undefined, nothing but a \clearpage happens. If defined, its contents is
executed (usually a redefinition of \titletopmatter, \titlemidmatter and
\titlebotmatter) and the \maketitle macro is called, issuing a new page (in-
tented to be a cover) followed by a \clearpage.

21
173 {\@ifundefined{startlabels}{}{\startlabels\maketitle\thispagestyle{empty}}
174 \clearpage}

\@processto This is an auxiliary macro to cut the letter environment’s argument into two
substrings (tokenizer). The token separator is \\ . \toname will contain everything
until the first occurrence of \\ , and \toaddress the remainder of the string.
175 \long\def\@processto#1\\#2@@@{\def\toname{#1}\def\toaddress{#2}}

5.3.4 Page breaking control


\stopbreaks When the command \stopbreaks is issued no page breaks should occur until
\startbreaks \startbreaks is called. These macros are used by the \closing command to
prevent any break in the middle of the signature field.
176 \def\stopbreaks{\interlinepenalty\@M\def\par{\@@par\nobreak}}
177 \def\startbreaks{\interlinepenalty100\def\par{\@@par}}

5.3.5 The generic letter commands


\opening Unlike the standard letter class, the \opening command doesn’t generate the
\salutation letterhead (this is done at the opening of the letter environment, seems more
logical). The content of \salutation is either filled with the mandatory argument
or recalled if the argument is empty (\opening{}), then output.
178\long\def\opening#1%
179{\ifx\@null#1\else\long\def\salutation{#1}\fi
180 \par\salutation\par\medskip}

\closing \closing works as \opening with the \valediction value. Page breaking is
\valediction prevented and \closingmatter (usually defined by \leftsig or \rightsig) is
added. \closingmatter should contain the signature field and may be completely
customized (for example to include some handwritten signature as a picture).
181\long\def\closing#1%
182{\ifx\@null#1\else\long\def\valediction{#1}\fi
183 \par\medskip\stopbreaks\valediction
184 \samepage\par\closingmatter\par\startbreaks}

\object The \object macro outputs the content of \@title, either previously defined by
a \title command or locally filled by a non empty argument (see \opening and
\closing commands for an explanation of this behaviour).
185 \long\def\object#1%
186 {\ifx\@null#1\else\title{#1}\fi\noindent\@title\par\bigskip}

\ps \ps is a shortcut for a simple LATEX list, with its first argument as the list topic
\cc and its second argument as a list item. \cc and \encl are further shortcuts,
\encl using respectively \ccname and \enclname as the list topic. There is a formatting
trick involved here: the list (\ps, \cc and \encl are actually lists!) behaviour is
altered after a \closing command (see definition of \closingmatter). This is
intentionally done to keep list default values within the letter body, while greatly
simplifying the definition and function of these three macros.
187 \long\def\ps#1#2{\begin{list}{}{}\item[#1]#2\end{list}}
188 \long\def\cc#1{\ps{\ccname}{#1}}
189 \long\def\encl#1{\ps{\enclname}{#1}}

22
5.3.6 Sections and paragraphs
\subparagraph The sectioning commands are defined, but they are merely formatting com-
\paragraph mands. So no section numbering nor table of contents generation. Anyway, the
\subsubsection \tableofcontents macro is not defined in this class!
\subsection 190 \long\def\subparagraph#1{\par\textbf{#1}\hskip\labelsep}
\section 191 \long\def\paragraph#1{\par\noindent\textbf{#1}\hskip\labelsep}
192 \long\def\subsubsection#1{\par\noindent\textbf{#1}\par\nobreak}
193 \long\def\subsection#1{\smallskip\subsubsection{#1}}
194 \long\def\section#1{\medskip\subsubsection{#1}}

5.3.7 Environments
This code is borrowed from the standard classes. Please look at the LATEX 2ε
documentation for further explanation.
195 \newenvironment{description}
196 {\list{}
197 {\labelwidth\z@
198 \itemindent-\leftmargin
199 \let\makelabel\descriptionlabel}}{\endlist}
200 \def\descriptionlabel#1{\hskip\labelsep\textbf{#1}}
201 \newenvironment{verse}
202 {\let\\\@centercr
203 \list{}
204 {\itemsep\z@
205 \itemindent-\parindent
206 \listparindent\itemindent
207 \rightmargin\leftmargin
208 \advance\leftmargin\parindent}
209 \item\relax}{\endlist}

210 \newenvironment{quotation}
211 {\list{}
212 {\listparindent\parindent
213 \itemindent\listparindent
214 \rightmargin\leftmargin}
215 \item\relax}{\endlist}

216\newenvironment{quote}
217{\list{}
218 {\rightmargin\leftmargin}
219 \item\relax}{\endlist}

5.3.8 Lists
This code is borrowed from the standard classes. Please look at the LATEX 2ε
documentation for further explanation.
220 \def\@listI{}
221 \let\@listi\@listI
222 \let\@listii\@listI
223 \let\@listiii\@listI
224 \let\@listiv\@listI

23
225 \def\theenumi{\@arabic\c@enumi}
226 \def\theenumii{\@alph\c@enumii}
227 \def\theenumiii{\@roman\c@enumiii}
228 \def\theenumiv{\@Alph\c@enumiv}

229 \def\labelenumi{\theenumi.}
230 \def\labelenumii{(\theenumii)}
231 \def\labelenumiii{\theenumiii.}
232 \def\labelenumiv{\theenumiv.}

233 \def\p@enumii{\theenumi}
234 \def\p@enumiii{\theenumi(\theenumii)}
235 \def\p@enumiv{\p@enumiii\theenumiii}

236 \def\labelitemi{\textbullet}
237 \def\labelitemii{\textbf{\textendash}}
238 \def\labelitemiii{\textasteriskcentered}
239 \def\labelitemiv{\textperiodcentered}

5.4 Setting the defaults


As in other classes, some values are set here rather than at kernel’s level. The
values used by the chletter class are as generic as possible.

5.4.1 Lists
\labelsep These default values are defined at document level and altered by \closingmatter
\labelwith (see above) in the following manner: \labelwidth3\labelsep (usually 18pt),
\leftmargin \leftmargin2\parindent (36pt in an indented letter, 0pt in a default letter).
240 \labelsep6\p@
241 \labelwidth12\p@
242 \leftmargin18\p@

5.4.2 Array, Tabular, Tabbing, Minipage, Equation


Exactly as in the standard classes.
243 \arraycolsep5\p@
244 \tabcolsep6\p@
245 \arrayrulewidth.4\p@
246 \doublerulesep2\p@
247 \tabbingsep\labelsep
248 \skip\@mpfootins=\skip\footins
249 \def\theequation{\@arabic\c@equation}

5.4.3 Framed boxes


\fboxsep Apart from their ordinary application, the values defined here are used by the
\fboxrule default \titlerule macro called by the \makemark declaration.
250 \fboxsep3\p@
251 \fboxrule.4\p@

5.4.4 Footnotes
Light is right! This definition is minimalist.
252 \long\def\@makefntext#1{\noindent\hb@xt@\z@{\hss\@makefnmark}#1}

24
5.4.5 Letter
Some specific chletter values are initialized here.

\titlerule The default is to output no rule. \titlerule is always called by \maketitle (see
above) and so has to be defined.
253 \let\titlerule\@empty

\fromname \fromname is not empty by default, so is \fromsig: they contain the \@author
\fromsig value, which is defined at kernel level to output nothing but a warning message (no
\fromaddress author given). \fromlocation and \fromaddress are somewhat redundant, but
\fromlocation they may be used for special purpose. \@author may be modified by the LATEX
\telephonenum \author command. \returnaddress should also output nothing by default, but
\returnaddress it has to leave an empty line, hence the \null trick (actually an empty \hbox).
254 \def\fromname{\@author}
255 \def\fromsig{\@author}
256 \let\fromlocation\@empty
257 \let\fromaddress\@empty
258 \let\telephonenum\@empty
259 \def\returnaddress{\null}

\toname These values retrieved or altered at the opening of a letter environment. They
\toaddress are initialized here to prevent an error in certain condition.
260 \let\toname\@empty
261 \let\toaddress\@empty

\salutation These values are retrieved or altered respectively by the \opening and \closing
\valediction commands. They are initialized here to prevent an error in certain condition.
262 \let\salutation\@empty
263 \let\valediction\@empty

5.4.6 Words
\ccname These words are common to the standard letter classes. They will be adjusted by
\enclname the linguistic packages (babel or polyglossia). \ccname and \enclname are used
\pagename respectively by the \cc and \encl macros; while \pagename and \headtoname are
\headtoname used within \pagestyle layouts and some additional packages.
264 \def\ccname{cc}
265 \def\enclname{encl}
266 \def\pagename{Page}
267 \def\headtoname{To}

5.4.7 Date
\today The \@date field, which appears in the letterhead, defaults to \today. The \today
value will be adjusted by the linguistic packages (babel or polyglossia).
268\def\today
269{\ifcase\month\or
270 January\or February\or March\or April\or May\or June\or
271 July\or August\or September\or October\or November\or December\fi
272 \space\number\day, \number\year}

25
5.4.8 Page and numbering styles
We have \pstyle{plain} pages in this document class by default. We use arabic
page numbers.
273 \pagestyle{plain}
274 \pagenumbering{arabic}

5.5 Applying the class options


The following code depends on some class options. It is executed at the end of
the class because it relies on macros defined at class level.

5.5.1 Letterhead layout


\@leftwin Conditionnaly calling the related macros \leftwin or \rightwin will initial-
ize the letterhead layout (by defining \titletopmatter, \titlemidmatter and
\titlebotmatter).
275 \if@leftwin\leftwin\else\rightwin\fi

5.5.2 Signature layout


\@leftsig Conditionnaly calling the related macros \leftsig or \rightsig will initialize
the signature layout (by defining \closingmatter).
276 \if@leftsig\leftsig\else\rightsig\fi

5.5.3 Two column mode


\@twocolumn The column separator (\columnsep) is initialized earlier in the class code (see
above). Please note that in one column mode we reverse the position of the
margin paragraphs.
277 \if@twocolumn\twocolumn\sloppy\else\onecolumn\reversemarginpar\fi}

5.6 Later initializations


We want the following values depend on the general layout of the document
(\textwidth, \oddsidemargin and \addressmargin), which may be eventually
adjusted in the preamble. Hence the late initialization.
278 \AtBeginDocument

\longindentation \longindentation is here for user convenience and for compatibility with the
standard letter class. It is defined as the length between the document margin
(\oddsidemargin) and the recipient’s address field (\addressmargin).
279 {\longindentation\addressmargin
280 \advance\longindentation-\oddsidemargin

\indentedwidth \indentedwith is here for user convenience and for compatibility with the stan-
dard letter class. It is defined as the length between the recipient’s address field
(\addressmargin) and the right document margin (defined by \textwidth).
281 \indentedwidth\textwidth
282 \advance\indentedwidth-\longindentation}
283 ⟨/chletter⟩

26

S-ar putea să vă placă și