Tell me more ×
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.

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.

share|improve this question

2 Answers

up vote 5 down vote accepted

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):

  1. mkdir out/include
  2. pdflatex -output-directory=out parent.tex
  3. cp mybib.bib out
  4. cd out ; bibtex parent
  5. cd .. ; pdflatex -output-directory=out parent.tex

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

share|improve this answer
It works, thank you! – Dmitry Jun 12 '11 at 22:22
Is there no way to get around copying the file? – mangledorf Oct 11 '12 at 7:02
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.) – EvanED Jan 16 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.

share|improve this answer
Unlike miktex, pdflatex's -output-directory=xyz switch causes everything (including aux files) to be placed beneath xyz. – Mark Mar 5 '11 at 15:09

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.