Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Executing BibTeX via Auctex (RefTeX) in emacs (24.2.1) only creates a .bbl file for the master file in a multifile document. Yet, if one wants bibliographies for each chapter, BibTeX has to be run on each .aux file seperately. Is there a hidden option in Auctex (RefTeX) that activates this feature?

In the minimal example attached, only a .bbl file for main.tex is generated, but not for incl.tex and incl2.tex. Copying main.bbl to incl.bbl and incl2.bbl resolves the situation and both the citations and bibliographies can be found in the document.

TeX distro version: texlive 2012

RefTeX version: 4.31

main.tex

\documentclass{book}
\usepackage[round,sort&compress]{natbib}
\usepackage[sectionbib]{chapterbib}

\begin{document}

\include{incl}
\include{incl2}

\end{document}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

incl.tex

\chapter{chap 1}

\input{inp}

\bibliographystyle{plainnat}
\bibliography{testbib} % BibTeX-File(s)


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "main"
%%% End: 

inp.tex

\section{sect1}

some text and a ref: \cite{test_01}
%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "main"
%%% End:

incl2.tex

\chapter{chap 2}
\section{sect1}

some text in chap2  and same ref: \cite{test_01}

\bibliographystyle{plainnat}
\bibliography{testbib} % BibTeX-File(s)

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "main"
%%% End: 

testbib.bib

@book{test_01,
    title = {Test},
    publisher = {Test},
    author = {Adam Smith},
    year = {1982}
}
share|improve this question
    
Welcome to TeX.SX! –  Claudio Fiandrino Nov 6 '13 at 7:50
    
No, AUCTeX cannot cope with this situation, but you can run latexmk from AUCTeX, which instead is able to run bibtex on the relevant files. On this site there are some suggestions about how to setup latexmk in AUCTeX, I'm using the configuration suggested here. –  giordano Nov 6 '13 at 8:49
    
Then I'm wondering why the reftex manual is claiming support for chapterbib.. Also is there a link missing in your comment giordano? Cheers –  cass Nov 6 '13 at 22:20
    
@StefanKuczera running the appropriate commands (latex, bibtex, etc...) is up to AUCTeX, not RefTeX, RefTeX just scans bibliography databases files to help you inserting bibliography entries ;-). Which link are you referring to? P.S. when you want to address someone in comments please start the message with @USERNAME, otherwise he/she won't be notified. –  giordano Nov 7 '13 at 9:52
    
@giordano in your first comment you write "On this site there are...", but maybe you meant stackexchange. I guess it is not worth to submit this as an auctex problem again. –  cass Nov 9 '13 at 0:16

1 Answer 1

First, execute customize-group TeX-command. Expand TeX-command-list. Under the name field BibTeX, change the command field to bibtex %B

Next, go down to TeX-expand-list and insert a new key, %B. Add the following in the field for expander: (lambda () (substring (TeX-current-file-name-master-relative) 0 -4))

["-4" above gets rid of the extension ".tex" from the file name that will be provided to BibTeX.]

Finally, save the customization.

The above steps will ensure that when you do BibTeX on a chapter in a subdirectory, the corresponding bbl file is created in that directory. I have tried this successfully on Windows and Mac Mavericks implementations.

share|improve this answer
    
Hi Simant, thanks for the answer and sorry for the late reply. Your command works in some cases. Yet it does not work if you execute C-c C-c from "inp.tex". Also the situation gets more complicated if you have multiple includes. I've updated the question, maybe someone wants to give it a go. –  cass May 28 at 13:46
    
I can confirm that it works for Biber in Mac Mavericks. –  Nathanael Farley Sep 16 at 9:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.