[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Latex export postamble
From: |
Pedro Silva |
Subject: |
Re: [O] Latex export postamble |
Date: |
Sun, 15 Apr 2012 00:40:16 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) |
Pedro Silva <address@hidden> writes:
> Is it possible to insert text just before \end{document} on export,
> similarly to org-export-html-postamble?
>
> I'd like to do this on a capture target file that contains the following
> at the end:
>
> \bibliography{references}
>
> New capture entries keep getting inserted below it, which makes the
> references section appear in the middle of the document if I forget to
> move it to the end again.
>
> Or maybe there is another way to make this work?
Looking at the relevant code in contrib/org-exp-bibtex.el, I managed to
produce the following, which *almost* works:
(defun org-export-bibliography-preprocess ()
"Insert \bibliography and \bibliographystyle commands at end
of buffer if keyword `#+BIBLIOGRAPHY <file> <style>' is present in
buffer when exporting via latex backend."
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^#\\+BIBLIOGRAPHY:[ \t]+\\(\\S-+\\)[
\t]+\\(\\S-+\\)\\([^\r\n]*\\)" nil t)
(let ((file (match-string 1))
(style (match-string 2)))
(when (eq org-export-current-backend 'latex)
(goto-char (point-max))
(insert
(concat "\n#+LATEX: \\bibliographystyle{" style "}"
"\n#+LATEX: \\bibliography{" file "}\n")))))))
(add-hook 'org-export-preprocess-hook 'org-export-bibliography-preprocess)
Unfortunately, it inserts the latex directives twice, one near the top
of the buffer, and the other one at its end, as expected. Any ideas why
that is?
Pedro
--
Any government will work if authority and responsibility are equal and
coordinate. This does not insure "good" government; it simply insures
that it will work. But such governments are rare--most people want to
run things but want no part of the blame. This used to be called the
"backseat-driver syndrome."
-- Lazarus Long