# Add new header variable in org-mode document, and use it in (LaTeX) export

I'm using a memorandum specific style when I do LaTeX export of an org-mode document. It has some fields that I'd like to specify/fill in in a manner similar to the way AUTHOR, TITLE, DATE are specified.

How do I define new document options?
How can I use them in exported documents?

Right now, I'm focused on LaTeX export, but might also want to do HTML output, in which case I would want to use the new options in a customized postamble.

What I have now:

#+OPTIONS: toc:nil
#+AUTHOR: Dave
#+TITLE: write_me
#+DATE: 22 March 2018

#+LATEX_CLASS: myMemo

* Content
blah....


myMemo is a modified version of this memo template. The original style uses some custom macros like memoto and memofrom to setup the To: and From lines in the memorandum. So far, I've modified most of the lines in myMemo.sty so that they use the values defined in the org file:

\begin{description}
\ifthenelse{\equal{\@memoto}{\relax}}{}{\item [{To:}] \@memoto}
\item [{From:}] \@author
\item [{Subject:}] \@title
\item [{Date:}] \@date
\end{description}


so that the header portion of the memo uses the values defined by #+AUTHOR: ... etc. However, I don't see a good solution for being able to do the same thing for the To: item that doesn't involve defining a new option (so that line is unchanged from the original style file, and it is specified in the org file with at LATEX_HEADER command).

so, it seems to me that I need a new variable in order to be able to specify the other features I'd like to have in the header. I'd like to have something like this:

#+OPTIONS: toc:nil
#+AUTHOR: Dave
#+RECIPIENT: Alice
#+TITLE: write_me
#+DATE: 22 March 2018

#+LATEX_CLASS: myMemo
# The class file has been modified to make use of the RECIPIENT field
# in an appropriate way; for example using a \@recipient macro
# whose value is specified via the RECIPIENT line above

* Content
blah...


How do I do it?

• Perthaps a macro? – NickD Mar 23 '18 at 16:55

There is a pretty complete example of doing this at https://github.com/jkitchin/scimax/blob/master/ox-cmu/ox-cmu-memo.el. The gist is you use the keywords like:

#+FROM: some name, etc
#+DEPARTMENT: Good stuff


Then create a custom exporter derived from the backend you want.

(org-export-define-derived-backend 'cmu-memo 'latex
:options-alist
'((:department "DEPARTMENT" nil "Department of Chemical Engineering")
;; the name is a committee or your name
(:fromname "FROMNAME" nil nil)
;; I am leaving out proftitle, location, telephone, email, and zipcode.
(:to "TO" nil nil)
(:from "FROM" nil nil)
(:subject "SUBJECT" nil nil)
(:cc "CC" nil "")
(:signature-lines "SIGNATURE-LINES" nil t))
:translate-alist '((template . cmu-memo-template))