-
Notifications
You must be signed in to change notification settings - Fork 12
/
template.sty
154 lines (136 loc) · 7.25 KB
/
template.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
\ProvidesPackage{template}
\usepackage{ctex} % 中文支持
\usepackage[
top=2.5cm,
bottom=2.5cm,
left=2.5cm,
right=2.5cm
]{geometry} % 页边距布局
\usepackage{fancyhdr} % Required for custom headers
\usepackage{setspace} % Required for the space setting
\usepackage{zhnumber}
\usepackage{titlesec} % Required for the Chapter & Section fonts adjustment
\usepackage{titletoc} % Required for the Content fonts adjustment
\usepackage[toc,page]{appendix} % Required for the appendix environment
\usepackage{lastpage} % Required to determine the last page for the footer
\usepackage{extramarks} % Required for headers and footers
\usepackage{courier} % Required for the courier font
\usepackage{float} % Required for the Here float
\usepackage{graphicx} % Required to insert images
\usepackage{wrapfig}
\usepackage{booktabs} % Required for the hline of the three lines table
\usepackage{multirow} % Required for the multirow of table
\usepackage{listings} % Required for insertion of code
\usepackage{indentfirst} % Required for the indent before each paragraph
\usepackage[bookmarks=true,colorlinks=true,linkcolor=black,anchorcolor=blue,citecolor=blue,urlcolor=blue]{hyperref}
\usepackage[usenames,dvipsnames]{color} % Required for custom colors
\usepackage[font=footnotesize,tableposition=top]{caption} % Required for the footnote size captions of figures and tables
%----------------------------------------------------------------------------------------
% 数学宏包
%----------------------------------------------------------------------------------------
\usepackage{bm} % Required for the bold in math display
\usepackage{amsmath} % Required for the math display
\usepackage{amssymb} % Required for the math display
\usepackage{amsbsy} % Required for the math display
\usepackage{cancel} % Required for the cancel symbol in math display
\usepackage{amsthm} % Required for the theorem edition
\usepackage{array} % Required for the array in math display
\usepackage{ifthen} % Required for the conditional commands
%----------------------------------------------------------------------------------------
% Superscript citation
%----------------------------------------------------------------------------------------
% 参考文献相关,需要更新
\usepackage{gbt7714}
\bibliographystyle{gbt7714-numerical}
\newcommand{\upcite}[1]{\textsuperscript{\textsuperscript{\cite{#1}}}}
\setmainfont{Times New Roman} % 常规英文字体
\setsansfont{Arial} % 非衬线字体
\setmonofont{Consolas} % 打字机字体,代码字体
\setCJKmainfont[AutoFakeBold=true]{SimSun}%正文字体
%----------------------------------------------------------------------------------------
% Upright d in integrate
%----------------------------------------------------------------------------------------
\newcommand{\ud}{\mathrm{d}}
%----------------------------------------------------------------------------------------
% Code Inclusion Configuration
%----------------------------------------------------------------------------------------
\definecolor{MyDarkGreen}{rgb}{0.0,0.4,0.0} % This is the color used for comments
\lstloadlanguages{Python} % Load Python syntax for listings, for a list of other languages supported see: ftp://ftp.tex.ac.uk/tex-archive/macros/latex/contrib/listings/listings.pdf
\lstset{language=Python, % Use Python in this example
frame=single, % Single frame around code
%basicstyle=\ttfamily, % Use small true type font
keywordstyle=[1]\color{Blue}\bf, % Python functions bold and blue
keywordstyle=[2]\color{Purple}\it, % Python function arguments purple
keywordstyle=[3]\color{Blue}\underbar, % Custom functions underlined and blue
identifierstyle=, % Nothing special about identifiers
commentstyle=\color{Gray}, % Comments small dark green courier font
stringstyle=\color{Green}, % Strings are purple
showstringspaces=false, % Don't put marks in string spaces
tabsize=4, % 4 spaces per tab
% Put standard Python functions not included in the default language here
morekeywords={rand},
% Put Python function parameters here
morekeywords=[2]{on, off, interp},
% Put user defined functions here
morekeywords=[3]{test},
%
morecomment=[l][\color{Blue}]{...}, % Line continuation (...) like blue comment
numbers=left, % Line numbers on left
firstnumber=1, % Line numbers start with line 1
numberstyle=\tiny\color{Blue}, % Line numbers are blue and small
stepnumber=1 % Line numbers go in steps of 1
}
% Creates a new command to include a Python script, the first parameter is the filename of the script (without .py), the second parameter is the caption
\newcommand{\pythonscript}[2]{
\begin{itemize}
\begin{spacing}{1.0}
\item[]\lstinputlisting[
caption=#2,
label=#1,
gobble=2,
numbers=left
]{#1.py}
\end{spacing}
\end{itemize}
}
%----------------------------------------------------------------------------------------
% Section related equations' number
%----------------------------------------------------------------------------------------
\makeatletter
\@addtoreset{equation}{section}
\makeatother
\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}
%----------------------------------------------------------------------------------------
% 章节标题格式调整
%----------------------------------------------------------------------------------------
% section
\titleformat{\section}{\centering\zihao{-2}\bfseries}{第\,\zhnumber{\thesection}\,章}{1em}{}
% subsection
\titleformat{\subsection}{\zihao{-3}\bfseries}{\thesubsection}{1em}{}
% subsubsection
\titleformat{\subsubsection}{\zihao{4}\bfseries}{\thesubsubsection}{1em}{}
% 重新定义paragraph样式
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0.75ex plus .2ex}
\titleformat{\paragraph}[hang]{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{\raggedright}
%----------------------------------------------------------------------------------------
% 目录格式调整
%----------------------------------------------------------------------------------------
\renewcommand\contentsname{目\quad\quad 录} % Setup contents
\titlecontents{section}[0em]{\zihao{4}\bfseries}
{\contentspush{第\,\zhnumber{\thecontentslabel}\,章\hspace{1em}}}
{}{\titlerule*[5pt]{.}\contentspage}
\titlecontents{subsection}[2.2em]{\zihao{-4}\songti}{\contentspush{\thecontentslabel\hspace{0.7em}}}
{}{\titlerule*[5pt]{.}\contentspage}
\titlecontents{subsubsection}[3.9em]{\zihao{-4}\songti}{\contentspush{\thecontentslabel\hspace{0.7em}}}
{}{\titlerule*[5pt]{.}\contentspage}
\titlespacing*{\subsection} {0pt}{1ex}{1ex} % Adjust the space between title and context
\titlespacing*{\subsubsection} {0pt}{1ex}{1ex}
%----------------------------------------------------------------------------------------
% Page header & Page footer setting
%----------------------------------------------------------------------------------------
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\sectionmark}[1]{\markboth{第\chinese{section} 章{\color{white}.} #1}{}}
\fancyhead[C]{\songti{华南理工大学学士学位论文}}
\fancyhead[CO]{\songti\leftmark}
\fancyfoot[C]{\thepage}