BUPTthesisbachelor.sty 10 KB

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