I want to write an article with supporting info which includes a table of content. Also main text and supporting info should have separate bibliographies printed. For testing, I used this example and modified it. I use Overleaf. There are two files chap1 and chap2. In chap2 I want to include ToC. As soon as I include the ToC, I get the following warning and a "?" where the citation should be:
Package natbib Warning: Citation `lshort' on page 3 undefined on input line 5. and
Package natbib Warning: There were undefined citations.
The main.tex:
\documentclass{article}
\usepackage[english]{babel}
\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\usepackage{siunitx}
\usepackage{natbib}
\citestyle{nature}
\usepackage{chapterbib}
\title{Your Paper}
\author{You}
\begin{document}
\maketitle
\include{chap1}
\include{chap2}
\end{document}
The chap1.tex:
\section{First Chapter}
\subsection{Section Heading}
Here's a citation! \citep{latex:companion}
\bibliographystyle{dcu}
\bibliography{sample}
The chap2.tex:
\section{Second Chapter}
\tableofcontents
\subsection{Section Heading}
Here's another citation! \citep{lshort}
\bibliographystyle{dcu}
\bibliography{sample}
and sample.bib:
@BOOK{latex:companion,
title = {The {\LaTeX} Companion},
publisher = {Addison-Wesley},
year = {2004},
author = {Frank Mittelbach and Michel Goossens and Johannes Braams and David
Carlisle and Chris Rowley},
series = {Addison-Wesley Series on Tools and Techniques for Computer Typesetting},
address = {Boston, MA, USA},
edition = {2nd}
}
@MANUAL{lshort,
title = {The Not So Short Introduction to {\LaTeXe}},
author = {Tobias Oetiker and Hubert Partl and Irene Hyna and Elisabeth Schlegl},
edition = {4.2},
year = {2006}
}