-
Notifications
You must be signed in to change notification settings - Fork 0
/
bjtu-bachelor-thesis.cls
539 lines (462 loc) · 16.5 KB
/
bjtu-bachelor-thesis.cls
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
%========================================================================%
% Copyright (C) 2016 All Rights Reserved. %
% Author:BillHu<billhu@icloud.com> Ver:<1.0> %
%========================================================================%
% The author grants permission, without fee and without a written %
% license agreement, for use, reproduction, modification, and distribu- %
% tion of this software and its documentation by educational, research, %
% and non-profit entities for noncommercial purposes only.The above %
% copyright notice and this paragraph MUST appear in all copies and %
% modifications of the software and/or documentation. %
%========================================================================%
\ProvidesClass{bjtu-bachelor-thesis}[2022/04/02]
\def\version{1.0}
% \LoadClass[a4paper,zihao=-4,twoside,hyperref,openright]{ctexbook}
\LoadClass[a4paper,zihao=-4,twoside,openright]{ctexbook}
\NeedsTeXFormat{LaTeX2e}
%========================================================================%
% 基本宏包
%========================================================================%
\RequirePackage{caption}
\RequirePackage{mathptmx}
\RequirePackage{changepage}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{geometry}
\RequirePackage{fancyhdr}
\RequirePackage{tabularx}
% \RequirePackage{subcaption}
\RequirePackage{pgfplots}
% \RequirePackage{tikz}
\RequirePackage{multicol}
\RequirePackage{setspace}
\RequirePackage{titletoc}
\RequirePackage{fontspec}
\RequirePackage[colorlinks,linkcolor=black,anchorcolor=black,citecolor=black,urlcolor=black]{hyperref}
\RequirePackage{calc}
\RequirePackage{datetime}
\RequirePackage{etoolbox}
\RequirePackage{booktabs}
\RequirePackage{floatrow}
\RequirePackage{appendix}
\RequirePackage{enumitem}
% \RequirePackage[backend=biber,style=gb7714-2015]{biblatex}
\RequirePackage{biblatex}
\RequirePackage{underscore}
\RequirePackage{listings}
% \RequirePackage{color}
\RequirePackage{multirow}
% \RequirePackage{float}
% \RequirePackage[linesnumbered,ruled]{algorithm2e}
% \RequirePackage{algpseudocode}
\RequirePackage{enumitem}
\RequirePackage{xcolor}
%========================================================================%
% 北京交大明确给出的格式
%========================================================================%
\setCJKfamilyfont{hwzs}{stzhongs.ttf}
\newcommand{\hwzs}{\CJKfamily{hwzs}}
\setCJKfamilyfont{timesnewroman}{timesnewroman.ttf}
\newcommand{\timesnewroman}{\CJKfamily{timesnewroman}}
\setCJKfamilyfont{mysong}{simsun.ttc}[AutoFakeBold=2.5]
\newcommand*{\mysongti}{\CJKfamily{mysong}}
\newfontfamily{\eheiti}{simhei.ttf}
\setCJKfamilyfont{myhei}{simhei.ttf}[AutoFakeBold=2]
\newcommand*{\myheiti}{\CJKfamily{myhei}}
\newcommand*{\yearmonth}{\songti \zihao{-3} \the \year 年 \the \month 月}
\geometry{left=2.5cm,right=2.5cm,top=3.0cm,bottom=3.0cm,headheight=1.5cm,footskip=1.2cm}
\setmainfont{Times New Roman}
\linespread{1.4}\selectfont
\setlength{\baselineskip}{20pt}
\renewcommand{\arraystretch}{1.2}
\renewcommand{\captionfont}{\zihao{5}}
\renewcommand{\theequation}{\arabic{chapter}-\arabic{equation}}
\renewcommand{\thefigure}{\arabic{chapter}-\arabic{figure}}
\renewcommand{\thetable}{\arabic{chapter}-\arabic{table}}
\DeclareCaptionFont{mysongti}{\zihao{5}\mysongti}
\captionsetup{font=mysongti}
\DeclareFloatFont{mysongti}{\zihao{5}\mysongti}
\DeclareFloatVCode{figureafterfloat}{\vspace{-16pt}}
\DeclareFloatVCode{tableafterfloat}{\vspace{-4pt}}
\floatsetup[table]{font=mysongti,capposition=top,captionskip=2pt,postcode=tableafterfloat}
\floatsetup[figure]{font=mysongti,capposition=bottom,captionskip=4pt,postcode=figureafterfloat}
\ctexset{
chapter = {
name={,},
number={\arabic {chapter}},
beforeskip={-4pt},
afterskip={18pt},
nameformat={},
titleformat={},
format=\heiti\zihao{3},
},
section = {
format=\raggedright\heiti\zihao{-3},
beforeskip={24pt},
afterskip={18pt},
},
subsection = {
format=\raggedright\heiti\zihao{4},
beforeskip={24pt},
afterskip={18pt},
},
}
\setlength{\itemsep}{100pt}
\captionsetup[table]{labelsep=space} % 表
\captionsetup[figure]{labelsep=space} % 图
%========================================================================%
\newcommand{\figcaption}[1]{\caption{图}{#1}}
%========================================================================%
% 目录格式
%========================================================================%
\makeatletter
\renewcommand\tableofcontents{%
\chapter*{\makebox[\linewidth]{\zihao{-2} 目\hspace{2em}录}
\@mkboth{\MakeUppercase \contentsname}{}}% ADDED
\vspace{-0.5cm}
\@starttoc{toc}%
}
\makeatother
\makeatletter
\renewcommand\contentspage[1][\MakeUppercase{\eheiti \thecontentspage}]{%
\hb@xt@\@pnumwidth{\hfil#1}%
\hspace*{-\@pnumwidth}}
\makeatother
\titlecontents{part}[0em]{\vspace{0.2ex}}{\eheiti \zihao{-4}\contentslabel{0em}}{\eheiti \myheiti\zihao{-4}}{\titlerule*[0.5pc]{.}\contentspage}[\vspace{0.2ex}]
% \contentsmargin{1em}
\titlecontents{chapter}[1.5em]{\vspace{0.3ex}}{\myheiti \eheiti \zihao{-4}\contentslabel{1.5em}}{\myheiti \eheiti \zihao{-4}}{\titlerule*[0.5pc]{.}\contentspage}[\vspace{0.15ex}]
\titlecontents{section}[3em]{\hspace{0em}}{\contentslabel{2.2em}}{\songti \zihao{-4}}{\titlerule*[0.5pc]{.}\contentspage}[\vspace{0ex}]
\titlecontents{subsection}[4.5em]{\hspace{0em}}{\contentslabel{2.9em}}{\songti \zihao{-4}}{\titlerule*[0.5pc]{.}\contentspage}[\vspace{0ex}]
%========================================================================%
% 页眉设置
%========================================================================%
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancypagestyle{myfancy}{
\fancyhead[CE,CO]{}
\fancyhead[L]{\zihao{4}\hwzs \hspace*{0.5cm}北京交通大学毕业设计(论文)}
\fancyhead[R]{\zihao{4}\hwzs \leftmark\hspace*{0.5cm}}
\fancyfoot[CO,CE]{\zihao{5}\thepage}
% Redefining headrule
\makeatletter
\renewcommand{\headrule}{\hrule height 2.5pt \vspace{1pt}\hrule height 1pt}
% \renewcommand{\headrule}{\hrule height 1pt \vspace{1pt}\hrule height 2.5pt}
}
\fancypagestyle{myfancymain}{
\fancyhead[R]{\zihao{4}\hwzs 正文\hspace*{0.5cm}}
}
\fancypagestyle{myextra}{
\fancyhead[CE,CO]{}
\fancyhead[L]{\zihao{4}\hwzs \hspace*{0.5cm}北京交通大学毕业论文(设计)}
\fancyhead[R]{\zihao{4}\hwzs \leftmark\hspace*{0.5cm}}
\fancyfoot[CO,CE]{\zihao{5}\thepage}
% Redefining headrule
\makeatletter
\renewcommand{\headrule}{\hrule height 2.5pt \vspace{1pt}\hrule height 1pt}
\fancyfoot{}
}
\fancypagestyle{myempty}{
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{myclear}{
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot{}
}
\fancypagestyle{plain}{
\fancyhead{}
\fancyhead[CE]{\zihao{5}\hspace{2em}北京交通大学硕士学位论文}
\fancyhead[CO]{\zihao{5}\hspace{2em}\leftmark}
\fancyfoot[CO,CE]{\zihao{-5}\thepage}
\renewcommand{\headrulewidth}{0.4pt}
}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
%========================================================================%
% 自定义内容
%========================================================================%
\newcommand{\ctitle}[1]{\renewcommand{\ctitle}{#1}}
\newcommand{\etitle}[1]{\renewcommand{\etitle}{#1}}
\newcommand{\cdata}[1]{\renewcommand{\cdata}{#1}}
\newcommand{\cauthor}[1]{\renewcommand{\cauthor}{#1}}
\newcommand{\cschool}[1]{\renewcommand{\cschool}{#1}}
\newcommand{\cmajor}[1]{\renewcommand{\cmajor}{#1}}
\newcommand{\cid}[1]{\renewcommand{\cid}{#1}}
\newcommand{\ctutor}[1]{\renewcommand{\ctutor}{\songti\zihao{3}#1}}
\newcommand{\cthanks}[1]{\renewcommand{\cthanks}{#1}}
\newcommand{\cchinese}[1]{\renewcommand{\cchinese}{#1}}
\newcommand{\cenglish}[1]{\renewcommand{\cenglish}{#1}}
\newcommand{\cabstract}[1]{\renewcommand{\cabstract}{#1}}
\newcommand{\ckeywords}[1]{\renewcommand{\ckeywords}{#1}}
\newcommand{\eabstract}[1]{\renewcommand{\eabstract}{#1}}
\newcommand{\ekeywords}[1]{\renewcommand{\ekeywords}{#1}}
\newcommand{\authorsign}[1]{\renewcommand{\authorsign}{#1}}
\newcommand{\tutorsign}[1]{\renewcommand{\tutorsign}{#1}}
\newcommand{\authorsigndate}[1]{\renewcommand{\authorsigndate}{#1}}
\newcommand{\tutorsigndate}[1]{\renewcommand{\tutorsigndate}{#1}}
% 插入代码样式
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{frame=none,
language=Java,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breakatwhitespace=true,
tabsize=3
}
%========================================================================%
% 参考文献格式
%========================================================================%
\addbibresource[]{MyDissBib.bib}
\defbibheading{myheading}[\zihao{-2}参考文献]{%
\centering\chapter*{#1}
\markboth{参考文献}{}}
\defbibenvironment{bibliography}
{\list
{}
{\setlength{\leftmargin}{2pt}%
\setlength{\itemindent}{2em}%
\setlength{\itemsep}{0pt}%
\setlength{\parsep}{\bibparsep}
}}
{\endlist}
{\item
\zihao{5} \mysongti
\printtext[labelnumberwidth]{%
\printfield{labelprefix}%
\printfield{labelnumber}}%
\addspace}
%========================================================================%
% 前置部分命令
%========================================================================%
% 设置有序和无序列表行距和留白
\setlist[itemize]{noitemsep, topsep=0pt}
\setlist[enumerate]{noitemsep, topsep=0pt}
% 设置全局样式
\let\cleardoublepage=\clearpage
\makeatletter
\let\ps@plain\ps@fancy
\patchcmd{\chapter}{plain}{myfancy}{}{}
\makeatother
\newenvironment{thecenter}
{\begin{center}\vspace{24pt}\zihao{-2}\heiti}
{\vspace{18pt}\end{center}}
\newcommand{\cover}{
\thispagestyle{myclear}
\vspace*{0.6cm}
\begin{center}
\includegraphics[width=107mm]{pic/newlogo.pdf}
{\vspace{1.1cm}\zihao{2}\mysongti \textbf{本科毕业论文(设计)}}
\vspace{1.98em}
\vspace*{\fill}
\begin{spacing}{2}
{\zihao{-2}\myheiti\textbf{\ctitle}}
\end{spacing}
\vspace*{1.4em}
\begin{spacing}{2}
{\zihao{-2}\mysongti\textbf{\etitle}}
\end{spacing}
\vspace*{\fill}
\newlength{\capwidth}
\setlength{\capwidth}{\widthof{\zihao{3}学生姓名:}}
\begin{spacing}{2}
\begin{tabular}{lc}
\rule{\capwidth}{0pt} & \rule{5cm}{0pt} \\
\makebox[\capwidth][s]{\zihao{3}学院:} & \cschool \\ \cline{2-2}
\makebox[\capwidth][s]{\zihao{3}专业:} & \cmajor \\ \cline{2-2}
\makebox[\capwidth][s]{\zihao{3}学生姓名:} & \cauthor \\ \cline{2-2}
\makebox[\capwidth][s]{\zihao{3}学号:} & \cid \\ \cline{2-2}
\makebox[\capwidth][s]{\zihao{3}指导教师:} & \ctutor \\ \cline{2-2}
\end{tabular}
\end{spacing}
\vspace*{1cm}
\zihao{-3}\mysongti \textbf{北京交通大学}\vspace*{0.5ex}
\yearmonth
\end{center}
\newpage
}
\newcommand{\ccopyright}{
% \thispagestyle{myccopyright
\thispagestyle{myextra}
\markboth{版权使用说明书}{}
\vspace*{0cm}
\begin{center}
{\zihao{-2}\heiti 学士论文版权使用授权书\bigskip}
\end{center}
本学士论文作者完全了解北京交通大学有关保留、使用学士论文的规定。特授权北京交通大学可以将学士论文的全部或部分内容编入有关数据库进行检索,提供阅览服务,并采用影印、缩印或扫描等复制手段保存、汇编以供查阅和借阅。\\
\begin{center}
(保密的学位论文在解密后适用本授权说明)
\end{center}
\vspace{3cm}
\begin{minipage}[t]{0.5\textwidth}
学位论文作者签名:\authorsign
签字日期:\authorsigndate
\end{minipage}
\hfill
\begin{minipage}[t]{0.4\textwidth}
指导教师签名:\tutorsign
签字日期:\tutorsigndate
\end{minipage}
\newpage
}
\newcommand{\chonesty}{
% \thispagestyle{mychonesty}
\thispagestyle{myextra}
\fancyfoot{}
\markboth{论文诚信声明}{}
\vspace*{0cm}
\begin{center}
{\zihao{-2}\heiti 学士论文诚信声明\bigskip}
\end{center}
本人声明所呈交的毕业论文(设计),题目\underline{~\ctitle~}是本人在指导教师的指导下,独立进行研究工作所取得的成果。尽我所知,除了文中特别加以标注和谢中所罗列的内容以外,论文中不包含其他人已经发表或撰写过的研究成果,也不包含为获得北京交通大学或其他教育机构的学位或证书而使用过的材料。
申请学位论文与资料若有不实之处,本人承担一切相关责任。\\
% \vspace{3cm}
\begin{minipage}[t]{0.417\textwidth}
本人签名:\underline{\hspace{3.75cm}}
\end{minipage}
\begin{minipage}[t]{0.4\textwidth}
日期: \underline{\hspace{3.75cm}}
\end{minipage}
% 签字日期:\authorsigndate
% \end{minipage}
% \hfill
% \begin{minipage}[t]{0.4\textwidth}
% 指导教师签名:\tutorsign
% 签字日期:\tutorsigndate
% \end{minipage}
\newpage
}
\newcommand{\cfanyi}{
% \thispagestyle{mychonesty}
\setlength{\baselineskip}{20pt} %行距20磅
\pagestyle{myextra}
\fancyfoot{}
\markboth{外文原文与译文}{}
% \vspace*{0cm}
\noindent\begin{minipage}[t]{0.09\textwidth}
\hwzs 题~目:
\end{minipage}
\begin{minipage}[t]{0.905\textwidth}
\begin{center}
\hwzs\ctitle
\end{center}
\par
\vspace{-1.05cm}
\hrulefill
\end{minipage}
\vspace{0.3cm} %行距
\noindent\begin{minipage}[t]{0.08\textwidth}
\hwzs 学院:
\end{minipage}
\noindent\begin{minipage}[t]{0.42\textwidth}
\begin{center}
\hwzs \cschool
\end{center}
\par
\vspace{-1.05cm}
\hrulefill
\end{minipage}
\begin{minipage}[t]{0.08\textwidth}
\hwzs 专业:
\end{minipage}
\begin{minipage}[t]{0.405\textwidth}
\begin{center}
\hwzs \cmajor
\end{center}
\par
\vspace{-1.05cm}
\hrulefill
\end{minipage}
\vspace{0.3cm} %行距
\noindent
\begin{minipage}[t]{0.13\textwidth}
\hwzs 学生姓名:
\end{minipage}
\noindent\begin{minipage}[t]{0.37\textwidth}
\begin{center}
\hwzs \cauthor
\end{center}
\par
\vspace{-1.05cm}
\hrulefill
\end{minipage}
\begin{minipage}[t]{0.08\textwidth}
\hwzs 学号:
\end{minipage}
\noindent\begin{minipage}[t]{0.405\textwidth}
\begin{center}
\hwzs \cid
\end{center}
\par
\vspace{-1.05cm}
\hrulefill
\end{minipage}
\vspace{0.4cm} %行距
\renewcommand{\thefigure}{\arabic{figure}}
\renewcommand\thesection{\arabic{section}}
\renewcommand{\thetable}{\arabic{table}}
\renewcommand{\figurename}{Figure}
\renewcommand{\tablename}{Table}
\noindent\hspace{0.1cm}\hwzs 一、外文原文\par
\timesnewroman\cenglish
\vspace{0.2cm}
\setcounter{figure}{0}
\setcounter{table}{0}
\setcounter{section}{0}
\renewcommand{\figurename}{图}
\renewcommand{\tablename}{表}
\noindent\hspace{0.1cm}\hwzs 二、译文\par
\songti\cchinese
}
\newcommand{\myclpage}{
\thispagestyle{myclear}
\mbox{}
\newpage
}
\newcommand{\myfanpage}{
\thispagestyle{myfancy}
\mbox{}
\newpage
}
\newcommand{\thankspage}{
\thispagestyle{myempty}
\chapter*{\makebox[\linewidth]{\zihao{-2}致\hspace{2em}谢}}
\markboth{致谢}{}
\addcontentsline{toc}{part}{致\hspace{2em}谢}
\cthanks
\newpage
}
\newcommand{\cabspage}{
\thispagestyle{myfancy}
\chapter*{\makebox[\linewidth]{\zihao{-2}中文摘要}}
\markboth{中文摘要}{}
\addcontentsline{toc}{part}{中文摘要}
\noindent\mysongti{\textbf{摘要:}}\cabstract \par
\vspace{2cm}
\noindent \mysongti {\textbf{关键词:}\ckeywords}
\newpage
}
\newcommand{\eabspage}{
\thispagestyle{myfancy}
\chapter*{\makebox[\linewidth]{\zihao{-2}ABSTRACT}}
\markboth{英文摘要}{}
\addcontentsline{toc}{part}{ABSTRACT}
\noindent\mysongti{\textbf{ABSTRACT:}}
\noindent\eabstract \par
\vspace{2cm}
\noindent \mysongti {\textbf{KEYWORDS:\;}\ekeywords}
\newpage
}
%========================================================================%
% 结束
%========================================================================%