Talk:Letter style

From ConTeXt wiki

better make it an environment --Hraban 22:26, 27 Jul 2004 (CEST)

you are right, done --Numenor 18:03, 31 Dec 2004 (CET)

Enhancement Proposals

Sender KeyVals

Replace the ugly heap of sender macros with \setvalue like this:

% some setups, only for completeness
\def\sendervalwidth{4cm}
\def\senderkeywidth{2cm}
\def\keystyle{\tfx\it}
\def\valstyle{}

% define setter (Sender) and getter (GetSenderLine)
\def\Sender#1#2#3{\setvalue{SenderKey#1}{#2}\setvalue{SenderVal#1}{#3}}
\def\GetSenderLine#1{\bTR\bTD\doiftextelse{\getvalue{SenderKey#1}}	{\getvalue{SenderKey#1}:}{}\eTD\bTD\getvalue{SenderVal#1}\eTD\eTR}
% initialize values - not even needed
%\dostepwiserecurse{1}{9}{1}{
%    \Sender{\recurselevel}{}{}
%}

\startsetups sendertablesetup
	\setupTABLE[frame=off]
	\setupTABLE[x][1][width=\senderkeywidth, align=left, style={\keystyle\strut}]
	\setupTABLE[x][2][width=\sendervalwidth, align=right, style={\valstyle\strut}]
	\bTABLE
\dostepwiserecurse{1}{9}{1}{
	\expanded{\GetSenderLine{\recurselevel}}
}
	\eTABLE
\stopsetups

You use it in your letter like this:

\Sender{1}{Name}{Hraban}
\Sender{2}{Address}{Anywhere}
\Sender{3}{}{in Switzerland}
\Sender{4}{Web}{www.fiee.net/texnique/}

(Thanks to Peter Rolf and Taco Hoekwater for their valuable help!)

Address and Logo Space

I (Hraban) wanted to use my "corporate design" and put the address directly under my logo:

% setups
\def\firstpageheaderheight{95mm}
\def\topspaceheight{12.5mm}
\def\sendervalwidth{40mm}
\def\senderkeywidth{20mm}
\def\bleed{3mm}
\def\logothirdwidth{\senderkeywidth}
\def\logoheight{\senderkeywidth}
% logo definition (simplified)
\defineoverlay[logo][{%
	\framed[frame=off,
	background=color, backgroundcolor=Grau,
	width=\logothirdwidth, height=\dimexpr(\logoheight+\bleed)]{}%
	\framed[frame=off,
	background=color, backgroundcolor=HKS5,
	width=\logothirdwidth, height=\dimexpr(\logoheight+\bleed)]{}%
	\framed[frame=off,
	background=color, backgroundcolor=Grau,
	width=\logothirdwidth, height=\dimexpr(\logothirdwidth+\bleed)]{}%
}]
	
\definelayer[firstpagelayer][width=\makeupwidth, height=\firstpageheaderheight]
\startsetups firstpageintrosetup
	% Logo field
	\setlayerframed[firstpagelayer]
		[y=-\dimexpr(\topspaceheight+\bleed), corner={right,top}, location={left,bottom}]
		[height=\dimexpr(\logoheight+\bleed),
		width=\dimexpr(\senderkeywidth+\sendervalwidth), %\overlaywidth,
		frame=off, offset=0mm,
		%align=left,
		background=logo
		]
		{}%{\externalfigure[fiee-kopf-144][width=60mm]}
	% Sender line in letter window / Absenderzeile im Brieffenster
	\setlayerframed[firstpagelayer]
		[y=38mm, location={right,bottom}]
		[height=5mm, width=80mm,
		frame=off, bottomframe=off,
		offset=none, align={right,lohi}]
		{\tfxx\lettershortsender}
	% Addressee field / Empfängerfeld
	\setlayerframed[firstpagelayer]
		[y=41mm, location={right,bottom}]
		[height=36mm, width=80mm,
		frame=off, offset=none, align={right,top}]
		{\doiftextelse{\letterdisposal}{\vskip1.0ex\letterdisposal}{}
		\vskip1.5ex
		\letteraddressee}
	% Sender field / Absenderfeld
	\setlayerframed[firstpagelayer]
		[corner={right}, location={left,bottom}, 
		y=\dimexpr(\senderkeywidth+\bleed-\topspaceheight)]
		[height=46mm, width=\dimexpr(\senderkeywidth+\sendervalwidth),
		frame=off, offset=none, align={left,top}]
		{\setups{sendertablesetup}}
	% Date field / Datumsfeld
		% perhaps one should use the \setvalue stuff for this again
	\setlayerframed[firstpagelayer]
		[corner={right},y=87mm,location={left,bottom}]
		[height=5mm,width=\dimexpr(\senderkeywidth+\sendervalwidth),
		align={left,top},frame=off,offset=none]
		 {\bTABLE
		\setupTABLE[frame=off]
		\setupTABLE[x][1][width=\senderkeywidth, align=left]
		\setupTABLE[x][2][width=\sendervalwidth, align=right]
		\bTR \bTD
		{\keystyle\translate[en=date, de=Datum]:}
		\eTD \bTD
		\valstyle
		\doiftextelse{\letterplace}
		{\letterplace,\translate[en=, de=]\ }{}
		% default date is actual date in ISO format
		\doiftextelse{\letterdate}{\letterdate}{\currentdate[year,-,mm,-,dd]}% {\currentdate}
		\eTD \eTR
		\eTABLE}
\stopsetups

Folding Marks

The folding marks used endash and emdash and didn't "bleed" over the margin (as they should if you want to offset print).

\def\bleed{3mm}
\definecolor[Grey][s=.5]

\definelayer[foldingmarkslayer][state=repeat]
\startsetups foldingmarkslayersetup
	\setupblackrules[width=13mm, height=0.1mm, color=Grey]
	\setlayer[foldingmarkslayer][y=107mm, x=-\bleed, align={lohi,right}]{\blackrule}
	\setlayer[foldingmarkslayer][y=148.5mm, x=-\bleed, align={lohi,right}]{\blackrule[width=10mm]}
	\setlayer[foldingmarkslayer][y=202mm, x=-\bleed, align={lohi,right}]{\blackrule}
\stopsetups