[Tex/LaTex] Including \bibliography command from separate tex file

bibliographiesbibtexchaptersfilesinput

I am writing a thesis and I am organizing the contents in the way described on this page.

In my project folder, the main document is thesis.tex. It looks like this:

% Write the thesis in report format (thesis.tex)
\documentclass[12pt,letterpaper]{report}

% Insert packages
\usepackage{style}

% Insert preamble
\input{./tex/preamble}

% Begin the thesis
\begin{document}

% Insert title
\input{./tex/title}

% Insert table of contents, figures, and tables
\tableofcontents
\listoffigures
\listoftables

% Insert the introduction
\input{./tex/introduction}

% Insert the conclusion
\input{./tex/conclusion}

% Insert the bibliography
\input{./tex/bibliography}

\end{document}

As you can see, all the chapters are located in the tex subdirectory. In particular, the tex subdirectory contains a bib file tex/references.bib and a file tex/bibliography.tex that looks like this:

% Bibliography (tex/bibliography.tex)

% Make the bibliography
\bibliographystyle{plain}
\bibliography{./references}

Now when I compile thesis.tex, the bibliography doesn't appear and I get

Warning: Citation 'aslam2013' undefined on page 4 on input line 4

However, if I instead put the following directly in thesis.tex:

\bibliographystyle{plain}
\bibliography{./tex/references} 

then I get no warning and the bibliography appears.

It's not such a big deal, but I would have liked my bibliography to be organized in a tex file just like the others. Why can't I include the bibliography the way I do? It must be quite obvious for some of you but I really can't see what's wrong…

I'm using Texnic Center on Windows 10.

Best Answer

Your paths always have to be relative to the main document - i.e. thesis.tex. This applies to \bibliography, as well as to \inputs and \includegraphics. Thus, you have to call

\bibliography{./tex/references} 

inside your file ./tex/bibliography.tex - even though both files are located in the same directory.

The same applies e.g. to images: in your file ./tex/introduction.tex, you'll have to include an example image located at ./tex/images/intro_image.jpg with

\includegraphics{./tex/images/intro_image.jpg}

and not with ./images/intro_image.jpg.

Related Question