Zum Inhalt springen

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.

  1. Each chapter should be in a .tex file of its own. Write
    \bibliographystyle{...}
    \bibliography{...}
    
    at the end of each chapter in each .tex file. You can specify a different .bib file for each chapter in the \bibliography.
  2. In your "main document" .tex file, load the chapterbib package. The sectionbib 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}
    
  3. Use \include in the main document file to pull in each of your chapter .tex files. \input will not work with chapterbib to produce the per-chapter bibliographies!
  4. 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 run bibtex 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.

Open an example in Overleaf

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.

  1. Start by writing \usepackage[sectionbib]{bibunits} in your main document .tex's preamble.
  2. To use the same .bib file and bibliography style for all citations in your document, use the \defaultbibliographystyle{...} and \defaultbibliography{...} commands after loading bibunits. For example:
    \defaultbibliographystyle{unsrt} 
    \defaultbibliography{references} % name of the .bib file without extensions
    
  3. Add \bibliographyunit[\chapter] after \begin{document}.
  4. 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 automatic bibunit-ing of chapters.)
  5. 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 run bibtex 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.

Open an example in Overleaf

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 the bibunit 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 the bibunit: \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 the bibunits 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:

  1. 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}
    
  2. 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 and paper2 are defined in references.bib and will be listed in the default bibliography. paper3 will be listed in the "Math Readings" bibliography; paper4 in the "Physics Readings" bibliography; both paper3 and paper4 are defined in refs-etc.bib file.

  3. If compiling on a local machine: Compiling your main document .tex will generate multiple .aux files. You must now run bibtex 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.

Open an example in Overleaf

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".

  1. You can have biblatex automatically start a new refsection when it encounters \chapter, by adding the refsection=chapter option when loading biblatex:
    \usepackage[natbib,style=authoryear,refsection=chapter]{biblatex}
    \addbibresource{refs.bib}
    
  2. 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 the heading=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]
    
  3. Alternatively, you can put \begin{refsection}...\end{refsection} around each chapter, or around arbitrary blocks of text. Do not use the refsection=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

  1. 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}
    }
    
  2. Cite your references as usual.
  3. Then issue several \printbibliography commands while specifying which keyword to include. You can set different titles 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}]
    

Open an example in Overleaf

Using categories

  1. 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}
    
  2. Cite your references as usual.
  3. Then issue several \printbibliography commands, each specifying which category 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}]
    

Open an example in Overleaf

Overleaf guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX