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

%
%   加载标准样式
%
\RequireCitationStyle{numeric-comp} %numeric


%
%   选项设置
%
\ExecuteBibliographyOptions{
  autocite  = superscript ,
  autopunct = true       ,
  %sorting   = none        ,
  maxcitenames=1,
  mincitenames=1,
}

%textcite标注命令中的标点设置
%\DeclareDelimFormat[textcite]{andothersdelim}{\addspace}%

%
%   定义一个上标方括号wrapper
%
\newcommand*\mkbibsuperbracket[1]{%
  \mkbibsuperscript{\mkbibbrackets{#1}}%
}

%
%   重定义cite命令
%
%   方法:\DeclareCiteCommand{\cite}[\mkbibparens]{precode}{loopcode}{sepcode}{postcode}
\DeclareCiteCommand{\cite}[\mkbibsuperbracket]%利用mkbibsuperbracket添加方括号
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}}

%
%   定义upcite命令
%   20180604,v1.0l,hzz
%   方法:对supercite增加[]
\DeclareCiteCommand{\upcite}[\mkbibsuperbracket]
  {\usebibmacro{cite:init}
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}}

%
%   新定义pagescite命令,以满足标签带页码的国标要求
%
%   原理方法:
%   1.修改postnote的输出格式
\DeclareFieldFormat{postnote}{#1}
%   2.新增页码输出宏
\newbibmacro*{postpages}{%
  \iffieldundef{postnote}
    {\printfield[postnote]{pages}}
    {\printfield{postnote}}}
%   3.新增\pagescite引用命令
\DeclareCiteCommand{\pagescite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标
  {[\usebibmacro{cite:init}%]直接添加方括号
   \usebibmacro{prenote}%
   }
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}]%
   \usebibmacro{postpages}}

%
%   定义yearpagescite,为与ay样式兼容,等同于\pagescite
%
\DeclareCiteCommand{\yearpagescite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标
  {[\usebibmacro{cite:init}%]直接添加方括号
   \usebibmacro{prenote}%
   }
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}]%
   \usebibmacro{postpages}}

%
%   定义\yearcite命令,为与ay样式兼容,且提供不输出页码的标签格式,
%
%   原理方法:等同于\pagescite,但不要页码
\DeclareCiteCommand{\yearcite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标
  {[\usebibmacro{cite:init}%]直接添加方括号
   \usebibmacro{prenote}%
   }
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}]}

%
%   定义\authornumcite命令,输出作者信息,然后在后面带上顺序编码
%   20180427,v1.0k,增加,hzz
%   gb7714样式新定义的命令都把cite放到最后,比如前面的pagescite,yearcite,这里的\authornumcite
%   区别于biblatex定义的命令都把cite放到前面,比如citeauthor等。
%见numeric.CBX
\newbibmacro*{cite}{%
  \printtext[bibhyperref]{%
    \printfield{labelprefix}%
    \printfield{labelnumber}%
    \ifbool{bbx:subentry}
      {\printfield{entrysetcount}}
      {}}}
%见numeric.CBX,\DeclareCiteCommand{\cite},
\DeclareCiteCommand{\authornumcite}%[\mkbibsuperscript]
  {\usebibmacro{prenote}}
  {\iffieldequalstr{userf}{cn}{\renewcommand*{\andothersdelim}{\addthinspace}}%\addthinspace
  {\renewcommand*{\andothersdelim}{\addspace}}%
  \printnames{labelname}\mkbibsuperscript{\mkbibbrackets{\usebibmacro{citeindex}%
   \usebibmacro{cite}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}