-
Notifications
You must be signed in to change notification settings - Fork 4
/
swunthesis.sty
executable file
·319 lines (280 loc) · 10.6 KB
/
swunthesis.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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
\ProvidesPackage{swunthesis}
% 引入基本宏包
% ==============================================================================
%
\usepackage{indentfirst} % 使得每章第一段中文缩进
% 数学相关
\usepackage{amsmath} % 重要的数学环境
\usepackage{wasysym} % 积分等特殊符号
% 图片相关
\usepackage{float} % 图片表格浮动
\usepackage{subfigure} % 子图
\usepackage{tikz} % 绘图宏包
\usepackage{graphicx} % 扩展 eps 图片支持
% 表格相关
\usepackage{csvsimple} % 通过 csv 数据创建表格
\usepackage{booktabs} % 创建没有竖线分割的表格
% 算法、代码相关
\usepackage{listings} % 提供代码插入环境
\usepackage{algorithm} % 提供算法浮动环境
\usepackage{algorithmic} % 提供算法描述环境
% 文献相关
%\usepackage[toc]{appendix} % 提供附录环境,暂时用不到
\usepackage{cite} % 文献引用,支持连续引用
% 定义代码样式
% ==============================================================================
%
% \usepackage[dvipsnames]{xcolor}
%
\usepackage{color}
\usepackage{xcolor}
\usepackage[CJKbookmarks=true,pdfborder=0 0 1]{hyperref}
\definecolor{keyword}{HTML}{BA2CA3}
\definecolor{string}{HTML}{D12F1B}
\definecolor{comment}{HTML}{008400}
\lstdefinelanguage{JavaScript}{
keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
ndkeywords={class, export, boolean, throw, implements, import, this},
ndkeywordstyle=\color{darkgray}\bfseries,
identifierstyle=\color{black},
sensitive=false,
comment=[l]{//},
morecomment=[s]{/*}{*/},
keywordstyle=\color{blue}\bfseries,
commentstyle=\color{gray}\ttfamily,
stringstyle=\color{green!50!yellow}\ttfamily,
morestring=[b]',
morestring=[b]"
}
\lstdefinelanguage{Swift}{
keywords={
func,if,then,else,for,in,while,do,switch,case,default,where,break,continue,fallthrough,return,
typealias,struct,class,enum,protocol,var,func,let,get,set,willSet,didSet,inout,init,deinit,extension,
subscript,prefix,operator,infix,postfix,precedence,associativity,left,right,none,convenience,dynamic,
final,lazy,mutating,nonmutating,optional,override,required,static,unowned,safe,weak,internal,
private,public,is,as,self,unsafe,dynamicType,true,false,nil,Type,Protocol,
},
comment=[l]{//}, % l is for line comment
morecomment=[s]{/*}{*/}, % s is for start and end delimiter
morestring=[b]", % defines that strings are enclosed in double quotes
keywordstyle=\color{keyword},
commentstyle=\color{gray}\ttfamily,
stringstyle=\color{green!50!yellow}\ttfamily,
}
\lstset{
basicstyle={\small\ttfamily},
keywordstyle={\bfseries\color{NavyBlue}},
breaklines=true,
emphstyle={\bfseries\color{Rhodamine}},
commentstyle={\color{PineGreen!60!black}},
stringstyle={\rmfamily\color{YellowOrange}},
showstringspaces=false,
frame=shadowbox,
breakatwhitespace=false,
captionpos=b,
extendedchars=true,
keepspaces=true,
numbers=left,
numberstyle=\tiny,
rulecolor=\color{black},
rulesepcolor={\color{blue!20!white}},
showspaces=false,
}
\renewcommand{\lstlistingname}{代码片段} % 将插入的代码从 Listing 1.1 变为 代码片段 1.1
% 提供定理环境
% ==============================================================================
%
% \newtheorem{definition}{定义}[section]
% \newtheorem{theorem}{定理}[section]
% \newtheorem{lemma}[theorem]{引理}
% \newtheorem{corollary}[theorem]{推论}
% 定义基础变量
% ==============================================================================
% 论文标题, thesis title
\newcommand{\titleValue}{}
\renewcommand{\title}[1]{\renewcommand{\titleValue}{#1}}
\newcommand{\entitleValue}{}
\newcommand{\entitle}[1]{\renewcommand{\entitleValue}{#1}}
% \renewcommand{\title}[1]{#1}
% 论文作者, tiesis author
\newcommand{\varAuthor}{}
\renewcommand{\author}[1]{\renewcommand{\varAuthor}{#1}}
\newcommand{\varAuthorEng}{}
\newcommand{\enauthor}[1]{\renewcommand{\varAuthorEng}{#1}}
% 论文日期, thesis date
\newcommand{\varDate}{}
\renewcommand{\date}[1]{\renewcommand{\varDate}{#1}}
% 论文导师, thesis adviser
\newcommand{\varAdviser}{}
\newcommand{\adviser}[1]{\renewcommand{\varAdviser}{#1}}
\newcommand{\varAdviserEng}{}
\newcommand{\enadviser}[1]{\renewcommand{\varAdviserEng}{#1}}
\newcommand{\advTitle}{}
\newcommand{\advtitle}[1]{\renewcommand{\advTitle}{#1}}
% 论文联合导师, co-adviser support
\newcommand{\varCoAdviser}{}
\newcommand{\coadviser}[1]{\renewcommand{\varCoAdviser}{#1}}
\newcommand{\varCoAdviserEng}{}
\newcommand{\encoadviser}[1]{\renewcommand{\varCoAdviserEng}{#1}}
\newcommand{\coadvTitle}{}
\newcommand{\coadvtitle}[1]{\renewcommand{\coadvTitle}{#1}}
% 学院名称, college name
\newcommand{\varCollege}{}
\newcommand{\college}[1]{\renewcommand{\varCollege}{#1}}
\newcommand{\varCollegeEng}{}
\newcommand{\encollege}[1]{\renewcommand{\varCollegeEng}{#1}}
% 专业名称, major name
\newcommand{\varMajor}{}
\newcommand{\major}[1]{\renewcommand{\varMajor}{#1}}
\newcommand{\varMajorEng}{}
\newcommand{\enmajor}[1]{\renewcommand{\varMajorEng}{#1}}
% 学号, student number
\newcommand{\varID}{}
\newcommand{\id}[1]{\renewcommand{\varID}{#1}}
% 年级, grade
\newcommand{\varGrade}{}
\newcommand{\grade}[1]{\renewcommand{\varGrade}{#1}}
% 摘要关键词, keyworkds
\newcommand{\varKeyword}{}
\newcommand{\keyword}[1]{\renewcommand{\varKeyword}{#1}}
% 自定义摘要环境
% ==============================================================================
%
\renewenvironment{abstract}[1]{
\addtolength{\leftskip}{1.1cm}
\addtolength{\rightskip}{1.1cm}
\vspace*{1cm}
\centerline{\heiti \zihao{-3} {摘要}}
\setcounter{page}{1}
\vspace{1.2cm}
\kaishu \zihao{5}
\keyword{#1}
}{
\\\par \textbf{关键词 } \varKeyword
\clearpage~~\thispagestyle{empty}\clearpage
}
\newenvironment{abstractEng}[1]{
\addtolength{\leftskip}{1.1cm}
\addtolength{\rightskip}{1.1cm}
\vspace*{1cm}
\centerline{\heiti \zihao{-3} \textbf{Abstract}}
\vspace{1.2cm}
\kaishu \zihao{5}
\keyword{#1}
}{
\\\par \textbf{Keywords} \varKeyword
\clearpage~~\thispagestyle{empty}\clearpage
}
% 自定义封面封面环境
% ==============================================================================
%
\usepackage{array} %
\newcommand{\makecover}{
\thispagestyle{empty}
\addtocounter{page}{0}
\vspace*{0cm}
\centerline{\includegraphics[height=1.6cm]{./template/title}}
\vspace*{1.2cm}
\centerline{\songti\zihao{3}本~~科~~生~~毕~~业~~设~~计(论~~文)} % skip bold, it's a hack and i dont know why
\vspace*{1.5cm}
\centerline{\songti \zihao{3} 题目:\titleValue}
\centerline{\songti~}
\centerline{\songti \zihao{4} \entitleValue}
\vspace*{4.0cm}
\centerline{
\begin{tabular}{ b{2cm} >{\centering\arraybackslash}b{8cm}}
\songti \zihao{4} 教学单位 & {\kaishu \zihao{4} \varCollege} \\[-3pt]
\cline{2-2} \\[0.1cm]
\songti \zihao{4} 姓\hspace{1cm}名 & {\kaishu \zihao{4} \varAuthor} \\[-3pt]
\cline{2-2} \\[0.1cm]
\songti \zihao{4} 学\hspace{1cm}号 & {\kaishu \zihao{4} \varID} \\[-3pt]
\cline{2-2} \\[0.1cm]
\songti \zihao{4} 年\hspace{1cm}级 & {\kaishu \zihao{4} \varGrade} \\[-3pt]
\cline{2-2} \\[0.1cm]
\songti \zihao{4} 专\hspace{1cm}业 & {\kaishu \zihao{4} \varMajor} \\[-3pt]
\cline{2-2} \\[0.1cm]
\songti \zihao{4} 导\hspace{1cm}师 & {\kaishu \zihao{4} \varAdviser} \\[-3pt]
\cline{2-2} \\[0.1cm]
\songti \zihao{4} 职\hspace{1cm}称 & {\kaishu \zihao{4} \advTitle} \\[-3pt]
\cline{2-2} \\[0.1cm]
\songti \zihao{4} 联合导师 & {\kaishu \zihao{4} \varCoAdviser} \\[-3pt]
\cline{2-2} \\[0.1cm]
\songti \zihao{4} 职\hspace{1cm}称 & {\kaishu \zihao{4} \coadvTitle} \\[-3pt]
\cline{2-2} \\[0.1cm]
\end{tabular}
}
\vfill
\centerline{\kaishu \zihao{3}\varDate}
\clearpage
~~\thispagestyle{empty}
\clearpage
\setcounter{page}{1}
\tableofcontents
\cleardoublepage
}
%
% 自定义页面边距
% ==============================================================================
%
\usepackage{geometry}
\geometry{
top=2.5cm, % 根据需求调整这个
headheight=0.5cm, % 这个
headsep=0.5cm, % 还有这个
inner=2.5cm,
outer=2cm,
bottom=2.5cm,
}
% 自定义行间距
% ==============================================================================
%
\usepackage{setspace}
\linespread{1.4} % 经验值, 不建议修改
% \setlength{\baselineskip}{25pt} % 行间距固定 20 磅, 但影响排版美观
%
% 自定义页眉环境
% ==============================================================================
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{\textcolor[gray]{0.5}{\zihao{-5} 西南民族大学本科毕业生论文}}
\rhead{\textcolor[gray]{0.5}{\zihao{-5} \varAuthor:\titleValue}}
% 自定义 CTEX 样式
% ==============================================================================
%
\ctexset{today=small}
%setup page counter
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
% 设置 chapter 格式
\fancypagestyle{plain}{} % let the chapter pages display headers
\ctexset{ chapter = { beforeskip={-10pt} } }
\ctexset{ chapter = { afterskip={10pt} } }
%\ctexset{ chapter = { name={第,章} } } % 可以通过该行定制为『第*章』形式
\ctexset{ chapter = { name={} } }
\ctexset{ chapter = { format={\raggedright}}}
\ctexset{ chapter = { number={\arabic{chapter}} }}
\ctexset{ chapter = { nameformat={\zihao{3} \bfseries \heiti} }}
\ctexset{ chapter = { titleformat={\zihao{3} \bfseries \heiti} }}
% 设置 section 格式
\ctexset{ section = { beforeskip={10pt} }}
\ctexset{ section = { afterskip={5pt} }}
\ctexset{ section = { format={\raggedright} }}
\ctexset{ section = { nameformat={\zihao{-3} \heiti} }}
\ctexset{ section = { titleformat={\zihao{-3} \heiti} }}
% 设置 subsection 格式
\ctexset{ subsection = { beforeskip={5pt} }}
\ctexset{ subsection = { afterskip={1pt} }}
\ctexset{ subsection = { format={\raggedright} }}
\ctexset{ subsection = { nameformat={\zihao{4} \heiti} }}
\ctexset{ subsection = { titleformat={\zihao{4} \heiti} }}
% 设置 subsubsection 格式
\ctexset{ subsubsection = { beforeskip={0pt} }}
\ctexset{ subsubsection = { afterskip={1pt} }}
\ctexset{ subsubsection = { format={\raggedright} }}
\ctexset{ subsubsection = { nameformat={\zihao{-4} \heiti} }}
\ctexset{ subsubsection = { titleformat={\zihao{-4} \heiti} }}
% 设置中文字体集为 Adobe 开源字体系列
\ctexset{ fontset = adobe }
% 设置英文字体为 Times New Roman
%\usepackage{fontspec}
%\setmainfont{Times New Roman}