-
Notifications
You must be signed in to change notification settings - Fork 2
/
biblatex-sjtuthesis.bbx
158 lines (142 loc) · 4.5 KB
/
biblatex-sjtuthesis.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
\ProvidesFile{biblatex-sjtuthesis.bbx}
\RequireBiber[3]
\RequireBibliographyStyle{numeric}
\ExecuteBibliographyOptions{texencoding = UTF-8, maxnames=99}
\renewcommand*{\biblabelsep}{0em}
\renewcommand*{\bibhang}{0.2em}
\defbibenvironment{bibliography}
{\list
{\printfield[labelnumberwidth]{labelnumber}}
{\setlength{\labelwidth}{\labelnumberwidth}
\setlength{\leftmargin}{\labelwidth}
\setlength{\labelsep}{\biblabelsep}
\addtolength{\leftmargin}{\labelsep}
\setlength{\itemsep}{\bibitemsep}
\setlength{\itemindent}{-\bibhang}
\setlength{\parsep}{\bibparsep}}
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
%判断中英文字符
\newcommand*{\bbx@cegen}[2]{\iffieldequalstr{userf}{zh}{#1}{#2}}
%中文标点
\newcommand*{\bbx@cncomma}{,}
\newcommand*{\bbx@cncolon}{:}
\newcommand*{\bbx@cnperiod}{。}
%通用标点
\newcommand*{\bbx@cecomma}{\bbx@cegen{\bbx@cncomma}{\addcomma\space}}
\newcommand*{\bbx@cecolon}{\bbx@cegen{\bbx@cncolon}{\addcolon\space}}
\newcommand*{\bbx@ceperiod}{\bbx@cegen{\bbx@cnperiod}{\addperiod\space}}
\newcommand*{\bbx@cespace}{\bbx@cegen{}{\space}}
\renewcommand*{\finalnamedelim}{\bbx@cegen{\bbx@cncomma}{\addcomma\addspace\bibstring{and}\space}}
\renewcommand*{\finentrypunct}{\bbx@cegen{\bbx@cnperiod}{.}}
\DefineBibliographyStrings{english}{
bibliography = {参考文献},
}
\DeclareFieldFormat[book]{title}{\mkbibemph{#1}}
\DeclareFieldFormat[inproceedings,article,thesis,online]{title}{#1}
\DeclareFieldFormat[inproceedings]{volume}{#1}
\DeclareFieldFormat*{url}{\url{#1}}
\DeclareNameFormat{default}{%
\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}
}
\DeclareNameAlias{sortname}{default}
\DeclareBibliographyDriver{book}{
\printnames{author}\setunit{\bbx@cecomma}
\newblock\printfield{title}\iffieldundef{edition}{}{\printtext{\bbx@cecomma}\printfield{edition}}\setunit{\bbx@ceperiod}
\newblock\printlist{location}\setunit*{\bbx@cecolon}\printlist{publisher}\setunit{\bbx@cecomma}%
\newblock\printfield{year}\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{inproceedings}{
\printnames{author}\setunit{\bbx@cecomma}
\newblock\printtext{\mkbibquote{\printfield{title}\printtext{\addcomma}}}
\newblock\printtext{in}\nopunct\setunit{\bbx@cespace}
\newblock\printfield{booktitle}\setunit{\bbx@cecomma}
\newblock\printfield{month}\printtext{\bbx@cespace}\printfield{year}\setunit{\bbx@cecomma}
\newblock\iffieldundef{volume}{}{\printtext{vol\bbx@ceperiod\printfield{volume}}}\setunit*{\bbx@cecomma}
\newblock\printfield{pages}\usebibmacro{finentry}
}
\DeclareBibliographyDriver{article}{
\printnames{author}\setunit{\bbx@cecomma}
\newblock\printtext{\mkbibquote{\printfield{title}\printtext{\addcomma}}}
\newblock\printfield{journaltitle}\setunit*{\bbx@cecomma}
\newblock\printtext{vol\bbx@ceperiod\printfield{volume}}\setunit{\bbx@cecomma}
\newblock\printtext{no\bbx@ceperiod\printfield{number}}\setunit{\bbx@cecomma}
\newblock\printfield{pages}\setunit{\bbx@cecomma}
\newblock\printfield{month}\printtext{\bbx@cespace}\printfield{year}\usebibmacro{finentry}
}
\DeclareBibliographyDriver{thesis}{
\printnames{author}\setunit{\bbx@cecomma}
\newblock\printfield{title}\nopunct
\newblock\printtext{\mkbibbrackets{\printfield{type}}\setunit{\bbx@cecomma}}
\newblock\printlist{institution}\setunit{\bbx@cecomma}
\newblock\printfield{year}\printtext{年}\usebibmacro{finentry}
}
\DeclareBibliographyDriver{online}{
\printnames{author}\setunit{\bbx@cecomma}
\newblock\printfield{title}\setunit{\bbx@cespace}
\newblock\printtext{[Online]}\setunit{\bbx@ceperiod}
\newblock\printtext{Available}\setunit{\bbx@cecolon}
\newblock\printfield{url}\usebibmacro{finentry}
}
%排序规则
\DeclareSortingScheme{ecnty}{
\sort{\field{presort}}
\sort[final]{\field{sortkey}}
\sort{
\field{userf}
}
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field{sortyear}
\field{year}
}
}
\DeclareSortingScheme{centy}{
\sort{\field{presort}}
\sort[final]{\field{sortkey}}
\sort[direction = descending]{
\field{userf}
}
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field{sortyear}
\field{year}
}
}
%中英文识别
\DeclareStyleSourcemap{
\maps{
\map[overwrite]{
\step[
fieldsource = language, match = \regexp{chinese},
fieldset = userf, fieldvalue = {zh}
]
}
\map{
\step[fieldset = userf, fieldvalue = {en}]
}
}
}