39

I am trying to create a central bibliography (.bib file) in a directory outside of my LaTeX project. I want to do this so I don't have to have different .bib's for each paper I write. Currently in each .tex file I write:

\bibliography{central-bibliography}

at the end where I want to put it. My .bib file is called central-bibliography.bib. The .bib file is in the same directory as the .tex file.

If I put the .bib file in an arbitrarily located directory, how would I reference it in the .tex file?

27

You can reference central-bibliography.bib at an absolute or relative (preferred) location from within the \bibliography command:

\bibliography{../references/central-bibliography}

Note the use of / and not \. Although it is not always required, using / (forward slash) works across most (all?) operating systems.

If you want to modify this from a location at the start of your document, you could also define a command to store the relative location:

\documentclass{<class>}
\newcommand{\myreferences}{../references/central-bibliography}
%...
\begin{document}
%...
\bibliography{\myreferences}
%...
\end{document}
0
31

The easiest way to do this is to place your .bib file where TeX can find it, which is conveniently done using your local TeX tree. Some of the basics for finding the right location are discussed in Where do I place my own .sty or .cls files, to make them available to all my .tex files?, which focusses on .sty files. On my TeX Live installations, I use the locations:

  • Windows C:\Users\<user name>\texmf\bibtex\bib\local
  • Mac OS X ~/Library/texmf/bibtex/bib/local
  • Linux ~/texmf/bibtex/bib/local

With a recent TeX Live, you can simply place your .bib file in the appropriate place and it will be found, so you can use

\bibliography{myfile}

with no path at all. With an older TeX Live you may need to run texhash first. MiKTeX also allows the same local installation procedure.

The only minor issue with placing a .bib file in your local texmf tree is that it's not so convenient for editing as if it were in the Documents folder. I get around this by using a link, so I actually have my .bib file on my Mac in ~/Documents/Literature and link from there to ~/Library/texmf/bibtex/bib/local using the Unix ln command. On Windows 7 you can do a similar thing using the mklink (you need to have Admin rights to do this).


An alternative approach is to use the BIBINPUTS environmental variable to set a path to be searched for .bib files, again allowing you use the file name directly with no path. Setting environmental variables depends on the operating system you are using.

3
  • 4
    TeX Live is slightly pickier about placement of these files. ".bib" files go in ~/Library/texmf/bibtex/bib or subfolders of this directory, and ".bst" files go in ~/Library/texmf/bibtex/bst or subfolders of this directory.
    – Ansd
    Mar 16 '14 at 12:52
  • If you are using bib2gls with the glossaries-extra package you should also use these locations.
    – user201385
    Jan 3 '20 at 10:14
  • adding the central path as a BIBINOUTS environment variable worked though it seems that the citation suggestions when I begin with ```\cite{```` don't auto populate. Jan 11 at 10:17
3

Simply, put your bibfile in any place in your laptop. For example in the Drive "D" in the folder Ph.D.

Now, suppose your bibfile`s name is centralbibfile.bib All what you need to do is to tell the program where is your bibfile and what is its name as follows: enter image description here

\bibliography{D:/Ph.D/centralbibfile}

1
  • This is already covered in the existing answer(s).
    – Werner
    Oct 19 '16 at 4:26
2

I found a solution finally and it is work 100%. This is help you to creating central bibliography for all documents and also mendeley sync your library automaticly.

First you have to locate your main MikTex file directory and "base" file. Mine is

C:\Program Files (x86)\MiKTeX 2.9\bibtex\bib\base

If you use windows 7 or later you definitelly set mendeley for working admin at all time. Right click on mendeley shortcut or .exe and select properties. In the Properties box, select the Compatibility tab and then check “Run this program as an administrator”. It is done.

Second you have to set mendeley for creating "library.bib" in this location. It is simple open mendeley and go

tools > options > bibtex

click browse and set it for "base" file location.

Refresh your library or close and open mendeley. Make sure library.bib file is created in

C:\Program Files (x86)\MiKTeX 2.9\bibtex\bib\base

Last step go "MikTex settings(admin)"

Click "Refresh FNBD" and after click "Update Formats" button.

If you did everthing right it is definitelly work correctly.

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.