summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-1987.bbx
blob: 708655f76fd7f4c831dfd6d1ecb9fc99213fc276 (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
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
%%
%% ---------------------------------------------------------------
%% Maintained by huzhenzhen
%% E-mail: hzzmail@163.com
%% Released under the LaTeX Project Public License v1.3c or later
%% ---------------------------------------------------------------
%%注意因为使用了stylemap所以只兼容了biblatex3.7以后的版本
\ProvidesFile{gb7714-1987.bbx}[2021/05/16 v1.0 a biblatex bibliography style for GB/T 7714-1987]


%==================================================
%加载gb样式
%==================================================
\RequireBibliographyStyle{gb7714-2015}

%==================================================
% 2005与2015的主要差异:
%1.无doi
%2.文献类型标志(电子文献必备,其他文献任选),引用日期(联机文献必备,其他电子文献任选),这条差异无需处理
%3.用汉语拼音书写的中国著者姓名不得缩写。标准说是这么说的,但没有任何示例。需要的话可以在bib条目中设置nameformat=quanpin
%4.无关于页码、获取和访问路径的说明。这条差异无需处理
%5.没有A/CM/DS/Z等新的类型
%==================================================
% 1987与2005的主要差异:
%1. 没有电子文献。主要考虑将高版本的电子文献转换为misc
%2. 各类文献没有引用日期,获取和访问路径。考虑去掉url和urldate
%3. 没有文献标志类型。考虑去掉文献类型标志和文献载体标志。
%4. 专著存在文献数量、丛编项、附注项、文献标准编号。这一条不考虑。
%5. 析出文献:中文用见:,英文用In:
%6. 页码之间的连接符用~
%7. 英文作者的姓只是首字母大写
%8. 作者年份制中;文献表中,最后一个作者与年份之间的标点用.加空格。但引用的标注标签上是空格
%9. 学位论文:用学位论文和dissertation表示。
%10. 编者会加上编者角色信息。
%11. 专利输出国别和类型。可以全部放到number中处理。专利的日期也有特点。特殊处理。
%==================================================


%==================================================
%选项设置
%==================================================
\ExecuteBibliographyOptions{
    gbtype=false,
    gbnamefmt=lowercase,
    gbfieldtype=true,
    gbpunctin=false,
    doi=false,
    url=false,
    }

%==================================================
%标点设置
%==================================================
\DefineBibliographyExtras{english}{\renewcommand*{\bibrangedash}{$\sim$}}
\DeclareFieldFormat%将期刊等文献的标题中原来带的引号去掉
  [thesis]
  {title}{#1}%\mkbibquote{#1\isdot}

%==================================================
%字符串设置
%==================================================
\DefineBibliographyStrings{english}{
    %andincitecn = {和},
    %andincite   = {and},
    mathesiscn={学位论文},
    phdthesiscn={学位论文},
    mathesis={[dissertation]},
    phdthesis={[dissertation]},
    in={In:\addspace},
    incn={见:\addspace},
    editorscn={编},
    editorcn={编},
}


%==================================================
%类型转换回来
%==================================================
    \DeclareStyleSourcemap{
        \maps[datatype=bibtex]{
            \map{
                \step[typesource=online, typetarget=misc, final]
            }
            \map{
                \step[typesource=electronic, typetarget=misc, final]
            }
            \map{
                \step[typesource=www, typetarget=misc, final]
            }
        }
    }

%==================================================
%域格式设置
%==================================================
%专著如果责任者是editor,也输入相关类型
\renewbibmacro*{editor+others}{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\usebibmacro{editor}%
     \clearname{editor}}
    {}}

%要注意要使用translator那么需要开启usetranslator选项的。
\renewbibmacro*{translator+others}{%
  \ifboolexpr{
    test \ifusetranslator
    and
    not test {\ifnameundef{translator}}
  }
    {\renewcommand{\aftertransdelim}{\adddot\addspace}\printnames{translator}%
     \clearname{translator}}
    {}}


%专利的日期
\renewbibmacro*{newsdate}{%%新增加一个公告日期,公开日期或新闻日期
    \iffieldundef{year}{}{\printfield{year}%
    \iffieldundef{month}{}{\adddot\printtext{\thefield{month}}%
    \iffieldundef{day}{}{\adddot\printfield{day}}}}%
    }

%
%   重设专利title的输出,将文献类型标识符输出出去
%
\newbibmacro*{patenttitle}{%原输出来自biblatex.def文件
  \ifboolexpr{%
    test{\iffieldundef{title}}%
    and%
    test{\iffieldundef{subtitle}}%
  }%
    {}%
    {\printtext[title]{\bibtitlefont%
       \printfield[titlecase]{title}%
       \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题
       {}{\setunit{\subtitlepunct}%
       \printfield[titlecase]{subtitle}}%
       \iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格
        {\setunit{\subtitlepunct}\printfield{titleaddon}}%
        \newunit\printfield{number}%写专利号
        \iftoggle{bbx:gbtype}{\printfield[gbtypeflag]{usera}}{}%
     %\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点
     %\newunit
     }%
}%
}


%==================================================
%条目的输出驱动
%==================================================
%
%   论文类型单独处理:增加论文类型信息
%
%
\DeclareBibliographyDriver{thesis}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
\ifnameundef{namea}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
  \usebibmacro{title}%
  \iftoggle{bbx:gbstrict}{}{%
  \newunit%
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%增加的译者信息
  \newunit\newblock
  \iftoggle{bbx:gbfieldtype}{%
  \setunit{\addcolon\addspace}%
  \printfield{type}%
  \setunit*{\addspace}}{}%
  \printfield{number}%
  \newunit\newblock
  \printfield{version}%
  \newunit
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{institution+location+date}%
  %\newunit\newblock
  \usebibmacro{chapter+pages}%
  \iffieldundef{url}{}{%当没有网址时也不输出修改或更新日期
  \usebibmacro{modifydate}}%修改或更新日期为带括号的时间
  \usebibmacro{doi+eprint+url}%
  \newunit
  \printfield{pagetotal}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isrn}}
    {}%
  \newunit\newblock
%  \usebibmacro{doi+eprint+url}%
%  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}\usebibmacro{annotation}}