Skip to content

Commit 65dcdeb

Browse files
committed
feat: add sjtu-acem biblatex style
1 parent ba580cf commit 65dcdeb

File tree

3 files changed

+281
-1
lines changed

3 files changed

+281
-1
lines changed

setup.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
% biblatex-gb7714-2015 常用选项
114114
% gbnamefmt=lowercase 姓名大小写由输入信息确定
115115
% gbpub=false 禁用出版信息缺失处理
116-
\usepackage[backend=biber,style=gb7714-2015]{biblatex}
116+
\usepackage[backend=biber,style=sjtu-acem]{biblatex}
117117
% 文献表字体
118118
\renewcommand{\bibfont}{\zihao{5}\setbaselineskip{16bp}}
119119
% 文献表条目间的间距

sjtu-acem.bbx

Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
%%
2+
%% ---------------------------------------------------------------
3+
%% sjtu-acem.bbx --- A bibliography style for SJTU ACEM
4+
%% modified from chinese-erj
5+
%% Original by huzhenzhen
6+
%% Released under the LaTeX Project Public License v1.3c or later
7+
%% ---------------------------------------------------------------
8+
%%
9+
%%用法:类似于标准的样式在biblatex加载时设置样式
10+
11+
\ProvidesFile{sjtu-acem.bbx}[2025/04/15 v1.0 a biblatex bibliography style for SJTU ACEM]
12+
13+
%==================================================
14+
%加载gb样式
15+
%==================================================
16+
\RequireBibliographyStyle{gb7714-2015}
17+
\RequirePackage{mfirstuc}%单词首字母大写的问题
18+
\MFUnocap{in}%
19+
\MFUnocap{the}%
20+
\MFUnocap{of}%
21+
\MFUnocap{on}%
22+
\MFUnocap{and}%
23+
\MFUnocap{for}%
24+
25+
%
26+
% 增加一个控制标点是英文还是中文的选项
27+
% 20220222,v1.0a,hzz
28+
\DeclareBibliographyOption{gbpunctcn}[true]{%biblatex低版本
29+
\ifstrequal{#1}{false}{\execerjpuncten}{}}
30+
31+
32+
%==================================================
33+
%考虑多音字增加multipinyin排序,是其可以根据key域添加拼音来排序
34+
%==================================================
35+
\DeclareSortingTemplate{multipinyin}{
36+
\sort{
37+
\field{presort}
38+
}
39+
\sort{
40+
\field{lansortorder}%language
41+
}
42+
\sort{
43+
\field{sortkey}
44+
}
45+
\sort{%[direction=descending]
46+
\field{sortname}
47+
\field{author}
48+
\field{editor}
49+
\field{translator}
50+
}
51+
\sort{
52+
\field{sortyear}
53+
\field{year}
54+
}
55+
\sort{
56+
\field{sorttitle}
57+
\field{title}
58+
}
59+
\sort{
60+
\field{volume}
61+
\literal{0}
62+
}
63+
}
64+
65+
%==================================================
66+
%选项设置
67+
%==================================================
68+
\ExecuteBibliographyOptions{
69+
maxbibnames=99,
70+
gbalign=left,
71+
gbtype=false,
72+
gbpub=false,
73+
gbnamefmt=reverseorder,
74+
sorting=multipinyin,
75+
doi=false,
76+
url=false,
77+
}
78+
79+
%==================================================
80+
%定义一些标点为中文全角标点
81+
%==================================================
82+
\def\gbpunctdot{。}%
83+
\def\gbpunctmark{、}%
84+
\def\gbpunctcomma{,}%
85+
\def\gbpunctcommalanen{\addcomma\addspace}%
86+
\def\gbpunctcolon{:}%
87+
\def\gbpunctcolonlanen{\addcolon\addspace}%
88+
\def\gbpunctsemicolon{;}%
89+
\def\gbpunctttl{《}%
90+
\def\gbpunctttr{》}
91+
92+
93+
\def\execerjpuncten{%
94+
\def\gbpunctdot{\adddot}%
95+
\def\gbpunctmark{\addcomma\addspace}%
96+
\def\gbpunctcomma{\addcomma\addspace}%
97+
\def\gbpunctcommalanen{\addcomma\addspace}%
98+
\def\gbpunctcolon{\addcolon\addspace}%
99+
\def\gbpunctcolonlanen{\addcolon\addspace}%
100+
\def\gbpunctsemicolon{\addsemicolon\addspace}%
101+
\def\gbpunctttl{《}%
102+
\def\gbpunctttr{》}%
103+
}
104+
105+
%==================================================
106+
%为标注和文献表中标点格式,重设and本地化字符串
107+
%==================================================
108+
\DefineBibliographyStrings{english}{
109+
and = { and},%and后面的空格在finalnamedelim已经加过了,所以这里去掉20191009
110+
andcn = {\gbpunctmark\unspace},%\gbpunctmark
111+
andincitecn = {和},%将标注中的分开,便于与文献表中的区分
112+
andincite = {\&},
113+
%andotherscn={等},
114+
%mathesiscn={[硕士学位论文]},
115+
%phdthesiscn={[博士学位论文]},
116+
}
117+
118+
119+
%==================================================
120+
%设置一些标点格式为中文的标点
121+
%==================================================
122+
\DeclareFieldFormat{titlecase}{\iffieldequalstr{userd}{chinese}{#1}{\capitalisewords{#1}}}
123+
\DeclareFieldFormat*{title}{\iffieldequalstr{userd}{chinese}{\gbpunctttl#1\gbpunctttr}{#1\isdot}}
124+
\DeclareFieldFormat[article]{title}{\iffieldequalstr{userd}{chinese}{\gbpunctttl#1\gbpunctttr}{\mkbibquote{#1}\isdot}}
125+
\DeclareFieldFormat*{journaltitle}{\iffieldequalstr{userd}{chinese}{\gbpunctttl#1\gbpunctttr}{\textit{#1}}}%
126+
%\DeclareFieldFormat*{booktitle}{\gbpunctttl#1\gbpunctttr}
127+
\renewcommand*{\revsdnamepunct}{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%%来源biblatex.def
128+
\DeclareDelimFormat*{multinamedelim}{\iffieldequalstr{userd}{chinese}{\gbpunctmark}{\gbpunctcommalanen}}%\addcomma\addspace
129+
\DeclareDelimFormat{finalnamedelim}{%
130+
%\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
131+
%\addspace%
132+
\edef\userfieldabcde{userd}%
133+
\ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
134+
\ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
135+
\ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
136+
\ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
137+
\ifcase\value{gbcitelocalcase}%
138+
\iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andincitecn}}{}%
139+
\iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
140+
\iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
141+
\iffieldequalstr{\userfieldabcde}{english}{\space\bibstring{andincite}\space}{}%
142+
\iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
143+
\iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
144+
%\space%
145+
\or%
146+
\bibstring{andincitecn}\space%
147+
\or%
148+
\bibstring{andincite}\space%
149+
\fi}
150+
\DeclareDelimFormat[bib,biblist]{finalnamedelim}{%
151+
% \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
152+
% \addspace%
153+
\edef\userfieldabcde{userd}%
154+
\ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
155+
\ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
156+
\ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
157+
\ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
158+
\ifcase\value{gbbiblocalcase}%
159+
\iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andcn}}{}%
160+
\iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
161+
\iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
162+
\iffieldequalstr{\userfieldabcde}{english}{\bibstring{and}}{}%
163+
\iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
164+
\iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
165+
\space%
166+
\or%
167+
\bibstring{andcn}\space%
168+
\or%
169+
\bibstring{and}\space%
170+
\fi}
171+
\DeclareDelimFormat{nameyeardelim}{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%\addcomma\addspace
172+
\DeclareDelimFormat[bib,biblist]{nameyeardelim}{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%\addcomma\addspace
173+
\DeclareDelimFormat{bibpagespunct}{\iffieldequalstr{userd}{chinese}{}{\unspace\gbpunctcommalanen}}%\addcomma\addspace\mbox{}
174+
\renewcommand*{\newunitpunct}{\iffieldequalstr{userd}{chinese}{\gbpunctcomma}{\gbpunctcommalanen}}%\addcomma\space %,
175+
\renewcommand*{\finentrypunct}{\iffieldequalstr{userd}{chinese}{\gbpunctdot}{\adddot}}
176+
177+
178+
%==================================================
179+
%调整部分域的输出格式
180+
%==================================================
181+
%
182+
% 修改number和volume的格式
183+
%
184+
\newcounter{numberwithoutzero}
185+
\DeclareFieldFormat[article,periodical]{number}%
186+
{\iffieldequalstr{userd}{chinese}{%
187+
\iffieldint{number}{\setcounter{numberwithoutzero}{#1}\printtext{\bibstring{serialcn}\addthinspace\arabic{numberwithoutzero}\addthinspace 期}}%
188+
{\printtext{\bibstring{serialcn}\addthinspace#1\addthinspace 期}}%
189+
}%
190+
{\printtext{(}#1\printtext{)}}}%\kern\z@
191+
\DeclareFieldFormat[article,periodical]{volume}%
192+
{\iffieldequalstr{userd}{chinese}{}%
193+
{#1}}% volume of a book
194+
195+
%
196+
% 调整期刊名的格式
197+
%
198+
% 原理方法:因为作者年制年份提到前面,因此涉及到期刊名与后面的卷期的关系。
199+
% v1.0k,20180425,增加了字体控制命令,hzz
200+
\renewbibmacro*{journal+issuetitle}{\bibpubfont%源来自standard.bbx
201+
\usebibmacro{journal}%
202+
%\setunit*{\addspace}%
203+
%\setunit*{\addcomma\addspace}%修改为增加一个逗号
204+
\iffieldundef{series}%
205+
{}%
206+
{\newunit%
207+
\printfield{series}%
208+
\setunit{\addspace}}%
209+
%\usebibmacro{volume+number+eid}%
210+
%\setunit{\addspace}%
211+
\usebibmacro{issue+date}%
212+
%\setunit{\addcolon\space}%
213+
%\iffieldundef{volume}{}{\setunit{\addcomma\space}}%
214+
%换成逗号和空格
215+
\usebibmacro{issue}%
216+
\usebibmacro{volume+number+eid}%把卷期放到年份后面
217+
%\newunit
218+
}
219+
220+
% 调整期刊卷和期的格式
221+
%
222+
\renewbibmacro*{volume+number+eid}{%源来自standard.bbx
223+
\iffieldequalstr{userd}{chinese}{%\printfield{volume}%
224+
\iffieldundef{number}{}{\printfield{number}}%区别于顺序编码制
225+
}
226+
{\newunit\printfield{volume}%
227+
%\setunit*{\adddot\space}%
228+
\printfield{number}%
229+
\setunit{\addcomma\space}%
230+
\printfield{eid}}}
231+
232+
%
233+
% 重设title的输出
234+
%
235+
% 20180425,v1.0k,为标题增加字体控制命令,Hu Zhenzhen
236+
% 原理方法:将文献类型标识符输出出去,原输出来自biblatex.def文件
237+
% 利用toggle做标识符是否输出的判断
238+
\renewbibmacro*{title}{%
239+
\ifboolexpr{%
240+
test{\iffieldundef{title}}%
241+
and
242+
test{\iffieldundef{subtitle}}%
243+
}%
244+
{}%
245+
{\setunit{\iffieldequalstr{userd}{chinese}{\gbpunctcolon}{\gbpunctcommalanen}}\printtext[title]{\bibtitlefont%增加字体控制命令%增加了标点:
246+
\printfield[titlecase]{title}%
247+
\ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题
248+
{}{\setunit{\subtitlepunct}%
249+
\printfield[titlecase]{subtitle}}%
250+
\iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格
251+
{\setunit{\subtitlepunct}\printfield{titleaddon}}%
252+
\iftoggle{bbx:gbtype}{%
253+
\iffieldundef{entrysubtype}{\printfield[gbtypeflag]{usera}}%在标题后直接给出文献标识字母,判断一下,是否是报纸和标准
254+
{\iffieldequalstr{entrysubtype}{standard}{\printfield[gbtypeflags]{usera}}%判断是否为标准
255+
{\iffieldequalstr{entrysubtype}{news}{\printfield[gbtypeflagn]{usera}}% 判断是否为报纸
256+
{\printfield[gbtypeflag]{usera}}}% 其它
257+
}}{}%
258+
%\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点
259+
%\newunit
260+
}%
261+
}}
262+
263+
\DeclareFieldFormat{pages}{\iffieldequalstr{userd}{chinese}{}{#1}}%页码引用格式的修改%去掉前面引导页码的pp.等字符

sjtu-acem.cbx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%%
2+
%% ---------------------------------------------------------------
3+
%% sjtu-acem.cbx --- A citation style for SJTU ACEM
4+
%% modified from gb7714-2015
5+
%% Original by huzhenzhen
6+
%% Released under the LaTeX Project Public License v1.3c or later
7+
%% ---------------------------------------------------------------
8+
%%
9+
%%用法:类似于标准的样式在biblatex加载时设置样式
10+
11+
12+
\ProvidesFile{sjtu-acem.cbx}[2025/04/15 v1.0 a biblatex citation style for SJTU ACEM]
13+
14+
%==================================================
15+
%加载gb样式
16+
%==================================================
17+
\RequireCitationStyle{gb7714-2015}

0 commit comments

Comments
 (0)