When I have master pdflatex file which includes one or more child documents using something like \include{include/childdoc}, and I call pdflatex on it using pdflatex -output-directory=out parent.tex, I seem unable to find a way of calling bibtex on the resulting parent.aux file. I have tried both cd out; bibtex parent, and bibtex out/parent, to no avail.

I know there are various build-tools out there, but I'd like first to make it work just from the shell with no special build-tool dependencies.

Consider more complicated variant where you have your source files in subdirectory src. Then you will use also variable BIBINPUTS to specify locations of your *.bib files and BSTINPUTS to specify location of your *.bst files (bibliography style). Then the makefile could look like this:

bibtex only puts its output in TEXMFOUTPUT (if it can't do so in the current directory), but doesn't look for inputs (aux files) there. This didn't work for me with TeX Live 2013 (bibtex 0.99d)
–
SameerSep 15 '14 at 22:54

Ok I finally figured it out (not sure if this is documented somewhere already):

I needed to explicitly create directories within out having the same name as the directories I include files from. Then, I need to be in the out directory when running bibtex. Furthermore, the bibtex file needs to be manually copied to the out directory. Finally, I run pdflatex a second time from the top-level directory, again with the -output-directory flag.

In summary (starting in the directory containing parent.tex):

mkdir out/include

pdflatex -output-directory=out parent.tex

cp mybib.bib out

cd out ; bibtex parent

cd .. ; pdflatex -output-directory=out parent.tex

(and maybe you need to run pdflatex again, depending on what packages you're using...)

Is there no way to get around copying the file?
–
Alec JacobsonOct 11 '12 at 7:02

1

There IS a way to get around copying the file, but it kind of sucks. When giving the \bibliography{...} command, give the paths to the .bib files relative to the output directory. So if are planning on running pdflatex -output-directory=out, say \bibliography{../mybib} instead of \bibliography{mybib}. (You still have to run bibtex from the output directory, unfortunately. If using a Unixy shell, you can say (cd out; bibtex parent) (parentheses included!) and avoid having to cd .. when you're done.)
–
EvanEDJan 16 '13 at 18:45

Did you check the location of the aux-files? The --output-directory doesn't affect auxiliary files (at least not in miktex. In miktex there is the --aux-directory switch to set the directory for auxiliary files). Also - as you use \include: Don't forget that they will be more than one aux-file.