diff --git a/gb7714-2015.bbx b/gb7714-2015.bbx index 76ec1a1..0f95d50 100644 --- a/gb7714-2015.bbx +++ b/gb7714-2015.bbx @@ -56,7 +56,7 @@ %4E00-9FBF cjk统一表意符号 %中文范围4E00-9FA5 \providetoggle{ifCJKforgbt} - \def\testCJKfirstchar#1#2&{% + \def\testCJKfirstchar#1#2&{%#1#2& \ifnumgreater{`#1}{"2E7F}{\toggletrue{ifCJKforgbt}}{\togglefalse{ifCJKforgbt}}% }% @@ -521,7 +521,7 @@ %这里调整一下两种语言参考文献的间隔,源来自biblatex.def %%双语之间用newline替换par(20170411 v1.0h),避免采用gb7714-2015的项对齐方式第二语言间分段导致没有缩进 \renewcommand*{\entrysetpunct}{\adddot\newline\nobreak} -\renewcommand*{\bibpagespunct}{\addcolon\space}%%页码引用格式的修改,修改为用冒号 +\renewcommand*{\bibpagespunct}{\addcolon\addthinspace}%%页码引用格式的修改,修改为用冒号 %===================================================================== @@ -734,7 +734,7 @@ \defversion{3.7}{date}{ \DeclareFieldFormat{urldate}{##1} \renewbibmacro*{urldate}{% - \addspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 + \addthinspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 \newbibmacro*{newsdate}{%%新增加一个新闻日期 \blx@edtfdate{}{}% @@ -752,7 +752,7 @@ \defversion{3.4}{date}{ \renewbibmacro*{urldate}{% - \addspace\printtext{[}\printfield{urlyear}% + \addthinspace\printtext{[}\printfield{urlyear}% \iffieldundef{urlmonth}{}{\bibrangedash\printfield{urlmonth}}% \iffieldundef{urlday}{}{\bibrangedash\printfield{urlday}}\printtext{]}} @@ -1236,7 +1236,7 @@ %\setunit{\labelnamepunct}\newblock \usebibmacro{title}% %\nopunct -\printtext{\texttt{//}\addnbthinspace}%%\texttt{//} +\printtext{\texttt{//}\addthinspace}%%\texttt{//}\addnbthinspace \usebibmacro{bybookauthor}% \ifnameundef{bookauthor}{\newblock}{\newunit\newblock}%替换下一句 %\newunit\newblock @@ -1639,7 +1639,7 @@ {\setunit{\labelnamepunct}\newblock}% %\setunit{\labelnamepunct}\newblock \usebibmacro{title}% -\printtext{\texttt{//}\addnbthinspace}%似乎顶格加百分号可以避免一些不必要的空格加入,特别是这种直接处理的语句前后 +\printtext{\texttt{//}\addthinspace}%似乎顶格加百分号可以避免一些不必要的空格加入,特别是这种直接处理的语句前后 \usebibmacro{bybookauthor}% \ifnameundef{bookauthor}{\newblock}{\newunit\newblock}%替换下一句 %\newunit\newblock @@ -1693,7 +1693,7 @@ % \usebibmacro{byauthor}% % \newunit\newblock %\usebibmacro{in:}% - \printtext{\texttt{//}\addnbthinspace}%似乎顶格加百分号可以避免一些不必要的空格加入,特别是这种直接处理的语句前后 + \printtext{\texttt{//}\addthinspace}%似乎顶格加百分号可以避免一些不必要的空格加入,特别是这种直接处理的语句前后 \usebibmacro{bybookauthor}%用类似inbook的方式处理 \ifnameundef{bookauthor}{\newblock}{\newunit\newblock}%替换下一句 %\newunit\newblock diff --git a/gb7714-2015ay.bbx b/gb7714-2015ay.bbx index a541cbc..9eb870c 100644 --- a/gb7714-2015ay.bbx +++ b/gb7714-2015ay.bbx @@ -54,7 +54,7 @@ %4E00-9FBF cjk统一表意符号 %中文范围4E00-9FA5 \providetoggle{ifCJKforgbt} -\def\testCJKfirstchar#1#2&{% +\def\testCJKfirstchar#1#2&{%#1#2& \ifnumgreater{`#1}{"2E7F}{\toggletrue{ifCJKforgbt}}{\togglefalse{ifCJKforgbt}}% }% @@ -317,9 +317,17 @@ backrefpages = {引用页:}, \step[fieldset=userf, origfieldval] \step[fieldsource=translator] \step[fieldset=usere, origfieldval] - \step[fieldsource=year]%处理一些用year表示date的情况 + } + \map{%处理一些用year表示date的情况 + %这样处理将会设置date域,并使得labeldatesource变为空,因为date的前缀为空(如果是urldate,那么labeldatesource就是url)。 + %同时date域会被biblatex自动解析为year,month,day,并且覆盖原来的year信息 + \step[fieldsource=year] \step[fieldset=date, origfieldval] } + \map{ + \step[fieldsource=title]%将title信息保存到userd中避免因为标签生成原因导致title域被清除 + \step[fieldset=userd, origfieldval] + } \map{%将entrykey放入keywords中用于后期的使用 \step[fieldsource=entrykey] \step[fieldset=keywords, origfieldval] @@ -505,7 +513,7 @@ backrefpages = {引用页:}, %设置排序格式 %===================================================================== %排序用降序或userb域 -\defversion{3.7}{sort}{ +\defversion{3.7}{sort}{%这是3.4版的,3.7版略有差异,但不大,后面有注释 \DeclareSortingScheme{nyt}{ \sort{ \field{presort} @@ -533,8 +541,8 @@ backrefpages = {引用页:}, \field{title} } \sort{ - \field[padside=left,padwidth=4,padchar=0]{volume} - \literal{0000} + \field[padside=left,padwidth=4,padchar=0]{volume}%3.7版是\field{volume} + \literal{0000}%3.7版是\literal{0} } } } @@ -567,8 +575,8 @@ backrefpages = {引用页:}, \field{title} } \sort{ - \field[padside=left,padwidth=4,padchar=0]{volume} - \literal{0000} + \field{volume} + \literal{0} } } } @@ -611,7 +619,7 @@ backrefpages = {引用页:}, %双语言或多语言的参考文献,可以参考3.11.5 Entry Sets,4.11.1 Entry Sets %这里调整一下两种语言参考文献的间隔,%源来自biblatex.def \renewcommand*{\entrysetpunct}{\adddot\par\nobreak} -\renewcommand*{\bibpagespunct}{\addcolon\space}%页码引用格式的修改%修改为用冒号 +\renewcommand*{\bibpagespunct}{\addcolon\addthinspace}%页码引用格式的修改%修改为用冒号 %===================================================================== @@ -789,7 +797,7 @@ backrefpages = {引用页:}, \defversion{3.7}{date}{ \DeclareFieldFormat{urldate}{##1} \renewbibmacro*{urldate}{% - \addspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 + \addthinspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 \newbibmacro*{newsdate}{%%新增加一个新闻日期 \blx@edtfdate{}{}% @@ -878,7 +886,7 @@ backrefpages = {引用页:}, %对edition版本信息做出修改,源来自biblatex.DEF \DeclareFieldFormat{edition}{% -\iffieldundef{title}{}{\testCJKfirst{\thefield{title}}}% +\iffieldundef{title}{}{\testCJKfirst{\thefield{userd}}}% \ifinteger{#1}% {\iftoggle{ifCJKforgbt}{\printtext{#1版}}% {\mkbibordedition{#1}~\bibstring{edition}}}% @@ -886,13 +894,13 @@ backrefpages = {引用页:}, %对version的版本信息做出修改,源来自biblatex.DEF \DeclareFieldFormat{version}{% -\iffieldundef{title}{}{\testCJKfirst{\thefield{title}}}% +\iffieldundef{title}{}{\testCJKfirst{\thefield{userd}}}% \ifinteger{#1}% {\iftoggle{ifCJKforgbt}{\printtext{#1版}}% {\mkbibordedition{#1}~\bibstring{version}}}% {#1\isdot}} -\renewbibmacro*{author}{% +\renewbibmacro*{author}{%author for biblatex version <=3.7 \ifboolexpr{ test \ifuseauthor and @@ -937,17 +945,51 @@ backrefpages = {引用页:}, \renewbibmacro*{date+extrayear}{% \iffieldundef{labelyear} {} - {\printtext{%[parens]%这里把括号去掉 + {\printtext[parens]{% \iffieldsequal{year}{labelyear} {\printlabeldateextra}% {\printfield{labelyear}% \printfield{extrayear}}}}}% } +\defversion{3.8}{dateextra}{ +\DeclareDelimFormat{nameyeardelim}{\addcomma\space} +\renewbibmacro*{author}{% + \ifboolexpr{ + test \ifuseauthor + and + not test {\ifnameundef{author}} + } + {\usebibmacro{bbx:dashcheck} + {}%\bibnamedash %去掉相同作者用横线代替的处理 + {\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}%%根据texlive/biblatex版本选择 {\switchversion{3.4}{dateextra}}% {\iftoggle{iftlsix}% {\switchversion{3.4}{dateextra}}% - {\switchversion{3.7}{dateextra}}% + {\iftoggle{iftlseven}% + {\switchversion{3.7}{dateextra}}% + {\switchversion{3.8}{dateextra}}% + }% } %修改译者位置格式,bytranslator+others原格式来自biblatex.def文件 @@ -971,7 +1013,8 @@ backrefpages = {引用页:}, test \ifmorenames } {%这里做一个判断是在处理author还是translator用于两者是不同语言的情况 - \ifcurrentname{translator}{\testCJKfirst{\thefield{usere}}}{\testCJKfirst{\thefield{userf}}}% + \ifcurrentname{translator}{\iffieldundef{usere}{\togglefalse{ifCJKforgbt}}{\testCJKfirst{\thefield{usere}}}}% + {\iffieldundef{usere}{\togglefalse{ifCJKforgbt}}{\testCJKfirst{\thefield{userf}}}}% %这句判断如果放到\andothersdelim后面会在等或etc.前增加一个空格,所以放前面 \ifnumgreater{\value{liststop}}{1} {\finalandcomma} @@ -988,7 +1031,7 @@ backrefpages = {引用页:}, %新增一个样式用于输出连续出版物的地址,单位,时间,%类似\newbibmacro*{publisher+location+date} \newbibmacro*{location+institution+date}{% \iftoggle{bbx:gbpub}% -{\testCJKfirst{\thefield{title}} +{\testCJKfirst{\thefield{userd}} \iflistundef{location}{\iftoggle{ifCJKforgbt}{\printtext{[出版地不详]}}{\printtext{[S.l.\adddot]}}}% {\printlist{location}}% % \iflistundef{institution} @@ -1018,7 +1061,7 @@ backrefpages = {引用页:}, \renewbibmacro*{publisher+location+date}{% \iftoggle{bbx:gbpub}% -{\testCJKfirst{\thefield{title}}% +{\testCJKfirst{\thefield{userd}}% \iflistundef{location}{%\adddot \iffieldequalstr{note}{standard}{}{%从gbt7714-2015标准第19页看到,标准存在出版项时输出,没有时完全省略。 \iftoggle{ifCJKforgbt}{\printtext{[出版地不详]}\addcolon\addspace}{\printtext{[S.l.\adddot]}\addcolon\addspace}% @@ -1322,7 +1365,7 @@ backrefpages = {引用页:}, % \usebibmacro{byauthor}% % \newunit\newblock % \usebibmacro{in:}% - \printtext{\texttt{//}\addnbthinspace}% + \printtext{\texttt{//}\addthinspace}% \usebibmacro{bybookauthor}% \ifnameundef{bookauthor}{}{\newunit\newblock}%替换下一句 %\newunit\newblock @@ -1429,7 +1472,7 @@ backrefpages = {引用页:}, % \usebibmacro{byauthor}% % \newunit\newblock % \usebibmacro{in:}% - \printtext{\texttt{//}\addnbthinspace}% + \printtext{\texttt{//}\addthinspace}% \usebibmacro{bybookauthor}% \ifnameundef{bookauthor}{}{\newunit\newblock}%替换下一句 %\newunit\newblock @@ -1813,7 +1856,7 @@ backrefpages = {引用页:}, % \usebibmacro{byauthor}% % \newunit\newblock %\usebibmacro{in:}% - \printtext{\texttt{//}\addnbthinspace}%似乎顶格加百分号可以避免一些不必要的空格加入,特别是这种直接处理的语句前后 + \printtext{\texttt{//}\addthinspace}%似乎顶格加百分号可以避免一些不必要的空格加入,特别是这种直接处理的语句前后 \usebibmacro{bybookauthor}%用类似inbook的方式处理 \ifnameundef{bookauthor}{}{\newunit\newblock}%替换下一句 %\newunit\newblock diff --git a/gb7714-2015ay.cbx b/gb7714-2015ay.cbx index 7205f9a..eb7362e 100644 --- a/gb7714-2015ay.cbx +++ b/gb7714-2015ay.cbx @@ -17,7 +17,7 @@ \RequireCitationStyle{authoryear} %\RequireCitationStyle{numeric} -\defversion{3.7}{cbxopt}{ +\defversion{3.4}{cbxopt}{ \ExecuteBibliographyOptions{ %autocite = superscript , %autopunct = true , @@ -30,7 +30,7 @@ } } -\defversion{3.8}{cbxopt}{ +\defversion{3.7}{cbxopt}{ \ExecuteBibliographyOptions{ %autocite = superscript , %autopunct = true , @@ -45,12 +45,12 @@ } \iftoggle{iftlfive} - {\switchversion{3.7}{sort}}%%当采用texlive2015以下版本时 + {\switchversion{3.4}{sort}}%%当采用texlive2015以下版本时 {\iftoggle{iftlsix}% - {\switchversion{3.7}{sort}}%%当采用texlive2016版本时 + {\switchversion{3.4}{sort}}%%当采用texlive2016版本时 {\iftoggle{iftlseven}% {\switchversion{3.7}{sort}}%%当采用texlive2017版本时 - {\switchversion{3.8}{sort}}%%当采用biblatex3.8a版本时 + {\switchversion{3.7}{sort}}%%当采用biblatex3.8a版本时 }% }