Nick Dokos <> writes:

> "R. Michael Weylandt" <> writes:
>> I want org-mode to export to the "amsart" class by default. In
>> addition to the regular \title, \author, \date macros, amsart also
>> allows for "email".
>> (add-to-list 'org-latex-classes
>>        '("amsart"
>>          "\\documentclass{amsart}
>>           [DEFAULT-PACKAGES]
>>           [PACKAGES]
>>           [EXTRA]
>>           \\email{ {{{email}}} }"
>>           ("\\section{%s}" . "\\section{%s}")
>>            ("\\subsection{%s}" . "\\subsection{%s}")
>>            ("\\subsubsection{%s}" . "\\subsubsection{%s}")))
>> Running this on a document like:
>> #+TITLE: Test 1
>> #+AUTHOR: Michael Weylandt
>> #+EMAIL:
>> #+LATEX_CLASS: amsart
>> * Header 1
>> Hello World
>> leaves me with "\email{email}" in the resulting LaTeX instead of
>> "\email{}". Since this is used as part of
>> \maketitle, doing something in the body (like your example) is too
>> late.
>> The #+EMAIL: value is handled by ox-latex.el, but it's only placed
>> inside the \author{} macro instead of in a stand alone \email{}.
>> That's the behavior I'm hoping to tweak.
>> Is that clearer?
> Much - thanks. I haven't thought much about it but my knee-jerk reaction
> is to use a marker (something like \email{@EMAIL@}) when defining the
> class and use a filter to replace it at the end. But there are might be
> more elegant solutions around.

So here's a brute-force solution along the above lines:

--8<---------------cut here---------------start------------->8---
#+LATEX_CLASS: amsart

* foo

* code                                                                          
This should probably go in some initialization file - for testing, I just 
the code blocks by hand:

#+name: email-filter
#+BEGIN_SRC elisp :results none
  (defun nd-email-filter (contents backend info)
    (let ((email (plist-get info :email)))
      (replace-regexp-in-string "@EMAIL@" email contents t)))
  (add-to-list 'org-export-filter-final-output-functions (function 

#+name: amsart
#+BEGIN_SRC elisp :results none
  (setq amsart-class
            \\email{@EMAIL@ }"
            ("\\section{%s}" . "\\section{%s}")
             ("\\subsection{%s}" . "\\subsection{%s}")
             ("\\subsubsection{%s}" . "\\subsubsection{%s}")))
  (add-to-list 'org-latex-classes amsart-class)

This deletes the amsart from the org-latex-classes list:

#+BEGIN_SRC elisp
  (setq org-latex-classes (cdr org-latex-classes))
--8<---------------cut here---------------end--------------->8---


Reply via email to