×
Pro použití ShareLaTeXu v Angličtina klikněte zde

[edit] ShareLaTeX guides

[edit] LaTeX Basics

[edit] Mathematics

[edit] Figures and tables

[edit] References and Citations

[edit] Languages

[edit] Document structure

[edit] Formatting

[edit] Fonts

[edit] Presentations

[edit] Commands

[edit] Field specific

[edit] Class files

Natbib uses the citation style associated with the corresponding bibliography style if no specific citation commands are declared. There are some additional commands to control some punctuation parameters. See the example below:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
 
%Import the natbib package and sets a bibliography  and citation styles
\usepackage{natbib}
\bibliographystyle{abbrvnat}
\setcitestyle{authoryear,open={((},close={))}}
 
 
\begin{document}
 
\section{First Section}
This document is an example, Two items are cited: \textit{The \LaTeX\ Companion} book \cite[see][chap 2]{latexcompanion} and Einstein's journal paper \cite{einstein}. 
 
 
%Imports the bibliography file "sample.bib"
\bibliography{sample}
 
\end{document}

CitationStylesEx1.png

The specific command to format the citation style is:

\setcitestyle{authoryear, open={((},close={))}


The parameters, comma-separated, tell LaTeX to use the authoryear citation mode and use double parentheses as opening and closing marks. Below a list of possible parameters that can be passed to this command:

  • Citation mode: authoryear, numbers or super.
  • Brackets: round or square. You can manually set any other opening and closing characters with open={char} adn close={char}.
  • Citation separator: semicolon, comma.
  • Separator between author and year: aysep{char}.
  • Separator between years with common author: <code>yysep={char}.
  • Text before post-note: notesep={text}.

The are other additional citation commands depending on the citation mode. For instance, in the example above the command \cite[see][chap 2]{latexcompanion} takes two extra parameters; the first optional parameter see is printed before the citation mark and the second optional parameter chap 2 is printed after the citation mark. Below a table describing some additional citation commands:

command description
\citet{} Textual citation
\citep{} Parenthetical citation
\citet*{} Same as \citet but if there are several authors, all names are printed
\citep*{} The same as \citep but if there are several authors, all names are printed
\citeauthor{} Prints only the name of the authors(s)
\citeyear{} Prints only the year of the publication.

For more information about the rest of the commands in this example see Bibliography management with natbib

  Open an example of the natbib package in ShareLaTeX

[edit] Further reading