在文档中手动复​​制 bib 文件

在文档中手动复​​制 bib 文件

我正在写一篇 IEEE 论文。我有一个单独的.tex文件和.bib文件。说明中提到

“向外部各方提交文档源 (.tex) 文件时,强烈建议将 BIBTEX .bbl 文件手动复制到文档中(在传统的 LATEX 书目环境中),以免依赖外部文件来生成书目,并防止其中发生更改的可能性”

我如何手动复制到同一个文件以便生成引用?

答案1

让我们从一个简单的 MWE 开始(包filecontents仅用于将 TeX 代码和 bib 文件合并到一个编译 MWE 中)mwe.tex

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Book{Goossens,
  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},
}
@article{feynman,
  title     = {Very High-Energy Collisions of Hadrons},
  author    = {Richard P. Feynman},
  journal   = {Phys. Rev. Lett.},
  volume    = {23},
  issue     = {24},
  pages     = {1415--1417},
  year      = {1969},
  month     = {Dec},
  doi       = {10.1103/PhysRevLett.23.1415},
  url       = {http://link.aps.org/doi/10.1103/PhysRevLett.23.1415},
  publisher = {American Physical Society},
}
\end{filecontents*}


\documentclass[10pt,a4paper]{article}

\usepackage{showframe}  % to visualise the typing area and margins
\usepackage{hyperref}

\begin{document}

This is text with \cite{Goossens} and \cite{adams}.

\nocite{*} % to test all bib entrys
\bibliographystyle{unsrt}

\bibliography{\jobname}

\end{document}

它编译为以下页面:

结果页面

现在使用资源管理器打开目录或直接使用终端并搜索文件mwe.bbl。您可以使用任何编辑器轻松打开它,例如notepad

\begin{thebibliography}{1}

\bibitem{Goossens}
Michel Goossens, Frank Mittelbach, and Alexander Samarin.
\newblock {\em The LaTeX Companion}.
\newblock Addison-Wesley, 1 edition, 1994.

\bibitem{adams}
Douglas Adams.
\newblock {\em The Restaurant at the End of the Universe}.
\newblock The Hitchhiker's Guide to the Galaxy. Pan Macmillan, 1980.

\bibitem{feynman}
Richard~P. Feynman.
\newblock Very high-energy collisions of hadrons.
\newblock {\em Phys. Rev. Lett.}, 23:1415--1417, Dec 1969.

\end{thebibliography}

它包含您的 tex 文件构建参考书目所需的信息。

现在复制mwe.texmwe-a.tex更改如下:

\documentclass[10pt,a4paper]{article}

\usepackage{showframe}  % to visualise the typing area and margins
\usepackage{hyperref}

\begin{document}

This is text with \cite{Goossens} and \cite{adams}.

\nocite{*} % to test all bib entrys
%\bibliographystyle{unsrt} % <==========================================

\begin{thebibliography}{1} % <==========================================

\bibitem{Goossens}
Michel Goossens, Frank Mittelbach, and Alexander Samarin.
\newblock {\em The LaTeX Companion}.
\newblock Addison-Wesley, 1 edition, 1994.

\bibitem{adams}
Douglas Adams.
\newblock {\em The Restaurant at the End of the Universe}.
\newblock The Hitchhiker's Guide to the Galaxy. Pan Macmillan, 1980.

\bibitem{feynman}
Richard~P. Feynman.
\newblock Very high-energy collisions of hadrons.
\newblock {\em Phys. Rev. Lett.}, 23:1415--1417, Dec 1969.

\end{thebibliography} % <===============================================

\end{document}

如您所见,我删除了 mwe 中的 bib 文件并更改了标有 的代码<======。 bib 文件不再需要,因为插入的.bbl部分包含所需的所有信息。 我还注释了参考书目样式(在 环境下不需要thebibliography)。

现在将此代码编译为结果:

结果页面

与第一个结果进行比较:没有区别!

相关内容