8

Apologies for the newbie question, I am trying to use chapterbib for multiple bibliographies in my thesis. Each chapter is in the main file with \include and has its own bibliography from the same .bib file. I understand that for chapterbib I need to build the main file, then bibtex on each of the subfiles then build the main file again. However, when I try to run bibtex on each of the subfiles, it just runs on the main file again, not the subfiles. I am using Texstudio, how do I run bibtex just on the subfiles so that chapterbib will work?

3 Answers 3

7

Running your LaTeX complier (e.g. PDFLaTeX) on your main file will create aux files for each of the included files. Open each aux file and run BibTex on each of them (press F8 in TeXStudio). You must open each aux file and run BibTex on each aux file to generate the bbl files for each included file. Then, go back to the main file. Rerun your LaTeX compiler twice to generate the citations and bibliography for each chapter.

1
  • Thank you for the tip. When I run the LaTeX compiler it doesn't create the aux file for each chapter included. Any idea on what is going on? Weirdly enough, bibliography on the first chapter is working, but not on the second.
    – Laura K
    Commented Mar 12, 2019 at 19:57
6

You dont need to install parallel toolbox as har-wradim stated. Simply type:

sh -c "for f in *.aux; do bibtex ${f}; done"

in your BibTeX textbox of TeXstudio configuration window (i.e. Configure --> Commands --> BibTeX) and you are good to go.

This perfectly works for Linux/Mac, for windows we need a different command:

cmd /C "FOR %f in (*.aux); DO bibtex %f"

Explanation:

  • Har-wradim code: What parallel bibtex -- ?*.aux does is that it runs a different thread for each file it finds with *.aux extension. While it works, running a task using multiple threads requires parallel package.

  • My script: It simply removes the aforementioned requirement by:

    1. List of all files that end with aux (using a for statement).
    2. Run bibtex <file>.aux for each individual file separately using single core.
1
  • Thanks a lot, it works... this has been so hard to debug!! Commented Nov 27, 2017 at 3:56
2

The easiest solution is to use parallel bibtex -- ?*.aux as the BibTeX command under Configure → Commands. This implies that parallel is installed and available in the PATH, which is almost certainly true by default if you use a Linux distribution. Installation on OSX is straightforward with brew. No idea how it might work on Windows.

This solution would not work for aux files with spaces in their names, but using spaces in file names is arguably a bad practice in the first place.

You must log in to answer this question.

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