Closed CSQ223 closed 4 years ago
chapterbib使用有个关键是要将多个章节都用include使其产生多个aux文件,然后bibtex编译对应每个章节的每个aux文件。 你先试试,再仔细看一下chapterbib文档。
若无法解决,可发mwe给我或作者。
使用 \usepackage[sectionbib]{chapterbib}
后需要给 natbib
传递选项 sectionbib
,可以通过 \usepackage[sectionbib]{gbt7714}
使用
\usepackage[sectionbib]{chapterbib}
后需要给natbib
传递选项sectionbib
,可以通过\usepackage[sectionbib]{gbt7714}
@zepinglee I tried to do as you proposed but failed. Can you show me in the attached file? Thank you a lot. sectionbib.tar.gz
@CSQ223
根据 chapterbib
宏包文档,你需要在每一个子文件中使用一次 \bibliographystyle
。
具体到你的例子,可以这么做:
xelatex review
review.aux
中搜索 \bibstyle
,搜到 \bibstyle{gbt7714-unsrt}
,复制参数 gbt7714-unsrt
(这样省去了人工判断 gbt7714
加载了哪个 bst 文件的功夫)\bibliographystyle{gbt7714-unsrt}
粘贴到 sec1.tex
和 sec2.tex
gbt7714
宏包的选项,就要重复上述三个步骤xelatex review
bibtex sec1
和 bibtex sec2
xelatex review
单独使用 gbt7714
宏包时,它会根据传入的宏包选项,在主文件中自动加载对应的 bst 文件。这是 gbt7714
宏包文档中明确指出「不需要使用 \bibliographystyle
」的原因。但以 gbt7714
目前的实现,在与 chapterbib
配合使用时,仍需要用户在子文件中手动使用 \bibliographystyle
。
相关文档:texdoc chapterbib
, Introduction
The main point is to allow you to use BibTeX: Each included file should have its own
\bibliographystyle
and\bibliography
commands, and you should run bibtex on each included file separately rather than on the main or root file.
我在分支 https://github.com/muzimuzhi/gbt7714-bibtex-style/tree/support-chapterbib 做了一些修改:
\bibliographystyle{<bst file>}
,而是把 <bst file>
储存在 \gbt@bib@stylename
中\bibliography{<bib file>}
都额外执行 \bibliography{\gbt@bib@stylename}
,向 aux 文件写入 \bibstyle{<bst file>}
信息总体,兼容 gbt7714 宏包现有功能不变,简化了与 chapterbib 宏包的搭配使用(免去了在子文件中手动使用 \bibliographystyle
)。
注意:目前的实现依赖 \bibliography
定义中直接包含 \immediate\write\@auxout
。
@CSQ223 根据
chapterbib
宏包文档,你需要在每一个子文件中使用一次\bibliographystyle
。具体到你的例子,可以这么做:
准备部分
- 执行
xelatex review
- 在生成的
review.aux
中搜索\bibstyle
,搜到\bibstyle{gbt7714-unsrt}
,复制参数gbt7714-unsrt
(这样省去了人工判断gbt7714
加载了哪个 bst 文件的功夫)- 把
\bibliographystyle{gbt7714-unsrt}
粘贴到sec1.tex
和sec2.tex
- 如果以后更改了
gbt7714
宏包的选项,就要重复上述三个步骤执行部分
- 执行一次
xelatex review
- 进入 body 文件夹,分别执行
bibtex sec1
和bibtex sec2
- 回到主目录,执行两次
xelatex review
单独使用
gbt7714
宏包时,它会根据传入的宏包选项,在主文件中自动加载对应的 bst 文件。这是gbt7714
宏包文档中明确指出「不需要使用\bibliographystyle
」的原因。但以gbt7714
目前的实现,在与chapterbib
配合使用时,仍需要用户在子文件中手动使用\bibliographystyle
。相关文档:
texdoc chapterbib
, IntroductionThe main point is to allow you to use BibTeX: Each included file should have its own
\bibliographystyle
and\bibliography
commands, and you should run bibtex on each included file separately rather than on the main or root file.
@muzimuzhi 提供的解决方案非常正确。
另外 -unsrt
和 -plain
两个后缀的命名有些让人困惑,在下个版本中会换成 -numerical
和 -author-year
,见 https://github.com/CTeX-org/gbt7714-bibtex-style/issues/49#issuecomment-586682470 。
另外
-unsrt
和-plain
两个后缀的命名有些让人困惑
同意
我想实现一个每章都有参考文献的效果,加上\usepackage[sectionbib]{chapterbib}之后不起作用,refsection=chapter也不起作用。