summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/biblatex-gb7714-2015/gb7714-2015ay.cbx
blob: 248732961963e663e6c4472dda3d5c60da27a6f8 (plain)
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
%%
%% ---------------------------------------------------------------
%% biblatex-gb7714-2015 --- A biblatex implementation of the
%% GBT7714-2015 citation style,author year sequence
%% Maintained by huzhenzhen
%% E-mail: hzzmail@163.com
%% Released under the LaTeX Project Public License v1.3c or later
%% ---------------------------------------------------------------
%%
\ProvidesFile{gb7714-2015ay.cbx}[2018/11/04 v1.0n biblatex citation style]

%
%   加载标准样式
%
\RequireCitationStyle{authoryear}



\ExecuteBibliographyOptions{
  %autocite  = superscript ,
  %autopunct = true       ,
  %sorting   = none        ,
  maxcitenames=1,
  mincitenames=1,
  uniquename=init,%因为使用了名字缩写选项,所以需要设置uniquename=init而不是full避免冲突
  uniquelist=minyear
}
%
%   选项设置,针对3.7以下版本
%
%   原理方法:labeldate用于控制是否给引用标签提供日期的成分
\defversion{3.4}{cbxopt}{
    \ExecuteBibliographyOptions{
      labeldate=true
    }
}

%
%   选项设置,针对3.7以上版本
%
%   原理方法:labeldateparts用于控制是否给引用标签提供日期的成分
\defversion{3.7}{cbxopt}{
    \ExecuteBibliographyOptions{
      labeldateparts=true
    }
}

\ifboolexpr{%选择选项设置
test {\iftoggle{iftlfive}}%biblatex<=3.2
or
test {\iftoggle{iftlsix}}%3.3<=biblatex<=3.6
}{\switchversion{3.4}{cbxopt}}{\switchversion{3.7}{cbxopt}}%else: biblatex>=3.7


\ifboolexpr{%兼容cite:labelyear+extrayear
test {\iftoggle{iftlfive}}%biblatex<=3.2
or
test {\iftoggle{iftlsix}}%3.3<=biblatex<=3.6
or
test {\iftoggle{iftlseven}}%3.7=biblatex
}{\newbibmacro{cite:labeldate+extradate}{\usebibmacro{cite:labelyear+extrayear}}}{}%else: biblatex>3.7

%textcite标注命令中的标点设置,注意只针对textcite命令。
\DeclareDelimFormat[textcite]{nameyeardelim}{}%\addcomma\space
\DeclareDelimFormat[textcite]{andothersdelim}{\iffieldequalstr{userf}{cn}{\addthinspace}{\addspace}}%
\AtEveryCitekey{%
\iffieldequalstr{userf}{cn}{\renewcommand*{\andothersdelim}{\addthinspace}}%\addthinspace
  {\renewcommand*{\andothersdelim}{\addspace}}%
}



%
%   重定义cite:label,针对biblatex3.8以上版本set条目集的标注(引用)标签
%
%   原理方法:当条目是set时,v3.8以上版本,都没有有用的信息(区别于3.7以下版本set复制第一个成员的信息),
%   于是利用entrykey来给出标签,那么就要set的条目关键字是需要的字符串,注意字符串中间不能有空格
\renewbibmacro*{cite:label}{%
  \iffieldundef{label}%
    {\iffieldundef{labeltitle}{\printtext[bibhyperref]{\printfield{entrykey}}}%entrykey
    {\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}}%
    {\printtext[bibhyperref]{\printfield{label}}}}

%
%   重定义cite命令
%
%   方法:\DeclareCiteCommand{\cite}[\mkbibparens]{precode}{loopcode}{sepcode}{postcode}
\DeclareCiteCommand{\cite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

%
%   定义upcite命令
%   20180604,v1.0l,hzz
%   方法:与yearcite命令相同
\DeclareCiteCommand{\upcite}
  {\printtext{(}\usebibmacro{prenote}}
  {\usebibmacro{cite:labeldate+extradate}}%
  {\multicitedelim}
  {\printtext{)}}

%
%   重定义parencite命令
%
\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}


%
%   新定义pagescite命令,以满足标签带页码的国标要求
%
%   原理方法:
%   1.修改postnote的输出格式
\newbibmacro*{postpages}{%
  \iffieldundef{postnote}
    {\printfield{pages}}
    {\printfield{postnote}}}
%   2.新增页码输出宏(括号外的页码格式)
\DeclareFieldFormat{postnote}{#1}
%   3.新增\pagescite引用命令
\DeclareCiteCommand{\pagescite}
  {\printtext{(}\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\printtext{)}\textsuperscript{\usebibmacro{postpages}}}

%
%   定义yearpagescite,用于当文中作者已经存在,需要页码和年份的情况
%
%   原理:增加一个命令yearpagescite
%   参考biblatex.DEF中的\DeclareCiteCommand*{\citeyear}命令
\DeclareCiteCommand{\yearpagescite}
  {\printtext{(}\usebibmacro{prenote}}
  {\usebibmacro{cite:labeldate+extradate}}%\printfield{year}\printfield{extrayear}
  {\multicitedelim}
  {\printtext{)}\textsuperscript{\usebibmacro{postpages}}}

%
%   定义yearcite,用于当文中作者已经存在,仅需要年份的情况
%
%   原理:增加一个命令yearcite
\DeclareCiteCommand{\yearcite}%仅输出年份,不要页码
  {\printtext{(}\usebibmacro{prenote}}
  {\usebibmacro{cite:labeldate+extradate}}%\printfield{year}\printfield{extrayear}
  {\multicitedelim}
  {\printtext{)}}

%
%   定义\authornumcite命令,输出作者信息,然后在后面带上顺序编码
%   20180427,v1.0k,增加,hzz
%   为与顺序编码制兼容,增加了命令,定义与cite相同
\DeclareCiteCommand{\authornumcite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}