[Tex/LaTex] Using bibtex from Org mode: .bbl and .aux files are incorrectly generated

bibtexemacsorg-mode

I've searched this site as well as other resources, and I understand it that this is a common problem, however, no single place can explain what exactly are the steps for debugging or troubleshooting. Here's my setup:

#+LATEX_HEADER: \hypersetup{urlcolor=blue}
#+LATEX_HEADER: \hypersetup{colorlinks,urlcolor=blue}
#+LATEX_HEADER: \bibliographystyle{plain}
#+LATEX_HEADER: \bibliography{gg}

#+BEGIN_SRC sh :exports none
  BIBINPUTS=./gg.bib:$BIBINPUTS
  export BIBINPUTS
#+END_SRC

Here's the TEX file produced from Org mode:

\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\hypersetup{urlcolor=blue}
\hypersetup{colorlinks,urlcolor=blue}
\bibliographystyle{plain}
\bibliography{gg}
\author{me}
\date{2014-08-24}
\title{unimportant}
\hypersetup{
 pdfkeywords={unimportant},
  pdfsubject={unimportant},
  pdfcreator={Emacs 24.3.1 (Org mode 8.2.6)}}
\begin{document}

\maketitle
\tableofcontents

\cite{Wilkinson}
...
\end{document}

Log produced by Bibtex:

This is BibTeX, Version 0.99d (TeX Live 2013)
Capacity: max_strings=35307, hash_size=35307, hash_prime=30011
The top-level auxiliary file: test.aux
The style file: plain.bst
I found no \bibdata command---while reading file test.aux
Warning--I didn't find a database entry for "Wilkinson"
[...] 

Contents of gg.bib file:

@book{Wilkinson,
 author = {Wilkinson, Leland},
 title = {The Grammar of Graphics (Statistics and Computing)},
 year = {2005},
 isbn = {0387245448},
 publisher = {Springer-Verlag New York, Inc.},
 address = {Secaucus, NJ, USA},
}

This is the .bbl file produced:

\begin{thebibliography}{}

\end{thebibliography}

Note that this is already wrong: content is missing.

Org mode log:

compiling test.tex...
test.bbl:1: Missing \begin{document}.
test.bbl:1: leading text: \begin{thebibliography}{}

Well, this is nonsense, why should there be \begin{document} here?

Anyways, in the end, the PDF is generated, but no bibliography and the citations look like [?].

I've tried all of these programs to generate the output:

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

;; (setq org-latex-to-pdf-process
;;       '("xelatex %f && bibtex %f && xelatex %f && xelatex %f"))

;; (setq org-latex-to-pdf-process
;;      '("pdflatex -interaction nonstopmode %b"
;;        "bibtex %b"
;;        "pdflatex -interaction nonstopmode %b"
;;        "pdflatex -interaction nonstopmode %b"))

;; (setq org-latex-pdf-process '("rubber -d --into %o %f"))

;; (setq org-latex-pdf-process
;;       '("texi2dvi --pdf --clean --verbose --batch %f"
;;         "bibtex %b" "texi2dvi --pdf --clean --verbose --batch %f"
;;         "texi2dvi --pdf --clean --verbose --batch %f"))

They give more or less the same results. Depending on the phase of the moon and whether Venus can be found in the constellation of Libra, the error messages can vary, but most of them don't even resemble the actual state of affairs in the document they are supposed to relate to. I will post error messages upon demand, because I don't want to clutter this already long post.

I will be enormously grateful if instead of / in addition to trying to fix my setup, you could provide a complete example which uses .org and .bib files.


I'm almost there:

#+LATEX_HEADER: \usepackage[backend=bibtex, style=numeric]{biblatex}
#+LATEX_HEADER: \hypersetup{urlcolor=blue}
#+LATEX_HEADER: \hypersetup{colorlinks,urlcolor=blue}
#+LATEX_HEADER: \addbibresource{gg.bib}

With these modifications and rubber as the compiler I can generate the proper citation, but the bibliography list isn't generated.


Oh, I made it! 🙂 I was missing \printbibliography – this instructs the processor to place the bibliography in the specified place.

I'll wait for an answer though before I post one myself. I can't say that I understand why does it work the way it does, so probably someone who knows better could explain it.

Best Answer

This is one reason why it is can be helpful to start with a minimal WORKING example, if you can find one :-)

#+LaTeX_HEADER: \usepackage{mathptmx}
#+LaTeX_HEADER: \usepackage{pifont}
#+LaTeX_HEADER: \usepackage[margin=0.7in]{geometry}
#+LaTeX_HEADER: \usepackage[backend=bibtex,sorting=none]{biblatex}
#+LaTeX_HEADER: \addbibresource{gg.bib}  %% point at your bib file
#+LaTeX_HEADER: \newcommand{\point}[1]{\noindent \textbf{#1}}
#+LaTeX_HEADER: \usepackage{hyperref}
#+LaTeX_HEADER: \usepackage{csquotes}
#+LaTeX_HEADER: \usepackage[mla]{ellipsis}
#+LaTeX_HEADER: \parindent = 0em
#+LaTeX_HEADER: \setlength\parskip{.5\baselineskip}
#+STARTUP: content

#+TITLE: The problem with computers
#+AUTHOR: Joseph Corneli
#+DATE: \today \\ (DRAFT)

It's not what you think! \cite{Wilkinson}. % change to a ref from your bib file

#+BEGIN_COMMENT
References
#+END_COMMENT

\printbibliography

My org mode config is here: https://gist.github.com/holtzermann17/6953779 The key bit is:

(setq org-latex-pdf-process
  '("latexmk -pdflatex='pdflatex -interaction nonstopmode' -pdf -bibtex -f %f"))