zepinglee / gbt7714-bibtex-style

GB/T 7714-2015 BibTeX Style
LaTeX Project Public License v1.3c
1.17k stars 196 forks source link

The bug is that the parameter of chapterbib fails to work #48

Closed CSQ223 closed 4 years ago

CSQ223 commented 4 years ago

我想实现一个每章都有参考文献的效果,加上\usepackage[sectionbib]{chapterbib}之后不起作用,refsection=chapter也不起作用。

hushidong commented 4 years ago

chapterbib使用有个关键是要将多个章节都用include使其产生多个aux文件,然后bibtex编译对应每个章节的每个aux文件。 你先试试,再仔细看一下chapterbib文档。

hushidong commented 4 years ago

若无法解决,可发mwe给我或作者。

zepinglee commented 4 years ago

使用 \usepackage[sectionbib]{chapterbib} 后需要给 natbib 传递选项 sectionbib,可以通过 \usepackage[sectionbib]{gbt7714}

CSQ223 commented 4 years ago

使用 \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

muzimuzhi commented 4 years ago

@CSQ223 根据 chapterbib 宏包文档,你需要在每一个子文件中使用一次 \bibliographystyle

具体到你的例子,可以这么做:

单独使用 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.

muzimuzhi commented 4 years ago

我在分支 https://github.com/muzimuzhi/gbt7714-bibtex-style/tree/support-chapterbib 做了一些修改:

总体,兼容 gbt7714 宏包现有功能不变,简化了与 chapterbib 宏包的搭配使用(免去了在子文件中手动使用 \bibliographystyle)。

注意:目前的实现依赖 \bibliography 定义中直接包含 \immediate\write\@auxout

zepinglee commented 4 years ago

@CSQ223 根据 chapterbib 宏包文档,你需要在每一个子文件中使用一次 \bibliographystyle

具体到你的例子,可以这么做:

  • 准备部分

    1. 执行 xelatex review
    2. 在生成的 review.aux 中搜索 \bibstyle,搜到 \bibstyle{gbt7714-unsrt},复制参数 gbt7714-unsrt (这样省去了人工判断 gbt7714 加载了哪个 bst 文件的功夫)
    3. \bibliographystyle{gbt7714-unsrt} 粘贴到 sec1.texsec2.tex
    4. 如果以后更改了 gbt7714 宏包的选项,就要重复上述三个步骤
  • 执行部分

    1. 执行一次 xelatex review
    2. 进入 body 文件夹,分别执行 bibtex sec1bibtex sec2
    3. 回到主目录,执行两次 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.

@muzimuzhi 提供的解决方案非常正确。

另外 -unsrt-plain 两个后缀的命名有些让人困惑,在下个版本中会换成 -numerical-author-year,见 https://github.com/CTeX-org/gbt7714-bibtex-style/issues/49#issuecomment-586682470

muzimuzhi commented 4 years ago

另外 -unsrt-plain 两个后缀的命名有些让人困惑

同意