1

I cannot seem to get natbib to work with author-year style citations.

The following standalone example:

\documentclass{article} 

\usepackage[authoryear]{natbib}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}

@misc{A01,
   author = {Test, A. and Foo, B.},
   year = {2001},
   title = {Alpha},
}

@misc{A02,
   author = {Alex, A. and Bar, B.},
   year = {2005},
   title = {Alpha},
}

\end{filecontents}

\begin{document}

\citep{A01}, \citep{A02}, \citet{A02} 

\bibliography{\jobname}


\end{document}

Simply returns the error

"! Package natbib Error: Bibliography not compatible with author-year itations."

I have looked about at the various answers surrounding this error but can't work out what's wrong in my case.

Thanks for any help :)

EDIT: Have added screenshot of code with the log-file too below:

enter image description here

  • You have no \bibliographystyle command. – Ulrike Fischer Aug 15 '17 at 12:10
  • @UlrikeFischer If I add "\bibliographystyle{abbrvnat}" the same error occurs. Do I have to make sure a certain package is installed or something? – EHH Aug 15 '17 at 12:19
  • 2
    Works fine for me after the suitable pdflatex and bibtex calls. Delete the aux and bbl and then try again. – Ulrike Fischer Aug 15 '17 at 12:23
  • @UlrikeFischer Ok it compiles ok now thanks! but the citation are just numbers in square brackets, not the author-year format I was hoping for. I tried adding \setcitestyle{authoryear} but then I get the original error message back again. Do you know what I can do to fix this? – EHH Aug 15 '17 at 12:55
  • Works fine for me with \bibliographystyle{abbrvnat}. The citation looks eg like [Alex and Bar, 2005]. Show your log-file and the blg-file. – Ulrike Fischer Aug 15 '17 at 13:02
1

Well, there seem to be two problems:

  1. You missed to add a bibliographystyle like \bibliographystyle{abbrvnat}
  2. It seems your TeX distribution is a little bit outdated ...

With the following MWE

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Test, A. and Foo, B.},
  year = {2001},
  title = {Alpha},
}
@misc{A02,
  author = {Alex, A. and Bar, B.},
  year = {2005},
  title = {Alpha},
}
\end{filecontents}


\listfiles %<========= creates list of used packages and version numbers
\documentclass{article} 

\usepackage[authoryear]{natbib}


\begin{document}

\citep{A01}, citep: \citep{A02}, citet: \citet{A02} 

\bibliographystyle{abbrvnat} % <=======================================
\bibliography{\jobname}

\end{document}

I get without error message the following result:

enter image description here

If you take a look into the .log file (for example 386491.log, if the TeX file is names 386491.tex)

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400 64-bit) (preloaded format=pdflatex 2017.4.26)  15 AUG 2017 19:37
entering extended mode
**./386491.tex
(386491.tex
LaTeX2e <2017-04-15>
Babel <3.9r> and hyphenation patterns for 76 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\filecontents\filecontents.sty"
Package: filecontents 2011/10/08 v1.3 Create an external file from within a LaTeX document
)

LaTeX Warning: Overwriting file `./386491.bib'.

\openout15 = `386491.bib'.


("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) ("C:\Program Files\MiKTeX 2.9\tex\latex\natbib\natbib.sty"
Package: natbib 2010/09/13 8.31b (PWD, AO)
\bibhang=\skip43
\bibsep=\skip44
LaTeX Info: Redefining \cite on input line 694.
\c@NAT@ctr=\count87
)
(386491.aux)
\openout1 = `386491.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 23.
LaTeX Font Info:    ... okay on input line 23.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 23.
LaTeX Font Info:    ... okay on input line 23.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 23.
LaTeX Font Info:    ... okay on input line 23.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 23.
LaTeX Font Info:    ... okay on input line 23.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 23.
LaTeX Font Info:    ... okay on input line 23.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 23.
LaTeX Font Info:    ... okay on input line 23.
 (386491.bbl) [1

{C:/Users/Internet/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] (386491.aux)

 *File List*
filecontents.sty    2011/10/08 v1.3 Create an external file from within a LaTeX document
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
  natbib.sty    2010/09/13 8.31b (PWD, AO)
  386491.bbl
 ***********

 ) 
Here is how much of TeX's memory you used:
 564 strings out of 493324
 6475 string characters out of 3138984
 58170 words of memory out of 3000000
 4171 multiletter control sequences out of 15000+200000
 4245 words of font info for 16 fonts, out of 3000000 for 9000
 1141 hyphenation exceptions out of 8191
 24i,4n,32p,145b,312s stack positions out of 5000i,500n,10000p,200000b,50000s
<C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmbx12.pfb><C:/Program Files/MiKTeX 2.9/fonts/type1/public
/amsfonts/cm/cmr10.pfb>
Output written on 386491.pdf (1 page, 24658 bytes).
PDF statistics:
 14 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

you can see in the first line that I am using a current MiKTeX 2,9, version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400 64-bit) and my system used the following packages (created with command \listfiles):

 *File List*
filecontents.sty    2011/10/08 v1.3 Create an external file from within a LaTeX document
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
  natbib.sty    2010/09/13 8.31b (PWD, AO)

Please compare this numbers with yours. From the screenshot you showed us I guess your sytem is a little bit older. Please update ...

| improve this answer | |
  • You were right it was a lack of bibliography style that was causing the problem. I will also update my Tex version as I didn't realise that it was so dated. Thanks :) – EHH Aug 28 '17 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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