Letter style

From ConTeXt wiki

< Sample documents


Wolfgang's Letter Module

Letter

German Letter style

The following is thought to be a(n early version of a) template for DIN (Deutsches Institut für Normung, German Standardization Institute) conforming letters. Using some provided commands, it should be easy to set sender and receiver addresses for window envelopes, include text or a logo at the top, and contact information to the right of the window space.

If you want to use it, save the following as letterstyle.tex and follow the usage instructions. A downloadable version is available here.

Beware: This style redefines \subject as letter subject line and thus disables header setup!

%
% Style (environment) for writing letters
%
% (c) 2004 Holger Schöner hfsch@cs.tu-berlin.de
% with contributions from Stefan Bunzel
%
% Feel free to use as you like. If modified, please remove the above
% copyright notice.
%

%=============================================================================
% Usage:
%
% \environment letterstyle
% \starttext
% \letter{}
% \setdate{(string)}
% \place{(string)}
% \shortsender{(one-line address of sender)}
% \disposal{(orders)}
% \addressee{(address of receiver; use \\ and \| for new lines)}
% % Block with information about sender on the right hand side (name, phone,
% % fax, email, etc.). (key) is set flush right in a very small font (by
% % default, see \keystyle) and specifies the type of information, and (value)
% % is the actual information.
% \senderone{(key)}{(value)}
% \sendertwo{(key)}{(value)}
% ...
% \sendernine{(key)}{(value)}
% \addfirstheaderlayer[corner={top,left},location={bottom,right}]{\framed[width=\overlaywidth,height=\logoboxheight,frame=off]{}}
% \headercontent{(text)}		% Text placed in the header of every page except the first
% \addheaderlayer[corner={top,left},location={bottom,right}]{}
% \footercontent{(text)}		% Text placed in the footer of every page
% \addfooterlayer[corner={bottom,right},location={top,left}]{}
% \subject{(subject)}
% \greeting{(greetings formulation)}
% \signature{(name)}
% \attachments{(text)}
%
% ----------------------------------------------------------------------------
% Modes:
% demo:		Set an example letter specified at the end of this file for
% 		test/demo purposes.
% nofold:	Determines whether folding marks are set or not. By default,
% 		they are printed; using this mode they are left out.
%
% Set modes by using
% 	texexec -pdf --mode=(mode1,mode2,...) (file)
% 	or specify \enablemode[(mode)] in your input (before including the style)
%
% ----------------------------------------------------------------------------
% There are some nasty tricks involved here; e.g. I could not find a cleaner
% way to specify a header which is to be used for only one page and has a
% different height than that of the following ...
%
% I'd be glad about any hints for improvement of this style!
%

\startenvironment letterstyle

%=============================================================================
% Default values

% Standard Dimensions
\def\firstpageheaderheight{9.5cm}
%\def\firstpagetextheight{8.0cm}
\def\normalheaderheight{1.0cm}
\def\logoboxheight{3.4cm}
\def\normaltextheight{27.4cm}
\def\normalfooterheight{1.0cm}
\def\sendervalwidth{5.05cm}
\def\senderkeywidth{1.85cm}

%% Standard Styles
\def\keystyle{\tfxx}
\def\valstyle{}

%=============================================================================
% Initializations

\def\\{\vskip0mm}
\def\|{\vskip1.5ex}

\def\letterdate{}
\def\letterplace{}
\def\lettershortsender{}
\def\letterdisposal{}
\def\letteraddressee{}

\def\lettersenderkeyone{}
\def\lettersendervalone{}
\def\lettersenderkeytwo{}
\def\lettersendervaltwo{}
\def\lettersenderkeythree{}
\def\lettersendervalthree{}
\def\lettersenderkeyfour{}
\def\lettersendervalfour{}
\def\lettersenderkeyfive{}
\def\lettersendervalfive{}
\def\lettersenderkeysix{}
\def\lettersendervalsix{}
\def\lettersenderkeyseven{}
\def\lettersendervalseven{}
\def\lettersenderkeyeight{}
\def\lettersendervaleight{}
\def\lettersenderkeynine{}
\def\lettersendervalnine{}

\def\letterheadertext{}
\def\letterfootertext{}

%=============================================================================

\setuppapersize[A4][A4]
\setuplayout[location=doublesided]
%\setuppagenumbering[alternative=doublesided]
%\setuppagenumbering[alternative={singlesided,doublesided}]
%\setuppagenumbering[alternative=singlesided}]
\setuppagenumbering[location=]

%=============================================================================
%% Header and footer initializations

%% Start of a new letter; heading text is used only in an optional table of contents
\def\letter#1{%
  \setuplayer[normalheaderlayer][state=reset]%
  \setuplayer[allpagefooterlayer][state=reset]%
  \letterhead{#1}%
  \setuplayer[firstheaderlayer][state=reset]%
  }
\definehead[letterhead][title]
\setuphead [letterhead][
  placehead=empty,
  before={%
    \setups{firstpagelayoutsetup}%
    },
  after=,
  header=firstpageheader,
  page=firstpagebreak,
  coupling=title]

%% Making empty pages completely empty (no page numbers):
\definepagebreak
  [firstpagebreak]
  [yes,header,footer,right] % yes instead of emtpy taken from the sources page-ini.tex line 1611

%% Layout of first page
\startsetups firstpagelayoutsetup
  \setuplayout[
    backspace=2.46cm,topspace=1.2cm,
    top=0cm,bottom=0cm,topdistance=0cm,bottomdistance=0cm,
    header=\firstpageheaderheight,footer=\normalfooterheight,headerdistance=0cm,footerdistance=0cm,
    leftedge=0cm,rightedge=0cm,leftedgedistance=0cm,rightedgedistance=0cm,
    leftmargin=1.5cm,rightmargin=1.5cm,leftmargindistance=0.42cm,rightmargindistance=0.42cm,
    width=16.5cm,height=\normaltextheight,
    ]
\stopsetups
% Layout of other pages
\startsetups normalpagelayoutsetup
  \setuplayout[
    backspace=2.46cm,topspace=1.2cm,
    top=0cm,bottom=0cm,topdistance=0cm,bottomdistance=0cm,
    header=\normalheaderheight,footer=\normalfooterheight,headerdistance=0cm,footerdistance=0cm,
    leftedge=0cm,rightedge=0cm,leftedgedistance=0cm,rightedgedistance=0cm,
    leftmargin=1.5cm,rightmargin=1.5cm,leftmargindistance=0.42cm,rightmargindistance=0.42cm,
    width=16.5cm,
    height=\normaltextheight,textheight=\normaltextheight,
    ]
\stopsetups

%% Header for first pages
\definetext[firstpageheader][header][\setups{firstpagesetup}]
\startsetups firstpagesetup
  \setups{firstpageintrosetup}
  \setups{foldingmarkslayersetup}
  \framed[width=\makeupwidth,height=\headerheight,
    background={firstpagelayer,firstheaderlayer},frame=off]
    {}
\stopsetups

%% Header for other pages
\setups{normalpagelayoutsetup}
\appendtoks\setups{normalpagelayoutsetup}\to\everyaftershipout
\startsetups normalheadersetups
  \setups{normalheaderlayersetup}
  \framed[width=\makeupwidth,height=\headerheight,
    background=normalheaderlayer,frame=off]
    {}
\stopsetups
\setupheadertexts[\setups{normalheadersetups}]

%% Footer for all pages
\startsetups allpagefootersetup
  \setups{allpagefooterlayersetup}
  \framed[width=\makeupwidth,height=\footerheight,
    background=allpagefooterlayer,frame=off]
    {}
\stopsetups
\setupfootertexts[\setups{allpagefootersetup}]

%=============================================================================
%% First page header setups

\definelayer[firstpagelayer][width=\makeupwidth,height=\firstpageheaderheight]

\startsetups firstpageintrosetup
  %% Logo frame
  \setlayerframed[firstpagelayer]
    [corner={left,top},location={right,bottom}]
    [height=3.4cm,width=\overlaywidth,frame=off,offset=none]
    {}
  %% Short sender frame
  \doiftextelse{\lettershortsender}{
    \setlayerframed[firstpagelayer]
      [y=3.8cm,location={right,bottom}]
      [height=0.3cm,width=8cm,frame=off,bottomframe=on,offset=none,align={right,lohi}]
      {\tfxx \lettershortsender}}{
    \setlayerframed[firstpagelayer]
      [y=3.8cm,location={right,bottom}]
      [height=0.3cm,width=8cm,frame=off,bottomframe=off,offset=none,align={right,lohi}]
      {\tfxx \lettershortsender}}
  %% Addressee frame
  \setlayerframed[firstpagelayer]
    [y=4.1cm,location={right,bottom}]
    [height=3.6cm,width=8cm,frame=off,offset=none,align={right,top}]
    {
      \doiftextelse{\letterdisposal}{\vskip1.0ex\letterdisposal}{}
      \vskip1.5ex
      \letteraddressee
    }
  %% Sender frame
  \setlayerframed[firstpagelayer]
    [corner={right},y=4.1cm,location={left,bottom}]
    [height=4.6cm,width=\dimexpr(\senderkeywidth+\sendervalwidth),frame=off,offset=none,align={left,top}]	% [height=4.6cm,width=6.4cm,frame=off,offset=none,align={left,top}]
    {\setups{sendertablesetup}}
  %% Date field
  \setlayerframed[firstpagelayer]
    [corner={right},y=8.7cm,location={left,bottom}]
    [height=0.5cm,width=\dimexpr(\senderkeywidth+\sendervalwidth),align={left,top},frame=off,offset=none]	% [height=0.5cm,width=6.4cm,align={left,top},frame=off,offset=none]
    {
      \bTABLE
      \setupTABLE[frame=off]
      \setupTABLE[x][1][width=\senderkeywidth,align=left]	% width: std 1.85cm
      \setupTABLE[x][2][width=\sendervalwidth,align=right]	% width: std 4.55cm
      %\setupTABLE[y][maxheight=1ex]
      \bTR \bTD
        {\keystyle\translate[en=date,de=Datum]:}
      \eTD \bTD
        \valstyle
        \doiftextelse{\letterplace}
          {\letterplace,\translate[en=, de=]\ }{}
        \doiftextelse{\letterdate}{\letterdate}{\currentdate}	% \currentdate[weekday,month,day,{, },year]
      \eTD \eTR
      \eTABLE
    }
\stopsetups

%% Table with sender information
\startsetups sendertablesetup
  \bTABLE
  \setupTABLE[frame=off]
  \setupTABLE[x][1][width=\senderkeywidth,align=left]
  \setupTABLE[x][2][width=\sendervalwidth,align=right]
  \bTR \bTD \strut\doiftextelse{\lettersenderkeyone}  {\keystyle\lettersenderkeyone:}  {} \eTD \bTD \valstyle\lettersendervalone   \eTD \eTR
  \bTR \bTD \strut\doiftextelse{\lettersenderkeytwo}  {\keystyle\lettersenderkeytwo:}  {} \eTD \bTD \valstyle\lettersendervaltwo   \eTD \eTR
  \bTR \bTD \strut\doiftextelse{\lettersenderkeythree}{\keystyle\lettersenderkeythree:}{} \eTD \bTD \valstyle\lettersendervalthree \eTD \eTR
  \bTR \bTD \strut\doiftextelse{\lettersenderkeyfour} {\keystyle\lettersenderkeyfour:} {} \eTD \bTD \valstyle\lettersendervalfour  \eTD \eTR
  \bTR \bTD \strut\doiftextelse{\lettersenderkeyfive} {\keystyle\lettersenderkeyfive:} {} \eTD \bTD \valstyle\lettersendervalfive  \eTD \eTR
  \bTR \bTD \strut\doiftextelse{\lettersenderkeysix}  {\keystyle\lettersenderkeysix:}  {} \eTD \bTD \valstyle\lettersendervalsix   \eTD \eTR
  \bTR \bTD \strut\doiftextelse{\lettersenderkeyseven}{\keystyle\lettersenderkeyseven:}{} \eTD \bTD \valstyle\lettersendervalseven \eTD \eTR
  \bTR \bTD \strut\doiftextelse{\lettersenderkeyeight}{\keystyle\lettersenderkeyeight:}{} \eTD \bTD \valstyle\lettersendervaleight \eTD \eTR
  \bTR \bTD \strut\doiftextelse{\lettersenderkeynine} {\keystyle\lettersenderkeynine:} {} \eTD \bTD \valstyle\lettersendervalnine  \eTD \eTR
  \eTABLE
\stopsetups

%=============================================================================
%% First page header setups

\definelayer[firstheaderlayer][width=\makeupwidth,height=\logoboxheight,width=\overlaywidth]

%=============================================================================
%% Normal page header setups

\definelayer[normalheaderlayer][width=\makeupwidth,height=\normalheaderheight]

\startsetups normalheaderlayersetup
  \setlayerframed[normalheaderlayer]
    [corner={top,left},location={bottom,right}]
    [height=\normalheaderheight,width=\makeupwidth,frame=off,offset=none,align={high,middle}]
    {\letterheadertext}
\stopsetups

%=============================================================================
%% Footer setups

\definelayer[allpagefooterlayer][width=\makeupwidth,height=\footerheight]

\startsetups allpagefooterlayersetup
  \setlayerframed[allpagefooterlayer]
    [corner={right,bottom},location={left,top}]
    [height=\footerheight,width=\makeupwidth,frame=off,offset=none,align={low,middle}]
    {\letterfootertext}
\stopsetups

%=============================================================================
%% Folding marks on left

\startnotmode[nofold]
  \setupbackgrounds[rightpage][page][state=start,background=foldingmarkslayer]
\stopnotmode

\definelayer[foldingmarkslayer][state=repeat]

\startsetups foldingmarkslayersetup
  \setlayer[foldingmarkslayer][y=10.7cm, x=0.5cm,align={lohi,right}]{---}
  \setlayer[foldingmarkslayer][y=14.85cm,x=0.5cm,align={lohi,right}]{--}
  \setlayer[foldingmarkslayer][y=20.2cm, x=0.5cm,align={lohi,right}]{---}
\stopsetups

%=============================================================================
%% Commonly used letter parts

% Date; if not used, current date is inserted
\def\setdate#1{\def\letterdate{#1}}
% Place, for the date line
\def\place#1{\def\letterplace{#1}}
% Short sender information for address window in envelope
\def\shortsender#1{\def\lettershortsender{#1}}
% Order
\def\disposal#1{\def\letterdisposal{#1}}
% Address of receiver of the letter
\def\addressee#1{\def\letteraddressee{{#1}}}	% \let\crlf=\\ 
% Information about sender
\def\senderone#1#2{\def\lettersenderkeyone{#1}\def\lettersendervalone{#2}}
\def\sendertwo#1#2{\def\lettersenderkeytwo{#1}\def\lettersendervaltwo{#2}}
\def\senderthree#1#2{\def\lettersenderkeythree{#1}\def\lettersendervalthree{#2}}
\def\senderfour#1#2{\def\lettersenderkeyfour{#1}\def\lettersendervalfour{#2}}
\def\senderfive#1#2{\def\lettersenderkeyfive{#1}\def\lettersendervalfive{#2}}
\def\sendersix#1#2{\def\lettersenderkeysix{#1}\def\lettersendervalsix{#2}}
\def\senderseven#1#2{\def\lettersenderkeyseven{#1}\def\lettersendervalseven{#2}}
\def\sendereight#1#2{\def\lettersenderkeyeight{#1}\def\lettersendervaleight{#2}}
\def\sendernine#1#2{\def\lettersenderkeynine{#1}\def\lettersendervalnine{#2}}
% Subject line
\def\subject#1{{\bf #1}\vskip2ex}
% Signature: Name, Position
\def\greeting#1{\testpage[8]\vskip1ex{#1}}
% Signature: Name, Position
\def\signature#1{{\let\\=\crlf \vskip8ex\vtop{#1}}}
% Attachments included
\def\attachments#1{{\let\\=\crlf \vskip3ex{{\bf\translate[en=Attachments, de=Anlagen]:}\\ #1}}}

%% First header
%\def\resetfirstheaderlayer{\setuplayer[firstheaderlayer][state=reset]}
\def\addfirstheaderlayer[#1]#2{%
%  \setuplayer[firstheaderlayer][state=repeat]%
  \setlayer[firstheaderlayer][#1]{#2}%
  }

%% Header
\def\letterheadertext{}
\def\headercontent#1{\def\letterheadertext{#1}}
\def\resetheaderlayer{\setuplayer[normalheaderlayer][state=reset]}
\def\addheaderlayer[#1]#2{%
  \def\letterheadertext{}%
  \setuplayer[normalheaderlayer][state=repeat]%
  \setlayer[normalheaderlayer][#1]{#2}%
  }

%% Footer
\def\letterfootertext{\translate[en=page, de=Seite]~\pagenumber/\totalnumberofpages}
\def\footercontent#1{\def\letterfootertext{#1}}
\def\resetfooterlayer{\setuplayer[allpagefooterlayer][state=reset]}
\def\addfooterlayer[#1]#2{%
  \def\letterfootertext{}%
  \setuplayer[allpagefooterlayer][state=repeat]%
  \setlayer[allpagefooterlayer][#1]{#2}%
  }

%=============================================================================
\stopenvironment

%=============================================================================
\startmode[demo]

% Necessary, if you want to print folding marks only on odd pages
\setuppagenumbering[alternative={singlesided,doublesided}]

% \input letterstyle

\starttext
\letter{Example Letter}
%\setdate{(string)}
\place{Berlin}

\shortsender{My Name $\cdot$ My Street 123 $\cdot$ 12345 My Town}
\disposal{confidential}
\addressee{Mr. Example\\ Test Drive 99\| 98765 Other Town}

\senderone{tel.}{+49 30 12345678}
\sendertwo{email}{xyz@abc.com}

%\addfirstheaderlayer[corner={top,left},location={bottom,right}]{\framed[width=\overlaywidth,height=\logoboxheight,frame=off]{}}
\headercontent{\hfill test letter, page \pagenumber}
%\addheaderlayer[corner={top,left},location={bottom,right}]{}
\footercontent{From MyName\hfill To Mr. Example}
%\addfooterlayer[corner={bottom,right},location={top,left}]{}

\subject{What do you think about the Letterstyle?}

Dear Reader,

\dorecurse{11}{\input tufte\par}

\greeting{Best regards,}
\signature{My Name}

\attachments{The Letterstyle}

%-----------------------------------------------------------------------------
% Necessary to suppress emtpy last page in doublesided pagenumbering mode
\installpagebreakhandler{last}{}

\stoptext

\stopmode

Another Approach

Here is an alternative to the approach suggested by Holger. My university introduced a new official letterhead some months ago, and I was quite impressed to see that they even provided a LaTeX class for it. Of course, there was no ConTeXt support, so I decided to do it myself. My aim was merely to copy the official style, so my approach is far less fancy than the one before: you get a letter with a logo in the upper right corner, fields for information about the sender (assuming that the sender sits in a department of a university), and commands for the parts of a typical letter.

Instructions: copy the code below into a file, modify the generic information provided there to your needs, and save this file somewhere where ConTeXt can find it (the canonical place would be $HOMETEXMF/tex/context/third) as t-letterhead.tex. See below for usage instructions.

\protect

\setuppapersize[A4][A4] % or [letter][letter]; in that case, you'll have to fidget with the dimensions

\setuplayout[header=0mm,topspace=20mm,backspace=22mm,footer=0mm,width=160mm] % margins etc.

\enableregime[utf] % or whatever you prefer

\setupcolors[state=start] % in case you want any colored output

\mainlanguage[en] % or whatever you prefer

\setupbodyfont[modern,8pt] % this is the small bodyfont for the letterhead; we'll change to a bigger size for the actual letter later

\setuptabulate[before={\blank[0pt]},after={\blank[0pt]}] % there's a tabular, and I don't want any blank lines around it

\setuppagenumbering[state=stop] 

\definelayer[myletter][x=1mm,y=1mm,width=\paperwidth,height=22mm] % The elements of the letterhead are defined as layers. This first layer contains  the logo; you'll have to
\setlayer[myletter][x=104mm,y=11mm]{\externalfigure[Logo][width=56mm,height=20mm]}  %  supplyan image file yourself.

\definelayer[myuni][x=1mm,y=1mm,width=\paperwidth,height=24mm]  % Second layer: Small column, right-aligned, with name of university and your name, in a narrow column
\setlayer[myuni][x=110.5mm,y=42mm]{\framed[width=50mm,height=22mm,frame=off]{\lbox to  % below the logo.
  35mm{\ss Name\\ of My University \\ (My Town) \\
    \blank[line] \\ {\bf My Name} \\ Supreme Headmaster}}}

\definelayer[dept][x=1mm,y=1mm,width=\paperwidth,height=24mm] % Third layer, left-aligned, opposite layer 2. This column contains you contact information and the date.
\setlayer[dept][x=163mm,y=42mm]{\framed[width=40mm,height=22mm,frame=off]{\rbox
to 35mm{\ss Faculty of \\ Arts and Sciences \\
\blank[2*line] \\ Department of \\ High Energe Metaphysics\\
\blank[2*line]\\ 33 Main Street \\ Capital, DC 12345 \\ \starttabulate[|lw(4mm)|lw(36mm)|]
\NC Tel.: \NC (123) 456-7890 \NC\NR \NC Fax.: \NC (098) 7654-321 \NC\NR
\stoptabulate \\ Administrator: Highly Efficient \\
\starttabulate[|lw(4mm)|lw(36mm)|] \NC Tel.: \NC (012) 345-6789 \NC\NR
\stoptabulate \\ mymail@myaddress\\ www.my.website.edu \\ \blank[2*line]\\ Mytown,
\currentdate}}}

\definelayer[send][x=0mm,y=1mm,width=\paperwidth,height=15mm] % Fourth layer: one line, in fine print, that contains a short sender address; will be on top of the
\setlayer[send][x=9.4mm,y=44mm]{\framed[width=100mm,height=13mm,frame=off]{\ss  %  envelope's window.
    \vii {\bf My University} $\cdot$ My Name $\cdot$
    Dept. of Metaphysics $\cdot$ Capital, DC 12345}}

\startuniqueMPgraphic{fold}
fill unitsquare scaled 1mm withcolor blue ;
\stopuniqueMPgraphic    

\definelayer[foldingmarkslayer][state=repeat] % Fifth layer: the folding marks
\setlayer[foldingmarkslayer][y=101mm, x=11mm]{\useMPgraphic{fold}}
\setlayer[foldingmarkslayer][y=147mm, x=11mm]{\useMPgraphic{fold}}
\setlayer[foldingmarkslayer][y=55mm, x=11mm]{\useMPgraphic{fold}}

\setupbackgrounds [page][background={foldingmarkslayer,myletter,myuni,dept,send}] % Make all layers active for page.

\long\def\addressee#1{\strut\blank[23*medium]\switchtobodyfont[11pt]\setupwhitespace[none]#1} % Defines field for receiver's address and places it at right position.

\long\def\lettersubject#1{\blank[3*line]{\bf Re: #1}} % Subject line, in bold face.

\long\def\letteropening#1{\blank[line]#1} % opening...

\long\def\letterbody#1{\blank[line]\setupwhitespace[medium]#1} % the main body

\long\def\letterclosing#1{\blank[line]#1\blank[3*line]} % and the closing formula

\setupalign[right] % I prefer letters with a ragged right, but you don't have to...

\ss % I want the sans font for the entire letter, but of course you can change to \tt or \rm, if you want

\unprotect

Here's an example how this module can be used:

\usemodule[t-letterhead]

\starttext

\addressee{Prof.\crlf
Heinrich Seltsam\crlf
Dept. of Physics\crlf
University of Southern Wyoming \crlf
123 Einstein Str.\crlf
Scumbag, WY 76543}

\lettersubject{My New Letterstyle}

\letteropening{Estimated Colleague,}

\letterbody{\dorecurse{6}{\input tufte\par}}

\letterclosing{Sincerely Yours}

Larry

\stoptext

Any feedback welcome. I'm not sure if the \long\defs for the several parts of the letters are very elegant and would be grateful if some of the moew knowledgeable folks could suggest something better. But overall, I like the simplicity of this style.


Another Simple Style

%Context Environment for a basic Full Block Letter with Letterhead
\enableregime [utf]
\mainlanguage [en]

%==============Setup Page Layout======================
\def\MyPageNumber#1%
   {{--~Page #1 / \lastpage~--}}%use lastpage for total page count
\setuppagenumbering[location={footer,middle},command=\MyPageNumber]
\setuppapersize[letter][letter]
\usetypescript[palatino]
\setupbodyfont[palatino,10pt,rm]
\setuplayout[
   topspace=1.7in,
   backspace=1.5in,
   header=0mm,
   footer=.25in,
   width=5.5in,
   height=8.55in]
\useexternalfigure[logo][letterheadLG][width=\makeupwidth,height=.7in]
\setupbackgrounds
   [page]
   [background={Letterhead,NextPgHead},state=repeat]
\definelayer[Letterhead]
   [x=1.5in,y=1in,width=\makeupwidth,height=.7in,state=start]
\setlayerframed[Letterhead]
   [corner={top,left},location={bottom,right},frame=off]
   [offset=none,frame=off]
   {\externalfigure[logo]}
\definelayer[NextPgHead]
   [x=1.5in,y=1in,width=\makeupwidth,height=.7in,state=continue]


%==============Setup Paragraph Formatting==============
\setupwhitespace[big]
\setupindenting[no,medium,next]

%=================Define Letter Elements==================

\defineblank[FourLines][4*line,flexible]
\defineblank[OneLine][1*line,flexible]

\def\Regarding#1{\setgvariables[Letter][val={Re: #1}]Re: #1}
\def\RecNameVal{}
\def\RecName#1{
   \def\RecNameVal{#1}
   \setlayerframed[NextPgHead]
      [corner={top,left},location={bottom,right},frame=off]
      [offset=none,frame=off]
      {\framed[frame=off,width=\makeupwidth,height=.7in,align={right,high}]%
         {{\setupinterlinespace \RecNameVal\par
         \setupinterlinespace\date\par
         \setupinterlinespace\getvariable{Letter}{val}\par}}}
   #1}

\long\def\MailingNote#1{\WORD{#1}\par}%
\long\def\Disposition#1{\WORD{#1}}%
\define[1]\Opening{#1:\blank[OneLine]}%
\define[1]\Closing{#1,\blank[FourLines]}%
\define[1]\Signature{#1\blank[OneLine]}%
\define[1]\Enclosures{\doifelse{#1}{1}{Enclosure}{Enclosures: #1}\blank[OneLine]}%
\definedescription[CC][location=left,distance=-.75in]

\definestartstop[Sender][before={\startlines},after={\stoplines\blank[FourLines]}]
\definestartstop[Notes][before={\startlines},after={\stoplines\blank[OneLine]}]
\definestartstop[Recipient][before={\startlines},after={\stoplines\blank[OneLine]}]
\definestartstop[Body][before={\startlines},after={\stoplines\blank[OneLine]}]


%=============Define Quotes====================
%just use \Qt{} and all nesting should be taken care of
\definedelimitedtext[Qt][quotation]
\setupdelimitedtext
  [Qt]
  [1]
  [left={\symbol[leftquotation]},
   right={\symbol[rightquotation]}]

\setupdelimitedtext
  [Qt]
  [2]
  [left={\symbol[leftquote]},
   right={\symbol[rightquote]}]

\setupdelimitedtext
  [Qt]
  [3]
  [left={\symbol[leftquotation]},
   right={\symbol[rightquotation]}]

%To create blockquotes use \startextract \stopextract
\defineblank[ExtractDistance][3pt]
\definestartstop[Extract][
   style=italic,
   before={\blank[ExtractDistance]
      \setupnarrower[left=1.5pc,right=1.5pc]
      \startnarrower[left,right]
      \noindent},
   after={\stopnarrower
      \blank[ExtractDistance]
      \indenting[next]}]%Don't indent the immediately following paragraph, but do indent later ones.

%==================Define Enumerations===========================
\defineitemgroup[Outline][5]%Use with \startOutline ... \item ... \stopOutline
\setupitemgroup[Outline][1][R]%First level, Roman Numerals
\setupitemgroup[Outline][2][A]%Second Level, A,B,C etc.
\setupitemgroup[Outline][3][n]%Third level, Numberd
\setupitemgroup[Outline][4][r][left=(,right=),stopper=]%Fourth level, lowercase roman
\setupitemgroup[Outline][5][m][left=(,right=),stopper=]%Fifth level, lowercase numbered

\defineitemgroup[Bullet][5]%Use with \startBullet ... \item ... \stopBullet
\setupitemgroup[Bullet][1][1]%First level
\setupitemgroup[Bullet][2][2]%Second Level
\setupitemgroup[Bullet][3][5]%Third level
\setupitemgroup[Bullet][4][1]%Fourth level
\setupitemgroup[Bullet][5][2]%Fifth level

And how to use it:

\environment basicLetterEnv
\starttext
\startSender
Company Name
Your Name, Your Title
1234 AnyStreet
City, ST 75098
Phone: 123-456-7890
Email: asdf@asdf.com
Web: www.asdf.com
\date
\Regarding{The subject of this letter}
\stopSender

\startNotes
\MailingNote{Certified Mail}%Mailing Notations:Certified,AirMail, Priority...
\Disposition{Confidential}%Disposition: Confidential, personal ...
\stopNotes

\startRecipient
\RecName{First Last Name}
Company Name
4567 ThisStreet
City, US 12345
\stopRecipient

\Opening{Dear First Name}

\startBody
\dorecurse{5}
  {Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras tellus.
   Proin fringilla euismod elit. Donec eleifend purus sed eros. Fusce quis
   diam. Donec euismod nisl non dui. Donec eu odio. Nam congue risus in
   eros commodo elementum. Duis dolor. Etiam luctus mauris ut mi. Vivamus
   vitae sem eu justo pretium ullamcorper. Aliquam ac mauris posuere justo
   molestie interdum. Nullam eleifend leo quis justo. Suspendisse tortor
   risus, porta a, hendrerit in, facilisis at, lectus.\par}
\stopBody

\Closing{Sincerely}


\Signature{Your Name, General Counsel}

\Enclosures{1}
\startCC{CC:}
A Name\par
Another Name\par
File
\stopCC

\stoptext

Letterhead

The following style was presented in the PracTeX Journal by Joseph Hogg, you find the article under the following link:

% Context file for letterhead
\setuppapersize[letter][letter]
\setuplayout[height=9in,backspace=80pt,location=middle]
\setupbodyfont[serif,12pt] \setupwhitespace[big]
\setupcolors[state=start]
% Set up addressee here, From and Date
\define\Toperson{A. U. Thor}
\define\Totitle{Editor}
\define\Tocompany{Great \TeX\ Journal}
\define\Tostreet{P. O. Box 3.1415926}
\define\TocityStateZip{\TeX town, 67890-12345}
\define\Tocountry{USA}
\define\Fromperson{Ben Lee User}
\define\Mydate{\currentdate}
% End addressee, From and Date
\setupheader[state=none] \setupfooter[state=empty]
\setupfootertexts[{\ssx {\Mydate} --- {\em from}
      {\Fromperson} {\em to} {\Toperson} --- page {\pagenumber}
      of {\totalnumberofpages}}]
%\showframe
%\showboxes
%\showsetups

\starttext
% Heading
{\ssb Ben Lee User} \hfill {\ssx voice: (123) 456-7890}\crlf {\ssx P. O.
Box 2.718281} \hfill {\ssx fax: (123) 456-7891}\crlf
{\ssx Punktown, 12345-67890} \hfill {\ssx email: ben.lee.user@tex.edu}%
\textrule \blank[10*medium]
% Address
\Toperson\crlf \Totitle\crlf \Tocompany\crlf \Tostreet\crlf
\TocityStateZip%\crlf
%\Tocountry
\blank[8*medium] \textrule
% Letter
\hfill\Mydate \blank[2*big]

Dear Thor:

Here's a setup for a business or personal letter that produces a
letterhead and the addressee's information on the letter. This allows
the sender to use envelopes with windows to avoid separately addressing
envelopes. I usually print a dozen or so of these envelopes with my
return address in advance.

Vertical spacing of addresses and other features is controlled by the
\type{\blank[..]} command. I experiment with this depending on the
number of lines in the address or where I want to place horizontal
lines.

% Jump to a new page to see the footer
I'll jump to a new page to illustrate the footer for the second and
subsequent pages. \page

There is no footer on the first page and no page number. Many letters
are only one page long. But on those with two or more pages, it is
useful to have page numbers and other identifying information.

\blank[2*big]

Very truly yours,

[signature space]

\blank[4*big]

Ben Lee User

\stoptext

Thanks to all those who contributed the original suggestions, they have been a great inspiration!

Thomas

Modern CV like cover letter

This example is separated into 2 files : the environment file and a letter sample. Layout was made based on swiss standards for cover letters.

In the letter it is possible to specify the following options :

  • full name of recipient (not to be provided if unknown)
  • gender of recipient (not to be provided if full name wasn't given)
  • if the sender address has to be put in an international format

Here is the letter sample :

% ENGLISH, TO MALE RECIPIENT
\mainlanguage[en]
\def\fullname{John Smith}
\def\gender{male}

% % FRENCH, TO FEMALE RECIPIENT
% \mainlanguage[fr]
% \def\fullname{Jeanne Petit}
% \def\gender{female}

% % ENGLISH, TO UNKNOWN RECIPIENT, INTERNATIONAL
% \mainlanguage[en]
% \define\international

\environment {cover-letter-env}

\starttext

\startletter[toaddress={Enterprise \\ Street \\ City \labeltext{date}},
             subject={Application for the role of \quote{C++ embedded systems engineer} posted on Jobup}]

\setupindenting[yes,small]

I am an electronic engineer specialized on software development of embedded systems and your job offer caught my attention.

...

Thank you in advance for your time and consideration and blablabla. I look forward to hearing from you.

\stopletter

\stoptext

And, finally, here is the environment file :

\def\secondwordtmp#1 #2\relax{#2}
\def\secondword#1{\expandafter\secondwordtmp#1\relax}

\startenvironment cover_letter

  \usemodule[letter]
  \useletterstyle[swiss]
  \usesymbols[mvs]
  \setupsymbolset[martinvogel 2]

  \def\lastname{\secondword{\fullname}}

  \setuplabeltext [en] [greetings={\rightaligned{Yours sincerely,}}]
  \setuplabeltext [fr] [greetings={}]

  \doifdefinedelse {fullname}
    {\def\to_name{\bold{\labeltext{\gender:title} \fullname{}}} % hack temp
     \setuplabeltext [en] [male:title=Mr, female:title=Ms,
			   date={\blank[7mm]{\em \currentdate}}]
     \setuplabeltext [en] [opening={{Dear \labeltext{\gender:title} \lastname{},}}]
     \setuplabeltext [fr] [male:title=M., female:title=Mme,
			   male:longtitle=Monsieur, female:longtitle=Madame,
			   date={\blank[7mm]{\em Fribourg, le \currentdate}}]
     \setuplabeltext [fr] [opening={{\labeltext{\gender:longtitle},}}]}
    {\setuplabeltext [en] [HR={Human Resources}]
     \setuplabeltext [fr] [HR={Ressources humaines}]
     \def\to_name{\bold{\labeltext{HR}}}
     \setuplabeltext [en] [opening={{Dear Hiring Manager,}}]
     \setuplabeltext [fr] [opening={{Madame, Monsieur,}}]}

  \def\CH{}
  \setuplabeltext [country={}]
  \doifdefined {international}
    {\setuplabeltext [en] [country={{, Switzerland}}]
     \setuplabeltext [fr] [country={{, Suisse}}]
     \def\CH{CH-}}

  \doif {\currentlanguage} {fr}
    {\setcharacterspacing[frenchpunctuation]}

  \setupbodyfont[sans, 12pt]
  \setupwhitespace[big]

\setuplettersection
  [reference,date,specialnotation,closing]
  [leftmargin=.55\textwidth]

  \setupletterlayer[head][alternative=left,
                          y=16mm,
                          style=slanted,
                          color=darkgray]
  \setupletterlayer[backaddress][state=stop]

  \setupletterlayer[address][preset=lefttop,
                             x=.7\textwidth]

  \setupletterlayer[reference][y=7cm]
  \setuplettertext[date=]

  \setupletterlayout[firstpage][topspace=9.5cm]

  \setupletterdescription[enclosure,postscript][headstyle=boldslanted]
  \setuplettersection[appendices][style=slanted,color=darkgray,spacebefore={samepage,5*line}]
  \setupletterstyle[fromname,toname][style=bold] % Bug : ne fonctionne pas pour toname !
  \setuplettertext[postscript={\color[black]{PS: }}]

  \setupletter
    [fromname={My Name},
    fromaddress={Street 1\\\CH{}1700 My-City\labeltext{country}},
    fromphone={\symbol[Mobilefone] +41 98 765 43 21\\\symbol[Telephone] +41 12 345 67 89},
    frommail={\symbol[Letter] my_email@address.com},
    toname={\to_name{}},
    opening={\labeltext{opening}},
    date=,
    closing={\labeltext{greetings}},
    signature={\bold{My Name}}]

\stopenvironment

And here is the PDF document generated after compilation: File:modern-cv-cover-letter.pdf.

Remark : there are still 1 or 2 hacks in the environment file, but I don't know how to make them better as I am not very experimented with ConTeXt, TeX and the use of the letter module.

Jonas Baggett