Firstly apologies if this is a silly mistake on my part.

I am writing my thesis and using subfiles for each chapter. I would like a reference section at the end of each chapter so I am therefore using chapterbib. I am also using the package achemso.

I'm having problems with compiling the subfiles in the main document. This could be the way that I am building the file, but it seems to work nicely for one subfile just not any more than that.

So I build each chapter (let's call it chapter1.tex) by:

Build (LuaLatex) Bibtex Build (LuaLatex) Build (LuaLatex)

Then the main document in the same way (let's call it thesis.tex)

Build (LuaLatex) Bibtex Build (LuaLatex) Build (LuaLatex)

The structure of my main document is something like:



And for my subfiles something like:



main text



Any help would be greatly appreciated.

Just to clarify, I can build the main document (thesis.tex) with the subfiles, but no references are included. Trying to then build the main document with bibtex pulls up an error something like:

The style file: achemso.bst Illegal, another \bibdata command---line 793 of file

This does not happen with only one subfile.

1 Answer 1


Perhaps a bit late for you, but I've been wrestling with a similar problem and this may help others.

I've not found a good way to use chapterbib with subfiles (according to the documentation, you could use \begin{cbunit}, although I had no joy with that, or \cbinput, but that looks like more effort than it's worth).

In most cases, however, it would be possible to use \include instead of \subfile (you will need to remove the preamble from your subfiles to do this). This works well with chapterbib.

There may also be a problem with \achemso when the root document has no citations (here, here), so avoid that if you can. You should be able to use the .bst files without using the rest of the package if, needed.

So your document would become something like:

\usepackage[sectionbib, super, sort]{natbib}


And your chapters something like:

\chapter{Chapter 1}
main text


The other, critical, step is building everything correctly. This is more likely to be an issue if you're using a GUI such as TeX Studio. If that's the case, I'd suggest you manually delete all the auxiliary files generated when running Latex (ie. everything you didn't put there) and manually running pdflatex on the root doc, bibtex on each chapter and then pdflatex twice on the root doc from a terminal.

You must log in to answer this question.

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