260

I have a basic tex file and a bibliography which is exported from Mendeley

However, when I want to cite in the author-year style, I get the error:

Package natbib Error: Bibliography not compatible with author-year citations. (natbib) Press <return> to continue in numerical citation style.

Any clue what's wrong?

Minimum working example:

\documentclass[letterpaper, 10pt]{article}

\usepackage[authoryear]{natbib}
\usepackage{lipsum}

\begin{document}

\lipsum[1-4]
\nocite{*}

\bibliographystyle{apalike}
\bibliography{articles}

\end{document} 

A snippet of my .bib library:

@article{shortcode,
author = {Lastname, Firstname},
file = {:/path/to/file.pdf:pdf},
journal = {Journal name},
number = {xx},
pages = {x--xx},
title = {Title},
volume = {xx},
year = {xxxx}    
}
3
  • 2
    I also get the error, but my PDF still gets rendered fine. All my library entries have a year and I deleted temporary files several times. So, I ignore it for now. I found out that this command always gets into the aux file: \providecommand\NAT@force@numbers{}\NAT@force@numbers
    – OneWorld
    Aug 22, 2012 at 10:15
  • 8
    I had the same problem and didn't have any BiBTeX entries without years. I was able to solve this error by changing two \cite commands to \citet or \citep.
    – user31480
    May 30, 2013 at 3:45
  • remove below line in the preamble works for me %\bibpunct{(}{)}{;}{a}{,}{,}
    – user39708
    Nov 8, 2013 at 15:18

13 Answers 13

134

Another way this error can arise is if one of your BibTeX entries has no year.

To find out which entry it is, look earlier in the output for a message like Warning--empty year in ABC2019. So check ABC2019.

5
  • 8
    That was indeed the case Josh. Tnx
    – grrrbytes
    May 31, 2012 at 8:03
  • 8
    This can also happen if a , is missed in the .bib file at the end of a line!
    – Srivatsan
    Oct 16, 2016 at 13:25
  • 4
    How come this is the accepted answer? Should it be a comment, I don't see how it solves the problem. For me it just seems like pointing a way to reproduce the problem. Feb 25, 2019 at 14:21
  • 1
    @Eduardo: It’s not just a “how to reproduce”; it explains a common cause of the problem (probably the most common cause of this error), and one with a pretty obvious fix (add a year!) Jun 6, 2019 at 11:21
  • But which entry? natbib outputs an error earlier in processing: Warning--empty year in ABC2019. So check ABC2019 (edited post to include this detail)
    – Ken Arnold
    Jul 2, 2019 at 13:18
185

When changing the bibliography style, sometimes natbib is upset because it can't interpret the data correctly.

In any case, after changing the argument to \bibliographystyle a run of LaTeX and one of BibTeX are necessary to get back in sync. Removing the .bbl and .aux files before those run is recommended, in order to avoid spurious error messages that might corrupt the .aux file currently being generated.

7
  • 54
    A vote here to remove all the temporary files- it does not seem like just the bbl+aux was enough (though I was tearing my hair out so I may not have been of entirely sound mind). Anyway- temporary files- they'll get ya. Jun 2, 2012 at 0:04
  • 3
    This fixed my problem! Dec 8, 2012 at 19:14
  • 3
    Maybe one day they'll fix this issue... Aug 23, 2014 at 20:24
  • 1
    Congrats on earning the "bibtex" golden badge! :-)
    – Mico
    Apr 5, 2016 at 14:24
  • @Mico Almost a year after yours! ;-)
    – egreg
    Apr 5, 2016 at 14:26
154

I had the same error trying to use spmpsci.bst in conjunction with natbib. While natbib's default citation style is author-year, spmpsci.bst is numeric, so this is a strange error to get. I eventually changed the following:

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

to

\usepackage[square,sort,comma,numbers]{natbib}

Problem went away.

7
  • 4
    The spbasic.bst doesn't have this problem for me, but the spmpsci.bst does. But if I use the svjour3.cls document class, I can't use natbib as you suggest, because of a clash of options. Also, doesn't setting numbers mean that you're no-longer using author-date?
    – naught101
    Jun 11, 2013 at 7:18
  • 8
    Thanks! \usepackage[square,sort,comma,numbers]{natbib} that helped for me.
    – user39408
    Nov 3, 2013 at 9:28
  • 2
    This also worked for eptcs.bst (style.eptcs.org)
    – Florian
    Jan 14, 2016 at 8:22
  • This is a usefult solution to a different question. OP wants to output citations in author-year, not in numbers. Sep 29, 2017 at 8:54
  • This solved the same error popping up with naturemag-doi.bst. However, my inline citations (\citet) stopped working.
    – Brian D
    May 14, 2018 at 21:19
28

The error occurs because natbib cannot find year information in the .bbl file (or possibly, but less likely, it cannot find author information). You can open it up yourself to see why this is the case.

The simplest reason would be that you have a \bibitem with the year field missing. A trickier reason is that your bibliography style does not output year information in a way that is parsable by natbib. For example, I was using \bibliographystyle{abbrv}, which does not play nicely with natbib. I fixed the problem by using instead \bibliographystyle{authordate1}. Of course, delete all temporary files, especially .bbl and .aux files, after making this change.

A final workaround is to use \usepackage[numbers]{natbib} when including the package. This outputs numbered citations instead of (author, year) citations and does not need year information.

1
  • I'm getting the same error from a bibliography in which author and year are defined for all entries, so there must be some other reasons that can trigger it.
    – MRule
    Sep 15, 2021 at 9:20
11

Follow these steps:

  1. Delete the .aux and the .bbl files
  2. Do your changes (in the \bibliographystyle or in any option of natbib)
  3. Run LaTeX
  4. Run BibTeX
1
  • 8
    What changes do you mean when you say "do your changes"? Thanks!
    – user29020
    Dec 4, 2014 at 23:04
6

Another way this error can arise is if one of your BibTeX entries has no year. (From Josh Porter's answer)

This is true, but due to the mismatch between natbib package and your bibliographystyle settings, instead of a bug of natbib, which uses its own bibliography styles (even though natbib supports the original bibtex styles but not completely).

natbib intends to offer better author-year citations. If using natbib, you should choose plainnat, abbrvnat or unsrtnat. For example,

\documentclass[letterpaper, 10pt]{article}

\usepackage[round,sort]{natbib}
\usepackage{lipsum}

\begin{document}

\lipsum[1-4]

\bibliographystyle{abbrvnat}
\bibliography{articles}

\end{document} 

Here [round,sort] is not necessary, which makes it look close to APA style. If you want use IEEE-like style, you could use \usepackage[numbers]{natbib}.

However, if you use apalike, ieeetr, siam, etc., it implies you use the default bibtex styles, you should comment natbib package; otherwise, you would meet the problems if your bib files contain entries without author/year information.

Either way should solve your problem. This also brothers me for a long time, due to many incorrect examples in blogs.

References:

https://en.wikibooks.org/wiki/LaTeX/More_Bibliographies

http://sites.stat.psu.edu/~surajit/present/bib.htm#bibstyle

1
  • useful answer, and it somehow made through to the first result in google preview
    – dEmigOd
    Jun 18, 2019 at 12:54
5

In my case the problem was setting the cite style!!so, simply \setcitestyle{...}

4
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. I doubt that this answers the original question. Could you please show a full solution to the problem in the question? Please remember that this is not a forum, and the Answer field is intended only for true answers to the problem.
    – yo'
    Jan 2, 2015 at 19:03
  • 2
    Could you please explain what you mean?
    – Stefan Kottwitz
    Jan 2, 2015 at 21:38
  • 2
    Actually, this suggestion is what I was looking for! Some journal document classes load natbib without the citation style option, and that may give rise to OP's error message even when numeric citations are being used. In those cases \setcitestyle{number} resolves the issue.
    – alexurba
    Feb 24, 2015 at 12:27
  • Setting \setcitestyle{number} also works for having springer styles spmpsci and spbasic output in author-year format. That's not a typo, BTW. It's the only way I found to use those styles in natbib and have author-year citations. Sep 29, 2017 at 9:01
5

To add to the compendium of ways this error can occur, if you are using elsarticle.cls, do not use it with options

    \documentclass[authoryear]{elsarticle}

and the style

    \bibliographystyle{elsarticle-num}
2

Another not so intuitive reason for me was that I simply forgot a comma after one of the shortcodes. There was no other error and the references displayed fine, however only numerical.

2

This error occurs because of the conflict in how you define the citation style and the bibliography style. In your case, note that \usepackage[authoryear]{natbib} is same as \usepackage{natbib} while the 'biblographystyle' is defined as \bibliographystyle{apalike} meaning it is plain, basically 'numbers'.

Therefore, just change

\usepackage{natbib}

to

\usepackage[numbers]{natbib}
1

This can also happen if one of the BibTeX entries is missing the label (shortcode).

One possible scenario is when the bibliography is exported from e.g. EndNote and the label for the entry has not been set in EndNote. (This happened to me.)

2
  • 1
    If the entry in question doesn't have a label, how do you \cite it?
    – Mico
    Dec 4, 2013 at 19:47
  • With the label I thought I had set, but had actually forgot to set.
    – matsr
    Dec 4, 2013 at 20:08
0

Don't use natbib in Beamer! Plus: possible solution

Another possibility: I have got the same errors when trying to use natbib in Beamer class (for presentation). The following two lines handles references properly:

\usepackage[style=authoryear]{biblatex}
\bibliography{bib.bib}
2
  • It should be \addbibresource{bib.bib}. In general, adding the .bib extension in the argument to \bibliography is wrong: it only works with MiKTeX.
    – egreg
    Feb 6, 2017 at 14:27
  • @egreg, thank you for the fix; exactly, I should have mentioned that I am using MIKTex on a Windows 10 machine.
    – llinfeng
    Feb 6, 2017 at 16:14
0

I had similar problem and it was over when I removed the option [authoryear]. Hope it works with you.

Not the answer you're looking for? Browse other questions tagged or ask your own question.