On Wed, 11 Feb 2015, Jacob Gerlach wrote:
Hi List,
I am using a custom Latex class that requires some code between
\begin{document} and \maketitle.
It seems from looking at ox-latex.el that there is nothing between document
start and title command available for me to customize.
I suppose I could customize the title command to include the extra code,
but I'd like to find an alternate approach if possible so I don't have to
manage org-latex-title-command on a per-document basis.
Are there any convenient alternatives?
(info "(org) Advanced configuration") has a heading called 'Filters' that
may interest you.
If you always export that custom class using the same boilerplate between
the \begin{document} and the \maketitle , you can install
your own `final-output' filter. All it needs to do is check if the custom
class is operative and if it is insert the needed text before \maketitle.
As a start, put something like this in your init file:
#+BEGIN_SRC emacs-lisp :exports results :results none
(defun my-final-filter (s backend info)
(when (eq backend 'latex)
(let ((class (plist-get info :latex-class)))
(message "class: %s" class)
(when (string= class "report")
(replace-regexp-in-string "\\maketitle"
"% put special stuff here\n\\maketitle"
s nil t)))))
(add-to-list 'org-export-filter-final-output-functions 'my-final-filter)
#+END_SRC
Change "report" to your special class and the % comment to whatever
you need.
To make it more robust, you might want to fiddle with the regexp in case
there is a \maketitle someplace else in your document.
HTH,
Chuck