35

I am trying to get Emacs (24.3.1), Org-mode (8.0.3, from ELPA) and BibTeX (from TeX Live 2012) to work together. I have followed the instructions under the Bibliography section in http://orgmode.org/worg/org-tutorials/org-latex-export.html but after exporting the document to LaTeX, compiling to PDF, and opening the result (with key sequence C-c C-e l o in the latest Org mode) I see a question mark instead of a citation (i.e., [?]) which means that the reference was not resolved by LaTeX. In fact, checking the Org PDF LaTeX Output buffer, I see the following warning:

LaTeX Warning: Citation `Tappert77' on page 3 undefined on input line 43.

No file org-bib-test.bbl.
[3] (.//org-bib-test.aux) 

LaTeX Warning: There were undefined references.

It looked to me that probably Org-mode was looking for a .bib file with the same base name as the .org file but renaming the .bib file and updating the \bibliography line did not solve the problem.

Here are two minimal .org and .bib files that together can be used to reproduce the behavior described above:

org-bib-test.org

* Tests
** Test1 slide
   - This is test1 \cite{Tappert77}.

\bibliographystyle{plain}
\bibliography{org-bib-test-refs}

The following, using #+LATEX_HEADER, gives the same result:

org-bib-test.org

#+LATEX_HEADER: \bibliographystyle{plain}
#+LATEX_HEADER: \bibliography{org-bib-test-refs}

* Tests
** Test1 slide
   - This is test1 \cite{Tappert77}.

org-bib-test-refs.bib

@incollection {Tappert77,
AUTHOR = {Tappert, Fred D.},
TITLE = {The parabolic approximation method},
BOOKTITLE = {Wave propagation and underwater acoustics ({W}orkshop,
              {M}ystic, {C}onn., 1974)},
PAGES = {224--287. Lecture Notes in Phys., Vol. 70},
PUBLISHER = {Springer},
ADDRESS = {Berlin},
YEAR = {1977},
MRCLASS = {76.41 (86.41)},
}

Currently I am using the following ugly hack to get the references resolved: I generate the .bbl file from the .bib file (using a minimal .tex file) and then I \include the resulting .bbl file directly in my .org file. This is rather cumbersome and of course requires that I regenerate the .bbl file every time I make a change to the .bib file. Although this process can be automated in Emacs by writing a lisp function to encapsulate these actions, I'd rather solve the problem than streamline a hack.

Edit I have checked the .tex file generated by Org mode. It does have the following necessary lines exported in it:

\bibliographystyle{plain}
\bibliography{org-bib-test-refs}
2
  • 6
    For future readers, I posted what I believe to be the answer on the Org mode mailing list, here: lists.gnu.org/archive/html/emacs-orgmode/2013-05/msg00791.html May 18, 2013 at 9:45
  • 1
    I can confirm that, disregarding efficiency (which is another story to be fair), the solution suggested by @G.JayKerns works. I will accept it if he posts it here as an answer.
    – 0mid
    May 19, 2013 at 21:53

4 Answers 4

15

@G.JayKerns has a perfectly good solution in the comments, but since this question has been a while without an answer, I'll fill it in. The important elisp variable is org-latex-pdf-process, which can work with a number of settings. I have mine set up as something like:

(setq org-latex-pdf-process (list
   "latexmk -pdflatex='lualatex -shell-escape -interaction nonstopmode' -pdf -f  %f"))

That's a simplification since I set the actual variable dynamically based on some other orgmode macro lines, but the basic idea should work.

You can use explicit multiple iterations or a build process like latexmk or rubber within org-latex-pdf-process. Use what you would at the command line and check the log in the *Org PDF LaTeX Output* buffer if you get errors.

The org-mode file should look like this: org-bib-test.org

* Tests
** Test1 slide
   - This is test1 \cite{Tappert77}.

\bibliographystyle{plain}
\bibliography{org-bib-test-refs}

Put your bibtex in the file org-bib-test-refs.bib and run C-c C-e l o and you should be good.

9

This answer from

Problems with .bbl in org-mode

(setq org-latex-to-pdf-process (list "latexmk -pdf %f"))

worked for me

2
  • 3
    Is org-latex-to-pdf-process a typo? Because, only org-latex-pdf-process exists on my system. Sep 25, 2018 at 6:22
  • org-latex-pdf-process works for me, the other not. Thank you @MaliRemorker
    – jaromrax
    Apr 24, 2021 at 17:42
6

From the documentation for org-latex-pdf-process in org-mode version 8.2.5h (February 10, 2014):

By default, Org uses 3 runs of pdflatex to do the processing. If you have texi2dvi on your system and if that does not cause the infamous egrep/locale bug:

http://lists.gnu.org/archive/html/bug-texinfo/2010-03/msg00031.html

then texi2dvi is the superior choice as it automates the LaTeX build process by calling the "correct" combinations of auxiliary programs. Org does offer texi2dvi as one of the customize options. Alternatively, rubber and latexmk also provide similar functionality. The latter supports `biber' out of the box.

The customization buffer offers a value menu that includes texi2dvi, so it can easily be set through that interface. If you prefer to set the value in your .emacs, you can use the following:

(setq org-latex-pdf-process (quote ("texi2dvi -p -b -V %f")))
1
  • texi2dvi I could find. But (setq org-latex-to-pdf-process (list "latexmk -pdf %f")) works fine.
    – jaromrax
    Apr 24, 2021 at 17:44
2

Because bibtex usually uses \cite{some_reference} there is a conflict involving reftex in org-mode where the usual bib{some_reference} is used. To get round this I define a my-org2pdf-export, which works for me using emacs-24 and org 8.3. I then an org file using reftex to call references and then use M-x my-org2pdf-export RET when I want to export to a pdf file.

;;; Begin "my-org2pdf-export"
;;;
;;; Define bib2cite
(defun my-bib2cite ()
"change bib to cite"
(interactive)
(let ((case-fold-search t)) ; or nil
(goto-char (point-min))
(while (search-forward "bib:" nil t)
(replace-match "cite:" t t))))
;;;
;;; Define cite2bib
(defun my-cite2bib ()
"change cite to bib"
(interactive)
(let ((case-fold-search t)) ; or nil
(goto-char (point-min))
(while (search-forward "cite:" nil t)
(replace-match "bib:" t t))))
;;;
;;; Change bib: to cite: in .org file
;;; Then call org-export-dispatch and 
;;; then change cite: back to bib: 
;;; to leave original .org file unchanged.
(defun my-export-org ()
"export settings"
(interactive)
(my-bib2cite) ;; Change bib: to cite:
(org-export-dispatch) ;; Call the dispatcher
(my-cite2bib) ;; Change cite: back to bib:
(save-buffer);; Save file again
) ;; End bracket
;;; End "my-org2pdf-export".
1
  • This post/discussion would help me greatly if it were current. Or is it current enough? Or what parts are not current? I'm on org-mode 9.0.2.
    – 147pm
    Jan 8, 2017 at 16:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .