-
Notifications
You must be signed in to change notification settings - Fork 87
/
gb7714-2015ay.bbx
executable file
·2303 lines (2174 loc) · 87.5 KB
/
gb7714-2015ay.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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%%
%% ---------------------------------------------------------------
%% 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: [email protected]
%% 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}