2

I'm new in latex world and I'm having troubles using natbib package. I have used this code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel} 
\usepackage{natbib} 
\bibliographystyle{abbrvnat} 
\begin{document} 

blabla \citep{prova1}

\medskip 
\begin{thebibliography}  
\bibliography{prova1}
\end{thebibliography}

\end{document}

I get no errors but the .pdf file has a (?) instead of the author and in the references there's only written the key, which I use to cite, just as if it is text. I guess the problem is in the .bib file that I got automatically with Mendeley software. The "prova1.bib" file is the following:

@ARTICLE {prova1,
    author  = "pincopallino",
    title   = "prova",
    journal = "test",
    year    = "2014"   
} 

I apologize if my explanation is unclear, any help will be really appreciated!

4
  • Welcome to TEX.SE. Please indicate whether you wish to generate authoryear-style or numeric-style citation call-outs (the output of \cite).
    – Mico
    Oct 3 '20 at 16:28
  • 1
    remove the \begin{thebibliography} \end{thebibliography} , they are generated automatically. Oct 3 '20 at 16:57
  • Hello @Mico, thank you for your help. I would like to use an authoryear-style citation in my thesis.
    – user225946
    Oct 14 '20 at 15:05
  • @user225946 - Since you use the abbrvnat bibliography style, it should suffice to change \usepackage{natbib} to \usepackage[authoryear]{natbib} and to run a full recompilation cycle (Latex, BibTeX, and Latex twice more) in order to get authoryear-style citation call-outs.
    – Mico
    Oct 14 '20 at 15:39
1

Some suggestions:

  • Don't use both \begin{bibliopraphy} and \end{bibliography} as well as \bibliography at the same time

  • Use \begin{bibliopraphy} and \end{bibliography} only if you desire to build the entire formatted bibliography by hand.

  • If you use \bibliography, you must also use BibTeX (an external program) to create the formatted bibliography.

If you want to use BibTeX, you should rewrite the code posted above as follows:

\documentclass{article}
% create the file 'prova.bib' on the fly:
\begin{filecontents}[overwrite]{prova.bib}
@ARTICLE {prova1,
    author  = "pincopallino",
    title   = "prova",
    journal = "test",
    year    = "2014"   
} 
\end{filecontents}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel} 
\usepackage{natbib} 
\bibliographystyle{abbrvnat} 

\begin{document} 
blabla \citep{prova1}
\bibliography{prova}  
\end{document}

and then run LaTeX, BibTeX, and LaTeX twice more to (a) create the formatted bibliography and (b) all the citation call-outs.

2
  • Excuse me @Mico, I don't understand what does it mean to "run BibTex". I created the .bib file from a software called Mendeley Desktop.
    – user225946
    Oct 14 '20 at 15:16
  • @user225946 - Please tell me which front-end software you employ to edit and compile your tex files.
    – Mico
    Oct 14 '20 at 15:36

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.