5

I'm trying to cite in parenthesis format with the name of the author and the year but when I compile it, it keeps asking for the name of the author. here is my code:

\documentclass[10pt, a4paper]{elsarticle}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{natbib}
\usepackage{graphicx}

\begin{document}

\citet{H}

\section*{References}
\bibliographystyle{elsarticle-num}
\bibliography{Biblio}

\end{document}

and here is my .bib file:

@article{AAA,
author = {AAAuthor},
title = {TTTitle},
year = {2017}
}
  • In your example, it should be \citet{AAA}, and you should run: latex myfile.tex, bibtex myfile.aux, latex myfile.tex, latex myfile.tex to get the reference list properly resolved. – jon Apr 04 '15 at 00:44
  • 1
    From the natbib documentation section 2.3, "The authors can only be listed if the .bst file supports author–year citations. The standard .bst files, such as plain.bst are numerical only and transfer no author–year information to LaTeX." But this is largely a duplicate of Natbib In-Text Citation displays (author?), and changing your bibliography style to an Author-Year format like plainnat resolves the problem. – Mike Renfro Apr 04 '15 at 00:51

1 Answers1

3

You have to use elsarticle-num-names:

\begin{filecontents*}{\jobname.bib}
@article{AAA,
  author = {A. Uthor},
  title = {TTTitle},
  year = {2017},
}
\end{filecontents*}

\documentclass[10pt, a4paper]{elsarticle}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{natbib}
\usepackage{graphicx}

\begin{document}

\citet{AAA}

\section*{References}
\bibliographystyle{elsarticle-num-names}
\bibliography{\jobname}

\end{document}

I used filecontents* just to have a self-contained example, you can use the external file as usual.

enter image description here

egreg
  • 1,121,712
  • It's working perfectly. Thanks. In case I want year included in my citation I have to cite year individually. Correct me if I'm wrong. – Ali Nabbi Apr 05 '15 at 13:20
  • You can use an option in elsarticle to get author-year style. – egreg Apr 05 '15 at 14:33