-
Notifications
You must be signed in to change notification settings - Fork 4
/
gb7714-CCNU.bbx
464 lines (423 loc) · 17.9 KB
/
gb7714-CCNU.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
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
%%
%% ---------------------------------------------------------------
%% gb7714-CCNU.bbx --- A bibliography style for CCNUthesis template
%% ---------------------------------------------------------------
%%
%%用法:类似于标准的样式在biblatex加载时设置样式
%%文献表正常处理,标注命令主要用cite和parencite
\ProvidesFile{gb7714-CCNU.bbx}
[2022/03/10 v0.1 a biblatex bibliography style for CCNUthesis]
%关于格式和bib文件的注意点
%1. bib文件按照正常的模式写,除了patent将国别放到number里。
%2. bib文件中会议文集和会议论文区分清楚,会议论文是带in的那种。若会议文集有附加的出版信息请一并放入publisher中。
%3. 标识为J的都是article,不管是否有url,所以不是online。
%4. 若inbook需要给出主编这种信息,需要给出editortype域,否则就当bookauthor处理。
%==================================================
%加载gb样式
%==================================================
\RequireBibliographyStyle{gb7714-2015}
% 增加一个控制标点是英文还是中文的选项
\DeclareBibliographyOption{CCNUpunctcn}[false]{%biblatex低版本
\ifstrequal{#1}{false}{\execpuncten}{}
}
%==================================================
%选项设置
%==================================================
\ExecuteBibliographyOptions{
gbpunctin = false,
gbfieldtype = true, % 输出type域,主要处理学位论文
gbnamefmt=lowercase
}
% 根据《通知》调整间距和缩进
\setlength{\biblabelsep}{0.5em}
\setlength{\bibitemindent}{0em} % bibitemindent表示一条文献中第一行相对后面各行的缩进
\setlength{\bibhang}{1.2ex}
\setlength{\bibparsep}{0em}
%这里把\bibhang放外面设置的方式也有其优势
%这里使用\bibhang+\labelnumberwidth来控制文献内容左边界与页边的间距
%然后用\biblabelsep来设置标签域文献内容左边界的间距
%gb7714-2015中则直接用\bibhang=\biblabelsep+\labelnumberwidth来控制文献内容左边界与页边的间距
%这其实是两种控制方式,CCNU这里用下面重定义的方式
\defbibenvironment{bibliography}
{\list
{\printtext[labelnumberwidth]{%
\printfield{labelprefix}%
\printfield{labelnumber}}}
{\addtolength{\labelnumberwidth}{\biblabelextend}%
\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\labelsep}{\biblabelsep}%
\setlength{\leftmargin}{\bibhang}%
\addtolength{\leftmargin}{\labelnumberwidth}%
\setlength{\itemindent}{\bibitemindent}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
%==================================================
% 定义一些标点为中文全角标点
%==================================================
\def\gbpunctdot{.}%
\def\gbpunctdotlanen{\adddot\addspace}%
\def\gbpunctmark{、}%
\def\gbpunctcomma{,}%
\def\gbpunctcommalanen{\addcomma\addspace}%
\def\gbpunctcolon{:}%
\def\gbpunctcolonlanen{\addcolon\addspace}%
\def\gbpunctsemicolon{;}%
\def\gbpunctsemicolonlanen{\addsemicolon\addspace}%
\def\gbpunctparenl{(}%
\def\gbpunctparenr{)}%
\def\execpuncten{%
\def\gbpunctdot{\adddot\addspace}%
\def\gbpunctdotlanen{\adddot\addspace}%
\def\gbpunctmark{\addcomma\addspace}%
\def\gbpunctcomma{\addcomma\addspace}%
\def\gbpunctcommalanen{\addcomma\addspace}%
\def\gbpunctcolon{\addcolon\addspace}%
\def\gbpunctcolonlanen{\addcolon\addspace}%
\def\gbpunctsemicolon{\addcolon\addspace}%
\def\gbpunctsemicolonlanen{\addsemicolon\addspace}%
\def\gbpunctparenl{(}%
\def\gbpunctparenr{)}%
}
%==================================================
%为标注和文献表中标点格式,重设and本地化字符串
%==================================================
\DefineBibliographyStrings{english}{
and = {\addcomma\space},
andcn = {\gbpunctcomma},
andincitecn = {和}, %将标注中的分开,便于与文献表中的区分
andincite = {\&},
andothers = {et al.},
andotherscn = {等},
bytranslator = {\addcomma\ 译},
bytranslatorcn = {译},
editors = {\MakeLowercase{eds}\adddot\isdot},
editor = {\MakeLowercase{ed}\adddot\isdot},
in = {In:\addspace},
incn = {见\iffieldequalstr{userd}{chinese}{\gbpunctcolon}{\gbpunctcolonlanen}},
mathesis = {(Master dissertation)},
mathesiscn = {[硕士学位论文]},
phdthesis = {(Ph D dissertation)},
phdthesiscn = {[博士学位论文]},
}
%==================================================
%设置一些标点格式为中文的标点
%==================================================
\DeclareFieldFormat*{title}{\iffieldequalstr{userd}{chinese}{#1}{#1\isdot}}
\DeclareFieldFormat[book]{title}{#1}
\def\gbcaselocalset{%
\renewrobustcmd*{\bibinitperiod}{}%
\renewcommand*{\revsdnamepunct}{}%
%\renewrobustcmd*{\bibinitdelim}{}%
}
\renewcommand{\aftertransdelim}{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}
\DeclareDelimFormat{multinamedelim}{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%\addcomma\addspace
\DeclareDelimFormat{finalnamedelim}{%
\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}{\space\bibstring{andincite}\space}{}%
\iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
\iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
\or%
\bibstring{andincitecn}%
\or%
\bibstring{andincite}%
\fi}
\DeclareDelimFormat[bib,biblist]{finalnamedelim}{%
\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{gbbiblocalcase}%
\iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andcn}}{}%
\iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
\iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
\iffieldequalstr{\userfieldabcde}{english}{\bibstring{and}}{}%
\iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
\iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
\or%
\bibstring{andcn}%
\or%
\bibstring{and}%
\fi%
}
\DeclareDelimFormat[bib,biblist]{andothersdelim}{%
\ifcurrentname{translator}{\iffieldequalstr{usere}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}{}%
\ifcurrentname{author}{\iffieldequalstr{userf}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}{}%
\ifcurrentname{editor}{\iffieldequalstr{userc}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}{}%
}
\DeclareDelimFormat{nameyeardelim}{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%\addcomma\addspace
\DeclareDelimFormat[bib,biblist]{nameyeardelim}{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%\addcomma\addspace
\DeclareDelimFormat{bibpagespunct}{\iffieldequalstr{userd}{chinese}{\gbpunctcolon}{\gbpunctcolonlanen}}%\addcomma\addspace\mbox{}
\renewcommand*{\newunitpunct}{\iffieldequalstr{userd}{chinese}{\gbpunctdot}{\gbpunctdotlanen}}%\addcomma\space %,
\renewcommand*{\finentrypunct}{\iffieldequalstr{userd}{chinese}{\gbpunctdot}{\adddot}}
\renewcommand{\publocpunct}{\iffieldequalstr{userd}{chinese}{\gbpunctcolon}{\addcolon\addspace}}%出版项中:出版社地址后面的标点
%==================================================
%调整部分域的输出格式
%==================================================
%
% 调整期刊名的格式
%
% v1.0k,20180425,增加了字体控制命令,hzz
\renewbibmacro*{journal+issuetitle}{\bibpubfont%源来自standard.bbx
\usebibmacro{journal}%
\setunit*{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%修改为增加一个逗号
\iffieldundef{series}
{}
{\newunit
\printfield{series}%
\setunit{\addspace}}%
\usebibmacro{issue+date}%
%\setunit{\addcolon\space}%
\iffieldundef{volume}{}{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%
%换成逗号和空格
\usebibmacro{issue}%
\usebibmacro{volume+number+eid}%把卷期放到年份后面
%\newunit
}
%
% 调整期刊卷和期的格式
%
\renewbibmacro*{volume+number+eid}{%源来自standard.bbx
\iftoggle{bbx:gbfieldstd}{%
\printfield{volume}%
\setunit*{\adddot}%
\printfield{number}%
\setunit{\addcomma\space}%
\printfield{eid}}{%
\printfield{volume}%
%\setunit*{\adddot}%去掉点号
%\printfield{number}%
\iffieldundef{number}{}{%
\iffieldequalstr{entrysubtype}{news}{\printtext{\mkbibparens{\printfield{number}}}}{%
\iffieldequalstr{userd}{chinese}{\printtext{\gbpunctparenl\printfield{number}\gbpunctparenr}}%
{\printtext{\mkbibparens{\printfield{number}}}}}%
}%增加一个圆括号
\iffieldundef{eid}{}{%
\setunit{\addcomma\space}%
\printfield{eid}}}}
% 新增一个样式用于输出连续出版物的地址,单位,时间,
% 用于periodical连续出版物的出版社和地址的处理
%
% v1.0k,20180425,为出版信息增加字体控制命令,hzz
% %类似\newbibmacro*{publisher+location+date}
\renewbibmacro*{location+institution+date}{\bibpubfont%
\iftoggle{bbx:gbpub}%
{\testCJKfirst{userd}%
\ifboolexpr{%
test {\iflistundef{location}} and test {\iflistundef{institution}}%
}{\iftoggle{ifCJKforgbt}{\printtext{[\str@noaddress}\space :\space\str@nopublisher]}%
{\printtext{[S.l.\space :\space s.n.\adddot]}}%
}{%
\iflistundef{location}{\iftoggle{ifCJKforgbt}{\printtext{[\str@noaddress]}}{\printtext{[S.l.\adddot]}}}%
{\printlist{location}}%
\publocpunct%
\iflistundef{institution}{%
\iftoggle{ifCJKforgbt}{\printtext{[\str@nopublisher]}}{\printtext{\mkbibbrackets{s.n.}}}}%
{\printlist{institution}}}%
\setunit{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%
%\usebibmacro{date}%
\printfield{year}%
\bibrangedash%
\iffieldundef{endyear}{}{\printfield{endyear}}%
\newunit}%
{\printlist{location}%
\iflistundef{institution}%
{\setunit*{\addcomma\space}}
{\setunit*{\publocpunct}}%
\printlist{institution}%
\setunit*{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%
\usebibmacro{date}%
\newunit}%
}
%
% 通用的出版社和地址的处理
%
% 原理方法:当没有出版社地址时,直接判断title的信息是否是中文,若为中文,则写出版地不详,否则用英文的字符表示。
% 事实上title对于每个文献来说是必须的,所以用它判断是最快的,而且一般标题和出版社的语言是一样的。
% 注意标准standard类型,因为当没有出版项时直接省略,所以做特殊处理
\renewbibmacro*{publisher+location+date}{\bibpubfont%
\iftoggle{bbx:gbpub}%
{\testCJKfirst{userd}%
\ifboolexpr{ test {\iflistundef{location}} and test {\iflistundef{publisher}} }%
{\iffieldequalstr{entrysubtype}{standard}{}{\iftoggle{ifCJKforgbt}{\printtext{[\str@noaddress}\space :\space\str@nopublisher]}{\printtext{[S.l.\space :\space s.n.\adddot]}}}}%
{\iflistundef{location}{%\adddot
\iffieldequalstr{entrysubtype}{standard}{}%%从gbt7714-2015标准第19页看到,标准存在出版项时输出,没有时完全省略。
{\iftoggle{ifCJKforgbt}{\printtext{[\str@noaddress]}\addcolon\addspace}{\printtext{[S.l.\adddot]}\publocpunct}}}% \bibstring{noaddress}
{\printlist{location}\publocpunct}%%\addcolon\addspace%
\iflistundef{publisher}{%
\iffieldequalstr{entrysubtype}{standard}{}%
{\iftoggle{ifCJKforgbt}{\printtext{[\str@nopublisher]}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}%
{\printtext{\mkbibbrackets{s.n.}}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}}}%
{\printlist{publisher}}}%
\setunit*{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%\addcomma\addspace%
\ifentrytype{report}{\printtext{\blx@gbdate{}{}}}%
{\usebibmacro{date}}%
}%
{\printlist{location}%
\iflistundef{publisher}
{\setunit*{\addcomma\space}}
{\setunit*{\publocpunct}}%
\printlist{publisher}%
\setunit*{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%
\ifentrytype{report}{\printtext{\blx@gbdate{}{}}}%
{\usebibmacro{date}}%
}%
}
%
% 修改了一个institution+location+date用于manual、thesis等类型
%
% 20180425,v1.0k,增加了字体控制命令,hzz
% 20190105,v1.0o,加了一个编组避免\usebibmacro{date}把month和day信息去掉
\renewbibmacro*{institution+location+date}{\bibpubfont%当没有institution时不处理。
{\printlist{location}%%加了一个编组避免\usebibmacro{date}把month和day信息去掉
\iflistundef{institution}
{\setunit*{\addcomma\space}}
{\setunit*{\publocpunct}}%
\printlist{institution}%
\setunit*{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%
\usebibmacro{date}%
%\newunit
}}
%
% 编者的符号修改一下
% v1.0 2016-07-01
% v1.0q 2019-03-01 hzz 修改editortype前的标点
%
\renewbibmacro*{editor}{%源来自biblatex.DEF
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\printnames{editor}%
\iffieldundef{editortype}%增加一个类型判断,用于存在editortype的情况
{\setunit{\iffieldequalstr{userd}{chinese}{\gbpunctdot}{\gbpunctdotlanen}}}%当没有editortype时,直接用句点
{\usebibmacro{editorstrg}\setunit{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}}%
}%
{}}
%
% 增加inbook:parent用于辅助crossref传统功能的实现
% 用在{crosscite}宏中
% 20210216,v1.0w,hzz
\renewbibmacro*{inbook:parent}{%
\usebibmacro{bybookauthor}%
%\ifnameundef{bookauthor}{%
% \ifnameundef{editor}{}{\newunit}%
%}{\newunit}%替换下一句
%\newunit\newblock
\iffieldundef{series}{}{\usebibmacro{series+number}\setunit{\addcolon\addspace}}%为处理一些存在series的情况而增加
\usebibmacro{maintitle+booktitle}%
\iffieldundef{volume}{}{\setunit{\addcolon\addspace}\printfield{volume}}%
\iffieldundef{number}{}{\setunit{\addcolon\addspace}\printfield{number}}%增加卷和册信息
\newunit\newblock%
\printfield{edition}%
\newunit\newblock
\usebibmacro{publisher+location+date}}
%
% 修改in:用于inbook、incollection、inproceedings等类型
% 2018.04.20,v1.0k,renewed marco,by hzz
% 20190212,v1.0q,增加中英文区分,by hzz
%
% 原理方法:使用bibmacro{in:}改变了以前在driver中直接输出//的方式,同时也简化了标点控制。
\renewbibmacro*{in:}{%
\iftoggle{bbx:gbpunctin}{\printtext{\allowbreak\texttt{//}\allowbreak}}%\addthinspace
{\setunit{\iffieldequalstr{userd}{chinese}{\gbpunctdot}{\gbpunctdotlanen}}%
\iffieldequalstr{userd}{chinese}%
{\printtext{\bibstring{incn}}}%
{\printtext{\bibstring{in}}}%
}}%\newunit\newblock\intitlepunct
%
% 对edition版本信息格式做出修改
% 注意实现逻辑:
% 1. 不是整数时原样输出
% 2. 当是整数且大于1时按版本格式输出
\DeclareFieldFormat{edition}{\bibtitlefont%源来自biblatex.DEF
\testCJKfirst{userd}%
\iftoggle{ifCJKforgbt}%
{\ifinteger{#1}%
{\ifnumgreater{#1}{1}{\printtext{#1\str@edition}\newunit}{}}%
{#1\isdot\newunit}}%
{\ifinteger{#1}%
{\ifnumgreater{#1}{1}{\mkbibordedition{#1}~\bibstring{edition}\newunit}{}}%
{#1\isdot\newunit}}%
}
%
% 增加inbook:parent用于辅助crossref传统功能的实现
% 用在{crosscite}宏中
% 20210216,v1.0w,hzz
\renewbibmacro*{inbook:parent}{%
\usebibmacro{bybookauthor}%
%\ifnameundef{bookauthor}{%
% \ifnameundef{editor}{}{\newunit}%
%}{\newunit}%替换下一句
%\newunit\newblock
\iffieldundef{series}{}{\usebibmacro{series+number}\setunit{\addcolon\addspace}}%为处理一些存在series的情况而增加
\usebibmacro{maintitle+booktitle}%
\iffieldundef{volume}{}{\setunit{\addcolon\addspace}\printfield{volume}}%
\iffieldundef{number}{}{\setunit{\addcolon\addspace}\printfield{number}}%增加卷和册信息
\newunit\newblock%
\printfield{edition}%
\usebibmacro{publisher+location+date}}
\DeclareBibliographyDriver{book}{%源来自standard.bbx文件
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\ifnameundef{namea}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
\usebibmacro{maintitle+title}%
\iftoggle{bbx:gbstrict}{}{%
\newunit%
\printlist{language}%
\newunit\newblock%
\usebibmacro{byauthor}%
\newunit\newblock}%
\usebibmacro{byeditor+others}%
\newunit%
\printfield{edition}%
\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{annotation}\usebibmacro{finentry}}