我已经使用以下代码创建了一个名为“myfile.tex”的文档。
\documentclass{article}
\begin{document}
As we can see in \cite{goossens93}...
\bibliographystyle{plain}
\bibliography{testbib}
\end{document}
这在 PDFLatex 中编译得很好,但是当我尝试运行 bibtex 来创建引用时出现以下错误。
I couldn't open file name `myfile.bib.aux'
有人知道我做错了什么吗?
编辑以回应评论:
我在 myfile 上运行 bibtex。没有 myfile.bib,bib 文件名为 testbib
答案1
将以下完整的 MWE 存储为文件mb-bibtex.tex
。然后编译:pdflatex mb-bibtex.tex
。它创建一个文件mb-bibtex.bib
(包filecontents
)。再编译两次,您将获得预期的结果......
%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}
您的错误是将.tex
文件(包含 TeX 代码)命名为.bib
文件。