I use Emacs‘ org-mode a lot for writing notes, todo lists, presentations and writing short reports. Recently I started writing a larger report which I normally would have done in LaTeX. This time, since the notes related to the project were already in org format, I decided to write the whole report in org-mode. The one thing I needed for that was using BibTeX bibliographies (and RefTeX) from org-mode. A quick web search revealed that that can easily be done by adding the following to your .emacs
file:
;; Configure RefTeX for use with org-mode. At the end of your ;; org-mode file you need to insert your style and bib file: ;; \bibliographystyle{plain} ;; \bibliography{ProbePosition} ;; See http://www.mfasold.net/blog/2009/02/using-emacs-org-mode-to-draft-papers/ (defun org-mode-reftex-setup () (load-library "reftex") (and (buffer-file-name) (file-exists-p (buffer-file-name)) (reftex-parse-all)) (define-key org-mode-map (kbd "C-c )") 'reftex-citation) ) (add-hook 'org-mode-hook 'org-mode-reftex-setup) |
After that, RefTeX works, but exporting the org document to PDF (via LaTeX) didn’t include the bibliography entries. A quick look at the error log showed that bibtex
hadn’t been run, so the question was: how to tell org-mode to do that too when exporting. The answer is to tell org-mode to use the latexmk
Perl script (on Debian/Ubuntu it is easily installed from the package repositories) when exporting to PDF. I added the following lines to my .emacs
file:
;; Use latexmk for PDF export (setq org-latex-to-pdf-process (list "latexmk -pdf -bibtex %f")) |
Thanks for the code!
I had to set %s instead of %f. Maybe this depends on the version?