-
Notifications
You must be signed in to change notification settings - Fork 119
/
BUPTthesisbachelor.sty
366 lines (324 loc) · 14.1 KB
/
BUPTthesisbachelor.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
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Copyright (c) 2010 - 2011 Caspar Zhang <casparant@gmail.com> %
% %
% This copyrighted material is made available to anyone wishing %
% to use, modify, copy, or redistribute it subject to the terms %
% and conditions of the GNU General Public License version 2. %
% %
% This program is distributed in the hope that it will be %
% useful, but WITHOUT ANY WARRANTY; without even the implied %
% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %
% PURPOSE. See the GNU General Public License for more details. %
% %
% You should have received a copy of the GNU General Public %
% License along with this program; if not, write to the Free %
% Software Foundation, Inc., 51 Franklin Street, Fifth Floor, %
% Boston, MA 02110-1301, USA. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\usepackage[fntef]{ctex} % invole CJKfntef
\usepackage{ctex}
\usepackage{setspace} % spacing
\usepackage{xcolor} % color
\usepackage{xltxtra} % print a XeLaTeX
% Font family
\setmainfont[Mapping=tex-text]{Times New Roman}
% Font size
\newcommand{\chuhao}{\zihao{0}}
\newcommand{\xiaochuhao}{\zihao{-0}}
\newcommand{\yihao}{\zihao{1}}
\newcommand{\xiaoyihao}{\zihao{-1}}
\newcommand{\erhao}{\zihao{2}}
\newcommand{\xiaoerhao}{\zihao{-2}}
\newcommand{\sanhao}{\zihao{3}}
\newcommand{\xiaosanhao}{\zihao{-3}}
\newcommand{\sihao}{\zihao{4}}
\newcommand{\xiaosihao}{\zihao{-4}}
\newcommand{\wuhao}{\zihao{5}}
\newcommand{\xiaowuhao}{\zihao{-5}}
\newcommand{\liuhao}{\zihao{6}}
\newcommand{\xiaoliuhao}{\zihao{-6}}
\newcommand{\qihao}{\zihao{7}}
\newcommand{\bahao}{\zihao{8}}
% Normal font size is XiaosiHao
\renewcommand{\normalsize}{\xiaosihao\songti\normalfont}
% Serveral Font pre-setting
\newcommand{\thesistitlefont}{\centering\heiti\sanhao\textbf} %论文题目的字体
\newcommand{\thesistitleenfont}{\centering\sanhao\bf} %论文英文题目的字体
\newcommand{\covernamefont}{\heiti\yihao\bf} % 封面上“本科论文”字样的字体
\newcommand{\coveritemsfont}{\songti\sanhao\bf} % 封面上姓名等条目的字体
\newcommand{\coverdatefont}{\songti\sanhao\bf} % 封面上的日期的字体
\newcommand{\statetitlefirst}{\songti\xiaosanhao\bf} %诚信声明标题第一行的字体
\newcommand{\statetitlesecond}{\songti\xiaosanhao\bf} %诚信声明标题第二行的字体
\newcommand{\abszhname}{\heiti\xiaosanhao\textbf} % 中文“摘要”字样的字体
\newcommand{\abszhkey}{\heiti\xiaosihao\textbf} % 中文摘要“关键字”字样的字体
\newcommand{\abszhkeys}{\songti\xiaosihao\normalfont} % 中文摘要关键字的字体
\newcommand{\absenname}{\xiaosanhao\textbf} % 英文``Abstract''字样的字体
\newcommand{\absenkey}{\xiaosihao\textbf} % 英文``KEY WORDS''字样的字体
\newcommand{\absenkeys}{\xiaosihao\normalfont} % 英文关键字的字体
\newcommand{\headfont}{\songti\xiaowuhao\normalfont} % 页眉字体
\newcommand{\toctitlefont}{\heiti\sanhao\textbf} % “目录”字样的字体
\newcommand{\tocchapterfont}{\heiti\xiaosihao} % 目录上第X章的字体
\newcommand{\tocsectionfont}{\songti\xiaosihao\normalfont} % 目录上X.Y节的字体
\newcommand{\tocsubsectionfont}{\songti\xiaosihao\normalfont} % 目录上X.Y.Z小节的字体
\newcommand{\tocsubsubsectionfont}{\songti\xiaosihao\normalfont} % 目录上X.Y.Z.A小节的字体
\newcommand{\textchapterfont}{\centering\heiti\sanhao\bfseries} % 正文上第X章的字体
\newcommand{\textsectionfont}{\heiti\sihao\bfseries} % 正文上X.Y节的字体
\newcommand{\textsubsectionfont}{\heiti\xiaosihao\bfseries} % 正文上X.Y.Z小节的字体
\newcommand{\textsubsubsectionfont}{\heiti\xiaosihao\bfseries} % 正文上X.Y.Z.A小节的字体
\newcommand{\footnotefont}{\songti\xiaowuhao\normalfont} % 脚注字体
%\newcommand{\ftcaptionfont}{\kaishu\wuhao\normalfont} % 图表标题的字体
\newcommand{\ftcaptionfont}{\kaishu\wuhao} % 图表标题的字体
\newcommand{\reftitlefont}{\heiti\sanhao\textbf} % “参考文献”字样的字体
\newcommand{\refbodyfont}{\songti\wuhao\normalfont} % 参考文献字体
\newcommand{\thanktitlefont}{\heiti\sanhao\textbf} % “致谢”字样的字体
\newcommand{\appendixtitlefont}{\heiti\sanhao\textbf} % “附录”字样的字体
\newcommand{\translationtitlefont}{\heiti\sanhao} % “外文译文”字样的字体
% Word spacing
% Usage: \ziju{spacing} spacing can be 1em, 10pt, etc.
%\newcommand{\ziju}[1]{\renewcommand{\CJKglue}{\hskip #1}}
%%%%%% Page Style %%%%%%
% Margin
% FIXME: Not very precise, but meets the need of the Word template.
% \usepackage[left=2.5cm,margin=2.5cm,headheight=1.5cm,footskip=1.5cm]{geometry}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm,headheight=1.5cm,headsep=0.6cm,footskip=0.5cm,textwidth=16cm,textheight=24.7cm]{geometry}
% Header and footer
\usepackage{fancyhdr}
\fancypagestyle{mainmatter}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[C]{\headfont{北京邮电大学本科毕业设计(论文)}}
\fancyfoot[C]{\footnotefont{\thepage}}
\renewcommand{\headrulewidth}{0.8pt}
}
\fancypagestyle{frontmatter}{%
\fancyhf{} % clear all header and footer fields
\fancyhead{}
\fancyfoot[C]{\footnotefont{\thepage}} % except the center
\renewcommand{\headrulewidth}{0pt}
}
% Bookmark (Chinese bookmark supported)
\usepackage{url}
\def\UrlFont{}
\usepackage[xetex, pdfstartview=FitH,
bookmarksnumbered=true, bookmarksopen=true, colorlinks=true,
pdfborder=001, linkcolor=black, citecolor=black, urlcolor=black]{hyperref}
% Deal with line breaking in url
\makeatletter
\def\UrlAlphabet{%
\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}
\def\UrlDigits{\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\0}
\g@addto@macro{\UrlBreaks}{\UrlOrds}
\g@addto@macro{\UrlBreaks}{\UrlAlphabet}
\g@addto@macro{\UrlBreaks}{\UrlDigits}
\makeatother
% Eliminate warnings about non-string commands not shown in PDF bookmarks. If you use more commands in section titles or chapter titles, you can add the commands here.
\pdfstringdefDisableCommands{
\def \quad{}
\def \qquad{}
}
% Line spread
\renewcommand{\baselinestretch}{1.30}
% \setlength{\itemsep}{-5pt} % item seperate too wide
% Indentation
%\usepackage{indentfirst}
%\setlength{\parindent}{2em} % indent 2em
% Footnote
% Usage: \footnote{Your Text}
\usepackage[perpage]{footmisc}
% \usepackage{footnpag} % footnote per page
% \usepackage{footnote}
% \let\ftnt=\footnote
% \renewcommand{\footnote}[1]{\ftnt{\footnotefont{#1}}}
% No Number Footnote
% Especially for stating which project the thesis is supported
% Usage: \blfootnote{Your Text}
\usepackage{lipsum}
\newcommand\blfootnote[1]{%
\begingroup
\renewcommand\thefootnote{}\footnote{#1}%
\addtocounter{footnote}{-1}%
\endgroup
}
%%%%%% Detail style %%%%%%
% Underline
% Usage: \ul[length]{<text>}
\makeatletter
\newcommand\ul[2][4cm]{\hskip1pt\underline{\hb@xt@ #1{\hss#2\hss}}\hskip3pt}
\makeatother
\def\ULthickness{1.1pt}%
% Content style
\setcounter{secnumdepth}{3} % let subsubsection have number
\setcounter{tocdepth}{3} % let subsubsection appear in CONTENTS
\usepackage{titletoc}
\renewcommand\contentsname{\centerline{\toctitlefont{目\qquad{}录}}}
\titlecontents{chapter}[0em]{\tocchapterfont\vspace{0.4mm}}
{\CTEXnumber{\CJKsection}{\thecontentslabel}{第\CJKsection{章}\quad{}}}
{}
{\hspace{.5em}\titlerule*[6pt]{$\cdot$}\contentspage}
\titlecontents{section}[1em]{\tocsectionfont\vspace{0.4mm}}{%
\thecontentslabel\quad{}}{}{%
\hspace{.5em}\titlerule*[6pt]{$\cdot$}\contentspage}%
\titlecontents{subsection}[2em]{\tocsubsectionfont\vspace{0.4mm}}{%
\thecontentslabel\quad{}}{}{%
\hspace{.5em}\titlerule*[6pt]{$\cdot$}\contentspage}%
\titlecontents{subsubsection}[3em]{\tocsubsubsectionfont\vspace{0.4mm}}{%
\thecontentslabel\quad{}}{}{%
\hspace{.5em}\titlerule*[6pt]{$\cdot$}\contentspage}%
\makeatletter % Content Page style
\renewcommand\frontmatter{%
\if@openright\cleardoublepage\else\clearpage\fi%
\@mainmatterfalse%
\pagenumbering{Roman}% Roman style page number
\pagestyle{frontmatter}
}
\makeatother%
\makeatletter % Content Page style
\renewcommand\mainmatter{%
\if@openright\cleardoublepage\else\clearpage\fi%
\@mainmattertrue%
\pagenumbering{arabic}% Roman style page number
\pagestyle{mainmatter}
}
\makeatother%
\makeatletter % Translation Page style
\renewcommand\backmatter{%
\if@openright\cleardoublepage\else\clearpage\fi%
\@mainmatterfalse%
\pagestyle{empty}
}
\makeatother%
% Text style
\usepackage{titlesec}
\titleformat{\chapter}[hang]{\textchapterfont}{第\chinese{chapter}章}{1em}{}
\titlespacing{\chapter}{0pt}{-1ex plus .2ex minus .2ex}{-1ex plus .2ex minus .2ex} % 缩短章节标题的上边距
\titleformat{\section}{\textsectionfont}{\thesection}{1em}{}
\titleformat{\subsection}{\textsubsectionfont}{\qquad{}\thesubsection}{1em}{}
\titleformat{\subsubsection}{\textsubsubsectionfont}{\qquad{}\thesubsubsection}{1em}{}
% Reference style
% \usepackage[numbers,sort&compress]{natbib}
\usepackage[super,numbers,sort&compress]{natbib}
%\usepackage[backend=biber,texencoding=utf8,bibencoding=utf8]{biblatex}
\renewcommand\bibname{\centerline{\reftitlefont{参考文献}}}
%\renewcommand{\citet}[1]{\textsuperscript{\cite{#1}}}
\setcitestyle{square}
\setlength{\bibsep}{0.2em}
% Appendix
% TODO: this needs imporvement
\usepackage{appendix}
%% Some tweaking/features/styles
% Figure & Table
\usepackage{caption}
\usepackage[position=t,singlelinecheck=off]{subfig}
% \renewcommand\thesubfigure{\Alph{subfigure}}
\renewcommand{\captionfont}{\ftcaptionfont}
\renewcommand{\captionlabelfont}{\ftcaptionfont}
\DeclareCaptionLabelSeparator{twospace}{ ~}
\captionsetup{labelsep=twospace} %去掉图1:后冒号
\renewcommand{\tablename}{表}
\renewcommand{\thetable}{~\arabic{chapter}-\arabic{table}~}
\renewcommand{\figurename}{图}
\renewcommand{\thefigure}{~\arabic{chapter}-\arabic{figure}~}
\renewcommand{\theequation}{\arabic{chapter}-\arabic{equation}~}
% 外文文献中表、图、公式编号重置
\newcommand{\newtranschapter}{\thispagestyle{empty}\addtocounter{chapter}{1}\setcounter{table}{0}\setcounter{equation}{0}\setcounter{figure}{0}}
% single figure tweaking
% New figure environment
% Usage: \buptfigure[scale]{figure path}{caption}{label}
\usepackage{graphicx} % graphic package
\newcommand{\buptfigure}[4][width=11cm]{%
\begin{figure}[!htbp]%
\centering % If you'd like to use center environment here, be advised that it will add extra white space at its top and bottom. So \centering is a better default option.
% \begin{center}
\includegraphics[#1]{#2}%
% \end{center}
\caption{#3}%
\label{#4}
\end{figure}}
% table tweaking
% New table environment
% Usage: \begin{bupttable}{caption}{label}
% <normal table>
% \end{bupttable}
\usepackage{array,booktabs,multirow} % multirow, multicolumn and more professional format support
\usepackage{tabularx} % deal with text wrapping in tables
\newenvironment{bupttable}[2]{%
\begin{table}[!htbp]%
\centering%
\renewcommand{\arraystretch}{1.38}%
\setlength{\abovecaptionskip}{0pt}%
\setlength{\belowcaptionskip}{10pt}%
\caption{#1}%
\label{#2}}{%
\end{table}}%
% equation tweaking
\usepackage{amssymb}
\usepackage{bm} % 加粗使用
\usepackage{amsmath,delarray,bm,mathtools}
\newtagform{newtag}[]{式(}{)} %定义公式编号样式
\usetagform{newtag}
% Theorem & definition
% \usepackage{amsthm}
\newtheorem{definition}{定义}[chapter]
\newtheorem{theorem}{定理}[chapter]
\newtheorem{axiom}{公理}[chapter]
\newtheorem{lemma}{引理}[chapter]
\newtheorem{proposition}{命题}[chapter]
\newtheorem{corollary}{推论}[chapter]
% Algorithm
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
% Code
\usepackage{listings}
\usepackage{xcolor}
\lstset{
basicstyle=\ttfamily\wuhao, %五号等宽字体
extendedchars=true,
keywordstyle=\color{blue},
commentstyle=\color{green!30!black},
showspaces=false, % 显示空格
showstringspaces=true, % 字符串中显示空格
showtabs=false, % 显示 TAB
tabsize=2, % TAB 被当作两个空格
captionpos=t, % 标题位置
breaklines=true, % 自动断行
breakatwhitespace=true,
basewidth={0.5em,0.35em},
frame=single, %单线边框,注释掉则无边框
numbers=left, %行号位于左侧
numberbychapter=true,
% xleftmargin=.5em,
% xrightmargin=.5em,
% aboveskip=1ex,
% columns=flexible, % 如果不指定等宽字体用这个
% mathescape,
escapeinside={\%*}{*)}
}
\renewcommand{\lstlistingname}{\kaishu{代码}}
\makeatletter
\AtBeginDocument{%
\renewcommand \thelstlisting
{\ifnum \c@chapter>\z@ \thechapter-\fi \@arabic\c@lstlisting}%
}
\makeatother
% insert PDF
\usepackage[final]{pdfpages}
% insert blank page
\makeatletter
\newcommand\blankmatter{%
\if@openright\cleardoublepage\else\clearpage\fi%
\@mainmatterfalse%
\pagestyle{empty}}%
\makeatother%
% List environment config
\usepackage[inline]{enumitem}
% Uncomment the two lines below if you want an list environment to share the same indent with a paragraph and no extra blank before, in or after the list.
%\setlist[itemize]{labelindent=\parindent,leftmargin=*,noitemsep,topsep=0pt}
%\setlist[enumerate]{labelindent=\parindent,leftmargin=*,noitemsep,topsep=0pt,label={\arabic*)}} % Modify the label format by yourself if you do not like 1), 2), ... here.