I tried to go through already posted solutions but I was not able to find one working for my case. I am compiling a ph.d. thesis with one main file, by including chapters. The format is the following
\documentclass[12pt, twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage[pagestyles]{titlesec}
\titleformat{\chapter}[display]{\normalfont\bfseries}{}{0pt}{\Huge}
\newpagestyle{mystyle}
{\sethead[\thepage][][\chaptertitle]{}{}{\thepage}}
\pagestyle{mystyle}
\usepackage[semicolon,round,sort&compress]{natbib}
\usepackage[sectionbib]{chapterbib}
\usepackage{hyperref}
\usepackage{epstopdf}
\usepackage{rotating}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{pdflscape}
\usepackage{calc}
\usepackage{float}
\usepackage{indentfirst}
\usepackage{chronology}
\usepackage[toc,page]{appendix}
\usepackage{graphics}
\usepackage{color,soul}
\usepackage{tablefootnote}
\usepackage{epsfig}
\usepackage{subfigure}
\usepackage{grffile}
\usepackage{soul}
\usepackage{longtable}
\usepackage{lscape}
\usepackage{url}
\usepackage{epsfig}
\graphicspath{ {images/} }
\usepackage{caption}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm
\begin{document}
\input{chapters/titlepage}
\mainmatter
\tableofcontents
\listoffigures
\listoftables
\chapter{Introduction}
\input{chapters/chap0}
\chapter{chap1}
\input{chapters/chap1}
\chapter{chap2}
\input{chapters/chap2}
\end{document}
Each chapter has its respective bibliography at the end, as follows
\bibliographystyle{apalike}
\bibliography{chapters/bib0}
in the case of chap0. Note that each chapter cannot be compiled alone, since it starts with \section{}
, and no \begin{document}
. However, things work well only for the first \input{ }
, i.e. only for chapter 0. From chapter1 onwards I get just the bibliography of chapter0 repeating. THerefore I get ?? as output in the text for new references. Warnings say that ref'x' is multiple defined and, later, that refx
is not defined. How can I fix that ?
Bibtek files are as follows:
bib0
@article{acemoglu2000,
title={The colonial origins of comparative development: An empirical investigation},
author={Acemoglu, Daron and Johnson, Simon and Robinson, James A},
year={2000},
institution={National bureau of economic research}
}
@book{acemoglu2012,
title={Why nations fail: the origins of power, prosperity and poverty},
author={Acemoglu, Daron and Robinson, James A and Woren, Dan},
volume={4},
year={2012},
publisher={SciELO Chile}
}
bib1
@article{acemoglu2000,
title={The colonial origins of comparative development: An empirical investigation},
author={Acemoglu, Daron and Johnson, Simon and Robinson, James A},
year={2000},
institution={National bureau of economic research}
}
@article{ackerberg2006,
title={Structural identification of production functions},
author={Ackerberg, Daniel and Caves, Kevin and Frazer, Garth},
year={2006}
}
Compile goes as follow: pdflatek -> biblatek -> pdflatek(x2). Looks like it is the only compiling solution working
Best Answer
References will not be generated as required because of the incorrect usage of
\chapterbib
withnatbib
. The correct usage is:When
natbib
is not being used as the citation manager, the usage of\chapterbib
for references at the end of each chapter is:This is the complete file to generate the list of references at the end of each chapter based on the code that was uploaded. A few commands from the original file are suppressed for convenience. To avoid getting orphan chapter headings I moved the
\chapter
commands inside the included files. I also deleted the paths to theincluded
andbib
files for simplicity.Remember to run the compiler (
PDFLaTeX
) on the main file which will generate auxiliary (aux
) files for each included file. Then open each auxiliary file and runbibtex
on each of those files. This will generatebbl
files for each chapter. Then go back to the main file and rerun the compiler twice.