-
Notifications
You must be signed in to change notification settings - Fork 8
/
gbt7714.sty
124 lines (124 loc) · 4.06 KB
/
gbt7714.sty
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
%%
%% This is file `gbt7714.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% gbt7714.dtx (with options: `package')
%% -------------------------------------------------------------------
%% GB/T 7714-2015 BibTeX Style
%% https://github.com/CTeX-org/gbt7714-bibtex-style
%% Version: 2019/03/21 v1.1.1
%% -------------------------------------------------------------------
%% Copyright (C) 2016-2019 by Zeping Lee <zepinglee AT gmail.com>
%% -------------------------------------------------------------------
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% https://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% -------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{gbt7714}
[2019/03/21 v1.1.1 GB/T 7714-2015 BibTeX Style]
\newif\if@gbt@mmxv
\newif\if@gbt@numerical
\newif\if@gbt@super
\DeclareOption{2015}{\@gbt@mmxvtrue}
\DeclareOption{2005}{\@gbt@mmxvfalse}
\DeclareOption{super}{\@gbt@numericaltrue\@gbt@supertrue}
\DeclareOption{numbers}{\@gbt@numericaltrue\@gbt@superfalse}
\DeclareOption{authoryear}{\@gbt@numericalfalse}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{natbib}}
\ExecuteOptions{2015,super}
\ProcessOptions\relax
\if@gbt@numerical
\PassOptionsToPackage{sort&compress}{natbib}
\fi
\RequirePackage{natbib}
\RequirePackage{etoolbox}
\RequirePackage{url}
\newcommand\bibstyle@super{\bibpunct{[}{]}{,}{s}{,}{\textsuperscript{,}}}
\newcommand\bibstyle@numbers{\bibpunct{[}{]}{,}{n}{,}{,}}
\newcommand\bibstyle@authoryear{\bibpunct{(}{)}{;}{a}{,}{,}}
\newcommand\gbtbibstyle[1]{%
\ifstrequal{#1}{numerical}{%
\if@gbt@mmxv
\bibliographystyle{gbt7714-unsrt}%
\else
\bibliographystyle{gbt7714-2005-unsrt}%
\fi
}{%
\ifstrequal{#1}{authoryear}{%
\if@gbt@mmxv
\bibliographystyle{gbt7714-plain}%
\else
\bibliographystyle{gbt7714-2005-plain}%
\fi
}{%
\PackageError{gbt7714}{Unknown argument #1.}%
{It should be `numerical' or `authoryear'.}%
}%
}%
}
\if@gbt@numerical
\if@gbt@super
\citestyle{super}%
\gbtbibstyle{numerical}%
\else
\citestyle{numbers}
\gbtbibstyle{numerical}%
\fi
\else
\citestyle{authoryear}
\gbtbibstyle{authoryear}%
\fi
\newcommand\gbt@patchfailure[1]{%
\PackageError{gbt7714}{Failed to patch command \protect#1}{}%
}
\patchcmd{\NAT@citexnum}{%
\@ifnum{\NAT@ctype=\z@}{%
\if*#2*\else\NAT@cmt#2\fi
}{}%
\NAT@mbox{\NAT@@close}%
}{%
\NAT@mbox{\NAT@@close}%
\@ifnum{\NAT@ctype=\z@}{%
\if*#2*\else\textsuperscript{#2}\fi
}{}%
}{}{\gbt@patchfailure{\NAT@citexnum}}
\renewcommand\NAT@citesuper[3]{\ifNAT@swa
\if*#2*\else#2\NAT@spacechar\fi
\unskip\kern\p@\textsuperscript{\NAT@@open#1\NAT@@close\if*#3*\else#3\fi}%
\else #1\fi\endgroup}
\patchcmd{\NAT@citex}{%
\if*#2*\else\NAT@cmt#2\fi
\if\relax\NAT@date\relax\else\NAT@@close\fi
}{%
\if\relax\NAT@date\relax\else\NAT@@close\fi
\if*#2*\else\textsuperscript{#2}\fi
}{}{\gbt@patchfailure{\NAT@citex}}
\renewcommand\NAT@cite%
[3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\NAT@spacechar\fi
#1\NAT@@close\if*#3*\else\textsuperscript{#3}\fi\else#1\fi\endgroup}
\patchcmd{\NAT@citexnum}{%
\ifx\NAT@last@yr\relax
\def@NAT@last@yr{\@citea}%
\else
\def@NAT@last@yr{--\NAT@penalty}%
\fi
}{%
\def@NAT@last@yr{-\NAT@penalty}%
}{}{\gbt@patchfailure{\NAT@citexnum}}
\renewcommand\@biblabel[1]{[#1]\hfill}
\def\UrlBreaks{%
\do\/%
\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j\do\k\do\l%
\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w\do\x\do\y\do\z%
\do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L%
\do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X\do\Y\do\Z%
\do0\do1\do2\do3\do4\do5\do6\do7\do8\do9\do=\do/\do.\do:%
\do\*\do\-\do\~\do\'\do\"\do\-}
\Urlmuskip=0mu plus 0.1mu