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
.tex
file of its own. Write\bibliographystyle{...} \bibliography{...}
.tex
file. You can specify a different.bib
file for each chapter in the\bibliography
. - In your "main document"
.tex
file, load thechapterbib
package. Thesectionbib
package 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
\include
in the main document file to pull in each of your chapter.tex
files.\input
will not work withchapterbib
to produce the per-chapter bibliographies! - If compiling on a local machine: Compiling your main document
.tex
will generate multiple.aux
files, one for each chapter.tex
file you had included. You must now runbibtex
on all these.aux
files, before compiling the main document.tex
file 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
.bib
file 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\cite
that have occurred since the last\chapter
. (You can write\bibliographyunit
without 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
.tex
will generate multiple.aux
files, one for each chapter.tex
file you had included. You must now runbibtex
on all these.aux
files, before compiling the main document.tex
file 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
.bib
file for each chapter/unit, you can specify it as an optional argument to\putbib
, e.g.\putbib[chap1refs]
—note, no.bib
extension. - If you need to divide your document into arbitrary "bibliography units" (i.e. not confined to
\chapter
or other section heading commands) with self-contained citations and bibliographies, you can use thebibunit
environment, with a\putbib
within it:\begin{bibunit} ...\cite{smith2012} and \cite{wilkins2008}... \putbib \end{bibunit}
If you need a different style for a particular
bibunit
i.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
globalcitecopy
option when loading thebibunits
package:
\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
multibib
package, and use the\newcites
command 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
,\bibliography
You can now use
\bibliographystyle
,\bibliographystyleMath
,\bibliographystylePhys
to specify the style for each bibliography; and specify the.bib
file for each\bibliography
,\bibliographyMath
,\bibliographyPhys
. (The bibliography style is often consistent across all bibliographies, but you might use different.bib
files.)\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,
paper1
andpaper2
are defined inreferences.bib
and will be listed in the default bibliography.paper3
will be listed in the "Math Readings" bibliography;paper4
in the "Physics Readings" bibliography; bothpaper3
andpaper4
are defined inrefs-etc.bib
file. - If compiling on a local machine: Compiling your main document
.tex
will generate multiple.aux
files. You must now runbibtex
on all these.aux
files, before compiling the main document.tex
file 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
biblatex
automatically start a newrefsection
when it encounters\chapter
, by adding therefsection=chapter
option when loadingbiblatex
:\usepackage[natbib,style=authoryear,refsection=chapter]{biblatex} \addbibresource{refs.bib}
- You can then put a
\printbibliography
at 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=subbibintoc
option 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=chapter
option 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
keywords
field to your reference entry in the.bib
file. For example:@article{paper4, title={High energy colliders as black hole factories...}, ... keywords={phys} }
- Cite your references as usual.
- Then issue several
\printbibliography
commands while specifying whichkeyword
to include. You can set differenttitle
s for each\printbibliography
command:% 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
.bib
file. Instead, you'll declare the category types and add the references to each category, in your.tex
file's preamble:\addbibresource{refs-nokeywords.bib} \DeclareBibliographyCategory{math} \DeclareBibliographyCategory{phys} \addtocategory{math}{paper3} \addtocategory{phys}{paper4}
- Cite your references as usual.
- Then issue several
\printbibliography
commands, each specifying whichcategory
to 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}]
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class