\startcomponent correspondence-letter-examples

\environment correspondence-environment

\chapter{Layout}

The components for the layout of a letter can be divided into {\em letter layers} and {\em letter sections}. You can position letter layers on the page wherever you want and it is also possible to put one layer in front of or behind another layer.

The underlying mechanism behind letter layers is \CONTEXT’s normal layer mechanism in combination with local framed environments. This is a very powerful combination and you can create complicated layouts with them.

Letter sections, the second group of components, are not as powerful as letter layers and you only have a limited number of elements to control their layout.

\setup[setupletterstyle:layout]

\setup[setupletterstyle:option]

\start

\setupletter
  [alternative=none]

\setupletterstyle
  [option]
  [marking=off,
   backaddress=yes]

\setupletterstyle
  [backaddress]
  [bottomframe=off]

\setupletterstyle
  [head,foot,address,backaddress,reference]
  [background=color,
   backgroundcolor=darkgray,
   backgroundoffset=-1.5pt]

\startletter
\dontleavehmode
\stopletter

\stop

\section{Letter layers}

Layers are used to position elements on a page independent of the page layout.
They are used for the header and footer, address block\footnote{The block styles
use a different structure and use a letter section for the address block.}, etc..

The complete list of all available layers is:

\startitemize[packed,columns,three]
\item head
\item letternext
\item lettermain
\item foot
\item address
\item reference
\item location
\item nexthead
\item lefthead
\item righthead
\item nextfoot
\item leftfoot
\item rightfoot
\item topmark
\item botmark
\item cutmark
\item endmark
\item usermark
\item backaddress
\stopitemize

\starttyping
\setlayer[...]{\framed{...}}
\stoptyping

The position and layout of the layers can be changed with the \type {\setupletterstyle} command.

\starttyping
\setupframed[...][..,..=..,..]
\stoptyping

\setup[setupletterlayer:frame]

\starttyping
\setuplayer[...][..,..=..,..]
\stoptyping

\setup[setupletterlayer:layer]

\starttyping
\getparameters[...][..,..=..,..]
\stoptyping

\setup[setupletterlayer:option]

\subsubject{State value}

\starttabulate
\HL
\NC start     \NC show layer on the first page                  \NC\NR
\NC stop      \NC disable layer                                 \NC\NR
\NC first     \NC see \mono{start}                              \NC\NR
\NC next      \NC show layer on the second and following pages  \NC\NR
\NC left      \NC show layer on left pages                      \NC\NR
\NC right     \NC show layer on right pages                     \NC\NR
\NC leftpage  \NC see \mono{left}                               \NC\NR
\NC rightpage \NC see \mono{right}                              \NC\NR
\NC page      \NC use global pagenumbering for left/right pages \NC\NR
\NC subpage   \NC use local pagenumbering for left/right pages  \NC\NR
\HL
\stoptabulate

\start

\definecolor[fakerulecolor][darkgray]

\setupletterstyle
  [reference]
  [alternative=none]

\setupletterstyle
  [enclosure,copy,postscript]
  [location=left,width=0pt,before=\nowhitespace,after=\nowhitespace]

\setuplabeltext
  [letter:enclosure=,
   letter:copy=,
   letter:postscript=]

\setupletter
  [title={\blackrule[width=\hsize,height=\lineheight,color=darkgray]},
   subject={\blackrule[width=\hsize,height=\lineheight,color=darkgray]},
   opening={\blackrule[width=\hsize,height=\lineheight,color=darkgray]},
   closing={\blackrule[width=.33\hsize,height=4\lineheight,color=darkgray]},
   appendices={\blackrule[width=.33\hsize,height=3\lineheight,color=darkgray]}]

\setlettervalue{title}     {\fakewords  {5} {10}}
\setlettervalue{subject}   {\fakewords  {5} {10}}
\setlettervalue{opening}   {\fakewords  {3}  {5}}
\setlettervalue{content}   {\fakewords{100}{150}}
\setlettervalue{closing}   {\fakewords  {2}  {4}}
\setlettervalue{enclosure} {\fakewords  {3}  {6}}
\setlettervalue{copy}      {\fakewords  {3}  {6}}
\setlettervalue{postscript}{\fakewords  {3}  {6}}

\startletter
\fakewords{100}{150}
\stopletter

\stop

\section{Letter sections}

\startitemize[packed,columns,three]
\item letterhead\footnote[section:blockstyle]{Only used for the blockstyle layouts.}
\item dateline\note[section:blockstyle]
\item referenceline\note[section:blockstyle]
\item specialnotation\note[section:blockstyle]
\item insideaddress\note[section:blockstyle]
\item title
\item subject
\item opening
\item content
\item closing
\item appendices
\stopitemize

You can change the layout of a letter section with the \type {\setupletterstyle}
command, the syntax is:

\setup[setuplettersection]

\start

\definecolor[fakerulecolor][darkgray]

\setupletterstyle
  [reference]
  [alternative=none]

\startletter
\fakewords{100}{150}
\stopletter

\stop

\section{Letter descriptions}

\setup[setupletterdescription]

\stopcomponent
