emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Latex export postamble
@ 2012-04-13 12:16 Pedro Silva
  2012-04-14 23:40 ` Pedro Silva
  0 siblings, 1 reply; 2+ messages in thread
From: Pedro Silva @ 2012-04-13 12:16 UTC (permalink / raw)
  To: Org Mode

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?

Pedro
-- 
Don't try to have the last word. You might get it.
                -- Lazarus Long

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Latex export postamble
  2012-04-13 12:16 Latex export postamble Pedro Silva
@ 2012-04-14 23:40 ` Pedro Silva
  0 siblings, 0 replies; 2+ messages in thread
From: Pedro Silva @ 2012-04-14 23:40 UTC (permalink / raw)
  To: emacs-orgmode

Pedro Silva <psilva+org@pedrosilva.pt> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-14 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-13 12:16 Latex export postamble Pedro Silva
2012-04-14 23:40 ` Pedro Silva

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).