Search code examples
filereferencedirectorylatexbibtex

How do I reference a bibtex file from directory other than current project?


What I am trying to do is create a "Master" bibtex bibliography (organized via JabRef) in a convenient directory so that I do not need to copy new references from every project I work on into my master database. The issue I am coming up against is that while I can reference another file easily enough (e.g. for STATA regression table output), even if it is not in the same directory, the bibliography does not want to cooperate.

For the purposes of this example I have created a dummy directory in

    My Documents/Course/Paper. 

The Tex file in under

    My Documents/Course/Paper/MasterTexFile.tex 

and the example Tex file referenced in the code (simply called Text) is under

    My Documents/Course/Text.tex.

My ideal is to have the bibliography in a more general directory altogether, but I have placed it just above the working tex file for illustrative purposes. Document code is as follows:

    \documentclass[12pt,titlepage]{article}
    \usepackage[round,longnamesfirst]{natbib} 
    \usepackage{setspace}
    \doublespacing
    \usepackage[margin=1in]{geometry}
    \usepackage{hyperref} 
    \hypersetup{
    pdftitle={TITLE},    
    pdfauthor={AUTHOR},     
    pdfsubject={SUBJECT},
    pdfkeywords={KEYWORD} {KEYWORD} {KEYWORD}, 
    colorlinks=true,
    linkcolor=blue,              
    citecolor=blue,
    filecolor=magenta,      
    urlcolor=blue           
    }

    \begin{document}
    \title{TITLE}
    \date{\today}
    \author{AUTHOR\\STUDENT NUMBER}
    \maketitle
    %Begin Document Text
    \pagestyle{headings}
    \section{Introduction}
    \cite{Shapiro2015} %Example citation from my database
    \input{../Text} %this comes from the directory ABOVE that of the current file.
    %\input{../00 Master Bibliography} %This was inputted using the user interface (Texmaker). I have it here just to demonstrate that it is truly in the directory.

    %References
    \newpage
    \bibliographystyle{plainnat} 
    \bibliography{../00 Master Bibliography}
    %\bibliography{00_Master_Bibliography} %If the database is in the directory, everything works fine.
    \end{document}

The document compiles (I use PdfLatex, BibTex, PdfLatex x2, sequentially), and properly references the Text document (which just contains the word "Text"), but I get the following errors:

    Package natbib Warning: Citation `Shapiro2015' on page 1 undefined on input line 40.
    Package natbib Warning: Empty `thebibliography' environment on input line 8.
    Package natbib Warning: There were undefined citations.

Note: I have removed some lines of comments for brevity, so if you copy this into your editor the line numbers will be different.

These are to be expected if the database wasn't found, but I have no idea why it wouldn't be found. Does it have anything to do with natbib? Is it a feature of the natbib package that it cannot reference a database from any directory other than that of the current file? This seems unlikely.

Any help would be greatly appreciated!


Solution

  • Well, turns our there was a simple solution. I am not sure whether it is the '00' I had before the bibliography name (I added '00' to make sure it was at the top of the list of files in its folder), or the space between these and the word 'Bibliography', but changing the name of the file to simply `Bibliography' worked.