38 Comments

  1. 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.

  2. 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}
  3. 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.

  4. 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.

  5. 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

  6. 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)

  7. 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})%
    }
  8. 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)

  9. 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!

  10. 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

  11. 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.

  12. 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

    • 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.

  13. Muatez

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

    • Hi Muatez,

      It’s sufficient to use the natbib package with

      \cited{citation1, citation2, citation3}

      Best, Tom.

    • Hi sham,

      Please see my update of the post above where natbib was replaced with cite. That should work.

      Best, Tom.

  14. 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!

  15. Thangapandiyan

    Hello

    I am not using sort and conmpress. how i can define my natbib file. So, please provide natbib with sort and compress file.

    Thank you

    Thangapandiyan D.

  16. Fernando

    Hello there. Sorry if this post should go in a different section.

    I have this problem: I renewed my pc and I installed MikTeX and TexMaker (the same programs I used before). However, when I try to run LaTeX an error message for the bibliography appears: “empty journal” or “empty booktitle” or “empty year” or “empty title”, something that did not happen before when I wrote an article (or any other reference) in the bilbiography without those details. I did not change anything from the previous version of my document.

    I am using natbib package. Can you help me please? I have been trying to figure out what is happenning but I haven´t been able to understand the problem. I updated the LaTeX version using MikTex maintenance but nothing works so far.

    Thank you very much for this blog.

    Regads!

    • tom

      Hi Fernando,

      These error messages mean that some required field is missing in the bib entry. The error probably also tells you the identifier of the bib entry where the problem was encountered. You can find a list of required fields for the different entry types (article, book, conference, etc.) here.

      HTH, Tom

Leave a Reply to LouicCancel reply