From 5f53e12799a2dd282de24bf598c98d032d20dcad Mon Sep 17 00:00:00 2001 From: TomHeaven Date: Wed, 8 Mar 2023 11:26:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=AD=E6=96=87=E5=8F=82?= =?UTF-8?q?=E8=80=83=E6=96=87=E7=8C=AE=E5=A4=9A=E4=BD=9C=E8=80=85=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8=E7=9A=84BUG=EF=BC=9B?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=82=E8=80=83=E6=96=87=E7=8C=AE=E6=94=BE?= =?UTF-8?q?=E5=85=A5=E8=A1=A8=E6=A0=BC=E9=9C=80=E8=A6=81=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E7=B9=81=E7=90=90=E6=93=8D=E4=BD=9C=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E7=8E=B0=E5=9C=A8=E4=BD=A0=E6=97=A0=E9=9C=80=E5=86=8D?= =?UTF-8?q?=E5=85=B3=E6=B3=A8\enabletablebib=E9=80=89=E9=A1=B9=E4=BA=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Biblio/gb7714-2015.bbx | 2200 ++++++++++++++++++++++++++++++++++++ Biblio/gb7714-2015.cbx | 83 ++ Biblio/gb7714-2015ay.bbx | 2303 ++++++++++++++++++++++++++++++++++++++ Biblio/gb7714-2015ay.cbx | 102 ++ README.md | 28 +- Style/nudtstyle.sty | 3 +- nudtProposal.tex | 18 +- 7 files changed, 4700 insertions(+), 37 deletions(-) create mode 100755 Biblio/gb7714-2015.bbx create mode 100755 Biblio/gb7714-2015.cbx create mode 100755 Biblio/gb7714-2015ay.bbx create mode 100755 Biblio/gb7714-2015ay.cbx diff --git a/Biblio/gb7714-2015.bbx b/Biblio/gb7714-2015.bbx new file mode 100755 index 0000000..3e6fd8a --- /dev/null +++ b/Biblio/gb7714-2015.bbx @@ -0,0 +1,2200 @@ +%% +%% --------------------------------------------------------------- +%% biblatex-gb7714-2015 --- A biblatex implementation of the +%% GBT7714-2015 bibliography style,numerical sequence +%% Maintained by huzhenzhen +%% history: +%% 2016/05/20 v1.0 2016/10/23 v1.0a 2016/11/11 v1.0b +%% 2016/11/14 v1.0c 2016/11/24 v1.0d 2016/12/07 v1.0e +%% 2017/02/26 v1.0g 2017/04/11 v1.0h +%% 2017/11/21 v1.0i 2018/01/20 v1.0j +%% E-mail: hzzmail@163.com +%% Released under the LaTeX Project Public License v1.3c or later +%% --------------------------------------------------------------- +%% +\ProvidesFile{gb7714-2015.bbx}[2018/01/20 v1.0j biblatex bibliography style] + + +%===================================================================== +%===================================================================== +%加载标准样式 +%===================================================================== +\RequireBibliographyStyle{numeric-comp}%Load the standard style to avoid copy-pasting unnecessary material +\RequireBibliographyStyle{standard} +\RequirePackage{xstring}%为兼容texlive2015的biblatex3.0不加载xstring包的问题 + + +%===================================================================== +%===================================================================== +%新增功能函数 +%===================================================================== + %版本判断,当版本继续更新时,增加一个新的toggle用以处理新的旧版,最新版本永远用iftlatest + \providetoggle{iftlfive}%用于处理biblatex3.2之前的版本 + \providetoggle{iftlsix}%用于处理biblatex3.3开始改变的新的姓名机制后版本 + \providetoggle{iftlseven}%用于处理biblatex3.7的兼容性 + \providetoggle{iftleight}%用于处理biblatex3.8到3.9的兼容性 + \providetoggle{iftlatest}%用于最新版biblatex,目前是biblatex3.10,20180117 + \StrBefore{\abx@version}{.}[\numinteger]%以点区分整数和小数 + \StrBehind{\abx@version}{.}[\numdigital]%小数部分可能带字母所以需将其去掉,见下一行代码 + \IfInteger{\numdigital}{}{\StrGobbleRight{\numdigital}{1}[\numdigital]} + \togglefalse{iftlfive} + \togglefalse{iftlsix} + \togglefalse{iftlseven} + \togglefalse{iftleight} + \toggletrue{iftlatest} + \ifnumcomp{\numinteger}{=}{3}{ + \ifnumcomp{\numdigital}{<}{10}{\ifnumcomp{\numdigital}{>}{7}{\toggletrue{iftleight}\togglefalse{iftlatest}}{}}{}%>3.8版本用iftleight=true表示 + \ifnumcomp{\numdigital}{=}{7}{\toggletrue{iftlseven}\togglefalse{iftlatest}}{}%3.7版本用iftlseven=true表示 + \ifnumcomp{\numdigital}{<}{7}{\ifnumcomp{\numdigital}{>}{2}{\toggletrue{iftlsix}\togglefalse{iftlatest}}{}}{}%3.3-3.6版本用iftlsix=true表示 + \ifnumcomp{\numdigital}{<}{3}{\toggletrue{iftlfive}\togglefalse{iftlatest}}{}%3.0-3.2版本用iftlfive=true表示 + }{\ifnumcomp{\numinteger}{>}{3}{ + \blx@warning@noline{% + biblatex version is >= 4.x.\MessageBreak + if errors raised,Please contact biblatex-gb7714-2015 pkg author.}% + }{ \toggletrue{iftlfive}\togglefalse{iftlatest}%2.x版本统一用iftlfive=true表示 + \blx@warning@noline{% + biblatex version is <= 2.x.\MessageBreak + if errors raised,Please contact biblatex-gb7714-2015 pkg author.}% + }} + \newcommand\defversion[2]{\csdef{codeversion#1#2}}%定义不同版本的命令 + \newcommand\switchversion[2]{\csuse{codeversion#1#2}}%使用不同版本的命令 + + %定义判断中文字符的函数,用于判断作者等信息是否由中文字符构成 + %2E00-2E7F 追加标点 + %2E80-2EFF cjk部首补充 + %2FF0-2FFF 表意文字描述符 + %3000-303F cjk符号和标点 + %3300-33FF cjk兼容 + %3400-4DBF cjk统一表意符号扩展 + %4E00-9FBF cjk统一表意符号 + %中文范围4E00-9FA5 + \providetoggle{ifCJKforgbt} + \def\testCJKfirstchar#1#2&{%#1#2& + \ifnumgreater{`#1}{"2E7F}{\toggletrue{ifCJKforgbt}}{\togglefalse{ifCJKforgbt}}% + }% + + %利用edef展开或xstring抽取第一个字符判断 + %现在采用xstring方法,避免抽取的是编组符号 + \def\testCJKfirst#1{% + %\edef\tempa{#1}% + %\expandarg%\noexpandarg + \exploregroups% + \StrChar{#1}{1}[\tempa]% + \expandafter\testCJKfirstchar\tempa&} + + %用于解析连续出版物,2个卷期的情况 + %范围起止间隔符号还是用-,而不是与date相同的/,因为有合期期刊的问题,需要用到/符号 + \newcommand{\multivolparser}[1]{% + \IfSubStr{#1}{-}% + {\StrBefore{#1}{-}[\multivolfirst]\StrBehind{#1}{-}[\multivolsecond]}% + {\def\multivolfirst{#1}\def\multivolsecond{}}% + } + + \newcommand{\multinumberparser}[1]{% + \IfSubStr{#1}{-}% + {\StrBefore{#1}{-}[\multinumberfirst]\StrBehind{#1}{-}[\multinumbersecond]}% + {\def\multinumberfirst{#1}\def\multinumbersecond{}}% + } + +%===================================================================== +%===================================================================== +%设置宏包选项 +%===================================================================== +\defversion{3.0}{opt}{ + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + + %增加姓名大小写格式处理选项 + \DeclareBibliographyOption{gbnamefmt}[uppercase]{% + %\ifstrequal{##1}{gbuppercase}{}{}% + \ifstrequal{##1}{lowercase}{\execgblowercase}{}% + \ifstrequal{##1}{none}{\execnamedefault}{} + \ifstrequal{##1}{pinyin}{\execnamepinyin}{} + } + %\ExecuteBibliographyOptions{gbnamefmt} + + %增加标签对齐选项,right是默认的右对齐,left是左对齐,gb7714-2015无效,仍然为右对齐模式,因为舍弃了list类环境后出错。 + \DeclareBibliographyOption{gbalign}[right]{%texlive2015中的3.0版中的DeclareBibliographyOption选项没有类型说明 + \ifstrequal{##1}{right}{}{} + \ifstrequal{##1}{left}{\setalignleft}{} + \ifstrequal{##1}{gb7714-2015}{}{} + } + + %增加一个出版项自动处理控制选项,当true时使用出版者不详等信息补充缺失的出版信息。 + \newtoggle{bbx:gbpub} + \DeclareBibliographyOption{gbpub}[true]{% + %\settoggle{bbx:gbpub}{#1} %或采用下面这一句 + \ifstrequal{##1}{false}{\togglefalse{bbx:gbpub}}{\toggletrue{bbx:gbpub}}} + \ExecuteBibliographyOptions{gbpub} + + %增加一个处理佚名或noauthor的控制选项 + %因为在顺序编码制中,不需要使用,这里也增加,为了与作者年制的兼容性考虑。 + \DeclareBibliographyOption{gbnoauthor}[true]{}% + + \ExecuteBibliographyOptions{ + sorting=none, + useprefix=true, %名字的信息包括前缀 + firstinits=true, %名字有缩写,参考3.1.2.3 Internal + %giveninits=true, + date = year, %日期仅写到年 + maxnames = 3 , %设置名字最大数量 + minnames = 3 %设置缩减后的名字最小数量 + %uniquename = init + } +} + +\defversion{3.4}{opt}{ + % Alter settings that carry through from biblatex + %biblatex3.3版后(比如texlive2016中的3.4版)的使用方式 + + %增加姓名大小写格式处理选项 + \DeclareBibliographyOption[string]{gbnamefmt}[uppercase]{% + %\ifstrequal{##1}{gbuppercase}{}{}% + \ifstrequal{##1}{lowercase}{\execgblowercase}{}% + \ifstrequal{##1}{none}{\execnamedefault}{} + \ifstrequal{##1}{pinyin}{\execnamepinyin}{} + } + %\ExecuteBibliographyOptions{gbnamefmt} + + %增加标签对齐选项,right是默认的右对齐,left是左对齐,gb7714-2015是项对齐方式 + \DeclareBibliographyOption[string]{gbalign}[right]{% + \ifstrequal{##1}{left}{\setalignleft}{} + \ifstrequal{##1}{gb7714-2015}{\setaligngbstyle}{} + } + + %增加一个出版项自动处理控制选项,当true时使用出版者不详等信息补充缺失的出版信息。 + \newtoggle{bbx:gbpub} + \DeclareBibliographyOption[boolean]{gbpub}[true]{% + %\settoggle{bbx:gbpub}{#1} %或采用下面这一句 + \ifstrequal{##1}{false}{\togglefalse{bbx:gbpub}}{\toggletrue{bbx:gbpub}}} + \ExecuteBibliographyOptions{gbpub} + + %增加一个处理佚名或noauthor的控制选项 + %因为在顺序编码制中,不需要使用,这里也增加,为了与作者年制的兼容性考虑。 + \DeclareBibliographyOption[boolean]{gbnoauthor}[true]{}% + + \ExecuteBibliographyOptions{ + sorting=none, + useprefix=true, %名字的信息包括前缀 + %firstinits=true, %名字有缩写,参考3.1.2.3 Internal + giveninits=true, + date = year, %日期仅写到年 + maxnames = 3 , %设置名字最大数量 + minnames = 3 %设置缩减后的名字最小数量 + %uniquename = init + } +} + +\defversion{3.7}{opt}{ + %biblatex3.7版后(比如texlive2017中的3.7版)的使用方式 + + %增加姓名大小写格式处理选项 + \DeclareBibliographyOption[string]{gbnamefmt}[uppercase]{% + %\ifstrequal{##1}{gbuppercase}{}{}% + \ifstrequal{##1}{lowercase}{\execgblowercase}{}% + \ifstrequal{##1}{none}{\execnamedefault}{} + \ifstrequal{##1}{pinyin}{\execnamepinyin}{} + } + %\ExecuteBibliographyOptions{gbnamefmt} + + %增加标签对齐选项,right是默认的右对齐,left是左对齐,gb7714-2015是项对齐方式 + \DeclareBibliographyOption[string]{gbalign}[right]{% + \ifstrequal{##1}{left}{\setalignleft}{} + \ifstrequal{##1}{gb7714-2015}{\setaligngbstyle}{} + } + + %增加一个出版项自动处理控制选项,当true时使用出版者不详等信息补充缺失的出版信息。 + \newtoggle{bbx:gbpub} + \DeclareBibliographyOption[boolean]{gbpub}[true]{% + %\settoggle{bbx:gbpub}{#1} %或采用下面这一句 + \ifstrequal{##1}{false}{\togglefalse{bbx:gbpub}}{\toggletrue{bbx:gbpub}}} + \ExecuteBibliographyOptions{gbpub} + + %增加一个处理佚名或noauthor的控制选项 + %因为在顺序编码制中,不需要使用,这里也增加,为了与作者年制的兼容性考虑。 + \DeclareBibliographyOption[boolean]{gbnoauthor}[true]{}% + + \ExecuteBibliographyOptions{ + sorting=none, + useprefix=true, %名字的信息包括前缀 + %firstinits=true, %名字有缩写,参考3.1.2.3 Internal + giveninits=true, + date = year, %日期仅写到年 + urldate =edtf, %iso8601 + eventdate =edtf, + maxnames = 3 , %设置名字最大数量 + minnames = 3 %设置缩减后的名字最小数量 + %uniquename = init + } +} + +\defversion{3.10}{opt}{ + %biblatex3.10版后的使用方式 + + %增加姓名大小写格式处理选项 + \DeclareBibliographyOption[string]{gbnamefmt}[uppercase]{% + %\ifstrequal{##1}{gbuppercase}{}{}% + \ifstrequal{##1}{lowercase}{\execgblowercase}{}% + \ifstrequal{##1}{none}{\execnamedefault}{} + \ifstrequal{##1}{pinyin}{\execnamepinyin}{} + } + %\ExecuteBibliographyOptions{gbnamefmt} + + %增加标签对齐选项,right是默认的右对齐,left是左对齐,gb7714-2015是项对齐方式 + \DeclareBibliographyOption[string]{gbalign}[right]{% + \ifstrequal{##1}{left}{\setalignleft}{} + \ifstrequal{##1}{gb7714-2015}{\setaligngbstyle}{} + } + + %增加一个出版项自动处理控制选项,当true时使用出版者不详等信息补充缺失的出版信息。 + \newtoggle{bbx:gbpub} + \DeclareBibliographyOption[boolean]{gbpub}[true]{% + %\settoggle{bbx:gbpub}{#1} %或采用下面这一句 + \ifstrequal{##1}{false}{\togglefalse{bbx:gbpub}}{\toggletrue{bbx:gbpub}}} + \ExecuteBibliographyOptions{gbpub} + + %增加一个处理佚名或noauthor的控制选项 + %因为在顺序编码制中,不需要使用,这里也增加,为了与作者年制的兼容性考虑。 + \DeclareBibliographyOption[boolean]{gbnoauthor}[true]{}% + + \ExecuteBibliographyOptions{ + sorting=none, + useprefix=true, %名字的信息包括前缀 + %firstinits=true, %名字有缩写,参考3.1.2.3 Internal + giveninits=true, + date = year, %日期仅写到年 + urldate =iso, %iso8601,edtf + eventdate =iso, + maxnames = 3 , %设置名字最大数量 + minnames = 3 %设置缩减后的名字最小数量 + %uniquename = init + } +} + +\iftoggle{iftlfive}{\switchversion{3.0}{opt}}{}%biblatex<=3.2 +\iftoggle{iftlsix}{\switchversion{3.4}{opt}}{}%3.3<=biblatex<=3.6 +\iftoggle{iftlseven}{\switchversion{3.7}{opt}}{}%biblatex=3.7 +\iftoggle{iftleight}{\switchversion{3.7}{opt}}{}%3.8<=biblatex<=3.9 +\iftoggle{iftlatest}{\switchversion{3.10}{opt}}{}%biblatex最新3.10 + + +%===================================================================== +%===================================================================== +%设置本地化字符串 +%===================================================================== + %新建一个当地化字符串,用来记录“等”字符 + \NewBibliographyString{andotherscn} + \NewBibliographyString{noaddress} + \NewBibliographyString{nopublisher} + + %直接利用当地化格式english进行修改一些中文的格式,具体可以修改哪些,参考english.lbx文件 + %当然也可以增加比如上面定义的andotherscn + %注意:在lbx文件和bbx文件中定义本地字符串的不同语法,两个参数和一个参数的区别 + \DefineBibliographyStrings{english}{ + bibliography = {参考文献}, + references = {参考文献}, + %bytranslator= {\addcomma\ 译\adddot}, %将trans. by 改成 译 + bytranslator= {\addcomma\ 译},%\addperiod + and = {\addcomma},%将第2和3人名见的and符号改成 逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 + %andothers = {et al.}, %将超过3个人名的省略,et al.改成为 等 + andotherscn = {等}, %将超过3个人名的省略,et al.改成为 等 + noaddress = {[S.l.]}, + nopublisher = {[s.n.]}, + backrefpage = {引用页:}, + backrefpages = {引用页:}, + } + + +%===================================================================== +%===================================================================== +%动态数据修改,修改输入的源文件数据,用于中文判断等 +%===================================================================== +%修改输入的源文件数据,用于中文判断等操作 +%首先把作者和译者信息准确的记录到userf,usere中,用于后面判断是否是cjk字符。 +%注意这里用userf,usere而不是namee,namef,是因为只有把name列表转成域,才能有效读取姓名中的字符, +%如果用namee,namef,name信息会自动解析,所以就不能为cjk判断提供需要的信息 +%注意\DeclareSourcemap命令只能出现一次 +\DeclareSourcemap{ +\maps[datatype=bibtex]{%增加文献标识符如[M],[J]等,下面首先生成这一信息 + \map[overwrite]{%用于处理zotero从cnki导出中文文献姓名中存在逗号的情况 + \step[fieldsource={author}, match=\regexp{([\x{2FF0}-\x{9FA5}])\,\s*}, replace=\regexp{$1}] + } + \map{%使用下面biber动态修改bbl文件的方法是正确的 + %\perdatasource{examples.bib} + \pertype{article} + \step[fieldset=usera, fieldvalue={J}] + } + \map{ + \pertype{periodical} + \step[fieldset=usera, fieldvalue={J}] + \step[fieldsource=author] %有时会把author和editor混淆,这里处理后就没有这个问题 + \step[fieldset=editor, origfieldval] + \step[fieldsource=publisher] %有时会把publisher和institution混淆,这里处理后就没有这个问题 + \step[fieldset=institution, origfieldval] + } + \map{ + \pertype{newspaper}%增加一个新闻报纸的类型newspaper + \step[fieldset=usera, fieldvalue={N}]%因为没有专门的驱动,这句的目的是定义一个usera域,方便映射为article后判断 + \step[fieldset=note, fieldvalue=news] + } + \map{ + \pertype{book} + \pertype{inbook} + \step[fieldset=usera, fieldvalue={M}] + \step[fieldsource=version] %有时会把version和edition混淆,这里处理后就没有这个问题,可以直接用version + \step[fieldset=edition, origfieldval] + } + \map{ + \pertype{standard}%兼容老的standard类型 + \step[fieldset=usera, fieldvalue={M}]%因为没有专门的驱动,这句的目的是定义一个usera域,方便映射为book和inbook后判断 + \step[fieldset=note, fieldvalue=standard] + } + \map{ + \pertype{patent} + \step[fieldset=usera, fieldvalue={P}] + } + \map{ + \pertype{inproceedings} + \pertype{conference}%兼容老的conference类型 + \step[fieldset=usera, fieldvalue={C}] + \step[fieldsource=institution] %有时会把publisher和institution混淆,这里处理后就没有这个问题 + \step[fieldset=publisher, origfieldval] + \step[fieldsource=editor] % + \step[fieldset=bookauthor, origfieldval] + } + \map{ + \pertype{proceedings} + \step[fieldset=usera, fieldvalue={C}] + \step[fieldsource=institution] % + \step[fieldset=publisher, origfieldval] + \step[fieldsource=editor] %有的时候可能只填写了编者,没有author,把它复制一下 + \step[fieldset=author, origfieldval] + } + \map{ + \pertype{report} + \pertype{techreport}%兼容老的techreport类型 + \step[fieldset=usera, fieldvalue={R}] + \step[fieldsource=publisher] %有时会把publisher和institution混淆,这里处理后就没有这个问题 + \step[fieldset=institution, origfieldval] + } + \map{ + \pertype{thesis} + \pertype{mastersthesis}%兼容老的mastersthesis和phdthesis类型 + \pertype{phdthesis} + \step[fieldset=usera, fieldvalue={D}] + } + \map{ + \pertype{online} + \pertype{electronic}%兼容老的electronic类型 + \pertype{www}%兼容老的www类型 + \step[fieldset=usera, fieldvalue={EB}] + } + \map{ + \pertype{manual} + \step[fieldset=usera, fieldvalue={A}] + \step[fieldsource=edition] %有时会把version和edition混淆,这里处理后就没有这个问题,可以直接用version + \step[fieldset=version, origfieldval] + \step[fieldsource=organization]%因为用的report的驱动,所以需要institution域,也把organization转成它,这样增大兼容性 + \step[fieldset=institution, origfieldval] + } + \map{ + \pertype{incollection} + \step[fieldset=usera, fieldvalue={G}] + } + \map{ + \pertype{collection} + \step[fieldset=usera, fieldvalue={G}] + \step[fieldsource=editor] %%有的时候可能只填写了编者,没有author,把它复制一下 + \step[fieldset=author, origfieldval] + } + \map{ + \pertype{unpublished} + \step[fieldset=usera, fieldvalue={Z}] + } + \map{ + \step[fieldsource=author] + \step[fieldset=userf, origfieldval] + \step[fieldsource=translator] + \step[fieldset=usere, origfieldval] + \step[fieldsource=year] + \step[fieldset=date, origfieldval] + } + \map{%title + \step[fieldsource={title}, match=\regexp{([^\\\{])}] + \step[fieldset=userd, fieldvalue={$1}] + } + \map{%将entrykey放入keywords中用于后期的使用 + \step[fieldsource=entrykey] + \step[fieldset=keywords, origfieldval] + } + \map[overwrite]{%这里还必须有overwrite,怎么之前会觉得没有问题呢,可能是之前版本拷错了,还是之前是texlive2015变16后biber有了变化(2016-1207修改正确) + \step[fieldsource=note, final]%将note域信息复制给keywords,用于输出时容易区分标准和报纸 + \step[fieldset=keywords, fieldvalue={,}, append] + \step[fieldset=keywords, origfieldval, append] + } +} +} + +\defversion{3.0}{map}{ + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + % \map{%尝试未定义数据模型的newspaper类型映射为article,newspaper完全是针对gb7714的新类型,在biblatex中完全没有定义 + % %但从实践看,并没有什么影响,映射过来就可以了。 + % \step[typesource=newspaper, typetarget=article, final] + % } + \map{%尝试未定义数据模型的standard类型映射为book,standard类型在blx-dm中有出现,但仅定义了类型,域和约束等都没有定义 + \step[fieldsource=booktitle,final]%当存在booktitle域是映射为inbook + \step[typesource=standard, typetarget=inbook, final] + } + \map{%尝试未定义数据模型的standard类型映射为book,standard类型在blx-dm中有出现,但仅定义了类型,域和约束等都没有定义 + \step[typesource=standard, typetarget=book, final]%当不存在booktitle域是映射为book + } + \map{%先于标准样式的driver层映射,将其先映射过来,并取消type设置 + \step[typesource=mastersthesis, typetarget=thesis, final] + %\step[fieldset=type, fieldvalue=mathesis] + } + \map{%先于标准样式的driver层映射,将其先映射过来,并取消type设置 + \step[typesource=phdthesis, typetarget=thesis, final] + %\step[fieldset=type, fieldvalue=phdthesis] + } + \map{%先于标准样式的driver层映射,将其先映射过来,并取消type设置 + \step[typesource=techreport, typetarget=report, final] + %\step[fieldset=type, fieldvalue=techreport] + } + \map[overwrite]{%title,booktitle,journaltitle,journal,publisher,address,location,institution,organization + \step[fieldsource={title}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={booktitle}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={journaltitle}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={journal}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={publisher}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={address}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={location}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={institution}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={booktitle}, match=\regexp{([^\\])\#}, replace=\regexp{$1\\\#}] + } + \map[overwrite]{ + \step[fieldsource={booktitle}, match=\regexp{([^\\])\%}, replace=\regexp{$1\\\%}] + } + } + } +} + +\defversion{3.4}{map}{ + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + % \map{%尝试未定义数据模型的newspaper类型映射为article,newspaper完全是针对gb7714的新类型,在biblatex中完全没有定义 + % %但从实践看,并没有什么影响,映射过来就可以了。 + % \step[typesource=newspaper, typetarget=article, final] + % } + \map{%尝试未定义数据模型的standard类型映射为book,standard类型在blx-dm中有出现,但仅定义了类型,域和约束等都没有定义 + \step[fieldsource=booktitle,final]%当存在booktitle域是映射为inbook + \step[typesource=standard, typetarget=inbook, final] + } + \map{%尝试未定义数据模型的standard类型映射为book,standard类型在blx-dm中有出现,但仅定义了类型,域和约束等都没有定义 + \step[typesource=standard, typetarget=book, final]%当不存在booktitle域是映射为book + } + \map{%先于标准样式的driver层映射,将其先映射过来,并取消type设置 + \step[typesource=mastersthesis, typetarget=thesis, final] + %\step[fieldset=type, fieldvalue=mathesis] + } + \map{%先于标准样式的driver层映射,将其先映射过来,并取消type设置 + \step[typesource=phdthesis, typetarget=thesis, final] + %\step[fieldset=type, fieldvalue=phdthesis] + } + \map{%先于标准样式的driver层映射,将其先映射过来,并取消type设置 + \step[typesource=techreport, typetarget=report, final] + %\step[fieldset=type, fieldvalue=techreport] + } + \map[overwrite, foreach={title,booktitle,journaltitle,journal,publisher,address,location,institution,organization}]{ + \step[fieldsource=\regexp{$MAPLOOP}, match=\regexp{([^\\])\#}, replace=\regexp{$1\\\#}] + } + \map[overwrite, foreach={title,booktitle,journaltitle,journal,publisher,address,location,institution,organization}]{ + \step[fieldsource=\regexp{$MAPLOOP}, match=\regexp{([^\\])\%}, replace=\regexp{$1\\\%}] + } + \map[overwrite, foreach={title,booktitle,journaltitle,journal,publisher,% + address,location,institution,organization}]{ + \step[fieldsource=\regexp{$MAPLOOP}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + } + } +} + +\iftoggle{iftlfive}% + {\switchversion{3.0}{map}}%%当采用biblatex<=3.2版本时 + {\switchversion{3.4}{map}}%%当采用3.3<=biblatex版本时 + +\DeclareBibliographyAlias{newspaper}{article}%定义驱动别名,尝试以替代驱动层映射,实践表明是可行的。 + + +%===================================================================== +%===================================================================== +%参考文献表环境 +%===================================================================== +%默认的参考文献列表格式,放这里作为参考 +%\defbibenvironment{bibliography} + +%修改序号标签格式为左对齐,注意各参考文献内容还是对齐的, +%这样就会使得序号标签与参考文献内容的间隔增大,这个问题是没有办法解决的 +%因为采用list做具有一定宽度的序号标签,\labelwidth只能设置一个,且是最宽的标签的宽度 +%但总的来说参考文献内容对齐是合理和漂亮的, +%而标签则只能对齐一个方向,要么左对齐要么右对齐,看个人选择了。 +%\DeclareFieldFormat{shorthandwidth}{\mkbibbrackets{#1}} %源来自numeric.BBX +%\DeclareFieldFormat{labelnumberwidth}{\ttfamily\mkbibbrackets{#1}\hfill} +%\iftoggle{alignleft}{\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}\hfill}}{}%这种方式无效是因为加载时就已经展开了。 +%修改序号标签格式为左对齐 +\def\setalignleft{\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{##1}\hfill}} + +%修改序号标签格式为以各条参文献为基础进行对齐的方式,即序号与条目内容间隔相等的方式。 +\def\setaligngbstyle{% +\def\blx@bibitem##1{% + \blx@ifdata{##1} + {\begingroup + \blx@getdata{##1}% + \blx@bibcheck + \iftoggle{blx@skipentry}{}{% + \blx@setdefaultrefcontext{##1}% + \global\let\blx@noitem\@empty + \blx@setoptions@type\abx@field@entrytype + \blx@setoptions@entry + \blx@thelabelnumber + \addtocounter{instcount}\@ne + \blx@initsep + \blx@namesep + \csuse{blx@item@\blx@theenv}\relax +% \blx@initsep %移动到上面去,恢复bibnamesep等的作用机制 +% \blx@namesep + \csuse{blx@hook@bibitem}% + \blx@execute + \blx@initunit + \blx@anchor + \blx@beglangbib + \bibsentence + \blx@pagetracker + \blx@driver\abx@field@entrytype + \blx@postpunct + \blx@endlangbib}% + \par\endgroup}%这里增加了一个\par + {}} +\newlength{\lengthid} +\newlength{\lengthlw} +\newcommand{\itemcmd}{% +\settowidth{\lengthid}{[\printfield{labelnumber}]} +\addtolength{\lengthid}{\biblabelsep} +\setlength{\lengthlw}{\textwidth} +\addtolength{\lengthlw}{-\lengthid} +\addvspace{\bibitemsep}%恢复\bibitemsep的作用 +%\parshape 2 0em \textwidth \lengthid \lengthlw +\hangindent\lengthid +[\printfield{labelnumber}]\hspace{\biblabelsep}} +\defbibenvironment{bibliography} +{\begingroup\setlength{\parindent}{0em}} +{\endgroup} +{\itemcmd}} + + +%===================================================================== +%===================================================================== +%设置单元或块等的标点 +%===================================================================== +\renewcommand*{\subtitlepunct}{\addcolon\space} %修改标题和其它标题信息间的标点,来源biblatex.def, +%双语言或多语言的参考文献,可以参考3.11.5 Entry Sets,4.11.1 Entry Sets +%这里调整一下两种语言参考文献的间隔,源来自biblatex.def +%%双语之间用newline替换par(20170411 v1.0h),避免采用gb7714-2015的项对齐方式第二语言间分段导致没有缩进 +\renewcommand*{\entrysetpunct}{\adddot\newline\nobreak} +\renewcommand*{\bibpagespunct}{\addcolon\addthinspace}%%页码引用格式的修改,修改为用冒号 + + +%===================================================================== +%===================================================================== +%修改域的格式,重定义域的输出宏 +%===================================================================== +%新增文献类型标识符的格式 +\DeclareFieldFormat{gbtypeflag}{% +\iftoggle{bbx:url}{\iffieldundef{url}%当存在url时,增加一个OL标识符 +{\nobreak\printtext{[}\nobreak#1\nobreak\printtext{]}}% +{\nobreak\printtext{[}\nobreak#1\nobreak\printtext{\texttt{/}OL]}}% +}{\nobreak\printtext{[}\nobreak#1\nobreak\printtext{]}}} + +\DeclareFieldFormat{gbtypeflagn}{%用于报纸newspaper +\iftoggle{bbx:url}{\iffieldundef{url}%当存在url时,增加一个OL标识符 +{\nobreak\printtext{[}\nobreak N\printtext{]}\nobreak}% +{\nobreak\printtext{[}\nobreak N\printtext{\texttt{/}OL]}\nobreak}% +}{\nobreak\printtext{[}\nobreak N\printtext{]}\nobreak}} + +\DeclareFieldFormat{gbtypeflags}{%用于标准standard +\iftoggle{bbx:url}{\iffieldundef{url}%当存在url时,增加一个OL标识符 +{\nobreak\printtext{[}\nobreak S\printtext{]}\nobreak}% +{\nobreak\printtext{[}\nobreak S\printtext{\texttt{/}OL]}\nobreak}% +}{\nobreak\printtext{[}\nobreak S\printtext{]}\nobreak}} + +%重设title的输出格式,不加emph,原格式来自biblatex.def文件 +\DeclareFieldFormat{title}{#1\adddot\addthinspace}% +\DeclareFieldFormat{journaltitle}{#1\isdot} +\DeclareFieldFormat{issuetitle}{#1} +\DeclareFieldFormat{maintitle}{#1} +\DeclareFieldFormat{booktitle}{#1} +\DeclareFieldFormat%将期刊等文献的标题中原来带的引号去掉 + [article,patent,thesis,unpublished] + {title}{#1\adddot\addthinspace}%\mkbibquote{#1\isdot} +\DeclareFieldFormat%将期刊等文献的标题中原来带的引号去掉 + [inbook,incollection,inproceedings] + {title}{#1\nopunct\unspace}% +\DeclareFieldFormat{url}{\url{#1}} %%url相关输出,url域修改如本行,源来自biblatex.def +\DeclareFieldFormat{titlecase}{\MakeCapital#1}%重设标题格式,将其修改为首字母大写 +\DeclareFieldFormat{pages}{#1}%去掉前面引导页码的pp.等字符,\mkpageprefix[bookpagination]{#1} + +%修改译者位置格式,bytranslator+others原格式来自biblatex.def文件 +\renewbibmacro*{bytranslator+others}{% + \ifnameundef{translator} + {} + {%\usebibmacro{bytranslator+othersstrg} + %\setunit{\addspace}% + \printnames[bytranslator]{translator}% + \clearname{translator}% + \usebibmacro{bytranslator+othersstrg}%“译”的位置换到下面来,即放到译者后面。 + \setunit*{\addspace}% + \newunit}% + \usebibmacro{withothers}} + +%下面一段没有作用,但从中可以看到当地化字符串格式的引用前的代码处理 +%比如生成cotranslator等用于调用cotranslator所代表的当地化字符串 +%\renewbibmacro*{bytranslator+othersstrg}{% + +%判断作者或译者是否中文,若中文用字符等,否则用etcl。 +\renewbibmacro*{name:andothers}{% + \ifboolexpr{% + test {\ifnumequal{\value{listcount}}{\value{liststop}}} + and + test \ifmorenames + }% + {%这里做一个判断是在处理author还是translator用于两者是不同语言的情况 + \ifcurrentname{translator}{\testCJKfirst{\thefield{usere}}}{\testCJKfirst{\thefield{userf}}}% + %这句判断如果放到\andothersdelim后面会在等或etc.前增加一个空格,所以放前面 + \ifnumgreater{\value{liststop}}{1}% + {\finalandcomma}% + {\finalandcomma}%biblatex作者要区别单作者加等的情况,这里为符合gbt7714-2015第7.2节的要求加上了逗号。 +\andothersdelim\iftoggle{ifCJKforgbt}{\bibstring{andotherscn}}{\bibstring{andothers}}% +%\andothersdelim\bibstring{andotherscn} +}% +{}} + +%重设title的输出,将文献类型标识符输出出去,原输出来自biblatex.def文件 +\renewbibmacro*{title}{% + \ifboolexpr{% + test{\iffieldundef{title}}% + and% + test{\iffieldundef{subtitle}}% + }% + {}% + {\printtext[title]{% + \printfield[titlecase]{title}% + \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题 + {}{\setunit{\subtitlepunct}% + \printfield[titlecase]{subtitle}}% + \iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格 + {\setunit{\subtitlepunct}\printfield{titleaddon}}% + \iffieldundef{note}{\printfield[gbtypeflag]{usera}}%在标题后直接给出文献标识字母,判断一下,是否是报纸和标准 + {\iffieldequalstr{note}{standard}{\printfield[gbtypeflags]{usera}}%判断是否为标准 + {\iffieldequalstr{note}{news}{\printfield[gbtypeflagn]{usera}}%判断是否为报纸 + {\printfield[gbtypeflag]{usera}}}%其它 + }% + %\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点 + %\newunit + }% +}% +} + +\defversion{3.0}{name}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + \renewbibmacro*{name:last-first}[4]{% + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifblank{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + %\mkbibnamelast{#1}\isdot + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{\MakeUppercase{##1}}}\isdot%\MakeUppercase %\mkbibnamelast{\MakeUppercase{#1}} %\MakeSentenceCase + %注意上一句\MakeCapital后面如果再跟一个{}包含#1,则没有效果,可能是包在里面少了一层展开 + %因为机构名通常包括在{}内,所以要多展开一次才行,所以这里去掉#1外面的{} + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{\MakeUppercase{##2}}\isdot}% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + %\mkbibnamelast{#1}\isdot %3.9.1 Generic Commands and Hooks,对姓重新处理,如下句: %\mkbibnamelast{\MakeUppercase{#1}} + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{\MakeUppercase{##1}}}\isdot %大写,参考4.6.4 Miscellaneous Commands,\MakeUppercase %\MakeSentenceCase + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2##3}{}{\revsdnamepunct}% + \ifblank{##2}{}{\bibnamedelimd\mkbibnamefirst{\MakeUppercase{##2}}\isdot}% + \ifblank{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot}% + \addcomma\addspace% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}% + } + } + \renewbibmacro*{name:first-last}[4]{% + \usebibmacro{name:last-first}{##1}{##2}{##3}{##4}} +} + +\defversion{3.4}{name}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + %biblatex3.3版后(比如texlive2016中的3.4版)的使用方式 + \renewbibmacro*{name:given-family}[4]{%用family-given修改后的内容定义given-family + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifdefvoid{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifprefchar{}{\bibnamedelimc}}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{\MakeUppercase{##1}}}\isdot% + \ifdefvoid{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamegiven{\MakeUppercase{##2}}\isdot}%\MakeCapital + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{\MakeUppercase{##1}}}\isdot% + % + \ifboolexpe{% + test {\ifdefvoid{##2}} + and + test {\ifdefvoid{##3}}} + {} + {\revsdnamepunct}% + \ifdefvoid{##2}{}{\bibnamedelimd\mkbibnamegiven{\MakeUppercase{##2}}\isdot}%\MakeCapital + \ifdefvoid{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot} + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + } + \renewbibmacro*{name:family-given}[4]{% + \usebibmacro{name:given-family}{##1}{##2}{##3}{##4}} +} + +\defversion{3.0}{nameb}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + \renewbibmacro*{name:last-first}[4]{% + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifblank{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + %\mkbibnamelast{#1}\isdot + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{{##1}}}\isdot%\MakeUppercase %\mkbibnamelast{\MakeUppercase{#1}} %\MakeSentenceCase + %注意上一句\MakeCapital后面如果再跟一个{}包含#1,则没有效果,可能是包在里面少了一层展开 + %因为机构名通常包括在{}内,所以要多展开一次才行,所以这里去掉#1外面的{} + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{{##2}}\isdot}% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + %\mkbibnamelast{#1}\isdot %3.9.1 Generic Commands and Hooks,对姓重新处理,如下句: %\mkbibnamelast{\MakeUppercase{#1}} + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{{##1}}}\isdot %大写,参考4.6.4 Miscellaneous Commands,\MakeUppercase %\MakeSentenceCase + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2##3}{}{\revsdnamepunct}% + \ifblank{##2}{}{\bibnamedelimd\mkbibnamefirst{{##2}}\isdot}% + \ifblank{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot}% + \addcomma\addspace% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}% + } + } + \renewbibmacro*{name:first-last}[4]{% + \usebibmacro{name:last-first}{##1}{##2}{##3}{##4}} +} + +\defversion{3.4}{nameb}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + %biblatex3.3版后(比如texlive2016中的3.4版)的使用方式 + \renewbibmacro*{name:given-family}[4]{%用family-given修改后的内容定义given-family + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifdefvoid{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifprefchar{}{\bibnamedelimc}}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{{##1}}}\isdot% + \ifdefvoid{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamegiven{{##2}}\isdot}%\MakeCapital + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{{##1}}}\isdot% + % + \ifboolexpe{% + test {\ifdefvoid{##2}} + and + test {\ifdefvoid{##3}}} + {} + {\revsdnamepunct}% + \ifdefvoid{##2}{}{\bibnamedelimd\mkbibnamegiven{{##2}}\isdot}%\MakeCapital + \ifdefvoid{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot} + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + } + \renewbibmacro*{name:family-given}[4]{% + \usebibmacro{name:given-family}{##1}{##2}{##3}{##4}} +} + +\defversion{3.0}{namec}{ + \renewrobustcmd*{\bibinitperiod}{\adddot} + \renewcommand*{\revsdnamepunct}{\addcomma} + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + \renewbibmacro*{name:last-first}[4]{% + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifblank{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + \mkbibnamelast{##1}\isdot + \ifblank{##4}{}{\bibnamedelimd\mkbibnameaffix{##4}\isdot}%这句放到后面 + \ifblank{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{{##2}}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + \mkbibnamelast{##1}\isdot %3.9.1 Generic Commands and Hooks,对姓重新处理,如下句: %\mkbibnamelast{\MakeUppercase{#1}} + \ifblank{##4}{}{\bibnamedelimd\mkbibnameaffix{##4}\isdot}%这句放到后面 + \ifblank{##2##3}{}{\revsdnamepunct}% + \ifblank{##2}{}{\bibnamedelimd\mkbibnamefirst{{##2}}\isdot}% + \ifblank{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot}% + } + } + \renewbibmacro*{name:first-last}[4]{% + \usebibmacro{name:last-first}{##1}{##2}{##3}{##4}} +} + +\defversion{3.4}{namec}{ + \renewrobustcmd*{\bibinitperiod}{\adddot} + \renewcommand*{\revsdnamepunct}{\addcomma} + \renewbibmacro*{name:given-family}[4]{% + \usebibmacro{name:delim}{##2##3##1}% + \usebibmacro{name:hook}{##2##3##1}% + \ifdefvoid{##2}{}{\mkbibnamegiven{##2}\isdot\bibnamedelimd}% + \ifdefvoid{##3}{}{% + \mkbibnameprefix{##3}\isdot + \ifprefchar + {} + {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}% + \mkbibnamefamily{##1}\isdot + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + \DeclareNameAlias{family-given}{default} + + \renewbibmacro*{name:family-given}[4]{% + \usebibmacro{name:given-family}{##1}{##2}{##3}{##4}} +} + +\defversion{3.0}{named}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \renewrobustcmd*{\bibnamedelima}{\mbox{-}} + + \DeclareNameFormat{first-last}{% + \usebibmacro{name:first-last}{##1}{##3}{##5}{##7}% + \usebibmacro{name:andothers}} + + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + \renewbibmacro*{name:last-first}[4]{% + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifblank{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + %\mkbibnamelast{#1}\isdot + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{\MakeUppercase{##1}}}\isdot%\MakeUppercase %\mkbibnamelast{\MakeUppercase{#1}} %\MakeSentenceCase + %注意上一句\MakeCapital后面如果再跟一个{}包含#1,则没有效果,可能是包在里面少了一层展开 + %因为机构名通常包括在{}内,所以要多展开一次才行,所以这里去掉#1外面的{} + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2}{}{\revsdnamepunct\bibnamedelimd\MakeSentenceCase{\mkbibnamefirst{##2}}\isdot}% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + %\mkbibnamelast{#1}\isdot %3.9.1 Generic Commands and Hooks,对姓重新处理,如下句: %\mkbibnamelast{\MakeUppercase{#1}} + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{\MakeUppercase{##1}}}\isdot %大写,参考4.6.4 Miscellaneous Commands,\MakeUppercase %\MakeSentenceCase + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2##3}{}{\revsdnamepunct}% + \ifblank{##2}{}{\bibnamedelimd\mkbibnamefirst{\MakeUppercase{##2}}\isdot}% + \ifblank{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot}% + \addcomma\addspace% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}% + } + } + \renewbibmacro*{name:first-last}[4]{% + \usebibmacro{name:last-first}{##1}{##2}{##3}{##4}} +} + +\defversion{3.4}{named}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \renewrobustcmd*{\bibnamedelima}{\mbox{-}} + + \DeclareNameFormat{given-family}{% + {\usebibmacro{name:given-family} + {\namepartfamily} + {\namepartgiven} + {\namepartprefix} + {\namepartsuffix}}% + \usebibmacro{name:andothers}} + + %biblatex3.3版后(比如texlive2016中的3.4版)的使用方式 + \renewbibmacro*{name:given-family}[4]{%用family-given修改后的内容定义given-family + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifdefvoid{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifprefchar{}{\bibnamedelimc}}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{\MakeUppercase{##1}}}\isdot% + \ifdefvoid{##2}{}{\revsdnamepunct\bibnamedelimd\MakeSentenceCase{\mkbibnamegiven{##2}}\isdot}%\MakeCapital + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{\MakeUppercase{##1}}}\isdot% + % + \ifboolexpe{% + test {\ifdefvoid{##2}} + and + test {\ifdefvoid{##3}}} + {} + {\revsdnamepunct}% + \ifdefvoid{##2}{}{\bibnamedelimd\mkbibnamegiven{\MakeCapital{##2}}\isdot}%\MakeCapital + \ifdefvoid{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot} + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + } + \renewbibmacro*{name:family-given}[4]{% + \usebibmacro{name:given-family}{##1}{##2}{##3}{##4}} +} + +%\def\execgbuppercase{ +\iftoggle{iftlfive}%根据texlive/biblatex版本选择 + {%%当采用biblatex<=3.3版本时 + \switchversion{3.0}{name} + }{%%当采用3.3<=biblatex版本时 + \switchversion{3.4}{name} + } +%} + +\def\execnamedefault{ +\iftoggle{iftlfive}%根据texlive/biblatex版本选择 + {%%当采用biblatex<=3.3版本时 + \switchversion{3.0}{namec} + }{%%当采用3.3<=biblatex版本时 + \switchversion{3.4}{namec} + } +} + +\def\execgblowercase{ +\iftoggle{iftlfive}%根据texlive/biblatex版本选择 + {%%当采用biblatex<=3.3版本时 + \switchversion{3.0}{nameb} + }{%%当采用3.3<=biblatex版本时 + \switchversion{3.4}{nameb} + } +} + +\def\execnamepinyin{ +\iftoggle{iftlfive}%根据texlive/biblatex版本选择 + {%%当采用biblatex<=3.3版本时 + \switchversion{3.0}{named} + }{%%当采用3.3<=biblatex版本时 + \switchversion{3.4}{named} + }} + + +\renewbibmacro*{url+urldate}{% + %\usebibmacro{url}%%更换url的位置,放到下面 + \iffieldundef{urlyear}% + {}{%\setunit*{\addspace}% + \usebibmacro{urldate}}% + \setunit{\addperiod\addspace}% + \usebibmacro{url}} +\renewbibmacro*{url}{\printfield{url}} + +\defversion{3.4}{date}{ + \renewbibmacro*{urldate}{% + \addthinspace\printtext{[}\printfield{urlyear}% + \iffieldundef{urlmonth}{}{\bibrangedash\printfield{urlmonth}}% + \iffieldundef{urlday}{}{\bibrangedash\printfield{urlday}}\printtext{]}} + + \newbibmacro*{newsdate}{%%新增加一个新闻日期 + \iffieldundef{year}{}{\printfield{year}% + \iffieldundef{month}{}{\bibrangedash\printtext{\thefield{month}}% + \iffieldundef{day}{}{\bibrangedash\printfield{day}}}}% + } + + \newbibmacro*{modifydate}{%新增加一个带括号的日期,用于表示电子资源的更新和修改日期,而公告日期则按日期格式 + \iffieldequalstr{year}{}{%替换\iffieldundef{year},因为year总是存在,但为空 + \iffieldundef{endyear}{% + \iffieldundef{eventyear}{}{\printtext{\mkbibparens{\printtext{\printfield{eventyear}}% + \iffieldundef{eventmonth}{}{\bibrangedash\thefield{eventmonth}}% + \iffieldundef{eventday}{}{\bibrangedash\printfield{eventday}}}}% + }% + }{% + \iffieldundef{endyear}{}{\printtext{\mkbibparens{\printtext{\printfield{endyear}}% + \iffieldundef{endmonth}{}{\bibrangedash\thefield{endmonth}}% + \iffieldundef{endday}{}{\bibrangedash\printfield{endday}}}}% + }% + }% + }% + {% + \iffieldundef{year}{}{\printtext{\mkbibparens{\printtext{\printfield{year}}% + \iffieldundef{month}{}{\bibrangedash\thefield{month}}% + \iffieldundef{day}{}{\bibrangedash\printfield{day}}}}% + }% + }% + }% +} + +\defversion{3.7}{date}{ + \DeclareFieldFormat{urldate}{##1} + \renewbibmacro*{urldate}{% + \addthinspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 + + \newbibmacro*{newsdate}{%%新增加一个新闻日期 + \blx@edtfdate{}{}% + } + + \newbibmacro*{modifydate}{%新增加一个带括号的日期,用于表示电子资源的更新和修改日期,而公告日期则按日期格式 + \iffieldundef{year}{% + \iffieldundef{endyear}{\iffieldundef{eventyear}{}{\printtext{(}\printeventdate\printtext{)}}}% + {\printtext{(}\printenddate\printtext{)}}% + }{\iffieldequalstr{year}{}{%因为year存在,但为空 + }{\printtext{(}\blx@edtfdate{}{}\printtext{)}}% + }% + }% +} + +\defversion{3.10}{date}{ + \DeclareFieldFormat{urldate}{##1} + \renewbibmacro*{urldate}{% + \addthinspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 + + \newbibmacro*{newsdate}{%%新增加一个新闻日期 + \blx@isodate{}{}% + } + + \newbibmacro*{modifydate}{%新增加一个带括号的日期,用于表示电子资源的更新和修改日期,而公告日期则按日期格式 + \iffieldundef{year}{% + \iffieldundef{endyear}{\iffieldundef{eventyear}{}{\printtext{(}\printeventdate\printtext{)}}}% + {\printtext{(}\printenddate\printtext{)}}% + }{\iffieldequalstr{year}{}{%因为year存在,但为空 + }{\printtext{(}\blx@isodate{}{}\printtext{)}}% + }% + }% +} + +\defversion{3.8}{dblang}{ + %为了实现v3.8以上版本的双语文献,采用related的方法代替set方法,因为set方法已经无法实现了, + %因为set不再复制其第一个成员的信息。于是定义一个命令,用于动态的修改数据,即添加related域的信息 + %其中使用了\DeclareStyleSourcemap,但由于其只能出现在导言区中,因此\defdoublelangentry命令也只能出现在导言区中 + \newcommand{\defdoublelangentry}[2]{% + \edef\entrykeya{##1} + \edef\entrykeyb{##2} + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + \map{ + \step[fieldsource=entrykey, match=\entrykeya, final] + \step[fieldset=related, fieldvalue=\entrykeyb] + } + } + } + } +} + +\iftoggle{iftlfive}{\switchversion{3.4}{date}}{}%biblatex<=3.2 +\iftoggle{iftlsix}{\switchversion{3.4}{date}}{}%3.3<=biblatex<=3.6 +\iftoggle{iftlseven}{\switchversion{3.7}{date}}{}%biblatex=3.7 +\iftoggle{iftleight}{\switchversion{3.7}{date}\switchversion{3.8}{dblang}}{}%3.8<=biblatex<=3.9 +\iftoggle{iftlatest}{\switchversion{3.10}{date}\switchversion{3.8}{dblang}}{}%biblatex最新3.10 + +\renewcommand{\relateddelim}{\adddot\newline\nobreak}%\par + +\renewbibmacro*{related}{% + \ifboolexpr{ test {\iffieldundef{related}} or test {\ifrelatedloop} } + {} + {\usebibmacro{begrelated}% + \def\bbx@tempa{}% + \setcounter{bbx:relatedtotal}{0}% + \def\do##1{% + \entrydata{##1}{% + \ifrelatedloop + {} + {\stepcounter{bbx:relatedtotal}% + \gappto{\bbx@tempa}{##1,}}}}% + \docsvfield{related}% + \restorefield{related}{\bbx@tempa}% + \ifnumgreater{\value{bbx:relatedtotal}}{0} + {\listcsxadd{bbx:relatedloop}{\strfield{entrykey}}% + \iffieldundef{clonesourcekey} + {} + {\listcsxadd{bbx:relatedloop}{\strfield{clonesourcekey}}}% + \setcounter{bbx:relatedcount}{0}% + \def\do{% + \stepcounter{bbx:relatedcount}% + \ifnumgreater{\value{bbx:relatedcount}}{0} + {\ifcsundef{relateddelim\strfield{relatedtype}} + {\printtext{\relateddelim}} + {\printtext{\csuse{relateddelim\strfield{relatedtype}}}}} + {}}% + \ifbibmacroundef{related:\strfield{relatedtype}} + {\appto{\do}{\usebibmacro{related:default}}} + {\appto{\do}{\usebibmacro*{related:\strfield{relatedtype}}}}% + \iffieldformatundef{related:\strfield{relatedtype}} + {\def\bbx@tempa{related}} + {\def\bbx@tempa{related:\strfield{relatedtype}}}% + \iffieldformatundef{relatedstring:\strfield{relatedtype}} + {\def\bbx@tempb{relatedstring:default}} + {\def\bbx@tempb{relatedstring:\strfield{relatedtype}}}% + \printtext[\bbx@tempa]{% + \usebibmacro{begrelatedloop}% + \iffieldundef{relatedstring} + {\ifboolexpr{ + test {\ifnumgreater{\value{bbx:relatedtotal}}{1}} + and + test {\ifbibxstring{\thefield{relatedtype}s}} + } + {\printtext[\bbx@tempb]{% + \bibstring[\mkrelatedstring]{\thefield{relatedtype}s}}} + {\iffieldbibstring{relatedtype} + {\printtext[\bbx@tempb]{% + \bibstring[\mkrelatedstring]{\thefield{relatedtype}}}} + {}}} + {\iffieldbibstring{relatedstring} + {\printtext[\bbx@tempb]{% + \bibstring[\mkrelatedstring]{\thefield{relatedstring}}}} + {\printfield[\bbx@tempb]{relatedstring}}}% + \docsvfield{related}% + \usebibmacro{endrelatedloop}}}% + {}% + \usebibmacro{endrelated}}} + +%调整doi+eprint+url格式,源来自standard.bbx +%因为页码后面直接跟引用日期,没有标点所以去掉其中的标点。 +\renewbibmacro*{doi+eprint+url}{% +% \iftoggle{bbx:doi}%把doi的位置放到url后面 +% {\printfield{doi}} +% {}% + %\newunit\newblock + \iftoggle{bbx:eprint} + {\usebibmacro{eprint}} + {}% + %\newunit\newblock + \iftoggle{bbx:url} + {\usebibmacro{url+urldate}} + {} + \newunit\newblock + \iftoggle{bbx:doi} + {\printfield{doi}} + {}} + +\renewbibmacro*{chapter+pages}{% + \printfield{chapter}% + \iffieldundef{pages}{}{%这里增加一个判断,当没有页码时就不输出 + \setunit{\bibpagespunct}% + \printfield{pages}}% + %\newunit %这里的标点去掉 +} + +%出版社和地址的处理 +%当没有出版社地址时,直接判断title的信息是否是中文,若为中文,则写出版地不详,否则用英文的字符表示。 +%事实上title对于每个文献来说是必须的,所以用它判断是最快的,而且一般标题和出版社的语言是一样的。 +%新增一个样式用于输出连续出版物的地址,单位,时间,%类似\newbibmacro*{publisher+location+date} +\newbibmacro*{location+institution+date}{% +\iftoggle{bbx:gbpub}% +{\testCJKfirst{\thefield{userd}} +\iflistundef{location}{\iftoggle{ifCJKforgbt}{\printtext{[出版地不详]}}{\printtext{[S.l.\adddot]}}}% + {\printlist{location}}% +% \iflistundef{institution} +% {\setunit*{\addcomma\space}} +% {\setunit*{\addcolon\space}}% +% \printlist{institution}% +% \setunit*{\addcomma\space}% +\addcolon\addspace% +\iflistundef{institution}{% +\iftoggle{ifCJKforgbt}{\printtext{[出版者不详]}}{\printtext{\mkbibbrackets{s.n.}}}}% \bibstring{nopublisher}%[s.n.\adddot] +{\printlist{institution}}% +\setunit{\addcomma\addspace}% + %\usebibmacro{date}% + \printfield{year}% + \bibrangedash% + \iffieldundef{endyear}{}{\printfield{endyear}}% + \newunit}% +{ \printlist{location}% + \iflistundef{institution}% + {\setunit*{\addcomma\space}} + {\setunit*{\addcolon\space}}% + \printlist{institution}% + \setunit*{\addcomma\space}% + \usebibmacro{date}% + \newunit}% +} + +\renewbibmacro*{publisher+location+date}{% +\iftoggle{bbx:gbpub}% +{\testCJKfirst{\thefield{userd}}% +\iflistundef{location}{%\adddot +\iffieldequalstr{note}{standard}{}{%从gbt7714-2015标准第19页看到,标准存在出版项时输出,没有时完全省略。 +\iftoggle{ifCJKforgbt}{\printtext{[出版地不详]}\addcolon\addspace}{\printtext{[S.l.\adddot]}\addcolon\addspace}% +}}% \bibstring{noaddress} +{\printlist{location}\addcolon\addspace}% +%\addcolon\addspace% +\iflistundef{publisher}{% +\iffieldequalstr{note}{standard}{}{% +\iftoggle{ifCJKforgbt}{\printtext{[出版者不详]}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}% +{\printtext{\mkbibbrackets{s.n.}}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}% +}}% +{\printlist{publisher}\setunit*{\addcomma\addspace}}% +%\addcomma\addspace% +\usebibmacro{date}% +%\newunit %去掉这个标点 +}% +{\printlist{location}% + \iflistundef{publisher} + {\setunit*{\addcomma\space}} + {\setunit*{\addcolon\space}}% + \printlist{publisher}% + \setunit*{\addcomma\space}% + \usebibmacro{date}% + %\newunit + }% +} + +%对edition版本信息做出修改,源来自biblatex.DEF +\DeclareFieldFormat{edition}{% +\testCJKfirst{\thefield{userd}}% +\iftoggle{ifCJKforgbt}% +{\ifinteger{#1}% +{\printtext{#1版}}% +{#1\isdot}}% +{\ifinteger{#1}% +{\mkbibordedition{#1}~\bibstring{edition}}% +{#1\isdot}}} + +%对version的版本信息做出修改,源来自biblatex.DEF +\DeclareFieldFormat{version}{% +\testCJKfirst{\thefield{userd}}% +\ifinteger{#1}% +{\iftoggle{ifCJKforgbt}{\printtext{#1版}}% +{\mkbibordedition{#1}~\bibstring{version}}}% +{#1\isdot}} + +%调整期刊名的格式,源来自standard.bbx +\renewbibmacro*{journal+issuetitle}{% + \usebibmacro{journal}% + %\setunit*{\addspace}% + \setunit*{\addcomma\addspace}%修改为增加一个逗号 + \iffieldundef{series} + {} + {\newunit + \printfield{series}% + \setunit{\addspace}}% + %\usebibmacro{volume+number+eid}% + %\setunit{\addspace}% + \usebibmacro{issue+date}% + %\setunit{\addcolon\space}% + \iffieldundef{volume}{}{\setunit{\addcomma\space}}% + %换成逗号和空格 + \usebibmacro{issue}% + \usebibmacro{volume+number+eid}%把卷期放到年份后面 + %\newunit + } + +%调整期刊年份的格式,去掉括号 +\renewbibmacro*{issue+date}{% + \printtext{%去掉了[parens] + \iffieldundef{issue} + {%\usebibmacro{date} + \iffieldundef{note}{\usebibmacro{date}}%判断一下,是否是报纸 + {\iffieldequalstr{note}{news}{\usebibmacro{newsdate}}%判断是否为报纸 + {\usebibmacro{date}}% + }}% + {\printfield{issue}% + \setunit*{\addspace}% + %\usebibmacro{date} + \iffieldundef{note}{\usebibmacro{date}}%判断一下,是否是报纸 + {\iffieldequalstr{note}{news}{\usebibmacro{newsdate}}%判断是否为报纸 + {\usebibmacro{date}}% + }}}% + %\newunit + } + +%调整期刊卷和期的格式,源来自standard.bbx +\renewbibmacro*{volume+number+eid}{% + \printfield{volume}% + %\setunit*{\adddot}%去掉点号 + %\printfield{number}% + \iffieldundef{number}{}{\printtext{\mkbibparens{\printfield{number}}}}%增加一个圆括号 + \iffieldundef{eid}{}{% + \setunit{\addcomma\space}% + \printfield{eid}}} + +%调整页码前的标点和去掉期刊文章等页码后面的标点,源来自standard.bbx +\renewbibmacro*{note+pages}{% + %\printfield{note}%不要note,note用来判断是否是报纸newspaper + \iffieldundef{pages}{}{ + \setunit{\bibpagespunct}% + \printfield{pages}}% + %\newunit + } + +%修改析出文献的文集的标题与附加标题间的符号 +\renewbibmacro*{booktitle}{% + \ifboolexpr{ + test {\iffieldundef{booktitle}} + and + test {\iffieldundef{booksubtitle}} + } + {} + {\printtext[booktitle]{% + \printfield[titlecase]{booktitle}% + \setunit{\subtitlepunct}% + \printfield[titlecase]{booksubtitle}}% + \newunit%标点换成下一句 + \setunit{\subtitlepunct}}% + \printfield{booktitleaddon}} + +%编者的符号修改一下,源来自biblatex.DEF +\renewbibmacro*{editor}{% + \ifboolexpr{ + test \ifuseeditor + and + not test {\ifnameundef{editor}} + } + {\printnames{editor}% + \iffieldundef{editortype}%增加一个类型判断,用于存在editortype的情况 + {\setunit\addspace}%当没有editortype时,直接用句点 + {\setunit{\addcomma\space}% + \usebibmacro{editorstrg}}% + \clearname{editor}} + {}} + +%编者类型做一修改,源来自biblatex.DEF +\renewbibmacro*{editorstrg}{% + \printtext[editortype]{% + \iffieldundef{editortype} + { +% \ifboolexpr{ %这一段去掉 +% test {\ifnumgreater{\value{editor}}{1}} +% or +% test {\ifandothers{editor}} +% } +% {\bibstring{editors}} +% {\bibstring{editor}} + } + {\ifbibxstring{\thefield{editortype}} + {\ifboolexpr{ + test {\ifnumgreater{\value{editor}}{1}} + or + test {\ifandothers{editor}} + } + {\bibstring{\thefield{editortype}s}} + {\bibstring{\thefield{editortype}}}} + {\thefield{editortype}}}}} + +%修改期刊的标题,源来自biblatex.DEF +\renewbibmacro*{periodical}{% + \iffieldundef{title} + {} + {\printtext[title]{% + \printfield[titlecase]{title}% + %\setunit{\subtitlepunct}% + \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题 + {}{\setunit{\subtitlepunct} + \printfield[titlecase]{subtitle}}% + % + \iffieldundef{usera}{}{%在标题后直接给出文献标识字母 + \printfield[gbtypeflag]{usera}} + }%把编组结束移到这里 + }% + } + +%期刊的标题做修改,源来自standard.BBX +\renewbibmacro*{title+issuetitle}{% + \usebibmacro{periodical}% + %\setunit*{\addspace}% + \setunit*{\adddot\addspace}%标点修改为句点 + \iffieldundef{series} + {} + {\newunit + \printfield{series}% + \setunit{\addspace}}% + \usebibmacro{periodical+issue}%将issue调整到上面来,并修改 +\iffieldundef{number}{}{%%进一步处理有范围的数字 + \multinumberparser{\thefield{number}}}% + \iffieldundef{volume}% + {\printfield{year}% + \printtext{\mkbibparens{\multinumberfirst}}% + \bibrangedash% + \iffieldundef{endyear}{}{\printfield{endyear}\printtext{\mkbibparens{\multinumbersecond}}}% + }% + {\multivolparser{\thefield{volume}}% + \printfield{year}% + \setunit{\addcomma\space}%将冒号修改为逗号 + \printtext{\multivolfirst}% + \printtext{\mkbibparens{\multinumberfirst}}% + \bibrangedash% + \iffieldundef{endyear}{}{% + \printfield{endyear}% + \setunit{\addcomma\space}%将冒号修改为逗号 + \printtext{\multivolsecond}% + \printtext{\mkbibparens{\multinumbersecond}}}% + }% + \setunit{\addcomma\space}% + \printfield{eid}% + \setunit{\addspace}% + %\usebibmacro{issue+date}% + %\setunit{\addcolon\space}% + \usebibmacro{issue}% + \newunit} + +%新增一个样式用于调整期刊年份的格式,只打印年份 +\newbibmacro*{periodical+issue}{% + \printtext{%去掉了[parens] + \iffieldundef{issue} + {%\usebibmacro{date}%修改为下一句 + }% + {\printfield{issue}% + \setunit*{\addspace}% + %\usebibmacro{date}%修改为下一句 + }% + }% + %\newunit +} + +%重设专利title的输出,将文献类型标识符输出出去,原输出来自biblatex.def文件 +\newbibmacro*{patenttitle}{% + \ifboolexpr{% + test{\iffieldundef{title}}% + and% + test{\iffieldundef{subtitle}}% + }% + {}% + {\printtext[title]{% + \printfield[titlecase]{title}% + \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题 + {}{\setunit{\subtitlepunct}% + \printfield[titlecase]{subtitle}}% + \iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格 + {\setunit{\subtitlepunct}\printfield{titleaddon}}% + \setunit{\subtitlepunct}\printfield{number}%写专利号 + \printfield[gbtypeflag]{usera}% + %\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点 + %\newunit + }% +}% +} + +%修改了一个institution+location+date用于report等的,当没有institution时不处理。 +\renewbibmacro*{institution+location+date}{% + \printlist{location}% + \iflistundef{institution} + {\setunit*{\addcomma\space}} + {\setunit*{\addcolon\space}}% + \printlist{institution}% + \setunit*{\addcomma\space}% + \usebibmacro{date}% + %\usebibmacro{modifydate}% + %\newunit + } + + +%===================================================================== +%===================================================================== +%设置驱动格式 +%===================================================================== +%book条目类的驱动,源来自standard.bbx文件 + \DeclareBibliographyDriver{book}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% +\usebibmacro{author/editor+others/translator+others}% +\ifnameundef{author}{%这一段用于去除作者不存在时多出的标点 +\ifnameundef{editor}{% +\ifnameundef{translator}{\relax}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}%这个注释去除标题前空格 +\usebibmacro{maintitle+title}% +\newunit +\printlist{language}% +\newunit\newblock% +\usebibmacro{byauthor}% +\newunit\newblock% +\usebibmacro{byeditor+others}% +\newunit\newblock% +\printfield{edition}% +\newunit% +\iffieldundef{maintitle}% +{\printfield{volume}% +\printfield{part}}% +{}% +\newunit% +\printfield{volumes}% +\newunit\newblock% +\usebibmacro{series+number}% +\newunit\newblock% +%\printfield{note}% +%\newunit\newblock% +\usebibmacro{publisher+location+date}% +%\newunit\newblock %这里标点去掉 +\usebibmacro{chapter+pages}% +\usebibmacro{doi+eprint+url}%从下面移动到上面来,因为gbt2015的url需直接放在页码后面。 + \newunit\newblock% + %\newunit + \printfield{pagetotal}% + \newunit\newblock% + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock + %\usebibmacro{doi+eprint+url}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%期刊文章,连续出版物中的析出文献的格式 + \DeclareBibliographyDriver{article}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{bytranslator+others}% + \newunit\newblock + \printfield{version}% + \newunit\newblock + %\usebibmacro{in:}% 不使用in来表示期刊等连续出版物 + \usebibmacro{journal+issuetitle}% + %\newunit +% \usebibmacro{byeditor+others}% +% \newunit + \usebibmacro{note+pages}% + \usebibmacro{doi+eprint+url}%从后面移上来,调整url和页码之间的位置 + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{issn}} + {}% + \newunit\newblock + %\usebibmacro{author/translator+others}% + %\usebibmacro{doi+eprint+url}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%专著中的析出文献的格式修改,源来自standard.bbx +\DeclareBibliographyDriver{inbook}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% +\ifnameundef{author}{%这一段用于去除作者不存在时多出的标点 +\ifnameundef{editor}{% +\ifnameundef{translator}{\relax}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}% +%\setunit{\labelnamepunct}\newblock +\usebibmacro{title}% +%\nopunct +\printtext{\texttt{//}\addthinspace}%%\texttt{//}\addnbthinspace +\usebibmacro{bybookauthor}% +\ifnameundef{bookauthor}{\newblock}{\newunit\newblock}%替换下一句 +%\newunit\newblock +\usebibmacro{maintitle+booktitle}%}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{edition}% + \newunit + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + %\printfield{note}% + %\newunit\newblock + \usebibmacro{publisher+location+date}% +%\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}%移到上面来 + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock + %\usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%修改连续出版物的驱动,源来自standard.BBX + \DeclareBibliographyDriver{periodical}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{editor}% + %\setunit{\labelnamepunct}\newblock + \newunit\newblock %删除上面一行,添加这一行 + \usebibmacro{title+issuetitle}% + \newunit + \usebibmacro{location+institution+date}%添加这一行用于输出地址,单位和时间 + \newunit\newblock%添加这一行 + \printlist{language}% + \newunit\newblock + \usebibmacro{byeditor}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{issn}} + {}% + \newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%处理专利文献,源来自standard.BBX + \DeclareBibliographyDriver{patent}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + %\usebibmacro{title}% + \usebibmacro{patenttitle}%给出专利专用的标题输出 + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + %\printfield{number}% + \iflistundef{location} + {} + {\setunit*{\addspace}% + \printtext[parens]{% + \printlist[][-\value{listtotal}]{location}}}% + \newunit\newblock + \usebibmacro{byholder}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \usebibmacro{newsdate}% + %\newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%处理在线文献,源来自standard.BBX +\DeclareBibliographyDriver{online}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/editor+others/translator+others}% + \ifnameundef{author}{%这一段用于去除作者不存在时多出的标点 +\ifnameundef{editor}{% +\ifnameundef{translator}{\relax}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}% + %\setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \printlist{organization}% + \newunit\newblock + %\usebibmacro{date}% + \usebibmacro{modifydate}%修改为带括号的时间 + \usebibmacro{url+urldate}%从下面移上来 + \newunit\newblock + \iftoggle{bbx:eprint} + {\usebibmacro{eprint}} + {}% + \newunit\newblock + %\usebibmacro{url+urldate}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%学位论文修改,源来自standard.BBX + \DeclareBibliographyDriver{thesis}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \printfield{type}% + \newunit + \usebibmacro{institution+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%2016-11-11增加了译者信息 +\DeclareBibliographyDriver{report}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}%增加的译者信息 + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + \printfield{number}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \usebibmacro{institution+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isrn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%直接利用report做manual,2016-11-11增加了译者信息 +%\DeclareBibliographyDriver{report}{% +\DeclareBibliographyDriver{manual}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}%增加的译者信息 + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + \printfield{number}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \usebibmacro{institution+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isrn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%直接利用report做unpublished +\DeclareBibliographyDriver{unpublished}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + \printfield{number}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \usebibmacro{institution+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isrn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%直接利用book做collection + \DeclareBibliographyDriver{collection}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% +\usebibmacro{author/editor+others/translator+others} +\ifnameundef{author}{%这一段用于去除作者不存在时多出的标点 +\ifnameundef{editor}{% +\ifnameundef{translator}{\relax}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}% + \usebibmacro{maintitle+title} + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{edition}% + \newunit + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + %\printfield{note}% + %\newunit\newblock + \usebibmacro{publisher+location+date}% + %\newunit\newblock %这里标点去掉 + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}%从下面移动到上面来,因为gbt2015的url需直接放在页码后面。 + \newunit\newblock + %\newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock + %\usebibmacro{doi+eprint+url}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%直接利用inbook做incollection +\DeclareBibliographyDriver{incollection}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% +\ifnameundef{author}{%这一段用于去除作者不存在时多出的标点 +\ifnameundef{editor}{% +\ifnameundef{translator}{\relax}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}}% +{\setunit{\labelnamepunct}\newblock}% +%\setunit{\labelnamepunct}\newblock +\usebibmacro{title}% +\printtext{\texttt{//}\addthinspace}%似乎顶格加百分号可以避免一些不必要的空格加入,特别是这种直接处理的语句前后 +\usebibmacro{bybookauthor}% +\ifnameundef{bookauthor}{\newblock}{\newunit\newblock}%替换下一句 + %\newunit\newblock + \usebibmacro{maintitle+booktitle}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{edition}% + \newunit + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + %\printfield{note}% + %\newunit\newblock + \usebibmacro{publisher+location+date}% + \newunit\newblock + \usebibmacro{chapter+pages}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%会议论文格式修改,源来自standard.BBX + \DeclareBibliographyDriver{inproceedings}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% +% \newunit +% \printlist{language}% +% \newunit\newblock +% \usebibmacro{byauthor}% +% \newunit\newblock + %\usebibmacro{in:}% + \printtext{\texttt{//}\addthinspace}%似乎顶格加百分号可以避免一些不必要的空格加入,特别是这种直接处理的语句前后 + \usebibmacro{bybookauthor}%用类似inbook的方式处理 + \ifnameundef{bookauthor}{\newblock}{\newunit\newblock}%替换下一句 + %\newunit\newblock + \usebibmacro{maintitle+booktitle}% + \newunit\newblock + \usebibmacro{event+venue+date}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \printlist{organization}% + \newunit + \usebibmacro{publisher+location+date}% + \newunit\newblock + \usebibmacro{chapter+pages}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%会议论文集格式修改,源来自standard.BBX +\DeclareBibliographyDriver{proceedings}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + %\usebibmacro{editor+others}% + \usebibmacro{author/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{maintitle+title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{event+venue+date}% + \newunit\newblock +% \usebibmacro{byeditor+others}% +% \newunit\newblock + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \printlist{organization}% + \newunit + \usebibmacro{publisher+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}%从下面移上来 + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} diff --git a/Biblio/gb7714-2015.cbx b/Biblio/gb7714-2015.cbx new file mode 100755 index 0000000..a9dc2d6 --- /dev/null +++ b/Biblio/gb7714-2015.cbx @@ -0,0 +1,83 @@ +%% +%% --------------------------------------------------------------- +%% biblatex-gb7714-2015 --- A biblatex implementation of the +%% GBT7714-2015 citation style,numerical sequence +%% Maintained by huzhenzhen +%% history: +%% 2016/05/20 v1.0 2016/10/23 v1.0a 2016/11/11 v1.0b +%% 2016/11/14 v1.0c 2016/11/24 v1.0d 2016/12/07 v1.0e +%% 2017/02/26 v1.0g 2017/04/11 v1.0h +%% 2017/11/21 v1.0i 2018/01/20 v1.0j +%% E-mail: hzzmail@163.com +%% Released under the LaTeX Project Public License v1.3c or later +%% --------------------------------------------------------------- +%% +\ProvidesFile{gb7714-2015.cbx}[2018/01/20 v1.0j biblatex citation style] + +\RequireCitationStyle{numeric-comp} +%\RequireCitationStyle{numeric} + +\ExecuteBibliographyOptions{ + autocite = superscript , + autopunct = true , + sorting = none , +} + +%\DeclareCiteCommand{\cite}[\mkbibparens]{⟨precode⟩}{⟨loopcode⟩}{⟨sepcode⟩}{⟨postcode⟩} +% +\DeclareCiteCommand{\cite}[\mkbibsuperscript] + {[\usebibmacro{cite:init}%直接添加方括号 + \usebibmacro{prenote}} + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {\usebibmacro{cite:dump}% + \usebibmacro{postnote}]} + +%\DeclareCiteCommand{\parencite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标 +% {[\usebibmacro{cite:init}% +% \usebibmacro{prenote}} +% {\usebibmacro{citeindex}% +% \usebibmacro{cite:comp}} +% {} +% {\usebibmacro{cite:dump}% +% \usebibmacro{postnote}]} + +\newbibmacro*{postpages}{% + \iffieldundef{postnote} + {\printfield{pages}} + {\printfield{postnote}}} + +%修改括号外带页码的引用格式 +\DeclareFieldFormat{postnote}{#1} + +\DeclareCiteCommand{\pagescite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标 + {[\usebibmacro{cite:init}% + \usebibmacro{prenote}% + } + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {\usebibmacro{cite:dump}]% + \usebibmacro{postpages}} + +%增加一个命令yearpagescite为与ay样式兼容,命令等同于\pagescite +\DeclareCiteCommand{\yearpagescite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标 + {[\usebibmacro{cite:init}% + \usebibmacro{prenote}% + } + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {\usebibmacro{cite:dump}]% + \usebibmacro{postpages}} + +%不要页码 +\DeclareCiteCommand{\yearcite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标 + {[\usebibmacro{cite:init}% + \usebibmacro{prenote}% + } + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {\usebibmacro{cite:dump}]} diff --git a/Biblio/gb7714-2015ay.bbx b/Biblio/gb7714-2015ay.bbx new file mode 100755 index 0000000..0f8f8b3 --- /dev/null +++ b/Biblio/gb7714-2015ay.bbx @@ -0,0 +1,2303 @@ +%% +%% --------------------------------------------------------------- +%% biblatex-gb7714-2015 --- A biblatex implementation of the +%% GBT7714-2015 bibliography style,author year sequence +%% Maintained by huzhenzhen +%% history: +%% 2016/05/20 v1.0 2016/10/23 v1.0a 2016/11/11 v1.0b +%% 2016/11/14 v1.0c 2016/11/24 v1.0d 2016/12/07 v1.0e +%% 2017/02/26 v1.0g 2017/04/11 v1.0h +%% 2017/11/21 v1.0i 2018/01/20 v1.0j +%% E-mail: hzzmail@163.com +%% Released under the LaTeX Project Public License v1.3c or later +%% --------------------------------------------------------------- +%% +\ProvidesFile{gb7714-2015ay.bbx}[2018/01/20 v1.0j biblatex bibliography style] + +%===================================================================== +%===================================================================== +%加载标准样式 +%===================================================================== +\RequireBibliographyStyle{authoryear} % Load the standard style to avoid copy-pasting unnecessary material +\RequireBibliographyStyle{standard} +\RequirePackage{xstring}%为兼容texlive2015的biblatex3.0不加载xstring包的问题 + + +%===================================================================== +%===================================================================== +%新增功能函数 +%===================================================================== + \providetoggle{iftlfive}%用于处理biblatex3.2之前的版本 + \providetoggle{iftlsix}%用于处理biblatex3.3开始改变的新的姓名机制后版本 + \providetoggle{iftlseven}%用于处理biblatex3.7的兼容性 + \providetoggle{iftleight}%用于处理biblatex3.8到3.9的兼容性 + \providetoggle{iftlatest}%用于最新版biblatex,目前是biblatex3.10,20180117 + \StrBefore{\abx@version}{.}[\numinteger] + \StrBehind{\abx@version}{.}[\numdigital] + \IfInteger{\numdigital}{}{\StrGobbleRight{\numdigital}{1}[\numdigital]} + \togglefalse{iftlfive} + \togglefalse{iftlsix} + \togglefalse{iftlseven} + \togglefalse{iftleight} + \toggletrue{iftlatest} + \ifnumcomp{\numinteger}{=}{3}{ + \ifnumcomp{\numdigital}{<}{10}{\ifnumcomp{\numdigital}{>}{7}{\toggletrue{iftleight}\togglefalse{iftlatest}}{}}{}%>3.8版本用iftleight=true表示 + \ifnumcomp{\numdigital}{=}{7}{\toggletrue{iftlseven}\togglefalse{iftlatest}}{}%3.7版本用iftlseven=true表示 + \ifnumcomp{\numdigital}{<}{7}{\ifnumcomp{\numdigital}{>}{2}{\toggletrue{iftlsix}\togglefalse{iftlatest}}{}}{}%3.3-3.6版本用iftlsix=true表示 + \ifnumcomp{\numdigital}{<}{3}{\toggletrue{iftlfive}\togglefalse{iftlatest}}{}%3.0-3.2版本用iftlfive=true表示 + }{\ifnumcomp{\numinteger}{>}{3}{ + \blx@warning@noline{% + biblatex version is >= 4.x.\MessageBreak + if errors raised,Please contact biblatex-gb7714-2015 pkg author.}% + }{ \toggletrue{iftlfive}\togglefalse{iftlatest}%2.x版本统一用iftlfive=true表示 + \blx@warning@noline{% + biblatex version is <= 2.x.\MessageBreak + if errors raised,Please contact biblatex-gb7714-2015 pkg author.}% + }} + \newcommand\defversion[2]{\csdef{codeversion#1#2}}%定义不同版本的命令 + \newcommand\switchversion[2]{\csuse{codeversion#1#2}}%使用不同版本的命令 + +%定义判断中文字符的函数,用于判断作者等信息是否由中文字符构成 +%2E00-2E7F 追加标点 +%2E80-2EFF cjk部首补充 +%2FF0-2FFF 表意文字描述符 +%3000-303F cjk符号和标点 +%3300-33FF cjk兼容 +%3400-4DBF cjk统一表意符号扩展 +%4E00-9FBF cjk统一表意符号 +%中文范围4E00-9FA5 +\providetoggle{ifCJKforgbt} +\def\testCJKfirstchar#1#2&{%#1#2& +\ifnumgreater{`#1}{"2E7F}{\toggletrue{ifCJKforgbt}}{\togglefalse{ifCJKforgbt}}% +}% + +%利用edef展开或xstring抽取第一个字符判断 +%现在采用xstring方法,避免抽取的是编组符号 +\def\testCJKfirst#1{% +%\edef\tempa{#1}% +%\expandarg% +\exploregroups% +\StrChar{#1}{1}[\tempa]% +\expandafter\testCJKfirstchar\tempa&} + +%用于解析连续出版物,2个卷期的情况 +%范围起止间隔符号还是用-,而不是与date相同的/,因为有合期期刊的问题,需要用到/符号 +\newcommand{\multivolparser}[1]{% + \IfSubStr{#1}{-}% + {\StrBefore{#1}{-}[\multivolfirst]\StrBehind{#1}{-}[\multivolsecond]}% + {\def\multivolfirst{#1}\def\multivolsecond{}}% +} +\newcommand{\multinumberparser}[1]{% + \IfSubStr{#1}{-}% + {\StrBefore{#1}{-}[\multinumberfirst]\StrBehind{#1}{-}[\multinumbersecond]}% + {\def\multinumberfirst{#1}\def\multinumbersecond{}}% +} + +%===================================================================== +%===================================================================== +%设置宏包选项 +%===================================================================== +\defversion{3.0}{opt}{ + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + + %增加姓名大小写格式处理选项 + \DeclareBibliographyOption{gbnamefmt}[uppercase]{% + %\ifstrequal{##1}{gbuppercase}{}{}% + \ifstrequal{##1}{lowercase}{\execgblowercase}{}% + \ifstrequal{##1}{none}{\execnamedefault}{} + \ifstrequal{##1}{pinyin}{\execnamepinyin}{} + } + %\ExecuteBibliographyOptions{gbnamefmt} + + %增加标签对齐选项,right是默认的右对齐,left是左对齐,gb7714-2015是项对齐方式 + %因为在作者年制中,不需要使用,这里也增加,为了与顺序年制的兼容性考虑。 + \DeclareBibliographyOption{gbalign}[right]{}% + + %增加一个出版项自动处理控制选项,当true时使用出版者不详等信息补充缺失的出版信息。 + \newtoggle{bbx:gbpub} + \DeclareBibliographyOption{gbpub}[true]{% + %\settoggle{bbx:gbpub}{#1} %或采用下面这一句 + \ifstrequal{##1}{false}{\togglefalse{bbx:gbpub}}{\toggletrue{bbx:gbpub}}} + \ExecuteBibliographyOptions{gbpub} + + %增加一个处理佚名或noauthor的控制选项 + \DeclareBibliographyOption{gbnoauthor}[true]{% + \ifstrequal{##1}{false}{}{\dealnoathor}} + %\ExecuteBibliographyOptions{gbnoauthor=true}%对于需要展开较早(展开层级优先)的选项,这一执行无效,只能用宏包加载时给出的选项。 + + \ExecuteBibliographyOptions{ + useprefix = true, %名字的信息包括前缀 + firstinits = true, %名字有缩写,参考3.1.2.3 Internal + date = year, %日期仅写到年 + %maxnames = 3 , %设置名字最大数量 + %minnames = 3, %设置缩减后的名字最小数量 + maxbibnames=3, %将文献列表和引用中最大名字数量区分开 + minbibnames=3, + %uniquename=init, + } +} + +\defversion{3.4}{opt}{ + %Alter settings that carry through from biblatex + %biblatex3.3版后(比如texlive2016中的3.4版)的使用方式 + + %增加姓名大小写格式处理选项 + \DeclareBibliographyOption[string]{gbnamefmt}[uppercase]{% + %\ifstrequal{##1}{gbuppercase}{}{}% + \ifstrequal{##1}{lowercase}{\execgblowercase}{}% + \ifstrequal{##1}{none}{\execnamedefault}{} + \ifstrequal{##1}{pinyin}{\execnamepinyin}{} + } + %\ExecuteBibliographyOptions{gbnamefmt} + + %增加标签对齐选项,right是默认的右对齐,left是左对齐,gb7714-2015是项对齐方式 + %因为在作者年制中,不需要使用,这里也增加,为了与顺序编码制的兼容性考虑。 + \DeclareBibliographyOption[string]{gbalign}[right]{}% + + %增加一个出版项自动处理控制选项,当true时使用出版者不详等信息补充缺失的出版信息。 + \newtoggle{bbx:gbpub} + \DeclareBibliographyOption[boolean]{gbpub}[true]{% + %\settoggle{bbx:gbpub}{#1} %或采用下面这一句 + \ifstrequal{##1}{false}{\togglefalse{bbx:gbpub}}{\toggletrue{bbx:gbpub}}} + \ExecuteBibliographyOptions{gbpub} + + %增加一个处理佚名或noauthor的控制选项 + \DeclareBibliographyOption[boolean]{gbnoauthor}[true]{% + \ifstrequal{##1}{false}{}{\dealnoathor}} + %\ExecuteBibliographyOptions{gbnoauthor=true}%对于需要展开较早(展开层级优先)的选项,这一执行无效,只能利用宏包加载时给出选项达到目的。 + + \ExecuteBibliographyOptions{ + useprefix = true, %名字的信息包括前缀 + %firstinits = true, %名字有缩写,参考3.1.2.3 Internal + giveninits = true, + date = year, %日期仅写到年 + %maxnames = 3 , %设置名字最大数量 + %minnames = 3, %设置缩减后的名字最小数量 + maxbibnames=3, %将文献列表和引用中最大名字数量区分开 + minbibnames=3, + %datezeros=true, + } +} + +\defversion{3.7}{opt}{ + %Alter settings that carry through from biblatex + %biblatex3.7版后(比如texlive2017)的使用方式 + + %增加姓名大小写格式处理选项 + \DeclareBibliographyOption[string]{gbnamefmt}[uppercase]{% + %\ifstrequal{##1}{gbuppercase}{}{}% + \ifstrequal{##1}{lowercase}{\execgblowercase}{}% + \ifstrequal{##1}{none}{\execnamedefault}{} + \ifstrequal{##1}{pinyin}{\execnamepinyin}{} + } + %\ExecuteBibliographyOptions{gbnamefmt} + + %增加标签对齐选项,right是默认的右对齐,left是左对齐,gb7714-2015是项对齐方式 + %因为在作者年制中,不需要使用,这里也增加,为了与顺序编码制的兼容性考虑。 + \DeclareBibliographyOption[string]{gbalign}[right]{}% + + %增加一个出版项自动处理控制选项,当true时使用出版者不详等信息补充缺失的出版信息。 + \newtoggle{bbx:gbpub} + \DeclareBibliographyOption[boolean]{gbpub}[true]{% + %\settoggle{bbx:gbpub}{#1} %或采用下面这一句 + \ifstrequal{##1}{false}{\togglefalse{bbx:gbpub}}{\toggletrue{bbx:gbpub}}} + \ExecuteBibliographyOptions{gbpub} + + %增加一个处理佚名或noauthor的控制选项 + \DeclareBibliographyOption[boolean]{gbnoauthor}[true]{% + \ifstrequal{##1}{false}{}{\dealnoathor}} + %\ExecuteBibliographyOptions{gbnoauthor=true}%对于需要展开较早(展开层级优先)的选项,这一执行无效,只能利用宏包加载时给出选项达到目的。 + + \ExecuteBibliographyOptions{ + useprefix = true, %名字的信息包括前缀 + %firstinits = true, %名字有缩写,参考3.1.2.3 Internal + giveninits = true, + date = year, %日期仅写到年 + urldate =edtf, + eventdate =edtf, + %maxnames = 3 , %设置名字最大数量 + %minnames = 3, %设置缩减后的名字最小数量 + maxbibnames=3, %将文献列表和引用中最大名字数量区分开 + minbibnames=3, + %datezeros=true, + } +} + +\defversion{3.10}{opt}{ + %Alter settings that carry through from biblatex + %biblatex3.10版后的使用方式 + + %增加姓名大小写格式处理选项 + \DeclareBibliographyOption[string]{gbnamefmt}[uppercase]{% + %\ifstrequal{##1}{gbuppercase}{}{}% + \ifstrequal{##1}{lowercase}{\execgblowercase}{}% + \ifstrequal{##1}{none}{\execnamedefault}{} + \ifstrequal{##1}{pinyin}{\execnamepinyin}{} + } + %\ExecuteBibliographyOptions{gbnamefmt} + + %增加标签对齐选项,right是默认的右对齐,left是左对齐,gb7714-2015是项对齐方式 + %因为在作者年制中,不需要使用,这里也增加,为了与顺序编码制的兼容性考虑。 + \DeclareBibliographyOption[string]{gbalign}[right]{}% + + %增加一个出版项自动处理控制选项,当true时使用出版者不详等信息补充缺失的出版信息。 + \newtoggle{bbx:gbpub} + \DeclareBibliographyOption[boolean]{gbpub}[true]{% + %\settoggle{bbx:gbpub}{#1} %或采用下面这一句 + \ifstrequal{##1}{false}{\togglefalse{bbx:gbpub}}{\toggletrue{bbx:gbpub}}} + \ExecuteBibliographyOptions{gbpub} + + %增加一个处理佚名或noauthor的控制选项 + \DeclareBibliographyOption[boolean]{gbnoauthor}[true]{% + \ifstrequal{##1}{false}{}{\dealnoathor}} + %\ExecuteBibliographyOptions{gbnoauthor=true}%对于需要展开较早(展开层级优先)的选项,这一执行无效,只能利用宏包加载时给出选项达到目的。 + + \ExecuteBibliographyOptions{ + useprefix = true, %名字的信息包括前缀 + %firstinits = true, %名字有缩写,参考3.1.2.3 Internal + giveninits = true, + date = year, %日期仅写到年 + urldate =iso, + eventdate =iso, + %maxnames = 3 , %设置名字最大数量 + %minnames = 3, %设置缩减后的名字最小数量 + maxbibnames=3, %将文献列表和引用中最大名字数量区分开 + minbibnames=3, + %datezeros=true, + } +} + +\iftoggle{iftlfive}{\switchversion{3.0}{opt}}{}%biblatex<=3.2 +\iftoggle{iftlsix}{\switchversion{3.4}{opt}}{}%3.3<=biblatex<=3.6 +\iftoggle{iftlseven}{\switchversion{3.7}{opt}}{}%biblatex=3.7 +\iftoggle{iftleight}{\switchversion{3.7}{opt}}{}%3.8<=biblatex<=3.9 +\iftoggle{iftlatest}{\switchversion{3.10}{opt}}{}%biblatex最新3.10 + + +%===================================================================== +%===================================================================== +%设置本地化字符串 +%===================================================================== + %新建一个当地化字符串,用来记录“等”字符 + \NewBibliographyString{andotherscn} + \NewBibliographyString{noaddress} + \NewBibliographyString{nopublisher} + +%直接利用当地化格式english进行修改一些中文的格式,具体可以修改哪些,参考english.lbx文件 +%当然也可以增加比如上面定义的andotherscn +%注意:在lbx文件和bbx文件中定义本地字符串的不同语法,两个参数和一个参数的区别 +\DefineBibliographyStrings{english}{ +bibliography = {参考文献}, +references = {参考文献}, +bytranslator= {\addcomma\ 译\adddot}, %将trans. by 改成 译 +and = {\addcomma},%将第2和3人名见的and符号改成 逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 +%andothers = {et al.}, %将超过3个人名的省略,et al.改成为 等 +andotherscn = {等}, %将超过3个人名的省略,et al.改成为 等 +noaddress = {[S.l.]}, +nopublisher = {[s.n.]}, +backrefpage = {引用页:}, +backrefpages = {引用页:}, +} + + +%===================================================================== +%===================================================================== +%动态数据修改,修改输入的源文件数据,用于中文判断等操作 +%===================================================================== +%首先把作者和译者信息准确的记录到userf,usere中,用于后面判断是否是cjk字符。 +%注意\DeclareSourcemap命令只能出现一次 +\DeclareSourcemap{ +\maps[datatype=bibtex]{ + \map[overwrite]{%用于处理zotero从cnki导出中文文献姓名中存在逗号的情况 + \step[fieldsource={author}, match=\regexp{([\x{2FF0}-\x{9FA5}])\,\s*}, replace=\regexp{$1}] + } + \map{ + \pertype{article} + \step[fieldset=usera, fieldvalue={J}] + } + \map{ + \pertype{periodical} + \step[fieldset=usera, fieldvalue={J}] + \step[fieldsource=author] %有时会把author和editor混淆,这里处理后就没有这个问题 + \step[fieldset=editor, origfieldval] + \step[fieldsource=publisher] %有时会把publisher和institution混淆,这里处理后就没有这个问题 + \step[fieldset=institution, origfieldval] + } + \map{ + \pertype{newspaper}%增加一个新闻报纸的类型newspaper + \step[fieldset=usera, fieldvalue={N}]%因为没有专门的驱动,这句的目的是定义一个usera域,方便映射为article后判断 + \step[fieldset=note, fieldvalue=news] + } + \map{ + \pertype{book} + \pertype{inbook} + \step[fieldset=usera, fieldvalue={M}] + \step[fieldsource=version] %有时会把version和edition混淆,这里处理后就没有这个问题,可以直接用version + \step[fieldset=edition, origfieldval] + } + \map{ + \pertype{standard}%兼容老的standard类型 + \step[fieldset=usera, fieldvalue={S}]%因为没有专门的驱动,这句的目的是定义一个usera域,方便映射为book和inbook后判断 + \step[fieldset=note, fieldvalue=standard] + } + \map{ + \pertype{patent} + \step[fieldset=usera, fieldvalue={P}] + } + \map{ + \pertype{inproceedings} + \pertype{conference}%兼容老的conference类型 + \step[fieldset=usera, fieldvalue={C}] + \step[fieldsource=institution] %有时会把publisher和institution混淆,这里处理后就没有这个问题 + \step[fieldset=publisher, origfieldval] + \step[fieldsource=editor] % + \step[fieldset=bookauthor, origfieldval] + } + \map{ + \pertype{proceedings} + \step[fieldset=usera, fieldvalue={C}] + \step[fieldsource=institution] %有时会把publisher和institution混淆,这里处理后就没有这个问题 + \step[fieldset=publisher, origfieldval] + \step[fieldsource=editor] %%有的时候可能只填写了编者,没有author,把它复制一下 + \step[fieldset=author, origfieldval] + } + \map{ + \pertype{report} + \pertype{techreport}%兼容老的techreport类型 + \step[fieldset=usera, fieldvalue={R}] + \step[fieldsource=publisher] %有时会把publisher和institution混淆,这里处理后就没有这个问题 + \step[fieldset=institution, origfieldval] + } + \map{ + \pertype{thesis} + \pertype{mastersthesis}%兼容老的mastersthesis和phdthesis类型 + \pertype{phdthesis} + \step[fieldset=usera, fieldvalue={D}] + } + \map{ + \pertype{online} + \pertype{electronic}%兼容老的electronic类型 + \pertype{www}%兼容老的www类型 + \step[fieldset=usera, fieldvalue={EB}] + } + \map{ + \pertype{manual} + \step[fieldset=usera, fieldvalue={A}] + \step[fieldsource=edition] %有时会把version和edition混淆,这里处理后就没有这个问题,可以直接用version + \step[fieldset=version, origfieldval] + \step[fieldsource=organization]%因为用的report的驱动,所以需要institution域,也把organization转成它,这样增大兼容性 + \step[fieldset=institution, origfieldval] + } + \map{ + \pertype{incollection} + \step[fieldset=usera, fieldvalue={G}] + } + \map{ + \pertype{collection} + \step[fieldset=usera, fieldvalue={G}] + \step[fieldsource=editor] %%有的时候可能只填写了编者,没有author,把它复制一下 + \step[fieldset=author, origfieldval] + } + \map{ + \pertype{unpublished} + \step[fieldset=usera, fieldvalue={Z}] + } + \map{ + \step[fieldsource=author] + \step[fieldset=userf, origfieldval] + \step[fieldsource=translator] + \step[fieldset=usere, origfieldval] + } + \map{%处理一些用year表示date的情况 + %这样处理将会设置date域,并使得labeldatesource变为空,因为date的前缀为空(如果是urldate,那么labeldatesource就是url)。 + %同时date域会被biblatex自动解析为year,month,day,并且覆盖原来的year信息 + \step[fieldsource=year] + \step[fieldset=date, origfieldval] + } + \map{%将title信息保存到userd中避免因为标签生成原因导致title域被清除 + \step[fieldsource=title, match=\regexp{([^\\\{])}]%} + \step[fieldset=userd, fieldvalue={$1}] + } + \map{%将entrykey放入keywords中用于后期的使用 + \step[fieldsource=entrykey] + \step[fieldset=keywords, origfieldval] + } + \map[overwrite]{%这里还必须有overwrite,怎么之前会觉得没有问题呢,可能是之前版本拷错了,还是之前是texlive2015变16后biber有了变化(2016-1207修改正确) + \step[fieldsource=note, final]%将note域信息复制给keywords,用于输出时容易区分标准和报纸 + \step[fieldset=keywords, fieldvalue={,}, append] + \step[fieldset=keywords, origfieldval, append] + } + \map{%因为要对author进行判断,所以这里先对有些只有编者而没有作者的情况进行处理 + \step[fieldsource=editor] + \step[fieldset=author,origfieldval] + } + \map{%因为无法进行cjk字符判断,所以用反的思路,判断没有英文字符,没有空格,没有逗号等字符情况下 + %认为是中文的,将文献userb设置成cn,用于排序 + %参考4.5.8 姓名首字母生成控制 + %\step[fieldsource=author,match=\regexp{[^a-zA-Z\s\.\,\'\{\}\\\/\-\x22\x26\:0-9\p{IsP}\p{PosixPunct}\x{2bf}\x{2018}\xE9\p{IsASCII}]},final] + %对于带重音符号的字符似乎无法匹配。比如\'e + %最后选择直接匹配cjk字符,unicode编码位置从2FF0到9FA5 + \step[fieldsource=author,match=\regexp{[\x{2FF0}-\x{9FA5}]},final] + \step[fieldset=userb,fieldvalue={cn}] + } + \map{\step[fieldsource=title,match=\regexp{[\x{2FF0}-\x{9FA5}]},final] + \step[fieldset=userb,fieldvalue={cn}] + }%如果没有作者和标题,那么剩下的最可能有意义的只有网址了,而网址通常是英文的,因此不用再进一步对其它域进行判断了。 + \map{%将没有设置的userb设置成en,即认为不是中文的就是英文的。 + \step[fieldset=userb,fieldvalue={en}] + } + %本来后面这些是放到DeclareStyleSourcemap中处理的,但是因为texlive2016的biblatex3.4不支持多个DeclareStyleSourcemap, + %但有处理特殊字符和处理gbnoauthor选项的需求,所以把这些提到这来,以后将这两个功能结合到一个DeclareStyleSourcemap时, + %不用复制如下段代码了。 + \map{%尝试未定义数据模型的newspaper类型映射为article,newspaper完全是针对gb7714的新类型,在biblatex中完全没有定义 + %但从实践看,并没有什么影响,映射过来就可以了。 + \step[typesource=newspaper, typetarget=article, final] + } + \map{%尝试未定义数据模型的standard类型映射为book,standard类型在blx-dm中有出现,但仅定义了类型,域和约束等都没有定义 + \step[fieldsource=booktitle,final]%当存在booktitle域是映射为inbook + \step[typesource=standard, typetarget=inbook, final] + } + \map{%尝试未定义数据模型的standard类型映射为book,standard类型在blx-dm中有出现,但仅定义了类型,域和约束等都没有定义 + \step[typesource=standard, typetarget=book, final]%当不存在booktitle域是映射为book + } + \map{%先于标准样式的driver层映射,将其先映射过来,并取消type设置 + \step[typesource=mastersthesis, typetarget=thesis, final] + %\step[fieldset=type, fieldvalue=mathesis] + } + \map{%先于标准样式的driver层映射,将其先映射过来,并取消type设置 + \step[typesource=phdthesis, typetarget=thesis, final] + %\step[fieldset=type, fieldvalue=phdthesis] + } + \map{%先于标准样式的driver层映射,将其先映射过来,并取消type设置 + \step[typesource=techreport, typetarget=report, final] + %\step[fieldset=type, fieldvalue=techreport] + } + \map[overwrite]{%title,booktitle,journaltitle,journal,publisher,address,location,institution,organization + \step[fieldsource={title}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={booktitle}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={journaltitle}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={journal}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={publisher}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={address}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={location}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={institution}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={booktitle}, match=\regexp{([^\\])\#}, replace=\regexp{$1\\\#}] + } + \map[overwrite]{ + \step[fieldsource={booktitle}, match=\regexp{([^\\])\%}, replace=\regexp{$1\\\%}] + } + %对于高版本(3.4以上)可以用下面这一段取代前面那一段,为了兼容gbnoauthor选项,这些代码只能在sourcemap中使用,所以只能选择前面那一段 + %\map[overwrite, foreach={title,booktitle,journaltitle,journal,publisher,address,location,institution,organization}]{ +% \step[fieldsource=\regexp{$MAPLOOP}, match=\regexp{([^\\])\#}, replace=\regexp{$1\\\#}] +% } +% \map[overwrite, foreach={title,booktitle,journaltitle,journal,publisher,address,location,institution,organization}]{ +% \step[fieldsource=\regexp{$MAPLOOP}, match=\regexp{([^\\])\%}, replace=\regexp{$1\\\%}] +% } +% \map[overwrite, foreach={title,booktitle,journaltitle,journal,publisher,% +% address,location,institution,organization}]{ +% \step[fieldsource=\regexp{$MAPLOOP}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] +% } + } +} + +\def\dealnoathor{ + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + \map{%默认情况下将空缺作者设置为佚名 + \step[fieldsource=userb,match={cn},final] + \step[fieldset=author, fieldvalue={佚名}] + } + \map{%默认情况下将空缺作者设置为佚名 + \step[fieldsource=userb,match={en},final] + \step[fieldset=author, fieldvalue={NOAUTHOR}] + } + } + } +} + + +%===================================================================== +%===================================================================== +%设置排序格式 +%===================================================================== +%排序用降序或userb域 +\defversion{3.7}{sort}{%这是3.4版的,3.7版略有差异,但不大,后面有注释 + \DeclareSortingScheme{nyt}{ + \sort{ + \field{presort} + } + \sort[final]{ + \field{sortkey} + } + \sort{ + \field{userb} + } + \sort{%[direction=descending] + \field{sortname} + \field{author} + \field{editor} + \field{translator} + \field{sorttitle} + \field{title} + } + \sort{ + \field{sortyear} + \field{year} + } + \sort{ + \field{sorttitle} + \field{title} + } + \sort{ + \field[padside=left,padwidth=4,padchar=0]{volume}%3.7版是\field{volume} + \literal{0000}%3.7版是\literal{0} + } + } +} + +\defversion{3.8}{sort}{ + \DeclareSortingTemplate{nyt}{ + \sort{ + \field{presort} + } + \sort[final]{ + \field{sortkey} + } + \sort{ + \field{userb} + } + \sort{%[direction=descending] + \field{sortname} + \field{author} + \field{editor} + \field{translator} + \field{sorttitle} + \field{title} + } + \sort{ + \field{sortyear} + \field{year} + } + \sort{ + \field{sorttitle} + \field{title} + } + \sort{ + \field{volume} + \literal{0} + } + } + + %为了实现v3.8以上版本的双语文献,采用related的方法代替set方法,因为set方法已经无法实现了, + %因为set不再复制其第一个成员的信息。于是定义一个命令,用于动态的修改数据,即添加related域的信息 + %其中使用了\DeclareStyleSourcemap,但由于其只能出现在导言区中,因此\defdoublelangentry命令也只能出现在导言区中 + \newcommand{\defdoublelangentry}[2]{% + \edef\entrykeya{##1} + \edef\entrykeyb{##2} + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + \map{ + \step[fieldsource=entrykey, match=\entrykeya, final] + \step[fieldset=related, fieldvalue=\entrykeyb] + } + } + } + } +} + + +\iftoggle{iftlfive}{\switchversion{3.7}{sort}}{}%biblatex<=3.2 +\iftoggle{iftlsix}{\switchversion{3.7}{sort}}{}%3.3<=biblatex<=3.6 +\iftoggle{iftlseven}{\switchversion{3.7}{sort}}{}%biblatex=3.7 +\iftoggle{iftleight}{\switchversion{3.8}{sort}}{}%3.8<=biblatex<=3.9 +\iftoggle{iftlatest}{\switchversion{3.8}{sort}}{}%biblatex最新3.10 + + +%===================================================================== +%===================================================================== +%参考文献列表环境 +%===================================================================== + \defbibenvironment{bibliography}%修改参考文献列表环境,不要缩进 + {\list + {} + {%\setlength{\leftmargin}{\bibhang}% + %\setlength{\itemindent}{-\leftmargin}% + \setlength{\leftmargin}{1em}% + \setlength{\itemindent}{-1em}% + \setlength{\itemsep}{\bibitemsep}% + \setlength{\parsep}{\bibparsep}}} + {\endlist} + {\item} + + +%===================================================================== +%===================================================================== +%设置单元或块等的标点 +%===================================================================== +\renewcommand*{\subtitlepunct}{\addcolon\space} %修改标题和其它标题信息间的标点%来源biblatex.def +%双语言或多语言的参考文献,可以参考3.11.5 Entry Sets,4.11.1 Entry Sets +%这里调整一下两种语言参考文献的间隔,%源来自biblatex.def +\renewcommand*{\entrysetpunct}{\adddot\par\nobreak} +\renewcommand*{\bibpagespunct}{\addcolon\addthinspace}%页码引用格式的修改%修改为用冒号 +%\renewcommand{\relateddelim}{}%\par + +%===================================================================== +%===================================================================== +%修改域的格式 +%===================================================================== +%新增文献类型标识符的格式 +\DeclareFieldFormat{gbtypeflag}{% +\iftoggle{bbx:url}{\iffieldundef{url}%当存在url时,增加一个OL标识符 +{\nobreak\printtext{[}\nobreak#1\nobreak\printtext{]}}% +{\nobreak\printtext{[}\nobreak#1\nobreak\printtext{\texttt{/}OL]}}% +}{\nobreak\printtext{[}\nobreak#1\nobreak\printtext{]}}} + +\DeclareFieldFormat{gbtypeflagn}{%用于报纸newspaper +\iftoggle{bbx:url}{\iffieldundef{url}%当存在url时,增加一个OL标识符 +{\nobreak\printtext{[}\nobreak N\printtext{]}\nobreak}% +{\nobreak\printtext{[}\nobreak N\printtext{\texttt{/}OL]}\nobreak}% +}{\nobreak\printtext{[}\nobreak N\printtext{]}\nobreak}} + +\DeclareFieldFormat{gbtypeflags}{%用于标准standard +\iftoggle{bbx:url}{\iffieldundef{url}%当存在url时,增加一个OL标识符 +{\nobreak\printtext{[}\nobreak S\printtext{]}\nobreak}% +{\nobreak\printtext{[}\nobreak S\printtext{\texttt{/}OL]}\nobreak}% +}{\nobreak\printtext{[}\nobreak S\printtext{]}\nobreak}} + +%重设title的输出格式,不加emph,原格式来自biblatex.def文件 +\DeclareFieldFormat{title}{#1\adddot\addthinspace} +\DeclareFieldFormat{journaltitle}{#1\isdot}%添加\isdot,用于缩写名带点情况,将其转换为缩写点,便于标点的追踪 +\DeclareFieldFormat{issuetitle}{#1} +\DeclareFieldFormat{maintitle}{#1} +\DeclareFieldFormat{booktitle}{#1} +\DeclareFieldFormat%将期刊等文献的标题中原来带的引号去掉 + [article,patent,thesis,unpublished] + {title}{#1\adddot\addthinspace} +\DeclareFieldFormat%将期刊等文献的标题中原来带的引号去掉 + [inbook,incollection,inproceedings] + {title}{#1\nopunct\unspace} +\DeclareFieldFormat{titlecase}{\MakeCapital#1}%重设标题格式,将其修改为首字母大写 + + +\defversion{3.0}{name}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + \renewbibmacro*{name:last-first}[4]{% + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifblank{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + %\mkbibnamelast{#1}\isdot + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{\MakeUppercase{##1}}}\isdot%\MakeUppercase %\mkbibnamelast{\MakeUppercase{#1}} %\MakeSentenceCase + %注意上一句\MakeCapital后面如果再跟一个{}包含#1,则没有效果,可能是包在里面少了一层展开 + %因为机构名通常包括在{}内,所以要多展开一次才行,所以这里去掉#1外面的{} + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{\MakeUppercase{##2}}\isdot}% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + %\mkbibnamelast{#1}\isdot %3.9.1 Generic Commands and Hooks,对姓重新处理,如下句: %\mkbibnamelast{\MakeUppercase{#1}} + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{\MakeUppercase{##1}}}\isdot %大写,参考4.6.4 Miscellaneous Commands,\MakeUppercase %\MakeSentenceCase + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2##3}{}{\revsdnamepunct}% + \ifblank{##2}{}{\bibnamedelimd\mkbibnamefirst{\MakeUppercase{##2}}\isdot}% + \ifblank{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot}% + \addcomma\addspace% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}% + } + } + + \renewbibmacro*{name:first-last}[4]{% + \usebibmacro{name:last-first}{##1}{##2}{##3}{##4}} +} + +\defversion{3.4}{name}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + %biblatex3.3版后(比如texlive2016中的3.4版)的使用方式 + \renewbibmacro*{name:given-family}[4]{%利用family-given定义given-family + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifdefvoid{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifprefchar{}{\bibnamedelimc}}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{\MakeUppercase{##1}}}\isdot + \ifdefvoid{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamegiven{\MakeUppercase{##2}}\isdot}%\MakeCapital + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{\MakeUppercase{##1}}}\isdot + % + \ifboolexpe{% + test {\ifdefvoid{##2}} + and + test {\ifdefvoid{##3}}} + {} + {\revsdnamepunct}% + \ifdefvoid{##2}{}{\bibnamedelimd\mkbibnamegiven{\MakeUppercase{##2}}\isdot}%\MakeCapital + \ifdefvoid{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot} + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + } + \renewbibmacro*{name:family-given}[4]{% + \usebibmacro{name:given-family}{##1}{##2}{##3}{##4}} +} + +\defversion{3.0}{nameb}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + \renewbibmacro*{name:last-first}[4]{% + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifblank{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + %\mkbibnamelast{#1}\isdot + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{{##1}}}\isdot%\MakeUppercase %\mkbibnamelast{\MakeUppercase{#1}} %\MakeSentenceCase + %注意上一句\MakeCapital后面如果再跟一个{}包含#1,则没有效果,可能是包在里面少了一层展开 + %因为机构名通常包括在{}内,所以要多展开一次才行,所以这里去掉#1外面的{} + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{{##2}}\isdot}% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + %\mkbibnamelast{#1}\isdot %3.9.1 Generic Commands and Hooks,对姓重新处理,如下句: %\mkbibnamelast{\MakeUppercase{#1}} + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{{##1}}}\isdot %大写,参考4.6.4 Miscellaneous Commands,\MakeUppercase %\MakeSentenceCase + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2##3}{}{\revsdnamepunct}% + \ifblank{##2}{}{\bibnamedelimd\mkbibnamefirst{{##2}}\isdot}% + \ifblank{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot}% + \addcomma\addspace% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}% + } + } + \renewbibmacro*{name:first-last}[4]{% + \usebibmacro{name:last-first}{##1}{##2}{##3}{##4}} +} + +\defversion{3.4}{nameb}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + %biblatex3.3版后(比如texlive2016中的3.4版)的使用方式 + \renewbibmacro*{name:given-family}[4]{%用family-given修改后的内容定义given-family + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifdefvoid{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifprefchar{}{\bibnamedelimc}}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{{##1}}}\isdot% + \ifdefvoid{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamegiven{{##2}}\isdot}%\MakeCapital + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{{##1}}}\isdot% + % + \ifboolexpe{% + test {\ifdefvoid{##2}} + and + test {\ifdefvoid{##3}}} + {} + {\revsdnamepunct}% + \ifdefvoid{##2}{}{\bibnamedelimd\mkbibnamegiven{{##2}}\isdot}%\MakeCapital + \ifdefvoid{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot} + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + } + \renewbibmacro*{name:family-given}[4]{% + \usebibmacro{name:given-family}{##1}{##2}{##3}{##4}} +} + +\defversion{3.0}{namec}{ + \renewrobustcmd*{\bibinitperiod}{\adddot} + \renewcommand*{\revsdnamepunct}{\addcomma} + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + \renewbibmacro*{name:last-first}[4]{% + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifblank{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + \mkbibnamelast{##1}\isdot + \ifblank{##4}{}{\bibnamedelimd\mkbibnameaffix{##4}\isdot}%这句放到后面 + \ifblank{##2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{{##2}}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + \mkbibnamelast{##1}\isdot %3.9.1 Generic Commands and Hooks,对姓重新处理,如下句: %\mkbibnamelast{\MakeUppercase{#1}} + \ifblank{##4}{}{\bibnamedelimd\mkbibnameaffix{##4}\isdot}%这句放到后面 + \ifblank{##2##3}{}{\revsdnamepunct}% + \ifblank{##2}{}{\bibnamedelimd\mkbibnamefirst{{##2}}\isdot}% + \ifblank{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot}% + } + } + \renewbibmacro*{name:first-last}[4]{% + \usebibmacro{name:last-first}{##1}{##2}{##3}{##4}} +} + +\defversion{3.4}{namec}{ + \renewrobustcmd*{\bibinitperiod}{\adddot} + \renewcommand*{\revsdnamepunct}{\addcomma} + \renewbibmacro*{name:given-family}[4]{% + \usebibmacro{name:delim}{##2##3##1}% + \usebibmacro{name:hook}{##2##3##1}% + \ifdefvoid{##2}{}{\mkbibnamegiven{##2}\isdot\bibnamedelimd}% + \ifdefvoid{##3}{}{% + \mkbibnameprefix{##3}\isdot + \ifprefchar + {} + {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}% + \mkbibnamefamily{##1}\isdot + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + \DeclareNameAlias{family-given}{default} + + \renewbibmacro*{name:family-given}[4]{% + \usebibmacro{name:given-family}{##1}{##2}{##3}{##4}} +} + +\defversion{3.0}{named}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \renewrobustcmd*{\bibnamedelima}{\mbox{-}} + + %注意authoryear作者输出用的sortname格式也就是family-given/given-family + %不同于nemeric的first-last格式 + \DeclareNameFormat{last-first/first-last}{% + \usebibmacro{name:first-last}{##1}{##3}{##5}{##7}% + \usebibmacro{name:andothers}} + + %biblatex3.3版前(比如texlive2015中的3.0版)的使用方式 + \renewbibmacro*{name:last-first}[4]{% + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifblank{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + %\mkbibnamelast{#1}\isdot + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{\MakeUppercase{##1}}}\isdot%\MakeUppercase %\mkbibnamelast{\MakeUppercase{#1}} %\MakeSentenceCase + %注意上一句\MakeCapital后面如果再跟一个{}包含#1,则没有效果,可能是包在里面少了一层展开 + %因为机构名通常包括在{}内,所以要多展开一次才行,所以这里去掉#1外面的{} + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2}{}{\revsdnamepunct\bibnamedelimd\MakeSentenceCase{\mkbibnamefirst{##2}}\isdot}% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + %\mkbibnamelast{#1}\isdot %3.9.1 Generic Commands and Hooks,对姓重新处理,如下句: %\mkbibnamelast{\MakeUppercase{#1}} + \ifblank{##2}{\MakeCapital##1}{\mkbibnamelast{\MakeUppercase{##1}}}\isdot %大写,参考4.6.4 Miscellaneous Commands,\MakeUppercase %\MakeSentenceCase + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{##2##3}{}{\revsdnamepunct}% + \ifblank{##2}{}{\bibnamedelimd\mkbibnamefirst{\MakeUppercase{##2}}\isdot}% + \ifblank{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot}% + \addcomma\addspace% + \ifblank{##4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{##4}\isdot}% + } + } + \renewbibmacro*{name:first-last}[4]{% + \usebibmacro{name:last-first}{##1}{##2}{##3}{##4}} +} + +\defversion{3.4}{named}{ + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \renewrobustcmd*{\bibnamedelima}{\mbox{-}} + + %注意authoryear作者输出用的sortname格式也就是family-given/given-family + %不同于nemeric的given-family格式 + \DeclareNameFormat{family-given/given-family}{% + {\usebibmacro{name:given-family} + {\namepartfamily} + {\namepartgiven} + {\namepartprefix} + {\namepartsuffix}}% + \usebibmacro{name:andothers}} + + %biblatex3.3版后(比如texlive2016中的3.4版)的使用方式 + \renewbibmacro*{name:given-family}[4]{%用family-given修改后的内容定义given-family + \ifuseprefix + {\usebibmacro{name:delim}{##3##1}% + \usebibmacro{name:hook}{##3##1}% + \ifdefvoid{##3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{##3}}\isdot} + {\mkbibnameprefix{##3}\isdot}% + \ifprefchar{}{\bibnamedelimc}}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{\MakeUppercase{##1}}}\isdot% + \ifdefvoid{##2}{}{\revsdnamepunct\bibnamedelimd\MakeSentenceCase{\mkbibnamegiven{##2}}\isdot}%\MakeCapital + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + {\usebibmacro{name:delim}{##1}% + \usebibmacro{name:hook}{##1}% + \ifdefvoid{##2}{\mkbibnamefamily{\MakeCapital{##1}}}{\mkbibnamefamily{\MakeUppercase{##1}}}\isdot% + % + \ifboolexpe{% + test {\ifdefvoid{##2}} + and + test {\ifdefvoid{##3}}} + {} + {\revsdnamepunct}% + \ifdefvoid{##2}{}{\bibnamedelimd\mkbibnamegiven{\MakeCapital{##2}}\isdot}%\MakeCapital + \ifdefvoid{##3}{}{\bibnamedelimd\mkbibnameprefix{##3}\isdot} + \ifdefvoid{##4}{}{\bibnamedelimd\mkbibnamesuffix{##4}\isdot}} + } + \renewbibmacro*{name:family-given}[4]{% + \usebibmacro{name:given-family}{##1}{##2}{##3}{##4}} +} + +\iftoggle{iftlfive}%根据texlive/biblatex版本选择 + {\switchversion{3.0}{name}}% + {\switchversion{3.4}{name}} + +\def\execnamedefault{ +\iftoggle{iftlfive}%根据texlive/biblatex版本选择 + {%%当采用biblatex<=3.3版本时 + \switchversion{3.0}{namec} + }{%%当采用3.3<=biblatex版本时 + \switchversion{3.4}{namec} + } +} + +\def\execgblowercase{ +\iftoggle{iftlfive}%根据texlive/biblatex版本选择 + {%%当采用biblatex<=3.3版本时 + \switchversion{3.0}{nameb} + }{%%当采用3.3<=biblatex版本时 + \switchversion{3.4}{nameb} + } +} + +\def\execnamepinyin{ +\iftoggle{iftlfive}%根据texlive/biblatex版本选择 + {%%当采用biblatex<=3.3版本时 + \switchversion{3.0}{named} + }{%%当采用3.3<=biblatex版本时 + \switchversion{3.4}{named} + }} + +%重设title的输出,将文献类型标识符输出出去,原输出来自biblatex.def文件 +\renewbibmacro*{title}{% + \ifboolexpr{% + test{\iffieldundef{title}}% + and% + test{\iffieldundef{subtitle}}% + }% + {}% + {\printtext[title]{% + \printfield[titlecase]{title}% + \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题 + {}{\setunit{\subtitlepunct}% + \printfield[titlecase]{subtitle}}% + \iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格 + {\setunit{\subtitlepunct}\printfield{titleaddon}}% + \iffieldundef{note}{\printfield[gbtypeflag]{usera}}%在标题后直接给出文献标识字母,判断一下,是否是报纸和标准 + {\iffieldequalstr{note}{standard}{\printfield[gbtypeflags]{usera}}%判断是否为标准 + {\iffieldequalstr{note}{news}{\printfield[gbtypeflagn]{usera}}%判断是否为报纸 + {\printfield[gbtypeflag]{usera}}}%其它 + }% + \iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点 + %\newunit + }% +}% +} + +\DeclareFieldFormat{url}{\url{#1}} %url域修改如本行%url相关输出,源来自biblatex.def +\renewbibmacro*{url+urldate}{% + %\usebibmacro{url}%%更换url的位置,放到下面 + \iffieldundef{urlyear}% + {}{%\setunit*{\addspace}% + \usebibmacro{urldate}}% + \setunit{\addperiod\addspace}% + \usebibmacro{url}} +\renewbibmacro*{url}{\printfield{url}} + +\defversion{3.4}{date}{ + \renewbibmacro*{urldate}{% + \addthinspace\printtext{[}\printfield{urlyear}% + \iffieldundef{urlmonth}{}{\bibrangedash\printfield{urlmonth}}% + \iffieldundef{urlday}{}{\bibrangedash\printfield{urlday}}\printtext{]}} + + \newbibmacro*{newsdate}{%%新增加一个新闻日期 + \iffieldundef{year}{}{\printfield{year}% + \iffieldundef{month}{}{\bibrangedash\printtext{\thefield{month}}% + \iffieldundef{day}{}{\bibrangedash\printfield{day}}}}% + } + + \newbibmacro*{modifydate}{%新增加一个带括号的日期,用于表示电子资源的更新和修改日期,而公告日期则按日期格式 + \iffieldequalstr{year}{}{%替换\iffieldundef{year},因为year总是存在,但为空 + \iffieldundef{endyear}{% + \iffieldundef{eventyear}{}{\printtext{\mkbibparens{\printtext{\printfield{eventyear}}% + \iffieldundef{eventmonth}{}{\bibrangedash\thefield{eventmonth}}% + \iffieldundef{eventday}{}{\bibrangedash\printfield{eventday}}}}% + }% + }{% + \iffieldundef{endyear}{}{\printtext{\mkbibparens{\printtext{\printfield{endyear}}% + \iffieldundef{endmonth}{}{\bibrangedash\thefield{endmonth}}% + \iffieldundef{endday}{}{\bibrangedash\printfield{endday}}}}% + }% + }% + }% + {% + \iffieldundef{year}{}{\printtext{\mkbibparens{\printtext{\printfield{year}}% + \iffieldundef{month}{}{\bibrangedash\thefield{month}}% + \iffieldundef{day}{}{\bibrangedash\printfield{day}}}}% + }% + }% + }% +} + +\defversion{3.7}{date}{ + \DeclareFieldFormat{urldate}{##1} + \renewbibmacro*{urldate}{% + \addthinspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 + + \newbibmacro*{newsdate}{%%新增加一个新闻日期 + \blx@edtfdate{}{}% + } + + \newbibmacro*{modifydate}{%新增加一个带括号的日期,用于表示电子资源的更新和修改日期,而公告日期则按日期格式 + \iffieldundef{year}{% + \iffieldundef{endyear}{\iffieldundef{eventyear}{}{\printtext{(}\printeventdate\printtext{)}}}% + {\printtext{(}\printenddate\printtext{)}}% + }{\iffieldequalstr{year}{}{%因为year存在,但为空 + }{\printtext{(}\blx@edtfdate{}{}\printtext{)}}% + }% + }% +} + +\defversion{3.10}{date}{ + \DeclareFieldFormat{urldate}{##1} + \renewbibmacro*{urldate}{% + \addthinspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 + + \newbibmacro*{newsdate}{%%新增加一个新闻日期 + \blx@isodate{}{}% + } + + \newbibmacro*{modifydate}{%新增加一个带括号的日期,用于表示电子资源的更新和修改日期,而公告日期则按日期格式 + \iffieldundef{year}{% + \iffieldundef{endyear}{\iffieldundef{eventyear}{}{\printtext{(}\printeventdate\printtext{)}}}% + {\printtext{(}\printenddate\printtext{)}}% + }{\iffieldequalstr{year}{}{%因为year存在,但为空 + }{\printtext{(}\blx@isodate{}{}\printtext{)}}% + }% + }% +} + +\iftoggle{iftlfive}{\switchversion{3.4}{date}}{}%biblatex<=3.2 +\iftoggle{iftlsix}{\switchversion{3.4}{date}}{}%3.3<=biblatex<=3.6 +\iftoggle{iftlseven}{\switchversion{3.7}{date}}{}%biblatex=3.7 +\iftoggle{iftleight}{\switchversion{3.7}{date}}{}%3.8<=biblatex<=3.9 +\iftoggle{iftlatest}{\switchversion{3.10}{date}}{}%biblatex最新 + + +\renewbibmacro*{related}{% + \ifboolexpr{ test {\iffieldundef{related}} or test {\ifrelatedloop} } + {} + {\usebibmacro{begrelated}% + \def\bbx@tempa{}% + \setcounter{bbx:relatedtotal}{0}% + \def\do##1{% + \entrydata{##1}{% + \ifrelatedloop + {} + {\stepcounter{bbx:relatedtotal}% + \gappto{\bbx@tempa}{##1,}}}}% + \docsvfield{related}% + \restorefield{related}{\bbx@tempa}% + \ifnumgreater{\value{bbx:relatedtotal}}{0} + {\listcsxadd{bbx:relatedloop}{\strfield{entrykey}}% + \iffieldundef{clonesourcekey} + {} + {\listcsxadd{bbx:relatedloop}{\strfield{clonesourcekey}}}% + \setcounter{bbx:relatedcount}{0}% + \def\do{% + \stepcounter{bbx:relatedcount}% + \ifnumgreater{\value{bbx:relatedcount}}{0} + {\ifcsundef{relateddelim\strfield{relatedtype}} + {\printtext{\relateddelim}} + {\printtext{\csuse{relateddelim\strfield{relatedtype}}}}} + {}}% + \ifbibmacroundef{related:\strfield{relatedtype}} + {\appto{\do}{\usebibmacro{related:default}}} + {\appto{\do}{\usebibmacro*{related:\strfield{relatedtype}}}}% + \iffieldformatundef{related:\strfield{relatedtype}} + {\def\bbx@tempa{related}} + {\def\bbx@tempa{related:\strfield{relatedtype}}}% + \iffieldformatundef{relatedstring:\strfield{relatedtype}} + {\def\bbx@tempb{relatedstring:default}} + {\def\bbx@tempb{relatedstring:\strfield{relatedtype}}}% + \printtext[\bbx@tempa]{% + \usebibmacro{begrelatedloop}% + \iffieldundef{relatedstring} + {\ifboolexpr{ + test {\ifnumgreater{\value{bbx:relatedtotal}}{1}} + and + test {\ifbibxstring{\thefield{relatedtype}s}} + } + {\printtext[\bbx@tempb]{% + \bibstring[\mkrelatedstring]{\thefield{relatedtype}s}}} + {\iffieldbibstring{relatedtype} + {\printtext[\bbx@tempb]{% + \bibstring[\mkrelatedstring]{\thefield{relatedtype}}}} + {}}} + {\iffieldbibstring{relatedstring} + {\printtext[\bbx@tempb]{% + \bibstring[\mkrelatedstring]{\thefield{relatedstring}}}} + {\printfield[\bbx@tempb]{relatedstring}}}% + \docsvfield{related}% + \usebibmacro{endrelatedloop}}}% + {}% + \usebibmacro{endrelated}}} + +\DeclareFieldFormat{pages}{#1}%页码引用格式的修改%去掉前面引导页码的pp.等字符 + +%调整doi+eprint+url格式,源来自standard.bbx +%因为页码后面直接跟引用日期,没有标点所以去掉其中的标点。 +\renewbibmacro*{doi+eprint+url}{% +% \iftoggle{bbx:doi}%把doi的位置放到url后面 +% {\printfield{doi}} +% {}% + %\newunit\newblock + \iftoggle{bbx:eprint} + {\usebibmacro{eprint}} + {}% + %\newunit\newblock + \iftoggle{bbx:url} + {\usebibmacro{url+urldate}} + {} + \newunit\newblock + \iftoggle{bbx:doi} + {\printfield{doi}} + {}} + +\renewbibmacro*{chapter+pages}{% + \printfield{chapter}% + \iffieldundef{pages}{}{%这里增加一个判断,当没有页码时就不输出 + \setunit{\bibpagespunct}% + \printfield{pages}}% + %\newunit %这里的标点去掉 + } + +%对edition版本信息做出修改,源来自biblatex.DEF +\DeclareFieldFormat{edition}{% +\iffieldundef{title}{}{\testCJKfirst{\thefield{userd}}}% + \ifinteger{#1}% + {\iftoggle{ifCJKforgbt}{\printtext{#1版}}% + {\mkbibordedition{#1}~\bibstring{edition}}}% + {#1\isdot}} + +%对version的版本信息做出修改,源来自biblatex.DEF +\DeclareFieldFormat{version}{% +\iffieldundef{title}{}{\testCJKfirst{\thefield{userd}}}% + \ifinteger{#1}% + {\iftoggle{ifCJKforgbt}{\printtext{#1版}}% + {\mkbibordedition{#1}~\bibstring{version}}}% + {#1\isdot}} + +\renewbibmacro*{author}{%author for biblatex version <=3.7 + \ifboolexpr{ + test \ifuseauthor + and + not test {\ifnameundef{author}} + } + {\usebibmacro{bbx:dashcheck} + {%\bibnamedash + \printnames{author}% + }% + {\usebibmacro{bbx:savehash}% + \printnames{author}% + \iffieldundef{authortype} + {\setunit{\addspace}} + {\setunit{\addcomma\space}}}% + \iffieldundef{authortype} + {} + {\usebibmacro{authorstrg}% + \setunit{\addspace}}}% + {\global\undef\bbx@lasthash + \usebibmacro{labeltitle}% + \setunit*{\addspace}}% + \setunit{\addcomma\space}%增加一个逗号 + \usebibmacro{date+extrayear} + } + +%设置标注和文献表中作者和年份之间的分隔符 +%注意3.4版已经有\nameyeardelim,上述修改的author宏虽然定义了著录表中的标点,但标注中的未定义 +%设置因为mergedate默认为true时的情况,来自\bbx@opt@mergedate@compact +%去掉作者后面包围年份的圆括号 +%这里因为biblatex版本的不同,做不同的处理,texlive2017版/2016等低版本分开处理 +\defversion{3.0}{dateextra}{ +\renewcommand*{\nameyeardelim}{\addcomma\space} + \renewbibmacro*{date+extrayear}{%%重设date+extrayear格式,源来自authoryear.BBX + \iffieldundef{\thefield{datelabelsource}year} + {} + {\printtext{%[parens]%这里把括号去掉 + \iffieldsequal{year}{\thefield{datelabelsource}year} + {\printdateextralabel}% + {\printfield{labelyear}% + \printfield{extrayear}}}}}% +} + +\defversion{3.4}{dateextra}{ + \DeclareDelimFormat{nameyeardelim}{\addcomma\space} + \DeclareDelimFormat[textcite]{nameyeardelim}{\addcomma\space} + \DeclareDelimFormat[bib,biblist]{nameyeardelim}{\addcomma\space} + \renewbibmacro*{date+extrayear}{%%重设date+extrayear格式,源来自authoryear.BBX + \iffieldundef{\thefield{datelabelsource}year} + {} + {\printtext{%[parens]%这里把括号去掉 + \iffieldsequal{year}{\thefield{datelabelsource}year} + {\printdateextralabel}% + {\printfield{labelyear}% + \printfield{extrayear}}}}}% +} +\defversion{3.7}{dateextra}{ + \DeclareDelimFormat{nameyeardelim}{\addcomma\space} + \DeclareDelimFormat[textcite]{nameyeardelim}{\addcomma\space} + \DeclareDelimFormat[bib,biblist]{nameyeardelim}{\addcomma\space} + \renewbibmacro*{date+extrayear}{%以前的\printdateextralabel宏变为了\printlabeldateextra + \iffieldundef{labelyear} + {} + {\printtext{%[parens] + \iffieldsequal{year}{labelyear} + {\printlabeldateextra}% + {\printfield{labelyear}% + \printfield{extrayear}}}}}% +} +\defversion{3.8}{dateextra}{ + \DeclareDelimFormat{nameyeardelim}{\addcomma\space} + \DeclareDelimFormat[textcite]{nameyeardelim}{\addcomma\space} + \DeclareDelimFormat[bib,biblist]{nameyeardelim}{\addcomma\space} +%注意这里当没有作者只有标题时在年份之前的标点是否需要标准并未涉及,所以未做处理。 +\renewbibmacro*{author}{%以前的date+extrayear变为date+extradate,所以对3.8以上版本重定义一下author + \ifboolexpr{ + test \ifuseauthor + and + not test {\ifnameundef{author}} + } + {\usebibmacro{bbx:dashcheck} + {%\bibnamedash %去掉相同作者用横线代替的处理 + \printnames{author}% + } + {\usebibmacro{bbx:savehash}% + \printnames{author}% + \iffieldundef{authortype} + {\setunit{\printdelim{nameyeardelim}}} + {\setunit{\printdelim{authortypedelim}}}}% + \iffieldundef{authortype} + {} + {\usebibmacro{authorstrg}% + \setunit{\printdelim{nameyeardelim}}}}% + {\global\undef\bbx@lasthash + \usebibmacro{labeltitle}% + \setunit*{\printdelim{nonameyeardelim}}}% + \usebibmacro{date+extradate}} + \renewbibmacro*{date+extradate}{% + \iffieldundef{labelyear} + {} + {\printtext{%[parens]%这里去掉括号 + \iflabeldateisdate + {\printdateextra} + {\printlabeldateextra}}}}% +} + +\iftoggle{iftlfive}{\switchversion{3.0}{dateextra}}{}%biblatex<=3.2 +\iftoggle{iftlsix}{\switchversion{3.4}{dateextra}}{}%3.3<=biblatex<=3.6 +\iftoggle{iftlseven}{\switchversion{3.7}{dateextra}}{}%biblatex=3.7 +\iftoggle{iftleight}{\switchversion{3.8}{dateextra}}{}%<=3.8biblatex<=3.9 +\iftoggle{iftlatest}{\switchversion{3.8}{dateextra}}{}%biblatex最新3.10 + + +%修改译者位置格式,bytranslator+others原格式来自biblatex.def文件 +\renewbibmacro*{bytranslator+others}{% + \ifnameundef{translator} + {} + {%\usebibmacro{bytranslator+othersstrg} + %\setunit{\addspace}% + \printnames[bytranslator]{translator}% + \clearname{translator}% + \usebibmacro{bytranslator+othersstrg}%“译”的位置换到下面来,即放到译者后面。 + \setunit{\addspace}% + \newunit}% + \usebibmacro{withothers}} + +%判断作者或译者是否中文,若中文用字符等,否则用etal。 +\renewbibmacro*{name:andothers}{% + \ifboolexpr{ + test {\ifnumequal{\value{listcount}}{\value{liststop}}} + and + test \ifmorenames + } + {%这里做一个判断是在处理author还是translator用于两者是不同语言的情况 + \ifcurrentname{translator}{\iffieldundef{usere}{\togglefalse{ifCJKforgbt}}{\testCJKfirst{\thefield{usere}}}}% + {\iffieldundef{usere}{\togglefalse{ifCJKforgbt}}{\testCJKfirst{\thefield{userf}}}}% + %这句判断如果放到\andothersdelim后面会在等或etc.前增加一个空格,所以放前面 + \ifnumgreater{\value{liststop}}{1} + {\finalandcomma} + {\finalandcomma}% +\andothersdelim\iftoggle{ifCJKforgbt}{\bibstring{andotherscn}}{\bibstring{andothers}} +%\andothersdelim\bibstring{andotherscn} +} +{}} + + +%出版社和地址的处理 +%当没有出版社地址时,直接判断title的信息是否是中文,若为中文,则写出版地不详,否则用英文的字符表示。 +%事实上title对于每个文献来说是必须的,所以用它判断是最快的,而且一般标题和出版社的语言是一样的。 +%新增一个样式用于输出连续出版物的地址,单位,时间,%类似\newbibmacro*{publisher+location+date} +\newbibmacro*{location+institution+date}{% +\iftoggle{bbx:gbpub}% +{\testCJKfirst{\thefield{userd}} +\iflistundef{location}{\iftoggle{ifCJKforgbt}{\printtext{[出版地不详]}}{\printtext{[S.l.\adddot]}}}% + {\printlist{location}}% +% \iflistundef{institution} +% {\setunit*{\addcomma\space}} +% {\setunit*{\addcolon\space}}% +% \printlist{institution}% +% \setunit*{\addcomma\space}% +\addcolon\addspace% +\iflistundef{institution}{% +\iftoggle{ifCJKforgbt}{\printtext{[出版者不详]}}{\printtext{\mkbibbrackets{s.n.}}}}% \bibstring{nopublisher}%[s.n.\adddot] +{\printlist{institution}}% +\setunit{\addcomma\addspace}% + %\usebibmacro{date}% + \printfield{year}% + \bibrangedash% + \iffieldundef{endyear}{}{\printfield{endyear}}% + \newunit}% +{ \printlist{location}% + \iflistundef{institution}% + {\setunit*{\addcomma\space}} + {\setunit*{\addcolon\space}}% + \printlist{institution}% + \setunit*{\addcomma\space}% + \usebibmacro{date}% + \newunit}% +} + +\renewbibmacro*{publisher+location+date}{% +\iftoggle{bbx:gbpub}% +{\testCJKfirst{\thefield{userd}}% +\iflistundef{location}{%\adddot +\iffieldequalstr{note}{standard}{}{%从gbt7714-2015标准第19页看到,标准存在出版项时输出,没有时完全省略。 +\iftoggle{ifCJKforgbt}{\printtext{[出版地不详]}\addcolon\addspace}{\printtext{[S.l.\adddot]}\addcolon\addspace}% +}}% \bibstring{noaddress} +{\printlist{location}\addcolon\addspace}% +%\addcolon\addspace% +\iflistundef{publisher}{% +\iffieldequalstr{note}{standard}{}{% +\iftoggle{ifCJKforgbt}{\printtext{[出版者不详]}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}% +{\printtext{\mkbibbrackets{s.n.}}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}% +}}% +{\printlist{publisher}\setunit*{\addcomma\addspace}}% +%\addcomma\addspace% +\usebibmacro{date}% +%\newunit %去掉这个标点 +}% +{\printlist{location}% + \iflistundef{publisher} + {\setunit*{\addcomma\space}} + {\setunit*{\addcolon\space}}% + \printlist{publisher}% + \setunit*{\addcomma\space}% + \usebibmacro{date}% + %\newunit + }% +} + + +%修改析出文献的文集的标题与附加标题间的符号 +\renewbibmacro*{booktitle}{% + \ifboolexpr{ + test {\iffieldundef{booktitle}} + and + test {\iffieldundef{booksubtitle}} + } + {} + {\printtext[booktitle]{% + \printfield[titlecase]{booktitle}% + \setunit{\subtitlepunct}% + \printfield[titlecase]{booksubtitle}}% + \newunit%标点换成下一句 + \setunit{\subtitlepunct}}% + \printfield{booktitleaddon}} + +%调整期刊名的格式,源来自standard.bbx +\renewbibmacro*{journal+issuetitle}{% + \usebibmacro{journal}% + %\setunit*{\addspace}% + %\setunit*{\addcomma\addspace}%修改为增加一个逗号 + \iffieldundef{series}% + {}% + {\newunit% + \printfield{series}% + \setunit{\addspace}}% + %\usebibmacro{volume+number+eid}% + %\setunit{\addspace}% + \usebibmacro{issue+date}% + %\setunit{\addcolon\space}% + %换成逗号和空格 + \usebibmacro{issue}% + \iffieldundef{volume}{}{\setunit{\addcomma\space}}% + \usebibmacro{volume+number+eid}%把卷期放到年份后面 + %\newunit + } + +%调整journal,首先判断子标题,然后在设置标点。避免直接设置标点后,当volume不存在是需要使用\nopuct去标点进而引入不必要的空格 +\renewbibmacro*{journal}{% + \iffieldundef{journaltitle}% + {}% + {\printtext[journaltitle]{% + \printfield[titlecase]{journaltitle}% + \iffieldundef{journalsubtitle}{}{\setunit{\subtitlepunct}% + \printfield[titlecase]{journalsubtitle}}}}} + +%调整issue+date,原在authoryear.BBX中\bbx@opt@mergedate@compact中定义 +%当issue存在时,才设置newunit。避免直接设置标点后,当volume不存在是需要使用\nopuct去标点进而引入不必要的空格 + \renewbibmacro*{issue+date}{% + \iffieldundef{issue}% + {}% + {\printtext[parens]{\printfield{issue}}\newunit}} + +%增加一个number带括号的格式,避免使用mkbibparens而引入一个不必要的空格 +\DeclareFieldFormat{addnumflag}{% +\nobreak\printtext{(}\nobreak #1\nobreak\printtext{)}} + +%调整期刊卷和期的格式,源来自standard.bbx +\renewbibmacro*{volume+number+eid}{% + \printfield{volume}% + %\setunit*{\adddot}%去掉点号 + %\printfield{number}% + \iffieldundef{number}{}{\printfield[addnumflag]{number}}% + %\iffieldundef{number}{}{\printtext{\mkbibparens{\printfield{number}}}}%增加一个圆括号 + \iffieldundef{eid}{}{% + \setunit{\addcomma\space}% + \printfield{eid}}} + +%调整页码前的标点和去掉期刊文章等页码后面的标点,源来自standard.bbx +\renewbibmacro*{note+pages}{% + %\printfield{note}%不要note,note用来判断是否是报纸newspaper + \iffieldundef{pages}{}{ + \setunit{\bibpagespunct}% + \printfield{pages}}% + %\newunit + } + +%编者类型做一修改,源来自biblatex.DEF +\renewbibmacro*{editorstrg}{% + \printtext[editortype]{% + \iffieldundef{editortype} + { +% \ifboolexpr{ %这一段去掉,未定义编者类型情况下不处理 +% test {\ifnumgreater{\value{editor}}{1}} +% or +% test {\ifandothers{editor}} +% } +% {\bibstring{editors}} +% {\bibstring{editor}} + } + {\ifbibxstring{\thefield{editortype}} %定义编者类型情况下处理,以后根据需要修改 + {\ifboolexpr{ + test {\ifnumgreater{\value{editor}}{1}} + or + test {\ifandothers{editor}} + } + {\bibstring{\thefield{editortype}s}} + {\bibstring{\thefield{editortype}}}} + {\thefield{editortype}}} + }} + +%修改期刊的标题,源来自biblatex.DEF +\renewbibmacro*{periodical}{% + \iffieldundef{title} + {} + {\printtext[title]{% + \printfield[titlecase]{title}% + %\setunit{\subtitlepunct}% + \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题 + {}{\setunit{\subtitlepunct} + \printfield[titlecase]{subtitle}}% + %}%把编组结束移到后面去 + \iffieldundef{usera}{}{%在标题后直接给出文献标识字母 + \printfield[gbtypeflag]{usera}} + }} + } + +%期刊的标题做修改,源来自standard.BBX +\renewbibmacro*{title+issuetitle}{% + \usebibmacro{periodical}% + %\setunit*{\addspace}% + \setunit*{\adddot\addspace}%标点修改为句点 + \iffieldundef{series} + {} + {\newunit + \printfield{series}% + \setunit{\addspace}}% + \usebibmacro{periodical+issue}%将issue调整到上面来,并修改 +\iffieldundef{number}{}{%%进一步处理有范围的数字 + \multinumberparser{\thefield{number}}}% + \iffieldundef{volume}% + {\printfield{year}% + \printtext{\mkbibparens{\multinumberfirst}}% + \bibrangedash% + \iffieldundef{endyear}{}{\printfield{endyear}\printtext{\mkbibparens{\multinumbersecond}}}% + }% + {\multivolparser{\thefield{volume}}% + \printfield{year}% + \setunit{\addcomma\space}%将冒号修改为逗号 + \printtext{\multivolfirst}% + \printtext{\mkbibparens{\multinumberfirst}}% + \bibrangedash% + \iffieldundef{endyear}{}{% + \printfield{endyear}% + \setunit{\addcomma\space}%将冒号修改为逗号 + \printtext{\multivolsecond}% + \printtext{\mkbibparens{\multinumbersecond}}}% + }% + \setunit{\addcomma\space}% + \printfield{eid}% + \setunit{\addspace}% + %\usebibmacro{issue+date}% + %\setunit{\addcolon\space}% + \usebibmacro{issue}% + \newunit} + +%新增一个样式用于调整期刊年份的格式,只打印年份 +\newbibmacro*{periodical+issue}{% + \printtext{%去掉了[parens] + \iffieldundef{issue} + {%\usebibmacro{date}%修改为下一句 + }% + {\printfield{issue}% + \setunit*{\addspace}% + %\usebibmacro{date}%修改为下一句 + }% + }% + %\newunit +} + +%重设专利title的输出,将文献类型标识符输出出去,原输出来自biblatex.def文件 +\newbibmacro*{patenttitle}{% + \ifboolexpr{% + test{\iffieldundef{title}}% + and% + test{\iffieldundef{subtitle}}% + }% + {}% + {\printtext[title]{% + \printfield[titlecase]{title}% + \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题 + {}{\setunit{\subtitlepunct}% + \printfield[titlecase]{subtitle}}% + \iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格 + {\setunit{\subtitlepunct}\printfield{titleaddon}}% + \setunit{\subtitlepunct}\printfield{number}%写专利号 + \printfield[gbtypeflag]{usera}% + \iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点 + %\newunit + }% +}% +} + +%修改了一个institution+location+date用于report等的,当没有institution时不处理。 +\renewbibmacro*{institution+location+date}{% + \printlist{location}% + \iflistundef{institution} + {\setunit*{\addcomma\space}} + {\setunit*{\addcolon\space}}% + \printlist{institution}% + \setunit*{\addcomma\space}% + \usebibmacro{date}% + %\usebibmacro{modifydate}% + %\newunit + } + + +%===================================================================== +%===================================================================== +%设置驱动格式 +%===================================================================== +%修改book的驱动,源来自standard.BBX +\DeclareBibliographyDriver{book}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/editor+others/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{maintitle+title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{edition}% + \newunit + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + %\printfield{note}% + %\newunit\newblock + \usebibmacro{publisher+location+date}% + \newunit\newblock + \usebibmacro{chapter+pages}% + %\newunit + \usebibmacro{doi+eprint+url}%从下面提上来 + \newunit\newblock + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock + %\usebibmacro{doi+eprint+url}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%修改inbook的驱动,源来自standard.BBX +\DeclareBibliographyDriver{inbook}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% + \setunit{\labelnamepunct}\newblock% + \usebibmacro{title}% +% \newunit +% \printlist{language}% +% \newunit\newblock +% \usebibmacro{byauthor}% +% \newunit\newblock +% \usebibmacro{in:}% + \printtext{\texttt{//}\addthinspace}% + \usebibmacro{bybookauthor}% + \ifnameundef{bookauthor}{}{\newunit\newblock}%替换下一句 + %\newunit\newblock + \usebibmacro{maintitle+booktitle}% + \newunit\newblock% + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{edition}% + \newunit + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + %\printfield{note}% + %\newunit\newblock + \usebibmacro{publisher+location+date}% + \newunit\newblock + \usebibmacro{chapter+pages}% + %\newunit\newblock + \usebibmacro{doi+eprint+url}%移到上面来 + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%collection直接用book的驱动 +\DeclareBibliographyDriver{collection}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/editor+others/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{maintitle+title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{edition}% + \newunit + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + %\printfield{note}% + %\newunit\newblock + \usebibmacro{publisher+location+date}% + \newunit\newblock + \usebibmacro{chapter+pages}% + %\newunit + \usebibmacro{doi+eprint+url}%从下面提上来 + \newunit\newblock + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock + %\usebibmacro{doi+eprint+url}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%incollection直接用inbook的驱动 +\DeclareBibliographyDriver{incollection}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% +% \newunit +% \printlist{language}% +% \newunit\newblock +% \usebibmacro{byauthor}% +% \newunit\newblock +% \usebibmacro{in:}% + \printtext{\texttt{//}\addthinspace}% + \usebibmacro{bybookauthor}% + \ifnameundef{bookauthor}{}{\newunit\newblock}%替换下一句 + %\newunit\newblock + \usebibmacro{maintitle+booktitle}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{edition}% + \newunit + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + %\printfield{note}% + %\newunit\newblock + \usebibmacro{publisher+location+date}% + \newunit\newblock + \usebibmacro{chapter+pages}% + %\newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%期刊文章,连续出版物中的析出文献的格式 + \DeclareBibliographyDriver{article}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{bytranslator+others}% + \newunit\newblock + \printfield{version}% + \newunit\newblock + %\usebibmacro{in:}% 不使用in来表示期刊等连续出版物 + \usebibmacro{journal+issuetitle}% +% \newunit +% \usebibmacro{byeditor+others}% +% \newunit + \usebibmacro{note+pages}% + \usebibmacro{doi+eprint+url}%从后面移上来,调整url和页码之间的位置 + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{issn}} + {}% + \newunit\newblock + %\usebibmacro{doi+eprint+url}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%修改连续出版物的驱动,源来自standard.BBX + \DeclareBibliographyDriver{periodical}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{editor}% + %\setunit{\labelnamepunct}\newblock + \newunit\newblock %删除上面一行,添加这一行 + \usebibmacro{title+issuetitle}% + \newunit + \usebibmacro{location+institution+date}%添加这一行用于输出地址,单位和时间 + \newunit\newblock%添加这一行 + \printlist{language}% + \newunit\newblock + \usebibmacro{byeditor}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{issn}} + {}% + \newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%处理专利文献,源来自standard.BBX + \DeclareBibliographyDriver{patent}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + %\usebibmacro{title}% + \usebibmacro{patenttitle}%给出专利专用的标题输出 + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + %\printfield{number}% + \iflistundef{location} + {} + {\setunit*{\addspace}% + \printtext[parens]{% + \printlist[][-\value{listtotal}]{location}}}% + \newunit\newblock + \usebibmacro{byholder}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \usebibmacro{newsdate}% + %\newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%处理在线文献,源来自standard.BBX +\DeclareBibliographyDriver{online}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/editor+others/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \printlist{organization}% + \newunit\newblock + %\usebibmacro{date}% + \usebibmacro{modifydate}%修改为带括号的时间 + \usebibmacro{url+urldate}%从下面移上来 + \newunit\newblock + \iftoggle{bbx:eprint} + {\usebibmacro{eprint}} + {}% + \newunit\newblock + %\usebibmacro{url+urldate}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%学位论文修改,源来自standard.BBX + \DeclareBibliographyDriver{thesis}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \printfield{type}% + \newunit + \usebibmacro{institution+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + + +%2016-11-11增加了译者信息 +\DeclareBibliographyDriver{report}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}%增加的译者信息 + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + \printfield{number}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \usebibmacro{institution+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isrn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%直接利用report做manual,2016-11-11增加了译者信息 +%\DeclareBibliographyDriver{report}{% +\DeclareBibliographyDriver{manual}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + \printfield{number}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \usebibmacro{institution+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isrn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%直接利用report做unpublished +%\DeclareBibliographyDriver{report}{% +\DeclareBibliographyDriver{unpublished}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + \printfield{number}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \usebibmacro{institution+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isrn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%会议论文格式修改,源来自standard.BBX + \DeclareBibliographyDriver{inproceedings}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{title}% +% \newunit +% \printlist{language}% +% \newunit\newblock +% \usebibmacro{byauthor}% +% \newunit\newblock + %\usebibmacro{in:}% + \printtext{\texttt{//}\addthinspace}%似乎顶格加百分号可以避免一些不必要的空格加入,特别是这种直接处理的语句前后 + \usebibmacro{bybookauthor}%用类似inbook的方式处理 + \ifnameundef{bookauthor}{}{\newunit\newblock}%替换下一句 + %\newunit\newblock + \usebibmacro{maintitle+booktitle}% + \newunit\newblock + \usebibmacro{event+venue+date}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \printlist{organization}% + \newunit + \usebibmacro{publisher+location+date}% + \newunit\newblock + \usebibmacro{chapter+pages}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} + +%会议论文集格式修改,源来自standard.BBX +\DeclareBibliographyDriver{proceedings}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + %\usebibmacro{editor+others}% + \usebibmacro{author/translator+others}% + \setunit{\labelnamepunct}\newblock + \usebibmacro{maintitle+title}% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{event+venue+date}% + \newunit\newblock +% \usebibmacro{byeditor+others}% +% \newunit\newblock + \iffieldundef{maintitle} + {\printfield{volume}% + \printfield{part}} + {}% + \newunit + \printfield{volumes}% + \newunit\newblock + \usebibmacro{series+number}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \printlist{organization}% + \newunit + \usebibmacro{publisher+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}} diff --git a/Biblio/gb7714-2015ay.cbx b/Biblio/gb7714-2015ay.cbx new file mode 100755 index 0000000..509dae1 --- /dev/null +++ b/Biblio/gb7714-2015ay.cbx @@ -0,0 +1,102 @@ +%% +%% --------------------------------------------------------------- +%% biblatex-gb7714-2015 --- A biblatex implementation of the +%% GBT7714-2015 citation style,author year sequence +%% Maintained by huzhenzhen +%% history: +%% 2016/05/20 v1.0 2016/10/23 v1.0a 2016/11/11 v1.0b +%% 2016/11/14 v1.0c 2016/11/24 v1.0d 2016/12/07 v1.0e +%% 2017/02/26 v1.0g 2017/04/11 v1.0h +%% 2017/11/21 v1.0i 2018/01/20 v1.0j +%% E-mail: hzzmail@163.com +%% Released under the LaTeX Project Public License v1.3c or later +%% --------------------------------------------------------------- +%% +\ProvidesFile{gb7714-2015ay.cbx}[2018/01/20 v1.0j biblatex citation style] + +\RequireCitationStyle{authoryear} +%\RequireCitationStyle{numeric} + +\defversion{3.4}{cbxopt}{ + \ExecuteBibliographyOptions{ + %autocite = superscript , + %autopunct = true , + %sorting = none , + maxcitenames=1, + mincitenames=1, + uniquename=init,%因为使用了名字缩写选项,所以需要设置uniquename=init而不是full避免冲突 + labeldate=true, + uniquelist=minyear + } +} + +\defversion{3.7}{cbxopt}{ + \ExecuteBibliographyOptions{ + %autocite = superscript , + %autopunct = true , + %sorting = none , + maxcitenames=1, + mincitenames=1, + uniquename=init,%因为使用了名字缩写选项,所以需要设置uniquename=init而不是full避免冲突 + labeldateparts=true, + %labeldate=true, + uniquelist=minyear %minyear, + } +} + +\iftoggle{iftlfive}{\switchversion{3.4}{cbxopt}}{}%biblatex<=3.2 +\iftoggle{iftlsix}{\switchversion{3.4}{cbxopt}}{}%3.3<=biblatex<=3.6 +\iftoggle{iftlseven}{\switchversion{3.7}{cbxopt}}{}%biblatex=3.7 +\iftoggle{iftleight}{\switchversion{3.7}{cbxopt}}{}%3.8<=biblatex<=3.9 +\iftoggle{iftlatest}{\switchversion{3.7}{cbxopt}}{}%biblatex最新3.10 + +%当条目是set时,所有的信息都没有于是利用entrykey来给出标签,那么就要set的条目关键字是需要的字符串,注意字符串中间不能有空格 +\renewbibmacro*{cite:label}{% + \iffieldundef{label}% + {\iffieldundef{labeltitle}{\printtext[bibhyperref]{\printfield{entrykey}}}%entrykey + {\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}}% + {\printtext[bibhyperref]{\printfield{label}}}} + +%\DeclareCiteCommand{\cite}[\mkbibparens]{⟨precode⟩}{⟨loopcode⟩}{⟨sepcode⟩}{⟨postcode⟩} +\DeclareCiteCommand{\cite}[\mkbibparens] + {\usebibmacro{prenote}} + {\usebibmacro{citeindex}% + \usebibmacro{cite}} + {\multicitedelim} + {\usebibmacro{postnote}} + +\DeclareCiteCommand{\parencite}[\mkbibparens] + {\usebibmacro{prenote}} + {\usebibmacro{citeindex}% + \usebibmacro{cite}} + {\multicitedelim} + {\usebibmacro{postnote}} + +\newbibmacro*{postpages}{% + \iffieldundef{postnote} + {\printfield{pages}} + {\printfield{postnote}}} + +%修改括号外带页码的引用格式 +\DeclareFieldFormat{postnote}{#1} + +\DeclareCiteCommand{\pagescite} + {\printtext{(}\usebibmacro{prenote}} + {\usebibmacro{citeindex}% + \usebibmacro{cite}} + {\multicitedelim} + {\printtext{)}\textsuperscript{\usebibmacro{postpages}}} + +%增加一个命令yearpagescite用于当文中作者已经存在,需要页码和年份的情况。 +%参考来源,biblatex.DEF,其中\DeclareCiteCommand*{\citeyear}命令 +\DeclareCiteCommand{\yearpagescite} + {\printtext{(}\usebibmacro{prenote}} + {\printfield{year}\printfield{extrayear}} + {\multicitedelim} + {\printtext{)}\textsuperscript{\usebibmacro{postpages}}} + +\DeclareCiteCommand{\yearcite}%仅输出年份,不要页码 + {\printtext{(}\usebibmacro{prenote}} + {\printfield{year}\printfield{extrayear}} + {\multicitedelim} + {\printtext{)}} diff --git a/README.md b/README.md index 5bd6dc8..b2e2b03 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,8 @@ 用过 latex 就会知道它的好,但是没有模板的时候真的很痛。所以“NUDT 硕士博士研究生开题报告 latex 模板”应运而生了。 -这里必须吐槽: - -+ 我校的开题报告竟然放在一个表里!!!这在全国高校里不多见。 -+ 开题报告的文献竟然也是放在表格里,这个罕见的设定让作者足足抓狂了三天。并且还留下了一个会带来一点点不方便的 BUG。 - # 更新日志 - -- 2021.08.29 更换字体为Windows TTF字体,与硕博论文模版[NUDT Thesis](https://github.com/TomHeaven/nudt_thesis)保持一致。 +- 2023.03.08 修复中文参考文献多作者时显示异常的BUG;修复参考文献放入表格需要需要繁琐操作的问题,现在你无需再关注\enabletablebib选项了。 - 2018.08.21 修正部分错误,更新 readme 文件 - 2018.03.24 更新为二〇一八年一月版本格式 - 2017.03.09 修正了参考文献文件不能被 texstudio 自动检测到的问题。 @@ -24,18 +18,11 @@ nudtProposal.tex 中的注释已有详细说明: ``` %%%%% --------------提示:修改本节内容用于设置文档,请仔细阅读--------------------- %% -%% 编译环境:texlive-2015。 -%% 推荐IDE:texstudio(WinXXX 太挫了)。 +%% 编译环境:texlive-2015或者texlive-2019。 +%% 推荐IDE:texstudio。 %% 编译选项:tex 编译器选择 xelatex,参考文献编译器选择 biber(不能用bibtex)! %% 以上环境配置经过作者测试,确定可以正常使用。 -%%%%% ---------------提示:本参数提供一个参考文献格式 BUG 的临时解决方案------------ -% 是否将参考文献放入表格。这个选项的设置因为参考文献格式有一个暂时无解的 BUG。设置为 yes 之前, -% 必须先设置为 no 编译一次。否则正文中引用数字都是 0。 -% 最终提交前将此参数改为 yes 编译一次。注意:设置为yes后编译第二次就会出现正文中引用数字都是 0 的 BUG! -% 如果设置为 yes 后,还需要修改正文,那么改为 no,编译两次参考文献才会正常! -\enabletablebib{no} % 最终提交前将此参数改为 yes 编译一次! 如需修改正文,改为 no 后编译两次参考文献才会正常! - %% 以下参数用于设置文档首页和页眉信息 \proposaltype{doctor} % 研究生类别:硕士设置为 master,博士设置为 doctor \enabletableofcontents{no} % 是否生成目录:如果需要目录设置为 yes,否则设置为 no。我校开题报告默认没有目录 @@ -102,15 +89,6 @@ nudtProposal.tex 中的注释已有详细说明: 作者在使用中发现个别时候 texstudio 并不能自动检测到参考文献更新了,故而提供一种手动更新参考文献的方法:执行“工具”->“编译”(快捷键F6);执行“工具”->“命令”->“biber”(可以在选项中设置这个命令的快捷键为 F4);再次执行编译。这样参考文献就手动更新了。 - -## 2. 安装依赖的字体 - -从以下链接中下载ttf.zip,并逐个安装: -https://github.com/TomHeaven/nudt_thesis/releases/tag/v1.1 - -## 3. 编译时报错bbl文件中找不到citation -确认texstudio中参考文献编译器设置为`biber`,而非`bibtex`。 - # 免责声明 本模板免费提供于同学们使用或修改,但 is provided "As IS"。使用本模板产生的任何问题作者不承担任何直接或者间接责任。但作者会尽力帮助有需要的同学解决问题。 diff --git a/Style/nudtstyle.sty b/Style/nudtstyle.sty index 61f4679..6dc1be0 100644 --- a/Style/nudtstyle.sty +++ b/Style/nudtstyle.sty @@ -30,8 +30,7 @@ \titleformat{\subsubsection}{\kaishu \zihao{5}}{\thesubsubsection}{5 pt}{} \titlespacing*{\subsubsection} {0pt}{0ex}{.2ex} % 定义upcite -\newcommand{\upcite}[1]{\textsuperscript{ [\cite{#1}] }} % 中文引用 -%\newcommand{\upcite}[6]{\textsuperscript{ [\cite{#1,#2,#3,#4,#5,#6}] }} % 中文引用 +%\newcommand{\upcite}[1]{\textsuperscript{ [\cite{#1}] }} % 中文引用 \newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}} % 单元格换行 % 首页图案 diff --git a/nudtProposal.tex b/nudtProposal.tex index c6a9e27..814e389 100644 --- a/nudtProposal.tex +++ b/nudtProposal.tex @@ -38,10 +38,15 @@ %% [table] % enable a table package for complex tables, default is ctable %% [math] % enable some extra math packages \usepackage{Style/custom}% user defined commands -\usepackage[backend=biber, style=Biblio/nudtcaspervector,utf8, sorting=none]{biblatex} % 设定引用格式 +\usepackage[backend=biber, bibstyle=gb7714-2015,%nature,%%加载biblatex宏包,使用参考文献 +citestyle=gb7714-2015,%,backref=true%%其中后端backend使用biber +gbnamefmt=lowercase, +gbpub=false % 是否显示“未知出版商”等信息从而更加符合gb7714-2015样式 +]{biblatex}%标注(引用)样式citestyle,著录样式bibstyle都采用gb7714-2015样式 % 设置参考文献文件 \addbibresource{Biblio/ref.bib} \usepackage{Style/nudtstyle} % 包含作者自定义的格式和命令 +\enabletablebib{yes} % 参考文献是否放入表格,默认yes。 %%%%% --------------------------------------------------------------------------------- %%%%% ---------------警告:以上内容请勿随意修改,除非你清楚自己在做什么------------ @@ -49,18 +54,11 @@ %%%%% --------------提示:修改本节内容用于设置文档,请仔细阅读--------------------- %% -%% 编译环境:texlive-2015。 -%% 推荐IDE:texstudio(WinXXX 太挫了)。 +%% 编译环境:texlive-2015或者texlive-2019。 +%% 推荐IDE:texstudio。 %% 编译选项:tex编译器选择xelatex, 参考文献编译器选择biber(不能用bibtex)! %% 以上环境配置经过作者测试,确定可以正常使用。 -%%%%% ---------------提示:本参数提供一个参考文献格式BUG的临时解决方案------------ -% 是否将参考文献放入表格。这个选项的设置因为参考文献格式有一个暂时无解的BUG。设置为yes之前之前,必须先 -% 设置为no编译一次。否则正文中引用数字都是0。 -% 最终提交前将此参数改为yes编译一次。注意:设置为yes后编译第二次就会出现正文中引用数字都是0的BUG! -% 如果设置为yes后,还需要修改正文,那么改为no,编译 两次 参考文献才会正常! -\enabletablebib{no} % 最终提交前将此参数改为yes编译一次! 如需修改正文,改为no后编译两次参考文献才会正常! - %% 以下参数用于设置文档首页和页眉信息 \proposaltype{doctor} % 研究生类别:硕士设置为master,博士设置为doctor \enabletableofcontents{no} % 是否生成目录:如果需要目录设置为yes,否则设置为no。我校开题报告默认没有目录