This post explains how to set up emacs so that the writing and sending of letters is always just a whim away. The resulting letters will adhere to the German DIN 5008 standard, and fit neatly into envelopes designed on that standard, as shown in the cover image on the top.


All you for the implementation shown in this tutorial is

  • Emacs with org-mode and
  • a LaTeX installation with the dinbrief.cls installed. On Ubuntu and Debian all you need are the packages texlive-latex-base and texlive-latex-extra.

Setting up the capture template

I use the following set-up for capturing templates. It writes each new captured letter to a single “letter”-File in The process of starting a letter via capture, i.e. C-c c l then prompts you for filename/heading of the letter in the LETTERFILE, address (each line separately), topic and greeting formula. After that, you can simply write your plain text letter within the capture and finish with C-c C-c.

(setq org-capture-templates '(("l" "Letter" entry
			     (file+headline "" "Letters")
			     "* %<%F> %^{Filename}
#+OPTIONS: toc:nil
#+LaTeX_CLASS: dinbrief
#+LaTeX: \\begin{letter}{
#+LaTeX: %^{Adresszeile 1 [Name]} \\\\
#+LaTex: %^{Adresszeile 2 [Street, Number]} \\\\
#+LaTex: %^{Adresszeile 3 [Place, ZIP]} }
#+LaTeX: \\subject{%^{Topic}}
#+LaTeX: \\opening{%^{Greeting}}
#+LaTeX: \\closing{Kind regards,}
#+LaTeX: \\underline{\\hspace{12cm}}\\\\
#+LaTeX: Sebastian  Schweer\\\\[2cm]
#+LaTeX: \\end{letter}" :jump-to-captured t)))

Hints for further customization

Within the variable `org-latex-classes`, you can set up your backadress and favourite pacakges to use while writing, so you don’t have to include these manually each time you write a letter. Obviously though, these settings should only be used for stationary information. Everything that might change from letter to letter should be handled within the capture template.

   '(("dinbrief" "\\documentclass{dinbrief}
\\address{Paul McCartney \\\\
Abbey Road 24 \\\\
6058 London}
\\backaddress{Paul McCartney, London}
      ("\\section{%s}" . "\\section*{%s}")
      ("\\subsection{%s}" . "\\subsection*{%s}")
      ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
      ("\\paragraph{%s}" . "\\paragraph*{%s}")
      ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
     ("article" "\\documentclass[11pt]{article}"
      ("\\section{%s}" . "\\section*{%s}")
      ("\\subsection{%s}" . "\\subsection*{%s}")
      ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
      ("\\paragraph{%s}" . "\\paragraph*{%s}")
      ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
     ("report" "\\documentclass[11pt]{report}"
      ("\\part{%s}" . "\\part*{%s}")
      ("\\chapter{%s}" . "\\chapter*{%s}")
      ("\\section{%s}" . "\\section*{%s}")
      ("\\subsection{%s}" . "\\subsection*{%s}")
      ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
     ("book" "\\documentclass[11pt]{book}"
      ("\\part{%s}" . "\\part*{%s}")
      ("\\chapter{%s}" . "\\chapter*{%s}")
      ("\\section{%s}" . "\\section*{%s}")
      ("\\subsection{%s}" . "\\subsection*{%s}")
      ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
   '(("AUTO" "inputenc" t
     ("T1" "fontenc" t
     ("" "graphicx" t nil)
     ("" "grffile" t nil)
     ("" "longtable" nil nil)
     ("" "wrapfig" nil nil)
     ("" "rotating" nil nil)
     ("normalem" "ulem" t nil)
     ("" "amsmath" t nil)
     ("" "textcomp" t nil)
     ("" "amssymb" t nil)
     ("" "capt-of" nil nil)
     ("" "hyperref" nil nil)
     ("official" "eurosym" nil nil)
     ("" "ngerman" nil nil)))
 '(org-latex-title-command "")


The final step is simple … just use it :) Capture your letter, answer all the prompts, and write your text. Once your capture is finished, navigate to the corresponding subtree in LETTERFILE, use and the org-export to latex to create your pdf: C-c C-e C-s l o.