I compile a document with this command:

    latexmk -outdir=obj these.tex

In these.tex, I specify \bibliography{../Bibliography}. But, when latexmk calls bibtex, the .aux file is one folder deeper and, hence, the compiler doesn't find the file.

Indeed, if in my .tex file I use \bibliography{../../Bibliography} then everything works fine for bibtex, but latexmk fails to find the file. Using -auxdir=obj doesn't change anything.

What can I do ?

edit: it seems important to precise that latexmk is called via a makefile.

  • Why not use a place that is simply searched by default? Using kpsewhich --var-value TEXMFHOME gives me ~/texmf, which means I'd put my bibliography (or a symlink even) in ~/texmf/bibtex/bib; then latex, latexmk, etc. will all find the file regardless of all the other jiggering I might want to do with other files... – jon Apr 24 '14 at 15:35

The simplest way to get out of this would be to set your environment variable BIBINPUTS to ../Bibliography or, in a one line style, do as follow:

BIBINPUTS=../Bibliography latexmk these.tex
  • Hi, adding export BIBINPUTS=../../../Bibliography in the Makefile actually doesn't solve the problem. I still have Latexmk: Found input bbl file 'obj/paper_diffusion_creep_draft.bbl' and Latexmk: Found bibliography file(s) [../../Bibliography.bib], but The top-level auxiliary file: paper_diffusion_creep_draft.aux and I couldn't open database file ../../Bibliography.bib. Doing the export in the terminal itself yield the same behavior. – Napseis Apr 28 '14 at 14:30
  • Does it work when you execute it in command line ? Because, when I replied first to this question, the Makefile was not mentioned...Or, I might have missed it. – perror Apr 28 '14 at 14:51
  • 1
    Hi, I added the makefile in the edit of the first post after your answer. In command line this doesn't work either, that is what I meant by 'Doing the export in the terminal itself yield the same behavior'. That is, export BIBINPUTS=... and then latexmk -outdir= file.tex return the same errors, it seems that it just want to take the bib file given in the aux file... Thanks – Napseis Apr 28 '14 at 15:14
  • Did you first try to clean the .aux files before running the Makefile ? Because, if the BIBINPUTS is not working, then I don't know how to do... :-/ – perror Apr 28 '14 at 16:09
  • Yes, I cleaned the folders. I think I will just give up the src/build separation, as I poses other kind of problems... I don't like having such messy folders, but... Thanks anyway. – Napseis Apr 28 '14 at 16:17

In your project root, create a .latexmk file with the following contents:

$bibtex = "bibtex -include-directory=.. %O %B";

This tells bibtex, which is executed in the obj directory, to look for *.bib files in ../obj.

  • BibTeX (version 0.99d (TeX Live 2017), kpathsea version 6.2.3) does not seem to support the option -include-directory. – Neal Young Oct 3 '17 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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