LaTeX/Letters

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Sometimes the mundane things are the most painful. However, it doesn't have to be that way because of evolved, user-friendly templates. Thankfully, LaTeX allows for very quick letter writing, with little hassle.

Contents

[edit] The letter class

To write letters use the standard document class letter.

You can write multiple letters in one LaTeX file - start each one with \begin{letter}{recipient} and end with \end{letter}. You can leave recipient blank. Each letter consists of four parts:

  1. opening (like \opening{Dear Sir or Madam,} or \opening{Dear Kate,}
  2. main body - written as usual in LaTeX
  3. closing (like \closing{Yours sincerely,}
    LaTeX will leave some space after closing for your hand-written signature; then it will put your name and surname, if you have declared them.
  4. additional elements: post scriptum , carbon copy and list of enclosures

If you want your name, address and telephone number to appear in the letter, you have to declare them first signature, address and telephone.

The output letter will look like this:

A sample letter.

Here is the example's code:

\documentclass{letter}
\signature{Joe Bloggs}
\address{21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
\begin{document}
 
\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\opening{Dear Sir or Madam:}
 
I am writing to you on behalf of the Wikipedia project (http://www.wikipedia.org/),
an endeavour to build a fully-fledged multilingual encyclopaedia in an entirely
open manner, to ask for permission to use your copyrighted material.
 
% The \ldots command produces dots in a way that will not upset
% the typesetting of the document.
\ldots 
 
That said, allow me to reiterate that your material will be used to the noble end of
providing a free collection of knowledge for everyone; naturally enough, only if you
agree. If that is the case, could you kindly fill in the attached form and post it
back to me? We shall greatly appreciate it.
 
Thank you for your time and consideration.
 
I look forward to your reply.
 
\closing{Yours Faithfully,}
\ps{P.S. You can find the full text of GFDL license at
http://www.gnu.org/copyleft/fdl.html.}
\encl{Copyright permission form}
 
\end{letter}
 
\end{document}

[edit] Envelopes

Here is a relatively simple envelope which uses the geometry package which is used because it vastly simplifies the task of rearranging things on the page (and the page itself).

% envelope.tex
\documentclass{letter}
\usepackage[margin=0.15in,papersize={4.125in,9.5in},landscape,twoside=false]{geometry}
\setlength\parskip{0pt}
\pagestyle{empty}
 
\begin{document}
 
FROM-NAME
 
FROM-STREET ADDRESS
 
FROM-CITY, STATE, \ ZIP
 
\vspace{1.0in}\large
\setlength\parindent{3.6in}
 
TO-NAME
 
TO-STREET ADDRESS
 
TO-CITY, STATE, \ ZIP
 
\end{document}
A sample envelope to be printed in landscape mode.

This will certainly take care of the spacing but the actual printing is between you and your printer. After all, different printers have different feeding mechanisms for envelopes. You may find the following commands useful for printing the envelope.

$ pdflatex envelope
$ pdf2ps envelope.pdf
$ lpr -o landscape envelope

Alternatively, you can use the latex dvi output driver.

In the first line, dvips command converts the .dvi file produced by latex into a .ps (PostScript) file. In the second line, the PostScript file is sent to the printer.

$ latex envelope.tex && dvips -t unknown -T 9.5in,4.125in envelope.dvi
$ lpr -o landscape envelope.ps

I have found that pdflatex creates the right page size but not dvips despite what it says in the geometry manual. It will never work though unless your printer settings are adjusted to the correct page style. These settings depend on the printer filter you are using and in CUPS might be available on the lpr command line if you are masochistic.

[edit] Windowed envelopes

An alternative to separately printing addresses on envelopes is to use the letter class from the KOMA package. It supports additional features like folding marks and the correct address placement for windowed envelopes. Using the scrlttr2 document class from the KOMA package the example letter code is:

% koma_env.tex
\documentclass[a4paper]{scrlttr2}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{url}
 
 
\setkomavar{fromname}{Joe Bloggs}
\setkomavar{fromaddress}{21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
\setkomavar{fromphone}{0123 45679}
 
\begin{document}
 
\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
 
\KOMAoptions{fromphone=true,fromfax=false}
\setkomavar{subject}{Wikipedia}
\setkomavar{customer}{2342}
\opening{Dear Sir or Madam,}
 
I am writing to you on behalf of the Wikipedia project
(\url{http://www.wikipedia.org/}), an endeavour to build a
fully-fledged multilingual encyclopaedia in an entirely open
manner, to ask for permission to use your copyrighted material.
 
\ldots 
 
That said, allow me to reiterate that your material will be used
to the noble end of providing a free collection of knowledge for
everyone; naturally enough, only if you agree. If that is the
case, could you kindly fill in the attached form and post it back
to me? We shall greatly appreciate it.
 
Thank you for your time and consideration.
 
I look forward to your reply.
 
\closing{Yours Faithfully,}
\ps{P.S. You can find the full text of GFDL license at
\url{http://www.gnu.org/copyleft/fdl.html}.}
\encl{Copyright permission form}
 
\end{letter}
 
\end{document}

The output is generated via

$ pdflatex koma_env
A sample letter with folding marks ready for standardized windowed envelopes.

Folding the print of the resulting file koma_env.pdf according the folding marks it can be placed into standardized windowed envelopes DIN C6/5, DL, C4, C5 or C6.

In addition to the default, the KOMA-package includes predefined format definitions for different standardized Swiss and Japanese letter formats.

[edit] Sources


Previous: Algorithms and Pseudocode Index Next: Packages
In other languages