BUPTthesisbachelor.sty 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. % %
  3. % Copyright (c) 2010 - 2011 Caspar Zhang <casparant@gmail.com> %
  4. % %
  5. % This copyrighted material is made available to anyone wishing %
  6. % to use, modify, copy, or redistribute it subject to the terms %
  7. % and conditions of the GNU General Public License version 2. %
  8. % %
  9. % This program is distributed in the hope that it will be %
  10. % useful, but WITHOUT ANY WARRANTY; without even the implied %
  11. % warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %
  12. % PURPOSE. See the GNU General Public License for more details. %
  13. % %
  14. % You should have received a copy of the GNU General Public %
  15. % License along with this program; if not, write to the Free %
  16. % Software Foundation, Inc., 51 Franklin Street, Fifth Floor, %
  17. % Boston, MA 02110-1301, USA. %
  18. % %
  19. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  20. %
  21. \usepackage{ctex} % invole CJKfntef
  22. \usepackage{xeCJKfntef}
  23. \usepackage{setspace} % spacing
  24. \usepackage{xcolor} % color
  25. \usepackage{xltxtra} % print a XeLaTeX
  26. % Font family
  27. \setmainfont[Mapping=tex-text]{Times New Roman}
  28. % Font size
  29. \newcommand{\chuhao}{\zihao{0}}
  30. \newcommand{\xiaochuhao}{\zihao{-0}}
  31. \newcommand{\yihao}{\zihao{1}}
  32. \newcommand{\xiaoyihao}{\zihao{-1}}
  33. \newcommand{\erhao}{\zihao{2}}
  34. \newcommand{\xiaoerhao}{\zihao{-2}}
  35. \newcommand{\sanhao}{\zihao{3}}
  36. \newcommand{\xiaosanhao}{\zihao{-3}}
  37. \newcommand{\sihao}{\zihao{4}}
  38. \newcommand{\xiaosihao}{\zihao{-4}}
  39. \newcommand{\wuhao}{\zihao{5}}
  40. \newcommand{\xiaowuhao}{\zihao{-5}}
  41. \newcommand{\liuhao}{\zihao{6}}
  42. \newcommand{\xiaoliuhao}{\zihao{-6}}
  43. \newcommand{\qihao}{\zihao{7}}
  44. \newcommand{\bahao}{\zihao{8}}
  45. % Normal font size is XiaosiHao
  46. \renewcommand{\normalsize}{\xiaosihao\songti\normalfont}
  47. % Serveral Font pre-setting
  48. \newcommand{\thesistitlefont}{\centering\heiti\sanhao\textbf} %论文题目的字体
  49. \newcommand{\thesistitleenfont}{\centering\sanhao\bf} %论文英文题目的字体
  50. \newcommand{\covernamefont}{\heiti\yihao\bf} % 封面上“本科论文”字样的字体
  51. \newcommand{\coveritemsfont}{\songti\sanhao\bf} % 封面上姓名等条目的字体
  52. \newcommand{\coverdatefont}{\songti\sanhao\bf} % 封面上的日期的字体
  53. \newcommand{\statetitlefirst}{\songti\xiaosanhao\bf} %诚信声明标题第一行的字体
  54. \newcommand{\statetitlesecond}{\songti\xiaosanhao\bf} %诚信声明标题第二行的字体
  55. \newcommand{\abszhname}{\heiti\xiaosanhao\textbf} % 中文“摘要”字样的字体
  56. \newcommand{\abszhkey}{\heiti\xiaosihao\textbf} % 中文摘要“关键字”字样的字体
  57. \newcommand{\abszhkeys}{\songti\xiaosihao\normalfont} % 中文摘要关键字的字体
  58. \newcommand{\absenname}{\xiaosanhao\textbf} % 英文``Abstract''字样的字体
  59. \newcommand{\absenkey}{\xiaosihao\textbf} % 英文``KEY WORDS''字样的字体
  60. \newcommand{\absenkeys}{\xiaosihao\normalfont} % 英文关键字的字体
  61. \newcommand{\headfont}{\songti\xiaowuhao\normalfont} % 页眉字体
  62. \newcommand{\toctitlefont}{\heiti\sanhao\textbf} % “目录”字样的字体
  63. \newcommand{\tocchapterfont}{\heiti\xiaosihao} % 目录上第X章的字体
  64. \newcommand{\tocsectionfont}{\songti\xiaosihao\normalfont} % 目录上X.Y节的字体
  65. \newcommand{\tocsubsectionfont}{\songti\xiaosihao\normalfont} % 目录上X.Y.Z小节的字体
  66. \newcommand{\tocsubsubsectionfont}{\songti\xiaosihao\normalfont} % 目录上X.Y.Z.A小节的字体
  67. \newcommand{\textchapterfont}{\centering\heiti\sanhao\bfseries} % 正文上第X章的字体
  68. \newcommand{\textsectionfont}{\heiti\sihao\bfseries} % 正文上X.Y节的字体
  69. \newcommand{\textsubsectionfont}{\heiti\xiaosihao\bfseries} % 正文上X.Y.Z小节的字体
  70. \newcommand{\textsubsubsectionfont}{\heiti\xiaosihao\bfseries} % 正文上X.Y.Z.A小节的字体
  71. \newcommand{\footnotefont}{\songti\xiaowuhao\normalfont} % 脚注字体
  72. %\newcommand{\ftcaptionfont}{\kaishu\wuhao\normalfont} % 图表标题的字体
  73. \newcommand{\ftcaptionfont}{\kaishu\wuhao} % 图表标题的字体
  74. \newcommand{\reftitlefont}{\heiti\sanhao\textbf} % “参考文献”字样的字体
  75. \newcommand{\refbodyfont}{\songti\wuhao\normalfont} % 参考文献字体
  76. \newcommand{\thanktitlefont}{\heiti\sanhao\textbf} % “致谢”字样的字体
  77. \newcommand{\appendixtitlefont}{\heiti\sanhao\textbf} % “附录”字样的字体
  78. \newcommand{\translationtitlefont}{\heiti\sanhao} % “外文译文”字样的字体
  79. % Word spacing
  80. % Usage: \ziju{spacing} spacing can be 1em, 10pt, etc.
  81. %\newcommand{\ziju}[1]{\renewcommand{\CJKglue}{\hskip #1}}
  82. %%%%%% Page Style %%%%%%
  83. % Margin
  84. % FIXME: Not very precise, but meets the need of the Word template.
  85. % \usepackage[left=2.5cm,margin=2.5cm,headheight=1.5cm,footskip=1.5cm]{geometry}
  86. \usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm,headheight=1.5cm,headsep=0.6cm,footskip=0.5cm]{geometry}
  87. % Header and footer
  88. \usepackage{fancyhdr}
  89. \fancypagestyle{mainmatter}{%
  90. \fancyhf{} % clear all header and footer fields
  91. \fancyhead[C]{\headfont{北京邮电大学本科毕业设计(论文)}}
  92. \fancyfoot[C]{\footnotefont{\thepage}}
  93. \renewcommand{\headrulewidth}{0.8pt}
  94. }
  95. \fancypagestyle{frontmatter}{%
  96. \fancyhf{} % clear all header and footer fields
  97. \fancyhead{}
  98. \fancyfoot[C]{\footnotefont{\thepage}} % except the center
  99. \renewcommand{\headrulewidth}{0pt}
  100. }
  101. % Bookmark (Chinese bookmark supported)
  102. \usepackage{url}
  103. \def\UrlFont{}
  104. \usepackage[xetex, pdfstartview=FitH,
  105. bookmarksnumbered=true, bookmarksopen=true, bookmarksdepth=2, colorlinks=true,
  106. pdfborder=001, linkcolor=black, citecolor=black, urlcolor=black]{hyperref} % 修改bookmarksdepth指定书签层级
  107. % Deal with line breaking in url
  108. \makeatletter
  109. \def\UrlAlphabet{%
  110. \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
  111. \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
  112. \do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D%
  113. \do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N%
  114. \do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X%
  115. \do\Y\do\Z}
  116. \def\UrlDigits{\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\0}
  117. \g@addto@macro{\UrlBreaks}{\UrlOrds}
  118. \g@addto@macro{\UrlBreaks}{\UrlAlphabet}
  119. \g@addto@macro{\UrlBreaks}{\UrlDigits}
  120. \makeatother
  121. % 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.
  122. \pdfstringdefDisableCommands{
  123. \def \quad{}
  124. \def \qquad{}
  125. }
  126. % Line spread
  127. \renewcommand{\baselinestretch}{1.30}
  128. % \setlength{\itemsep}{-5pt} % item seperate too wide
  129. % Indentation
  130. %\usepackage{indentfirst}
  131. %\setlength{\parindent}{2em} % indent 2em
  132. % Footnote
  133. % Usage: \footnote{Your Text}
  134. \usepackage[perpage]{footmisc}
  135. % \usepackage{footnpag} % footnote per page
  136. % \usepackage{footnote}
  137. % \let\ftnt=\footnote
  138. % \renewcommand{\footnote}[1]{\ftnt{\footnotefont{#1}}}
  139. % No Number Footnote
  140. % Especially for stating which project the thesis is supported
  141. % Usage: \blfootnote{Your Text}
  142. \usepackage{lipsum}
  143. \newcommand\blfootnote[1]{%
  144. \begingroup
  145. \renewcommand\thefootnote{}\footnote{#1}%
  146. \addtocounter{footnote}{-1}%
  147. \endgroup
  148. }
  149. %%%%%% Detail style %%%%%%
  150. % Underline
  151. % Usage: \ul[length]{<text>}
  152. \makeatletter
  153. \newcommand\ul[2][4cm]{\hskip1pt\underline{\hb@xt@ #1{\hss#2\hss}}\hskip3pt}
  154. \makeatother
  155. \def\ULthickness{1.1pt}%
  156. % Content style
  157. \setcounter{secnumdepth}{3} % let subsubsection have number
  158. \setcounter{tocdepth}{3} % let subsubsection appear in CONTENTS
  159. \usepackage{titletoc}
  160. \newif{\ifpagenumber}
  161. \pagenumbertrue
  162. \renewcommand\contentsname{\centerline{\toctitlefont{目\qquad{}录}}}
  163. \titlecontents{chapter}[0em]{\tocchapterfont\vspace{0.4mm}} {%
  164. \ifpagenumber \CTEXnumber{\CJKsection}{\thecontentslabel}{第\CJKsection{章}\quad{}} \fi}{%
  165. } {%
  166. \ifpagenumber \hspace{.5em}\titlerule*[6pt]{$\cdot$}\contentspage\fi}
  167. \titlecontents{section}[1em]{\tocsectionfont\vspace{0.4mm}}{%
  168. \thecontentslabel\quad{}}{}{%
  169. \ifpagenumber \hspace{.5em}\titlerule*[6pt]{$\cdot$}\contentspage\fi}%
  170. \titlecontents{subsection}[2em]{\tocsubsectionfont\vspace{0.4mm}}{%
  171. \thecontentslabel\quad{}}{}{%
  172. \ifpagenumber \hspace{.5em}\titlerule*[6pt]{$\cdot$}\contentspage\fi}%
  173. \titlecontents{subsubsection}[3em]{\tocsubsubsectionfont\vspace{0.4mm}}{%
  174. \thecontentslabel\quad{}}{}{%
  175. \ifpagenumber \hspace{.5em}\titlerule*[6pt]{$\cdot$}\contentspage\fi}%
  176. \makeatletter % Content Page style
  177. \renewcommand\frontmatter{%
  178. \if@openright\cleardoublepage\else\clearpage\fi%
  179. \@mainmatterfalse%
  180. \pagenumbering{Roman}% Roman style page number
  181. \pagestyle{frontmatter}
  182. }
  183. \makeatother%
  184. \makeatletter % Content Page style
  185. \renewcommand\mainmatter{%
  186. \if@openright\cleardoublepage\else\clearpage\fi%
  187. \@mainmattertrue%
  188. \pagenumbering{arabic}% Roman style page number
  189. \pagestyle{mainmatter}
  190. }
  191. \makeatother%
  192. \makeatletter % Translation Page style
  193. \renewcommand\backmatter{%
  194. \if@openright\cleardoublepage\else\clearpage\fi%
  195. \@mainmatterfalse%
  196. \pagestyle{empty}
  197. }
  198. \makeatother%
  199. % Text style
  200. \usepackage{titlesec}
  201. \titleformat{\chapter}[hang]{\textchapterfont}{第\chinese{chapter}章}{1em}{}
  202. \titlespacing{\chapter}{0pt}{-20pt}{12pt} % 缩短章节标题的上边距
  203. \titleformat{\section}{\textsectionfont}{\thesection}{1em}{}
  204. \titleformat{\subsection}{\textsubsectionfont}{\qquad{}\thesubsection}{1em}{}
  205. \titleformat{\subsubsection}{\textsubsubsectionfont}{\qquad{}\thesubsubsection}{1em}{}
  206. % Reference style
  207. % \usepackage[numbers,sort&compress]{natbib}
  208. \usepackage[super,numbers,sort&compress]{natbib}
  209. %\usepackage[backend=biber,texencoding=utf8,bibencoding=utf8]{biblatex}
  210. \renewcommand\bibname{\centerline{\reftitlefont{参考文献}}}
  211. %\renewcommand{\citet}[1]{\textsuperscript{\cite{#1}}}
  212. \setcitestyle{square}
  213. \setlength{\bibsep}{0.2em}
  214. % Appendix
  215. % TODO: this needs imporvement
  216. \usepackage{appendix}
  217. %% Some tweaking/features/styles
  218. % Figure & Table
  219. \usepackage{caption}
  220. \usepackage[position=t,singlelinecheck=off]{subfig}
  221. % \renewcommand\thesubfigure{\Alph{subfigure}}
  222. \renewcommand{\captionfont}{\ftcaptionfont}
  223. \renewcommand{\captionlabelfont}{\ftcaptionfont}
  224. \DeclareCaptionLabelSeparator{twospace}{ ~}
  225. \captionsetup{labelsep=twospace} %去掉图1:后冒号
  226. \renewcommand{\tablename}{表}
  227. \renewcommand{\thetable}{~\arabic{chapter}-\arabic{table}~}
  228. \renewcommand{\figurename}{图}
  229. \renewcommand{\thefigure}{~\arabic{chapter}-\arabic{figure}~}
  230. \renewcommand{\theequation}{\arabic{chapter}-\arabic{equation}~}
  231. % 外文文献中表、图、公式、代码编号重置
  232. \newcommand{\newtranschapter}{\thispagestyle{empty}\addtocounter{chapter}{1}\setcounter{table}{0}\setcounter{equation}{0}\setcounter{figure}{0}\setcounter{lstlisting}{0}}
  233. % single figure tweaking
  234. % New figure environment
  235. % Usage: \buptfigure[scale]{figure path}{caption}{label}
  236. \usepackage{graphicx} % graphic package
  237. \newcommand{\buptfigure}[4][width=11cm]{%
  238. \begin{figure}[!htbp]%
  239. \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.
  240. % \begin{center}
  241. \includegraphics[#1]{#2}%
  242. % \end{center}
  243. \caption{#3}%
  244. \label{#4}
  245. \end{figure}}
  246. % table tweaking
  247. % New table environment
  248. % Usage: \begin{bupttable}{caption}{label}
  249. % <normal table>
  250. % \end{bupttable}
  251. \usepackage{array,booktabs,multirow} % multirow, multicolumn and more professional format support
  252. \usepackage{tabularx} % deal with text wrapping in tables
  253. \newenvironment{bupttable}[2]{%
  254. \begin{table}[!htbp]%
  255. \centering%
  256. \renewcommand{\arraystretch}{1.38}%
  257. \setlength{\abovecaptionskip}{0pt}%
  258. \setlength{\belowcaptionskip}{10pt}%
  259. \caption{#1}%
  260. \label{#2}}{%
  261. \end{table}}%
  262. % equation tweaking
  263. \usepackage{amssymb}
  264. \usepackage{bm} % 加粗使用
  265. \usepackage{amsmath,delarray,bm,mathtools}
  266. \newtagform{newtag}[]{式(}{)} %定义公式编号样式
  267. \usetagform{newtag}
  268. % Theorem & definition
  269. % \usepackage{amsthm}
  270. \newtheorem{definition}{定义}[chapter]
  271. \newtheorem{theorem}{定理}[chapter]
  272. \newtheorem{axiom}{公理}[chapter]
  273. \newtheorem{lemma}{引理}[chapter]
  274. \newtheorem{proposition}{命题}[chapter]
  275. \newtheorem{corollary}{推论}[chapter]
  276. % Algorithm
  277. \usepackage{algorithm}
  278. \usepackage{algorithmicx}
  279. \usepackage{algpseudocode}
  280. % Code
  281. \usepackage{listings}
  282. \usepackage{xcolor}
  283. \lstset{
  284. basicstyle=\ttfamily\wuhao, %五号等宽字体
  285. extendedchars=true,
  286. keywordstyle=\color{blue},
  287. commentstyle=\color{green!30!black},
  288. showspaces=false, % 显示空格
  289. showstringspaces=true, % 字符串中显示空格
  290. showtabs=false, % 显示 TAB
  291. tabsize=2, % TAB 被当作两个空格
  292. captionpos=t, % 标题位置
  293. breaklines=true, % 自动断行
  294. breakatwhitespace=true,
  295. basewidth={0.5em,0.35em},
  296. frame=single, %单线边框,注释掉则无边框
  297. numbers=left, %行号位于左侧
  298. numberbychapter=true,
  299. % xleftmargin=.5em,
  300. % xrightmargin=.5em,
  301. % aboveskip=1ex,
  302. % columns=flexible, % 如果不指定等宽字体用这个
  303. % mathescape,
  304. escapeinside={\%*}{*)}
  305. }
  306. \renewcommand{\lstlistingname}{\kaishu{代码}}
  307. \makeatletter
  308. \AtBeginDocument{%
  309. \renewcommand \thelstlisting
  310. {\ifnum \c@chapter>\z@ \thechapter-\fi \@arabic\c@lstlisting}%
  311. }
  312. \makeatother
  313. % insert PDF
  314. \usepackage[final]{pdfpages}
  315. % insert blank page
  316. \makeatletter
  317. \newcommand\blankmatter{%
  318. \if@openright\cleardoublepage\else\clearpage\fi%
  319. \@mainmatterfalse%
  320. \pagestyle{empty}}%
  321. \makeatother%
  322. % No page number environment for appendix
  323. \newenvironment{nopagenumber}{%
  324. \titleformat{\chapter}[hang]{\textchapterfont}{}{1em}{} %
  325. \setcounter{secnumdepth}{0}%
  326. \addtocontents{toc}{%
  327. \protect\setcounter{tocdepth}{0}%
  328. \protect\pagenumberfalse%
  329. \ignorespaces}}{%
  330. \setcounter{secnumdepth}{3}%
  331. \addtocontents{toc}{%
  332. \protect\setcounter{tocdepth}{3}%
  333. \protect\pagenumbertrue%
  334. \ignorespaces}}
  335. % List environment config
  336. \usepackage[inline]{enumitem}
  337. % 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.
  338. %\setlist[itemize]{labelindent=\parindent,leftmargin=*,noitemsep,topsep=0pt}
  339. %\setlist[enumerate]{labelindent=\parindent,leftmargin=*,noitemsep,topsep=0pt,label={\arabic*)}} % Modify the label format by yourself if you do not like 1), 2), ... here.