Difference between revisions of "Letter"

From Wiki
Jump to navigation Jump to search
(The entire page was repeated 3 times for whatever reason. Removed the duplicated sections.)
Line 335: Line 335:
[[Category:Sample documents]]

Revision as of 19:11, 7 February 2021

< Modules | User:Wolfgang_Schuster >

NOTE: This module is still in development


The letter module provides a interface to write different kinds of correspondence with the support for different styles and extensions.




  [opening={Dear Reader,},
   closing={Best regards,},
   signature={The TeXnician}]

\input knuth





The layout of the letter can be changed with styles, the module comes with styles for:

  • Germany
  • Netherlands
  • France
  • America

The predefined styles are loaded from external files with the \useletterstyle command, in the past these files had names in the form <style>.nls. The name system has changed and personal styles have to follow the form “letter-<style>.tex”, you could also use “mkiv” and “mkii” as extensions.

To load the style you need only the <style> part as argument for the command because the “letter-” part is always added. It doesn't matter if you use .tex or .mkiv as file extension because the file is found in either case.

\startletter, \stopletter

The letter environment has only optional arguments which acts like a local version of \setupletter where the values are only used in the environment. When you use your document only for a single letter without anything else you can even drop \starttext and \stoptext, because this is handled by \startletter and \stopletter.


Previously there has been only the \setupletterstyle command to change the values of the elements, now the various types of elements have dedicated commands.

The “layers” (which are used for the “head”, “address” or “reference line”) are configured with \setupletterlayer and \setupletterframe command, the first is used to move the layer to its position on the page with the “x” and “y” keys and you can select one letter elements (which are created with \defineletterelement) with the “alternative” key. With \setupletterframe you can change the “width” and “height” of the element.

Thus, for example, the following will produce a small, sans serif header, 10pt from the bottom of the page and centered.

                    {This is my footer.}


The “sections” (which are used for the “subject” and “content”) are configured with \setuplettersection which allows you to change the alignment and spacing before and after the element.

Global settings like the bodyfont, whitespace or language can be changed with \setuplettersoptions.

The old \setupletterstyle command had been reduced to change the style and color for the variables which are set with \setupletter (or \startletter), e.g. you can say \setupletter[date][textstyle=bold,color=red] to change the layout of the date in the reference line.

A complete list with all values for the various commands can be seen in the following document: commands.pdf

List of Layers and Sections

These layers are defined and configurable:

  • head, nexthead, lefthead, righthead
  • foot, nextfoot, rightfoot, leftfoot
  • address, backaddress
  • reference, location
  • topmark, botmark, cutmark, endmark, usermark
  • lettermain, letternext

These sections are defined and configurable:

  • (default) title, subject, opening, content, closing, appendices
  • (block style layouts) head, date, reference, specialnotation, address

Changing the order of elements

The order of elements can be changed using \setupletterelements. For example, to place the subject after the opening (as is standard in Britain), use the following:



One limitation of the old module was that element names had been shared between layers and section (i.e. it was impossible to have a layer and a section with the same name). This limitation was removed and it’s now possible to layers and sections with the same name but to handle this the \defineletterlement command needed a additional argument. The syntax for the command is now


As an example I show a definition for the head with the name “test” which prints the value of the “firstname” key.


The old \copyletterelement command is no longer available.


The old version used \startsetups for the content of the elements. With the current version all internals use now \letterelement but there is a method to feed them with the \startsetups argument, all you need is \setupletteroptions[option=setups] in your document. Nevertheless also the names for \startsetups have been changed to follow the unique named mentioned above and the old name “letter:location” is now “letter:layer:location”.


The layout of the letter environment can be changed with \setupletterlayout, it is possible to use a different layout for the first (firstpage) and the following (secondpage) pages, but starting from the second page one can also set different value for left (leftpage) and right (rightpage) pages.


There is only one way to set values for the letter variables, this is \setupletter with it’s keyval syntax, e.g. \setupletter[name=…,address=…]. (\setlettervalue from the previous version is gone and won’t come back.)

To change the labels in the reference line for the “Date” string, you have to use \setuplettertext, a special version of \setuplabeltext only for the letter module.


It is possible to change the default input method to the one used by Hans Hagen in the m-letter module or Donald Knuths letter style in the TeXbook.

Further Information

You can find more informations here: 

The manual for module was included in some versions of the package and is available from:


List of enclosures/attachments

   symbol=bullet, % or "none"
   \input knuth 

Hraban’s complicated logo and address setup

Same as in Invoice sample.

   \setuplanguage [nl] [date={year, –, mm, –, dd}] % ISO 8601 date
   \setupbodyfont    [rm, 10pt]
   \setupinterlinespace[3.0ex] % default: 2.8ex
   \setbreakpoints[compound] % break at / and -
      whitespace=1.5ex, %3ex
       % Sender address in envelope window
       backaddress={Pragma ADE · H.\,Hagen · Riderstraat 27 · NL-8061 GH Hasselt}
   % Define logo for the first page
   % Other logo for subsequent (right) pages
   % We put our logo in the head
       name={Hans Hagen},
       street={Ridderstraat 27},
       city={NL-8061 GH Hasselt},
       phone={+31 (0)38 477\,53\,69},
       mobile={+31 (0)38 477\,53\,69},
   % center around the :
       \NC person     \NC\correspondenceparameter{name} \NC\NR
       \NC location   \NC\correspondenceparameter{street}\\\correspondenceparameter{city}\NC\NR
       \NC phone      \NC\correspondenceparameter{phone}\\\correspondenceparameter{mobile} \NC\NR
       \NC internet    \NC\correspondenceparameter{email}\\\correspondenceparameter{web} \NC\NR
       \NC skype       \NC\correspondenceparameter{skype} \NC\NR
   % Our own recipient setup without too much space before the address
   % Subject and date on the same line, date below logo
           %\bTD{\tf 2012-12-12}\eTD
   % account information at the foot, below the logo
           \NC financial \NC \NC\NR
           \NC tax no. \NC 1234567890 \NC\NR
           \NC UStID \NC NL\,123\,456\,789 \NC\NR
           \NC Account \NC 123\,456\,890\\Context bank, BIC NLPRCOHA \NC\NR
           \NC IBAN \NC NL12\,345\,678\,908\,12 \NC\NR
   % switch off reference line
   % Move the text a bit up
   % Adjust text start on subsequent pages
   % Move marks to the paper rim (won't print on most printers)
       toname={MIT\\Prof. Donald Knuth},
       toaddress={13, Anywhere Outthere\\Utopia, MA\\USA},
       subject={Regression in latest release of i\TEX}]
   \input knuth
   Best regards,
   Hans Hagen