Document Classeschapterbib | References following each Chapter

Information and discussion about specific document classes and how to create your own document classes.
JensL
Posts: 3
Joined: Sat Dec 13, 2008 11:37 am

chapterbib | References following each Chapter

Post by JensL »

Hi there,

I am trying to compile a thesis in LaTeX and I need to put in References after each chapter. I have spend hours trying to get chapterbib to work, but I can't get it right.

Can anyone give a good example how to solve this problem? My current structure, cleaned of the formatting code, is this:

Code: Select all

\documentclass[phd,tocprelim]{CU}
\usepackage[sectionbib]{chapterbib}

%\bibliographystyle{plain}
%\bibliographystyle{IEEEbib}

\begin{document}

\include{chapter1/thesis-chapter1}
\include{chapter2/thesis-chapter2}
\include{chapter3/thesis-chapter3}

\end{document}
This is the main document called "Thesis.tex". The three individual chapters are stored in separate sub-folders, following a suggestion from someone on this list. An example for thesis-chapter1 is:

Code: Select all

\chapter{Introduction}

\section{SECTION 1}
The text for Section 1 goes here, without brackets.

test \cite{Brakenridge1994}

\bibliographystyle{plain}
\bibliography{chapter1/thesis-chapter1}
and the bibliography for this chapter is in thesis-chapter1.bib, which looks like this:

Code: Select all

@article{Brakenridge1994,
   Author = {Brakenridge, G.B. and Knox, J.C. and Paylor II, E.D. and Magiligan, F.},
   Title = {Radar Remote Sensing Aids Study of the Great Flood of 1993},
   Journal = {EOS},
   Volume = {75},
   Number = {45},
   Pages = {521-530},
   Year = {1994}
}
and is also stored in the sub-folder. Accordingly, there is a thesis-chapter2.bib in sub-folder "chapter2", and a thesis-chapter3.bib in sub-folder "chapter3".

For a test, I set up chapter 2 identical to chapter 1, but citing

Code: Select all

\cite{Barber1996}
, which is the only reference in thesis-chapter2.bib.
In chapter 3, I want to cite by \cite{awe}, which is the only reference in "thesis-chapter3.bib".

A number of web pages suggest that you need to compile as follows

Code: Select all

latex Thesis.tex
bibtex thesis-chapter1.tex
bibtex thesis-chapter2.tex  
bibtex thesis-chapter3.tex
latex Thesis.tex
latex Thesis.tex
But it doesn't work, and I can't make any sense out of the error messages I get:

Code: Select all

A level-1 auxiliary file: chapter2/thesis-chapter2.aux
Illegal, another \bibstyle command---line 8 of file chapter2/thesis-chapter2.aux
: \bibstyle
:	{plain}

I'm skipping whatever remains of this command


Illegal, another \bibdata command---line 9 of file chapter2/thesis-chapter2.aux
: \bibdata
:	{chapter2/thesis-chapter2}
I'm skipping whatever remains of this command

A level-1 auxiliary file: chapter3/thesis-chapter3.aux
Illegal, another \bibstyle command---line 8 of file chapter3/thesis-chapter3.aux
: \bibstyle
:	{plain}

I'm skipping whatever remains of this command


Illegal, another \bibdata command---line 9 of file chapter3/thesis-chapter3.aux
: \bibdata
:	{chapter3/thesis-chapter3}
I'm skipping whatever remains of this command

Database file #1: chapter1/thesis-chapter1.bib
Warning--I dind't find a database entry for "Barber1996"
Can anyone give a detailed example of how to use chapterbib properly to obtain a bibliography at the end of each chapter?
There are a few comments on this topics on the web, but I can't get it to work.

Any help is greatly appreciated.
Last edited by JensL on Sat Dec 13, 2008 1:52 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

chapterbib | References following each Chapter

Post by localghost »

Please, build a minimal working example (MWE). Since you are using a non-standard document class, you have to attach it to your next post or give at least a link where to find it. Avoid file inclusions in the MWE because other users don't have the included files on their system. Use the filecontents environment to create a short sample bibliography file (*.bib) or attach the one you use.


Best regards and welcome to the board
Thorsten
JensL
Posts: 3
Joined: Sat Dec 13, 2008 11:37 am

chapterbib | References following each Chapter

Post by JensL »

Hi there,

I have tried over and over to get this to work, and in the end I figured out what caused the problem, or at least how to get around it.

I have found many posts online of people having the same problem, but I didn't find any explanation like this. Maybe this can save someone a couple of hours of work and a headache:

When I started from scratch with a main.tex with

Code: Select all

\include{ChapterOne}
\include{ChapterTwo}
\include{ChapterThree}
and ChapterOne.tex, ChapterTwo.tex and ChapterThree.tex in the same folder,
and at the end of each of the included chapters (here the example of ChapterOne)

Code: Select all

\pagebreak
\renewcommand\bibname{{REFERENCES}} %  will print "REFERENCES" instead of "BIBLIOGRAPHY"
\bibliographystyle{elsarticle-harv}
\addcontentsline{toc}{chapter}{REFERENCES} %  adds "REFERENCES" to the table of content
\bibliography{Chapter1Radar}  % uses the references stored in Chapter1Radar.bib
all of a sudden it worked fine.

So I thought great, let me just save it as a project to have it a little more organized, and all of a sudden I had the same old problem, and the references did not show up in the document.

So if you have the same problem, just don't save your file as a project, but take the individual files. It worked perfectly fine for me. Eventually, I have used three .bib files, one for each chapter, and it worked like a charm.

Cheers,
Jens
nash
Posts: 1
Joined: Tue Jan 13, 2009 3:58 am

Re: chapterbib | References following each Chapter

Post by nash »

Hi Jens,

Thank you very much for giving information on what worked for you. That did save me a couple of hours of work.

Cheers, Avinash


PS: I would like to leave a note here if I have any further problems on the multi-paper format thesis I am working on. Please answer them when you find time. Thanks!
mrbobwang
Posts: 2
Joined: Thu Mar 26, 2009 1:14 am

Re: chapterbib | References following each Chapter

Post by mrbobwang »

I have successfully made the chapterbib, natbib and bibunits working. However, one problem still exists, the counter for references from one chapter continues to the next which I want to reset for a new chapter. Does anyone know how?

I suggest the following links for those who want to get reference working for each chapter and have it in their table of contents, also have a final bibliography at the end.

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=chapbib
http://www.eng.cam.ac.uk/help/tpl/textp ... phies.html
http://fuzzy.iau.dtu.dk/download/thesis/Thesis.htm
http://www.cirmmt.mcgill.ca/activities/ ... pdf-slides
http://email.esm.psu.edu/pipermail/maco ... 15843.html
mrbobwang
Posts: 2
Joined: Thu Mar 26, 2009 1:14 am

Re: chapterbib | References following each Chapter

Post by mrbobwang »

I solved the problem by commenting out natbib which was making the reference counter continuous.
pitchounou
Posts: 1
Joined: Sun Mar 29, 2009 5:55 pm

Re: chapterbib | References following each Chapter

Post by pitchounou »

Hi I am currently writting my thesis and I am having the same problem. How did you reset the counter with natbib.

Thanks
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

chapterbib | References following each Chapter

Post by kaiserkarl13 »

I know this post is about two months old, but I wanted to make sure the question got answered in case anyone searches for the same topic later.

To reset the citation counter in natbib, issue

Code: Select all

\setcounter{NAT@ctr}{0}
You could redefine \chapter so that the counter gets reset every time a chapter starts without much trouble:

Code: Select all

\let\newchapter\chapter
\renewcommand{\chapter}{\setcounter{NAT@ctr}{0}\newchapter}}
coolth
Posts: 1
Joined: Wed Jul 08, 2009 5:55 pm

chapterbib | References following each Chapter

Post by coolth »

Thanks kaiserkarl13 - I recently had the same issue with needing to reset the numbering and your follow-up post helped.

To elaborate a little more - I reset the counter in each 'chapter' file. So, instead of having something like:

Code: Select all

\bibliographystyle{plain}
\bibliography{chapter1/thesis-chapter1}
I have:

Code: Select all

%reset bib counter
\setcounter{NAT@ctr}{0}
\bibliographystyle{plain}
\bibliography{chapter1/thesis-chapter1}
Thanks again,
Thorarin Bjarnason
vietnamica
Posts: 21
Joined: Thu Nov 19, 2009 6:00 am

chapterbib | References following each Chapter

Post by vietnamica »

I used this option of [sectionbib] and it works well. No need to reset the counter.

Code: Select all

\usepackage[sectionbib]{chapterbib}
Post Reply