I have a problem when I have multiple bib files (i.e.,full.bib,article.bib,conf.bib,book.bib,me.bib; all the bib files are put into the bib folder), that is, every time I want to add bib files to my document, I will write as follows


but it's annoying when I have many bib files.

My question is that, should there be a simple way to write down thebibliography just as follows


with a pre-defined path at the beginning of the document like


(This is a solution for Overleaf since the user specifically asked to get the BIBINPUTS working on Overleaf in the comments.)

You can set the BIBINPUTS variable on your Overleaf project, by adding a file named latexmkrc with the following line in it:

$ENV{'BIBINPUTS'}='./bib//:' . $ENV{'BIBINPUTS'};

and then add some text to your .tex file to trigger a recompile.

The idea is similar to changing TEXINPUTS so that your project can access .sty, .bst, .cls etc in a folder: https://www.overleaf.com/help/212

  • 1
    @WangyanLi Your file was named latexmkrc.tex – this is a special file to control the latexmk build tool options, so it should not have any file extensions. I've renamed it to latexmkrc in your project, and behold! The citations appear! – imnothere May 19 '16 at 8:48
  • It works well before, but when I started a new project, it surprisely won't work, may I have your attention to this project, overleaf.com/5287941nxtwys, hope you can help me find the problem, which is much appreciated! – wayne May 24 '16 at 9:01
  • @WangyanLi You were writing \bibliography instead of \bibliographystyle :p – imnothere May 24 '16 at 9:05
  • 1
    Yes - book.bib is already present in the TEXMF tree (jurabib), so the engine looks to that file instead of yours. Hmm. The easiest way to solve this is to rename your bib e.g. to books.bib and point the \bibliography at that. – imnothere May 24 '16 at 9:20
  • 2
    By setting TEXINPUTS, LaTeX can now see the custom .sty, .cls and .bst in your tex folder. However for bst files, there's another variable BSTINPUTS that takes precedence, so LaTeX uses the default IEEEtran.bst in the system tree! Solution? Set BSTINPUTS to your tex as well. – imnothere May 25 '16 at 1:39

On a unix system (including macs) you can do this using the BIBINPUTS environment variable (sorry, but I have no idea how to do this on windows). For example, if you are using bash then put the following into your .bashrc or .bash_profile:

export BIBINPUTS="$HOME/bib"

This is assuming that your bib directory is $HOME/bib. If not then you need to replace this with the appropriate path.

  • Thx for you reply, but I can't get it, since I used Overleaf, and can't find .bashrc or .bash_profile either. Can it be simplified to just write a default path like \bigliographypath{bib/} at the beginning? – wayne May 19 '16 at 2:52
  • 1
    @WangyanLi I am not sure you can change it during compilation. graphicx does some somersaults to enable this functionality, as I understand it, and people seem to think even using that isn't a great idea. (I use it constantly, but they are very likely right even so.) – cfr May 19 '16 at 3:04
  • @cfr Yes, the reason I came up with \bigliographypath{bib/} is motivated by the similar setting in graphicx, but, unfortunately, I have not yet found the similar command in biblatex, does it mean the my question is a dead end? – wayne May 19 '16 at 3:15
  • 2
    @WangyanLi you can change the environmental variable in your project via a latexmkrc file – I've added an answer on how to do this. – imnothere May 19 '16 at 3:38

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.