Bruker natbib med BibTeX og Overleaf

Denne siden er for øyeblikket ikke tilgjengelig på norsk, så den presenteres på engelsk. Kunne du tenke deg å støtte oss ved å hjelpe til med å oversette denne siden? Oversett denne siden

The natbib package revolutionizes the standard \cite{*} command in LaTeX, when using BibTeX; providing a plethora of options for author-year schemes and displaying both textual and parenthetical information when using BibTeX. With this enhanced feature, you can easily customize your citations to suit any style preferences!

Trenger du en enkel løsning for håndtering av dine BibTeX-oppføringer? Utforsk CiteDrive!

  • Nettbasert, moderne referansehåndtering
  • Samarbeid og del med forskerkolleger
  • Integrasjon med Overleaf
  • Omfattende støtte for BibTeX/BibLaTeX
  • Lagre artikler og nettsteder direkte fra nettleseren din
  • Søk etter nye artikler i en database med titalls millioner av referanser
Prøv CiteDrive

Why use natbib?

natbib is a LaTeX package that allows you to use bibtex references more freely. It includes many citation commands and citation styles not found in standard bibtex, as well as the ability to customize existing citation styles to meet your needs; most notably, ab citation style requirements. One of the advantages of using natbib is the ability to generate author-year in a narrative or textual format. As an alternative, you could look into BibLaTeX, which includes all of these features on top of a much more feature-rich ecosystem and a very robust framework.

Getting started

Step 1: Create a bibliography

We recommend using CiteDrive to create the.bib-file because it assists you with formatting and saves articles from your browser directly to your bibliography. Among many other features, such as native BibTeX/BibLaTeX support, collaboration, error handling, and formatting, Overleaf allows you to keep your bibliographies in sync. Overleaf has more information.

Your bib-file, which you can also create manually if you don’t want to use CiteDrive, is a bibliographic reference file that LaTeX uses to format bibliographies and citations. Here’s an example of a straightforward bib-file:

@book{knuth1984texbook,
title = {The {\TeX}book},
author = {Donald E. Knuth},
year = 1984,
publisher = {Addison-Wesley}
}
@article{lamport1994latex,
title = {{LaTeX}: A Document Preparation System},
author = {Leslie Lamport},
year = 1994,
journal = {Addison-Wesley}
}
@inproceedings{gosling1995java,
title = {The Java Language Environment},
author = {James Gosling and Henry McGilton},
year = 1995,
booktitle = {Proceedings of the Sun Microsystems
Symposium on the Java Language},
publisher = {Sun Microsystems}
}

In this example, we have three references of different types (book, article, and inproceedings). Each reference is given a unique identifier (e.g. knuth1984texbook), which can be used to cite the reference in the LaTeX document.

Step 2: Create a TeX file

Here’s how to get everything together in our tex-file after we’ve created our.bib-file:

  1. Include the natbib package in your LaTeX document by adding the following line to the preamble:
\usepackage{natbib}
  1. Specify the citation style you want to use. For example, if you want to use the numeric style, add the following line:
\bibliographystyle{plainnat}
  1. We will include our previously generated bibliographic reference file, which is in.bib format, in your LaTeX document using the bibliography command — notice that we omit the file extension.
\bibliography{references}
  1. To cite a reference in the text, use the \cite or \citep command followed by the reference identifier:
As discussed in \cite{knuth1984texbook},
\TeX\ is a powerful typesetting system.
  1. Finally, include the following command to produce the bibliography at the end of your document:
\bibliography