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

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

主站蜘蛛池模板: 鹤庆县| 光山县| 布尔津县| 郁南县| 象山县| 镇沅| 南康市| 哈巴河县| 漳州市| 邹城市| 中西区| 永定县| 中西区| 灵丘县| 济源市| 托里县| 大悟县| 温宿县| 巨鹿县| 海宁市| 黑河市| 金川县| 肥西县| 龙泉市| 廉江市| 大兴区| 崇礼县| 乾安县| 阿勒泰市| 庆阳市| 广灵县| 华宁县| 文安县| 杂多县| 疏附县| 班戈县| 永川市| 奉新县| 罗甸县| 乳山市| 延长县|