-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshnubachelor.sty
430 lines (381 loc) · 13.6 KB
/
shnubachelor.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
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
%
% This is file `shnubachelor.sty',
% author andy123t
% date 2023/02/28
% version v1.4
% LaTeX template for Bachelor thesis of SHNU
%
%---------- 常用宏包 ----------
\usepackage{amsmath,amsthm,amssymb}
\usepackage{mathrsfs}
\usepackage{graphicx}
%\usepackage[english]{babel}
\usepackage{color,xcolor}
\usepackage{float}
\usepackage{pifont}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow,multicol}
\usepackage{longtable}
\usepackage{makecell}
\usepackage{anyfontsize}
\usepackage{pdfpages}
\usepackage{listings}
\usepackage[numbered]{bookmark}
\usepackage{geometry}
\geometry{left=3.17cm,right=3.17cm,top=3.0cm,bottom=3.0cm}
%\geometry{left=3.0cm,right=3.0cm,top=2.9cm,bottom=3.2cm}
%---------- 设置图片的路径 ----------
\graphicspath{{./figure/}{./figures/}{./image/}{./images/}}
%---------- 定义列表项的样式 ----------
\usepackage{enumitem}
\setlist{nolistsep}
%---------- 设置超链接 ----------
\usepackage{hyperref}
\hypersetup{
colorlinks = true,
linkcolor = black,
citecolor = blue,
filecolor = blue,
urlcolor =blue,
}
%--- 允许多行公式跨页显示 ---
\allowdisplaybreaks
%---------- 页眉页脚 ----------
\usepackage{fancyhdr}
%---------- 设置页眉样式 ----------
%\renewcommand{\headrule}{%
% \let\headrulewidth\plainheadrulewidth
% \hrule\@height 1.5pt \@width\headwidth %上面线1pt粗
% \vskip 1.6pt %两条线的距离
% \hrule\@height 0.4pt \@width\headwidth %下面线0.4pt粗
% \vskip-1.5pt
%}
\renewcommand{\headrulewidth}{0.5pt}
\newcommand{\headstyle}{
%\fancyhead[RO,LE]{\zihao{5} \nouppercase{\leftmark}}
%\fancyhead[LO,RE]{\zihao{5} 上海师范大学本科毕业论文(设计)}
%\fancyhead[C]{\zihao{5} \nouppercase{\leftmark}}
\fancyhead[C]{\zihao{5} 上海师范大学本科毕业论文(设计)}
}
\newcommand{\footstyle}{
\fancyfoot[C]{\zihao{5} \thepage}
%\fancyfoot[LE]{\zihao{5} \thepage}
%\fancyfoot[RO]{\zihao{5} \thepage}
}
\fancypagestyle{plain}{%
\fancyhf{}
\headstyle
\footstyle
}
\setlength{\headheight}{15pt}
\setlength{\headsep}{18pt}
\pagestyle{plain}
%---------- 设置章节 ----------
\ctexset{
%--- section ---
section/name = {},
section/number = \arabic{section},
%section/number = \chinese{section},
section/format = \centering,
section/nameformat = \zihao{-2}\sffamily\heiti,
section/titleformat = \zihao{-2}\sffamily\heiti,
%--- subsection ---
subsection/format = \raggedright,
subsection/nameformat = \zihao{3}\sffamily\heiti,
subsection/titleformat = \zihao{3}\sffamily\heiti,
subsection/beforeskip = 10pt plus 2pt minus 2pt,
subsection/afterskip = 5pt plus 1pt minus 1pt,
%--- subsubsection ---
subsubsection/format = \raggedright,
subsubsection/nameformat = \zihao{4}\sffamily\heiti,
subsubsection/titleformat = \zihao{4}\sffamily\heiti,
subsubsection/beforeskip = 8pt plus 2pt minus 2pt,
subsubsection/afterskip = 4pt plus 1pt minus 1pt,
%--- paragraph ---
paragraph/name = {,},
paragraph/format = \rmfamily\zihao{-4},
paragraph/number={\chinese{paragraph}},
%--- subparagraph ---
subparagraph/name = {,},
subparagraph/format = \rmfamily\zihao{-4},
subparagraph/number={\arabic{subparagraph}},
%--- appendix ---
appendix/name = {附录},
}
%---------- 设置目录 ----------
\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hfill\sffamily\heiti\Large}
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\contentsname}{目~~录}
\setlength{\cftbeforetoctitleskip}{8pt}
\setlength{\cftaftertoctitleskip}{20pt}
\setlength{\cftbeforesecskip}{10pt plus 2pt minus 2pt}
\setlength{\cftbeforesubsecskip}{4pt}
\renewcommand{\cftdot}{$\cdot$}
\renewcommand{\cftdotsep}{3}
\renewcommand{\cftsecdotsep}{\cftdotsep}%
\renewcommand{\cftsecfont}{\sffamily\heiti}
%---------- 中文摘要环境 ----------
\newenvironment{cnabstract}{
\clearpage
\phantomsection
\addcontentsline{toc}{section}{摘~~要}
\section*{摘~~要}
\sectionmark{摘~~要}
}{
\par
}
%---------- 英文摘要环境 ----------
\newenvironment{enabstract}{
\phantomsection
\addcontentsline{toc}{section}{Abstract}
\section*{Abstract}
%\sectionmark{Abstract}
}{
\par
}
%---------- 中文段落缩进和行距 ----------
\setlength{\parindent}{2em} % 首行两个汉字的缩进量
\setlength{\parskip}{4pt plus 1pt minus 1pt} % 段落之间的竖直距离
\linespread{1.35} % 设置行距
%\renewcommand{\baselinestretch}{1.35} % 设置行距
%\setlength{\baselineskip}{18pt}
%---------- 设置公式间距 ----------
\AtBeginDocument{
\setlength{\abovedisplayskip}{6pt plus 2pt minus 2pt}
\setlength{\belowdisplayskip}{6pt plus 2pt minus 2pt}
\setlength{\abovedisplayshortskip}{3pt plus 1pt minus 1pt}
\setlength{\belowdisplayshortskip}{3pt plus 1pt minus 1pt}
%\setlength{\arraycolsep}{2pt} % array中列之间空白长度
}
%---------- 定制图形和表格标题的样式 ----------
\usepackage{caption}
\captionsetup{font={small,singlespacing},labelformat={default},labelsep=quad}
\captionsetup[figure]{position=bottom,skip={6pt},name={图}}
\captionsetup[table]{position=top,skip={3pt},name={表}}
\setlength{\textfloatsep}{12pt plus 2pt minus 2pt}
\setlength{\floatsep}{10pt plus 2pt minus 2pt}
\setlength{\intextsep}{10pt plus 2pt minus 2pt}
%\setlength{\abovecaptionskip}{2pt plus 1pt minus 1pt}
%\setlength{\belowcaptionskip}{2pt plus 1pt minus 1pt}
%---------- 浮动对象设置 ----------
% 浮动对象的缺省值稍微宽松一点,从而防止幅度对象占据过多的文本页面
% 也可以防止在很大空白的浮动页上放置很小的图形
%\renewcommand{\textfraction}{0.15}
%\renewcommand{\topfraction}{0.85}
%\renewcommand{\bottomfraction}{0.65}
%\renewcommand{\floatpagefraction}{0.60}
%---------- 设置编号格式 ----------
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\numberwithin{table}{section}
%-------- 重新设置图表公式 autoref ----------
\renewcommand{\figureautorefname}{图}
\renewcommand{\tableautorefname}{表}
\renewcommand{\equationautorefname}{公式}
%---------- 算法设置 ----------
\usepackage{algorithm,algorithmicx}
\usepackage{algpseudocode}
\floatname{algorithm}{算法}
\algrenewcommand\algorithmicrequire{\textbf{输入:}}
\algrenewcommand\algorithmicensure{\textbf{输出:}}
%---------- 使用 tabularx库并定义新的左右中格式 ----------
\newcolumntype{L}{X}
\newcolumntype{C}{>{\centering \arraybackslash}X}
\newcolumntype{R}{>{\raggedleft \arraybackslash}X}
\newcolumntype{P}[1]{>{\centering \arraybackslash}p{#1}}
%---------- 数学定理设置 ----------
\newtheoremstyle{shnu}
{0.5\topsep}{0.5\topsep}
{\itshape}{}{\bfseries}
{.}{5pt plus 1pt minus 1pt}{}
%\theoremstyle{plain}
\theoremstyle{shnu}
\newtheorem{definition}{定义}[section]
\newtheorem{proposition}{命题}[section]
\newtheorem{lemma}{引理}[section]
\newtheorem{theorem}{定理}[section]
\newtheorem{example}{例}[section]
\newtheorem{corollary}{推论}[section]
\newtheorem{remark}{注}[section]
\newtheorem{exercise}{练习}[section]
\newtheorem{assumption}{假设}[section]
\newtheorem{axiom}{公理}[section]
\newtheorem{property}{性质}[section]
\newtheorem{conjecture}{猜想}[section]
%\renewcommand{\proofname}{\heiti 证明}
\renewcommand{\proofname}{证明}
\renewenvironment{proof}[1][\proofname]{\par
\pushQED{\qed}%
%\normalfont \topsep6\p@\@plus6\p@\relax
\normalfont \topsep0\p@\@plus3\p@\relax
\trivlist\item[\hskip\labelsep
\bfseries #1\@addpunct{\,:\,}]\ignorespaces
}{
\popQED\endtrivlist\@endpefalse
}
%---------- 子图宏包 ----------
\usepackage{subfig} % 需要在tocloft后面
%----------- 添加几个新的文档属性 -----------
\newcommand{\institute}[1]{\def\definstitute{#1}}
\newcommand{\grademajor}[1]{\def\defgrademajor{#1}}
\newcommand{\studentID}[1]{\def\defstudentID{#1}}
\newcommand{\advisor}[1]{\def\defadvisor{#1}}
\renewcommand{\title}[2][1]{\def\titlerownum{#1}\def\@title{#2}}
\newcommand{\entitle}[2][1]{\def\defentitlerownum{#1}\def\defentitle{#2}}
%\newcolumntype{I}{!{\vrule width 3pt}}
\newlength\savedwidth
\newcommand\whline[1]{%
\noalign{%
\global\savedwidth\arrayrulewidth\global\arrayrulewidth 0.8pt%
}%
\cline{#1}%
\noalign{\vskip\arrayrulewidth}%
\noalign{\global\arrayrulewidth\savedwidth}%
}
%---------- 载入学校logo ----------
\def\logopic{shnu.eps} %SHNU-logo
%---------- 定义新的标题页面 ----------
\makeatletter
\renewcommand{\maketitle}[1][15em]{
\clearpage
\phantomsection
\pdfbookmark[1]{封~~面}{cover}
\thispagestyle{empty}
\begin{center}
\vspace*{1.0\baselineskip}
\includegraphics[width=7.8cm]{\logopic}
\vspace*{2.0\baselineskip}
{\fontsize{30bp}{30bp}\selectfont\heiti 本~科~毕~业~论~文(设~计)}
\vspace*{3.2\baselineskip}
{\zihao{4}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{lp{.68\linewidth}<{\centering}}
\ifthenelse{\titlerownum=1}{
\raisebox{2.0pt}{\textbf{题目(中文):}} & \multirow{\titlerownum}{\linewidth}{\centering\heiti \@title}
\\[-9pt] \whline{2-2}
}{
\raisebox{-4.0pt}{\textbf{题目(中文):}} & \multirow{\titlerownum}{\linewidth}{\centering\heiti \@title}
\\[-3pt] \whline{2-2} \\[-12pt] \whline{2-2}
}
\end{tabular}
\begin{tabular}{lp{.68\linewidth}<{\centering}}
\ifthenelse{\defentitlerownum=1}{
\raisebox{1.0pt}{\textbf{\hspace{2\ccwd}(英文):}} & \multirow{\defentitlerownum}{\linewidth}{\centering \defentitle}
\\[-7.5pt] \whline{2-2}
}{
\raisebox{-4.0pt}{\textbf{\hspace{2\ccwd}(英文):}} & \multirow{\defentitlerownum}{\linewidth}{\centering \defentitle}
\\[-2pt] \whline{2-2} \\[-12pt] \whline{2-2}
}
\end{tabular}
}
\vspace*{3.3\baselineskip}
{\zihao{4}
\renewcommand{\arraystretch}{1.8}
\begin{tabular}{lp{.46\linewidth}<{\centering}}
学\hspace{2\ccwd}院 & \definstitute \\[-8pt]
\whline{2-2}
年级专业 & \defgrademajor \\[-8pt]
\whline{2-2}
学生姓名 & \@author \\[-8pt]
\whline{2-2}
学\hspace{2\ccwd}号 & \defstudentID \\[-8pt]
\whline{2-2}
指导教师 & \defadvisor \\[-8pt]
\whline{2-2}
\end{tabular}
}
\vfill
{\zihao{3}\textbf{完~成~日~期} \quad \@date}
\vspace*{5pt}
\end{center}
}
\makeatother
%---------- 定义代码高亮 ----------
% restore the tt default family to lmodern tt family
%\renewcommand\ttdefault{lmtt}
%---------- add code highlight style ----------
% matlab highlight color settings
%\definecolor{mBasic}{RGB}{248,248,242}
\definecolor{mKeyword}{RGB}{0,0,255}
\definecolor{mString}{RGB}{160,32,240}
\definecolor{mComment}{RGB}{34,139,34}
\definecolor{mNumber}{RGB}{96,96,96}
\definecolor{mBackground}{RGB}{255,255,255}
\definecolor{mRule}{RGB}{96,96,96}
% Python highlight color settings
%\definecolor{pBasic}{RGB}{248,248,242}
\definecolor{pKeyword}{RGB}{228,0,128}
\definecolor{pString}{RGB}{148,0,209}
\definecolor{pComment}{RGB}{117,113,94}
\definecolor{pIdentifier}{RGB}{166,226,46}
\definecolor{pNumber}{RGB}{96,96,96}
\definecolor{pBackground}{RGB}{255,255,255}
\definecolor{pRule}{RGB}{96,96,96}
%----- matlab highlight style -----
\lstdefinestyle{matlab}
{
language=matlab,
xleftmargin=23pt,
xrightmargin=5pt,
frame=tlbr,framesep=4pt,framerule=0.5pt,
framexleftmargin=18pt,
%frame=shadowbox,rulesepcolor=\color{red!20!green!20!blue!20},
basicstyle=\footnotesize\ttfamily,
%basicstyle=\footnotesize\fontspec{Consolas},
keywordstyle={\color{mKeyword}},
stringstyle={\color{mString}},
commentstyle={\color{mComment}},
backgroundcolor=\color{mBackground},
rulecolor=\color{mRule},
keywords={
break,case,catch,classdef,continue,else,
elseif,end,for,function,global,if,otherwise,parfor,
persistent,return,spmd,switch,try,while
},
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=4,
captionpos=t,
breaklines=true,
numberstyle=\tiny\color{mNumber},
%numbersep=9pt,
numbers=left,
stepnumber=1,
}
%----- python highlight style -----
\lstdefinestyle{python}{
language=python,
xleftmargin=23pt,
xrightmargin=5pt,
frame=tlbr,framesep=4pt,framerule=0.5pt,
framexleftmargin=18pt,
%frame=shadowbox,rulesepcolor=\color{red!20!green!20!blue!20},
basicstyle=\footnotesize\ttfamily,
%basicstyle=\footnotesize\fontspec{Consolas},
keywordstyle=\color{pKeyword},
stringstyle=\color{pString},
commentstyle=\color{pComment},
backgroundcolor=\color{pBackground},
rulecolor=\color{pRule},
emph={format_string,eff_ana_bf,permute,eff_ana_btr},
emphstyle=\color{pIdentifier}
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=4,
captionpos=t,
breaklines=true,
numberstyle=\tiny\color{pNumber},
%numbersep=9pt,
numbers=left,
stepnumber=1,
}
%\lstset{basicstyle=\footnotesize\fontspec{Consolas}}
%\lstset{basicstyle=\footnotesize\fontspec{Courier New}}
%\newcommand*\lstinputpath[1]{\lstset{inputpath=#1}}
%\lstinputpath{{./code/}}
% End of file `shnubachelor.sty'.