3.1 ⁎Writing a Letter Using the letter Class
This section describes how to use the basic letter class. As
with all the base LaTeX classes, the paper size defaults to the US
letter size, but this can be changed via the class options. For
example, for A4 paper you can use the a4paper
option:
\documentclass[a4paper]{letter}
or you can use the geometry package [110]:
\documentclass{letter} \usepackage[a4paper]{geometry}
A document using the letter class may have one or more
letter
environments that contain the text of the letter:
Within ⟨body⟩, you can use:
for the letter greeting, and
for the closing text (such as “Yours Sincerely”). After
\closing
you can also use:
for any postscripts (note that ⟨postscript text⟩ isn't an argument and you need to supply your own “PS” tag at the start of it)
to indicate a list of people to be cc'd, and
to specify a list of any enclosures.
Here is a simple letter:
\documentclass[12pt]{letter} \usepackage[a4paper]{geometry} \usepackage[british]{babel} \begin{document} \begin{letter}{Mrs Mabel Canary\\24 The Street\\ Some Village\\Some Town\\Noshire\\AB1 2YZ} \opening{Dear Mrs Canary} This is an imaginary letter. This is the second paragraph of the letter. \closing{Yours sincerely} \ps PS: this is a postscript. \encl{Photocopy of something interesting\\ Photocopy of something rather dull} \cc{Prof Important Person\\Dr Bor Ing} \end{letter} \end{document}
(I've used the babel package [7] with the british
option
to ensure that the date is displayed using the British format rather
than the default US format.)
The resulting document is shown in Figure 3.1. You can download or view this example.
You can add information about the sender as well. This typically goes in the preamble. The sender's name is specified using:
Additionally, you can specify the sender's name as it should appear
after the closing text (supplied by \closing
):
The sender's address is specified using:
You may use \\ within ⟨text⟩ to separate the lines of the address. The sender's telephone number is specified using:
Additional location information for the sender is specified using:
By default, the location and telephone number information is placed on the footer of the first page if no sender address has been specified. If you want to specify the sender address as well, you need to use
\thispagestyle{firstpage}
after \opening
.
The letter class is very old and doesn't provide a means for specifying modern communication methods such as email, mobile phone numbers or web addresses.
Modify Example 12 to include sender details.
For the More Adventurous
Recall from §2.8 Fetching Data From a Given Row that you can fetch a single row of data from a database. Use one of the commands described in that section to fetch the recipient's details from the sample people.csv file or the people SQL table rather than explicitly typing them into the document. You can download or view a solution.
This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-07-4).