1

I have this .org-file (let’s call it letter.org):

#+AUTHOR: Me
#+SENDER: hu-berlin-letter-example
#+SUBJECT: Short description
#+LANG: de
#+ADDRESSEE: my adress

#+SETUPFILE: org-setupfile.org

Thank you very much for your letter.

THIS WORKS: {{{keyword(SENDER)}}}
ADDRESSEE: {{{keyword(ADDRESSEE)}}}
AUTHOR: {{{keyword(AUTHOR)}}}
THIS WORKS, TOO: \LoadLetterOption{ {{{keyword(SENDER)}}} }

My org-setupfile.org contains this:

#+begin_src emacs-lisp :results none :export none
(add-to-list 'org-latex-classes
             '("hu-berlin-letter"
               "\\documentclass{hu-berlin-letter}
           [NO-DEFAULT-PACKAGES]
           [PACKAGES]
\\usepackage{hyperref}
           [EXTRA]"
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
               ("\\paragraph{%s}" . "\\paragraph*{%s}")
               ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
#+end_src

#+OPTIONS: toc:nil
#+LATEX_COMPILER: lualatex
#+LATEX_CLASS: hu-berlin-letter
#+LATEX_CLASS_OPTIONS: [{{{keyword(SENDER)}}}]
#+LATEX_HEADER: \LoadLetterOption{ {{{keyword(SENDER)}}} }

When I export it to a .tex-file (using DOOM Emacs with SPC m e l l) I get this result:

\documentclass[{{{keyword(SENDER)}}}]{hu-berlin-letter}
           \usepackage{hyperref}
           \LoadLetterOption{ {{{keyword(SENDER)}}} }
\author{Me}
\date{\today}
\title{}
\hypersetup{
 pdfauthor={Me},
 pdftitle={},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 29.0.90 (Org mode 9.6.1)}, 
 pdflang={English}}
.... % deleted biblatex-part
\begin{document}

Thank you very much for your letter.

THIS WORKS: hu-berlin-letter-example
ADDRESSEE: my adress
AUTHOR: Me
THIS WORKS, TOO: \LoadLetterOption{ hu-berlin-letter-example }
\end{document}

My problem is that this documentclass depends on the .lco-file which I want to load with \LoadLetterOption (or as an option to the documentclass) - but I cannot pass the content of the keyword SENDER where I need it to be (which is #+LATEX_HEADER: \LoadLetterOption{{{{keyword(SENDER)}}}} or #+LATEX_CLASS_OPTIONS: [{{{keyword(SENDER)}}}]).

The macro {{{keyword(SENDER)}}} works fine in the main body, but not in the LaTeX header....

2
  • The only keywords where, on export, macros are expanded on the RHS are TITLE, DATE and AUTHOR. This is controlled by the parse setting in org-export-options-alist. You'd have to add entries to that list for the LATEX_CLASS_OPTIONS and LATEX_HEADER keywords. That would be a start, but I don't know if it would be enough. Do C-h f org-macro-replace-all and check its last argument - then check how that last argument is calculated in org-export--annotate-info.
    – NickD
    Commented May 22, 2023 at 5:13
  • Thanks for pointing that out. I didnt know about org-export-options-alist, I will check it out. Commented May 22, 2023 at 18:24

1 Answer 1

2

There is an Org-mode LaTeX exporter designed for letters. Read Creating letters with KOMA-Script scrlttr2 and Org-mode for more details.

With this exporter, you can customize the look of your letter by writing your own LCO files and including them with the #+LCO: keyword.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.