> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/questions-and-answers/07-creating-multiple-bibliographies-in-the-same-document.md).

# 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](/latex/references-and-citations/01-bibliography-management-with-bibtex.md) or [biblatex](/latex/references-and-citations/03-bibliography-management-with-biblatex.md): 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](#with-biblatex). Otherwise, you're most probably using BibTeX, so continue reading [here](#packages-for-bibtex).

## 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

   ```latex
   \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.

   ```latex
   \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`,](/latex/knowledge-base/064-how-does-overleaf-compile-my-project.md) 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](https://www.overleaf.com/project/new/template/5694?id=8827885\&mainFile=main.tex\&templateName=Per-chapter+bibliographies+with+chapterbib)

### 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:

   ```latex
   \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`,](/latex/knowledge-base/064-how-does-overleaf-compile-my-project.md) 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](https://www.overleaf.com/project/new/template/5695?id=8828133\&mainFile=main.tex\&templateName=Per-chapter+bibliographies+with+bibunits)

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:

  ```latex
  \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.

   ```latex
   \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:

   ```latex
   \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.)

   ```latex
   \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](https://www.overleaf.com/project/new/template/18645?id=3104751\&latexEngine=pdflatex\&mainFile=main.tex\&templateName=Multiple+Bibliographies+with+multibib)

## 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`:

   ```latex
   \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`).

   ```latex
   \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:

   ```latex
   \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.](https://www.overleaf.com/docs?snip_uri=https://assets.ctfassets.net/nrgyaltdicpt/3mfINcJWZRlegHyXND3SEQ/7843cab4a5d022161a43bea6662bc00b/biblatex-perchapter.zip) 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:

   ```bibtex
   @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 `title`s for each `\printbibliography` command:

   ```latex
   % 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](https://www.overleaf.com/docs?snip_uri=https://assets.ctfassets.net/nrgyaltdicpt/3Bt5Tf9eSCtcXQrGshjQJT/7c64c3820a4adc4e20468aee752dc1e9/biblatex-keywords.zip)

#### 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:

   ```latex
   \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.

   ```latex
   % 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](https://www.overleaf.com/docs?snip_uri=https://assets.ctfassets.net/nrgyaltdicpt/6l5HYYfby0AscSXwLsWKPM/71b6fb3e848f473fc9d2735847af7ec1/biblatex-categories.zip)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/questions-and-answers/07-creating-multiple-bibliographies-in-the-same-document.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
