-
Notifications
You must be signed in to change notification settings - Fork 84
/
gb7714-NWAFU.bbx
434 lines (398 loc) · 13.6 KB
/
gb7714-NWAFU.bbx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
%%
%% ---------------------------------------------------------------
%% NWAFUthesis.bbx --- A bibliography style for NWAFUthesis template
%% ---------------------------------------------------------------
%%
%%用法:类似于标准的样式在biblatex加载时设置样式
%%文献表正常处理,标注命令主要用cite和parencite
\ProvidesFile{gb7714-NWAFU.bbx}
[2022/03/10 v0.1 a biblatex bibliography style for NWAFUthesis]
%==================================================
%加载gb样式
%==================================================
\RequireBibliographyStyle{gb7714-2015ay}
%==================================================
%选项设置
%==================================================
\ExecuteBibliographyOptions{
sortlocale=zh__pinyin,
gbpub=false,
gbtype=false,
maxbibnames=99,% 著录所有作者
minbibnames=1,
gbnamefmt=familyahead,
%url=false,
doi=false,
isbn=false,
gbfieldtype=true,
gbpunctin=false,
uniquename=false,
uniquelist=false,
nohashothers=false,
}
%==================================================
%一些字体设置
%==================================================
%\def\bibrangedash{$\sim$}% 表示范围的波浪线符号
\DefineBibliographyExtras{english}{\renewcommand*{\bibrangedash}{\iffieldequalstr{userd}{chinese}%
{$\sim$}{\textendash\penalty\hyphenpenalty}}}
%\newcommand\nwafubibfont{\linespread{1.0}\zihao{-5}}% 字体
\newcommand\nwafubibfont{\zihao{5}}% 字体
\renewcommand{\bibfont}{\nwafubibfont}% 全局字体设置
\setlength{\bibitemsep}{2pt}%0ex
\setlength{\bibnamesep}{0ex}
\setlength{\bibinitsep}{0ex}
%==================================================
%为标注和文献表中标点格式,重设and本地化字符串
%==================================================
\DefineBibliographyStrings{english}{
andincitecn = {和},%将标注中的分开,便于与文献表中的区分
andincite = {and},
mathesiscn={[硕士学位论文]},
phdthesiscn={[博士学位论文]},
in={In:\addspace},
incn={见:\addspace},
}
%==================================================
%设置一些标点格式为中文的标点
%==================================================
\renewcommand{\postnotedelim}{\addcolon\space}
\renewcommand*{\nameyeardelim}{\addspace}
\DeclareDelimFormat[bib,biblist]{nameyeardelim}{\addperiod\space}
\DeclareFieldFormat{postnote}{#1}
\def\gbcaselocalset{%
\renewrobustcmd*{\bibinitperiod}{}%
\renewcommand*{\revsdnamepunct}{}%
%\renewrobustcmd*{\bibinitdelim}{}%
}
\renewbibmacro*{name:family-given}[4]{%
\gbcaselocalset%
\ifuseprefix
{\usebibmacro{name:delim}{#3#1}%
\usebibmacro{name:hook}{#3#1}%
\mkbibcompletenamefamilygiven{%
\ifdefvoid{#3}
{}
{\ifcapital
{\mkbibnameprefix{\MakeCapital{#3}}\isdot}
{\mkbibnameprefix{#3}\isdot}%
\ifprefchar{}{\bibnamedelimc}}%
\mkbibnamefamily{#1}\isdot
\ifdefvoid{#4}
{}
{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}%
\ifdefvoid{#2}
{}
{\revsdnamepunct\bibnamedelimd\mkbibnamegiven{#2}\isdot}}}
{\usebibmacro{name:delim}{#1}%
\usebibmacro{name:hook}{#1}%
\mkbibcompletenamefamilygiven{%
\mkbibnamefamily{#1}\isdot
\ifdefvoid{#4}
{}
{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}%
\ifboolexpe{%
test {\ifdefvoid{#2}}
and
test {\ifdefvoid{#3}}}
{}
{\revsdnamepunct}%
\ifdefvoid{#2}
{}
{\bibnamedelimd\mkbibnamegiven{#2}\isdot}%
\ifdefvoid{#3}
{}
{\bibnamedelimd\mkbibnameprefix{#3}\isdot}}}}
%==================================================
%调整部分域的输出格式
%==================================================
\DeclareFieldFormat[article]{journaltitle}{\iffieldequalstr{userd}{chinese}{#1}{\textit{#1}}\isdot}% 英文刊名用斜体
% “和”与“and”前后的空格调整
\DeclareDelimFormat{finalnamedelim}{%
\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
%\addspace%
\edef\userfieldabcde{userd}%
\ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
\ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
\ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
\ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
\ifcase\value{gbcitelocalcase}%
\iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andincitecn}}{}%
\iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
\iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
\iffieldequalstr{\userfieldabcde}{english}{\addspace\bibstring{andincite}\addspace}{}%
\iffieldequalstr{\userfieldabcde}{french}{\addspace\bibstring{and}\addspace}{}%
\iffieldequalstr{\userfieldabcde}{russian}{\addspace\bibstring{and}\addspace}{}%
\or%
\bibstring{andincitecn}%
\or%
\addspace\bibstring{andincite}\addspace%
\fi
}
\newbibmacro*{origdate+extradate}{%
\printtext{\printorigdate}%
}
%
% 修改译者位置格式
%
% 原理方法:修改来自biblatex.def文件的bytranslator+others宏的格式
\renewbibmacro*{bytranslator+others}{%
\ifnameundef{translator}
{}
{%\usebibmacro{bytranslator+othersstrg}
%\setunit{\addspace}%
\printnames[bytranslator]{translator}%
%\clearname{translator}%
%从macro*{bytranslator+othersstrg}%中可以看到当地化字符串格式的引用前的代码处理
%比如生成cotranslator等用于调用cotranslator所代表的当地化字符串
\usebibmacro{bytranslator+othersstrg}%“译”的位置换到下面来,即放到译者后面。
%\setunit{\addspace}%
\newunit}%
\usebibmacro{withothers}%
\ifboolexpr{%
test {\iffieldundef{origyear}} or test {\ifnameundef{translator}}%%
}{}{\printtext{\printdate}}%
}
%
% url和url日期格式
%
\renewbibmacro*{url+urldate}{%
%\usebibmacro{url}%%更换url的位置,放到下面
\usebibmacro{url}%
\iffieldundef{urlyear}%
{}{%\setunit*{\addspace}%
\usebibmacro{urldate}}}
\DeclareFieldFormat{addnumflag}{%
\ifentrytype{newspaper}{\setunit{\addcomma\addspace}\printtext{#1}}
{\nobreak\printtext{(}\nobreak #1\nobreak\printtext{)}}}
%
% 重设专利title的输出,将文献类型标识符输出出去
%
\renewbibmacro*{patenttitle}{%原输出来自biblatex.def文件
\ifboolexpr{%
test{\iffieldundef{title}}%
and%
test{\iffieldundef{subtitle}}%
}%
{}%
{\printtext[title]{\bibtitlefont%
\printfield[titlecase]{title}%
\ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题
{}{\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}%
\iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格
{\setunit{\subtitlepunct}\printfield{titleaddon}}%
\setunit{\adddot\addspace}\printfield{number}%写专利号
\iftoggle{bbx:gbtype}{\printfield[gbtypeflag]{usera}}{}%
%\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点
%\newunit
}%
}%
}
%
% 修改作者数量超过限定值,做省略时的处理格式
% v1.0,20160701,hzz
% v1.0O,20190103,hzz,修改利用新定义的一个分隔符strandothersdelim
%
% 原理方法:判断作者或译者是否中文,若中文用字符等,否则用et al. 。
\renewbibmacro*{name:andothers}{%
\ifboolexpr{
test {\ifnumequal{\value{listcount}}{\value{liststop}}}
and
test \ifmorenames
}{\ifnumgreater{\value{liststop}}{1}%
{\finalandcomma}%
{}%biblatex作者要区别单作者加等的情况,这里为符合gbt7714-2015第7.2节的要求加上了逗号。
\printdelim{andothersdelim}\printdelim{strandothersdelim}%
}{%当是译者的时候需要特殊处理:从7.2节看等,译前面加逗号,但从示例看等和译同时出现时,译前的逗号没有,比如:
%袁训来, 陈哲, 肖书海, 等.
%胡泳, 范海燕, 译.
%潘惠霞, 魏婧, 杨艳, 等译.
%\ifcurrentname{translator}{\addcomma}{}%
}}
%
% 对edition版本信息格式做出修改
%
\DeclareFieldFormat{edition}{%源来自biblatex.DEF
\testCJKfirst{userd}%
\iftoggle{ifCJKforgbt}%
{\ifinteger{#1}%
{\printtext{\bibstring{serialcn}\zhnumber{#1}\str@edition}}%
{#1\isdot}}%
{\ifinteger{#1}%
{\mkbibordedition{#1}~\bibstring{edition}}%
{#1\isdot}}}
%注意这里当没有作者只有标题时在年份之前的标点是否需要标准并未涉及,所以未做处理。
\renewbibmacro*{author}{%以前的date+extrayear变为date+extradate,所以对3.8以上版本重定义一下author
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\usebibmacro{bbx:dashcheck}
{%\bibnamedash %去掉相同作者用横线代替的处理
\printnames{author}\setunit{\printdelim{nameyeardelim}}%把标点也带上
}
{\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}}}%
\ifboolexpr{%
test {\iffieldundef{origyear}} or test {\ifnameundef{translator}}%
}{\usebibmacro{date+extradate}}%
{\usebibmacro{origdate+extradate}}%
}
%==================================================
%调整部分类型驱动
%==================================================
%
% book条目类的驱动
%
\DeclareBibliographyDriver{book}{%源来自standard.bbx文件
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
\usebibmacro{maintitle+title}%
\iftoggle{bbx:gbstrict}{}{%
\newunit
\printlist{language}%
\newunit\newblock%
\usebibmacro{byauthor}%
\newunit\newblock}%
\newunit
\printfield{edition}%
\newunit
\usebibmacro{byeditor+others}%
\newunit\newblock%%
\iftoggle{bbx:gbstrict}{}{%
\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}%
\iffieldundef{url}{}{%当没有网址时也不输出
\usebibmacro{modifydate}}%带括号的修改或更新日期,
\usebibmacro{doi+eprint+url}%从下面移动到上面来,因为gbt2015的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}}
%
% 在线文献驱动
%
\DeclareBibliographyDriver{online}{%源来自standard.BBX
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
\usebibmacro{title}%
\iftoggle{bbx:gbstrict}{}{%
\newunit%
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{note}}%
\newunit
\printfield{version}%
\newunit\newblock
% \printlist{organization}%
\printlist{institution}%
\newunit\newblock
\ifboolexpr{%
test{\iffieldundef{day}} and test{\iffieldundef{endday}} and test{\iffieldundef{eventday}}%
}{\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}}
%
% 专利文献驱动
%
\DeclareBibliographyDriver{patent}{%源来自standard.BBX
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
%\usebibmacro{title}%
\usebibmacro{patenttitle}%给出专利专用的标题输出
\iftoggle{bbx:gbstrict}{}{%
\newunit%
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}}%
\newunit\newblock
\printfield{type}%
\setunit*{\addspace}%
%\printfield{number}%已放到patenttitle中处理
\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}}