General\include causes missing citations

General information and discussion about TeXnicCenter
Post Reply
brad
Posts: 5
Joined: Wed Mar 14, 2007 10:21 pm

\include causes missing citations

Post by brad »

Hello,

I am attempting to compile my thesis using \include{} for each chapter. The problem I am having is with the citations. When I compile the main document all of the refrences used in the chapters are listed in the bibliography as expected, but the citations within the chapter are replaced with a "?". When I add a preamble and compile a chapters individually, I am able to get the citations and bibiography.

Can anyone give me some advice on how to correct this? What is the correct procedure to use in this situation?

In addition, I'm not entirely clear on how to set up and correctly use the project feature. Perhaps this has something to do with my missing citations?

Thank you so much,
Brad

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
pumpkinegan
Posts: 91
Joined: Thu May 03, 2007 10:29 pm

\include causes missing citations

Post by pumpkinegan »

One approach to a project is to have one tex file set as the main project file. This tex file would have the \documentclass, \usepackage, and \newcommand commands. It would also have the \begin{document} and \end{document} commands:

Code: Select all

\documentclass[12pt]{muthesis}
\usepackage[ps2pdf]{hyperref}
\begin{document}
\title{Title of thesis}
\author{Author Name}
\include{chapter1/thesis-chapter1}
\include{chapter2/thesis-chapter2}
\include{chapter3/thesis-chapter3}
\bibliographystyle{plain}
\bibliography{thesis-references}
\end{document}
thesis-chapter1.tex is a tex file which is in the subdirectory chapter1 (this keeps things tidy, but it is optional). The first line of thesis-chapter1 would be \chapter{Name of chapter 1}. The bibliography file thesis-references.bib is a bib file which is located in the main directory.

That is about it. Make sure you set the main tex file in the project. Make sure you run latex.exe followed by bibtex.exe followed by latex.exe to get correct citations. Remember to redo this when commenting out or adding new chapters because the bbl and aux files will need to be updated.
brad
Posts: 5
Joined: Wed Mar 14, 2007 10:21 pm

Re: \include causes missing citations

Post by brad »

Thanks for the speedy reply!

I just discovered that the error occurred because I was messing around with chapterbib in this file a few days ago and forgot to comment out the line loading the package.

That being said, I was unable to get chapterbib to work correctly. Any suggestions?

Brad
User avatar
pumpkinegan
Posts: 91
Joined: Thu May 03, 2007 10:29 pm

\include causes missing citations

Post by pumpkinegan »

chapterbib is a nice package for a thesis.

In my previous example, I put the bibliography definition at the end of the main tex file---the result is a large bibliography at the end of the compiled document.

Using the chaperbib package, I would put

Code: Select all

\bibliographystyle{plain}
\bibliography{../thesis-references}
at the end of each chapter tex file. Note that the "../" has directed latex.exe and bibtex.exe out of the chapter subdirectory (for example, "chapter1") into the main project directory to where thesis-references.bib is located (remove this if you are not using project directories).

If I recall correctly, you will need to run bibtex.exe on each chapter individually. This is crucial, since each chapter needs to generate its own bbl file. So run latex.exe once on the main tex file. Then run bibtex.exe on each chapter. Then run latex.exe on the main tex file.

Now there should be a bibliography at the end of each chapter. (Note: be careful of duplicated citations across different chapters using chapterbib and hyperref packages because the hyperlinks get all messed up. My workaround solution was to copy and paste bib entries, give a different label, and cite specific labels inside specific chapters.)
brad
Posts: 5
Joined: Wed Mar 14, 2007 10:21 pm

Re: \include causes missing citations

Post by brad »

Thanks! I'm beginning to discover more of the features of TexnicCenter like BibTeX now, and was able to get chapterbib to work correctly this time.

I will keep an eye out for the duplicate references issue. I have many references that will be that way (all those self-citations, you know ;) ), so I'll probably try out your workaround.

Have you ever tried to using "\usepackage[sectionbib]{chapterbib}" in the preamble? Supposedly this will move the bibliographies into a section within each chapter instead of appearing as a separate chapter. However, like all things LaTeX, I haven't been able to get those results yet.

I really appreciate you help!
Brad
Post Reply