forked from Jeff-Hugh/USTBThesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
USTBThesis.cls
296 lines (261 loc) · 8.72 KB
/
USTBThesis.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
% !Mode:: "TeX:UTF-8"
% University of Science and Technology Beijing Thesis Template
% For Bachelor Master and Doctor
%
% Version
% 0.1
% Created
% 2015.12.21 by JeffHugh@USTB
%
%%%%%%%%%% class clarification %%%%%%%%%%
%
\NeedsTeXFormat{LaTeX2e}[2007/10/19]
\ProvidesClass{USTBThesis}[2015/12/21 v0.1 USTBthesis document class]
%定义模板学位选项
\newif\ifustb@master\ustb@masterfalse
\newif\ifustb@doctor\ustb@doctorfalse
\DeclareOption{master}{\ustb@mastertrue}
\DeclareOption{doctor}{\ustb@doctortrue}
% 其余选项传递给ctexbook
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{ctexbook}}
\ProcessOptions\relax
% 引用ctexbook及基本设置
\LoadClass[cs4size,a4paper,fancyhdr,twoside,UTF8]{ctexbook}[2007/10/19]
%主要字体设置
\setCJKmainfont{SimSun.ttc}% I don't understand why this stupid university use a property font here. This is non-sense.
\setCJKfamilyfont{zhsongx}{SimSun.ttc}
\renewcommand*{\songti}{\CJKfamily{zhsongx}}
\setCJKfamilyfont{zhheix}{SimHei.ttf}
\renewcommand*{\heiti}{\CJKfamily{zhheix}}
\setmainfont{tnr.ttf}
\RequirePackage[pdfstartview=FitH, CJKbookmarks=true, bookmarksnumbered=true,bookmarksopen=true, colorlinks=false, colorlinks=black,pdfborder=100, citecolor=black ]{hyperref} % 书签设置
\RequirePackage[super,square,numbers,sort&compress]{natbib} %参考文献设置
\RequirePackage{ulem} %下划线强调
\RequirePackage{fancyhdr} %页眉页脚
\RequirePackage{mathptmx} %是英文字体为Times New Roman
\RequirePackage{tabu} %表格
\RequirePackage{booktabs} %表格线宏包
\RequirePackage{tabularx} %调整表格列宽
\RequirePackage{multirow} %表格合并
\RequirePackage{array} %数组宏包,用于表格宽度
\RequirePackage{multicol} %表格合并
\RequirePackage{longtable} %表格合并
\RequirePackage{rotating} %表格合并
\RequirePackage[top=31mm, bottom=30mm, outer=3cm, inner=4cm,headsep=1.1cm]{geometry} %页面边距设置
\RequirePackage{graphicx} %插图
\RequirePackage{amsmath,bm} %公式换行
\RequirePackage{titletoc} %目录
\RequirePackage{titlesec} %章节
\RequirePackage{listings} %插入代码
\RequirePackage{texnames} %TeX家族标识符
\RequirePackage{float} %表格位置
\RequirePackage{setspace} %调整行距
\RequirePackage{lastpage} %得到论文页数
\RequirePackage{subfig}
\RequirePackage{enumerate} %自定义列表编号
\RequirePackage{listings} %插入程序代码
\lstset{breaklines} %这条命令可以让LaTeX自动将长的代码行换行排版
\lstset{extendedchars=false} %这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题
% Provides better toc mimicing ^_^
\usepackage{titletoc}
\titlecontents{figure}[0mm]%
{\makebox{图~}}%
{\makebox{\thecontentslabel\quad}}%
{}%
{\enspace\dotfill\enspace\thecontentspage}
\titlecontents{table}[0mm]%
{\makebox{表~}}%
{\makebox{\thecontentslabel\quad}}%
{}%
{\enspace\dotfill\enspace\thecontentspage}
%\usepackage{CJKvert} %直排文字
%%%%%%%%%%%%%%%%%%%%%%%%%论文信息%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%学校
\def\UniversityCN{北京科技大学}
\def\UniversityEN{University of Science and Technology Beijing}
\newcommand{\university}[2]{%
\def\UniversityCN{#1}
\def\UniversityEN{#2}
}
%学院
\def\SchoolCN{土木与环境工程学院}
\def\SchoolEN{School of Civil and Environmental Engineering}
\newcommand{\school}[2]{%
\def\SchoolCN{#1}
\def\SchoolEN{#2}
}
%专业
\def\MajorCN{}
\def\MajorEN{}
\newcommand{\major}[2]{%
\def\MajorCN{#1}
\def\MajorEN{#2}
}
%学位
\def\degreecn{}
\def\degreeen{}
\newcommand{\degree}[2]{%
\def\degreecn{#1}
\def\degreeen{#2}
}
\ifustb@doctor
\degree{博士}{Doctor of Philosophy}
\else
\ifustb@master
\degree{硕士}{Master}
\fi
\fi
%论文标题
\def\ThesisTitleCN{}
\def\ThesisTitleEN{}
\def\ThesisSubTitleCN{}
\def\ThesisSubTitleEN{}
\newcommand{\thesistitle}[4]{%
\def\ThesisTitleCN{#1}
\def\ThesisTitleEN{#2}
\def\ThesisSubTitleCN{#3}
\def\ThesisSubTitleEN{#4}
}
%作者
\def\AuthorCN{}
\def\AuthorEN{}
\newcommand{\thesisauthor}[2]{%
\def\AuthorCN{#1}
\def\AuthorEN{#2}
}
%学号
\def\StudentID{}
\newcommand{\authorid}[1]{%
\def\StudentID{#1}
}
% 指导老师
\def\TeacherCN{}
\def\TeacherEN{}
\def\TeacherDepartment{}
\def\TeacherJobtitle{}
\newcommand{\teacher}[4]{%
\def\TeacherCN{#1}
\def\TeacherEN{#2}
\def\TeacherDepartment{#3}
\def\TeacherJobtitle{#4}
}
% 副指导老师
\def\SubTeacherCN{}
\def\SubTeacherEN{}
\def\SubTeacherDepartment{}
\def\SubTeacherJobtitle{}
\newcommand{\subteacher}[4]{%
\def\SubTeacherCN{#1}
\def\SubTeacherEN{#2}
\def\SubTeacherDepartment{#3}
\def\SubTeacherJobtitle{#4}
}
% 分类号
\def\ThesisCategory{}
\newcommand{\category}[1]{%
\def\ThesisCategory{#1}
}
% 论文提交日期
\def\ThesisYear{}
\def\ThesisMonth{}
\def\ThesisDay{}
\newcommand{\thesisdate}[3]{%
\def\ThesisYear{#1}
\def\ThesisMonth{#2}
\def\ThesisDay{#3}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%一级标题
\def\@chapter[#1]#2{%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
%\typeout{\@chapapp\space\thechapter}
\typeout{\CTEXthechapter}%
\addcontentsline{toc}{chapter}
%{\protect\numberline {\thechapter}#1}%
{\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi
}
\def\@makechapterhead#1{%
\vskip 17pt
%\vspace*{\CTEX@chapter@beforeskip}%
{\normalfont \parindent \z@ \raggedright
%{\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
% \bfseries \space\nobreak
%\vskip 20\p@ \@chapapp \thechapter
\CTEX@chaptername \zihao{-3} \heiti
\fi
\fi
\interlinepenalty\@M
%\Huge \bfseries #1\par\nobreak
\CTEX@chapter@titleformat #1\par\nobreak
\vskip 17pt
%\vskip \CTEX@chapter@afterskip
}
}
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname\ }
%%%%%%%二级标题
\renewcommand\section{\@startsection{section}{1}{\z@}%
{13pt \@plus 2pt \@minus 2pt}%
{13pt \@plus 2pt \@minus 2pt}%
{ \zihao{4} \raggedright \bf \heiti}%
}
%%%%%%%三级标题
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{13pt \@plus 2pt \@minus 2pt}%
{13pt \@plus 2pt \@minus 2pt}%
{ \zihao{4} \raggedright \bf \heiti}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% 设置行距
\renewcommand{\baselinestretch}{1.383} \normalsize % Magic number from https://github.com/liuzhaoboatenficomcn/Latex-template-for-University-of-Science-and-Technology-Beijing/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%公式、图名和表名用“2-3”形式表示
\makeatletter
\numberwithin{figure}{chapter}
\numberwithin{table}{chapter}
\renewcommand{\thefigure}{\thechapter-\arabic{figure}}
\renewcommand{\thetable}{\thechapter-\arabic{table}}
\@addtoreset{equation}{chapter}
\makeatother
\renewcommand\theequation{\arabic{chapter}-\arabic{equation}}
\RequirePackage{caption} %图表标题设置
\DeclareCaptionFont{heiti}{\heiti}
\DeclareCaptionFont{wuhao}{\zihao{5}}
\captionsetup[table]{font={wuhao,bf,heiti},labelsep=space,skip=0.5ex,
position=top}
\captionsetup[figure]{font={wuhao,bf,heiti},labelsep=space,skip=0.5ex,
position=bottom}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%目录%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\contentsname}{\centering 目\quad 录}
\titlecontents{chapter}[0pt]{\heiti\zihao{-4}}{\thecontentslabel\ }{}
{\hspace{.5em}\titlerule*[4pt]{$\cdot$}\contentspage}
\titlecontents{section}[2em]{\vspace{0.1\baselineskip}\songti\zihao{-4}}{\thecontentslabel\ }{}
{\hspace{.5em}\titlerule*[4pt]{$\cdot$}\contentspage}
\titlecontents{subsection}[4em]{\vspace{0.1\baselineskip}\songti\zihao{-4}}{\thecontentslabel\ }{}
{\hspace{.5em}\titlerule*[4pt]{$\cdot$}\contentspage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%定义摄氏度单位符号 \celsius ,在公式和文本中都可使用%%%%
\def\celsius{\ensuremath{^\circ\hspace{-0.09em}\mathrm{C}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%Footer, surround the page number by nice little dashs.
\cfoot{-~\thepage~-}