[Tex/LaTex] Package natbib Warning: Undefined Citation Warning

citingerrorsnatbibpaper

After hours of trying to figure it out, I finally decided to ask for help. I checked various related answers but I am new to Natbib and couldn't figure out the problem if you might please be able to help. Here is the tex code-

\documentclass{article}

\usepackage[preprint]{nips_2018}

\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{hyperref}       % hyperlinks
\usepackage{url}            % simple URL typesetting
\usepackage{booktabs}       % professional-quality tables
\usepackage{amsfonts}       % blackboard math symbols
\usepackage{nicefrac}       % compact symbols for 1/2, etc.
\usepackage{microtype}      % microtypography


\title{Whatever the title maybe}

\author{
  Writer Name\thanks{32nd Conference on Neural Information Processing Systems (NIPS 2018), Montréal, Canada. ---\emph{whatever it may be}.} \\
  Institution and University\\
  London,
  United Kingdom\\
  \texttt{bla-bla-bla} \\
}

\begin{document}


\maketitle

\begin{abstract}
  The abstract paragraph should be indented \nicefrac{1}{2}~inch
  (3~picas) on both the left- and right-hand margins. Use 10~point
  type, with a vertical spacing (leading) of 11~points.  The word
  \textbf{Abstract} must be centered, bold, and in point size 12. Two
  line spaces precede the abstract. The abstract must be limited to
  one paragraph.

\end{abstract}

\section{Heading 1}
   So, for example \citet{hasselmo} investigated that\dots

\section{Heading 2}

\section{Heading 3}

\section{Heading 4}

\subsubsection*{Acknowledgments}

Use unnumbered third level headings for the acknowledgments. All
acknowledgments go at the end of the paper. Do not include
acknowledgments in the anonymized submission, only in the final paper.of the margin problems come from figures positioned by hand using or other commands.   We suggest using the command from the
graphicx package.

Always specify the figure width as a multiple of the line width as in the example below

\section*{References}

References follow the acknowledgments. Use unnumbered first-level
heading for the references. Any choice of citation style is acceptable as long as you are consistent. It is permissible to reduce the font size to \verb+small+ (9 point) when listing the references. {\bf
  Remember that you can use more than eight pages as long as the
  additional pages contain \emph{only} cited references.}
\medskip

\small

[1] Alexander, J.A.\ \& Mozer, M.C.\ (1995) Template-based algorithms
for connectionist rule extraction. In G.\ Tesauro, D.S.\ Touretzky and
T.K.\ Leen (eds.), {\it Advances in Neural Information Processing
  Systems 7}, pp.\ 609--616. Cambridge, MA: MIT Press.

[2] Bower, J.M.\ \& Beeman, D.\ (1995) {\it The Book of GENESIS:
  Exploring Realistic Neural Models with the GEneral NEural SImulation
  System.}  New York: TELOS/Springer--Verlag.

[3] Hasselmo, M.E., Schnell, E.\ \& Barkai, E.\ (1995) Dynamics of
learning and recall at excitatory recurrent synapses and cholinergic
modulation in rat hippocampal region CA3. {\it Journal of
  Neuroscience} {\bf 15}(7):5249-5262.


\end{document}

I am using this NIPS 2018 Style-file listed here and I'm slightly confused if I need to mention the authors in some author = {}, year = {}, etc.. etc.. format or should natbib be already capable of making that sense for me?

I am sure it must be some mistake on my end since while compiling natbib says "undefined citation" and puts "?" in the output pdf.

If it helps, I am using TexMaker.

Best Answer

You should read how to use bibtex or biblatex with your LaTeX system, which will give you a lot of flexibility in sorting, maintaining and using a bibliographic database that you can grow over time. But if you want to manually input the bibliography in your paper, this is the way to to do it, using thebibliography environment (but then, I do not think that natbib will do anything useful... it will become really unmanageable faster than you think). But if you want it, this is the structure

\documentclass{article}

%\usepackage[preprint]{nips_2018}  % so I can compile without the nips format
\usepackage{natbib} % this is probably into you nips_2018 format file

\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{hyperref}       % hyperlinks
\usepackage{url}            % simple URL typesetting

\title{Whatever the title maybe}

\author{
  Writer Name\thanks{32nd Conference on Neural Information Processing Systems (NIPS 2018), Montréal, Canada. ---\emph{whatever it may be}.} \\
  Institution and University\\
  London,
  United Kingdom\\
  \texttt{bla-bla-bla} \\
}

\begin{document}
\maketitle

\section{Heading 1}
   So, for example \citet{hasselmo95} investigated that\dots

\begin{thebibliography}{99} 
  \bibitem[Alexander et al.(1995)]{Alexander95} Alexander, J.A.\ \& Mozer,  M.C.\ (1995) Template-based algorithms
   for connectionist rule extraction. In G.\ Tesauro, D.S.\ Touretzky and
   T.K.\ Leen (eds.), {\itshape Advances in Neural Information Processing
   Systems 7}, pp.\ 609--616. Cambridge, MA: MIT Press.
  \bibitem[Hasselmo et al.(1995)]{hasselmo95} Hasselmo, M.E., Schnell, E.\ \& Barkai, E.\ (1995) Dynamics of
    learning and recall at excitatory recurrent synapses and cholinergic
    modulation in rat hippocampal region CA3. {\itshape Journal of
    Neuroscience} {\bfseries 15}(7):5249-5262.
\end{thebibliography}
\end{document}

...and notice that natbib is really finicky on the format of the bibitem...

enter image description here

Related Question