BUPTthesisbachelor.sty 11 KB

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