Writing a letter
Letters have a specific structure. Commonly, they have an addressee field at a fixed position, which should be visible in the envelope window. It also should show a back address of yourself as the sender. An opening text and a closing phrase are usual elements; you may add fold marks and enclosures.
How to do it...
We will use a KOMA-Script class specifically designed for letters named scrlttr2. Follow the following steps:
- Use the scrlttr2 class, activate the address field and fold marks via an option, and align the sender’s address to the right:
\documentclass[addrfield=true, foldmarks=true, fromalign=right]{scrlttr2}
- Provide your name and your address using the \setkomavar command:
\setkomavar{fromname}{Thomas Smith} \setkomavar{fromaddress}{123 Blvd \\ City, CC 12345}
- Write a date, either \today for today or any date as text:
\date{\today}
- Begin the document:
\begin{document}
- Open a letter environment with the recipient’s address as an argument:
\begin{letter}{Agency \\ 5th Avenue \\ Capital City, CC 12345}
- Start with an opening, and let your letter text follow:
\opening{Dear Sir or Madam,} the actual content of the letter follows.
- End with closing words:
\closing{Yours sincerely}
- End the letter environment and the document:
\end{letter} \end{document}
- Compile the document. Here is the upper part of the output:
Figure 1.6 – A letter template
That was pretty easy! You got fully fledged formal letter addressing information, envelope window support, today’s date, phrases, signature, and even fold marks.
Now, you can enter real addresses and actual letter text.
How it works...
When loading the scrlttr2 letter class, we activated the address field, switched on fold marks, and set the options for right aligning the sender’s address.
The scrlttr2 class is quite different from others, so it has a unique interface. Using the \setkomavar command, we set the content of class variables, similar to \renewcommand. Here, we put names and addresses. The KOMA-Script manual explains all available variables. As mentioned in the Developing a thesis recipe, you can open it by executing texdoc koma-script at Command Prompt or online at https://texdoc.org/pkg/koma-script.
We used a letter environment for the actual content, including the opening and closing phrases. The address is a mandatory argument for that environment. You can have several letter environments in a single document.
There’s more...
To improve input and hyphenation and change the font, look at the first recipes in Chapter 2, Tuning the Text.
Let’s take a look at some letter-specific options.
Separating paragraphs
Instead of indenting the beginning of paragraphs, you can visualize a paragraph break with an empty line. For this, add the parskip=full option to the comma-separated list of class options at the beginning.
Use parskip=half for less space.
Changing the signature
If you would like to use a signature different from your specified name for the address, you can modify the corresponding variable content in the preamble:
\setkomavar{signature}{Thomas}
It would be indented. You can get it left aligned by specifying the following code:
\renewcommand{\raggedsignature}{\raggedright}
The code just shown also belongs to the preamble.
Adding enclosures
If you would like to add enclosures to your letter, it’s common to mention them. You can do this by inserting an \encl command right before \end{letter}:
\encl{Curriculum vitae, certificates}
You can change the default encl: option if you like by modifying the corresponding variable before calling the \encl command:
\setkomavar*{enclseparator}{Attached}
We used the \setkomavar* starred version, which modifies the description of a variable instead of its content, which actually is : – that is, a colon followed by a space.