Hoppa till innehåll

Natbib Tutorial: Mastering Reference Management in LaTeX with BibTeX

Det här innehållet är inte tillgängligt på ditt språk än.

Managing bibliographic references in LaTeX becomes streamlined and efficient with the natbib package. Whether you’re working with the traditional \cite{*} command or diving deep into advanced citation methods, this guide provides foundational insights to get you started.

Behöver du en enkel lösning för att hantera dina BibTeX-poster? Upptäck CiteDrive!

  • Webbaserad, modern referenshantering
  • Samarbeta och dela med forskarkollegor
  • Integration med Overleaf
  • Omfattande stöd för BibTeX/BibLaTeX
  • Spara artiklar och webbplatser direkt från din webbläsare
  • Sök efter nya artiklar i en databas med tiotals miljoner referenser
Prova CiteDrive ► Titta på demo

Introduction to natbib and Its Strengths

The natbib package extends the capabilities of the standard \cite{*} command in LaTeX. It particularly shines in in-text citations with various options and customizations, especially for author-year schemes and displaying textual and parenthetical citations when integrated with BibTeX.

Let’s delve into the details of how to harness the power of natbib to format and cite your bibliographic sources.

Kickstarting Your Journey: Parenthetical and Textual/Narrative In-Text Citations with natbib

Setting up natbib requires a similar structure to the standard LaTeX setup. Start by loading the library using \usepackage{natbib}. The library offers several configuration options via \usepackage[options]{natbib}, discussed in detail below. The primary citation commands in Natbib are \citet{*} for textual/narrative citations and \citep{*} for parenthetical citations.

\documentclass{article}
\usepackage{natbib}
\bibliographystyle{apalike}
\title{A Comprehensive Guide to Reference Management using natbib with BibTeX}
\author{CiteDrive}
\date {January 1988}
\begin{document}
\maketitle
\textbf{Narrative citation:} \citet{Doe:1966} investigated the risks of incorrectly \\
recorded [...], which results in distortion.
\textbf{Parenthetical citation:} The risks of incorrect recording of [...] could lead to distortion
\citep{Doe:1966}.
\medskip
\bibliography{sample}
\end{document}

By using \bibliography{sample}, you point LaTeX towards your .bib-file, which contains bibliographic entries like:

@article{Doe:1966,
title = {Study on the risks of incorrectly recorded [...] and their impact on [...].},
author = {John Doe},
year = 1966,
journal = {BibTeX Publishing},
volume = 44,
number = 44,
pages = {123--456}
}
@article{smith2017,
title = {An interesting article},
author = {John Smith},
year = {2017},
journal = {Journal of Interesting Articles}
}

Output example of reference management using natbib with BibTeXOutput example of reference management using natbib with BibTeX

For those inclined towards numeric citation styles, here’s how you adapt natbib:

\usepackage[square,numbers]{natbib}
\bibliographystyle{abbrvnat}

Output example of reference management using natbib with BibTeX in numeric styleOutput example of reference management using natbib with BibTeX in numeric style

Deep Dive: Exploring the cite{*} Commands in natbib

Understanding the range of cite{*} commands provided by natbib allows you to cite sources efficiently. This table breaks down their outputs:

Command (single citation)Output (author-year)Output (Numeric)Command (Multiple citations)Output (author-year)Output (Numeric)
\citet{Doe:1966}Doe (1966)Doe [1]\citet{Doe:1966,smith2017}Doe (1966); Smith (2017)Doe [1], Smith [2]
\citet[chap.~4]{Doe:1966}Doe (1966, chap. 4)Doe [1, chap. 4]\citet[chap.~4]{Doe:1966,smith2017}Doe (1966); Smith (2017, chap. 4)Doe [1], Smith [2, chap. 4]
\citep{Doe:1966}(Doe, 1966)[1]\citep{Doe:1966,smith2017}(Doe, 1966; Smith, 2017)[1, 2
\citep[chap.~4]{Doe:1966}(Doe, 1966, chap. 4)[1, chap. 4\citep[chap.~4]{Doe:1966,smith2017}(Doe, 1966; Smith, 2017, chap. 4)1, 2, chap. 4]
\citep[see][]{Doe:1966}(see Doe, 1966)[see 1]\citep[see][]{Doe:1966,smith2017}(see Doe, 1966; Smith, 2017)[see 1, 2]
\citep[see][chap.~4]{Doe:1966}(see Doe, 1966, chap. 4)[see 1, chap. 4]\citep[see][chap.~4]{Doe:1966,smith2017}(see Doe, 1966; Smith, 2017, chap. 4)[see 1, 2, chap. 4]
\citet*{Doe:1966}Doe (1966)Doe [1]\citet*{Doe:1966,smith2017}Doe (1966); Smith (2017)Doe [1], Smith [2]
\citep*{Doe:1966}(Doe, 1966)[1]\citep*{Doe:1966,smith2017}(Doe, 1966; Smith, 2017)[1, 2]

Other natbib commands, such as \citealp and \citealt, offer additional flexibility by suppressing brackets. Discover the entire range of commands in the Reference sheet for natbib usage.

Appendix: Mastering the Options for natbib

When working with natbib, customizing its behavior can make your workflow smoother. Here’s a breakdown of the options available via \usepackage[options]{natbib}:

OptionDescription
rounddisplays round parentheses
squaredisplays square brackets
curlydisplays curly braces
angledisplays angle braces
semicolonmultiple citations are separated by semicolons
colonsame as semicolon
commamultiple citations are separated by coma
authoryeardisplay author-year citations
numbersdisplay numerical citations
superdisplays superscript numbers for numerical citations
sortsorts multiple citations in order of references displayed in bibliography.
compresssorting and multiple numerical citations are compressed where appropriate
sort&compressmultiple numerical citations are compressed where appropriate
longnamesfirstthe full name of the author appears in the first citation
sectionbibredefines \thebibliography to output \section instead of \chapter
nonamebreakDisplays all author names of a citation in one line

Further Reading and Sources

Wrapping Up

Harnessing natbib with BibTeX simplifies reference management in LaTeX. This guide offered a comprehensive walkthrough from basic setups to intricate citation styles. For more insights into LaTeX and its many functionalities, explore our collection of in-depth guides.