\startcomponent correspondence-letter-beginner

\environment correspondence-environment

\chapter{Beginners’ guide}

The most important thing in the module for the users is the interface to write the letter text and to set the values for one or more letters.

You will learn how to write a letter with the module step by step, beginning with just a few lines of text, following with opening and closing sentences and at the end, after you know how to set every kind of information, you will finally learn how to change the position of the reference line and how to change the texts for the labels and to customise their style and color.

\start

\setupletter[alternative=none]

\startletter
\input knuth\par
\stopletter

\stop

\section{Pure text}

To understand how a letter is written let’s study the code for the example letter on the left page.

\starttyping
\usemodule[letter]

\starttext

\startletter
Thus, I came to the conclusion ...
\stopletter

\stoptext
\stoptyping

As you can see from the first line the letter module has to be loaded before it can be used because it is none of the functions \CONTEXT\ provides by default. To make the examples in the following sections a little bit shorter I will no longer add \type{\usemodule}, \type{\starttext} and \type{\stoptext} but you shouldn’t forget to add all of them in your files.

The content for your letter is written between the letter environment, it doesn’t matter if you use blank lines before or after the letter text.

If you take a closer look at the result on the left side you can see the paragraphs are separated by blank lines. This can be changed with the \type{\setupletterstyle} command but let us keep this for later.

You’re not restricted to only one letter for a file. It is possible to write as many as you like in a file and you could use this to write serial letters. An easier method for this task is described later in this manual.

\start

\setupletter[alternative=none]

\setupletter
  [opening={Dear Reader,},
   closing={Greetings from the Author}]

\startletter
\input knuth\par
\stopletter

\stop

\section{Opening and closing}\index{opening}\index{closing}

You saw in the last example how to write a simple text. But shouldn’t it be possible to give a few opening and also closing words for the letter, because the reader should know for whom the content is.

To achieve this the module provides the two variables {\em opening} and {\em closing}. To feed them with text you could either use the optional arguments for \type{\startletter} as done in the current example or you could set them before the start of the letter with the two commands \type{\setupletter} and \type{\setlettervalue}.

Let us begin with first alternative and set them as arguments for \type{\startletter}:

\starttyping
\startletter
  [opening={Dear Reader,},
   closing={Greetings from the Author}]
Thus, I came to the conclusion ...
\stopletter
\stoptyping

If you don’t like this method you could set the two values before the letter environment with the \type{\setupletter} command. The text in your file should now look like:

\starttyping
\setupletter
  [opening={Dear Reader,},
   closing={Greetings from the Author}]

\startletter
Thus, I came to the conclusion ...
\stopletter
\stoptyping

If you are more interested in a KOMA-Script like solution to set with every command only one value there is as last alternative the \type{\setlettervalue} command, both keyword and content are written between braces.
The first version with braces for two values has the following look.

\starttyping
\setlettervalue{opening}{Dear Reader,}
\setlettervalue{closing}{Greetings from the Author}
\stoptyping

The values itself have to be given before the letter environment because values in the letter text are ignored and will never be shown in the output.

You have also to be careful with the content for the values because commas are interpreted as end of the value if you write it as argument for \type{\startletter} or with \type{\setupletter} and the text has to be protected with braces in this case but you don’t need them when there is no comma in the argument.

This cannot happen if you set the values with the \type{\setlettervalue} command, because the content is delimited by the braces and commas are just normal text.

\page[left]

\start

\setupletter[alternative=none]

\setupletter
  [opening={Dear Reader,},
   closing={Greetings from the Author},
   subject={Step by step guide to write a letter}]

\startletter
\input knuth\par
\stopletter

\stop

\section{Subject}\index{subject}

After you read how to write the text and set values for the opening and closing we mention now how we can write a subject.

Instead of integrating this point in the last section I wrote a new one to let you understand the system. Before I will tell more let’s take a look at the code.

\starttyping
\startletter
  [opening={Dear Reader,},
   subject={Step by step guide to write a letter},
   closing={Greetings from the Author}]
Thus, I came to the conclusion ...
\stopletter
\stoptyping

The text for the subject is written as argument for {\em subject} as argument for \type{\startletter}, as you already guess you could have set it also with \type{\setupletter} or \type{\setlettervalue} and this is also possible and true for the values in the following sections.

Besides the {\em subject} you have also the option to set a {\em title} for the letter. There is no big difference between them, but the title is normally written before the subject and has a slightly bigger size or is emphasized in another way.

\start

\setupletterstyle[whitespace=line]

\setupletter
  [toname={Mike Wilson},
   toaddress={Linden street 12\\78569 TeX City}]

\setupletter
  [opening={Dear Reader,},
   closing={Greetings from the Author},
   subject={Step by step guide to write a letter}]

\startletter
\input knuth\par
\stopletter

\stop

\section{Address}\flushatnextpar{\index{toname}\index{toaddress}}

Letters are normally meant to be sent by mail. To prevent you from writing the address by hand on the envelope you could buy envelopes with windows. To use these envelopes the address has to be written on the letter and to do this you have to set the {\em name} and the {\em address} for the addressee with the two values {\em toname} and {\em toaddress}.

The input for the example on the left page looks like:

\starttyping
\setupletter
  [toname={Mike Wilson},
   toaddress={Linden street 12\\78569 TeX City}]

\startletter
  [opening={Dear Reader,},
   subject={Step by step guide to write a letter},
   closing={Greetings from the Author}]
Thus, I came to the conclusion ...
\stopletter
\stoptyping

The author prefers to set the values for the addressee not with \type{\startletter} but with \type{\setupletter} but this is just a matter of taste and you can select what fits your own working style best.

\start

\setupletter
  [fromname={The Author},
   fromaddress={Hidden Street 2\\57895 Mystery town}]

\setupletter
  [toname={Mike Wilson},
   toaddress={Linden street 12\\78569 TeX City}]

\setupletter
  [opening={Dear Reader,},
   closing={Greetings from the Author},
   subject={Step by step guide to write a letter}]

\startletter
\input knuth\par
\stopletter

\stop

\section{Sender}\index{fromname}\index{fromaddress}

It is not often enough to have just the addressee information on the letter. You’re also looking for a way to put the {\em name} and {\em address} of the sender into the header.

If you have wondered why the author hasn’t just used {\em name} and {\em address} as keys for the addressee values you will now find the solution. To make the system consistent to set the values for addressee and the sender both needed unique key names to prevent confusion. Which value should use the simpler and which one a more verbose one both got a prefix to the key to differentiate them. So addressee information got the prefix {\em to} and sender information the prefix {\em from}.

The additional lines for the example on the left page compared to the previous one are:

\starttyping
\setupletter
  [fromname={The Author},
   fromaddress={Hidden Street 2\\57895 Mystery town}]
\stoptyping

This manual describes in a later section how to write an own header with a personal look and feel. But this is outside of the user interface and requires knowledge about the layout.

\start

\setupletter
  [name={Ben Johnson},
   phone={4922-89564},
   fax={4922-89564}]

\setupletter
  [list={name,phone,fax,date}]

\setupletter
  [fromname={The Author},
   fromaddress={Hidden Street 2\\57895 Mystery town}]

\setupletter
  [toname={Mike Wilson},
   toaddress={Linden street 12\\78569 TeX City}]

\setupletter
  [opening={Dear Reader,},
   closing={Greetings from the Author},
   subject={Step by step guide to write a letter}]

\startletter
\input knuth\par
\stopletter

\stop

\section{Reference line}

If you’re in a company or an organisation you sometimes need a few extra information on your letter. The reference line or block is the right place to put these information to.

Our old example from the last section is now extended by a reference line between the information of our addressee and the subject line. The information for the four fields are set with the following code.

\starttyping
\setupletter
  [name={Ben Johnson},
   phone={4922-89564},
   fax={4922-89564},
   date=\currentdate]

\setupletter
  [list={name,phone,fax,date}]
\stoptyping

The first \type{\setupletter} set the content for the four fields {\em name}, {\em phone}, {\em fax} and {\em date}. Although the values are set none of them will appear in the output. We have to declare the fields for the reference line first, this is done in the second \type{\setupletter} command with the key {\em list}, the entries appear in the same order as you write them in the list. If one or more of the keys in the list have no values they will still appear in the output but no content is shown.

If you do not change the {\em list} key in your file, by default the module will show the current date at the right side of the reference line. This will normally always happen and you could see the result in the examples of the two preceding sections.

\start

\setupletter
  [name={Ben Johnson},
   phone={4922-89564},
   fax={4922-89564}]

\setupletter
  [list={name,phone,fax,date}]

\setupletter
  [fromname={The Author},
   fromaddress={Hidden Street 2\\57895 Mystery town}]

\setupletter
  [toname={Mike Wilson},
   toaddress={Linden street 12\\78569 TeX City}]

\setupletter
  [opening={Dear Reader,},
   closing={Greetings from the Author},
   subject={Step by step guide to write a letter},
   signature={Arthur Thor}]

\startletter
\input knuth\par
\stopletter

\stop

\section{Signature}\index{signature}

You know now how to set the letter text, the opening and closing lines, the values for the addressee and the sender and also how define your own values for the reference line.

Most of the things needed for a letter are already told but a few fields at the end of the letter remain untold. The first line you want to add to our example letter is the signature. It is set with the {\em signature} in the same way as the other values in the former examples. What the author did in the left example was:

\starttyping
\setupletter
  [signature={Arthur Thor}]
\stoptyping

There is some space between the closing and the signature to give you the possibility to sign the letter after having printed it out.

You’re not limited to simple text for the signature. It is also possible to use a graphic if you won’t sign the letter by hand after you printed it. This solution is used in the following code.

\starttyping
\setupletter
  [signature={\externalfigure[autograph][height=2\lineheight]}]
\stoptyping

How to adjust the space between the closing line and the signature for this way is shown in the letter style section.

\start

\setupletter
  [name={Ben Johnson},
   phone={4922-89564},
   fax={4922-89564}]

\setupletter
  [list={name,phone,fax,date}]

\setupletter
  [fromname={The Author},
   fromaddress={Hidden Street 2\\57895 Mystery town}]

\setupletter
  [toname={Mike Wilson},
   toaddress={Linden street 12\\78569 TeX City}]

\startletter
  [opening={Dear Reader,},
   subject={Step by step guide to write a letter},
   closing={Greetings from the Author},
   signature={Arthur Thor}]

\input knuth\par

\ps{Postscript}

\stopletter

\stop

\section{Postscript}\index{postscript}\index{\tex{ps}}

\starttyping
\startletter

...

\ps{Postscript}

\stopletter
\stoptyping

\start

\setupletter
  [name={Ben Johnson},
   phone={4922-89564},
   fax={4922-89564}]

\setupletter
  [list={name,phone,fax,date}]

\setupletter
  [fromname={The Author},
   fromaddress={Hidden Street 2\\57895 Mystery town}]

\setupletter
  [toname={Mike Wilson},
   toaddress={Linden street 12\\78569 TeX City}]

\startletter
  [opening={Dear Reader,},
   subject={Step by step guide to write a letter},
   closing={Greetings from the Author},
   signature={Arthur Thor}]

\input knuth\par

\ps{Postscript}

\encl{Appendices}

\stopletter

\stop

\section{Enclosure}\index{enclosure}\index{\tex{encl}}

\starttyping
\startletter

...

\ps{Postscript}
\encl{Appendices}

\stopletter
\stoptyping

\start

\setupletter
  [name={Ben Johnson},
   phone={4922-89564},
   fax={4922-89564}]

\setupletter
  [list={name,phone,fax,date}]

\setupletter
  [fromname={The Author},
   fromaddress={Hidden Street 2\\57895 Mystery town}]

\setupletter
  [toname={Mike Wilson},
   toaddress={Linden street 12\\78569 TeX City}]

\startletter
  [opening={Dear Reader,},
   subject={Step by step guide to write a letter},
   closing={Greetings from the Author},
   signature={Arthur Thor}]

\input knuth\par

\ps{Postscript}

\encl{Appendices}

\cc{List of recipients}

\stopletter

\stop

\section{Copy}\index{copy}\index{\tex{cc}}

\starttyping
\startletter

...

\ps{Postscript}
\encl{Appendices}
\cc{List of recipients}

\stopletter
\stoptyping

\stopcomponent
