官术网_书友最值得收藏!

  • 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:

  1. 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}
  2. Provide your name and your address using the \setkomavar command:
    \setkomavar{fromname}{Thomas Smith}
    \setkomavar{fromaddress}{123 Blvd \\ City, CC 12345}
  3. Write a date, either \today for today, or any date as text:
    \date{\today}
  4. Begin the document:
    \begin{document}
  5. Open a letter environment, with the recipient's address as an argument:
    \begin{letter}{Agency \\ 5th Avenue \\
                   Capital City, CC 12345}
  6. Start with an opening, and let your letter text follow:
    \opening{Dear Sir or Madam,}
    the actual content of the letter follows.
  7. End with closing words:
    \closing{Yours sincerely}
  8. End the letter environment and the document:
    \end{letter}
    \end{document}
  9. Compile the document. Here is the upper part of the output:
    How to do it...

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.

Separating paragraphs

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.

Changing the signature

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.

Adding enclosures

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.

主站蜘蛛池模板: 大同市| 博客| 石林| 台安县| 孟连| 平南县| 长乐市| 凤山市| 共和县| 涟源市| 阿鲁科尔沁旗| 富阳市| 轮台县| 闸北区| 宜章县| 科尔| 水富县| 临清市| 岳普湖县| 揭东县| 托里县| 秦皇岛市| 云和县| 鄂温| 兴国县| 长宁县| 德惠市| 丹凤县| 乌兰察布市| 普洱| 株洲市| 五峰| 盐源县| 平阴县| 汾阳市| 乡城县| 讷河市| 齐河县| 治多县| 赤城县| 新干县|