多个书目

多个书目

我有以下内容:

\documentclass{report}
\begin{document}
\include{chapter1}
\include{chapter2}
\end{document}

我还有一个reference.bib文件,其中包含条目book1、book2和book3。

第一章.tex:

\chapter{Foo}
Some text and a reference to \cite{book1}. But also have a look in \cite{book2}...
\bibliographystyle{plain}
\bibliography{references}

chapter2.tex 完全相同,只是将 book2 改为 book3。因此,book1 在两处均被引用,但 book2 仅在 chapter1 中被引用,而 book3 仅在 chapter2 中被引用。

这会产生“多重定义”警告,因此我正在寻找一种简单的方法来正确执行此操作。任何建议都非常感谢。

编辑:Bibtex 产生了这个:

This is BibTeX, Version 0.99c (TeX Live 2009/Debian)
The top-level auxiliary file: main.aux
A level-1 auxiliary file: chapter1.aux
The style file: plain.bst
A level-1 auxiliary file: chapter2.aux
Illegal, another \bibdata command---line 4 of file chapter2.aux
 : \bibdata
 :         {references}
I'm skipping whatever remains of this command
Database file #1: references.bib
Warning--empty publisher in book1
(There was 1 error message)

pdflatex 的输出是:

This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
entering extended mode
(./main.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, ngerman, german, german-x-2009-06-19, ngerman-x-2009-06-19,    loaded.

(/usr/share/texmf-texlive/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo)) (./main.aux
(./chapter1.aux) (./chapter2.aux

LaTeX Warning: Label `book2' multiply defined.


LaTeX Warning: Label `book1' multiply defined.


LaTeX Warning: Label `book3' multiply defined.

)) (./chapter1.tex
Chapter 1.
(./main.bbl [1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}])) [2]
(./chapter2.tex
Chapter 2.
(./main.bbl [3])) [4] (./main.aux (./chapter1.aux) (./chapter2.aux))

LaTeX Warning: There were multiply-defined labels.

)</usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmbx12.pfb>   </usr/sha
re/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/share   /texmf-tex
live/fonts/type1/public/amsfonts/cm/cmti10.pfb>
Output written on main.pdf (4 pages, 38197 bytes).
Transcript written on main.log.

答案1

看起来您正在使用该chapterbib包来生成多个参考书目。您收到的错误消息表明您没有正确编译文档。

我将通过一个简单的示例解释如何编译您的文档;我假设您的主文档被调用test.tex并且看起来像这样:

\documentclass{report}
\usepackage{chapterbib}
\begin{document}

\include{chapter1}
\include{chapter2}

\end{document}

文件 chapter1.tex:

\chapter{Foo}
Some text and a reference to \cite{goossens93}. But also have a look in \cite{knuth79}...
\bibliographystyle{plain}
\bibliography{references}

文件 chapter2.tex:

\chapter{Bar}
Some text and a reference to \cite{lamport94}. But also have a look in \cite{knuth79}...
\bibliographystyle{plain}
\bibliography{references}

数据库references.bib:

@book{goossens93,
    author = "Michel Goossens and Frank Mittlebach and Alexander Samarin",
    title = "The Latex Companion A",
    year = "1993",
    publisher = "Addison-Wesley",
    address = "Reading, Massachusetts"

}

@book{knuth79,
    author = "Donald E. Knuth",
        title = "Tex and Metafont, New Directions in Typesetting",
    year = {1979{(}1950{)}},
    publisher = "American Mathematical Society and Digital Press",
    address = "Stanford"
}

@book{lamport94,
    author = "Leslie Lamport",
    title = "Latex: A Document Preparation System",
    year = "1994",
    edition = "Second",
    publisher = "Addison-Wesley",
    address = "Reading, Massachusetts"
}

您必须按照以下方式编译您的文档:

pdflatex test
bibtex chapter1
bibtex chapter2
pdflatex test
pdflatex test

在您的实际文档中,作为第一步,您需要删除辅助文件以防止可能继承的错误。

答案2

我创建了一个小型 csh 脚本以便在 shell 中轻松完成此操作。

首先确保已经csh安装了- sudo apt-get install csh

然后按照以下模式保存文件,root_chapX.tex其中root是您的主文件的名称(例如test),并且chapX是您想要的任何内容(重要的是两者之间有一个下划线)。

#!/bin/csh

set base = "root"

echo " Compiling root tex file"
pdflatex $base
echo "================================================================"

echo " Running bibex on included files"
set pattern = ${base}_*.tex
foreach auxfile ($pattern)
  bibtex `basename $auxfile .tex`
end
echo "================================================================"

echo " Compiling root tex file"
pdflatex $base
pdflatex $base
echo "================================================================"

答案3

在你的根 *.tex 文件上运行bibtex没有问题。

然而,在这种情况下,你可能会遇到非法,另一个 \bibdata 命令\bibliography如果对不同的文件多次使用该命令,则会出错。

在这种情况下,而不是:

\bibliography{refs1}
\bibliography{refs2}

做:

\bibliography{refs1,refs2}

这样就解决问题了。

相关内容