[Tex/LaTex] Bibtex for mac not working

bibliographiesbibtex

I use a Mac. I have a a .tex file called references test.tex. I have (what I think is) a plaintext file called sample1.bib. The files are super minimal. The references test.tex file looks like this:

\documentclass[12pt]{article}
\usepackage{natbib}
\renewcommand{\refname}{References}

\begin{document}
\cite{blackholes}

\bibliographystyle{plain} 
\bibliography{sample1}
\end{document}

And the sample1.bib file looks like this:

@article{blackholes,
      author="Rabbert Klein",
      title="Black Holes and Their Relation to Hiding Eggs",
      journal="Theoretical Easter Physics",
      publisher="Eggs Ltd.",
      year="2010",
      note="(to appear)"
}

Apologies for the way the output looks – I'm not so good at LaTeX, but it looks like the input if you were to try to edit this original post

They're even saved in the same place (macintosh HD/User/Documents). So why does my reference appear as "[?]"? Do I need to compile somehow or something? Really quite confused.

Best Answer

I had no problem to typeset your file, my graphical interface to (La)TeX being TeXShop.

enter image description here

In your case you seems to have forgotten to use BibTeX. As an example, when TeXShop is opened, you have the typesetting menu available ("composition" in my case, since I'm French-speaking).

enter image description here

First open your TeX file with TeXShop. Then, in the above menu, select LaTeX first, and then BibTeX, and then LaTeX twice again. The results should be the same as it was with mine

There is a shorter way: to select, in the Macro menu, the "Bibliography" script:

enter image description here

Once selected, the four compilations above should execute themselves automatically.

There are even other ways, such as using the more general latexmk utility, which TeXShop can interface. Don't hesitate to read the "Help" menu of TeXShop or another editors and the documentation it contains, most notably the one for beginners.