1

I'm using AUCTeX along with RefTeX in Emacs 25.1.1. My question is how to make AUCTeX to compile Bibliography without having to explicitly provide \bibliographystyle and \bibliography in every file.

For example, I have the following options enabled in .emacs

(require 'reftex)
(setq reftex-mode t)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq reftex-default-bibliography '("/path-to/refLib.bib"))

And as expected when I perform C-c [ RefTeX is able to identify and insert citations. So here is an example of a simple LaTeX file file1.tex one citation from the RefTeX default bib file.

\documentclass[12pt]{article}
\usepackage{hyperref}
\tolerance=1000
\usepackage[margin=1in]{geometry}
\usepackage{enumitem}
\setlist[enumerate,itemize]{noitemsep,nolistsep,leftmargin=*}
\date{}
\title{Testing Bib}
\hypersetup{
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs 25.1.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle
\section{Testing Bib Once}
\label{sec-1}
SCHEDULED \textit{<2017-03-31 Fri 11:03>}
\subsection{Modeling Updates}
\label{sec-1-1}
\begin{itemize}
This is a bibliography test \cite{hohenberg_inhomogeneous_1964}
\end{itemize}
% Emacs 25.1.1 (Org mode 8.2.10)
\end{document}

LaTeX compiles through C-c C-c LaTeX. However when I perform C-c C-c BibTeX it throws me an error as follows

I found no \bibdata command---while reading file file1.aux
I found no \bibstyle command---while reading file file1.aux

When AUCTeX+RefTeX are able to find citations to insert, I'm not sure what is the issue in compiling without explicitly specifying the BiBTeX file.

2 Answers 2

2

RefTeX manual says:

User Option: reftex-default-bibliography

List of BibTeX database files which should be used if none are specified. When reftex-citation is called from a document with neither a \bibliography{...} statement nor a thebibliography environment, RefTeX will scan these files instead. Intended for using reftex-citation in non-LaTeX files. The files will be searched along the BIBINPUTS or TEXBIB path.

I think you're abusing this variable since it is intended for non-LaTeX files. You could try to pass the information to compiler at command line with a file local variable like:

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-command-extra-options: "do-something-in-document"
%%% End:

I'm not sure if it is worth the effort, though.

0

Emacs, AUCTeX and RefTeX are only tools you use, to prepare you LaTeX input file, which is then compiled via LaTeX---and in your case BibTeX. Emacs/AUCTeX suggests the correct compiler you should use in the correct order.

Please, keep always in mind, that LaTeX does not know anything of Emacs and its magic. Despite of your definition (setq reftex-default-bibliography '("/path-to/refLib.bib")), which works for Emacs, LaTeX has no way to guess, which bibliography file it should use. And further on, BibTeX has no clue, which bibliographystyle to use, unless you define it in your tex file.

You have to add

\bibliographystyle{plain} % or any style you prefer

into the preamble of your LaTeX input file and

\bibliography{/path-to/refLib}  % don't add the file name extension ".bib" here

into the document-part (i.e. between \begin{document} and \end{document} of your input file. That is the only solution.

Maybe you can avoid the /path-to/ directory part of the filename, if the path is defined in your TeXsystem already. On TeXLive you could try kpsewhich bib refLib.bib. If the bibliography file could be found in the standard pathes, kpsewhich will print out the complete path where this file could be found. If so, you don't need to insert the complete path. Just the name of the bibliography file refLib will be sufficient.

On the other hand: if you add those two lines to your LaTeX input file, Emacs in turn should inspect the file and should therefore know by itself about the bibliography file, even if you hadn't defined it in your .emacs file by typing (setq reftex-default-bibliography '("/path-to/refLib.bib")). Inserting the \cite via Emacs/AUCTeX or RefTeX should work fine without complaints.

You must log in to answer this question.

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