\startcomponent correspondence-letter-examples

\environment correspondence-environment

\chapter{Layout}

The components for the letter can be divided in to groups, the first are letter layers, you can position them on the page wherever you want and it is also possible to put one layer bevor or behind another layer.

The underliying machanism behind letter layers are \CONTEXT's normal layer mechanism in combination with localframed environments, this is a very powerful combination and you could create complicated layouts with them.

The second group of components for the layout are letter sections, they are not as powerfule as letter layers and you have only 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}

Layer are used to position elements one page independant 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]

\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
