Store the following complete MWE as file mb-bibtex.tex
. Then compile: pdflatex mb-bibtex.tex
. It creates a file mb-bibtex.bib
(package filecontents
). Compile two more times and you will get a result as expected ...
%http://tex.stackexchange.com/questions/95455/problem-compiling-document#95455
%File mb-bibtex.tex, then \jobname = mb-bibtex
\RequirePackage{filecontents} % loading package filecontents
% writing file \jobname.bib, for example mb-bibtex.bib.
\begin{filecontents*}{\jobname.bib}
@Book{companion,
author = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
title = {The LaTeX Companion},
edition = {1},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
year = {1994},
}
@Book{adams,
title = {The Restaurant at the End of the Universe},
author = {Douglas Adams},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980},
}
\end{filecontents*}
\documentclass{article}
\begin{document}
Test of bibliography:
The \LaTeX{} companion~\cite{companion}, the funny book of Adams~\cite{adams}.
\bibliographystyle{plain}
\bibliography{\jobname} % uses \jobname.bib, according to \jobname.tex
\end{document}
Your error was to name a .tex
file (containing TeX code) as .bib
file.
.bib
file rather than the.tex
file. – Joseph Wright♦ Jan 26 '13 at 16:08bibtex myfile
notbibtex myfile.bib
– David Carlisle Jan 26 '13 at 16:08.tex
file to be compiled. Thebib
file contains the entrys for your bibliography ... So renamemyfile.bib
tomyfile.tex
... – Mensch Jan 26 '13 at 16:10mytex.bib
and it is looking for the aux file. So it and/or latex are confused, delete all the files except myfile.tex and testbib.bib and runpdflatex myfile;bibtex myfile; pdflatex myfile
and things should get back in sync – David Carlisle Jan 26 '13 at 16:24