[Tex/LaTex] Can’t manage to cite in IEEE style with document class {book}

bibliographiesbibtexnatbib

None of the solutions that I've found on internet have worked with me. I am trying to cite this paper: http://ijarece.org/wp-content/uploads/2013/08/IJARECE-VOL-1-ISSUE-4-52-56.pdf and many other documents as articles and books. I need to use IEEE style.

This is my document style:

\documentclass[a4paper]{book}
\usepackage[numbers]{natbib}

\begin{document}
....
\bibliographystyle{ieeetr} %I also tried IEEEtran, and IEEEtranN
\bibliography{literature/library}
\end document

This is what I have in my library.bib document:

@article{r1,
author = "A. N. Shinde, A. C. Joshi, S.S. Patil, Dr. A.P. Vaidya",
journal = "International Journal of Advanced Research in Electronics and Communication Engineering (IJARECE)",
month = oct,
number = "4",
pages = "1-5",
title = "DC Drive using PWM Techniques For Treadmill",
volume = "1",
year = "2012"
}

I'm using \cite{r1} to refer it.
But when compiling, I get this error:

! Package natbib Error: Bibliography not compatible with author-year citations

SOLVED:
I went back to use:

\usepackage[numbers]{natbib}
\bibliographystyle{IEEEtranN}

Now it's working. My problem was I was editing a template which contained some packages that somehow affected my whole code. I just started a new template myself with the stuff I need. I'm starting to learn Latex, and I confess it was a mistake editing an already-made template.

Best Answer

The error message provides the key clue. The ieeetr bibliography style is not compatible with natbibt.

The format of a \bibitmem required by natbib has the following template

\bibitem[Author-List (year)]{key} ...

While ieeetr provides bib items with the following form:

\bibitem{key} ...

Thus, one option is not to load the natbib package (remove \usepackage[numbers]{natbib}. The manual for IEEEtran suggests to use the cite style to manage citation (optionally).

If natbib commands are already used in the body of the document, an option could be to use biblatex and the bib latex-ieee style, i.e., add the following lines to the preamble

\usepackage[style=ieee,natbib]{biblatex}
\addbibresource{literature/library.bib}

and then \printbibliography where the bibliography should appear it the document. This solution requires to use biber instead of bibtex to generate the bibliography.

Related Question