BUPTthesisbachelor.sty 11 KB

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