Typevia
References and Citations

Introduction to Natbib

Managing references is one of the most powerful features of LaTeX. While LaTeX has a built-in bibliography system, the natbib package is the gold standard for many researchers and students. It offers significantly more flexibility than the standard bibliography environment, particularly when it comes to switching between author-year and numerical citation styles.

natbib was originally designed for the natural sciences (hence the name), but its versatility has made it popular across all academic disciplines. Whether you need to cite a paper as "Smith (2023) argued..." or "(Smith, 2023)," natbib makes it effortless.


Setting Up Your Bibliography

To use natbib, you don't just type your references directly into your document. Instead, you use a two-part system:

  1. The .bib file: A separate database file containing all your reference data.
  2. The .tex file: Your main document where you cite the work.

1. Creating the .bib File

Create a new file named references.bib. Each entry follows a specific format. Here is an example of a book and a journal article:

@book{lamport94,
  author    = {Leslie Lamport},
  title     = {LaTeX: A Document Preparation System},
  year      = {1994},
  publisher = {Addison-Wesley},
  address   = {Reading, Massachusetts}
}

@article{einstein1905,
  author  = {Albert Einstein},
  title   = {Does the Inertia of a Body Depend Upon Its Energy Content?},
  journal = {Annalen der Physik},
  volume  = {18},
  pages   = {639--641},
  year    = {1905}
}

Note: The first string after the open brace (e.g., lamport94) is the citation key. You will use this unique ID to reference the work in your document.

2. The LaTeX Document Structure

In your main .tex file, you need to load the package and tell LaTeX where your bibliography is located.

\documentclass{article}

% 1. Load the package in the preamble
\usepackage[round]{natbib} 

\begin{document}

Einstein's famous work \citep{einstein1905} changed physics forever.

% 2. Define the style and link the .bib file at the end
\bibliographystyle{plainnat}
\bibliography{references} % Points to references.bib

\end{document}

Essential Citation Commands

The true power of natbib lies in its citation commands. Unlike the standard \cite command, natbib distinguishes between citations that are part of the sentence flow and those that are purely parenthetical.

1. Textual Citations: \citet

Use \citet when the author's name is part of your sentence.

  • Code: \citet{lamport94} says LaTeX is great.
  • Output: Lamport (1994) says LaTeX is great.

2. Parenthetical Citations: \citep

Use \citep when you want the entire citation to appear inside brackets.

  • Code: LaTeX is a powerful tool \citep{lamport94}.
  • Output: LaTeX is a powerful tool (Lamport, 1994).

3. Adding Page Numbers and Notes

You can add optional arguments to these commands for specific page references or "see also" notes.

  • Code: \citep[see][p. 45]{lamport94}
  • Output: (see Lamport, 1994, p. 45)

4. Handling Multiple Authors

If a paper has many authors, natbib usually truncates them to "et al." automatically based on the style. If you want to force the full list of authors, use the starred version:

  • Code: \citep*{smith2020}
  • Output: (Smith, Jones, and Miller, 2020)

Customizing the Appearance

natbib is highly customizable via package options. You load these in the preamble: \usepackage[options]{natbib}.

Common Package Options

OptionDescription
authoryear(Default) Use author-year citations.
numbersUse numerical citations (e.g., [1]).
superUse superscripted numbers (common in medical journals).
roundUse round parentheses () for citations.
squareUse square brackets [] for citations.
sort&compressSorts multiple citations and compresses them (e.g., [1, 2, 3] becomes [1-3]).

Example with Numerical Style

If you prefer a numerical style with square brackets:

\usepackage[numbers,square,sort&compress]{natbib}

Choosing a Bibliography Style

The \bibliographystyle{...} command determines how the references are formatted in the "References" section at the end of your document. There are three primary styles compatible with natbib:

  1. plainnat: A versatile style that supports all natbib features and sorts entries alphabetically.
  2. abbrvnat: Similar to plainnat, but abbreviates first names and journal titles to save space.
  3. unsrtnat: References are listed in the order they are first cited in the text (often used in numerical systems).

The Compilation Process

One of the most common points of confusion for beginners is that you cannot simply "Click Build" once. Because BibTeX handles the bibliography, you must compile in a specific sequence to resolve all references:

  1. pdflatex: Scans the document and finds the \cite keys.
  2. bibtex: Looks up those keys in your .bib file and formats them.
  3. pdflatex: Integrates the bibliography into the document.
  4. pdflatex: Fixes the "labels" so that citations in the text point to the right page/number.

Tip: Most modern LaTeX editors (like Typevia, TeXstudio, or VS Code with LaTeX Workshop) have a "Build" or "Recipe" tool that automates this four-step process for you.


Best Practices and Common Pitfalls

1. Capitalization in Titles

BibTeX often forces titles to lowercase (except for the first letter). To preserve capitalization (e.g., for "Einstein" or "LaTeX"), wrap the letter or word in curly braces in your .bib file:

title = {The {E}instein theory of relativity},

2. Use Non-breaking Spaces

When citing manually (if not using natbib), people often forget to link the citation to the previous word. With natbib, always ensure there is a space before your command.

  • Bad: This is true\citep{key}.
  • Good: This is true \citep{key}.

3. Check for Missing Commas

A common error in the .bib file is forgetting a comma after a field (like the year). This will cause the entire bibliography to fail to compile.

4. Handling "Et al."

If your bibliography shows "Jones, Smith, and others," it means you have multiple authors in your .bib file but haven't used the keyword and.

  • Wrong: author = {Jones, Smith, Brown}
  • Right: author = {Jones, A. and Smith, B. and Brown, C.}

Summary

natbib provides the perfect balance between ease of use and professional control. By separating your data (the .bib file) from your presentation (the .tex file), you can change your entire citation style from "Harvard" to "Vancouver" by simply changing one line of code in your preamble.