% \iffalse meta-comment
% !TEX program  = LuaLaTeX
%
% hustthesis.dtx
%
% Copyright (C) 2013-2014 by Xu Cheng <xucheng@me.com>
%               2014-2016 by hust-latex <https://github.com/hust-latex>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is hust-latex Organization.
%
% This work consists of the files hustthesis.bst, hustthesis.dtx,
% hustthesis.ins and the derived file hustthesis.cls
% along with its document and example files.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{hustthesis.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{hustthesis}
%<*class>
[2016/11/17 v1.4 A Thesis Template for Huazhong University of Science and Technology]
%</class>
%
%<*driver>
\documentclass[12pt,a4paper,numbered,full]{l3doc}

\usepackage{fontspec}
\setmainfont[Ligatures={Common,TeX}]{Tex Gyre Pagella}
\setsansfont[Ligatures={Common,TeX}]{Droid Sans}
\setmonofont{CMU Typewriter Text}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}

\usepackage{luatexja-fontspec}
\setmainjfont[BoldFont={AdobeHeitiStd-Regular},ItalicFont={AdobeKaitiStd-Regular}]{AdobeSongStd-Light}
\setsansjfont{AdobeKaitiStd-Regular}
\defaultjfontfeatures{JFM=kaiming}
\newjfontfamily\KAI{AdobeKaitiStd-Regular}
\newjfontfamily\FANGSONG{AdobeFangsongStd-Regular}

\linespread{1.2}\selectfont

\usepackage[top=1.2in,bottom=1.2in,left=1.5in,right=1in]{geometry}
\pagewidth=\paperwidth
\pageheight=\paperheight

\usepackage{color}
\usepackage[table]{xcolor}

\definecolor{hyperreflinkred}{RGB}{128,23,31}
\hypersetup{
  unicode,
  bookmarksnumbered=true,
  bookmarksopen=true,
  bookmarksopenlevel=0,
  breaklinks=true,
  colorlinks=true,
  allcolors=hyperreflinkred,
  linktoc=page,
  plainpages=false,
  pdfpagelabels=true,
  pdfstartview={XYZ null null 1}
}
\usepackage{indentfirst}
\setlength{\parindent}{2em}

\usepackage{titlesec,titletoc}
\usepackage[titles]{tocloft}
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{3}

\usepackage{enumitem}
\setlist{noitemsep,partopsep=0pt,topsep=.8ex}
\setlist[1]{labelindent=\parindent}
\setlist[enumerate,1]{label=\arabic*.,ref=\arabic*}
\setlist[enumerate,2]{label*=\arabic*,ref=\theenumi.\arabic*}
\setlist[enumerate,3]{label=\emph{\alph*}),ref=\theenumii\emph{\alph*}}

\usepackage{listings}
\definecolor{lstgreen}{rgb}{0,0.6,0}
\definecolor{lstgray}{rgb}{0.5,0.5,0.5}
\definecolor{lstmauve}{rgb}{0.58,0,0.82}
\lstset{
  basicstyle=\footnotesize\ttfamily\FANGSONG,
  keywordstyle=\color{blue}\bfseries,
  commentstyle=\color{lstgreen}\itshape\KAI,
  stringstyle=\color{lstmauve},
  showspaces=false,
  showstringspaces=false,
  showtabs=false,
  numbers=left,
  numberstyle=\tiny\color{lstgray},
  frame=lines,
  rulecolor=\color{black},
  breaklines=true
}

\AtBeginEnvironment{verbatim}{\small}
\let\AltMacroFont\MacroFont

\usepackage{metalogo}
\usepackage{notes}
\usepackage{tabularx}

\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\setlength{\cftsecindent}{2em}
\setlength{\cftsubsecindent}{4em}
\makeatletter
\newskip\HUST@oldcftbeforepartskip
\HUST@oldcftbeforepartskip=\cftbeforepartskip
\newskip\HUST@oldcftbeforesecskip
\HUST@oldcftbeforesecskip=\cftbeforesecskip
\let\HUST@oldl@part\l@part
\let\HUST@oldl@section\l@section
\let\HUST@oldl@subsection\l@subsection
\def\l@part#1#2{\HUST@oldl@part{#1}{#2}\cftbeforepartskip=3pt}
\def\l@section#1#2{\HUST@oldl@section{#1}{#2}\cftbeforepartskip=\HUST@oldcftbeforepartskip\cftbeforesecskip=3pt}
\def\l@subsection#1#2{\HUST@oldl@subsection{#1}{#2}\cftbeforesecskip=\HUST@oldcftbeforesecskip}
\makeatother

\titleformat{\part}
  {
    \bfseries
    \centering
    \fontsize{18pt}{23.4pt}\selectfont
  }
  {\thepart}
  {1em}
  {}
\let\oldpart\part
\def\part#1{\newpage\oldpart{#1}}

\def\orvar{\textnormal{|}}

\IndexPrologue
 {
  \part{Index}
  The~italic~numbers~denote~the~pages~where~the~
  corresponding~entry~is~described,~
  numbers~underlined~point~to~the~definition,~
  all~others~indicate~the~places~where~it~is~used.
 }

\GlossaryPrologue
 {
  \part{Change History}
 }

\EnableCrossrefs
\CodelineIndex
\RecordChanges

\def\email#1{
  \href{mailto:#1}{\texttt{#1}}
}

\usepackage{xparse}
\ExplSyntaxOn
\DeclareDocumentCommand\pkgurl{o m}
{
    \IfNoValueTF{#1}
    {
        \href
        {
        http://mirrors.ctan.org/help/Catalogue/entries/
        \str_fold_case:n {#2} .html
        }
        { \textsf{#2} }
    }
    {
        \href
        {
        http://mirrors.ctan.org/help/Catalogue/entries/
        \str_fold_case:n {#1} .html
        }
        { \textsf{#2} }
    }
}
\ExplSyntaxOff

\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}

\begin{document}
\DocInput{hustthesis.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{1568}
%
% \iffalse
%<*!(example-bib)>
% \fi
%% \CharacterTable
%% {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%  Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%  Digits        \0\1\2\3\4\5\6\7\8\9
%%  Exclamation   \!     Double quote  \"     Hash (number) \#
%%  Dollar        \$     Percent       \%     Ampersand     \&
%%  Acute accent  \'     Left paren    \(     Right paren   \)
%%  Asterisk      \*     Plus          \+     Comma         \,
%%  Minus         \-     Point         \.     Solidus       \/
%%  Colon         \:     Semicolon     \;     Less than     \<
%%  Equals        \=     Greater than  \>     Question mark \?
%%  Commercial at \@     Left bracket  \[     Backslash     \\
%%  Right bracket \]     Circumflex    \^     Underscore    \_
%%  Grave accent  \`     Left brace    \{     Vertical bar  \|
%%  Right brace   \}     Tilde         \~}
% \iffalse
%</!(example-bib)>
% \fi
%
% \changes{v1.0}{2013/06/01}{Initial version}
% \changes{v1.1}{2013/07/01}{Pack template using dtx and ins file}
% \changes{v1.1}{2013/07/01}{Add language option}
% \changes{v1.2}{2016/06/01}{Fix for TeXLive 2016. Remove \texttt{interfaces} and other problematic package}
% \changes{v1.3}{2016/07/05}{Fix for \XeLaTeX}
% \changes{v1.4}{2016/11/17}{Minor update to fulfill school requirement.}
% \changes{v1.4}{2016/11/17}{Add command to custom apply name field.}
%
% \GetFileInfo{hustthesis.dtx}
%
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\,}
% \DoNotIndex{\def,\if,\else,\fi,\gdef,\long,\let}
% \DoNotIndex{\@ne,\@nil}
% \DoNotIndex{\begingroup,\endgroup,\advance}
% \DoNotIndex{\newcommand,\renewcommand}
% \DoNotIndex{\newenvironment,\renewenvironment}
% \DoNotIndex{\RequirePackage}
%
% \title{A Thesis Template for Huazhong University of Science and Technology: the \textsf{hustthesis} class
% \thanks{This document corresponds to \textsf{hustthesis.cls}~\fileversion, dated \filedate.}}
% \author{Xu Cheng \\ \email{xucheng@me.com}}
% \date{\today}
%
% \begingroup
% \hypersetup{allcolors=black}
% \maketitle
% \endgroup
% \tableofcontents
%
% \part{Introduction}
%
% This is a thesis template for \href{http://www.hust.edu.cn/}{Huazhong University of Science \& Technology}. This template is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%
% The whole project is published under LPPL v1.3 License at \href{https://github.com/hust-latex/hustthesis}{GitHub}.
%
% 中文使用说明见\autoref{part:中文使用说明}。
%
% English version instruction is in \autoref{part:English Version Instruction}.
%
% \part{中文使用说明}\label{part:中文使用说明}
%
% \section{使用必要条件}
%
% \begin{enumerate}
%     \item 安装最新版本的\href{http://www.tug.org/texlive/}{\texttt{TeXLive}}（推荐）或\href{http://miktex.org/}{\texttt{MiKTeX}}。因为未及时更新的宏包可能存在未修复的bug，请确保所有宏包都更新至最新。
%     \item 安装如下中文字体\footnote{本模板所用到的英文字体\textsf{Tex Gyre Termes}，\textsf{Droid Sans}和\textsf{CMU Typewriter Text}均默认安装于\textsf{TeXLive}和\textsf{MiKTeX}中。}：
%     \begin{enumerate}[label=\emph{\alph*})]
%         \item \textsf{AdobeSongStd-Light}
%         \item \textsf{AdobeKaitiStd-Regular}
%         \item \textsf{AdobeHeitiStd-Regular}
%         \item \textsf{AdobeFangsongStd-Regular}
%     \end{enumerate}
%     \begin{informationnote}
%     如果使用\textnormal{\LuaTeX}，安装字体之后需运行命令\verb+mkluatexfontdb+生成字体索引。
%     \end{informationnote}
% \end{enumerate}
%
% \section{安装}
%
% \subsection{安装到本地}
%
% 使用如下命令即可安装本模板到本地：
% \begin{verbatim}
%     make install
% \end{verbatim}
% 如需卸载，则使用如下命令：
% \begin{verbatim}
%     make uninstall
% \end{verbatim}
%
% 对于没有安装\verb+Make+的Windows系统用户，可以使用如下命令安装：
% \begin{verbatim}
%     makewin32.bat install
% \end{verbatim}
% 如需卸载，则使用如下命令：
% \begin{verbatim}
%     makewin32.bat uninstall
% \end{verbatim}
% 虽然\verb+makewin32.bat+表现与\verb+Makefile+极其相似，但是还是强烈建议你安装\verb+Make+，对于Windows用户可以在\href{http://gnuwin32.sourceforge.net/packages/make.htm}{这里}下载。
%
% \subsection{免安装使用}
%
% 如果你希望临时使用本模板，而非安装到本地供长期使用。使用如下命令解压模板文件：
% \begin{verbatim}
%     make unpack
% \end{verbatim}
% 对于没有安装\verb+Make+的Windows系统用户，则使用如下命令解压：
% \begin{verbatim}
%     makewin32.bat unpack
% \end{verbatim}
%
% 再将\verb+hustthesis+目录下的如下文件拷贝到你\TeX{}工程根目录下即可：
% \begin{itemize}
%     \item \verb+hustthesis.bst+
%     \item \verb+hustthesis.cls+
%     \item \verb+hust-title.eps+
%     \item \verb+hust-title.pdf+
% \end{itemize}
%
% \section{基本用法}
%
% \begin{importantnote}
% 本文档只能使用\textnormal{\XeLaTeX}或\textnormal{\LuaLaTeX}（推荐）编译。
% \end{importantnote}
%
% 在源文件开头处选择加载本文档类型，即可使用本模板，如下所示：
% \begin{verbatim}
%     \documentclass{hustthesis}
% \end{verbatim}
%
% \subsection{文档类型选项}
%
% 加载本文档类型时，有如下三个选项提供选择。
%
% \begin{function}{format}
%     \begin{syntax}
%         format = \meta{draft\orvar{}\textbf{final}}
%     \end{syntax}
%     提交草稿选择\verb+draft+选项，提交最终版选\verb+final+选项。其中草稿正文页包括页眉（“华中科技大学\verb+xx+学位论文”）、页眉修饰线（双线）、页脚（页码）和页脚修饰线（单线）。而最终版正文页不包括页眉、页眉修饰线和页脚修饰线，仅包含页脚（页码）。如果不指定，默认设置为\verb+final+。
% \end{function}
%
% \begin{function}{degree}
%     \begin{syntax}
%         degree = \meta{\textbf{none}\orvar{}fyp\orvar{}bachelor\orvar{}master\orvar{}phd}
%     \end{syntax}
%     指定论文种类，它将通过设置字段\verb+\HUST@zhapplyname+和\verb+\HUST@enapplyname+来影响中英文封面处的标题和正文处的页眉（如果\verb+format+设为\verb+draft+）。各个不同的选项产生的效果见表\ref{tab:optdegree-zh}。如果不指定，默认设置为\verb+none+。如有需要，这两个字段可以通过\href{doc/function//applyname}{\texttt{\textbackslash{}zhapplyname},\texttt{\textbackslash{}enapplyname},\texttt{\textbackslash{}applyname}}命令进一步修改。
% \end{function}
%
% \begin{function}[updated=2013-07-01]{language}
%     \begin{syntax}
%         language = \meta{\textbf{chinese}\orvar{}english\orvar{}english-draft}
%     \end{syntax}
%     指定论文语言。特别的，如果设定为\verb+english-draft+，将会剔除论文中的所有中文内容，这有利于在未安装中文字体的环境中使用。如果不指定，默认设置为\verb+chinese+。
% \end{function}
%
% \begin{table}[ht]
%     \centering
%     \caption{\texttt{degree}选项的作用}\label{tab:optdegree-zh}
%     \begin{tabularx}{\textwidth}{|c|X|X|}
%     \hline
%     \textbf{选项} & \tabincell{c}{\textbf{中文标题}\\（字段\verb+\HUST+\verb+@zhapplyname+）} & \tabincell{c}{\textbf{英文标题}\\（字段\verb+\HUST+\verb+@enapplyname+）} \\
%     \hline
%     \verb+none+ & 学位论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree \\ \hline
%     \verb+fyp+ & 毕业论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for Final Year Project \\ \hline
%     \verb+bachelor+ & 学士学位论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Bachelor \\ \hline
%     \verb+master+ & 硕士学位论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Master \\ \hline
%     \verb+phd+ & 博士学位论文 & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Philosophy \\ \hline
%     \end{tabularx}
% \end{table}
%
% \subsection{基本字段设置}
%
% 模板中定义一些命令用于设置文档中的字段。其中一部分命令是以\verb+\zhX{<Chinese var>}+，\verb+\enX{<English var>}+和\verb+\X{<Chinese var>}{<English var>}+的形式出现，他们分别意味着设置字段\verb+X+的中文部分，英文部分及一同设定。
%
% \begin{function}{\zhtitle,\entitle,\title}
%     \begin{syntax}
%     \cs{zhtitle}\Arg{Chinese title}
%     \cs{entitle}\Arg{English title}
%     \cs{title}\Arg{Chinese title}\Arg{English title}
%     \end{syntax}
%     这一组命令用于设定论文的中英文标题。
% \end{function}
%
% \begin{function}{\zhauthor,\enauthor,\author}
%     \begin{syntax}
%     \cs{zhauthor}\Arg{Chinese author}
%     \cs{enauthor}\Arg{English author}
%     \cs{author}\Arg{Chinese author}\Arg{English author}
%     \end{syntax}
%     这一组命令用于设定论文的中英文作者名。
% \end{function}
%
% \begin{function}{\date}
%     \begin{syntax}
%     \cs{date}\Arg{Year}\Arg{Month}\Arg{Day}
%     \end{syntax}
%     该命令用于设定论文的答辩日期。如果不设定，则会选择当前编译日期作为答辩日期。
% \end{function}
%
% \begin{function}{\zhschoolname,\enschoolname,\schoolname}
%     \begin{syntax}
%     \cs{zhschoolname}\Arg{Chinese school name}
%     \cs{enschoolname}\Arg{English school name}
%     \cs{schoolname}\Arg{Chinese school name}\Arg{English school name}
%     \end{syntax}
%     这一组命令用于设定论文的中英文学校名。该字段在模板中已默认设置为\verb+\schoolname{华中科技大学}{Huazhong University of Science \& Technology}+。所以除非需更改学校名，无需使用该命令。
% \end{function}
%
% \begin{function}{\zhaddress,\enaddress,\address}
%     \begin{syntax}
%     \cs{zhaddress}\Arg{Chinese address}
%     \cs{enaddress}\Arg{English address}
%     \cs{address}\Arg{Chinese address}\Arg{English address}
%     \end{syntax}
%     这一组命令用于设定论文的中英文学校地址。该字段在模板中已默认设置为\verb+\address{中国，武汉，430074}{Wuhan~430074, P.~R.~China}+。所以除非需更改学校地址，无需使用该命令。
% \end{function}
%
% \begin{function}[updated=2016-11-17]{\zhapplyname,\enapplyname,\applyname}
%     \begin{syntax}
%     \cs{zhapplyname}\Arg{Chinese apply name}
%     \cs{enapplyname}\Arg{English apply name}
%     \cs{applyname}\Arg{Chinese apply name}\Arg{English apply name}
%     \end{syntax}
%     这一组命令用于自定义中英文封面处的标题和正文处的页眉。详情见~\href{doc/function//degree}{\texttt{degree} 文档类型选项}。
% \end{function}
%
% \begin{function}{\zhmajor,\enmajor,\major}
%     \begin{syntax}
%     \cs{zhmajor}\Arg{Chinese major}
%     \cs{enmajor}\Arg{English major}
%     \cs{major}\Arg{Chinese major}\Arg{English major}
%     \end{syntax}
%     这一组命令用于设定论文的中英文专业名。
% \end{function}
%
% \begin{function}{\zhsupervisor,\ensupervisor,\supervisor}
%     \begin{syntax}
%     \cs{zhsupervisor}\Arg{Chinese supervisor}
%     \cs{ensupervisor}\Arg{English supervisor}
%     \cs{supervisor}\Arg{Chinese supervisor}\Arg{English supervisor}
%     \end{syntax}
%     这一组命令用于设定论文的中英文指导老师名（含职称）。
% \end{function}
%
% \begin{function}{\zhasssupervisor,\enasssupervisor,\asssupervisor}
%     \begin{syntax}
%     \cs{zhasssupervisor}\Arg{Chinese asssupervisor}
%     \cs{enasssupervisor}\Arg{English asssupervisor}
%     \cs{asssupervisor}\Arg{Chinese asssupervisor}\Arg{English asssupervisor}
%     \end{syntax}
%     这一组命令用于设定论文的中英文副指导老师名（含职称）。该命令是可选的，如果不加以设定，封面处不会显示相应项。
% \end{function}
%
% \begin{function}{\schoolcode}
%     \begin{syntax}
%     \cs{schoolcode}\Arg{school code}
%     \end{syntax}
%     用于设置学校代码。
% \end{function}
%
% \begin{function}{\stuno}
%     \begin{syntax}
%     \cs{stuno}\Arg{student number}
%     \end{syntax}
%     用于设置学号。
% \end{function}
%
% \begin{function}{\classno}
%     \begin{syntax}
%     \cs{classno}\Arg{classify number}
%     \end{syntax}
%     用于设置分类号。
% \end{function}
%
% \begin{function}{\secretlevel}
%     \begin{syntax}
%     \cs{secretlevel}\Arg{secret level}
%     \end{syntax}
%     用于设置密级。
% \end{function}
%
% \begin{function}{\zhabstract,\enabstract,\abstract}
%     \begin{syntax}
%     \cs{zhabstract}\Arg{Chinese abstract}
%     \cs{enabstract}\Arg{English abstract}
%     \cs{abstract}\Arg{Chinese abstract}\Arg{English abstract}
%     \end{syntax}
%     这一组命令用于设定论文的中英文摘要。
% \end{function}
%
% \begin{function}{\zhkeywords,\enkeywords,\keywords}
%     \begin{syntax}
%     \cs{zhkeywords}\Arg{Chinese keywords}
%     \cs{enkeywords}\Arg{English keywords}
%     \cs{keywords}\Arg{Chinese keywords}\Arg{English keywords}
%     \end{syntax}
%     这一组命令用于设定论文的中英文关键字。
% \end{function}
%
% \subsection{其它基本命令}
%
% 下面来介绍其它基本命令。
%
% \begin{function}{\frontmatter,\mainmatter,\backmatter}
%     这一组命令用于设定论文的状态、改变样式，其具体使用见\nameref{sec:简单示例}。\verb+\frontmatter+用在文档最开始，表明文档的前言部分（如封面，摘要，目录等）的开始。\verb+\mainmatter+表示论文正文的开始。\verb+\backmatter+表示论文正文的结束。
% \end{function}
%
% \begin{function}{\maketitle,\makecover}
%     \verb+\maketitle+和\verb+\makecover+作用相同，用于生成封面和版权页面。
% \end{function}
%
% \begin{function}{\makeabstract}
%     用于生成中英文摘要页面。
% \end{function}
%
% \begin{function}{\tableofcontents}
%     用于生成目录。
% \end{function}
%
% \begin{function}{\zhdateformat,\endateformat}
%     用于打印中英文日期。
% \end{function}
%
% \vskip 1ex\DescribeEnv{ack}
%     \verb+ack+环境用于致谢页面。使用方法如下：
%     \begin{verbatim}
%     \begin{ack}
%         <content>
%     \end{ack}
%     \end{verbatim}
%
% \begin{function}{\bibliography}
%     \begin{syntax}
%     \cs{bibliography}\Arg{.bib file}
%     \end{syntax}
%     用于生成参考文献。
% \end{function}
%
% \vskip 1ex\DescribeEnv{appendix}
%     \verb+appendix+环境用于附录环境。你可以将附录置于\verb+appendix+环境中，如：
%     \begin{verbatim}
%     \begin{appendix}
%         <content>
%     \end{appendix}
%     \end{verbatim}
% \begin{function}{\appendix}
%     或者使用\verb+\appendix+代表后文均为附录，如：
%     \begin{verbatim}
%     \appendix
%     <content>
%     \end{verbatim}
% \end{function}
%
% \begin{function}{\listoffigures,\listoftables}
%     这两个命令分别用于生成图片和表格索引，可以根据要求在论文前言中使用或附录中使用。
% \end{function}
%
% \vskip 1ex\DescribeEnv{publications}
%     \verb+publications+环境用于已发表论文页面。一般用于附录中。使用上同\verb+enumerate+环境。如下：
%     \begin{verbatim}
%     \begin{publications}
%         \item <thesis>
%         <...>
%     \end{publications}
%     \end{verbatim}
%
% \begin{function}{\TurnOffTabFontSetting,\TurnOnTabFontSetting}
%     因为模板中设定了表格的行距和字号，使得使用中无法临时自定义表格的行距和字号。故提供两个命令用于关闭和开启默认表格的行距和字号设置。比如你如果需要输出一个自己定义字号的表格，可以使用如下示例：
%     \begin{verbatim}
%     \begingroup
%     \TurnOffTabFontSetting
%     \footnotesize % 设置字号
%     \begin{tabular}{...}
%         <content>
%     \end{tabular}
%     \TurnOnTabFontSetting
%     \endgroup
%     \end{verbatim}
% \end{function}
%
% \begin{function}{\email}
%     \begin{syntax}
%     \cs{email}\Arg{Email Address}
%     \end{syntax}
%     用于生成邮箱地址。如\verb+\email{name@example.com}+会生成如下效果的地址：\email{name@example.com}。
% \end{function}
%
% \section{简单示例}\label{sec:简单示例}
% 如下为一个使用本模板的简单示例。更完整的例子请见\texttt{hustthesis-zh-example.tex}文件，其效果见\href{https://github.com/hust-latex/hustthesis/raw/master/hustthesis/hustthesis-zh-example.pdf}{\texttt{hustthesis-zh-example.pdf}}。
%
% \iffalse
%<*driver>
% \fi
\begin{lstlisting}[language={[LaTeX]TeX}]
\documentclass[degree=phd,language=chinese]{hustthesis}

\stuno{你的学号}
\schoolcode{10487}
\title{中文标题}{英文标题}
\author{作者名}{作者名拼音}
\major{专业中文}{专业英文}
\supervisor{指导老师中文}{指导老师英文}
\date{2013}{7}{1} % 答辩日期

\zhabstract{中文摘要}
\zhkeywords{中文关键字}
\enabstract{英文摘要}
\enkeywords{英文关键字}

\begin{document}

\frontmatter
\maketitle
\makeabstract
\tableofcontents
\listoffigures
\listoftables
\mainmatter

%% 正文

\backmatter

\begin{ack}
%% 致谢
\end{ack}
\bibliography{参考文献.bib文件}

\appendix

\begin{publications}
%% 发表过的论文列表
\end{publications}

%% 附录剩余部分

\end{document}
\end{lstlisting}
% \iffalse
%</driver>
% \fi
%
% \section{预设宏包介绍}
%
% 本模板中预设了一些宏包，下面对其进行简单介绍。
%
% \begin{itemize}
%     \item \pkgurl{algorithm2e} 算法环境。
%     \item \pkgurl{enumitem} 自定义列表环境的式样。
%     \item \pkgurl{fancynum} 用于将大数每三位断开。
%     \item \pkgurl{listings} 代码环境。如需更好的代码高亮可以使用\pkgurl{minted}宏包。
%     \item \pkgurl{longtable} 跨页的超长表格环境。
%     \item \pkgurl{ltxtable} \textsf{longtable}环境和\textsf{tabularx}环境的合并。
%     \item \pkgurl{multirow} 用于表格中合并行。
%     \item \pkgurl{overpic} 用于在图片上层叠其他内容。
%     \item \pkgurl{tabularx} 扩展到表格环境。
%     \item \pkgurl{zhnumber} 用于生成中文数字。
% \end{itemize}
%
% \section{高级设置}
%
% \subsection{切换字体}
%
% 模板正文字体为宋体（\textsf{AdobeSongStd-Light}），同时我们提供如下命令切换中文字体：
%
% \begin{function}{\HEI,\hei}
%     \begin{syntax}
%     \{\cs{HEI} \meta{content}\}
%     \cs{hei}\Arg{content}
%     \end{syntax}
%     切换字体为黑体（\textsf{AdobeHeitiStd-Regular}）。
% \end{function}
%
% \begin{function}{\KAI,\kai}
%     \begin{syntax}
%     \{\cs{KAI} \meta{content}\}
%     \cs{kai}\Arg{content}
%     \end{syntax}
%     切换字体为楷体（\textsf{AdobeKaitiStd-Regular}）。
% \end{function}
%
% \begin{function}{\FANGSONG,\fangsong}
%     \begin{syntax}
%     \{\cs{FANGSONG} \meta{content}\}
%     \cs{fangsong}\Arg{content}
%     \end{syntax}
%     切换字体为仿宋（\textsf{AdobeFangsongStd-Regular}）。
% \end{function}
%
% 如果需要加载其他字体，请参阅宏包\pkgurl{fontspec}，宏包\pkgurl{xeCJK}（对于\XeLaTeX{}）和宏包\pkgurl[luatexja]{luatex-ja}（对于\LuaLaTeX{}）的文档。
%
% \subsection{内部字段设置}
%
% 本模板定义了很多内部字段，其具体内容见\autoref{sec:Localization}。通过更改这些字段，可以对论文格式进行自定义。
%
% \part{English Version Instruction}\label{part:English Version Instruction}
%
% \section{Requirement}
% Install the latest version of \href{http://www.tug.org/texlive/}{\texttt{TeXLive}}(Recommend) or \href{http://miktex.org/}{\texttt{MiKTeX}}. Please ensure that all the packages are up-to-date.
%
% If you need to produce the final format of thesis (see \autoref{subsec:Option} for more details), you should also need to install following Chinese fonts:
% \begin{itemize}
%   \item \textsf{AdobeSongStd-Light}
%   \item \textsf{AdobeKaitiStd-Regular}
%   \item \textsf{AdobeHeitiStd-Regular}
%   \item \textsf{AdobeFangsongStd-Regular}
% \end{itemize}
% \begin{informationnote}
% If you use \textnormal{\LuaTeX}, you need to run the command \verb+mkluatexfontdb+ to refresh font database index after installing the fonts.
% \end{informationnote}
%
% \section{Installation}
%
% \subsection{Install into local}
%
% Use the command below to install this template into local.
% \begin{verbatim}
%    make install
% \end{verbatim}
% If you need uninstall it, use the command below.
% \begin{verbatim}
%    make uninstall
% \end{verbatim}
%
% For Windows User who don't install \texttt{Make}, use the command below to install.
% \begin{verbatim}
%     makewin32.bat install
% \end{verbatim}
% If you need uninstall it, use the command below.
% \begin{verbatim}
%     makewin32.bat uninstall
% \end{verbatim}
% Although \texttt{makewin32.bat} behaves much like \texttt{Makefile}, I still
% recommend you install \texttt{Make} into your Windows. You can download
% it from \href{http://gnuwin32.sourceforge.net/packages/make.htm}{here}.
%
% \subsection{Use without installation}
%
% If you want to use this template temporary rather than installing it into local for long term use. Run below command to unpack the package.
% \begin{verbatim}
%     make unpack
% \end{verbatim}
% For Windows User who don't install \texttt{Make}, use the command below to unpack the package.
% \begin{verbatim}
%     makewin32.bat unpack
% \end{verbatim}
% Then copy the following files from directory \texttt{hustthesis} into your \TeX{} project root directory.
% \begin{itemize}
%     \item \verb+hustthesis.bst+
%     \item \verb+hustthesis.cls+
%     \item \verb+hust-title.eps+
%     \item \verb+hust-title.pdf+
% \end{itemize}
%
% \section{Usage}
% \begin{importantnote}
% This template can only be compiled by \\
% \hskip 10pt \textnormal{\XeLaTeX} or\textnormal{\LuaLaTeX}(Recommend).
% \end{importantnote}
%
% Insert below code in the top of source code to use this template:
% \begin{verbatim}
%     \documentclass[language=english]{hustthesis}
% \end{verbatim}
%
% \subsection{Option} \label{subsec:Option}
%
% There're three options available when use this template.
%
% % \begin{function}{format}
%     \begin{syntax}
%         format = \meta{draft\orvar{}\textbf{final}}
%     \end{syntax}
%     If \verb+format+ is set to \verb+final+, the header will be removed. This option is only valid if \verb+language+ is not set to \verb+english-draft+. The default value is \verb+final+.
% \end{function}
%
% \begin{function}[updated=2013-07-01]{language}
%     \begin{syntax}
%         language = \meta{\textbf{chinese}\orvar{}english\orvar{}english-draft}
%     \end{syntax}
%     Set what language is used in the document. Specially, if it's set to \verb+english-draft+, all the Chinese characters will be removed in the document. This is extremely helpful when you don't install Chinese fonts. The default value is \verb+chinese+.
% \end{function}
%
% \begin{function}{degree}
%     \begin{syntax}
%         degree = \meta{\textbf{none}\orvar{}fyp\orvar{}bachelor\orvar{}master\orvar{}phd}
%     \end{syntax}
%     Set the category of thesis. It will influence the title of document, see Table~\ref{tab:optdegree-en}. The default value is \verb+none+. Noted that the apply name field in the title page can be further customized through \href{doc/function//applyname}{\texttt{\textbackslash{}applyname}} command.
% \end{function}
%
% \begin{table}[ht]
%     \centering
%     \caption{Title under different \texttt{degree}}\label{tab:optdegree-en}
%     \begin{tabularx}{\textwidth}{|c|X|}
%     \hline
%     \textbf{Option} & \textbf{Title}\\
%     \hline
%     \verb+none+  & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree \\ \hline
%     \verb+fyp+ & A Thesis Submitted in Partial Fulfillment of the Requirements for Final Year Project \\ \hline
%     \verb+bachelor+ & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Bachelor \\ \hline
%     \verb+master+ & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Master \\ \hline
%     \verb+phd+ & A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Philosophy \\ \hline
%     \end{tabularx}
% \end{table}
%
% \subsection{Variables setting}
%
% There're some commands which are used to set the variables for the thesis.
%
% \begin{function}{\title}
%     \begin{syntax}
%     \cs{title}\Arg{title}
%     \end{syntax}
%     Set title.
% \end{function}
%
% \begin{function}{\author}
%     \begin{syntax}
%     \cs{author}\Arg{author}
%     \end{syntax}
%     Set author.
% \end{function}
%
% \begin{function}{\date}
%     \begin{syntax}
%     \cs{date}\Arg{Year}\Arg{Month}\Arg{Day}
%     \end{syntax}
%     Set date. If you don't set it, template will use current date.
% \end{function}
%
% \begin{function}{\schoolname}
%     \begin{syntax}
%     \cs{schoolname}\Arg{school name}
%     \end{syntax}
%     Set the name of school which has been set as \\*\hbox{\verb+\schoolname{Huazhong University of Science \& Technology}+} by default. So unless you want to change the name, you don't need to use this command.
% \end{function}
%
% \begin{function}{\address}
%     \begin{syntax}
%     \cs{address}\Arg{address}
%     \end{syntax}
%     Set the address of school which has been set as \\*\hbox{\verb+\address{Wuhan~430074, P.~R.~China}+} by default. So unless you want to change the address, you don't need to use this command.
% \end{function}
%
% \begin{function}[updated=2016-11-17]{\applyname}
%     \begin{syntax}
%     \cs{applyname}\Arg{apply name}
%     \end{syntax}
%     Custom the apply name which affects English title page. See more detail at~\href{doc/function//degree}{\texttt{degree} option}.
% \end{function}
%
% \begin{function}{\major}
%     \begin{syntax}
%     \cs{major}\Arg{major}
%     \end{syntax}
%     Set your major.
% \end{function}
%
% \begin{function}{\supervisor}
%     \begin{syntax}
%     \cs{supervisor}\Arg{supervisor}
%     \end{syntax}
%     Set your supervisor.
% \end{function}
%
% \begin{function}{\asssupervisor}
%     \begin{syntax}
%     \cs{asssupervisor}\Arg{ass-supervisor}
%     \end{syntax}
%     Set your ass-supervisor if you have.
% \end{function}
%
% \begin{function}{\abstract}
%     \begin{syntax}
%     \cs{abstract}\Arg{abstract}
%     \end{syntax}
%     Put your abstract.
% \end{function}
%
% \begin{function}{\keywords}
%     \begin{syntax}
%     \cs{keywords}\Arg{keywords}
%     \end{syntax}
%     Put your keywords.
% \end{function}
%
% \subsection{Other commands}
%
% \begin{function}{\frontmatter,\mainmatter,\backmatter}
%     Used to determine the different part of document. You can see the example at \autoref{sec:simple-example}.
% \end{function}
%
% \begin{function}{\maketitle,\makecover}
%     \verb+\maketitle+ and \verb+\makecover+ are the same. Used to create the title page.
% \end{function}
%
% \begin{function}{\makeabstract}
%     Used to create abstract page.
% \end{function}
%
% \begin{function}{\tableofcontents}
%     Used to create table of contents.
% \end{function}
%
% \begin{function}{\endateformat}
%     Used to print the date.
% \end{function}
%
% \vskip 1ex\DescribeEnv{ack}
%     The \verb+ack+ environment is used to create acknowledge page.
%     \begin{verbatim}
%     \begin{ack}
%         <content>
%     \end{ack}
%     \end{verbatim}
%
% \begin{function}{\bibliography}
%     \begin{syntax}
%     \cs{bibliography}\Arg{.bib file}
%     \end{syntax}
%     Used to create bibliography page.
% \end{function}
%
% \vskip 1ex\DescribeEnv{appendix}
%     The \verb+appendix+ environment is for appendix of course. Used like this:
%     \begin{verbatim}
%     \begin{appendix}
%         <content>
%     \end{appendix}
%     \end{verbatim}
% \begin{function}{\appendix}
%     Or simple use \verb+\appendix+ to indicate that the rest of document are all in appendix, like this:
%     \begin{verbatim}
%     \appendix
%     <content>
%     \end{verbatim}
% \end{function}
%
% \begin{function}{\listoffigures,\listoftables}
%     Create the index for all the figures and tables separately.
% \end{function}
%
% \vskip 1ex\DescribeEnv{publications}
%     The \verb+publications+ environment is where you list all of your published thesises. It's usually putted in appendix.
%     \begin{verbatim}
%     \begin{publications}
%         \item <thesis>
%         <...>
%     \end{publications}
%     \end{verbatim}
%
% \begin{function}{\TurnOffTabFontSetting,\TurnOnTabFontSetting}
%     This template has set the font size and line spread for all the tables which makes it's impossible to change font format temporary in one table.  So it provides these to command to temporary disable or enable default font setting in table. For example, if you want to change table font size, you can use the code like this:
%     \begin{verbatim}
%     \begingroup
%     \TurnOffTabFontSetting
%     \footnotesize % Set your font format as you like.
%     \begin{tabular}{...}
%         <content>
%     \end{tabular}
%     \TurnOnTabFontSetting
%     \endgroup
%     \end{verbatim}
% \end{function}
%
% \begin{function}{\email}
%     \begin{syntax}
%     \cs{email}\Arg{Email Address}
%     \end{syntax}
%     A command to display email address. For example, \verb+\email{name@example.com}+ would look like this: \email{name@example.com}.
% \end{function}
%
% \section{Simple example}\label{sec:simple-example}
% Below is a simple example of using this template. For a complete example see \texttt{hustthesis-en-example.tex} which will generate \href{https://github.com/hust-latex/hustthesis/raw/master/hustthesis/hustthesis-en-example.pdf}{\texttt{hustthesis-en-example.pdf}}.
%
% \iffalse
%<*driver>
% \fi
\begin{lstlisting}[language={[LaTeX]TeX}]
\documentclass[degree=phd,language=english]{hustthesis}

\title{your title}
\author{your name}
\major{your major}
\supervisor{your supervisor}
\date{2013}{7}{1}

\abstract{the abstract}
\keywords{the keywords}

\begin{document}

\frontmatter
\maketitle
\makeabstract
\tableofcontents
\listoffigures
\listoftables
\mainmatter

%% main body

\backmatter

\begin{ack}
%% acknowledge
\end{ack}
\bibliography{.bib file}

\appendix

\begin{publications}
%% your publications
\end{publications}

%% rest of appendix

\end{document}
\end{lstlisting}
% \iffalse
%</driver>
% \fi
%
%
% \section{Introduction to some packages used in the template}
%
% Here's a list of some packages used in the template.
%
% \begin{itemize}
%     \item \pkgurl{algorithm2e} For display algorithm.
%     \item \pkgurl{enumitem} For set the style of enumerate, itemize and description environment.
%     \item \pkgurl{fancynum} Display the really big number.
%     \item \pkgurl{listings} For display the highlighted code. If you need better quality, use the package \pkgurl{minted}.
%     \item \pkgurl{longtable} Create a very long table.
%     \item \pkgurl{ltxtable} Combine the features of \textsf{longtable} anb \textsf{tabularx}.
%     \item \pkgurl{multirow} Combine multi-rows in table.
%     \item \pkgurl{overpic} Put something over a picture,
%     \item \pkgurl{tabularx} A better table environment.
% \end{itemize}
%
% \StopEventually{
%  \PrintIndex
%  \PrintChanges
% }
%
% \part{Implementation}\label{part:Implementation}
%
%    \begin{macrocode}
%<*class>
\RequirePackage{ifthen}
%    \end{macrocode}
%
% \section{Process Options}
% Use \pkgurl{xkeyval} to process options.
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
%
% Option |format|.
%    \begin{macrocode}
\newif\ifHUST@finalformat
\HUST@finalformattrue
\DeclareOptionX{format}[final]{
  \ifthenelse{\equal{#1}{final}}{
    \HUST@finalformattrue
  }{
    \ifthenelse{\equal{#1}{draft}}{
      \HUST@finalformatfalse
    }{
      \ClassError{hustthesis}
      {Option format can only be 'final' or 'draft'}
      {Try to remove option format^^J}
    }
  }
}
%    \end{macrocode}
%
% Option |language|.
%    \begin{macrocode}
\gdef\HUST@language{chinese}
\DeclareOptionX{language}[chinese]{
  \ifthenelse{\equal{#1}{chinese} \OR \equal{#1}{english} \OR \equal{#1}{english-draft}}{
    \gdef\HUST@language{#1}
  }{
    \ClassError{hustthesis}
    {Option language can only be 'chinese', 'english' or 'english-draft'}
    {Try to remove option language^^J}
  }
}
%    \end{macrocode}
%
% Option |degree|.
%    \begin{macrocode}
\gdef\HUST@degree{none}
\DeclareOptionX{degree}[none]{
  \ifthenelse{\equal{#1}{none} \OR \equal{#1}{fyp} \OR \equal{#1}{bachelor} \OR \equal{#1}{master} \OR \equal{#1}{phd}}{
    \gdef\HUST@degree{#1}
  }{
     \ClassError{hustthesis}
      {Option degree can only be 'none', 'fyp', 'bachelor', 'master' or 'phd'}
      {Try to remove option degree^^J}
  }
}
%    \end{macrocode}
%
% Process options and load class |book|.
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptionsX
\LoadClass[12pt, a4paper, openany]{book}
%    \end{macrocode}
%
% \section{Check Engine}
% Check engine, only \XeLaTeX{} and \LuaLaTeX{} are supported.
%    \begin{macrocode}
\RequirePackage{iftex}
\ifXeTeX\else
  \ifLuaTeX\else
    \begingroup
      \errorcontextlines=-1\relax
      \newlinechar=10\relax
      \errmessage{^^J
      *******************************************************^^J
      * XeTeX or LuaTeX is required to compile this document.^^J
      * Sorry!^^J
      *******************************************************^^J
      }%
    \endgroup
  \fi
\fi
%    \end{macrocode}
%
% \section{Font Setting}
% Set font used in document. Firstly, it's font setting for English font under |english-draft| mode. We use \pkgurl{fontspec} package to handle font. We choose \textsf{Tex Gyre Termes}, \textsf{Droid Sans} and \textsf{CMU Typewriter Text} as document main font, sans font and mono font.
%    \begin{macrocode}
\ifthenelse{\equal{\HUST@language}{english-draft}}{
    \RequirePackage{fontspec}
    \setmainfont[
      Ligatures={Common,TeX},
      Extension=.otf,
      UprightFont=*-regular,
      BoldFont=*-bold,
      ItalicFont=*-italic,
      BoldItalicFont=*-bolditalic]{texgyretermes}
    \setsansfont[Ligatures={Common,TeX}]{Droid Sans}
    \setmonofont{CMU Typewriter Text}
    \defaultfontfeatures{Mapping=tex-text}
%    \end{macrocode}
%
% Now let's set the Chinese font commands into empty, when document is under |english-draft| mode.
%    \begin{macrocode}
    \let\HEI\relax
    \let\KAI\relax
    \let\FANGSONG\relax
    \newcommand{\hei}[1]{#1}
    \newcommand{\kai}[1]{#1}
    \newcommand{\fangsong}[1]{#1}
}{}
%    \end{macrocode}
%
% Below is the font setting under |chinese| or |english| mode. We chooses the same English font as under |english-draft| mode. We use \pkgurl{xecjk} package (for \XeLaTeX) or \pkgurl[luatexja]{luatex-ja} package (for \LuaLaTeX, recommend) to handle Chinese font. We will use font: \textsf{AdobeSongStd-Light}, \textsf{AdobeKaitiStd-Regular}, \textsf{AdobeHeitiStd-Regular} and \textsf{AdobeFangsongStd-Regular}.
%    \begin{macrocode}
\ifthenelse{\equal{\HUST@language}{english-draft}}{}{
    \ifXeTeX  % XeTeX下使用fontspec + xeCJK处理字体
      % 英文字体
      \RequirePackage{fontspec}
      \RequirePackage{xunicode}
      \setmainfont[
        Ligatures={Common,TeX},
        Extension=.otf,
        UprightFont=*-regular,
        BoldFont=*-bold,
        ItalicFont=*-italic,
        BoldItalicFont=*-bolditalic]{texgyretermes}
      \setsansfont[Ligatures={Common,TeX}]{Droid Sans}
      \setmonofont{CMU Typewriter Text}
      \defaultfontfeatures{Mapping=tex-text}
      % 中文字体
      \RequirePackage[CJKmath]{xeCJK}
      \setCJKmainfont[
       BoldFont={Adobe Heiti Std},
       ItalicFont={Adobe Kaiti Std}]{Adobe Song Std}
      \setCJKsansfont{Adobe Kaiti Std}
      \setCJKmonofont{Adobe Fangsong Std}
      \xeCJKsetup{PunctStyle=kaiming}

      \newcommand\ziju[2]{{\renewcommand{\CJKglue}{\hskip #1} #2}}
%    \end{macrocode}
%
% \begin{macro}{\HEI}
%    \begin{macrocode}
      \newCJKfontfamily\HEI{Adobe Heiti Std}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\KAI}
%    \begin{macrocode}
      \newCJKfontfamily\KAI{Adobe Kaiti Std}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FANGSONG}
%    \begin{macrocode}
      \newCJKfontfamily\FANGSONG{Adobe Fangsong Std}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hei}
%    \begin{macrocode}
      \newcommand{\hei}[1]{{\HEI #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\kai}
%    \begin{macrocode}
      \newcommand{\kai}[1]{{\KAI #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fangsong}
%    \begin{macrocode}
      \newcommand{\fangsong}[1]{{\FANGSONG #1}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
    \else\fi
    \ifLuaTeX  % LuaTeX下使用luatex-ja处理字体 [推荐]
      \RequirePackage{luatexja-fontspec}
      % 英文字体
      \setmainfont[Ligatures={Common,TeX}]{Tex Gyre Termes}
      \setsansfont[Ligatures={Common,TeX}]{Droid Sans}
      \setmonofont{CMU Typewriter Text}
      \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
      % 中文字体
      \setmainjfont[
       BoldFont={AdobeHeitiStd-Regular},
       ItalicFont={AdobeKaitiStd-Regular}]{AdobeSongStd-Light}
      \setsansjfont{AdobeKaitiStd-Regular}
      \defaultjfontfeatures{JFM=kaiming}

      \newcommand\ziju[2]{\vbox{\ltjsetparameter{kanjiskip=#1} #2}}
%    \end{macrocode}
%
% \begin{macro}{\HEI}
%    \begin{macrocode}
      \newjfontfamily\HEI{AdobeHeitiStd-Regular}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\KAI}
%    \begin{macrocode}
      \newjfontfamily\KAI{AdobeKaitiStd-Regular}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FANGSONG}
%    \begin{macrocode}
      \newjfontfamily\FANGSONG{AdobeFangsongStd-Regular}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hei}
%    \begin{macrocode}
      \newcommand{\hei}[1]{{\jfontspec{AdobeHeitiStd-Regular} #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\kai}
%    \begin{macrocode}
      \newcommand{\kai}[1]{{\jfontspec{AdobeKaitiStd-Regular} #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fangsong}
%    \begin{macrocode}
      \newcommand{\fangsong}[1]{{\jfontspec{AdobeFangsongStd-Regular} #1}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
    \else\fi
%    \end{macrocode}
%
% Generate Chinese number using \pkgurl{zhnumber}.
%    \begin{macrocode}
    \RequirePackage{zhnumber}
    \def\CJKnumber#1{\zhnumber{#1}} % 兼容CJKnumb
}
%    \end{macrocode}
%
% \section{Basic Format}
% We set global line spread to 1.3.
%    \begin{macrocode}
\linespread{1.3}\selectfont
%    \end{macrocode}
%
% Use \pkgurl{geometry} package to handle paper page.
%    \begin{macrocode}
\RequirePackage{geometry}
\geometry{
  top=1.77in,
  bottom=0.8in,
  left=1.1in,
  right=1.1in,
  includefoot
}
\ifthenelse{\isundefined{\pagewidth}}{
  \pdfpagewidth=\paperwidth
  \pdfpageheight=\paperheight
}{
  \pagewidth=\paperwidth
  \pageheight=\paperheight
}
%    \end{macrocode}
%
% Indent of paragraph and skip between paragraphs.
%    \begin{macrocode}
\RequirePackage{indentfirst}
\setlength{\parindent}{2em}
\setlength{\parskip}{0pt plus 2pt minus 1pt}
%    \end{macrocode}
%
% Packages to handle color.
%    \begin{macrocode}
\RequirePackage{color}
\RequirePackage[table]{xcolor}
%    \end{macrocode}
%
% Use \pkgurl{hyperref} package to generate cross-reference link.
%    \begin{macrocode}
\RequirePackage[unicode]{hyperref}
\hypersetup{
  bookmarksnumbered=true,
  bookmarksopen=true,
  bookmarksopenlevel=1,
  breaklinks=true,
  colorlinks=true,
  allcolors=black,
  linktoc=all,
  plainpages=false,
  pdfpagelabels=true,
  pdfstartview={XYZ null null 1},
  pdfinfo={Template.Info={hustthesis.cls v1.1 2013/07/01, Copyright (C) 2013-2014 by Xu Cheng 2014 by hust-latex, https://github.com/hust-latex/hustthesis}}
}
%    \end{macrocode}
%
% \section{Load Packages}
% Load packages for math.
%    \begin{macrocode}
\RequirePackage{amsmath,amssymb,amsfonts}
\RequirePackage[amsmath,amsthm,thmmarks,hyperref,thref]{ntheorem}
\RequirePackage{fancynum}
\setfnumgsym{\,}
\RequirePackage[lined,boxed,linesnumbered,ruled,vlined,algochapter]{algorithm2e}
%    \end{macrocode}
%
% Load packages for picture.
%    \begin{macrocode}
\RequirePackage{overpic}
\RequirePackage{graphicx,caption,subcaption}
%    \end{macrocode}
%
% Load packages for table.
%    \begin{macrocode}
\RequirePackage{array}
\RequirePackage{multirow,tabularx,ltxtable}
%    \end{macrocode}
%
% Load package for code highlight. Here we use \pkgurl{listings} to highlight the code. But if you need more features, use \pkgurl{minted}.
%    \begin{macrocode}
\RequirePackage{listings}
%    \end{macrocode}
%
% Load package for bibliography cite style.
%    \begin{macrocode}
\RequirePackage[numbers,square,comma,super,sort&compress]{natbib}
%    \end{macrocode}
%
% Other packages for style setting.
%    \begin{macrocode}
\RequirePackage{titlesec}
\RequirePackage{titletoc}
\RequirePackage{tocvsec2}
\RequirePackage[inline]{enumitem}
\RequirePackage{fancyhdr}
\RequirePackage{afterpage}
\RequirePackage{datenumber}
\RequirePackage{etoolbox}
\RequirePackage{appendix}
\RequirePackage[titles]{tocloft}
\RequirePackage{xstring}
\RequirePackage{perpage}
%    \end{macrocode}
%
% \section{Variables Setting}
% \begin{macro}{\zhtitle,\entitle,\title}
% Commands to set the title.
%    \begin{macrocode}
\def\zhtitle#1{\gdef\HUST@zhtitle{#1}\hypersetup{pdftitle={#1}}}
\def\entitle#1{\gdef\HUST@entitle{#1}}
\DeclareDocumentCommand\title{m g}
{
  \IfNoValueTF{#2}{
    \zhtitle{#1}\entitle{#1}
  }{
    \zhtitle{#1}\entitle{#2}
  }
}
\title{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhauthor,\enauthor,\author}
% Commands to set the author.
%    \begin{macrocode}
\def\zhauthor#1{\gdef\HUST@zhauthor{#1}\hypersetup{pdfauthor={#1}}}
\def\enauthor#1{\gdef\HUST@enauthor{#1}}
\DeclareDocumentCommand\author{m g}
{
  \IfNoValueTF{#2}{
    \zhauthor{#1}\enauthor{#1}
  }{
    \zhauthor{#1}\enauthor{#2}
  }
}
\author{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\date,\zhdateformat,\endateformat,\dateformat}
% A command to set the date and several commands to display date.
%    \begin{macrocode}
\def\date#1#2#3{
  \setdate{#1}{#2}{#3}
}
\setdatetoday
\def\zhdateformat{~\thedateyear~年~\thedatemonth~月~\thedateday~日}
\def\endateformat{\datedate}
\ifthenelse{\equal{\HUST@language}{chinese}}{
  \let\dateformat\zhdateformat
}{
  \let\dateformat\endateformat
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhschoolname,\enschoolname,\schoolname}
% Commands to set the school name.
%    \begin{macrocode}
\def\zhschoolname#1{\gdef\HUST@zhschoolname{#1}}
\def\enschoolname#1{\gdef\HUST@enschoolname{#1}}
\DeclareDocumentCommand\schoolname{m g}
{
  \IfNoValueTF{#2}{
    \zhschoolname{#1}\enschoolname{#1}
  }{
    \zhschoolname{#1}\enschoolname{#2}
  }
}
\schoolname{华中科技大学}{Huazhong University of Science~\char38~Technology}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhaddress,\enaddress,\address}
% Commands to set the address.
%    \begin{macrocode}
\def\zhaddress#1{\gdef\HUST@zhaddress{#1}}
\def\enaddress#1{\gdef\HUST@enaddress{#1}}
\DeclareDocumentCommand\address{m g}
{
  \IfNoValueTF{#2}{
    \zhaddress{#1}\enaddress{#1}
  }{
    \zhaddress{#1}\enaddress{#2}
  }
}
\address{中国，武汉，430074}{Wuhan~430074, P.~R.~China}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhapplyname,\enapplyname,\applyname}
% Commands to custom apply name.
%    \begin{macrocode}
\def\zhapplyname#1{\def\HUST@zhapplyname{#1}}
\def\enapplyname#1{\def\HUST@enapplyname{#1}}
\DeclareDocumentCommand\applyname{m g}
{
  \IfNoValueTF{#2}{
    \enapplyname{#1}
  }{
    \zhapplyname{#1}\enapplyname{#2}
  }
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhmajor,\enmajor,\major}
% Commands to set the major.
%    \begin{macrocode}
\def\zhmajor#1{\gdef\HUST@zhmajor{#1}}
\def\enmajor#1{\gdef\HUST@enmajor{#1}}
\DeclareDocumentCommand\major{m g}
{
  \IfNoValueTF{#2}{
    \zhmajor{#1}\enmajor{#1}
  }{
    \zhmajor{#1}\enmajor{#2}
  }
}
\major{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhsupervisor,\ensupervisor,\supervisor}
% Commands to set the supervisor.
%    \begin{macrocode}
\def\zhsupervisor#1{\gdef\HUST@zhsupervisor{#1}}
\def\ensupervisor#1{\gdef\HUST@ensupervisor{#1}}
\DeclareDocumentCommand\supervisor{m g}
{
  \IfNoValueTF{#2}{
    \zhsupervisor{#1}\ensupervisor{#1}
  }{
    \zhsupervisor{#1}\ensupervisor{#2}
  }
}
\supervisor{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhasssupervisor,\enasssupervisor,\asssupervisor}
% Commands to set the asssupervisor.
%    \begin{macrocode}
\def\zhasssupervisor#1{\gdef\HUST@zhasssupervisor{#1}}
\def\enasssupervisor#1{\gdef\HUST@enasssupervisor{#1}}
\DeclareDocumentCommand\asssupervisor{m g}
{
  \IfNoValueTF{#2}{
    \zhasssupervisor{#1}\enasssupervisor{#1}
  }{
    \zhasssupervisor{#1}\enasssupervisor{#2}
  }
}
\asssupervisor{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\schoolcode}
% A command to set school code.
%    \begin{macrocode}
\def\schoolcode#1{\gdef\HUST@schoolcode{#1}}
\schoolcode{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\stuno}
% A command to set student number.
%    \begin{macrocode}
\def\stuno#1{\gdef\HUST@stuno{#1}}
\stuno{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\classno}
% A command to set classification number.
%    \begin{macrocode}
\def\classno#1{\gdef\HUST@classno{#1}}
\classno{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\secretlevel}
% A command to set secret level.
%    \begin{macrocode}
\def\secretlevel#1{\gdef\HUST@secretlevel{#1}}
\secretlevel{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhabstract,\enabstract,\abstract}
% Commands to set the abstract.
%    \begin{macrocode}
\long\def\zhabstract#1{\long\gdef\HUST@zhabstract{#1}}
\long\def\enabstract#1{\long\gdef\HUST@enabstract{#1}}
\DeclareDocumentCommand\abstract{+m +g}
{
  \IfNoValueTF{#2}{
    \zhabstract{#1}\enabstract{#1}
  }{
    \zhabstract{#1}\enabstract{#2}
  }
}
\abstract{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhkeywords,\enkeywords,\keywords}
% Commands to set the keywords.
%    \begin{macrocode}
\def\zhkeywords#1{\gdef\HUST@zhkeywords{#1}\hypersetup{pdfkeywords={#1}}}
\def\enkeywords#1{\gdef\HUST@enkeywords{#1}}
\DeclareDocumentCommand\keywords{m g}
{
  \IfNoValueTF{#2}{
    \zhkeywords{#1}\enkeywords{#1}
  }{
    \zhkeywords{#1}\enkeywords{#2}
  }
}
\keywords{}{}
%    \end{macrocode}
% \end{macro}
%
% \section{Localization}\label{sec:Localization}
% Chinese localization.
% \footnote{The |autorefname| Reference:\url{http://tex.stackexchange.com/questions/52410/how-to-use-the-command-autoref-to-implement-the-same-effect-when-use-the-comman}}
%    \begin{macrocode}
\ifthenelse{\equal{\HUST@language}{chinese}}{
    \def\indexname{索引}
    \def\figurename{图}
    \def\tablename{表}
    \AtBeginDocument{\def\listingscaption{代码}}
    \def\bibname{参考文献}
    \def\contentsname{目\hspace{1em}录}
    \def\contentsnamenospace{目录}
    \def\appendixname{附录}
    \def\HUST@listfigurename{插图索引}
    \def\HUST@listtablename{表格索引}
    \def\equationautorefname{公式}
    \def\footnoteautorefname{脚注}
    \def\itemautorefname~#1\null{第~#1~项\null}
    \def\figureautorefname{图}
    \def\tableautorefname{表}
    \def\appendixautorefname{附录}
    \expandafter\def\csname\appendixname autorefname\endcsname{\appendixname}
    \def\chapterautorefname~#1\null{第\zhnumber{#1}章\null}
    \def\sectionautorefname~#1\null{#1~小节\null}
    \def\subsectionautorefname~#1\null{#1~小节\null}
    \def\subsubsectionautorefname~#1\null{#1~小节\null}
    \def\FancyVerbLineautorefname~#1\null{第~#1~行\null}
    \def\pageautorefname~#1\null{第~#1~页\null}
    \def\lstlistingautorefname{代码}
    \def\definitionautorefname{定义}
    \def\propositionautorefname{命题}
    \def\lemmaautorefname{引理}
    \def\theoremautorefname{定理}
    \def\axiomautorefname{公理}
    \def\corollaryautorefname{推论}
    \def\exerciseautorefname{练习}
    \def\exampleautorefname{例}
    \def\proofautorefname{证明}
    \SetAlgorithmName{算法}{算法}{算法索引}
    \SetAlgoProcName{过程}{过程}
    \SetAlgoFuncName{函数}{函数}
    \def\AlgoLineautorefname~#1\null{第~#1~行\null}
}{}
%    \end{macrocode}
%
% English localization.
%    \begin{macrocode}
\ifthenelse{\equal{\HUST@language}{chinese}}{}{
    \def\HUST@listfigurename{List of Figures}
    \def\HUST@listtablename{List of Tables}
    \def\equationautorefname{Equation}
    \def\footnoteautorefname{Footnote}
    \def\itemautorefname{Item}
    \def\figureautorefname{Figure}
    \def\tableautorefname{Table}
    \def\appendixautorefname{Appendix}
    \expandafter\def\csname\appendixname autorefname\endcsname{\appendixname}
    \def\chapterautorefname{Chapter}
    \def\sectionautorefname{Section}
    \def\subsectionautorefname{Subsection}
    \def\subsubsectionautorefname{Sub-subsection}
    \def\FancyVerbLineautorefname{Line}
    \def\pageautorefname{Page}
    \def\lstlistingautorefname{Code Fragment}
    \def\definitionautorefname{Definition}
    \def\propositionautorefname{Proposition}
    \def\lemmaautorefname{Lemma}
    \def\theoremautorefname{Theorem}
    \def\axiomautorefname{Axiom}
    \def\corollaryautorefname{Corollary}
    \def\exerciseautorefname{Exercise}
    \def\exampleautorefname{Example}
    \def\proofautorefname{Proof}
    \SetAlgorithmName{Algorithm}{Algorithm}{List of Algorithms}
    \SetAlgoProcName{Procedure}{Procedure}
    \SetAlgoFuncName{Function}{Function}
    \def\AlgoLineautorefname{Line}
}
%    \end{macrocode}
%
% Internal variables.
%    \begin{macrocode}
\def\HUST@classnotitle{{分}\hfill{类}\hfill{号}}
\def\HUST@stunotitle{学号}
\def\HUST@schoolcodetitle{学校代码}
\def\HUST@secrettile{密级}
\def\HUST@zhauthortitle{{学}\hfill{位}\hfill{申}\hfill{请}\hfill{人}}
\def\HUST@zhmajortitle{{学}\hfill{科}\hfill{专}\hfill{业}}
\def\HUST@zhsupervisortitle{{指}\hfill{导}\hfill{教}\hfill{师}}
\def\HUST@zhasssupervisortitle{{副}\hfill{指}\hfill{导}\hfill{教}\hfill{师}}
\def\HUST@zhdatetitle{{答}\hfill{辩}\hfill{日}\hfill{期}}

\def\HUST@enauthortitle{Student}
\def\HUST@enmajortitle{Major}
\def\HUST@ensupervisortitle{Supervisor}
\def\HUST@enasssupervisortitle{Co-Supervisor}

\def\HUST@originaldeclare{独创性声明}
\long\def\HUST@originaldeclaretext{
  本人声明所呈交的学位论文是我个人在导师的指导下进行的研究工作及取得的研究成果。尽我所知，除文中已标明引用的内容外，本论文不包含任何其他人或集体已经发表或撰写过的研究成果。对本文的研究做出贡献的个人和集体，均已在文中以明确方式标明。本人完全意识到本声明的法律结果由本人承担。
}
\def\HUST@zhauthorsig{学位论文作者签名：}
\def\HUST@zhdatefield{日期：\hspace{2em}年\hspace{2em}月\hspace{2em}日}

\def\HUST@authtitle{学位论文版权使用授权书}
\long\def\HUST@authorizationtext{
  本学位论文作者完全了解学校有关保留、使用学位论文的规定，即：学校有权保留并向国家有关部门或机构送交论文的复印件和电子版，允许论文被查阅和借阅。本人授权华中科技大学可以将本学位论文的全部或部分内容编入有关数据库进行检索，可以采用影印、缩印或扫描等复制手段保存和汇编本学位论文。
}
\long\def\HUST@authorizationaddon{
 本论文属于
 \tabincell{l}{
  保密$\square$，在~\makebox[2em]{\hrulefill} 年解密后适用本授权书。\\
  不保密~$\square$。
 }
}
\def\HUST@authorizationcheck{（请在以上方框内打“$\surd$”）}
\def\HUST@zhteachersig{指导教师签名：}

\def\HUST@zhabstractname{摘\hspace{1em}要}
\def\HUST@zhabstractnamenospace{摘要}
\def\HUST@zhkeywordstitle{关键词：}
\def\HUST@enabstractname{Abstract}
\def\HUST@enkeywordstitle{Key words:}

\ifthenelse{\equal{\HUST@language}{chinese}}{
  \def\HUST@ackname{致\hspace{1em}谢}
  \def\HUST@acknamenospace{致谢}
  \def\HUST@publicationtitle{攻读学位期间发表的学术论文}
}{
  \def\HUST@ackname{Acknowledge}
  \def\HUST@acknamenospace{Acknowledge}
  \def\HUST@publicationtitle{Publication}
}

\ifthenelse{\equal{\HUST@degree}{none}}{
  \def\HUST@zhapplyname{学位论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree}
}{}

\ifthenelse{\equal{\HUST@degree}{fyp}}{
  \def\HUST@zhapplyname{毕业设计论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for Final Year Project}
}{}

\ifthenelse{\equal{\HUST@degree}{bachelor}}{
  \def\HUST@zhapplyname{学士学位论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Bachelor}
}{}

\ifthenelse{\equal{\HUST@degree}{master}}{
  \def\HUST@zhapplyname{硕士学位论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Master}
}{}

\ifthenelse{\equal{\HUST@degree}{phd}}{
  \def\HUST@zhapplyname{博士学位论文}
  \def\HUST@enapplyname{A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Philosophy}
}{}

\ifthenelse{\equal{\HUST@language}{chinese}}{
  \hypersetup{pdfsubject={\HUST@zhschoolname\HUST@zhapplyname}}
}{
  \hypersetup{pdfsubject={\HUST@enapplyname}}
}
%    \end{macrocode}
%
% Set |\listfigurename| and |\listtablename|.
%    \begin{macrocode}
\def\listfigurename{\HUST@listfigurename}
\def\listtablename{\HUST@listtablename}
%    \end{macrocode}
%
% \section{Style Setting}
% \subsection{Equation Style}
% Allow long equation breaking between lines or pages.
%    \begin{macrocode}
\allowdisplaybreaks[4]
%    \end{macrocode}
%
% Set skip between equation and context.
%    \begin{macrocode}
\abovedisplayskip=10bp plus 2bp minus 2bp
\abovedisplayshortskip=10bp plus 2bp minus 2bp
\belowdisplayskip=\abovedisplayskip
\belowdisplayshortskip=\abovedisplayshortskip
%    \end{macrocode}
%
% Set equation numbering style.
%    \begin{macrocode}
\numberwithin{equation}{chapter}
%    \end{macrocode}
%
% \subsection{Theorem Style}
% We use \pkgurl{amsthm} to handle the proof environment and use \pkgurl{ntheorem} to handle other theorem environments.
%    \begin{macrocode}
\theoremnumbering{arabic}
\ifthenelse{\equal{\HUST@language}{chinese}}{
  \theoremseparator{：}
}{
  \theoremseparator{:}
}
\theorempreskip{1.2ex plus 0ex minus 1ex}
\theorempostskip{1.2ex plus 0ex minus 1ex}
\theoremheaderfont{\normalfont\bfseries\HEI}
\theoremsymbol{}

\theoremstyle{definition}
\theorembodyfont{\normalfont}
\ifthenelse{\equal{\HUST@language}{chinese}}{
  \newtheorem{definition}{定义}[chapter]
}{
  \newtheorem{definition}{Definition}[chapter]
}

\theoremstyle{plain}
\theorembodyfont{\itshape}
\ifthenelse{\equal{\HUST@language}{chinese}}{
  \newtheorem{proposition}{命题}[chapter]
  \newtheorem{lemma}{引理}[chapter]
  \newtheorem{theorem}{定理}[chapter]
  \newtheorem{axiom}{公理}[chapter]
  \newtheorem{corollary}{推论}[chapter]
  \newtheorem{exercise}{练习}[chapter]
  \newtheorem{example}{例}[chapter]
  \def\proofname{\hei{证明}}
}{
  \newtheorem{proposition}{Proposition}[chapter]
  \newtheorem{lemma}{Lemma}[chapter]
  \newtheorem{theorem}{Theorem}[chapter]
  \newtheorem{axiom}{Axiom}[chapter]
  \newtheorem{corollary}{Corollary}[chapter]
  \newtheorem{exercise}{Exercise}[chapter]
  \newtheorem{example}{Example}[chapter]
  \def\proofname{\textbf{Proof}}
}
%    \end{macrocode}
%
% \subsection{Floating Objects Style}
% Set the skip to the context for floating object with argument `h'.
%    \begin{macrocode}
\setlength{\intextsep}{0.7\baselineskip plus 0.1\baselineskip minus 0.1\baselineskip}
%    \end{macrocode}
%
% Set the skip to the context for top or bottom floating object.
%    \begin{macrocode}
\setlength{\textfloatsep}{0.8\baselineskip plus 0.1\baselineskip minus 0.2\baselineskip}
%    \end{macrocode}
%
% Set the fraction of floating object. Make the fraction less crowded than default value to prevent floating object occupying too much space.
%    \begin{macrocode}
\renewcommand{\textfraction}{0.15}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.60}
%    \end{macrocode}
%
% \subsection{Table Style}
%
% \begin{macro}{\tabincell}
% A command make it easier to insert a new table into an existing cell.
%    \begin{macrocode}
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
%    \end{macrocode}
% \end{macro}
%
% To prevent |\cline| breaking page in \pkgurl{longtable} environment, use in this way:
% \meta{table content} |\\* \nopagebreak \cline{i-j}|
% \footnote{Reference:\url{http://tex.stackexchange.com/questions/52100/longtable-multirow-problem-with-cline-and-nopagebreak}}
%    \begin{macrocode}
\def\@cline#1-#2\@nil{%
  \omit
  \@multicnt#1%
  \advance\@multispan\m@ne
  \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
  \@multicnt#2%
  \advance\@multicnt-#1%
  \advance\@multispan\@ne
  \leaders\hrule\@height\arrayrulewidth\hfill
  \cr
  \noalign{\nobreak\vskip-\arrayrulewidth}}
%    \end{macrocode}
%
% Here we set the global font setting (font size: 11pt and line spread: 1.4) for tables. But first we will declare a variable to determine whether table global font setting is activated.
%    \begin{macrocode}
\newif\ifHUST@useoldtabular
\HUST@useoldtabularfalse
%    \end{macrocode}
%
% \begin{macro}{\TurnOffTabFontSetting}
% Use |\TurnOffTabFontSetting| to deactivate global font setting.
%    \begin{macrocode}
\def\TurnOffTabFontSetting{\HUST@useoldtabulartrue}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TurnOnTabFontSetting}
% Use |\TurnOnTabFontSetting| to activate global font setting.
%    \begin{macrocode}
\def\TurnOnTabFontSetting{\HUST@useoldtabularfalse}
%    \end{macrocode}
% \end{macro}
%
% Hook the \pkgurl{tabular}, \pkgurl{tabularx} and \pkgurl{longtable} environment to imply the global font setting.
%    \begin{macrocode}
\AtBeginEnvironment{tabular}{
  \ifHUST@useoldtabular\else
    \fontsize{11pt}{15.4pt}\selectfont
  \fi
}
\AtBeginEnvironment{tabularx}{
  \ifHUST@useoldtabular\else
    \fontsize{11pt}{15.4pt}\selectfont
  \fi
}
\AtBeginEnvironment{longtable}{
  \ifHUST@useoldtabular\else
    \fontsize{11pt}{15.4pt}\selectfont
  \fi
}
%    \end{macrocode}
%
% \subsection{Caption Style}
% Set caption font size as 11pt, use hang format, remove `:' after number and set the skip between context as 12pt.
%    \begin{macrocode}
\DeclareCaptionFont{HUST@captionfont}{\fontsize{11pt}{14.3pt}\selectfont}
\DeclareCaptionLabelFormat{HUST@caplabel}{#1~#2}
\captionsetup{
  font=HUST@captionfont,
  labelformat=HUST@caplabel,
  format=hang,
  labelsep=quad,
  skip=12pt
}
%    \end{macrocode}
%
% Set figure and table numbering style.
%    \begin{macrocode}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand{\thefigure}{\arabic{chapter}-\arabic{figure}}
%    \end{macrocode}
%
% \subsection{Code Highlight Style}
%    \begin{macrocode}
\definecolor{HUST@lstgreen}{rgb}{0,0.6,0}
\definecolor{HUST@lstmauve}{rgb}{0.58,0,0.82}

\lstset{
  basicstyle=\footnotesize\ttfamily\linespread{1}\selectfont\FANGSONG,
  keywordstyle=\color{blue}\bfseries,
  commentstyle=\color{HUST@lstgreen}\itshape\KAI,
  stringstyle=\color{HUST@lstmauve},
  showspaces=false,
  showstringspaces=false,
  showtabs=false,
  numbers=left,
  numberstyle=\tiny\color{black},
  frame=lines,
  rulecolor=\color{black},
  breaklines=true
}
%    \end{macrocode}
%
% \subsection{Section Title Style}
% Set the numbering depth for section.
%    \begin{macrocode}
\setcounter{secnumdepth}{3}
%    \end{macrocode}
%
% Chapter tilte format and spacing setting.
%    \begin{macrocode}
\titleformat{\chapter}
  {
    \bfseries
    \HEI
    \centering
    \fontsize{18pt}{23.4pt}\selectfont
  }
  {
    \ifthenelse{\equal{\HUST@language}{chinese}}
    {\zhnumber{\thechapter}}
    {Chapter~\thechapter}
  }
  {1em}
  {}
\titlespacing*{\chapter}{0pt}{0pt}{20pt}
%    \end{macrocode}
%
% Section tilte format and spacing setting.
%    \begin{macrocode}
\titleformat*{\section}{\bfseries\HEI\fontsize{16pt}{20.8pt}\selectfont}
\titlespacing*{\section}{0pt}{18pt}{6pt}
%    \end{macrocode}
%
% Subsection tilte format and spacing setting.
%    \begin{macrocode}
\titleformat*{\subsection}{\bfseries\HEI\fontsize{14pt}{18.2pt}\selectfont}
\titlespacing*{\subsection}{0pt}{12pt}{6pt}
%    \end{macrocode}
%
% Subsubsection tilte format and spacing setting.
%    \begin{macrocode}
\titleformat*{\subsubsection}{\bfseries\HEI\fontsize{13pt}{16.9pt}\selectfont}
\titlespacing*{\subsubsection}{0pt}{12pt}{6pt}
%    \end{macrocode}
%
% \subsection{TOC Style}
% TOC depth.
%    \begin{macrocode}
\setcounter{tocdepth}{1}
%    \end{macrocode}
%
% TOC right margin.
%    \begin{macrocode}
\contentsmargin{2.0em}
%    \end{macrocode}
%
% Remove vertical space between two continues chapter entries.
% \footnote{Reference:\url{http://tex.stackexchange.com/questions/89103/remove-vertical-space-between-two-chapters-in-table-of-contents-in-latex}}
%    \begin{macrocode}
\newskip\HUST@oldcftbeforechapskip
\HUST@oldcftbeforechapskip=\cftbeforechapskip
\newskip\HUST@oldcftbeforesecskip
\HUST@oldcftbeforesecskip=\cftbeforesecskip
\let\HUST@oldl@chapter\l@chapter
\let\HUST@oldl@section\l@section
\let\HUST@oldl@subsection\l@subsection
\def\l@chapter#1#2{\HUST@oldl@chapter{#1}{#2}\cftbeforechapskip=3pt}
\def\l@section#1#2{\HUST@oldl@section{#1}{#2}\cftbeforechapskip=\HUST@oldcftbeforechapskip\cftbeforesecskip=3pt}
\def\l@subsection#1#2{\HUST@oldl@subsection{#1}{#2}\cftbeforesecskip=\HUST@oldcftbeforesecskip}
%    \end{macrocode}
%
% Set LOF LOT style.
% \footnote{Reference:\url{http://www.latex-community.org/viewtopic.php?f=5&t=1838}}
%    \begin{macrocode}
\renewcommand*\cftfigpresnum{\figurename~}
\newlength{\HUST@cftfignumwidth@tmp}
\settowidth{\HUST@cftfignumwidth@tmp}{\cftfigpresnum}
\addtolength{\cftfignumwidth}{\HUST@cftfignumwidth@tmp}
\renewcommand{\cftfigaftersnumb}{\quad~}
\renewcommand*\cfttabpresnum{\tablename~}
\newlength{\HUST@cfttabnumwidth@tmp}
\settowidth{\HUST@cfttabnumwidth@tmp}{\cfttabpresnum}
\addtolength{\cfttabnumwidth}{\HUST@cfttabnumwidth@tmp}
\renewcommand{\cfttabaftersnumb}{\quad~}
%    \end{macrocode}
%
% \subsection{Head \& Foot Style}
%    \begin{macrocode}
\let\ps@plain\ps@fancy
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\ifthenelse{\equal{\HUST@degree}{fyp}}{
  \fancyfoot[R]{\thepage}
}{
  \fancyfoot[C]{\thepage}
}

\ifthenelse{\equal{\HUST@language}{english-draft}}{}{
  \ifHUST@finalformat\else
    \fancyhead[C]{
      \ziju{1em}{\kai{\fontsize{14pt}{18.2pt}\selectfont\HUST@zhschoolname\HUST@zhapplyname}}
      \vskip -5pt
      \vbox{
        \hrule width \textwidth height 2pt
      }
    }
  \fi
}
%    \end{macrocode}
%
% \subsection{List Environment Style}
%    \begin{macrocode}
\setlist{noitemsep,partopsep=0pt,topsep=.8ex}
\setlist[1]{labelindent=\parindent}
\setlist[enumerate,1]{label=\arabic*.,ref=\arabic*}
\setlist[enumerate,2]{label*=\arabic*,ref=\theenumi.\arabic*}
\setlist[enumerate,3]{label=\emph{\alph*}),ref=\theenumii\emph{\alph*}}
\setlist[description]{font=\bfseries\HEI}
%    \end{macrocode}
%
% \subsection{Footnote Style}
%    \begin{macrocode}
\MakePerPage{footnote}
%    \end{macrocode}
%
% \section{Specical Page}
% \begin{macro}{\frontmatter,\mainmatter,\backmatter}
%    \begin{macrocode}
\def\frontmatter{
  \clearpage
  \@mainmatterfalse
  \pagenumbering{Roman}
}
\def\mainmatter{
  \clearpage
  \@mainmattertrue
  \pagenumbering{arabic}
}
\def\backmatter{
  \clearpage
  \@mainmatterfalse
  \settocdepth{chapter}
  \hypersetup{bookmarksopenlevel=0}
}
%    \end{macrocode}
% \end{macro}
%
% Chinese title page.
%    \begin{macrocode}
\def\HUST@zhtitlepage{
  \begin{center}
  \vspace*{-1.0cm}
  \parbox[t][2.2cm][t]{\textwidth}{
    \begin{center}
      \setlength{\tabcolsep}{0pt}
      \setlength{\extrarowheight}{12pt}
      \TurnOffTabFontSetting
      \fontsize{14pt}{16.8pt}\selectfont
      \begin{tabularx}{\textwidth}{p{4em}p{5em}Xp{2em}p{12em}}
        \HUST@classnotitle    & \makebox[5em][l]{\rule[-2.0pt]{5em}{1pt}\hspace{-5em}\hfill\texttt{\HUST@classno}\hfill} & &
        \HUST@stunotitle      & \makebox[12em][l]{\rule[-2.0pt]{12em}{1pt}\hspace{-12em}\hfill\texttt{\HUST@stuno}\hfill} \\
        \HUST@schoolcodetitle & \makebox[5em][l]{\rule[-2.0pt]{5em}{1pt}\hspace{-5em}\hfill\texttt{\HUST@schoolcode}\hfill} & &
        \HUST@secrettile      & \makebox[12em][l]{\rule[-2.0pt]{12em}{1pt}\hspace{-12em}\hfill\texttt{\HUST@secretlevel}\hfill}
      \end{tabularx}
      \TurnOnTabFontSetting
    \end{center}
    }
  \parbox[t][6cm][t]{\textwidth}{
    \vspace{1.0cm}
    \begin{center}
    \includegraphics[scale=1.1]{hust-title.pdf}\\[0.8cm]
    \ziju{10bp}{\fontsize{42pt}{54.6pt}\selectfont\HEI\HUST@zhapplyname}
    \end{center}
  }
  \parbox[t][4.8cm][t]{.8\textwidth}{
    \vspace{1.4cm}
    \begin{center}
    \fontsize{22pt}{35.2pt}\selectfont\hei{\HUST@zhtitle}
    \end{center}
  }
  \parbox[t][7.4cm][t]{\textwidth}{
    \vspace{1.2cm}
    \begin{center}
    \fontsize{18pt}{27.0pt}\selectfont
    \setlength{\extrarowheight}{0pt}
    \TurnOffTabFontSetting
    \begin{tabular}{p{5em}@{{：\hspace{1em}}}l}
    \HUST@zhauthortitle       & {\HUST@zhauthor} \\
    \HUST@zhmajortitle      & {\HUST@zhmajor} \\
    \HUST@zhsupervisortitle & {\HUST@zhsupervisor} \\
    \ifthenelse{\equal{\HUST@zhasssupervisor}{}}{}{
      \HUST@zhasssupervisortitle & {\HUST@zhasssupervisor} \\
    }
    \HUST@zhdatetitle & \zhdateformat
    \end{tabular}
    \TurnOnTabFontSetting
    \end{center}
  }
  \end{center}
}
%    \end{macrocode}
%
% English title page.
%    \begin{macrocode}
\def\HUST@entitlepage{
  \begin{center}
    \parbox[t][4.5cm][t]{.9\textwidth}{
      \begin{center}
        \fontsize{16pt}{17.6pt}\selectfont
        \HUST@enapplyname
      \end{center}
    }
    \parbox[t][5.7cm][t]{\textwidth}{
      \begin{center}
        \fontsize{18pt}{23.4pt}\selectfont
        \textbf{\textsf{\HUST@entitle}}
      \end{center}
    }
    \parbox[t][5cm][t]{.8\textwidth}{
      \begin{center}
      \setlength{\extrarowheight}{5pt}
      \fontsize{16pt}{24.0pt}\selectfont
      \TurnOffTabFontSetting
      \begin{tabular}{l@{~:~}p{18em}}
        \HUST@enauthortitle     & {\HUST@enauthor} \\
        \HUST@enmajortitle      & {\HUST@enmajor} \\
        \HUST@ensupervisortitle & {\HUST@ensupervisor}
        \ifthenelse{\equal{\HUST@enasssupervisor}{}}{}{
          \\ \HUST@enasssupervisortitle & {\HUST@enasssupervisor}
        }
      \end{tabular}
      \TurnOnTabFontSetting
      \end{center}
    }
    \parbox[t][7cm][b]{.8\textwidth}{
      \begin{center}
      \bfseries
      \fontsize{14pt}{28.0pt}\selectfont
      \HUST@enschoolname \\
      \HUST@enaddress \\
      \endateformat
    \end{center}
    }
  \end{center}
}
%    \end{macrocode}
%
% Copyright page.
%    \begin{macrocode}
\def\HUST@authorization{
  \centerline{\fontsize{16pt}{20.8pt}\selectfont \HEI \HUST@originaldeclare}
  \vspace{1cm}
  {
    \fontsize{12pt}{24.0pt}\selectfont
    \indent\HUST@originaldeclaretext
  }
  \\[1.9cm]
  \parbox[t]{\textwidth}{
    \fontsize{12pt}{18.0pt}\selectfont
    \TurnOffTabFontSetting
    \hfill\begin{tabular}{ll}
        \HUST@zhauthorsig & \hspace{2em}\\
        \HUST@zhdatefield & \hspace{2em}\\
    \end{tabular}
    \TurnOnTabFontSetting
  }
  \\[1.9cm]
  \centerline{\fontsize{16pt}{20.8pt}\selectfont \HEI \HUST@authtitle}
  \\[1cm]
  {
    \fontsize{12pt}{24.0pt}\selectfont
    \indent\HUST@authorizationtext \\
    \indent\HUST@authorizationaddon \\
    \indent\HUST@authorizationcheck
  }
  \\[1.9cm]
  \hspace{2em}\parbox[t]{.9\textwidth}{
    \fontsize{12pt}{18.0pt}\selectfont
    \TurnOffTabFontSetting
    \begin{tabular}{ll}
        \HUST@zhauthorsig & \hspace{2em}\\
        \HUST@zhdatefield & \hspace{2em}\\
    \end{tabular}
    \hfill
    \begin{tabular}{ll}
        \HUST@zhteachersig & \hspace{2em}\\
        \HUST@zhdatefield & \hspace{2em}\\
    \end{tabular}
    \TurnOnTabFontSetting
  }
  \vfill
}
%    \end{macrocode}
%
% \begin{macro}{\maketitle,\makecover}
% Commands to generate title page.
%    \begin{macrocode}
\def\maketitle{
  \newgeometry{
    top=1.2in,
    bottom=1.2in,
    left=1in,
    right=1in,
  }
  \let\HUST@oldthepage\thepage
  \ifthenelse{\equal{\HUST@language}{english-draft}}
  {\def\thepage{Titlepage}}
  {\def\thepage{封面}}
  \begin{titlepage}
    \ifthenelse{\equal{\HUST@language}{english-draft}}{}{
      \thispagestyle{empty}
      \HUST@zhtitlepage
      \clearpage
    }
    \thispagestyle{empty}
    \HUST@entitlepage
  \end{titlepage}
  \ifthenelse{\equal{\HUST@language}{english-draft}}{}{
    \def\thepage{版权页}
    \thispagestyle{empty}
    \HUST@authorization
    \clearpage
  }
  \restoregeometry
  \let\thepage\HUST@oldthepage
  \setcounter{page}{1}
}
\let\makecover\maketitle
%    \end{macrocode}
% \end{macro}
%
% Chinese abstract page.
%    \begin{macrocode}
\def\HUST@zhabstractpage{
  \chapter*{\HUST@zhabstractname}
  \begingroup
  \fontsize{10.5pt}{13.7pt}\selectfont
  \HUST@zhabstract \par
  \vskip 1.2ex
  \noindent\hei{\HUST@zhkeywordstitle}\hspace{.8em} \HUST@zhkeywords
  \endgroup
}
%    \end{macrocode}
%
% English abstract page.
%    \begin{macrocode}
\def\HUST@enabstractpage{
  \chapter*{\textsf{\HUST@enabstractname}}
  \begingroup
  \fontsize{10.5pt}{13.7pt}\selectfont
  \HUST@enabstract \par
  \vskip 1.2ex
  \noindent\textbf{\HUST@enkeywordstitle}\hspace{.8em} \HUST@enkeywords
  \endgroup
}
%    \end{macrocode}
%
% \begin{macro}{\makeabstract}
% A command to generate abstract page.
%    \begin{macrocode}
\def\makeabstract{
  \phantomsection
  \ifthenelse{\equal{\HUST@language}{chinese}}{
    \addcontentsline{toc}{chapter}{\HUST@zhabstractnamenospace}
  }{
    \addcontentsline{toc}{chapter}{\HUST@enabstractname}
  }
  \ifthenelse{\equal{\HUST@language}{english-draft}}{}{
    \HUST@zhabstractpage
    \clearpage
  }
  \HUST@enabstractpage
  \clearpage
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tableofcontents}
% A command to generate table of contents.
%    \begin{macrocode}
\let\HUST@tableofcontents\tableofcontents
\def\tableofcontents{
  \ifthenelse{\equal{\HUST@language}{chinese}}{
    \pdfbookmark{\contentsnamenospace}{\contentsnamenospace}
  }{
    \pdfbookmark{\contentsname}{\contentsname}
  }
  \HUST@tableofcontents
  \clearpage
}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{ack}
% A command to generate acknowledge page.
%    \begin{macrocode}
\newenvironment{ack}{
  \clearpage
  \phantomsection
  \addcontentsline{toc}{chapter}{\HUST@acknamenospace}
  \chapter*{\HUST@ackname}
  \begingroup
  \fontsize{10.5pt}{13.7pt}\selectfont
}{
  \endgroup
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{publications}
% A command to generate publications page.
%    \begin{macrocode}
\newenvironment{publications}{
  \clearpage
  \ifHUST@inappendix
    \chapter{\HUST@publicationtitle}
  \else
    \phantomsection
    \addcontentsline{toc}{chapter}{\HUST@publicationtitle}
    \chapter*{\HUST@publicationtitle}
  \fi
  \begin{enumerate}[labelindent=0pt,label={[\arabic*]},itemsep=0.5ex]
  \fontsize{10.5pt}{10.5pt}\selectfont
}{
  \end{enumerate}
}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\bibliography}
% A command to generate bibliography page.
%    \begin{macrocode}
\bibliographystyle{hustthesis}
\let\HUST@bibliography\bibliography
\def\bibliography#1{
  \clearpage
  \phantomsection
  \addcontentsline{toc}{chapter}{\bibname}
  \begingroup
  \fontsize{10.5pt}{10.5pt}\selectfont
  \setlength\bibsep{0.5ex}
  \HUST@bibliography{#1}
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{appendix}
% The appendix environment.
%    \begin{macrocode}
\newif\ifHUST@inappendix
\HUST@inappendixfalse
\newif\ifHUST@appendix@resetmainmatter
\HUST@appendix@resetmainmatterfalse
\renewenvironment{appendix}{
  \if@mainmatter
    \HUST@appendix@resetmainmatterfalse
  \else
    \HUST@appendix@resetmainmattertrue
    \@mainmattertrue
  \fi
  \appendixtitletocon
  \appendices
  \titleformat{\chapter}
  {
    \bfseries\HEI
    \centering
    \fontsize{18pt}{23.4pt}\selectfont
  }
  {\appendixname\,\thechapter}
  {1em}
  {}
  \HUST@inappendixtrue
}{
  \endappendices
  \HUST@inappendixfalse
  \ifHUST@appendix@resetmainmatter
    \HUST@appendix@resetmainmatterfalse
    \@mainmatterfalse
  \else\fi
}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\listoffigures}
% A command to generate list of figures.
%    \begin{macrocode}
\let\HUST@listoffigures\listoffigures
\def\listoffigures{
  \clearpage
  \ifHUST@inappendix
    \addtocounter{chapter}{1}
    \def\listfigurename{\appendixname\,\thechapter\hspace{1em}\HUST@listfigurename}
  \else
    \def\listfigurename{\HUST@listfigurename}
  \fi
  \phantomsection
  \ifHUST@inappendix
    \addcontentsline{toc}{chapter}{\thechapter\hspace{1em}\HUST@listfigurename}
  \else
    \addcontentsline{toc}{chapter}{\listfigurename}
  \fi
  \HUST@listoffigures
  \def\listfigurename{\HUST@listfigurename}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listoftables}
% A command to generate list of tables.
%    \begin{macrocode}
\let\HUST@listoftables\listoftables
\def\listoftables{
  \clearpage
  \ifHUST@inappendix
    \addtocounter{chapter}{1}
    \def\listtablename{\appendixname\,\thechapter\hspace{1em}\HUST@listtablename}
  \else
    \def\listtablename{\HUST@listtablename}
  \fi
  \phantomsection
  \ifHUST@inappendix
    \addcontentsline{toc}{chapter}{\thechapter\hspace{1em}\HUST@listtablename}
  \else
    \addcontentsline{toc}{chapter}{\listtablename}
  \fi
  \HUST@listoftables
  \def\listtablename{\HUST@listtablename}
}
%    \end{macrocode}
% \end{macro}
%
% \section{Other Command}
% \begin{macro}{\email}
%    \begin{macrocode}
\def\email#1{
  \href{mailto:#1}{\texttt{#1}}
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%
% \Finale
%
% ^^A Other files
% \iffalse
%
%<*example-zh|example-en>
%<example-zh>\documentclass[format=draft,language=chinese,degree=bachelor]{hustthesis}
%<example-en>\documentclass[format=draft,language=english,degree=bachelor]{hustthesis}

\stuno{U2009xxxxx}
\schoolcode{10487}
%<example-zh>\title{\LaTeX 模板使用示例}{An Example of Using hustthesis \LaTeX{} Template}
%<example-en>\title{An Example of Using hustthesis \LaTeX{} Template}
\author
%<example-zh>{许铖}{Xu Cheng}
%<example-en>{}
\major
%<example-zh>{电子信息工程}{Electronic and Information Engineering}
%<example-en>{}
\supervisor
%<example-zh>{黑晓军\hspace{1em}副教授}{Ass. Prof. Xiaojun Hei}
%<example-en>{}
\date{2013}{7}{1}

%<*example-zh>
\zhabstract{
    这这是一个\LaTeX{}模板使用实例文件，该模板用于华中科技大学毕业设计、学士论文、硕士论文和博士论文写作中。

    该模板基于LPPL v1.3发行。

}
\zhkeywords{\LaTeX{}，华中科技大学，论文，模板}
%</example-zh>

%<example-zh>\enabstract
%<example-en>\abstract
{
    This is a \LaTeX{} template example file. This template is used in written thesis for Huazhong Univ. of Sci. \& Tech.

    This template is published under LPPL v1.3 License.

}
%<example-zh>\enkeywords
%<example-en>\keywords
{\LaTeX{}, Huazhong Univ. of Sci. \& Tech., Thesis, Template}

\begin{document}

\frontmatter
\maketitle
\makeabstract
\tableofcontents
\listoffigures
\listoftables
\mainmatter

%<*example-zh>
\chapter{基本格式测试}\label{chapter:1}

\section{第一层}\label{sec:1}
\subsection{第二层}\label{sec:2}
\subsubsection{第三层}\label{sec:3}
测试测试测试测试测试测试测试测试测试测试测试测试。
\footnote{\label{footnote:1}脚注}

\section{字体}

普通\textbf{粗体}\emph{斜体}

\hei{黑体}\kai{楷体}\fangsong{仿宋}

\section{公式}

单个公式，公式引用：\autoref{eq:1}。
\begin{equation}
 c^2 = a^2 + b^2 \label{eq:1}
\end{equation}

多个公式，公式引用：\autoref{eq:2}，\autoref{eq:3}。

\begin{subequations}
\begin{equation}
  F = ma \label{eq:2}
\end{equation}
\begin{equation}
  E = mc^2 \label{eq:3}
\end{equation}
\end{subequations}

\section{罗列环境}

\begin{enumerate}
    \item 第一层\label{item:1}
    \item 第一层
    \begin{enumerate}
        \item 第二层\label{item:2}
        \item 第二层
        \begin{enumerate}
            \item 第三层\label{item:3}
            \item 第三层
        \end{enumerate}
    \end{enumerate}
\end{enumerate}

\begin{description}
    \item[解释环境]  解释内容
\end{description}

\chapter{其他格式测试}

\section{代码环境}

\begin{lstlisting}[language=python]
import os

def main():
    '''
    doc here
    '''
    print 'hello, world' # Abc
    print 'hello, 中文' # 中文
\end{lstlisting}

\section{定律证明环境}

\begin{definition}\label{def:1}
这是一个定义。
\end{definition}
\begin{proposition}\label{proposition:1}
这是一个命题。
\end{proposition}
\begin{axiom}\label{axiom:1}
这是一个公理。
\end{axiom}
\begin{lemma}\label{lemma:1}
这是一个引理。
\end{lemma}
\begin{theorem}\label{theorem:1}
这是一个定理。
\end{theorem}
\begin{proof}\label{proof:1}
这是一个证明。
\end{proof}

\section{算法环境}

\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;\label{alg_line:1}
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}\label{alg:1}
\end{algorithm}

\section{表格}
表格见\autoref{tab:1}。

\begin{table}[!h]
\centering
\caption{一个表格}\label{tab:1}
\begin{tabular}{|c|c|}
\hline
a & b \\
\hline
c & d \\
\hline
\end{tabular}
\end{table}
\section{图片}
图片见\autoref{fig:1}。图片格式支持eps，png，pdf等。多个图片见\autoref{fig:2}，分开引用：\autoref{fig:2-1}，\autoref{fig:2-2}。

\begin{figure}[!h]
\centering
\includegraphics[width=.4\textwidth]{fig-example.pdf}
\caption{一个图片}\label{fig:1}
\end{figure}

\begin{figure}[!h]
\centering
  \begin{subfigure}[b]{0.3\textwidth}
  \includegraphics[width=\textwidth]{fig-example.pdf}
  \caption{图片1}\label{fig:2-1}
  \end{subfigure}
  ~
  \begin{subfigure}[b]{0.3\textwidth}
  \includegraphics[width=\textwidth]{fig-example.pdf}
  \caption{图片2}\label{fig:2-2}
  \end{subfigure}
\caption{多个图片}\label{fig:2}
\end{figure}

\section{参考文献示例}
这是一篇中文参考文献\cite{TEXGURU99}；这是一篇英文参考文献\cite{knuth}；同时引用\cite{TEXGURU99,knuth}。

\section[\textbackslash{}autoref 测试]{\texttt{\textbackslash{}autoref} 测试}

\begin{description}
  \item[公式] \autoref{eq:1}
  \item[脚注] \autoref{footnote:1}
  \item[项] \autoref{item:1},\autoref{item:2},\autoref{item:3}
  \item[图] \autoref{fig:1}
  \item[表] \autoref{tab:1}
  \item[附录] \autoref{appendix:1}
  \item[章] \autoref{chapter:1}
  \item[小节] \autoref{sec:1},\autoref{sec:2},\autoref{sec:3}
  \item[算法] \autoref{alg:1},\autoref{alg_line:1}
  \item[证明环境] \autoref{def:1},\autoref{proposition:1},\autoref{axiom:1},\autoref{lemma:1},\autoref{theorem:1},\autoref{proof:1}
\end{description}


\backmatter

\begin{ack}
致谢正文。
\end{ack}

\bibliography{ref-example}

\appendix

\begin{publications}
    \item 论文1
    \item 论文2
\end{publications}

\chapter{这是一个附录}\label{appendix:1}
附录正文。

%</example-zh>
%<*example-en>
\chapter{Simple Test}\label{chapter:1}

\section{Level 1}\label{sec:1}
\subsection{Level 2}\label{sec:2}
\subsubsection{Level 3}\label{sec:3}
Content
\footnote{\label{footnote:1}A footnote.}

\section{Font}

Normal \textbf{Bold} \emph{Italic} \textsf{Sans}

The quick brown fox jumps over the lazy dog.

\section{Equation}

Single equation, see \autoref{eq:1}.
\begin{equation}
  c^2 = a^2 + b^2 \label{eq:1}
\end{equation}

Multi-equations, see \autoref{eq:2} and \autoref{eq:3}.

\begin{subequations}
\begin{equation}
  F = ma \label{eq:2}
\end{equation}
\begin{equation}
  E = mc^2 \label{eq:3}
\end{equation}
\end{subequations}

\section{List Environment}

\begin{enumerate}
    \item Level 1\label{item:1}
    \item Level 1
    \begin{enumerate}
        \item Level 2\label{item:2}
        \item Level 2
        \begin{enumerate}
            \item Level 3\label{item:3}
            \item Level 3
        \end{enumerate}
    \end{enumerate}
\end{enumerate}

\begin{description}
    \item[Discription]  Content
\end{description}

\chapter{Other Test}

\section{Code Highlight}

\begin{lstlisting}[language=python]
import os

def main():
    '''
    doc here
    '''
    print 'hello, world' # Abc
\end{lstlisting}

\section{Theorem}

\begin{definition}\label{def:1}
This is a definition.
\end{definition}
\begin{proposition}\label{proposition:1}
This is a proposition.
\end{proposition}
\begin{axiom}\label{axiom:1}
This is an axiom.
\end{axiom}
\begin{lemma}\label{lemma:1}
This is a lemma.
\end{lemma}
\begin{theorem}\label{theorem:1}
This is a theorem.
\end{theorem}
\begin{proof}\label{proof:1}
This is a proof.
\end{proof}

\section{Algorithm}

\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;\label{alg_line:1}
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}\label{alg:1}
\end{algorithm}

\section{Table}
See \autoref{tab:1}.

\begin{table}[!h]
\centering
\caption{A table}\label{tab:1}
\begin{tabular}{|c|c|}
\hline
a & b \\
\hline
c & d \\
\hline
\end{tabular}
\end{table}

\section{Figure}
See \autoref{fig:1}.Figure supports format in eps, png, pdf and so on. Multi-figures, see \autoref{fig:2}. Reference separately: \autoref{fig:2-1}, \autoref{fig:2-2}.

\begin{figure}[!h]
\centering
\includegraphics[width=.4\textwidth]{fig-example.pdf}
\caption{A figure}\label{fig:1}
\end{figure}

\begin{figure}[!h]
\centering
  \begin{subfigure}[b]{0.3\textwidth}
  \includegraphics[width=\textwidth]{fig-example.pdf}
  \caption{Figure A}\label{fig:2-1}
  \end{subfigure}
  ~
  \begin{subfigure}[b]{0.3\textwidth}
  \includegraphics[width=\textwidth]{fig-example.pdf}
  \caption{Figure B}\label{fig:2-2}
  \end{subfigure}
\caption{Multi-figures}\label{fig:2}
\end{figure}

\section{Bibliography}
Cite one bib\cite{knuth}, cite two\cite{TEXGURU99,knuth}.

\section[\textbackslash{}autoref Test]{\texttt{\textbackslash{}autoref} Test}

\begin{description}
  \item[Equation] \autoref{eq:1}
  \item[Footnote] \autoref{footnote:1}
  \item[Item] \autoref{item:1},\autoref{item:2},\autoref{item:3}
  \item[Figure] \autoref{fig:1}
  \item[Table] \autoref{tab:1}
  \item[Appendix] \autoref{appendix:1}
  \item[Chapter] \autoref{chapter:1}
  \item[Section] \autoref{sec:1},\autoref{sec:2},\autoref{sec:3}
  \item[Algorithm] \autoref{alg:1},\autoref{alg_line:1}
  \item[Theorem] \autoref{def:1},\autoref{proposition:1},\autoref{axiom:1},\autoref{lemma:1},\autoref{theorem:1},\autoref{proof:1}
\end{description}

\backmatter

\begin{ack}
Acknowledge
\end{ack}

\bibliography{ref-example}

\appendix

\begin{publications}
    \item Thesis 1
    \item Thesis 2
\end{publications}

\chapter{This is an appendix}\label{appendix:1}
Content.

%</example-en>

\end{document}

%</example-zh|example-en>
%
%<*example-bib>
@BOOK{TEXGURU99,
  AUTHOR        = "{\TeX}Guru",
  TITLE         = "{\LaTeXe} Manual",
  YEAR          = "1999"
}

@BOOK{knuth,
  AUTHOR        = "{Donald E. Knuth}",
  TITLE         = "The \TeX{}book",
  publisher     = "Addison–Wesley Pub. Co.",
  address       = "MA",
  YEAR          = "1984"
}
%</example-bib>
%
%<*bst>
%<<BSTFILE

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% PREDEFINED STRING MACROS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MACRO {jan} {"January"}
MACRO {feb} {"February"}
MACRO {mar} {"March"}
MACRO {apr} {"April"}
MACRO {may} {"May"}
MACRO {jun} {"June"}
MACRO {jul} {"July"}
MACRO {aug} {"August"}
MACRO {sep} {"September"}
MACRO {oct} {"October"}
MACRO {nov} {"November"}
MACRO {dec} {"December"}


MACRO {IEEE_J_MTT} {"{IEEE} Trans. Microwave Theory Tech."}


%%%%%%%%%%%%%%%%%%
%% ENTRY FIELDS %%
%%%%%%%%%%%%%%%%%%

ENTRY
  { address
    author
    booktitle
    chapter
    edition
    editor
    howpublished
    institution
    journal
    key
    lang
    month
    note
    number
    organization
    pages
    publisher
    school
    series
    title
    type
    volume
    year
    url
    nationality
  }
  {}
  { label }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INTEGER VARIABLES, STRING VARIABLES and FUNCTIONS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

INTEGERS { output.state before.all mid.sentence after.sentence after.block }

INTEGERS { longest.label.width multiresult nameptr namesleft number.label numnames }



FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}

FUNCTION {and}
{   'skip$
    { pop$ #0 }
  if$
}

FUNCTION {or}
{   { pop$ #1 }
    'skip$
  if$
}

FUNCTION {is.num}
{ chr.to.int$
  duplicate$ "0" chr.to.int$ < not
  swap$ "9" chr.to.int$ > not and
}

FUNCTION {init.state.consts}
{ #0 'before.all :=
  #1 'mid.sentence :=
  #2 'after.sentence :=
  #3 'after.block :=
}

STRINGS { s t }

FUNCTION {output.nonnull}
{ 's :=
  output.state mid.sentence =
    { ", " * write$ }
    { output.state after.block =
    { add.period$ write$
      newline$
      "\newblock " write$
    }
    { output.state before.all =
        'write$
        { add.period$ " " * write$ }
      if$
    }
      if$
      mid.sentence 'output.state :=
    }
  if$
  s
}

STRINGS {z}
FUNCTION {remove.dots}
{ 'z :=
  ""
  { z empty$ not}
  { z #1 #1 substring$
    z #2 global.max$ substring$ 'z :=
    duplicate$ "." = 'pop$
      { * }
    if$
  }
  while$
  %z
}

FUNCTION {bibinfo.check}
{ swap$
  duplicate$ missing$
    {
      pop$ pop$
      ""
    }
    { duplicate$ empty$
        {
          swap$ pop$
        }
        { swap$
          pop$
        }
      if$
    }
  if$
}

FUNCTION {bibinfo.warn}
{ swap$
  duplicate$ missing$
    {
      swap$ "missing " swap$ * " in " * cite$ * warning$ pop$
      ""
    }
    { duplicate$ empty$
        {
          swap$ "empty " swap$ * " in " * cite$ * warning$
        }
        { swap$
          pop$
        }
      if$
    }
  if$
}

% IEEE separates large numbers with more than 4 digits into groups of
% three. IEEE uses a small space to separate these number groups.
% Typical applications include patent and page numbers.

% number of consecutive digits required to trigger the group separation.
FUNCTION {large.number.trigger}{ #5 }

% For numbers longer than the trigger, this is the blocksize of the groups.
% The blocksize must be less than the trigger threshold, and 2 * blocksize
% must be greater than the trigger threshold (can't do more than one
% separation on the initial trigger).
FUNCTION {large.number.blocksize}{ #3 }

% What is actually inserted between the number groups.
FUNCTION {large.number.separator}{ "\," }

% So as to save on integer variables by reusing existing ones, numnames
% holds the current number of consecutive digits read and nameptr holds
% the number that will trigger an inserted space.
FUNCTION {large.number.separate}
{ 't :=
  ""
  #0 'numnames :=
  large.number.trigger 'nameptr :=
  { t empty$ not }
  { t #-1 #1 substring$ is.num
      { numnames #1 + 'numnames := }
      { #0 'numnames :=
        large.number.trigger 'nameptr :=
      }
    if$
    t #-1 #1 substring$ swap$ *
    t #-2 global.max$ substring$ 't :=
    numnames nameptr =
      { duplicate$ #1 nameptr large.number.blocksize - substring$ swap$
        nameptr large.number.blocksize - #1 + global.max$ substring$
        large.number.separator swap$ * *
        nameptr large.number.blocksize - 'numnames :=
        large.number.blocksize #1 + 'nameptr :=
      }
      { skip$ }
    if$
  }
  while$
}

FUNCTION {format.note}
{
 note empty$
    { "" }
    { note #1 #1 substring$
      duplicate$ "{" =
        'skip$
        { output.state mid.sentence =
          { "l" }
          { "u" }
        if$
        change.case$
        }
      if$
      note #2 global.max$ substring$ * "note" bibinfo.check
    }
  if$
}

FUNCTION {output}
{ duplicate$ empty$
    'pop$
    'output.nonnull
  if$
}

FUNCTION {output.check}
{ 't :=
  duplicate$ empty$
    { pop$ "empty " t * " in " * cite$ * warning$ }
    'output.nonnull
  if$
}

FUNCTION {output.bibitem}
{ newline$
  "\bibitem{" write$
  cite$ write$
  "}" write$
  newline$
  ""
  before.all 'output.state :=
}

FUNCTION {fin.entry}
{ add.period$
  write$
  newline$
}

FUNCTION {new.block}
{ output.state before.all =
    'skip$
    { after.block 'output.state := }
  if$
}

FUNCTION {new.sentence}
{ output.state after.block =
    'skip$
    { output.state before.all =
    'skip$
    { after.sentence 'output.state := }
      if$
    }
  if$
}


FUNCTION {new.block.checka}
{ empty$
    'skip$
    'new.block
  if$
}

FUNCTION {new.block.checkb}
{ empty$
  swap$ empty$
  and
    'skip$
    'new.block
  if$
}

FUNCTION {new.sentence.checka}
{ empty$
    'skip$
    'new.sentence
  if$
}

FUNCTION {new.sentence.checkb}
{ empty$
  swap$ empty$
  and
    'skip$
    'new.sentence
  if$
}

FUNCTION {field.or.null}
{ duplicate$ empty$
    { pop$ "" }
    'skip$
  if$
}

FUNCTION {emphasize}
{ duplicate$ empty$
    { pop$ "" }
    { "{\em " swap$ * "}" * }
  if$
}

FUNCTION {bbl.etal}
{ "et~al." }

FUNCTION {bbl.cn.etal}
{ "等." }

FUNCTION {format.lang}
{ lang empty$
    'skip$
    'skip$
  if$
 }

FUNCTION {format.names}
{ 's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr
      "{ll}{ f{~}}"
      format.name$
      %remove.dots
      %bibinfo bibinfo.check
      't :=
      nameptr #1 >
        {
          nameptr #3
          #1 + =
          numnames #3
          > and
            { "others" 't :=
              #1 'namesleft := }
            'skip$
          if$
          namesleft #1 >
            { ", " * t * }
            { numnames #2 >
              { "" * }
              'skip$
              if$
              s nameptr "{ll}" format.name$ duplicate$ "others" =
                { 't := }
                { pop$ }
              if$
              t "others" =
                {
                  lang empty$
                    { ", " * bbl.etal * }
                    { lang "chinese" =
                       { ", " * bbl.cn.etal * }
                       'skip$
                      if$
                    }
                  if$
                }
                {
                  lang empty$
                    { ", " * t * }
                    { lang "chinese" =
                       { ", " * t * }
                       'skip$
                     if$
                    }
                  if$
                }
              if$
            }
          if$
        }
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

FUNCTION {format.authors}
{ author empty$
    { "" }
    { author format.names }
  if$
}

%FUNCTION {format.editors}
%{ editor empty$
%    { "" }
%    { editor format.names
%      editor num.names$ #1 >
%    { ", editors" * }
%    { ", editor" * }
%      if$
%    }
%  if$
%}

FUNCTION {format.editors}
{ editor empty$
    { "" }
    { lang empty$
    { editor format.names
      editor num.names$ #1 >
    { ", editors" * }
    { ", editor" * }
      if$
    }
    { editor format.names * ", " }
    if$
    }
  if$
}

FUNCTION {format.title}
{ title empty$
    { "" }
    { title }
  if$
}

FUNCTION {n.dashify}
{ 't :=
  ""
    { t empty$ not }
    { t #1 #1 substring$ "-" =
    { t #1 #2 substring$ "--" = not
        { "--" *
          t #2 global.max$ substring$ 't :=
        }
        {   { t #1 #1 substring$ "-" = }
        { "-" *
          t #2 global.max$ substring$ 't :=
        }
          while$
        }
      if$
    }
    { t #1 #1 substring$ *
      t #2 global.max$ substring$ 't :=
    }
      if$
    }
  while$
}

FUNCTION {format.date}
{ year empty$
    { month empty$
    { "" }
    { "there's a month but no year in " cite$ * warning$
      month
    }
      if$
    }
    { month empty$
    'year
    { month ", " * year * }
      if$
    }
  if$
}

FUNCTION {format.btitle}
{ edition empty$
  { title }
  { title empty$
    { title }
    {
      lang empty$
        { " " title * ", " * edition * " ed." * }
        { lang "chinese" =
          { " " title * ", 第~" * edition * " 版" * }
          'skip$
          if$
        }
      if$
    }
    if$
  }
  if$
}

FUNCTION {tie.or.space.connect}
{ duplicate$ text.length$ #3 <
    { "~" }
    { " " }
  if$
  swap$ * *
}

FUNCTION {either.or.check}
{ empty$
    'pop$
    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  if$
}

FUNCTION {format.bvolume}
{ volume empty$
    { "" }
    { "volume" volume tie.or.space.connect
      series empty$
    'skip$
    { " of " * series emphasize * }
      if$
      "volume and number" number either.or.check
    }
  if$
}

FUNCTION {format.number.series}
{ volume empty$
    { number empty$
    { series field.or.null }
    { output.state mid.sentence =
        { "number" }
        { "Number" }
      if$
      number tie.or.space.connect
      series empty$
        { "there's a number but no series in " cite$ * warning$ }
        { " in " * series * }
      if$
    }
      if$
    }
    { "" }
  if$
}

FUNCTION {format.url}
{ url empty$
    { "" }
    { new.block " {\url{" url * "}}" * }
  if$
}



FUNCTION {multi.page.check}
{ 't :=
  #0 'multiresult :=
    { multiresult not
      t empty$ not
      and
    }
    { t #1 #1 substring$
      duplicate$ "-" =
      swap$ duplicate$ "," =
      swap$ "+" =
      or or
    { #1 'multiresult := }
    { t #2 global.max$ substring$ 't := }
      if$
    }
  while$
  multiresult
}

FUNCTION {format.pages}
{ pages empty$
    { "" }
    { pages multi.page.check
    {  lang empty$
         {"pages" pages n.dashify tie.or.space.connect }
         { lang "chinese" =
         { "" pages n.dashify tie.or.space.connect }
         'skip$
         if$
         }
       if$
    }
       { "page" pages tie.or.space.connect }
      if$
    }
  if$
}

FUNCTION {format.vol.num.pages}
{ volume field.or.null
  number empty$
    'skip$
    { "(" number * ")" * *
      volume empty$
    { "there's a number but no volume in " cite$ * warning$ }
    'skip$
      if$
    }
  if$
  pages empty$
    'skip$
    { duplicate$ empty$
    { pop$ format.pages }
    { ":" * pages n.dashify * }
      if$
    }
  if$
}

FUNCTION {format.chapter.pages}
{ chapter empty$
    'format.pages
    { type empty$
    { "chapter" }
    { type "l" change.case$ }
      if$
      chapter tie.or.space.connect
      pages empty$
    'skip$
    { ", " * format.pages * }
      if$
    }
  if$
}

FUNCTION {format.in.ed.booktitle}
{ booktitle empty$
    { "" }
    { editor empty$
    { lang empty$
        { "in: Proceedings of " booktitle * }
        { "见: " booktitle * }
      if$
    }
    { lang empty$
        { "in: " format.editors * ", Proceedings of " * booktitle * }
        { ". 见: " * format.editors * booktitle * }
      if$
    }
      if$
    }
  if$
}

FUNCTION {empty.misc.check}
{ author empty$ title empty$ howpublished empty$
  month empty$ year empty$ note empty$
  and and and and and
    { "all relevant fields are empty in " cite$ * warning$ }
    'skip$
  if$
}

FUNCTION {format.thesis.type}
{ type empty$
    'skip$
    { pop$
      type "t" change.case$
    }
  if$
}

FUNCTION {format.tr.number}
{ type empty$
    { "Technical Report" }
    'type
  if$
  number empty$
    { "t" change.case$ }
    { number tie.or.space.connect }
  if$
}

FUNCTION {format.article.crossref}
{ key empty$
    { journal empty$
    { "need key or journal for " cite$ * " to crossref " * crossref *
      warning$
      ""
    }
    { "In {\em " journal * "\/}" * }
      if$
    }
    { "In " key * }
  if$
  " \cite{" * crossref * "}" *
}

FUNCTION {format.crossref.editor}
{ editor #1 "{ll }{f{~}}" format.name$
  editor num.names$ duplicate$
  #2 >
    { pop$ " et~al." * }
    { #2 <
    'skip$
    { editor #2 "{ll }{f{~}}" format.name$ "others" =
        { " et~al." * }
        { " and " * editor #2 "{ll }{f{~}}" format.name$ * }
      if$
    }
      if$
    }
  if$
}

FUNCTION {format.book.crossref}
{ volume empty$
    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
      "In "
    }
    { "Volume" volume tie.or.space.connect
      " of " *
    }
  if$
  editor empty$
  editor field.or.null author field.or.null =
  or
    { key empty$
    { series empty$
        { "need editor, key, or series for " cite$ * " to crossref " *
          crossref * warning$
          "" *
        }
        { "{\em " * series * "\/}" * }
      if$
    }
    { key * }
      if$
    }
    { format.crossref.editor * }
  if$
  " \cite{" * crossref * "}" *
}

FUNCTION {format.incoll.inproc.crossref}
{ editor empty$
  editor field.or.null author field.or.null =
  or
    { key empty$
    { booktitle empty$
        { "need editor, key, or booktitle for " cite$ * " to crossref " *
          crossref * warning$
          ""
        }
        { "In {\em " booktitle * "\/}" * }
      if$
    }
    { "In " key * }
      if$
    }
    { "In " format.crossref.editor * }
  if$
  " \cite{" * crossref * "}" *
}

FUNCTION {format.patent.nationality.type.number}
{
  nationality duplicate$ empty$
    { "nationality" bibinfo.warn pop$ "" }
    { "nationality" bibinfo.check
      duplicate$ "l" change.case$ "china" =
        { pop$ "中国" }
        { skip$ }
      if$
      " " *
    }
  if$
  type empty$
    { "Patent" "type" bibinfo.check }
    { type "type" bibinfo.check }
  if$
  *
  number duplicate$ empty$
    { "number" bibinfo.warn pop$ }
    { "number" bibinfo.check
      large.number.separate
      swap$ " " * swap$ *
    }
  if$
}

FUNCTION {format.address.publisher}
{ address empty$
    { publisher empty$
    { "" }
    { "there's a publisher but no address in " cite$ * warning$
      publisher
    }
      if$
    }
    { publisher empty$
    'address
    { address ": " * publisher * }
      if$
    }
  if$
}

FUNCTION {format.address.school}
{ address empty$
    { school empty$
    { "" }
    { "there's a school but no address in " cite$ * warning$
      school
    }
      if$
    }
    { school empty$
    'address
    { address ": " * school * }
      if$
    }
  if$
}


FUNCTION {format.title.type}
{ title empty$
    { type empty$
        { "" }
        { "there's a type but no title in " cite$ * warning$
          type
        }
      if$
    }
    { type empty$
        'title
        { title ": " * type * }
      if$
    }
  if$
}

FUNCTION {book} { output.bibitem
  author empty$
    { format.editors "author and editor" output.check }
    { format.authors output.nonnull
      crossref missing$
    { "author and editor" editor either.or.check }
    'skip$
      if$
    }
  if$
  new.block
  format.btitle
  "title" output.check
  crossref missing$
    { format.bvolume output
      new.block
      format.number.series output
      new.sentence
    }
    { new.block
      format.book.crossref output.nonnull
    }
  if$
  %format.edition output
  format.address.publisher output
  format.date "year" output.check
  new.block
  note output
  fin.entry
}

FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { %journal emphasize "journal" output.check
      journal "journal" output.check
      %format.date "year" output.check
      %new.block
      year output
      format.vol.num.pages output
    }
    { format.article.crossref output.nonnull
      format.pages output
    }
  if$
  new.block
  format.note output
  fin.entry
}

FUNCTION {booklet}
{ output.bibitem
  format.authors output
  new.block
  format.title "title" output.check
  howpublished address new.block.checkb
  howpublished output
  address output
  format.date output
  new.block
  note output
  fin.entry
}

FUNCTION {inbook} { output.bibitem
  author empty$
    { format.editors "author and editor" output.check }
    { format.authors output.nonnull
      crossref missing$
    { "author and editor" editor either.or.check }
    'skip$
      if$
    }
  if$
  new.block
  format.btitle "title" output.check
  crossref missing$
    { format.bvolume output
      new.block
      format.number.series output
      new.sentence
    }
    { new.block
      format.book.crossref output.nonnull
    }
  if$
  %format.edition output
  format.address.publisher output
  format.date "year" output.check
  format.chapter.pages "chapter and pages" output.check
  new.block
  note output
  fin.entry
}

FUNCTION {incollection}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { format.in.ed.booktitle "booktitle" output.check
      format.bvolume output
      format.number.series output
      format.chapter.pages output
      new.sentence
      publisher "publisher" output.check
      address output
      %format.edition output
      format.date "year" output.check
    }
    { format.incoll.inproc.crossref output.nonnull
      format.chapter.pages output
    }
  if$
  new.block
  note output
  fin.entry
}

FUNCTION {inproceedings}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { format.in.ed.booktitle "booktitle" output.check
      %format.bvolume output
      %format.number.series output
      %format.pages output
      address empty$
    { organization publisher new.sentence.checkb
      organization output
      publisher output
      format.date "year" output.check
      %year output
    }
    { %address output.nonnull
      format.address.publisher output
      format.date "year" output.check
      %year output
      %new.sentence
      organization output
    }
      if$
      %new.block
      pages output
      %remove.dots
    }
    { format.incoll.inproc.crossref output.nonnull
      format.pages output
    }
  if$
  new.block
  note output
  fin.entry
}

FUNCTION {conference} { inproceedings }

FUNCTION {manual}
{ output.bibitem
  author empty$
    { organization empty$
    'skip$
    { organization output.nonnull
      address output
    }
      if$
    }
    { format.authors output.nonnull }
  if$
  new.block
  format.btitle "title" output.check
  author empty$
    { organization empty$
    { address new.block.checka
      address output
    }
    'skip$
      if$
    }
    { organization address new.block.checkb
      organization output
      address output
    }
  if$
  %format.edition output
  format.date output
  new.block
  note output
  fin.entry
}

FUNCTION {masterthesis.type}
{ lang empty$
    { "[Master Thesis]" }
    { "[硕士学位论文]" }
  if$
}

FUNCTION {mastersthesis}
{ output.bibitem
  format.authors "author" add.period$ output.check
  new.block
  format.title remove.dots ": " * masterthesis.type * output
  new.block
  format.address.school output
  %format.madd "address" output.check
  %school "school" output.check
  format.date "year" output.check
  new.block
  note output
  fin.entry
}

FUNCTION {misc}
{ output.bibitem
  format.authors output
  title howpublished new.block.checkb
  format.title output
  howpublished new.block.checka
  howpublished output
  format.date output
  format.url output
  new.block
  note output
  fin.entry
  empty.misc.check
}

FUNCTION {phdthesis.type}
{ lang empty$
    { "[PhD Dissertation]" }
    { "[博士学位论文]" }
  if$
}

FUNCTION {phdthesis}
{ output.bibitem
  format.authors "author" add.period$ output.check
  new.block
  format.title remove.dots ": " * phdthesis.type * output
  new.block
  format.address.school output
  %address output
  %school "school" output.check
  format.date "year" output.check
  new.block
  note output
  fin.entry
}

FUNCTION {proceedings}
{ output.bibitem
  editor empty$
    { organization output }
    { format.editors output.nonnull }
  if$
  new.block
  format.btitle "title" output.check
  format.bvolume output
  format.number.series output
  address empty$
    { editor empty$
    { publisher new.sentence.checka }
    { organization publisher new.sentence.checkb
      organization output
    }
      if$
      publisher output
      format.date "year" output.check
    }
    { address output.nonnull
      format.date "year" output.check
      new.sentence
      editor empty$
    'skip$
    { organization output }
      if$
      publisher output
    }
  if$
  new.block
  note output
  fin.entry
}

FUNCTION {techreport}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  format.tr.number output.nonnull
  institution "institution" output.check
  address output
  format.date "year" output.check
  format.url output
  new.block
  note output
  fin.entry
}

FUNCTION {patent} { output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  format.patent.nationality.type.number output
  format.date "year" output.check
  format.pages output
  new.block
  note output
  fin.entry
}

FUNCTION {unpublished}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  note "note" output.check
  format.date output
  fin.entry
}

FUNCTION {default.type} { misc }


%%%%%%%%%%%%%%%%%%
%% MAIN PROGRAM %%
%%%%%%%%%%%%%%%%%%

READ

STRINGS { longest.label }

FUNCTION {initialize.longest.label}
{ "" 'longest.label :=
  #1 'number.label :=
  #0 'longest.label.width :=
}

FUNCTION {longest.label.pass}
{ number.label int.to.str$ 'label :=
  number.label #1 + 'number.label :=
  label width$ longest.label.width >
    { label 'longest.label :=
      label width$ 'longest.label.width :=
    }
    'skip$
  if$
}

EXECUTE {initialize.longest.label}

ITERATE {longest.label.pass}

FUNCTION {begin.bib}
{ preamble$ empty$
    'skip$
    { preamble$ write$ newline$ }
  if$
  "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
}

EXECUTE {begin.bib}

EXECUTE {init.state.consts}

ITERATE {call.type$}

FUNCTION {end.bib}
{ newline$
  "\end{thebibliography}" write$ newline$
}

EXECUTE {end.bib}

%BSTFILE
%<\bst>
%
% \fi
%
\endinput
