BUPTthesisbachelor.sty 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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[fntef]{ctex} % invole CJKfntef
  22. \usepackage{ctex}
  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{\abscnname}{\heiti\xiaosanhao\textbf} % 中文“摘要”字样的字体
  56. \newcommand{\abscnkey}{\heiti\xiaosihao\textbf} % 中文摘要“关键字”字样的字体
  57. \newcommand{\abscnkeys}{\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\textbf} % “附录”字样的字体
  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,textwidth=16cm,textheight=24.7cm]{geometry}
  87. % Header and footer
  88. \usepackage{fancyhdr}
  89. \fancyhf{} % clear head and foot
  90. \fancyhead[C]{\headfont{北京邮电大学本科毕业设计(论文)}}
  91. \fancyfoot[C]{\footnotefont{\thepage}}
  92. % Bookmark (Chinese bookmark supported)
  93. \usepackage{url}
  94. \def\UrlFont{}
  95. \usepackage[xetex, pdfstartview=FitH,
  96. bookmarksnumbered=true, bookmarksopen=true, colorlinks=true,
  97. pdfborder=001, linkcolor=black, citecolor=black, urlcolor=black]{hyperref}
  98. \pdfstringdefDisableCommands{ % eliminate warnings about non-string commands not supported in PDF bookmarks. If you use more commands in section titles or chapter titles, you can add them here.
  99. \def \quad{}
  100. \def \qquad{}
  101. }
  102. % Line spread
  103. \renewcommand{\baselinestretch}{1.30}
  104. % \setlength{\itemsep}{-5pt} % item seperate too wide
  105. % Indentation
  106. %\usepackage{indentfirst}
  107. %\setlength{\parindent}{2em} % indent 2em
  108. % Footnote
  109. % Usage: \footnote{Your Text}
  110. \usepackage[perpage]{footmisc}
  111. % \usepackage{footnpag} % footnote per page
  112. % \usepackage{footnote}
  113. % \let\ftnt=\footnote
  114. % \renewcommand{\footnote}[1]{\ftnt{\footnotefont{#1}}}
  115. % No Number Footnote
  116. % Especially for stating which project the thesis is supported
  117. % Usage: \blfootnote{Your Text}
  118. \usepackage{lipsum}
  119. \newcommand\blfootnote[1]{%
  120. \begingroup
  121. \renewcommand\thefootnote{}\footnote{#1}%
  122. \addtocounter{footnote}{-1}%
  123. \endgroup
  124. }
  125. %%%%%% Detail style %%%%%%
  126. % Underline
  127. % Usage: \ul[length]{<text>}
  128. \makeatletter
  129. \newcommand\ul[2][4cm]{\hskip1pt\underline{\hb@xt@ #1{\hss#2\hss}}\hskip3pt}
  130. \makeatother
  131. \def\ULthickness{1.1pt}%
  132. % Content style
  133. \setcounter{secnumdepth}{3} % let subsubsection have number
  134. \setcounter{tocdepth}{3} % let subsubsection appear in CONTENTS
  135. \usepackage{titletoc}
  136. \renewcommand\contentsname{\centerline{\toctitlefont{目\qquad{}录}}}
  137. \titlecontents{chapter}[0em]{\tocchapterfont\vspace{0.4mm}}
  138. {\CTEXnumber{\CJKsection}{\thecontentslabel}{第\CJKsection{章}\quad{}}}
  139. {}
  140. {\hspace{.5em}\titlerule*[10pt]{$\cdot$}\contentspage}
  141. \titlecontents{section}[1em]{\tocsectionfont\vspace{0.4mm}}{%
  142. \thecontentslabel\quad{}}{}{%
  143. \hspace{.5em}\titlerule*[10pt]{$\cdot$}\contentspage}%
  144. \titlecontents{subsection}[2em]{\tocsubsectionfont\vspace{0.4mm}}{%
  145. \thecontentslabel\quad{}}{}{%
  146. \hspace{.5em}\titlerule*[10pt]{$\cdot$}\contentspage}%
  147. \titlecontents{subsubsection}[3em]{\tocsubsubsectionfont\vspace{0.4mm}}{%
  148. \thecontentslabel\quad{}}{}{%
  149. \hspace{.5em}\titlerule*[10pt]{$\cdot$}\contentspage}%
  150. \makeatletter % Content Page style
  151. \renewcommand\frontmatter{%
  152. \if@openright\cleardoublepage\else\clearpage\fi%
  153. \@mainmatterfalse%
  154. \pagenumbering{Roman}% Roman style page number
  155. \pagestyle{plain}}%
  156. \makeatother%
  157. \makeatletter % Translation Page style
  158. \renewcommand\backmatter{%
  159. \if@openright\cleardoublepage\else\clearpage\fi%
  160. \@mainmatterfalse%
  161. \pagestyle{empty}
  162. }
  163. \makeatother%
  164. % Text style
  165. \usepackage{titlesec}
  166. \titleformat{\chapter}[hang]{\textchapterfont}{第\chinese{chapter}章}{1em}{}
  167. \titlespacing{\chapter}{0pt}{3ex plus .5ex minus .5ex}{3ex plus .5ex minus .5ex} % 缩短章节标题的上边距
  168. \titleformat{\section}{\textsectionfont}{\thesection}{1em}{}
  169. \titleformat{\subsection}{\textsubsectionfont}{\qquad{}\thesubsection}{1em}{}
  170. \titleformat{\subsubsection}{\textsubsubsectionfont}{\qquad{}\thesubsubsection}{1em}{}
  171. % Reference style
  172. % \usepackage[numbers,sort&compress]{natbib}
  173. \usepackage[super,numbers,sort&compress]{natbib}
  174. %\usepackage[backend=biber,texencoding=utf8,bibencoding=utf8]{biblatex}
  175. \renewcommand\bibname{\centerline{\reftitlefont{参考文献}}}
  176. %\renewcommand{\citet}[1]{\textsuperscript{\cite{#1}}}
  177. \setcitestyle{square}
  178. % Appendix
  179. % TODO: this needs imporvement
  180. \usepackage{appendix}
  181. %% Some tweaking/features/styles
  182. % Figure & Table
  183. \usepackage{caption}
  184. \usepackage[position=t,singlelinecheck=off]{subfig}
  185. % \renewcommand\thesubfigure{\Alph{subfigure}}
  186. \renewcommand{\captionfont}{\ftcaptionfont}
  187. \renewcommand{\captionlabelfont}{\ftcaptionfont}
  188. \DeclareCaptionLabelSeparator{twospace}{ ~}
  189. \captionsetup{labelsep=twospace} %去掉图1:后冒号
  190. \renewcommand{\tablename}{表}
  191. \renewcommand{\thetable}{~\arabic{chapter}-\arabic{table}~}
  192. \renewcommand{\figurename}{图}
  193. \renewcommand{\thefigure}{~\arabic{chapter}-\arabic{figure}~}
  194. \renewcommand{\theequation}{\arabic{chapter}-\arabic{equation}~}
  195. % 外文文献中表、图、公式编号重置
  196. \newcommand{\newtranschapter}{\thispagestyle{empty}\addtocounter{chapter}{1}\setcounter{table}{0}\setcounter{equation}{0}\setcounter{figure}{0}}
  197. % single figure tweaking
  198. % New figure environment
  199. % Usage: \buptfigure[scale]{figure path}{caption}{label}
  200. \usepackage{graphicx} % graphic package
  201. \newcommand{\buptfigure}[4][width=11cm]{%
  202. \begin{figure}[!htbp]%
  203. \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.
  204. % \begin{center}
  205. \includegraphics[#1]{#2}%
  206. % \end{center}
  207. \caption{#3}%
  208. \label{#4}
  209. \end{figure}}
  210. % table tweaking
  211. % New table environment
  212. % Usage: \begin{bupttable}{caption}{label}
  213. % <normal table>
  214. % \end{bupttable}
  215. \usepackage{multirow} % multirow and multicolumn
  216. \newenvironment{bupttable}[2]{%
  217. \begin{table}[!htbp]%
  218. \centering%
  219. \renewcommand{\arraystretch}{1.38}%
  220. \setlength{\abovecaptionskip}{0pt}%
  221. \setlength{\belowcaptionskip}{10pt}%
  222. \caption{#1}%
  223. \label{#2}}{%
  224. \end{table}}%
  225. % equation tweaking
  226. \usepackage{amssymb}
  227. \usepackage{bm} % 加粗使用
  228. \usepackage{amsmath,delarray,bm,mathtools}
  229. \newtagform{newtag}[]{式(}{)} %定义公式编号样式
  230. \usetagform{newtag}
  231. % Theorem & definition
  232. % \usepackage{amsthm}
  233. \newtheorem{definition}{定义}[chapter]
  234. \newtheorem{theorem}{定理}[chapter]
  235. \newtheorem{axiom}{公理}[chapter]
  236. \newtheorem{lemma}{引理}[chapter]
  237. \newtheorem{proposition}{命题}[chapter]
  238. \newtheorem{corollary}{推论}[chapter]
  239. % Algorithm
  240. \usepackage{algorithm}
  241. \usepackage{algorithmicx}
  242. \usepackage{algpseudocode}
  243. % Code
  244. \usepackage{listings}
  245. \usepackage{xcolor}
  246. \lstset{
  247. basicstyle=\ttfamily\wuhao, %五号等宽字体
  248. extendedchars=true,
  249. keywordstyle=\color{blue},
  250. commentstyle=\color{green!30!black},
  251. showspaces=false, % 显示空格
  252. showstringspaces=true, % 字符串中显示空格
  253. showtabs=false, % 显示 TAB
  254. tabsize=2, % TAB 被当作两个空格
  255. captionpos=t, % 标题位置
  256. breaklines=true, % 自动断行
  257. breakatwhitespace=true,
  258. basewidth={0.5em,0.35em},
  259. frame=single, %单线边框,注释掉则无边框
  260. numbers=left, %行号位于左侧
  261. numberbychapter=true,
  262. % xleftmargin=.5em,
  263. % xrightmargin=.5em,
  264. % aboveskip=1ex,
  265. % columns=flexible, % 如果不指定等宽字体用这个
  266. % mathescape,
  267. escapeinside={\%*}{*)}
  268. }
  269. \renewcommand{\lstlistingname}{\kaishu{代码}}
  270. \makeatletter
  271. \AtBeginDocument{%
  272. \renewcommand \thelstlisting
  273. {\ifnum \c@chapter>\z@ \thechapter-\fi \@arabic\c@lstlisting}%
  274. }
  275. \makeatother
  276. % insert PDF
  277. \usepackage[final]{pdfpages}
  278. % insert blank page
  279. \makeatletter
  280. \newcommand\blankmatter{%
  281. \if@openright\cleardoublepage\else\clearpage\fi%
  282. \@mainmatterfalse%
  283. \pagestyle{empty}}%
  284. \makeatother%