-
Notifications
You must be signed in to change notification settings - Fork 84
/
chinese-cajhss.cbx
294 lines (258 loc) · 9.86 KB
/
chinese-cajhss.cbx
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
%%
%% ---------------------------------------------------------------
%% erj.cbx --- A citation style of comprehensive academic journal of humanities and social sciences in china
%% modified from gb7714-2015ay
%% Maintained by huzhenzhen
%% E-mail: [email protected]
%% Released under the LaTeX Project Public License v1.3c or later
%% ---------------------------------------------------------------
%%
%%用法:类似于标准的样式在biblatex加载时设置样式
%%文献表正常处理,标注命令主要用cite和textcite
\ProvidesFile{chinese-cajhss.cbx}[v1.0a a biblatex citation style for ERJ]
%==================================================
%加载gb样式
%==================================================
\RequireCitationStyle{gb7714-2015ay} %
%
% 增加一个控制标注中标点是英文还是中文的选项
% 20220222,v1.0a,hzz
\DeclareBibliographyOption{gbcitepunctcn}[true]{%biblatex低版本
\ifstrequal{#1}{false}{\exegbpunctencite}{}}
\def\gbpunctmarkcite{、}%
\def\gbpunctsemicoloncite{;}%
\def\gbpunctparenlcite{(}%
\def\gbpunctparenrcite{)}
\def\exegbpunctencite{%
\def\gbpunctmarkcite{\addcomma\addspace}%
\def\gbpunctsemicoloncite{\addsemicolon\addspace}%
\def\gbpunctparenlcite{(}%
\def\gbpunctparenrcite{)}
}
%==================================================
%选项设置
%==================================================
\ExecuteBibliographyOptions{
maxcitenames=2,
mincitenames=1,
}
\DefineBibliographyStrings{english}{
andincitecn = {和},%将标注中的分开,便于与文献表中的区分
andincite = {\&},
}
%==================================================
%引用命令设置,主要用cite和textcite
%包括标点设置
%==================================================
\renewcommand*{\multicitedelim}{\gbpunctsemicoloncite}%\addsemicolon\addspace;
\renewcommand*{\textcitedelim}{%
\iffinalcitedelim
{\ifnumgreater{\value{textcitetotal}}{2}
{}{}%\iftextcitepunct{\finalandsemicolon}{\finalandcomma}
\addspace\gbpunctmarkcite}%\addspace\bibstring{andincitecn}
{\iftextcitepunct{\addsemicolon\space}{\addspace\gbpunctmarkcite}}%\addcomma
}%\space
\DeclareDelimFormat[textcite]{nameyeardelim}{\addspace}%\addcomma\space
\DeclareDelimFormat[textcite]{andothersdelim}{\iffieldequalstr{userf}{chinese}{}{\addspace}}%
%之所以不用\DeclareDelimFormat{andothersdelim}{}这样的设置是因为gb7714-2015中为兼容老版本的biblatex做的处理就是这样的
%所以用相同的方式
\AtEveryCitekey{%
\iffieldequalstr{userf}{chinese}{\renewcommand*{\andothersdelim}{}}%\addthinspace
{\renewcommand*{\andothersdelim}{\addspace}}%
}
%标注压缩时,直接用date+extradate代替extradate实现2006a,2006b的效果
%\DeclareDelimFormat*{compcitedelim}{\gbpunctmarkcite}%\addcomma\addspace
\newbibmacro*{cite:extradate}{%
\iffieldundef{extradate}
{}
{\printtext[bibhyperref]{\addspace\printlabeldateextra}}}%\printfield{extradate}\printlabeldateextra \printfield{labelyear}\printfield{extradate}
%\AtEveryCite{%
%\let\parentext=\parentexttrack%
%\let\bibopenparen=(%
%\let\bibcloseparen=)}
%添加前后空格
\DeclareCiteCommand{\cite}%[\mkbibparens]
{\usebibmacro{cite:init}%
\unspace\printtext{\gbpunctparenlcite}\usebibmacro{prenote}}%\addspace
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{}
{\usebibmacro{postnote}%
\gbpunctparenrcite}%\addspace
%原版
%\DeclareCiteCommand{\cite}[\mkbibparens]
% {\usebibmacro{cite:init}%
% \usebibmacro{prenote}}%)
% {\usebibmacro{citeindex}%
% \usebibmacro{cite}}
% {}
% {\usebibmacro{postnote}}
%
%添加后面空格
%\DeclareCiteCommand{\cbx@textcite}
% {\usebibmacro{cite:init}}
% {\usebibmacro{citeindex}%
% \usebibmacro{textcite}}
% {}
% {\usebibmacro{textcite:postnote}\addspace}
%修改注释后的标点
\renewcommand{\bibfootnotewrapper}[1]{%
#1}%\bibsentence
%避免去除前面的空白
\renewrobustcmd{\blx@mkbibfootnote}[2]{%
\iftoggle{blx@footnote}
{\blx@warning{Nested notes}%
\addspace\mkbibparens{#2}}
{%\unspace
\ifnum\blx@notetype=\tw@
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{\csuse{blx@theendnote#1}{\protecting{\blxmkbibnote{end}{#2}}}}
{\csuse{footnote#1}{\protecting{\blxmkbibnote{foot}{#2}}}}}}
%修改脚注注释的实现
\def\execgbfootbib%
{%
%开启引用跟踪计数器,为使用\ifciteseen等测试命令
\ExecuteBibliographyOptions{citetracker=true}
%
%重定义\footfullcite使完成css的脚注文献要求
\DeclareCiteCommand{\footfullcite}[\mkbibfootnote]%
{\defcounter{maxnames}{\blx@maxcitenames}%局部定义maxnames和minnames计数器
\defcounter{minnames}{\blx@mincitenames}%使footfullcite内的作者输出与正文文献表中的一致。
\usebibmacro{prenote}%
\renewbibmacro*{postnote}{%
\iffieldundef{postnote}%
{}{\setunit{\iffieldequalstr{userd}{chinese}{\unspace\gbpunctcomma}{\addcolon\addspace}}%
\printfield{postnote}}}%与ay样式不同,由于已修改postnote域格式,直接用printfield
}%
{\ifciteseen%
{\usedriver{\DeclareNameAlias{sortname}{default}}{citeseen:\thefield{entrytype}}}%\nopunct
{\usedriver{\DeclareNameAlias{sortname}{default}}{\thefield{entrytype}}}%
}%
{\multicitedelim}%
{\usebibmacro{postnote}\usebibmacro{finentry}}%
\DeclareCiteCommand{\fullcite}
{\usebibmacro{prenote}%
\renewbibmacro*{postnote}{%
\iffieldundef{postnote}%
{}{\setunit{\iffieldequalstr{userd}{chinese}{\unspace\gbpunctcomma}{\addcolon\addspace}}%
\printfield{postnote}}}%与ay样式不同,由于已修改postnote域格式,直接用printfield
}
{\ifciteseen%
{\usedriver{\DeclareNameAlias{sortname}{default}}{citeseen:\thefield{entrytype}}}%\nopunct
{\usedriver{\DeclareNameAlias{sortname}{default}}{\thefield{entrytype}}}%
}
{\multicitedelim}
{\usebibmacro{postnote}\usebibmacro{finentry}}%
\DeclareCiteCommand{\fullinnercite}
{\usebibmacro{prenote}%
\renewbibmacro*{postnote}{%
\iffieldundef{postnote}%
{}{\setunit{\iffieldequalstr{userd}{chinese}{\unspace\gbpunctcomma}{\addcolon\addspace}}%
\printfield{postnote}}}%与ay样式不同,由于已修改postnote域格式,直接用printfield
}
{\ifciteseen%
{\usedriver{\DeclareNameAlias{sortname}{default}}{citeseen:\thefield{entrytype}}}%\nopunct
{\usedriver{\DeclareNameAlias{sortname}{default}}{\thefield{entrytype}}}%
}
{\multicitedelim}
{\usebibmacro{postnote}\usebibmacro{finentry}}%
}
%为先秦文献夹注做处理
\DeclareFieldFormat*{citejz}{%
\iffieldequalstr{userd}{chinese}{\gbpunctprl\gbpunctttl#1\gbpunctttr\gbpunctprr}%
{\mkbibemph{#1}}}
\DeclareCiteCommand{\citejz}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifciteindex
{\indexfield{indextitle}}
{}%
\printfield[citejz]{labeltitle}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareFieldFormat{citetitle}{%
\iffieldequalstr{userd}{chinese}{\gbpunctttl#1\gbpunctttr}%
{\mkbibemph{#1}}%
}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{citetitle}{%
\iffieldequalstr{userd}{chinese}{\gbpunctttl#1\gbpunctttr}%
{\mkbibquote{#1\isdot}}%
}
%为文献输出出版信息
\DeclareCiteCommand{\citepub}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifciteindex
{\indexfield{indextitle}}
{}%
\ifentrytype{online}{\usebibmacro{institution+location+date}}{\usebibmacro{publisher+location+date}}%
}
{\multicitedelim}
{\usebibmacro{postnote}}
\newbibmacro*{textcite}{%
\iffieldequals{namehash}{\cbx@lasthash}
{\iffieldundef{shorthand}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma}%
\usebibmacro{cite:extradate}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labeldate+extradate}%
\savefield{labelyear}{\cbx@lastyear}}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:shorthand}%
\global\undef\cbx@lastyear}}
{\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nonameyeardelim}\unspace\gbpunctparenlcite}%\bibopenparen
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}
{\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nameyeardelim}\unspace\gbpunctparenlcite}%\bibopenparen
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\iffieldundef{shorthand}
{\iffieldundef{labelyear}
{\usebibmacro{cite:label}}
{\usebibmacro{cite:labeldate+extradate}}%
\savefield{labelyear}{\cbx@lastyear}}
{\usebibmacro{cite:shorthand}%
\global\undef\cbx@lastyear}}%
\stepcounter{textcitecount}%
\savefield{namehash}{\cbx@lasthash}}%
\setunit{%
\ifbool{cbx:parens}
{\gbpunctparenrcite\global\boolfalse{cbx:parens}}%\bibcloseparen
{}%
\textcitedelim}}
\newbibmacro*{textcite:postnote}{%
\usebibmacro{postnote}%
\ifthenelse{\value{multicitecount}=\value{multicitetotal}}
{\setunit{}%
\printtext{%
\ifbool{cbx:parens}
{\gbpunctparenrcite\global\boolfalse{cbx:parens}}%\bibcloseparen
{}}}
{\setunit{%
\ifbool{cbx:parens}
{\gbpunctparenrcite\global\boolfalse{cbx:parens}}%\bibcloseparen
{}%
\textcitedelim}}}
\let\citet=\textcite
\let\citep=\cite