[Tex/LaTex] TeXworks references in included tex files show as [?]

bibtexnatbib

I am try to set up TeXworks on Windows to write my thesis, but have hit a problem with creating a shared bibliography in a two-tier document hierarchy.

I have a main thesis.tex file which sets up the packages and then includes chapters, and finally a bibliography. The collection.bib file is in the folder above thesis.tex, and chapters are in subfolders.

\documentclass[11pt,a4paper]{../uolthesis}
%\usepackage{alltt,float}
%\usepackage{lgrind}
\usepackage{url}                    % for better handling of URL
\usepackage{lscape}                 
\usepackage{subfigure}
\usepackage{mathrsfs}
\usepackage{graphicx}
%\usepackage{caption2}
\usepackage{epstopdf}

\usepackage{sidecap}
\usepackage{../draft_doc}

\graphicspath{{ch1/}{ch2/}}

% correct bad hyphenation here
\hyphenation{op-tical}
% use less hyphenation
\lesshyphenation
% or totally stop it
%\nohyphenation

% speed up compilation
%\includeonly{ch1/ch1}

\begin{document}
\chapter*{thesis title}
\cite{Santner2010,Kalal2011}    % This works
\include{ch1/ch1}               % \cite{} in here produces [?]
\include{ch2/ch2}               % \cite{} in here produces [?]

\clearpage
\markboth{References}{References}
\bibliographystyle{ieeetr}
{\bibliography{../collection}}

\end{document}

The problem is that \cite{} from within thesis.tex work correctly, but the same citations in the chapter tex files produce [?]. The bibliography produced correctly contains all cited papers, so the problem is only in getting the numeric references are the citation point.

The log file is, predictably, full of lines like

Package natbib Warning: Citation `Santner2010' on page 9 undefined on input line 61.

I am compiling with pdfLatex+MakeIndex+BibTeX. I've tried compiling multiple times without success.

What am I doing wrong, please?

Best Answer

This seems to be a problem with the two custom elements included in your MWE - the \documentclass[11pt,a4paper]{../uolthesis} documentclass and whatever is in your \usepackage{../draft_doc} package.

Using the standard report class and commenting the mentioned usepackage line (as well as getting rid of the stuff relating to hyphenation) yields the following which behaves perfectly fine: With the uolthesis class (from OP's comment) I can reproduce the error with the following minimal example:

\documentclass[11pt,a4paper]{../uolthesis}

\begin{filecontents}{ch1/ch1.tex}
\chapter{ch1}
this is include file 1. citing \cite{citekey}.
\end{filecontents}

\begin{filecontents}{ch2/ch2.tex}
\chapter{ch2}
this is include file 2. also citing \cite{citekey}.
\end{filecontents}

\begin{filecontents}{../collection.bib}
@article{citekey,
    author = "Bloggs, Joseph K.",
    journal = "International Journal of Dubious Assertions",
    pages = "337-629",
    title = "Misusing Scientific Terminology for Fun and Profit",
    volume = "202",
    year = "1950"
}
\end{filecontents}


\begin{document}
\chapter*{thesis title}
This cites \cite{citekey}.    % This works
\include{ch1/ch1}             % This works too!
\include{ch2/ch2}             % As does this..

\clearpage
\markboth{References}{References}
\bibliographystyle{ieeetr}
{\bibliography{../collection}}

\end{document}

and commenting the line:

\RequirePackage{chapterbib}         % create bibiography for each chapter

solves the problem.

Refer to the documentation of chapterbib as to why this behaviour would occur and how to use the package if separate bibliographies are needed.