Transcription

GB/T 7714 BibTEX styleZeping Lee 2022/03/21v2.1.4摘要The gbt7714 package provides a BibTEX implementation for the China’s national bibliography style standard GB/T 7714. It consists of .bst files for numeric and author-date styles aswell as a LATEX package which provides the citation style defined in the standard. It is compatible with natbib and supports language detection (Chinese and English) for each biblilographyentry.简介1GB/T 7714—2015 《信息与文献参考文献著录规则》[1] 的格式。本宏包是国标的 BibTEX [2] 实现,具有以下特性: 兼容 natbib 宏包 [3] 。 ”两种风格。 自动识别语言并进行相应处理。 提供了简单的接口供用户修改样式。 同时提供了 2005 版的 .bst epinglee/gbt7714-bibtex-style。版本 v2.0 的重要修改2从 v2.0 中使用 如 gbt7714-numerical 或 文献样式的方法是将 numbers 或 super 等参数传递给 gbt7714,而不能使用 \bibliographystyle。这跟标准的 LaTeX 接口不一致,所以将被弃用。 zepinglee AT gmail.com1

使用方法3以下是 gbt7714 调用宏包 gbt7714,并且使用 \bibliographystyle ibliographystyle{gbt7714-numerical}%㙫㩠 㸃- ㅰ㺨此外还可以使用 2005 版的格式 gbt7714-2005-numerical 和 gbt7714-2005-author-year。注意,版本 v2.0 求直接使用 而且更改了 bst 的文件名。\citestyle\citestyle{⟨citation 角标式,如“张三[2] 献 [3] 中说明”,可以使用 \citestyle 用多篇文献时,应当将各篇文献的 key 一同写在 \cite 为起讫序号并用短横线连接(见 natbib 的 compress 排序,需要在调用 gbt7714 时加 sort&compress 参数会传给 natbib 在 \cite 的可选参数中,如 以参考 natbib 宏包的使用说明 [3] 。使用时需要注意以下几点:2

.bib 数据库应使用 UTF-8 编码。 的文献必须 在 key 排序,详见第 6 节。4文献类型国标中规定了 16 种参考文献类型,表 1 列举了 bib 兼容 BibTEX 和 biblatex (带 * 号)。表 1: gs 或 的析出文献Jarticle学位论文Dmastersthesis 或 数据集DSdataset*其他5Entry 项目多于 BibTEX * BibLaTeX,如 date 和 or 主要责任者title 题名3

mark* 文献类型标识medium* 载体类型标识translator* 译者editor 编辑organization 组织(用于会议)booktitle 图书题名series 系列journal 期刊题名edition 版本address 出版地publisher 出版者school 学校(用于 @phdthesis)institution 机构(用于 @techreport)year 出版年volume 卷number 期(或者专利号)pages 引文页码date* 更新或修改日期urldate* 引用日期url 获取和访问路径doi 数字对象唯一标识符langid* 语言key 拼音(用于排序)不支持的 BibTEX 标准著录项目有 annote, chapter, crossref, month, 手动指定,如:@misc{citekey,langid {japanese},mark {Z},medium {DK},.}可选的语言有 english, chinese, japanese, russian。4

排列。然而由于 BibTEX 的拼音或笔画笔顺,所以必须在 bib 数据库中的 key 如:@book{capital,author { 㙴 andkey 㙱}, {ma3 ke4 si1 & en1 ge2 使用 biblatex 宏包,其后端 biber 手动填写拼音。7自定义样式BibTEX 户只能通过修改 bst bst 文件开始处的 load.config ,表 被设为 #1 则表示该项被启用,设为 #0 学习 bst 文件的语法并修改 [4-6] ,或者联系作者。8相关工作TeX 社区也有其他关于 GB/T 7714 系列参考文献标准的工作。2005 年吴凯 [7] 发布了基于 GB/T 7714—2005 的 BibTEX 两种风格。李志奇 [8] 发布了严格遵循 GB/T 7714—2005 的 BibLaTeX 的样式。胡海星 [9] 提供了另一个 BibTEX 实现,还给每行 bst 代码写了 java 语言注释。沈周 [10] 基于 biblatexcaspervector [11] 发布了符合 GB/T 7714—2015标准的 BibLaTeX 参考文献样式 [12] ,并进行了比较完善的持续维护。5

表 2: ence.case.title#1将西文的题名转为 sentence caselink.title#0在题名上添加 url "in", urldateshow.url#1显示 urlshow.doi#1显示 显示 note 文献[1] 中国国家标准化委员会. 信息与文献参考文献著录规则: GB/T 7714—2015[S].北京: 中国标准出版社, 2015.[2] PATASHNIK O. BibTEXing[M/OL]. 1988. pdf.[3] DALY P W. Natural sciences citations and references[M/OL]. 1999. b/natbib.pdf.[4] PATASHNIK O. Designing BibTEX styles[M/OL]. 1988. pdf.6

[5] MARKEY N. Tame the beast[M/OL]. 2003. tb en.pdf.[6] MITTELBACH F, GOOSSENS M, BRAAMS J, et al. The LATEX companion[M]. 2nded. Reading, MA, USA: Addison-Wesley, 2004.[7] 吴凯. 发布 GBT7714-2005.bst version1 Beta 版 [EB/OL]. 2006. CTeX 论坛(已关闭).[8] 李志奇. 基于 biblatex 的符合 GBT7714—2005 的中文文献生成工具 [EB/OL].2013. CTeX 论坛(已关闭).[9] 胡海星. A GB/T 7714—2005 national standard compliant BibTeX style[EB/OL].2013. Style.[10] 沈周. 基于 caspervector 改写的符合 GB/T 7714—2005 标准的参考文献格式[EB/OL]. 2016. https://github.com/szsdk/biblatex-gbt77142005.[11] VECTOR C T. biblatex 参考文献和引用样式: caspervector[M/OL]. 2012. .pdf.[12] 胡振震. 符合 GB/T 7714—2015 标准的 biblatex 参考文献样式 [M/OL]. 714-2015.pdf.7

宏包的代码实现A兼容过时的接口1⟨ ng{gbt7714}{The option "#1" is [email protected]}将选项传递给 rentOption}{natbib}}37\ProcessOptions\relax8

调用宏包,注意只需要 compress 不需要 url}如果将 compress 传给 natbib 容易导致 option 献的标注法,可用 \citestyle 调用 numerical 或 authoryear,参见 \[email protected]{\[email protected]}(End definition for \citestyle. This function is documented on page 2.)在使用 \bibliographystyle }下面修改 natbib 里直接重定义命令不使用 etoolbox 的 \patchcmd。Super 样式的 \citep 的页码也为上标。另外加上 \kern\[email protected] 格,参考 4\fi55% *#3*\else\[email protected]#3\fi\else *#3*\else#3%63\fi6465}%66\kern\[email protected]

\else67#1%68\fi69\endgroup7071}将 numbers 样式的 \citep [email protected]\fi78% rical 模式的 \citet let\[email protected]\@empty93\@for\@citeb: ndefined\PackageWarning{natbib}%{Citation \@citeb' on page \thepage \space et\[email protected] [email protected]@citeb}{}}{}%10

@swa\@ifnum{\[email protected] \@ne}{%\@citea\[email protected]@{\@ifnum{\[email protected] um{\[email protected] \[email protected]}{%\[email protected]@num\[email protected]{\let\[email protected] [email protected]{\@tempcnta um{\[email protected] \@tempcnta}{%121\@ifnum{\[email protected] empcnta by\@ne125\@ifnum{\[email protected] \@tempcnta}{%在顺序编码制下,natbib 连接号。126% \ifx\[email protected]@yr\relax127%128% \else129%130% atrue138\@ifnum{\[email protected] \@ne}{\@ifnum{\[email protected]@num 44145\else\ifcase\[email protected]\ifx\[email protected]@nm\[email protected] \[email protected]\[email protected]\[email protected]\else11

\@citea }%160161\@ifnum{\[email protected] 在括号外边,并且置于上标。163% \@ifnum{\[email protected] \[email protected]}{%164%165% e n\fi173}{#1}{#2}%174175}%Author-year 模式的 \citep se#1\fi\endgroup}(End definition for \cite. This function is documented on page ?.)Author-year 模式的 \citet [email protected]@parser182\[email protected]@cites{#3}%12

t\[email protected]\@empty185\@for\@citeb: @[email protected]}{\@citea%190{\[email protected]\bfseries 193{Citation \@citeb' on page \thepage \space undefined}\def\[email protected]{}}%{\let\[email protected]@nm \[email protected]\let\[email protected]@yr 98199\let\[email protected] iple citation on page \thepage: same authors and210year\MessageBreak without distinguishing extraletter,\MessageBreak appears as question 4}%\fi13

a\[email protected]@{\[email protected]}%229\fi ine{natbib}%239{Multiple citation on page \thepage: same authors and240year\MessageBreak without distinguishing extraletter,\MessageBreak appears as question 65\fi266}}\[email protected]\else14

267% blabel[1]{[#1]\hfill}使用 xurl 宏包的方法,增加 URL o\x\do\y\do\z277278}279\Urlmuskip 0mu plus 0.1mu(End definition for \url. This function is documented on page ?.)兼容 v2.0 [email protected]#1 umerical15

310⟨/package⟩BibTeX 下面的 load.config 函数中选择是否启用。311⟨ author-year numerical⟩342INTEGERS 034116

r⟩350}351352353354STRINGS 为 #1 则启用该项,若被设为 #0 配置。356357FUNCTION {load.config}{如果姓名的数量大于等于 et.al.min,只著录前 et.al.use.first 361362363364365366367⟨ !ucas⟩#2 'citation.et.al.min : #1 'citation.et.al.use.first : ⟨/!ucas⟩⟨ ucas⟩#3 'citation.et.al.min : #1 'citation.et.al.use.first : ⟨/ucas⟩#4 'bibliography.et.al.min : #3 'bibliography.et.al.use.first : !(no-uppercase thu)⟩#1 'uppercase.name : ⟨/!(no-uppercase thu)⟩⟨ no-uppercase thu⟩#0 'uppercase.name : ⟨/no-uppercase thu⟩使用 TeX 宏输出“和”、“等”374375376377378⟨ !(macro ucas)⟩#0 'terms.in.macro : ⟨/!(macro ucas)⟩⟨ macro ucas⟩#1 'terms.in.macro : 379⟨/macro ucas⟩380⟨ numerical 年制默认)381382383384385#0 'year.after.author : ⟨/numerical ucas⟩⟨ author-year&!ucas⟩#1 'year.after.author : ⟨/author-year&!ucas⟩17

393394⟨ numerical⟩#1 'period.after.author : ⟨/numerical⟩⟨ author-year⟩⟨ 2015&!(period ustc)⟩#0 'period.after.author : ⟨/2015&!(period ustc)⟩⟨ period 2005 ustc⟩#1 'period.after.author : 396⟨/period 2005 ustc⟩⟨/author-year⟩397⟨ 9400401#0 'italic.book.title : ⟨/!italic-book-title⟩⟨ italic-book-title⟩#1 'italic.book.title : 402⟨/italic-book-title⟩403⟨ !no-sentence-case⟩英文标题转为 sentence case 6407408#1 'sentence.case.title : ⟨/!no-sentence-case⟩⟨ no-sentence-case⟩#0 'sentence.case.title : 409410411412413414⟨ !link-title⟩#0 'link.title : ⟨/!link-title⟩⟨ link-title⟩#1 'link.title : 418419⟨ !no-title-in-journal⟩#1 'title.in.journal : ⟨/!no-title-in-journal⟩⟨ no-title-in-journal⟩#0 'title.in.journal : 420⟨/no-title-in-journal⟩421⟨ !(show-patent-country 2005 ustc 25426#0 'show.patent.country : ⟨/!(show-patent-country 2005 ustc thu)⟩⟨ (show-patent-country 2005 ustc thu)⟩#1 'show.patent.country : ⟨/(show-patent-country 2005 ustc thu)⟩18

427428429430431432⟨ !no-mark⟩#1 'show.mark : ⟨/!no-mark⟩⟨ no-mark⟩#0 'show.mark : :433434435436437⟨ !space-before-mark⟩#0 'space.before.mark : ⟨/!space-before-mark⟩⟨ space-before-mark⟩#1 'space.before.mark : 438⟨/space-before-mark⟩439⟨ 比如“/OL“):440441442443#1 'show.medium.type : ⟨/!no-medium-type⟩⟨ no-medium-type⟩#0 'show.medium.type : 444⟨/no-medium-type⟩445⟨ !(in-collection 448449450451452"slash" 'component.part.label : ⟨/!(in-collection no-slash)⟩⟨ in-collection⟩"in" 'component.part.label : ⟨/in-collection⟩⟨ no-slash⟩"none" 'component.part.label : 453⟨/no-slash⟩454⟨ 458459#0 'short.journal : ⟨/!short-journal⟩⟨ short-journal⟩#1 'short.journal : 462463464465⟨ !italic-journal⟩#0 'italic.journal : ⟨/!italic-journal⟩⟨ italic-journal⟩#1 'italic.journal : 6#0 'bold.journal.volume : 19

s.n.”:467468469470471⟨ !sl-sn⟩#0 'show.missing.address.publisher : ⟨/!sl-sn⟩⟨ sl-sn⟩#1 'show.missing.address.publisher : 472⟨/sl-sn⟩473⟨ 间是否有空格:474475476477#1 'space.before.pages : ⟨/!no-space-before-pages⟩⟨ no-space-before-pages⟩#0 'space.before.pages : 478⟨/no-space-before-pages⟩479⟨ 80481482483484#0 'only.start.page : ⟨/!only-start-page⟩⟨ only-start-page⟩#1 'only.start.page : 485486487488489⟨ !wave-dash-in-pages⟩#0 'wave.dash.in.pages : ⟨/!wave-dash-in-pages⟩⟨ wave-dash-in-pages⟩#1 'wave.dash.in.pages : 490⟨/wave-dash-in-pages⟩491⟨ 日期:492493494495496#1 'show.urldate : ⟨/!no-urldate⟩⟨ no-urldate⟩#0 'show.urldate : ⟨/no-urldate⟩是否著录 URL:497498499500501⟨ !no-url⟩#1 'show.url : ⟨/!no-url⟩⟨ no-url⟩#0 'show.url : 502⟨/no-url⟩503⟨ !(no-doi 2005)⟩是否著录 DOI:504505506507508#1 'show.doi : ⟨/!(no-doi 2005)⟩⟨ no-doi 2005⟩#0 'show.doi : ⟨/no-doi 2005⟩20

是否著录 e-print:509⟨ !preprint⟩#1 'show.preprint : 510511512⟨/!preprint⟩⟨ preprint⟩#0 'show.preprint : 注释(note)的内容:#0 'show.note : 515中文文献是否显示英文翻译516⟨ !show-english-translation⟩#0 'show.english.translation : 517518519⟨/!show-english-translation⟩⟨ show-english-translation⟩#1 'show.english.translation : 522⟨ !no-period-at-end⟩#1 'end.with.period : 523524525⟨/!no-period-at-end⟩⟨ no-period-at-end⟩#0 'end.with.period : 526527⟨/no-period-at-end⟩528⟨ 4#5529530531532533'lang.zh.order : 'lang.ja.order : 'lang.en.order : 'lang.ru.order : 'lang.other.order : 534⟨/author-year⟩535}536B.2The ENTRY declarationLike Scribe’s (according to pages 231-2 of the April ’84 edition), but no fullauthor oreditors fields because BibTeX does name handling. The annote field is commented out herebecause this family doesn’t include an annotated bibliography style. And in addition to thefields listed here, BibTeX has a built-in crossref field, explained later.537538539540541542543544ENTRY{ 1

volumeyear}{ entry.lang entry.is.electronic is.pure.electronic entry.numbered }These string entry variables are used to form the citation label. In a storage pinch,sort.label can be easily computed on the fly.576{ label extra.label sort.label short.label short.list entry.mark entry.url }577B.3Entry functionsEach entry function starts by calling output.bibitem, to write the \bibitem and itsarguments to the .BBL file. Then the various fields are formatted and printed by output or output.check. Those functions handle the writing of separators (commas, periods,\newblock’s),taking care not to do so when they are passed a null string. Finally, fin.entryis called to add the final period and finish the entry.A bibliographic reference is formatted into a number of ‘blocks’: in the open format,a block begins on a new line and subsequent lines of the block are indented. A block maycontain more than one sentence (well, not a grammatical sentence, but something to be endedwith a sentence ending period). The entry functions should call new.block whenever a blockother than the first is about to be started. They should call new.sentence whenever a new22

sentence is to be started. The output functions will ensure that if two new.sentence’s occurwithout any non-null string being output between them then there won’t be two periodsoutput. Similarly for two successive new.block’s.The output routines don’t write their argument immediately. Instead, by convention,that argument is saved on the stack to be output next time (when we’ll know what separatorneeds to come after it). Meanwhile, the output routine has to pop the pending output off thestack, append any needed separator, and write it.To tell which separator is needed, we maintain an output.state. It will be one of thesevalues: before.all just after the \bibitem mid.sentence in the middle of a sentence: commaneeded if more sentence is output after.sentence just after a sentence: period needed after.block just after a block (and sentence): period and \newblock needed. Note: Thesestyles don’t use after.sentenceVAR: output.state : INTEGER – state variable for outputThe output.nonnull function saves its argument (assumed to be nonnull) on the stack,and writes the old saved value followed by any needed separator. The ordering of the testsis decreasing frequency of 到很特殊的“//”,所以我又加了一个 出,所以写了一个 output.after。output.nonnull(s) BEGINs : argument on stackif output.state mid.sentence thenwrite (pop() * ", ")-- "pop" isn't a function: just use stack topelseif output.state after.block thenwrite (add.period (pop()))newline write ("\newblock ")elseif output.state before.all thenwrite (pop())else-- output.state should be after.sentencewrite (add.period (pop()) * " ")fifioutput.state : mid.sentencefipush s on stackENDThe output function calls output.nonnull if its argument is non-empty; its argument maybe a missing field (thus, not necessarily a string)output(s) 23

BEGINif not empty (s) then output.nonnull(s)fiENDThe output.check function is the same as the output function except that, if necessary,output.check warns the user that the t field shouldn’t be empty (this is because it probablywon’t be a good reference without the field; the entry functions try to make the formattinglook reasonable even when such fields are empty).output.check(s,t) BEGINif empty (s) thenwarning ("empty " * t * " in " * cite )else output.nonnull(s)fiENDThe output.bibitem function writes the \bibitem for the current entry (the label shouldalready have been set up), and sets up the separator state for the output functions. And, itleaves a string on the stack as per the output convention.output.bibitem BEGINnewline write ("\bibitem[")% for alphabetic labels,write (label)% these three lineswrite ("]{")% are usedwrite ("\bibitem{")% this line for numeric labelswrite (cite )write ("}")push "" on stackoutput.state : before.allENDThe fin.entry function finishes off an entry by adding a period to the string remainingon the stack. If the state is still before.all then nothing was produced for this entry, so theresult will look bad, but the user deserves it. (We don’t omit the whole entry because theentry was cited, and a bibitem is needed to define the citation label.)fin.entry BEGINwrite (add.period (pop()))newline ENDThe new.block function prepares for a new block to be output, and new.sentence prepares for a new sentence.new.block 24

BEGINif output.state before.all thenoutput.state : after.blockfiENDnew.sentence BEGINif output.state after.block thenif output.state before.all thenoutput.state : after.sentencefifiEND578INTEGERS { output.state before.all mid.sentence after.sentence after.block after.slash }579580INTEGERS { lang.zh lang.ja lang.en lang.ru lang.other }581582INTEGERS { charptr len }583584585586587588589590591592593594595FUNCTION {init.state.consts}{ #0 'before.all : #1 'mid.sentence : #2 'after.sentence : #3 'after.block : #4 'after.slash : #3 'lang.zh : #4 'lang.ja : #1 'lang.en : #2 'lang.ru : #0 'lang.other : 02FUNCTION {bbl.anonymous}{ entry.lang lang.zh { " 佚名" }{ "Anon" }if }603604605606607608609FUNCTION {bbl.space}{ entry.lang lang.zh { "\ " }{ " " }if }610611612FUNCTION {bbl.and}{ "" }613614FUNCTION {bbl.et.al}25

615616617618619620621622623624625626627{ entry.lang lang.zh { " 等" }{ entry.lang lang.ja { " 他" }{ entry.lang lang.ru { "идр" }{ "et al." }if }if }if }628629630631632633634FUNCTION {citation.and}{ terms.in.macro{ "{\biband}" }'bbl.andif }635636637638639640641FUNCTION {citation.et.al}{ terms.in.macro{ "{\bibetal}" }'bbl.et.alif }642643FUNCTION {bbl.colon} { ": " }644645646647648649650FUNCTION {bbl.pages.colon}{ space.before.pages{ ": " }{ ":\allowbreak " }if }651652⟨ !2005⟩653FUNCTION {bbl.wide.space} { "\quad " }655⟨/!2005⟩⟨ 2005⟩656FUNCTION {bbl.wide.space} { "\ " }657⟨/2005⟩654658659FUNCTION {bbl.slash} { "//\allowbreak " }660661662663664665666FUNCTION {bbl.sine.loco}{ entry.lang lang.zh { "[出版地不详]" }{ "[S.l.]" }if }667668669FUNCTION {bbl.sine.nomine}{ entry.lang lang.zh 26

{ "[出版者不详]" }{ "[s.n.]" }if 670671672673}674675676677678679680FUNCTION {bbl.sine.loco.sine.nomine}{ entry.lang lang.zh { "[出版地不详: 出版者不详]" }{ "[S.l.: s.n.]" }if }681These three functions pop one or two (integer) arguments from the stack and push asingle one, either 0 or 1. The 'skip in the ‘and’ and ‘or’ functions are used because thecorresponding if would be idempotent682683684685686FUNCTION {not}{{ #0 }{ #1 }if }687688689690691692FUNCTION {and}{'skip { pop #0 }if }693694695696697698FUNCTION {or}{{ pop #1 }'skip if }699700STRINGS { x y N {contains}{ 'y : 'x : y text.length 'len : x text.length len - #1 'charptr : { charptr #0 x charptr len substring y notand}{ charptr #1 - 'charptr : }while charptr #0 }715the variables s and t are temporary string holders716STRINGS { s t }71727

4735736737738739740741742743FUNCTION {output.nonnull}{ 's : output.state mid.sentence { ", " * write }{ output.state after.block { add.period write newline "\newblock " write }{ output.state before.all 'write { output.state after.slash { bbl.slash * write newline }{ add.period " " * write }if }if }if mid.sentence 'output.state : }if s}744745746747748749750FUNCTION {output}{ duplicate empty 'pop 'output.nonnullif 67768769770771772FUNCTION {output.after}{ 't : duplicate empty 'pop { 's : output.state mid.sentence { t * write }{ output.state after.block { add.period write newline "\newblock " write }{ output.state before.all 'write { output.state after.slash { bbl.slash * write }{ add.period " " * write }if }if }28

if mid.sentence 'output.state : 773774}if s775776777}if 778779780}781782783784785786787788FUNCTION {output.check}{ 't : duplicate empty { pop "empty " t * " in " * cite * warning }'output.nonnullif }789This function finishes all FUNCTION {fin.entry}{ end.with.period'add.period 'skip if write show.english.translation entry.lang lang.zh and{ ")"write }'skip if newline }804805806807808809810811812813814FUNCTION {new.block}{ output.state before.all 'skip { output.state after.slash 'skip { after.block 'output.state : }if }if }815816817818819820821822823824825FUNCTION {new.sentence}{ output.state after.block 'skip { output.state before.all 'skip { output.state after.slash 'skip { after.sentenc

表2:参考文献表样式的配置参数 参数值 默认值 功能 uppercase.name #1 将著者姓名转为大写 max.num.authors #3 输出著者的最多数量 year.after.author #0 年份置于著者之后 period.after.author #0 著者和年份之间使用句点连接 italic.book.title