BibTeX, biblatex and biberCan't get chapterbib-package to work; simple example include

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
bbcda
Posts: 3
Joined: Tue Oct 06, 2009 11:29 am

Can't get chapterbib-package to work; simple example include

Post by bbcda »

Dear all!

For some hours now, I am trying to get the chapterbib-package for Latex to work on a simple example document. I feel like stupid - but I don't seem to find what stops this from working. I would be very grateful for any help with this!

So, here is my simple, but still non-working example; lets begin with the main document, "test.tex":

Code: Select all

% test file for chapterbib
\documentclass{book}

% the packages:
\usepackage[numbers]{natbib}
%\usepackage{chapterbib}		% if the comment sign ("%") is removed (so that this package is being used), the citations marks in the text appear as "[? ]" instead of "[X]" (where "X" is the number for the citation in the bibliography)

\begin{document}
	\include{subfolder/filia}
	\include{subfolder2/filia2}

\end{document}
As You see, I have commented out the command that reads in the chapterbib-package for now (so that it is not read in). More to that later.
Also, I hope You see that I have two filial documents that I read in with the include-command from the subfolders "subfolder" and "subfolder2". Those documents are very simple:
filia.tex looks as this:

Code: Select all

%!TEX root = ../test.tex
\chapter{Math} \label{chapmath}

First Citation: \cite{Pletser1}.

Just another citation: \cite{lin1973}

\bibliographystyle{plain}
\bibliography{biblio}
and filia2.tex as such:

Code: Select all

%!TEX root = ../test.tex
\chapter{Second Chapter} \label{chapSec}

Nothing here - just some dummy text. \cite{blabla3}

% \bibliographystyle{plain}
% \bibliography{biblio2}
As You see in the second filial document "filia2.tex", I have also commented out the section that reads in the second bibliography for the second chapter for now (since I do not even reach this point - more below...).

Now, the two bibliography files "biblio.bib" and "biblio2.bib", which - as the example is written - need to be put into the main folder (the one containing "test.tex"):
biblio.bib:

Code: Select all

@article{Pletser1,
	author  = "Pletser, Vladimir and Huylenbrouck, Dirk",
	title   = "{The Ishango Artefact: the Missing Base 12 Link}",
	journal = "Forma",
	volume= "14",
	pages = {339-346},
	year = 1999
}

@article{lin1973,
   author = "Shen Lin and Brian W. Kernighan",
   title = "An Effective Heuristic Algorithm for the Travelling-Salesman Problem",
   journal = "Operations Research",
   volume = "21",
   year = 1973,
   pages = {498-516}
}
and biblio2.bib:

Code: Select all

@article{blabla3,
	author  = "Test, Tester",
	title   = "{Hmmmm....}",
	journal = "Journal of Advanced Advances",
	volume= "1",
	pages = {1-111},
	year = 2009
}
If I compile this example file, I get an output that shows the bibliography for the first chapter at its end, as expected, and the bibliography for chapter 2 is not shown (since the commands which would produce it are commented out - they wouldn't work anyway, since the chapterbib-package is not read in in the preamble of the main document).
Okay. Now comes the problem: as soon as I remove the comment for the "\include{chapterbib}"-command, and run the Latex-Bibtex-Latex-Latex sequence, I run into trouble: although the bibliography is still produced at the end of the first chapter, the citation marks in the text do not show the correct reference numbers anymore (i.e., "[X]", where X is a number) - instead we only find empty dummy placeholders ("[? ]").

This is the place where I stopped; reading in the second bibliography for the second chapter didn't change anything about this for me (in fact, it gives an error message that the item cited from this bibliography is unknown). Anyway, I do not believe that this (the second bibliography not being read in) is likely to be the cause for the problem I find with the empty dummy placeholders for the citations. Instead, I believe that there is something wrong with the way how I use the chapterbib-package. Could anyone with some more experience with this package please have a look at the example and give me some helpful hints?

Thank You for reading and considering my question! With kind regards,
Björn

Recommended reading 2024:

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

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

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

Can't get chapterbib-package to work; simple example include

Post by localghost »

Perhaps you can benefit from the discussion in another thread [1]. The descriptions are very detailed and should help you in getting things work. The chapterbib manual also gives good explanations.

[1] View topic: chapterbib


Best regards and welcome to the board
Thorsten¹
bbcda
Posts: 3
Joined: Tue Oct 06, 2009 11:29 am

Re: Can't get chapterbib-package to work; simple example include

Post by bbcda »

Hey, Thorsten!

Thanks for Your quick reply!! And thanks for the hint! I have tried the sample file for chapterbib that is included in the linked forum topic from Your email - and it compiles fine on my computer (works great). Just a simple additional question: the sample You gave contains chapters which all include only ONE bibtex-file (sample.bib); the example I have given (above) tries to read in DIFFERENT bibtex-files (one for each chapter that shall contain a bibliography). This, to me, seems to be the central difference between Your example and mine. And after trying a bit more with my example, I need to say that it still doesn't work. Now, my question is: can You (or anybody else) tell me with certainty whether or not my approach (as used in the example above) of using different bib-files for each filial document work or not with the chapterbib-package? Because I would prefer to do for clarity.

Thank You!
With kind regards,
Björn
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Can't get chapterbib-package to work; simple example include

Post by localghost »

I modified my example according to your sample code. It now contains two chapters with citations from two different bibliography databases. It works fine for me. All necessary files as well as the resulting output are in the attached archive. To get the result I had to pass the usual work-flow.

Code: Select all

pdflatex sample.tex
bibtex chp01
bibtex chp02
pdflatex sample.tex
pdflatex sample.tex
Attachments
sample.zip
An example for chapterbib with different bibliography databases for each chapter.
(124.26 KiB) Downloaded 520 times
bbcda
Posts: 3
Joined: Tue Oct 06, 2009 11:29 am

Can't get chapterbib-package to work; simple example include

Post by bbcda »

Hey, Thorsten!

Thanks again for the quick and helpful reply, and the sample files!!
Using Your cooked-down example, I could find out my original problem in my files: I have put the bibtex database files into the wrong folder (directory). As said in my original post, I want my filial documents (the ones includes by the "\include" command) to be in single folders, together with the respective bibtex-files - and, of course, I want the chapterbib-package to work on them, so that I have bibliographies in each chapter.
Well - the problem is that I misinterpreted the way how Latex would handle the path variables (based on my understanding how figure files need to be referenced); for example, in my example I put the Bibtex files into the main (root) directory of the main .tex-file, but opened it in the filial documents (which are in subfolders). With figures, it works this way. But when You Bibtex the filial document's .tex files, the software doesn't find into the correct root directory, and thus doesn't find the .bib-files.

So, to cut it short: the solution was to adjust the path variables for the "\bibliography"-commands in the filial documents. Since I know that this sounds complicated, here is my adjusted minimal working example with the subdirectories. Should anybody want to make use of those files: process as Thorsten explained in the previous post!
sample-folders.zip
chapterbib-example with filial documents and different bibtex-files in subfolders
(154.23 KiB) Downloaded 489 times
Thorsten: thanks again!!

With kind regards,
Björn
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Can't get chapterbib-package to work; simple example include

Post by localghost »

Ah, yes. Now I see what I missed in the beginning. This discussion could have been much shorter. It's just about putting the database files into the same sub-folder as the chapter files.

But you can test another option. Put the database files in the same folder as your root document and give a relative path in your single chapter files.

Code: Select all

\bibliography{../sample-chp01}   % for chp01.tex
\bibliography{../sample-chp02}   % for chp02.tex
I didn't test it but I'm almost convinced that it should work, too. But for the sake of clarity it seems better to put the chapters together with their databases into one sub-folder.
Post Reply