Creating multiple bibliographies in the same document
Introduction
This article will discuss how you can create multiple bibliographies in the same LaTeX document using appropriate packages. By default, each LaTeX document can contain only one bibliography or reference list, either with a \begin{thebibliography}\bibitem...\end{thebibliography} list or with \bibligraphystyle{...}\bibliography{...}, or \printbibliography. But there are situations where you may need to create multiple bibliographies. You might want to have a separate bibliography for each chapter, rather than for the entire document. Or you might want to have separate bibliographies for different categories and themes.
If you try to cater for these scenarios by putting multiple \bibliography calls at different locations in your LaTeX document, you'll find that they all contain the same list of items, encompassing all citations in your entire document. Instead, you'll have to use the appropriate LaTeX packages to correctly generate separate bibliographies.
You'll first need to determine if you're using BibTeX or biblatex: they require different packages which cannot be mixed. If you're using a template provided by your publisher or university, check if the sample template .tex file contains \printbibliography or \addbibresource. If so, you're using biblatex, so head on to the section here. Otherwise, you're most probably using BibTeX, so continue reading here.
Packages for BibTeX
The chapterbib package
If you simply need to have a bibliography at the end of each chapter of your book/thesis, the chapterbib package may be all you need.
- Each chapter should be in a
.texfile of its own. Writeat the end of each chapter in each\bibliographystyle{...} \bibliography{...}
.texfile. You can specify a different.bibfile for each chapter in the\bibliography. - In your "main document"
.texfile, load thechapterbibpackage. Thesectionbibpackage option is useful if you want the bibliography for each chapter to appear as an unnumbered section instead of an unnumbered chapter after the actual chapter.\usepackage[sectionbib]{chapterbib}
- Use
\includein the main document file to pull in each of your chapter.texfiles.\inputwill not work withchapterbibto produce the per-chapter bibliographies! - If compiling on a local machine: Compiling your main document
.texwill generate multiple.auxfiles, one for each chapter.texfile you had included. You must now runbibtexon all these.auxfiles, before compiling the main document.texfile again. Overleaf's build tool,latexmk, will take care of all these processing steps automatically, so all you need to do is to click the "Recompile" button once.
Note that you must not write \bibliobraphy{...} in your main document .tex file when using chapterbib. Otherwise you may get lots of BibTeX error messages about "Illegal; another \bibdata command". If you also need to have a "global" bibliography that collects all the citations in the entire document, the bibunits package might be a better choice.
The bibunits package
The bibunits package can also be used to create per-chapter bibliographies, and the chapters do not need to be in separate .tex files.
- Start by writing
\usepackage[sectionbib]{bibunits}in your main document.tex's preamble. - To use the same
.bibfile and bibliography style for all citations in your document, use the\defaultbibliographystyle{...}and\defaultbibliography{...}commands after loadingbibunits. For example:\defaultbibliographystyle{unsrt} \defaultbibliography{references} % name of the .bib file without extensions
- Add
\bibliographyunit[\chapter]after\begin{document}. - At the end of each chapter, add
\putbib. This will then print the bibliography for all instances of\citethat have occurred since the last\chapter. (You can write\bibliographyunitwithout any arguments at a later point in the document to turn off the automaticbibunit-ing of chapters.) - If compiling on a local machine: Compiling your main document
.texwill generate multiple.auxfiles, one for each chapter.texfile you had included. You must now runbibtexon all these.auxfiles, before compiling the main document.texfile again. Overleaf's build tool,latexmk, will take care of all these processing steps automatically, so all you need to do is to click the "Recompile" button once.
A few extra tips:
- If you are using a different
.bibfile for each chapter/unit, you can specify it as an optional argument to\putbib, e.g.\putbib[chap1refs]—note, no.bibextension. - If you need to divide your document into arbitrary "bibliography units" (i.e. not confined to
\chapteror other section heading commands) with self-contained citations and bibliographies, you can use thebibunitenvironment, with a\putbibwithin it:\begin{bibunit} ...\cite{smith2012} and \cite{wilkins2008}... \putbib \end{bibunit}
If you need a different style for a particular
bibuniti.e. different to the\defaultbibliographystyle{...}that you had specified, you can pass it as an optional argument to thebibunit:\begin{bibunit}[plain] - If you also need a "global" bibliography that includes all citations from all chapters or bibunits, add the
globalcitecopyoption when loading thebibunitspackage:
\usepackage[sectionbib,globalcitecopy]{bibunits}
The multibib package
Sometimes you may want to have separate bibliographies for different categories. One way to achieve this is to use the multibib package. For example, to create a bibliography list for chemistry-related references, and one for physics-related references, here are the steps required:
- Load the
multibibpackage, and use the\newcitescommand to create the "Math" and "Phys" bibliography types. They will have "Math Readings" and "Physics Readings" as the bibliography headings.\usepackage[resetlabels,labeled]{multibib} \newcites{Math}{Math Readings} \newcites{Phys}{Physics Readings}
You can use comma-separated values to create multiple bibliography types in the same
\newcites{}command; just be sure that you have specified the correct number of bibliography titles, too:\newcites{Math,Phys}{Math Readings,Physics Readings}
- For each new bibliography
X, you now have new commands\citeX,\bibliographystyleX,\bibliographyX. Therefore you will now have\citeMath,\bibliographystyleMath,\bibliographyMath\citePhys,\bibliographystylePhys,\bibliographyPhys
in addition to the default
\cite,\bibliographystyle,\bibliographyYou can now use
\bibliographystyle,\bibliographystyleMath,\bibliographystylePhysto specify the style for each bibliography; and specify the.bibfile for each\bibliography,\bibliographyMath,\bibliographyPhys. (The bibliography style is often consistent across all bibliographies, but you might use different.bibfiles.)\cite{paper1} and \cite{paper2} were published later than \citeMath{paper3}. See also \citePhys{paper4}. \bibliographystyle{unsrt} \bibliography{references} \bibliographystyleMath{unsrt} \bibliographyMath{refs-etc} \bibliographystylePhys{unsrt} \bibliographyPhys{refs-etc}
In this example,
paper1andpaper2are defined inreferences.biband will be listed in the default bibliography.paper3will be listed in the "Math Readings" bibliography;paper4in the "Physics Readings" bibliography; bothpaper3andpaper4are defined inrefs-etc.bibfile. - If compiling on a local machine: Compiling your main document
.texwill generate multiple.auxfiles. You must now runbibtexon all these.auxfiles, before compiling the main document.texfile again. On Overleaf, you just need to click the Recompile button and it will take care of all these steps automatically.
With biblatex
If you're using the biblatex package, then you should not load any of the packages mentioned in the previous sections: this includes natbib, chapterbib, bibunits, multibib.
Per-chapter bibliographies
The biblatex package has a refsection mechanism, similar to a "bibunit".
- You can have
biblatexautomatically start a newrefsectionwhen it encounters\chapter, by adding therefsection=chapteroption when loadingbiblatex:\usepackage[natbib,style=authoryear,refsection=chapter]{biblatex} \addbibresource{refs.bib}
- You can then put a
\printbibliographyat the end of each\chapter, to list only the citations that had appeared since the last\chapter. In the code sample below, we also use theheading=subbibintocoption for\printbibliography, so that the bibliography is printed at the end of the chapter as an unnumbered section (subbib) rather than an unnumbered chapter; and such that it will be included in the table of contents (intoc).\chapter{First Chapter} \section{Section Heading} Here's a citation! \citep{latex:companion} \printbibliography[heading=subbibintoc] \chapter{Second Chapter} \section{Section Heading} Here's another citation! \citep{lshort} \printbibliography[heading=subbibintoc]
- Alternatively, you can put
\begin{refsection}...\end{refsection}around each chapter, or around arbitrary blocks of text. Do not use therefsection=chapteroption in this case:\usepackage[natbib,style=authoryear]{biblatex} \addbibresource{refs.bib} ... \begin{refsection} \chapter{First Chapter} \section{Section Heading} Here's a citation! \citep{latex:companion} \printbibliography[heading=subbibintoc] \end{refsection} \begin{refsection} \chapter{Second Chapter} \section{Section Heading} Here's another citation! \citep{lshort} \printbibliography[heading=subbibintoc] \end{refsection} %% A list of publications can be created using this approach \begin{refsection} \nocite{paper1,paper2} %% Here we want an unnumbered chapter, but with a different title \printbibliography[title={List of Publications}] \end{refsection}
Open an example in Overleaf. In this example, main.tex uses the [refsection=chapter] package option, while alt.tex uses the manually-inserted refsection environments.
Bibliographies for different categories
You can use keywords or categories to create separate bibliographies based on different topics.
Using keywords
- In this approach, you need to add a
keywordsfield to your reference entry in the.bibfile. For example:@article{paper4, title={High energy colliders as black hole factories...}, ... keywords={phys} }
- Cite your references as usual.
- Then issue several
\printbibliographycommands while specifying whichkeywordto include. You can set differenttitles for each\printbibliographycommand:% The "main" bibliography \printbibliography[notkeyword={math},notkeyword={phys}] % The Math bibliography \printbibliography[keyword={math},title={Math Readings}] % The Physics Bibliography \printbibliography[keyword={phys},title={Physics Readings}]
Using categories
-
In this approach, you do not need to add any extra fields to your
.bibfile. Instead, you'll declare the category types and add the references to each category, in your.texfile's preamble:\addbibresource{refs-nokeywords.bib} \DeclareBibliographyCategory{math} \DeclareBibliographyCategory{phys} \addtocategory{math}{paper3} \addtocategory{phys}{paper4}
- Cite your references as usual.
- Then issue several
\printbibliographycommands, each specifying whichcategoryto print.% The "main" bibliography \printbibliography[notcategory={math},notcategory={phys}] % The Math bibliography \printbibliography[category={math},title={Math Readings}] % The Physics Bibliography \printbibliography[category={phys},title={Physics Readings}]