[Tex/LaTex] How to make a reference slide in beamer? mine only showed a ‘?’

beamerbibliographies

My code:

\documentclass{beamer}
\usetheme{default}
\usecolortheme{default}
\usefonttheme{serif}
\begin{document}

\begin{frame}{Reference}
\cite{bilson1978rational}.
\bibliographystyle{apalike}
\bibliography{abc.bib} 
\end{frame}

\end{document}

My abc.bib file:

@article{bilson1978rational,
title={Rational expectations and the exchange rate},
author={Bilson, John FO},
journal={The economics of exchange rates: Selected studies},
pages={75--96},
year={1978}
}

But here is my result…..
enter image description here

Best Answer

Assuming, the document is called foo.tex

Running pdflatex foo ; bibtex foo ; pdflatex foo; pdflatex foo this will provide the correct citation. The important step is bibtex and recompile twice after bibtexing.

\documentclass{beamer}

\begin{filecontents}{abc.bib}
@article{bilson1978rational,
title={Rational expectations and the exchange rate},
author={Bilson, John FO},
journal={The economics of exchange rates: Selected studies},
pages={75--96},
year={1978}
}
\end{filecontents}
\usetheme{default}
\usecolortheme{default}
\usefonttheme{serif}
\begin{document}

\begin{frame}{Reference}
\cite{bilson1978rational}.
\bibliographystyle{apalike}
\bibliography{abc.bib} 
\end{frame}

\end{document}

enter image description here