(The following minimal example works fine for me:) EDIT: Yes, it is possible to create section-bibliographies within book chapters. For convenience, I'm switching to the biblatex
package which works together well with the memoir
class. Note that when compiling my example, you have to run BibTeX several times unless you use makefiles like e.g. latexmk. For reference sections see section 3.5.4, for running BibTeX several times see section 3.10.1 of the biblatex
manual.
\documentclass[twocolumn]{memoir}
\usepackage[refsection=chapter]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{test.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
\end{filecontents}
\addbibresource{test.bib}
\begin{document}
\chapter{bla}
\section{blubb}
Some text \autocite{B02}.
\printbibliography[heading=subbibliography]
\chapter{foo}
\section{bar}
Some text \autocite{A01,B02}.
\printbibliography[heading=subbibliography]
\end{document}
(The filecontents environment is only used to include some external files directly into the example, so that it compiles. It is not necessary for the solution.)
Sub-bibliographies work with subfiles
from version 1.5 onwards, available from Github or from CTAN. See its documentation. Note that it is no longer necessary to manipulate the path of files oneself. Below I show how to typeset sub-bibliographies with package
(A) chapterbib
(B) bibunits
(C) biblatex
For each of these scenarios, we consider two file structures.
(1) bib files in the top directory
main.tex
bib1.bib
bib2.bib
chapter1/chapter1.tex
chapter2/chapter2.tex
(2) bib files in the subdirectories
main.tex
chapter1/bib1.bib
chapter1/chapter1.tex
chapter2/bib2.bib
chapter2/chapter2.tex
The bib files contain the following entries.
% bib1.bib
@book{A,
title={The meaning of A},
author={A. Alpha},
year=2019,
publisher={Apublisher}
}
% bib2.bib
@book{B,
title={The meaning of B},
author={B. Beta},
year=2019,
publisher={Bpublisher}
}
(A1) Package chapterbib
, bib files in main directory
% main.tex
\documentclass{report}
\usepackage{chapterbib}
\usepackage{subfiles}
\begin{document}
\subfileinclude{chapter1/chapter1}
\subfileinclude{chapter2/chapter2}
\end{document}
% chapter1/chapter1.tex
\documentclass[../main]{subfiles}
\begin{document}
\chapter{First chapter}
My references: \cite{A}
\bibliographystyle{alpha}
\bibliography{../bib1,../bib2}
\end{document}
% chapter2/chapter2.tex
\documentclass[../main]{subfiles}
\begin{document}
\chapter{Second chapter}
My references: \cite{B}
\bibliographystyle{alpha}
\bibliography{../bib1,../bib2}
\end{document}
To typeset main.tex
, run
pdflatex main
bibtex chapter1/chapter1
bibtex chapter2/chapter2
pdflatex main
pdflatex main
To typeset one of the chapters separately, run
cd chapter1
pdflatex chapter1
bibtex chapter1
pdflatex chapter1
pdflatex chapter1
(A2) Package chapterbib
, bib files in sub-directory
Like (A1), but change the \bibliography
commands to \bibliography{bib1}
in chapter1.tex
and to \bibliography{bib2}
in chapter2.tex
.
(B1) Package bibunits
, bib files in main directory
% main.tex
\documentclass{report}
\usepackage{bibunits}
\defaultbibliographystyle{apalike}
\usepackage{subfiles}
\begin{document}
\subfile{chapter1/chapter1}
\subfile{chapter2/chapter2}
\end{document}
% chapter1/chapter1.tex
\documentclass[../main]{subfiles}
\begin{document}
\begin{bibunit}
\chapter{First chapter}
My references: \cite{A}
\putbib[\subfix{../bib1},\subfix{../bib2}]
\end{bibunit}
\end{document}
% chapter2/chapter2.tex
\documentclass[../main]{subfiles}
\begin{document}
\begin{bibunit}
\chapter{Second chapter}
My references: \cite{B}
\putbib[\subfix{../bib1},\subfix{../bib2}]
\end{bibunit}
\end{document}
To typeset the main document, run
pdflatex main
bibtex bu1
bibtex bu2
pdflatex main
pdflatex main
To typeset the chapters separately, run
cd chapter1
pdflatex chapter1
bibtex bu1
pdflatex chapter1
pdflatex chapter1
(B2) Package bibunits
, bib files in sub-directory
Like (B1), but change the \putbib
commands to \putbib[\subfix{bib1}]
in chapter1.tex
and to \putbib[\subfix{bib2}]
in chapter2.tex
.
(C1) Package biblatex
, bib files in main directory
% main.tex
\documentclass{report}
\usepackage{biblatex}
\usepackage{subfiles}
\bibliography{bib1,bib2}
\begin{document}
\subfileinclude{chapter1/chapter1}
\subfileinclude{chapter2/chapter2}
\end{document}
% chapter1/chapter1.tex
\documentclass[../main]{subfiles}
\begin{document}
\newrefsection
\chapter{First chapter}
My references: \cite{A}
\printbibliography
\end{document}
% chapter2/chapter2.tex
\documentclass[../main]{subfiles}
\begin{document}
\newrefsection
\chapter{Second chapter}
My references: \cite{B}
\printbibliography
\end{document}
To typeset the main document, run
pdflatex main
biber main
pdflatex main
pdflatex main
To typeset the chapters separately, run
cd chapter1
pdflatex chapter1
biber chapter1
pdflatex chapter1
pdflatex chapter1
(C2) Package biblatex
, bib files in sub-directory
Like (C1), but replace the \bibliography
command in main.tex
by \bibliography{chapter1/bib1,chapter2/bib2}
.
Note on filenames and their paths
In general, filenames (with an optional path) have to be surrounded by \subfix{...}
, as demonstrated in (B1) and (B2). The \bibliography
command has this \subfix
magic already built-in, therefore \subfix
is not needed in (A1), (A2), (C1) and (C2) (in fact, it rather would mess up things).
Best Answer
Use of
refsegment
will continue label numbering for you. To print a reference in just one sub-bibliography (and completely frustrate most readers), you can track the continuation number for eachrefsegment
and skip any items whose label is less than that number.In the example below the default sorting scheme is used, but it could be changed. To get the label numbers right, this approach will require a couple additional passes with
latex
.biblatex
gives you a message whenever another pass is needed.Results for the first chapter:
And the second:
And the third: