%D \module %D [ file=default, %D version=2008.10.27, %D title=\CONTEXT\ Letter Interface, %D subtitle=Default Interface, %D author=Wolfgang Schuster, %D date=\currentdate, %D copyright=Wolfgang Schuster, %D email=schuster.wolfgang@googlemail.com, %D license=Public Domain] %M \loadsetups[letter.xml] %D \subject{Constants and Variables} \unprotect %D I define a few additional constants and variables, I will move them %D to the base some time. \startinterface all \setinterfaceconstant {opening} {opening} \setinterfaceconstant {content} {content} \setinterfaceconstant {closing} {closing} \setinterfaceconstant {signature} {signature} \setinterfaceconstant {dispatch} {dispatch} \setinterfaceconstant {appendices} {appendices} \setinterfaceconstant {fromaddress} {fromaddress} \setinterfaceconstant {frombank} {frombank} \setinterfaceconstant {frommail} {frommail} \setinterfaceconstant {fromfax} {fromfax} \setinterfaceconstant {fromlogo} {fromlogo} \setinterfaceconstant {fromname} {fromname} \setinterfaceconstant {fromphone} {fromphone} \setinterfaceconstant {fromurl} {fromurl} \setinterfaceconstant {toname} {toname} \setinterfaceconstant {toaddress} {toaddress} \setinterfaceconstant {enclosure} {enclosure} \setinterfaceconstant {copy} {copy} \setinterfaceconstant {postscript} {postscript} \setinterfaceconstant {attention} {attention} \setinterfaceconstant {distribution} {distribution} \setinterfaceconstant {salutation} {salutation} \setinterfaceconstant {addressee} {addressee} \stopinterface \startinterface all \setinterfacevariable {e} {e} \setinterfacevariable {data} {data} \setinterfacevariable {sender} {sender} \setinterfacevariable {dispatch} {dispatch} \setinterfacevariable {enclosure} {enclosure} \setinterfacevariable {copy} {copy} \setinterfacevariable {nobreak} {nobreak} \setinterfacevariable {endgraf} {endgraf} \setinterfacevariable {memo} {memo} \setinterfacevariable {addressee} {addressee} \setinterfacevariable {french} {french} \setinterfacevariable {simplified} {simplified} \setinterfacevariable {fullblock} {fullblock} \setinterfacevariable {hanging} {hanging} \setinterfacevariable {modified} {modified} \stopinterface %D \subject{Reference line} %D %D Dimen value to save the height of the reference line. \newdimen\letter!height!reference %D We come now to the new macros defined in this file, they are meant to place the %D information about date, phone number and more information. You could select on of %D the alternatives with \type{\setupletter[alternative=...]}. %D %D I define here only what I need myself but you're free to define your own %D alternatives but try to avoid to use the same names as I do. You could also send %D me your alternatives and I will include them. %D %D This is the first alternative a, it use the values from the style file without any %D change, this is the normal layout for a DIN letter. \long\def\doformatreferencelista#1% {\def\\{\egroup\hbox\bgroup}% \setupinterlinespace\hbox\bgroup#1\egroup\par} \long\def\formatreferencelista#1% {\bgroup \convertargument#1\to\ascii \vbox {\vbox{\doattributes{\????ld\ascii}\c!titlestyle\c!titlecolor {\doformatreferencelista{\labeltext{\v!letter:\ascii}}}} \vtop{\doattributes{\????ld\ascii}\c!textstyle\c!textcolor {\doformatreferencelista{\lettervalue\ascii}}}}% \egroup \hfill} \setvalue{\v!letter:\v!reference:\v!a}% {\setbox\scratchbox\hbox\!!to\hsize {\getcommacommandsize[\@@@@ldlist]% \@@@@ldreference? \ifnum\commalistsize<\plustwo\hfill\fi \processcommacommand[\@@@@ldlist]\formatreferencelista\unskip}% \global\letter!height!reference\dimexpr\ht\scratchbox+\dp\scratchbox\relax \box\scratchbox} \startsetups[letter:reference:\v!a] \setupletterstyle [\v!reference] [\c!hoffset=\backspace, \c!voffset=\dimexpr\letterstylevalue\v!address\c!voffset+\letterstylevalue\v!address\c!height+\plusthree\c!mm\relax, \c!width=\textwidth] \setupletterstyle [\v!firstpage] [\c!topspace=\dimexpr\letterstylevalue\v!reference\c!voffset+\letter!height!reference+\plustwo\lineheight\relax] \stopsetups %D This is the alternative b, you could use it if you want to place the information %D in a infoblock not just a simple line, it is also better suited if you want to %D place more infomration. \long\def\formatreferencelistb#1% {\bgroup \doifelse{#1}\v!line {\blank[\v!line]} {\hbox {\doattributes{\????ld#1}\c!titlestyle\c!titlecolor {\labeltext{\v!letter:#1}\lettervalue{#1\c!separator}}% \doattributes{\????ld#1}\c!textstyle\c!textcolor {\lettervalue{#1}}}}% \egroup} \setvalue{\v!letter:\v!reference:\v!b}% {\vtop % why not \vbox? {\processcommacommand[\@@@@ldlist]\formatreferencelistb}} \startsetups[letter:reference:\v!b] \setupletterstyle [\v!reference] [\v!layer] [\c!hoffset=125.7mm, \c!voffset=\letterstylevalue\v!address\c!voffset] \setupletterstyle [\v!reference] [\v!frame] [\c!width=\dimexpr\paperwidth-\letterstylevalue{\v!reference\v!layer}\c!hoffset-\cutspace\relax, \c!height=\v!fit] \stopsetups %D The third alternative c could used, if you want to place just a single line %D with text and nothing more, like your place and the date. You need only the %D following two lines in your document. %D %D \starttyping %D \setupletter[alternative=c,list=reference] %D \setupletter[reference=\rightaligned{Place, \currentdate}] %D \stoptyping \long\def\formatreferencelistc#1% {\bgroup \convertargument#1\to\ascii \doattributes{\????ld\ascii}\c!textstyle\c!textcolor {\lettervalue\ascii}% \egroup} \setvalue{\v!letter:\v!reference:\v!c}% {\hbox\!!to\hsize {\processcommacommand[\@@@@ldlist]\formatreferencelistc}} \startsetups[letter:reference:\v!c] \setups[letter:reference:\v!a] \stopsetups %D Alternative d, text is placed in a block like alternative bit the text %D is put in a table. \long\def\doformatreferencelistd#1% {\doifelse{#1}\v!line {\NC\NC\NC\NR} % ugly but working {\NC \doattributes{\????ld#1}\c!titlestyle\c!titlecolor {\labeltext{\v!letter:#1}\lettervalue{#1\c!separator}}% \NC\doattributes{\????ld#1}\c!textstyle\c!textcolor{\lettervalue{#1}} \NC\NR}} \def\formatreferencelistd#1% {\appendtoks\doformatreferencelistd{#1}\to\scratchtoks} \setvalue{\v!letter:\v!reference:\v!d}% {\vtop % why not \vbox? {\scratchtoks\emptytoks \processcommacommand[\@@@@ldlist]\formatreferencelistd \setuptabulate[\c!before=,\c!after=]% \starttabulate[|l|l|] \the\scratchtoks \stoptabulate}} \startsetups[letter:reference:\v!d] \setupletterstyle [\v!reference] [\v!layer] [\c!hoffset=125.7mm, \c!voffset=\letterstylevalue\v!address\c!voffset] \setupletterstyle [\v!reference] [\v!frame] [\c!width=\dimexpr\paperwidth-\letterstylevalue{\v!reference\v!layer}\c!hoffset-\cutspace\relax, \c!height=\v!fit] \stopsetups %D Alternative e, nearly the same as a but you could control the width of the %D fields with the width key for \tex{setupletter}. \long\def\doformatreferenceliste#1% {\def\\{\egroup\hbox\bgroup}% \setupinterlinespace\hbox\bgroup#1\egroup\par} \long\def\formatreferenceliste#1% {\bgroup \convertargument#1\to\ascii \doifelselettervalue{\ascii\c!width} {\hbox\!!to\lettervalue{\ascii\c!width}} {\hbox}% {\vbox {\vbox{\doattributes{\????ld\ascii}\c!titlestyle\c!titlecolor {\doformatreferenceliste{\labeltext{\v!letter:\ascii}}}} \vtop{\doattributes{\????ld\ascii}\c!textstyle\c!textcolor {\doformatreferenceliste{\lettervalue\ascii}}}}}% \egroup} \setvalue{\v!letter:\v!reference:\v!e}% {\hbox\!!to\hsize {\processcommacommand[\@@@@ldlist]\formatreferenceliste\hss}} \startsetups[letter:reference:\v!e] \setups[letter:reference:\v!a] \stopsetups %D The alternative \mono{none} could be used to disable the reference. %D %D The advantage is to change only the list alternative to nothing, another %D method to get this result to use alternative c and remove all values from %D the reference but the none key is better. \resetvalue{\v!letter:\v!reference:\v!none} \startsetups[letter:reference:\v!none] % Use the topspace value from the style \stopsetups %D \subject{Setup commands} %D %D \macros %D {setupletter,setlettervalue} %D %D The values for the letter field is set eitheir either with \tex{setupletter} %D or with \tex{setlettervalue}, the first commands allows you to input the data %D in a key-val list while the second is only able to accept a single value. %D %D The first definition for \tex{setupletter} was defined in \filename{t-letter.tex} %D and used till \date[d=20,m=4,y=2008] but I decided to replace it by a simpler %D method to avoid a few lines of code in my letter and the letter versions from %D \date[d=21,m=4,y=2008] will use the new user interface. The old definition from %D \filename{t-letter.tex} is now oveloaded in will eventually disappear. %D %D The second command to set \tex{setlettervalue} was developed as a alternative %D method to set values for the letter, I implemnted the command at the same time %D as I changed the user interface. %D %D Untill the old definition for \tex{setupletter} remains in \filename{t-letter.tex} %D I have to redefine also \tex{lettervalue}, \tex{doiflettervalue} and %D \tex{doifelselettervalue} because the old and new definitions differe in the %D number of arguments but the new definition will move to the core file as soon %D as I replace \tex{setupletter} in the core. %D \starttyping %D \def\setupletter %D {\dodoubleempty\dosetupletter} %D %D \def\dosetupletter[#1][#2]% %D {\ifsecondargument %D \dodosetupletter[#1][#2]% %D \else %D \dodosetupletter[#1][]% %D \fi} %D %D \def\dodosetupletter[#1][#2]% %D {\doifelsenothing{#2} %D {\getparameters[\????ld][#1]} %D {\def\dododosetupletter##1% %D {\getparameters[\????ld##1][#2]}% %D \processcommalist[#1]\dododosetupletter}} %D %D \def\lettervalue#1% %D {\csname\????ld#1\endcsname} %D %D \def\doiflettervalue#1% %D {\doiftextelse{\lettervalue{#1}} %D \firstofoneargument %D \gobbleoneargument} %D %D \def\doifelselettervalue#1% %D {\doiftextelse{\lettervalue{#1}} %D \firstoftwoarguments %D \secondoftwoarguments} %D %D \definecomplexorsimple\setlettervalue %D %D \def\complexsetlettervalue[#1]#2% %D {\setvalue{\????ld#1}{#2}} %D %D \def\simplesetlettervalue#1#2% %D {\setvalue{\????ld#1}{#2}} %D \stoptyping %D \subject{Letter environment} %D %D \macros %D {startletter} %D %D The main macro in this file, it is used to write the letter content. %D It is also possible to set the address and a few other values like %D the opening and closing with the optional argument, the values are %D local in this case and not global like the values you could set with %D \tex{setupletter}. %D %D \showsetup{startletter} \def\startletter {\bgroup\dodoubleempty\dostartletter} \def\dostartletter[#1][#2]% {\ifsecondargument \setupletter[#1]% \doifundefinedelse{\????ld\????ld#2} {\setvalue{\????ld\c!toaddress}{#2}} {\setvalue{\????ld\c!toaddress}{\getvalue{\????ld\????ld#2}}}% \else\iffirstargument \doifassignmentelse{#1} {\setupletter[#1]} {\doifundefinedelse{\????ld\????ld#1} {\setvalue{\????ld\c!toaddress}{#1}} {\setvalue{\????ld\c!toaddress}{\getvalue{\????ld\????ld#1}}}}% \fi\fi \def\stopletter {\setups[letter:place]\egroup \setupsubpagenumber[\c!state=\@@@@lsoptionstate]}% \dostartbuffer[lettercontent][startletter][stopletter]} %D Patched version of the \tex{flushbufferline} macro for \MKII, %D the changes are definition as long and removing of \tex{string} %D in the argument of the last write block. \long\def\flushbufferline#1% {\iftmpblockstarted \ifsegmentatebuffer \ifemptybufferline \immediate\write\tmpblocks{\string\stopbufferparagraph }% \immediate\write\tmpblocks{\string\startbufferparagraph}% \else \immediate\write\tmpblocks{#1}% \fi \else \immediate\write\tmpblocks{#1}% \fi \else \doifsomething{#1} {\tmpblockstartedtrue \immediate\write\tmpblocks{#1}}% \fi} %D \macros %D {startlettercontent} %D %D The letter content is saved in the value content, although I could %D place it in the corresponding I prefer this solution because you could %D now use it in your own macros and redefine the content setups to your %D own wishes. \setupletter [\c!content={\getbuffer[lettercontent]}] \def\startlettercontent {\dostartbuffer[lettercontent][startlettercontent][stoplettercontent]} %D After the definition of all macros I could now put the content %D in the corresponding setups, this is only important if you want %D to define your own layout for header, address etc. \setvalue{\v!letter:\v!head:\v!a}% {\lettervalue\c!fromname \doiflettervalue\c!fromname\\ \lettervalue\c!fromaddress} \startsetups[letter:head] \def\\{\letterstylevalue\v!head\c!separator}% \executeifdefined{\v!letter:\v!head:\@@@@lsheadalternative}{\getvalue{\v!letter:\v!head:\v!a}}% \stopsetups \startsetups[letter:foot] \executeifdefined{\v!letter:\v!foot:\@@@@lsfootalternative}\donothing \stopsetups \startsetups[letter:nexthead] \executeifdefined{\v!letter:\v!nexthead:\@@@@lsnextheadalternative}\donothing \stopsetups \startsetups[letter:nextfoot] \executeifdefined{\v!letter:\v!nextfoot:\@@@@lsnextfootalternative}\donothing \stopsetups \setvalue{\v!letter:\v!header:\v!fullblock}% {\hbox\!!to\hsize {\rlap{\lettervalue\c!toname}% \midaligned{\pagenumber}% \llap{\framed[\c!frame=\v!off,\c!location=\v!top,\c!align=\v!left] {\lettervalue\c!date \\ \lettervalue\c!reference}}}} \setvalue{\v!letter:\v!header:\v!hanging}% {\hbox\!!to\hsize {\framed[\c!frame=\v!off,\c!location=\v!top,\c!align=v!right] {\lettervalue\c!toname \\ \lettervalue\c!date \\ \lettervalue\c!reference \\ \labeltext{page}\pagenumber}}\hss} \copycsname\v!letter:\v!header:\v!modified\endcsname\csname\v!letter:\v!header:\v!hanging\endcsname \startsetups[letter:header] \executeifdefined{\v!letter:\v!header:\@@@@lsheaderalternative}\donothing \stopsetups \startsetups[letter:footer] \executeifdefined{\v!letter:\v!footer:\@@@@lsfooteralternative}\donothing \stopsetups %D \subject{Addressee field} %D %D The address field is separated into two different fields. %D The upper field is meant for dispatch information, the official height %D in germany is 3 lines but this would lead to different heights dependent %D of the font size and the fonts own height. The lower field contains the %D name and address of the receiver and has a height of 6 lines in germany. %D This value will lead to the same problem as the upper field, because the %D whole address field has a fixed height and both field should fit into %D this space. I solved this problem by assinging the upper field 1/3 of the %D address height and the lower field 2/3 of the address height. %D %D If you hace problem to put all information in the limited space you could %D try to reduce the font size or reduce the interlinespace in the field. \presetlocalframed[\????ls\v!dispatch] \presetlocalframed[\????ls\v!addressee] \startsetups[letter:place:dispatch] \localframed [\????ls\v!dispatch] {\doadaptleftskip {\letterstylevalue\v!dispatch\c!leftmargin}% \doadaptrightskip{\letterstylevalue\v!dispatch\c!rightmargin}% \doattributes{\????ls\v!dispatch}\c!style\c!color{\setups[letter:address:dispatch]}} \stopsetups \startsetups[letter:place:addressee] \localframed [\????ls\v!addressee] {\doadaptleftskip {\letterstylevalue\v!addressee\c!leftmargin}% \doadaptrightskip{\letterstylevalue\v!addressee\c!rightmargin}% \doattributes{\????ls\v!addressee}\c!style\c!color{\setups[letter:address:content]}} \stopsetups \setvalue{\v!letter:\v!address:\v!a}% {\doif\@@@@lsoptiondispatch \v!yes{\setups[letter:place:dispatch]}% \doif\@@@@lsoptionaddressee\v!yes{\setups[letter:place:addressee]}} \startsetups[letter:address] \offinterlineskip\vskip-\lineheight \executeifdefined{\v!letter:\v!address:\@@@@lsaddressalternative}{\getvalue{\v!letter:\v!address:\v!a}}% \stopsetups \startsetups[letter:address:dispatch] \lettervalue\c!dispatch \stopsetups \startsetups[letter:address:content] \def\\{\letterstylevalue\v!address\c!separator}% \lettervalue\c!toname \doiflettervalue\c!toname\\ \lettervalue\c!toaddress \stopsetups %D The following setups shouldn't be changed ar you will loose information %D in the output. %D %D The reference line is choosen with the alternative key or if you set %D a not defined alternative the definition a is choosen. \startsetups[letter:reference] \executeifdefined{\v!letter:\v!reference:\@@@@lsreferencealternative}{\getvalue{\v!letter:\v!reference:\v!a}} \stopsetups \resetvalue{\v!letter:\v!location:\v!a} \setvalue{\v!letter:\v!location:\v!french}% {\lettervalue\c!place \doiflettervalue\c!place{\lettervalue{\c!place\c!separator}}% \lettervalue\c!date} \startsetups[letter:location] \executeifdefined{\v!letter:\v!location:\@@@@lslocationalternative}{\getvalue{\v!letter:\v!location:\v!a}} \stopsetups \startsetups[letter:title] \doifelselettervalue\c!title {\lettervalue\c!title} {\doiflettervalue\c!attention {\labeltext{\v!letter:\c!attention}\lettervalue\c!attention}} \stopsetups \startsetups[letter:subject] \labeltext{\v!letter:\c!subject}\lettervalue\c!subject \stopsetups \setvalue{\v!letter:\v!opening:\v!a}% {\doifelselettervalue\c!opening {\lettervalue\c!opening} {\doiflettervalue\c!salutation {\lettervalue\c!salutation}}} \setvalue{\v!letter:\v!opening:\v!french}% {\ExpandSecondAfter\doifsomething{\letterstylevalue\v!option\c!indenting} {\setupindenting[\@@@@lsoptionindenting]}% \getvalue{\v!letter:\v!opening:\v!a}} \startsetups[letter:opening] \executeifdefined{\v!letter:\v!opening:\@@@@lsopeningalternative}{\getvalue{\v!letter:\v!opening:\v!a}} \stopsetups \startsetups[letter:content] \lettervalue\c!content \stopsetups %D \subject{Closing and appendices} %D %D It is possible to attach a signature to the closing command, before the signature %D a skip is inserted but only if the the signature key has a value. The height of the %D closing environment itself has a height of 4 lines to provide a free space for your %D own handwritten signature and to have a little bit space between the closing text %D and the appendices. \setvalue{\v!letter:\v!closing:\v!a}% {\lettervalue\c!closing \doiflettervalue\c!signature{\letterstylevalue\v!closing\c!inbetween}% \lettervalue\c!signature} \setvalue{\v!letter:\v!closing:\v!french}% {\ExpandSecondAfter\doifsomething{\letterstylevalue\v!option\c!indenting} {\setupindenting[\@@@@lsoptionindenting,\v!first]}% \lettervalue\c!closing \doiflettervalue\c!signature{\letterstylevalue\v!closing\c!inbetween}% \raggedcenter\doadaptleftskip{.5\textwidth}% quick and dirty \lettervalue\c!signature\endgraf} \setvalue{\v!letter:\v!closing:\v!simplified}% {\doiflettervalue\c!signature{\letterstylevalue\v!closing\c!inbetween}% \lettervalue\c!signature} \startsetups[letter:closing] \def\\{\letterstylevalue\v!closing\c!separator}% \executeifdefined{\v!letter:\v!closing:\@@@@lsclosingalternative}{\getvalue{\v!letter:\v!closing:\v!a}}% \stopsetups \startsetups[letter:appendices] \let\\\crlf \doflushletterdescription \stopsetups \dodefineletterdescription[\v!enclosure] \startsetups[letter:enclosure] \processaction [\lettervalue\c!enclosure] [ \v!empty=>\vrule\!!height\zeropoint\!!depth\zeropoint\!!width\hsize\relax\ifvmode\nowhitespace\fi, \s!unknown=>\lettervalue\c!enclosure] \stopsetups \dodefineletterdescription[\v!copy] \startsetups[letter:copy] \processaction [\lettervalue\c!copy] [ \v!empty=>\vrule\!!height\zeropoint\!!depth\zeropoint\!!width\hsize\relax\ifvmode\nowhitespace\fi, \s!unknown=>\lettervalue\c!copy] \stopsetups \dodefineletterdescription[\v!postscript] \startsetups[letter:postscript] \processaction [\lettervalue\c!postscript] [ \v!empty=>\vrule\!!height\zeropoint\!!depth\zeropoint\!!width\hsize\relax\ifvmode\nowhitespace\fi, \s!unknown=>\lettervalue\c!postscript] \stopsetups \setvalue{\v!letter:\v!backaddress:\v!yes}% {\lettervalue\c!fromname \doiflettervalue\c!fromaddress\\ \lettervalue\c!fromaddress} \resetvalue{\v!letter:\v!backaddress:\v!no} \setvalue{\v!letter:\v!backaddress:\v!auto}% {\doifelselettervalue\c!backaddress {\lettervalue\c!backaddress} {\lettervalue\c!fromname \doiflettervalue\c!fromaddress\\ \lettervalue\c!fromaddress}} \startsetups[letter:backaddress] \def\\{\letterstylevalue\c!backaddress\c!separator}% \executeifdefined{\v!letter:\v!backaddress:\@@@@lsbackaddressalternative}{\getvalue{\v!letter:\v!backaddress:\v!no}}% \stopsetups %D To prevent a pagebreak between the last line of the text and %D the siganture a nonbreakable vertical space is necessary. %D The vertical space is inserted in the style file with the normal %D before and after commands where we control the distance between %D the elements. \defineblankmethod [\v!nobreak] {\penalty\plustenthousand} \defineblankmethod [\v!endgraf] {\endgraf} %D \subject{Additional settings} %D %D I set alternative a as default value for alternative, the only content %D is the date with a label. f you dont want a label choose alternative c %D or change the label. \startsetups[letter:optimize] \setbox\scratchbox\hbox % trial typesetting to get the heigth of the reference line {\executeifdefined{\v!letter:\v!reference:\@@@@lsreferencealternative}{\getvalue{\v!letter:\v!reference:\v!a}}} %\setups[letter:reference:\@@@@lsreferencealternative] \stopsetups %D We have at the moment only the values from the core module, I use the settings %D from the dinb file as default settings, you could replace them in your own %D document but I won't change the default style. %D %D The labels are stored in a common file, you could use them in your own interface %D but you have to live with my names. \useletterstyle [dinb] % layout \useletterextension[label] % labels \protect \endinput