About these ads

Natbib: Multiple reference citation

Natbib is a reimplementation of the \cite command, providing both, author-year and numerical citations.You can get the distribution as well as the documentation from CTAN.Apparently, my previous post on this topic was not providing sufficient information in order to automatically create lists for multiple citations, e.g. [1,2,3, 5] -> [1-3, 5].Here is how it definitely works using “natbib”: First you include the package into your document with whatever options you prefer:

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

Here, “sort&compress” provides the effect we are looking for, i.e. comma separation and hyphenation of multiple citations. By default, natbib uses round parentheses and colons, hence I changed them to square brackets and commas.Use

\citet{wikiEn}

for textual and

\citep{wikiEn}

for parenthetical citation, instead of \cite. The following example shows how Natbib replaces more than two consecutive citations by a hypen:

\documentclass{article}
\usepackage[square, comma, sort&compress]{natbib}
\begin{document}
\section{Comma separated citations}
Most popular search engines include Google and Yahoo, \citep{google, yahoo}.
\section{Citation list}
The most popular free online encyclopaedia is available in different languages, \citep{wikiEn, wikiDe, wikiFr}.
\bibliographystyle{plainnat}
\begin{thebibliography}{99}
\bibitem{google}http://www.google.com. Google Inc. search engine, 2008.
\bibitem{yahoo}http://www.yahoo.com. Yahoo! Inc. search engine, 2008.
\bibitem{wikiEn}http://en.wikipedia.org. Wikipedia in English, 2008.
\bibitem{wikiDe}http://de.wikipedia.org. Wikipedia in German, 2008.
\bibitem{wikiFr}http://fr.wikipedia.org. Wikipedia in French, 2008.
\end{thebibliography}
\end{document}

My apologies, I got something wrong here in the first place. Natbib is not a bibliography-style, but a package providing  author-year and numerical citation. Natbib is supported by the following three styles:

plainnat.bst, abbrvnat.bst and unsrtnat.bst

which replace the standard bst-files.

(Source: http://merkel.zoneo.net/Latex/natbib.php)

Update

The code above doesn’t seem to work any longer. Here is the same code where natbib was replaced by cite (package documentation):

\documentclass{article}
\usepackage{cite}
\begin{document}
\section{Comma separated citations}
Most popular search engines include Google and Yahoo, \cite{google, yahoo}.
\section{Citation list}
The most popular free online encyclopaedia is available in different languages, \cite{google, wikiEn, wikiDe, wikiFr}.
\bibliographystyle{plainnat}
\begin{thebibliography}{99}
\bibitem{google}http://www.google.com. Google Inc. search engine, 2008.
\bibitem{yahoo}http://www.yahoo.com. Yahoo! Inc. search engine, 2008.
\bibitem{wikiEn}http://en.wikipedia.org. Wikipedia in English, 2008.
\bibitem{wikiDe}http://de.wikipedia.org. Wikipedia in German, 2008.
\bibitem{wikiFr}http://fr.wikipedia.org. Wikipedia in French, 2008.
\end{thebibliography}
\end{document}
About these ads

29 Responses to “Natbib: Multiple reference citation”

  • satsuma

    Thanks for the good info, this really helps. One thing that your posting does not cover though, and neither does any other site that I’ve found about natbib, is how to set page numbers for multiple citations.

    What I mean is that sometimes it’s needed to have the citation like this: [2, p. 15 ; 4, p 181]

    I am not experienced enough with LaTex to provide a work-around for this. If you have a clue on how to do this, please add it to your blog. Appreciate it. Thanks.

  • tom

    Hi!

    You are right, natbib cannot do it. But you can define your own citation-command as a work-around:

    \newcommand{\mycite}[4]{[\citenum{#1}, #2; \citenum{#3}, #4]}

    And now you can have multiple citations with page numbers as follows:

    \mycite{bla91}{p. 15}{bla99}{p. 181}
  • satsuma

    For some reason in my environment the natbib didn’t seem to have a command \citenum. All I got was an undefined control sequence error. But when I downloaded the natbib.sty and included in the directory where my tex files are, it is working.

    Thanks for sharing that work-around.

  • satsuma

    The problem with \citenum problem is that the version of natbib that came with LaTex is an old version from 2003. The new one I downloaded is from 2007.

  • Louic

    Thanks for your website, it’s very informative.

    I needed to download hypernat.sty and use

    \usepackage{hypernat}

    to get the sort&compress to work.

    Apparently there is a conflict between hyperref and natbib, which is solved by using hypernat.

    Happy TeX’ing

  • k

    I had to spend an hour with Google to find this one trivial command:

    \nocite{key}

    which puts a citation in your \bibliography, without showing up in the actual text (good for abstracts)

  • Pradeep

    Thanks a lot buddy.. How to use “square brackets” in natbib trick worked….

  • Eivind Uggedal

    satsuma: In my own thesis class I have to following to cite two sources with pages:

    % Double page citation
    \newcommand{\citedouble}[4]{%
      (\citealp[#1]{#2}; \citealp[#3]{#4})%
    }
  • sohail

    Using natbib, for a single citation with page number and the text see e.g. I do

    \citep[see e.g.][p.394]{efron1993ib}

    and it generates

    (see e.g. Efron and Tibshirani, 1993, p.394)

    but I am unable to do the same for the multiple citation with page numbers and the text see e.g. like

    (see e.g. Efron and Tibshirani, 1993, p.107; Chernick, 1999, p.84)

  • Naveen

    Thanks Tom!! That helped.

  • Courtney

    Thank you Louic!

    For those using natbib and hyperref, it is required to use

    \usepackage{hypernat}

    to allow natbib to use sort&compress properly. Finding your post saved me many hours!

  • kezz

    Thanks very much for this!

  • Mander

    @sohail:

    I get around that kind of problem with judicious use of \citealp, \citealt, etc. For instance:

    There is some evidence of seasonal distribution of goods (\citealp[9]{freddie04transition}, see also \citealt{vicent97island}), as well as a strong suggestion blah blah blah

    compiles as:

    There is some evidence of seasonal distribution of goods (Freddie 2004:9, see also Vicent 1997), as well as a strong suggestion blah blah blah

  • Rachel

    Thank you for this post. I found that after adding \usepackage[square, comma, sort&compress]{natbib}, I got the error “! Package natbib Error: Bibliography not compatible with author-year citations.” After searching on another forum (http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2009-03/msg00162.html) I found that the solution is to add the option “numbers” to your \usepackage command above; i.e. \usepackage[square, comma, sort&compress, numbers]{natbib}. Just thought I’d add this in case anyone else is experiencing the same difficulty.

  • Virag Shah

    \usepackage{cite} …worked for me

  • Eve

    Thanks for the great post! Also, thank you to Rachel – I had the same problem, and that fixed it!

  • rozita

    hi every one
    I am typing my thesis in latex and i got big problem, I need to seprate my all references with comma , i am using

    \cite{citation40,citation41,citation59,citation97}

    but i am getting instead of comma semicolon; for separating references {40;59;97} and whenever i am using

    \cite{citation2}{,} \cite{citation3} {,} \cite{citation41}

    i am getting comma but i am having extra [] such as : [2],[3],[41]

    My goal is just [2,3,41] how i can get this???
    please help, this is so urgent.
    thanks.
    Rozita

    • tom

      Hi Rozita,

      Thanks for your comment. It suffices to load the natbib package. Here is a minimal example:

      \documentclass{article}
      \usepackage{natbib}
      \begin{filecontents}{bibtextest.bib}
      @book{knuth1979tex,
        title={TEX and METAFONT: New directions in typesetting},
        author={Knuth, D.E.},
        year={1979},
        publisher={American Mathematical Society}}
        @book{knuth1986texbook,
        title={The texbook},
        author={Knuth, D.E. and Bibby, D. and Makai, I.},
        volume={1993},
        year={1986},
        publisher={Addison-Wesley}}
      @book{knuth1988tex,
        title={Tex},
        author={Knuth, D.E. and Bibby, D.},
        year={1988},
        publisher={Addison Wesley Publ. Comp.}}
      \end{filecontents}
      \begin{document}
      See \cite{knuth1979tex, knuth1986texbook, knuth1988tex}.
      \bibliographystyle{plain}
      \bibliography{bibtextest}
      \end{document}

      You may also want to view the natbib reference sheet, a very nice collection of options provided by the package.

      Best, Tom.

  • Muatez

    Hi Tom,
    Could you please help me with that???
    I want to write three references in the same box?
    Thanks in advance

  • Sham

    dear Tom,
    how we can cite multiple references like [1-4] instead of [1,2,3,4]?

  • azim

    Thankyou dear Rachel..I face the same problem as you mention.Now it works…May God Bless you….

  • Norman

    This is a very good tip particularly to those fresh to the blogosphere.
    Brief but very precise info… Thanks for sharing this one.
    A must read article!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 711 other followers

%d bloggers like this: