\startcomponent correspondence-letter-beginner

\environment correspondence-environment

\chapter{Beginners guide}

%This chapter will help you to write your own letter without studying first the complete manual, only the most important information are given to get a result with the default styles.

The most important 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.

\startbuffer[interface:text]
\startletter
\input knuth\par
\stopletter
\stopbuffer

\start

\setupletter[alternative=none]

\getbuffer[interface:text]

\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 could see from the first line the letter module has to be loaded before it could 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 forgot 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 and after the letter text.

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

You're not restricted to only one letter in file, it is possible to write as many as you like in a file and you could use this to write serial letters but a easier method to do this is described later in the manual.

\startbuffer[interface:opening]

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

\getbuffer[interface:text]

\stopbuffer

\start

\setupletter[alternative=none]

\getbuffer[interface:opening]

\stop

\section{Opening\index{opening} and closing\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 argument for \type {\startletter} as done in the current or you could set them before the content of the letter with the two commands \type {\setupletter} and \type {\setlettervalue}.

Let us begin with first alternative and set them as argument with \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 value 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 their is as last alternative the \type {\setlettervalue} command, it comes in two different versions where the keyword is either written in braces or in bracket but the content itself is 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 nearly no difference to the second version and both give the same result and you could the one which you prefer.

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

The values itself had 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 is their is no comma in you text.

This could not 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]

\startbuffer[interface:subject]

\setupletter
  [subject={Step by step guide to write a letter}]

\getbuffer[interface:opening]

\stopbuffer

\start

\setupletter[alternative=none]

\getbuffer[interface:subject]

\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 could write a subject.

Instead of integrating this point in the last section I wrote a new 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, the is no big difference between them but the title is normally written before the subject and has and use a slightly bigger size or is emphasized in another way.

\startbuffer[interface:address]

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

\getbuffer[interface:subject]

\stopbuffer

\start

\setupletterstyle[whitespace=line]

\getbuffer[interface:address]

\stop

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

Letter are normally meant to be send by post and 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 prefer to set the values for the addressee not with \type {\startletter} but with \type {\setupletter} but this is just a matter of style and you could select what fits best to your own working style.

\startbuffer[interface:sender]

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

\getbuffer[interface:address]

\stopbuffer

\start

\getbuffer[interface:sender]

\stop

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

It is not often enough to have just the addressee information on the letter, you're looking also for way to put the {\em name} and {\em address} for 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 key names to prevent confusions which value should use the the simpler and which one a more verbose one both got e prefix to the key to differentiate them, so got addressee information the prefix {\em to} and sender information the prefix {\em from}.%\footnote{The real answer is the author took the names for the new user interface from KOMA-Script and this is where most of the commands have their name from.}

The additional input for the example on the left page to the one from the previous examples is:

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

The manual will describe in a later section how to write a own header with a personal look and feel but this is outside of the user interface and requires knowledge about the layout.

\startbuffer[interface:reference]

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

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

\getbuffer[interface:sender]

\stopbuffer

\start

\getbuffer[interface:reference]

\stop

\section{Reference line}

If you're in a company or a organisation you need sometimes a few extra information on your letter. The reference line or block is the right place where you can place these information.

Our old example from the last section was now extended by a reference line between the information from our addressee and the subject line, the information for the four fields were 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 but 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 will appear in the 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 change the content for the {\em list} key in your file the module will show by default the date of the current date at the right side of the reference line, this will normally always happen and you could say the result in the examples of the two preceding sections.

\startbuffer[interface:signature]

\setupletter
  [signature={Arthur Thor}]

\getbuffer[interface:reference]

\stopbuffer

\start

\getbuffer[interface:signature]

\stop

\section{Signature\index{signature}}

You know now ho 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 need for a letter are already told but a few fields at the end of the letter remains untold, the first line you will add to our example letter is the signature. It is set with the {\em signature} in se 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 also by hand after you have printed the letter.

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, such a solution would have been for the author the next 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 will be 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{Posctscript}

\stopletter

\stop

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

\starttyping
\startletter

...

\ps{...}

\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{...}
\encl{...}

\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{...}
\encl{...}
\cc{...}

\stopletter
\stoptyping

\stopcomponent
