[Tex/LaTex] Overleaf: Bibliography not appearing

bibliographies

I have copied and pasted the example here:
https://www.overleaf.com/learn/latex/Bibliography_management_in_LaTeX#The_bibliography_file

I have created a file "example.tex"

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{biblatex}
\addbibresource{sample.bib}

\begin{document}
Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's 
book \cite{dirac} are physics related items. 

\printbibliography

\end{document}

and a file "sample.bib"

@article{einstein,
    author = "Albert Einstein",
    title = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
    [{On} the electrodynamics of moving bodies]",
    journal = "Annalen der Physik",
    volume = "322",
    number = "10",
    pages = "891--921",
    year = "1905",
    DOI = "http://dx.doi.org/10.1002/andp.19053221004",
    keywords = "physics"
}

@book{dirac,
    title = {The Principles of Quantum Mechanics},
    author = {Paul Adrien Maurice Dirac},
    isbn = {9780198520115},
    series = {International series of monographs on physics},
    year = {1981},
    publisher = {Clarendon Press},
    keywords = {physics}
}

@online{knuthwebsite,
    author = "Donald Knuth",
    title = "Knuth: Computers and Typesetting",
    url  = "http://www-cs-faculty.stanford.edu/~uno/abcde.html",
    addendum = "(accessed: 01.09.2016)",
    keywords = "latex,knuth"
}

@inbook{knuth-fa,
    author = "Donald E. Knuth",
    title = "Fundamental Algorithms",
    publisher = "Addison-Wesley",
    year = "1973",
    chapter = "1.2",
    keywords  = "knuth,programming"
}

when I run it I am getting this output:

"You have cited something which is not included in your bibliography. Make sure that the citation (\cite{…}) has a corresponding key in your bibliography, and that both are spelled the same way."

and no bibliography is showing.

Best Answer

Try this code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

%\usepackage{biblatex}
%\addbibresource{sample.bib}

% *** CITATION PACKAGES ***
\usepackage{natbib}

\begin{document}
Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's 
book \cite{dirac} are physics related items. 


\ifCLASSOPTIONcaptionsoff
  \newpage
\fi

\bibliographystyle{unsrt}
\bibliography{sample.bib}

\end{document}

The output: "The references will be in a separate page" enter image description here

enter image description here

Related Question