- LaTeX Cookbook
- Stefan Kottwitz
- 604字
- 2021-07-09 21:24:58
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, and you may add fold marks and enclosures.
How to do it...
We will use a KOMA-Script class, which has been specifically designed for letters, named scrlttr2
. Take a look at the following steps:
- Use the
scrlttr2
class, activate the address field and fold marks using the options as follows, 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:
That was pretty easy! You got a fully fledged formal letter with addressing information, an envelope window support, date of writing, phrases, signature, and even fold marks.
Now you can enter the real addresses and the actual letter text.
How it works...
When loading the letter class scrlttr2
, we activated the address field, switched on fold marks, and set the options for aligning the sender's address to the right.
The scrlttr2
class is quite different from other classes, so it has a special interface. Using the \setkomavar
command, we set the content of class variables, similar to the \renewcommand
command. Here, we set the name and address. The KOMA-Script manual explains all the available variables. As mentioned in the recipe Writing a book, you can open it by typing the texdoc scrguien
command in Command Prompt, or online at http://texdoc.net/pkg/scrguien.
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...
For improving input and hyphenation, and for changing the font, take a look at the first recipe in Chapter 2, Tuning the Text.
Let's take a look at some letter specific options.
Instead of indenting the beginnings of paragraphs, you can indicate a paragraph break with an empty line instead. For this, simply add the following option to the comma-separated list of class options at the beginning:
parskip=full
Use the parskip=half
option for less space between paragraphs.
If you would like to use a signature that is 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 preceding code also belongs to the preamble.
If you wish to add enclosures to your letter, it's a common practice to mention them. You can do this by inserting an \encl
command right before the \end{letter}
command:
\encl{Curriculum vitae, certificates}
You can change the default encl:
if you like by modifying the corresponding variable before calling the \encl
option:
\setkomavar*{enclseparator}{Attached}
We used the starred version, \setkomavar*
, which modifies the description of a variable instead of its content, which actually is :
, that is, a colon followed by a space.
- Progressive Web Apps with React
- HoloLens Beginner's Guide
- AngularJS深度剖析與最佳實踐
- Learn Scala Programming
- Mastering LibGDX Game Development
- Apache Karaf Cookbook
- 人人都是網站分析師:從分析師的視角理解網站和解讀數據
- JavaScript+Vue+React全程實例
- Oracle Exadata專家手冊
- 大模型RAG實戰(zhàn):RAG原理、應用與系統(tǒng)構建
- Buildbox 2.x Game Development
- Python期貨量化交易實戰(zhàn)
- 原型設計:打造成功產品的實用方法及實踐
- C語言王者歸來
- Learning Unity Physics