The error message
Package natbib Error: Bibliography not compatible with author-year citations.
has two major causes:
- Either it can be taken at face value and then says that the bibliography style you used is incompatible with
natbib
's authoryear
citation option
- or the style you use is in principle compatible with
natbib
's authoryear
citation option, but certain entries are missing author
/editor
or year
fields.
All that is due to the way author-year citations are implemented in natbib
. The usual bibliography that is created by BibTeX is essentially a glorified enumerate
environment and \cite
works just like a \ref
to a \label
(you can read more about this at A design question: citation commands). In order to be able to produce flexible author-year citations natbib
uses a clever way to make the author and year known in the document. But that means that the bibliography created by BibTeX must have a particular format, this is explained in a code comment in natbib.sty
% If author-year citations are selected, \bibitem must have one of the
% following forms:
% \bibitem[Jones et al.(1990)]{key}...
% \bibitem[Jones et al.(1990)Jones, Baker, and Williams]{key}...
% \bibitem[Jones et al., 1990]{key}...
% \bibitem[\protect\citeauthoryear{Jones, Baker, and Williams}{Jones
% et al.}{1990}]{key}...
% \bibitem[\protect\citeauthoryear{Jones et al.}{1990}]{key}...
% \bibitem[\protect\astroncite{Jones et al.}{1990}]{key}...
% \bibitem[\protect\citename{Jones et al., }1990]{key}...
% \harvarditem[Jones et al.]{Jones, Baker, and Williams}{1990}{key}...
You can only get author-year citations if your \bibliographystyle
produces \bibitem
s looking like this. Not all styles are compatible with this format.
If author or year fields are missing, even styles that are in principle compatible with this format can produce a \bibitem
that can not be parsed by natbib
according to the above specification. In that case you will also get this error.
A 'solution' that works for both problems is to forget about author-year citations and tell natbib
to use numeric citations by loading it with the numbers
option. Then natbib
does not try to extract author-year data for normal citations. \citet
may still not work as desired though. So it is somewhat pointless to use natbib
with an incompatible style.
If the style is incompatible the other straightforward solution is to choose a compatible style. The natbib
styles plainnat
, abbrvnat
, unsrtnat
are obviously a good natbib
compatible choice, but there are many more styles out there that work.
If the problem is just caused by your entry missing author
/editor
or year
fields, the obvious solution is to try and supply these fields. If that is not possible you may get a slightly better result if you add placeholder values for those fields. Like author = {N.N.},
and year = {n.d.},
natbib
has a very clever method to avoid this kind of error for some common styles: If you just load natbib
without any additional citation style options \usepackage{natbib}
some styles automatically force the numbers
option without you explicitly setting it and even if you have passed the authoryear
option. But that method is disabled when you use the citation style option square
.
Compare the following MWE with and without the square
option.
\documentclass{article}
\usepackage[square]{natbib}
\begin{filecontents}{\jobname.bib}
@article{ghahramani2015probabilistic,
title = {Probabilistic machine learning and artificial intelligence},
author = {Ghahramani, Zoubin},
journal = {Nature},
volume = {521},
number = {7553},
pages = {452--459},
year = {2015},
}
\end{filecontents}
\begin{document}
\citep{ghahramani2015probabilistic}
\citet{ghahramani2015probabilistic}
\bibliographystyle{alpha}
\bibliography{\jobname}
\end{document}