% \iffalse meta-comment
%
% Copyright (C) 2019-2021 by Miracle0565
%
%     https://github.com/Miracle0565/BUCTthesis
% -------------------------------------------------------
%
% This file may be distributed and/or modified under
% the conditions of the LaTeX Project Public License,
% either version 1.3c 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.3c or later is part of all distributions
% of LaTeX version 1999/12/01 or later.
%
% \fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \iffalse
%<*driver>
\ProvidesFile{buctthesis.dtx}[2022/03/04 v1.3 BUCT Thesis Template]
\documentclass{ltxdoc}
\usepackage{manual}
\begin{document}
\DocInput{\jobname.dtx}
\PrintIndex
\PrintChanges
\end{document}
%</driver>
% \fi
%
% \DoNotIndex{\newcommand,\newenvironment,\renewcommand,\renewenvironment}
% \DoNotIndex{\providecommand,\NewDocumentCommand}
% \DoNotIndex{\begin,\end,\begingroup,\endgroup}
% \DoNotIndex{\Huge,\huge,\LARGE,\Large,\large,\normalsize}
% \DoNotIndex{\small,\footnotesize,\scriptsize,\tiny,\zihao}
% \DoNotIndex{\addtocounter,\label,\let,\linewidth,\newcounter}
% \DoNotIndex{\noindent,\normalfont,\par,\parskip,\phantomsection}
% \DoNotIndex{\providecommand,\ProvidesPackage,\refstepcounter}
% \DoNotIndex{\setcounter,\setlength,\string,\strut}
% \DoNotIndex{\textbackslash,\texttt,\ttfamily,\usepackage}
% \DoNotIndex{\par,\\}
% \DoNotIndex{\if,\ifx,\ifdim,\ifnum,\ifcase,\else,\or,\fi}
% \DoNotIndex{\let,\def,\xdef,\edef,\newcommand,\renewcommand}
% \DoNotIndex{\expandafter,\csname,\endcsname,\relax,\protect}
% \DoNotIndex{\normalfont,\bfseries,\slshape,\sffamily,\interlinepenalty}
% \DoNotIndex{\textbf,\textit,\textsf,\textsc}
% \DoNotIndex{\hfil,\par,\hskip,\vskip,\vspace,\quad}
% \DoNotIndex{\centering,\raggedright,\ref}
% \DoNotIndex{\c@secnumdepth,\@startsection,\@setfontsize}
% \DoNotIndex{\ ,\@plus,\@minus,\p@,\z@,\@m,\@M,\@ne,\m@ne}
% \DoNotIndex{\@@par,\DeclareOperation,\RequirePackage,\LoadClass}
% \DoNotIndex{\AtBeginDocument,\AtEndDocument}
%
%
% \GetFileInfo{buctthesis.dtx}
%
% \title{\textsf{BUCTthesis}：北京化工大学学位论文模板}
% \author{Miracle0565\\ \texttt{https://github.com/Miracle0565}}
% \date{\fileversion （\filedate）}
%
% \newgeometry{hcentering}
% \maketitle
% \tableofcontents\restoregeometry\clearpage
%
% \section{欢迎！}
% BUCTthesis是北京化工大学本科与硕士、博士研究生毕业论文的 \LaTeX\ 写作模板，版本号~\fileversion。
% 本文是模板的使用指南，旨在帮助北化毕业生掌握此模板的使用方法，从而写出符合北化
% \href{https://jiaowuchu.buct.edu.cn/2018/1009/c515a22046/page.htm}{《本科生毕业设计（论文）撰写规范》}（以下称《本科规范》）
% 和 \href{https://xxgk.buct.edu.cn/2017/1107/c2835a39437/page.htm}{《北京化工大学研究生学位论文撰写规范（修订）》}（以下称《研究生规范》）
% 要求的毕业论文。
%
% \subsection{模板内容}
% 本模板为中文论文模板，暂不支持英语专业的论文写作。以下是完整论文的书序，其中划线部分为模板未完成的部分。
% \begin{description}
%    \item[本科] \without{开题报告} \footnote{格式未指定。}、\without{中期进展情况检查表} \footnote{由学校提供 Word，可转换为 PDF 文件插入。}、\without{论文封面} \footnote{学校统一印制，论文题目等信息需手写，可使用扫描件插入。}、诚信声明、任务书、摘要、目录、前言、正文、结论、参考文献、符号说明、致谢和附录；
%    \item[研究生] 论文封面、版权页（独创性声明和授权书）、\without{学位论文数据集} \footnotemark[2]、中英文摘要、中英文目录、符号和缩略词说明、正文、参考文献、附录、致谢、作者攻读学位期间发表的学术论文及科研成果目录、作者和导师简介和\without{答辩委员会决议} \footnote{使用扫描件插入。}。
% \end{description}
%
% \subsection{免责声明}
% 请您注意，至本文档编译时，北京化工大学教务处仅提供《本科规范》和《研究生规范》而未对本模板做任何测试或授权。
% 模板作者自当尽力，但限于软件等各种因素，由本模板生成的文档可能仍与要求有所出入，
% 故不保证审查老师对格式不提意见。在开始使用之前，您需要同意：
% 任何由于使用本模板而引起的论文格式审查问题均与本模板作者无关。
%
% \subsection{开源说明}
% 本模板开源于 \href{https://github.com/Miracle0565/BUCTthesis}{GitHub}，代码部分遵循
% \href{https://www.latex-project.org/lppl.txt}{\LaTeX\ Project Public License 1.3c} 及以上协议。
% 模板文件夹中有关学校校徽和校名的插图，其版权归北京化工大学所有。
%
% 由于模板建设尚在起步阶段，欢迎任何有兴趣的同学加入模板的开发工作。
%
% \subsection{关于本文}
% 本文档将对使用这份模板作一简单介绍。在第~\ref{sec:start}~节将概述使用模板前的准备，以及介绍编译方法；
% 在第~\ref{sec:usage}~节将介绍本模板中新定义及实用的命令与环境；
% 最后在第~\ref{sec:implementation}~节将简述模板文档类代码，面向对 BUCTthesis 开发感兴趣的用户。
%
% 本文档中的宏包、命令等内容以不同字体或形式展现，以作区分：
% 无衬线字体表示宏包、文档类等存在于计算机上的文件，
% 如 \file{buctthesis.cls} 文件、\pkg{amsmath}宏包、\cls{ctexbook} 文档类；
% 等宽字体表示命令与环境，如 \cs{buctsetup} 命令、\env{abstract} 环境。
% 对于命令中的参数将置于尖括号（尖括号无需输入）中，如 \cs{include}\marg{file}；
% 对于命令行指令，将置于\ {\color{violet!65}\rule[.25ex]{1em}{1ex}} 颜色框内，且需要逐行输入；
% 而对于 \LaTeX\ 代码，将置于\ {\color{cyan}\rule[.25ex]{1em}{1ex}} 颜色框内，
% 需要保存为特定文件后进行编译。
%
% \section{开始使用}\label{sec:start}
% \subsection{准备工作}
% 开始之前，您需要选择一个合适的 \TeX\ 发行版，以及需要一些必要的 \TeX\ 技能。
% \begin{enumerate}
%     \item  \TeX\ 发行版：
%     \begin{description}
%         \item[本地编译] 建议完整安装 \TeX\ Live 2020 或更新版本。模板\emph{不支持} \CTeX\ 套装。安装 \TeX 发行版的详细步骤可参考\href{https://github.com/OsbertWang/install-latex-guide-zh-cn}{《一份简短的关于 \LaTeX 安装的介绍》}。此外，该文档简要地介绍了几款常见的文本编辑器，可根据喜好自行选择。
%         \item[在线编译] 推荐 \href{https://www.overleaf.com/}{Overleaf}，它提供了 Ubuntu 系统下的 \TeX\ Live，目前为 2021 版。免费版本足以应对模板的正常编译，至于完整的文档历史和协作编辑等功能则需付费订阅。
%     \end{description}
%     \item \TeX\ 技能：本文档不是一份 \LaTeX\ 零基础教程，使用本模板需要对 \LaTeX\ 和参考文献管理工具 \BibTeX 有一定的熟练度。若您是新手，我们建议您先阅读一些入门文档，如\href{http://mirror.ctan.org/info/lshort/chinese/lshort-zh-cn.pdf}{《一份不太简短的 \LaTeXe 介绍》}。
% \end{enumerate}
%
% \subsection{模板组成}
% 在表 \ref{tab:mainfile} 中罗列了本模板所包含的主要文件。
% \begin{table}[ht]
%   \centering
%   \caption{模板的组成}\label{tab:mainfile}
%     \begin{tabular}{ll}
%         \toprule
%         文件（夹）名 & 简述\\
%         \midrule
%         \file{buctthesis.ins} & \textsc{DocStrip} 驱动文件\\
%         \file{buctthesis.dtx} & \textsc{DocStrip} 源文件\\\cmidrule(lr){1-2}
%         \file{chapter/} & 论文各部分的源文件路径\\
%         \file{code/} & 源代码的路径\\
%         \file{cover/} & 论文封面的路径\\
%         \file{figure/}  & 插图的路径\\\cmidrule(lr){1-2}
%         \file{main.tex} & 主文件\\
%         \file{main.pdf} & 示例文档\\
%         \file{buctthesis.cls} & 模板的文档类文件\\
%         \file{thesisbib.bib}  & \BibTeX{}参考文献数据库\\
%         \file{mycfg.sty} & 自定义配置文件\\
%         \file{README.md} & 项目自述文件\\
%         \file{\bfseries buctthesis.pdf} & 写作指南，即本文\\
%         \bottomrule
%     \end{tabular}
% \end{table}
%
% \begin{enumerate}
%     \item 主文件 \file{main.tex}：定义论文相关信息，并对分散于 \file{chapter/} 文件夹下的各部分内容进行“整合”。这里的“各部分内容”包括诚信声明或版权页、摘要、正文等。
%     \item 文档类文件 \file{buctthesis.cls}：格式控制。可由 \file{buctthesis.ins} 和 \file{buctthesis.dtx} 生成：
%     \begin{shell}
%   xelatex buctthesis.ins
%     \end{shell}
%     \item \file{buctthesis.pdf}：写作指南，即本文。可由 \file{buctthesis.dtx} 生成：
%     \begin{shell}
%   xelatex buctthesis.ins
%   xelatex buctthesis.dtx
%   makeindex -s gind.ist -o buctthesis.ind buctthesis.idx
%   xelatex buctthesis.dtx
%   xelatex buctthesis.dtx
%     \end{shell}
% \end{enumerate}
%
% \subsection{编译论文}
% 模板基于 \cls{ctexbook} 文档类构建，但\emph{仅} 支持 \XeTeX\ 引擎。
% 目前参考文献生成基于 \BibTeX，因此完整的编译流程如下：
% （输入以下命令时可略去文件扩展名）
% \begin{shell}
%   xelatex main.tex
%   bibtex main.tex
%   xelatex main.tex
%   xelatex main.tex
% \end{shell}
%
% 或者使用更方便的 latexmk 工具：不加参数则默认对 \file{main.tex} 进行编译。
% 相比上一种，使用 latexmk 更加自动化，能持续编译直到解决所有的交叉引用：
% \begin{shell}
%   latexmk
% \end{shell}
%
% 示例文件会随模板一同发布。建议在写作开始前对示例文件执行一次全编译，以检查编程环境是否合适。
%
% \subsection{提问}
% 对于模板的任何问题或新功能需求请提交至 \href{https://github.com/Miracle0565/BUCTthesis/issues}{GitHub Issues}。
% 以下步骤可能对排除与精简问题有所帮助：
% \begin{enumerate}
%     \item 将 \file{buctthesis.cls} 和 \file{main.tex} 文件复制到一空白文件夹；
%     \item 简化 \file{main.tex} 中能复现问题的代码至如下所示：
%        \begin{latex}
%   \documentclass[ type = bachelor ]{buctthesis}      % 请注意指定文档类型
%   \begin{document}
%     sOmetHInG GoEs wRoNg.
%   \end{document}
%       \end{latex}
%    \item 如果有必要的话可以将 \file{.log} 文件通过 \href{https://pastebin.com/}{Pastebin} 一并提交。
% \end{enumerate}
%
% \section{使用说明}\label{sec:usage}
% 本节将简单介绍模板中的命令和环境。除了以下介绍，推荐对照示例文件及源代码看一看。
%
% \subsection{论文选项}\label{subsec:options}
% \subsubsection{文档类选项}
% 主文件 \file{main.tex} 以
% \begin{latex}
%   \documentclass[
%       type = doctor,          % bachelor | master | doctor
%       fontset = windows,      % fandol | windows | ...
%       submit,
%       openany,                % openany | openright(default)
%   ]{buctthesis}
% \end{latex}
% 命令载入文档类，从而控制全文格式。
%
% 以下逐一简述各个选项：
%
% \DescribeOpt{type = }
% \emph{必须指定一种类型}：本科 \opt{bachelor}，硕士 \opt{master}，以及博士 \opt{doctor}。
% 如：
% \begin{latex}
%   % 博士论文
%   \documentclass[type = doctor,]{buctthesis}
%   % 或：
%   % 本科论文
%   \documentclass[type = bachelor,]{buctthesis}
% \end{latex}
%
% \DescribeOpt{fontset = }
% 该选项会传递至 \pkg{ctex} 宏集，从而指定全文的字体。模板的设置如表~\ref{tab:fontset}~所示。
% 
% 其中选项 \opt{fandol} 或使用 \opt{\meta{others}} 选项 \footnote{参见\pkg{ctex}宏集第 4.3 小节。}是为了一些不方便安装字体的系统或平台（如 Overleaf）所采取的\emph{临时解决方案}。
% 这些字体与中易系列字体有少许差别，且偶尔有缺字现象。
% 因此，强烈建议在最后提交论文前，在合适的环境下使用 \opt{fontset = windows} 进行编译。
%
% \begin{table}[ht]
%   \centering
%   \caption{模板的字体配置}\label{tab:fontset}
%     \begin{tabular}{llll}
%         \toprule
%         \opt{fontset =}   & \opt{windows} & \opt{fandol} & \opt{\meta{others}}\\
%         \midrule
%         中文      & 中易字库 （宋、黑开启伪粗体）  & Fandol 字库 & / \\
%         西文      & Times New Roman             & Times New Roman & Times New Roman \\
%         \bottomrule
%     \end{tabular}
% \end{table}
%
% \DescribeOpt{submit}
% 是否为提交版本。如果启用则会将文章超链接和代码块的文字颜色全部设置为黑色，适合论文最终提交与付梓。
% 需要提醒的是，它不能转换插图的颜色。
%
% \DescribeOpt{openright}
% \DescribeOpt{openany}
% 对于书籍而言，一般章标题都只出现在右边的页面（奇数页），之前不足的页面用空白补足。
% 这也是打开模板 \opt{openright} 选项的结果：将会在适当处插入一完全空白页。
% 而 \opt{openany} 则允许在任意页开启新的一章。
%
% 其它选项：多余的选项将传递给 \pkg{ctexbook} 文档类，如 \opt{draft} 将关闭插图和部分宏包的渲染，从而加快编译速度。
%
% \subsubsection{论文信息}\label{subsec:buctsetup}
% \DescribeMacro{\buctsetup}
% \DescribeOpt{ctitle}
% \DescribeOpt{etitle}
% \DescribeOpt{cauthor}
% \DescribeOpt{class}
% \DescribeOpt{studentid}
% \DescribeOpt{school}
% \DescribeOpt{major}
% \DescribeOpt{supervisor}
% \DescribeOpt{msupervisor}
% \begin{syntax}{buctsetup}
%    \marg{键值列表}
% \end{syntax}
%
% 接下来需要定义论文相关信息，使用 \cs{buctsetup} 命令以 \meta{key}$=$\meta{value}
% 的形式进行定义，包括论文的中英文标题、作者个人信息等。
% \begin{latex}
%    \buctsetup{
%        % 论文的中文标题
%        ctitle         = {基于 \LaTeX\ 的北京化工大学毕业论文写作模板},
%        % 论文的英文标题，一般需要大写
%        etitle         = {BUCTthesis: A \LaTeX\ WRITING TEMPLATE FOR BUCT},
%        % 作者的中文姓名
%        cauthor        = {张三},
%        % 班级（仅本科）
%        class          = {某某1024},
%        % 学号（仅本科）
%        studentid      = {2018020999},
%        % 学院（仅本科）
%        school         = {材料科学与工程学院},
%        % 专业名称（仅本科）
%        major          = {高分子材料与工程},
%        % 导师的姓名与职称（仅本科）
%        supervisor     = {李四教授},
%        % 专业负责人姓名（仅本科）
%        msupervisor    = {王五},
%        % 中文、英文关键词，各关键词间以西文逗号“,”分隔
%        ckeywords      = {论文,\LaTeX{},模板},
%        ekeywords      = {thesis,\LaTeX{},template},
%    }
% \end{latex}
%
% \emph{无论是文档类选项还是 \cs{buctsetup} 命令，各选项之间不要留有空行，并以西文逗号“,”分隔。}
%
% 此外，\cs{buctsetup}\marg{键值列表} 与下列命令等价：
% \begin{latex}
%   % 于导言区
%   \ctitle{基于 \LaTeX\ 的北京化工大学毕业论文写作模板}
%   \etitle{BUCTthesis: A \LaTeX\ WRITING TEMPLATE FOR BUCT}
%   % ...（下同）
% \end{latex}
%
% \subsection{前置部分}\label{subsec:frontmatter}
%
% 在“目录”之前的几个部分，包括“诚信声明”\footnote{根据《现代汉语词典》对“申明”与“声明”二词的释义，%
% 《本科规范》中的“诚信申明”应作“诚信声明”；模板以后者作为标题。}（仅本科）、
% 版权页（仅硕博）、“任务书”（仅本科）、“摘要”和“Abstract”，
% 分别对应于 \file{chapter/frontmatter.tex} 中的不同命令或环境。
%
% \subsubsection{诚信声明与版权页}
% \DescribeMacro{\makedeclare}
% \begin{syntax}{makedeclare}
%    \oarg{文件路径}
% \end{syntax}
%
% 直接使用而不带任何参数的 \cs{makedeclare} 会根据所选 \opt{type} 生成对应内容。
%
% 此外，考虑到有时需要插入扫描页，所以该命令可跟一个可选参数，如：
% \begin{latex}
%   \makedeclare[figure/declare.png]
% \end{latex}
% 即可插入位于 \file{figure/declare.png} 的图片来代替。
%
% \subsubsection{摘要和关键词}\label{subsubsec:abstract}
% \DescribeEnv{cabstract}
% \DescribeEnv{eabstract}
% 中、英文摘要分别使用 \env{cabstract} 和 \env{eabstract} 环境。
% \begin{latex}
%   \begin{cabstract}
%       中文摘要。
%   \end{cabstract}
%   \begin{eabstract}
%       Abstract in English.
%   \end{eabstract}
% \end{latex}
%
% 关键词会根据在 \cs{buctsetup} 中的定义自动生成，参见~\ref{subsec:buctsetup}。
%
% \subsubsection{任务书}\label{subsubsec:taskbook}
% \DescribeEnv{taskbook}
% \DescribeMacro{\taskinfo}
% \DescribeMacro{\taskinfo*}
% \DescribeEnv{bibenumerate}
% 该环境仅适用于本科论文中。
%
% “本科生毕业设计（论文）任务书”部分使用 \env{taskbook} 环境。
% 主文件中所定义的部分信息会作用于“任务书”的开头部分；
% 该部分以 \cs{taskinfo} 或 \cs{taskinfo*} 命令来插入，
% 二者的区别在于后者比前者少了一次换行，是《本科规范》中示例的实现，但不适合文字较多时使用。
%
% 除此之外，可以选择使用 \env{bibenumerate} 环境来排版有序文献列表，
% 序号已经设置为带方括号的数字。
%
% \emph{以上各部分在源文件中含有部分代码，稍作改动即可。}
%
% \subsubsection{目录}\label{subsubsec:content}
% \DescribeMacro{\tableofcontents}
% \DescribeMacro{\tableofcontentsEN}
% \DescribeMacro{\listofdesignfigures}
% 三个命令分别生成中文目录、英文目录（仅硕博）、设计图纸目录（仅本科部分专业）。
% \begin{latex}
%   \tableofcontents
%   \tableofcontentsEN
%   \listofdesignfigures
% \end{latex}
%
% 三者是互相独立的。
% 英文目录通过 \cs{echapter} 等命令指定某一标题的英文标题，参见~\ref{subsubsec:bitoc}。
% 设计图纸目录通过 \env{dfigure} 环境指定插图为“设计图纸”并计数编号。
% 参见~\ref{subsubsec:dfigure}。
%
% \subsubsection{符号说明表}\label{subsubsec:deno}
% \DescribeEnv{denotation}
% 符号说明部分的源文件位于 \file{chapter/denotation.tex}，
% 使用 \env{denotation} 环境。
% 《本科规范》和《研究生规范》中都未详细规定符号说明部分的格式，
% 模板设计了一个无框线、可跨页的长表格，直接在环境里填入内容即可。
% 环境接受一个可选 \meta{Width} 参数 ，代表“说明”一列的宽度，用于在必要时调整。
% \begin{latex}
%   \begin{denotation}[12cm] % 设置第二列的列宽为 12 cm，默认 10 cm
%       符号1   &   说明1   \\
%       符号2   &   说明2   \\
%   \end{denotation}
% \end{latex}
%
% \emph{注意：“符号说明表”在本科论文中置于“参考文献”之后，与研究生论文有所差异。}
%
% \subsubsection{前言}\label{subsubsec:foreword}
% 该环境仅适用于本科论文中。
%
% 该部分的源代码位于 \file{chapter/foreword.tex}，
% 使用 \env{foreword} 环境，在相应位置输入文本即可。注意不能在此环境中使用
% \cs{section}等与“章”计数器有关的命令，结论、翻译、致谢部分同理。
%
% \subsection{正文部分}\label{subsec:mainmatter}
%
% \subsubsection{纲举目张}
% \DescribeMacro{\include}
% \DescribeMacro{\input}
% \begin{syntax}{include}
%     \marg{文件}
% \end{syntax}
% \qquad
% \begin{syntax}{input}
%     \marg{文件}
% \end{syntax}
%
% 正文部分各个章节的源文件存放于 \file{chapter/} 文件夹，
% 只要在 \file{main.tex} 正文部分以上述命令插入各章节即可成文。
% 插入 \meta{文件} 可以不带扩展名，默认为 \file{.tex}。
%
% 使用 \cs{include} 命令会在读入文件前另起一页，而 \cs{input}
% 纯粹插入文件里的内容。
% 当随着写作章节增多，每次编译时间也会越来越长。
% 此时可以选择性地注释部分章节，从而快速编译查错。
%
% \subsubsection{双语目录}\label{subsubsec:bitoc}
% \DescribeMacro{\echapter}
% \DescribeMacro{\esection}
% \DescribeMacro{\esubsection}
% \DescribeMacro{\esubsubsection}
% \begin{syntax}{echapter}
%     \marg{英文目录标题}
% \end{syntax}
%
% 这些命令仅适用于硕博论文中，支持章、节、小节和小小节标题，且语法相同。
%
% 硕博论文要求中英双语目录，且英语目录要与中文对应。
% 我们只需在正文章节标题命令后加上对应标签即可。
% 如：
% \begin{latex}
%   \chapter{绪论}\echapter{Intorduciton}
%       \section{基本概念}\esection{Basic Conceptions}
%       \section{本章小结}\esection{Chapter Summary}
%   \chapter{实验}\echapter{The Experiments}
% \end{latex}
%
% 可能写两遍 chapter 或 section 显得过于繁琐，我们也有更简单的 \cs{bichapter} 与 \cs{bisection} 等命令。以 \cs{bichapter} 为例，语法格式为：
%
% \DescribeMacro{\bichapter}
% \DescribeMacro{\bisection}
% \DescribeMacro{\bisubsection}
% \DescribeMacro{\bisubsubsection}
% \begin{syntax}{bichapter}
%     \oarg{中文目录标题}\marg{中文正文标题}\marg{英文目录标题}
% \end{syntax}
%
% 可见与 \cs{chapter} 相比，它多了一个参数用于接受 \meta{英文目录的标题}。
% 于是，上面这个例子可以这样简化：
% \begin{latex}
%   \bichapter{绪论}{Intorduciton}
%       \bisection{基本概念}{Basic Conceptions}
%       \bisection{本章小结}{Chapter Summary}
%   \bichapter{实验}{The Experiments}
% \end{latex}
%
% 但这也有少许弊端：一些编辑器会检测代码中诸如 \cs{section} 等章节结构命令，
% 以此在编辑窗口中显示论文的结构树；但是，如果使用了 \cs{bisection} 等命令之后，
% 就可能无法正常显示了。
%
% \DescribeMacro{\tableofcontentsEN}
% 然后，使用 \cs{tableofcontentsEN} 生成英文目录项。
% 类似中文目录，英文目录需要经过两次编译才能正确生成。
%
% \subsubsection{双语图表注}\label{subsubsec:bicaption}
% \DescribeMacro{\bicaption}
% \begin{syntax}{bicaption}
%     \marg{中文长图表注}\marg{英文长图表注}
% \end{syntax}
%
% 该命令仅适用于硕博论文中。
%
% 具体的用法很简单：使用 \cs{bicaption} 代替 \cs{caption} 命令即可，如：
% \begin{latex}
%   \begin{figure}
%       \centering \includegraphics[]{file}
%       \bicaption{中文标题}{English Title}
%   \end{figure}
% \end{latex}
%
% \subsubsection{设计图纸}\label{subsubsec:dfigure}
% 这些命令和环境仅适用于本科论文中。
%
% 关于一般的插图请看示例文件，这里介绍关于“设计图纸”及编目的方法。
%
% 由于《本科规范》未对所谓“设计图纸”详细说明，因此模板设计了两种编目方式：
% 一是加入主目录，另一种是单独生成目录。
%
% \DescribeEnv{dfigure}
% 设计图纸的计数器是独立于一般插图的，故需要使用 \env{dfigure} 环境来代替 \env{figure}。

% \DescribeMacro{\dcaption}
% 先来看编入主目录的方式，在正文内插入插图的代码处，
% 除了使用 \cs{dcaption} 代替 \cs{caption}外都一样。
% \begin{latex}
%   \begin{dfigure}[htbp]
%       \centering\includegraphics[]{file}
%       \dcaption{设计图纸示例}
%   \end{dfigure}
% \end{latex}
%
% \DescribeMacro{\listofdesignfigures}
% 而独立目录也很简单，一个 \cs{listofdesignfigures} 即可。参见~\ref{subsubsec:content}。
% \subsubsection{结论}
% \DescribeEnv{conclusion}
% 该环境仅适用于本科论文中。
%
% 结论部分的源文件位于 \file{chapter/conclusion.tex}。该环境与前言相似，没有章的编号。
% 但如果希望把“结论”编入章节，如“第五章\hspace{\ccwd}结论”，
% 那么就不必使用 \env{conclusion} 环境，像其他章节一样使用 \cs{chapter} 就可以了。
% \begin{latex}
%   \begin{conclusion}
%      本文的结论有什么？
%   \end{conclusion}
% \end{latex}
%
% \subsubsection{参考文献}\label{subsubsec:bib}
% \DescribeMacro{\cite}
% \DescribeMacro{\nocite}
% \begin{syntax}{cite}
%    \marg{CiteKey}
% \end{syntax}
%
% 模板以上标、方括号按“顺序编码制”引用参考文献。
% 而 \cs{nocite}\marg{CiteKey} 则指明不引用但需要列出的参考文献。
% 在同一处引用多个文献时，应将各篇文献的引用标签一同写在参数里，
% 并以西文逗号“,”分隔每个 \meta{CiteKey}。
%
% 主文件中以
% \begin{latex}
%   \bibliographystyle{gbt7714-numerical}
%   \bibliography{thesisbib.bib}
% \end{latex}
% 来增加符合格式要求的参考文献章节。为罗列各条参考文献，
% 需要在 \file{thesisbib.bib} 文件中增删需引用的文献数据。
% 在文章中相应位置引用文献后，需执行一次全编译以确保正确显示。
%
% \emph{注意：至少需要引用一篇文献，否则执行完全编译可能会引起编译错误。}
%
%
% \subsection{后置部分}\label{subsec:backmatter}
% \subsubsection{翻译}
% \DescribeEnv{translation}
% 该环境仅适用于本科论文中。
%
% 文献翻译的源文件位于 \file{chapter/translation.tex}，
% 使用 \env{translation} 环境，原文和翻译都要有。
% \begin{latex}
%   \begin{translations}
%      English.
%
%      汉语。
%   \end{translations}
% \end{latex}
%
% \subsubsection{附录}\label{subsubsec:app}
% \DescribeMacro{\appendix}
% \cs{appendix} 命令作为附录部分的开始。
% 与正文类似，只需往 \file{chapter/app1.tex} 等加入内容即可。
% \begin{latex}
%   \appendix
%   \chapter{...}
%   ...
% \end{latex}
%
% \subsubsection{致谢}
% \DescribeEnv{acknowledgement}
% 致谢部分的源文件位于 \file{chapter/acknowledgement.tex}，
% 使用 \env{acknowledgement} 环境，
% 往里面写入感谢的话就可以啦。
% \begin{latex}
%   \begin{acknowledgement}
%       谢谢你！
%   \end{acknowledgement}
% \end{latex}
%
% \emph{注意：“致谢”在本科论文中置于“附录”之前，与研究生论文有所差异。}
%
% \subsubsection{成果与简介}
% \DescribeEnv{achievements}
% \DescribeEnv{resume}
% 这些环境仅适用于研究生论文中。
%
% 该部分包括“作者攻读学位期间发表的学术论文及科研成果目录”与“作者和导师简介”，
% 源文件位于 \file{chapter/resume.tex}。示例文档中已有现成例子，推荐直接修改。
%
% \DescribeEnv{bibenumerate}
% 其中可以使用 \env{bibenumerate} 环境来生成带有方括号的列表，适合罗列文献。
%
% \begin{latex}
%   \begin{achievements}
%       \section*{发表及已接受的论文：}
%       \section*{成果及专利：}
%   \end{achievements}
%   \begin{resume}
%      \section*{作者简介：}
%      \section*{导师简介：}
%   \end{resume}
% \end{latex}
%
% \subsection{封面}\label{subsec:cover}
% 本小节将简单介绍研究生论文封面的代码与编译。
%
% 与本科模板不同的是，BUCTthesis 的硕博模板在 \file{cover} 文件夹中仿制了学校的封面。
% 在该文件夹中的三个文件都与封面有关，编译时请确保它们位于同一路径之下。
%
% \emph{注意：这里的“仿制”仅是实现封面的效果，学校印制的封面需要手写内容，故不能替代学校统一印制的封面。}
% \begin{enumerate}
%    \item \file{cover.tex}：源文档。与 \cs{buctsetup} 类似，这里使用\cs{coversetup} 定义论文信息。
% \begin{latex}
%   \coversetup{
%       % 学号，位于封面的右上角
%       studentid = {2021010234},
%       % 标题。封面的标题有两行，每一行控制在 18 个汉字长度以内
%       titleA = {甲乙丙丁戊己庚辛壬癸一二三},
%       titleB = {四五六七八九十甲乙丙丁戊己},
%       % 作者
%       author = {张三},
%       % 专业
%       major  = {计算机科学与技术},
%       % 导师
%       supervisor = {某某某教授},
%       % 日期，不填为当日。请注意：务必使用形如“YYYY-MM-DD”的格式
%       date = {2021-12-23},
%   }
% \end{latex}
%
% 至于编译，只需一遍 xelatex 即可，扩展名可省略。
% \begin{shell}
%   xelatex cover.tex
% \end{shell}
%    \item \file{buctcover.cls}：格式控制文件。类似 \file{buctthesis.cls}，亦可由 \file{buctthesis.ins} 和 \file{buctthesis.dtx} 生成：
%     \begin{shell}
%   xelatex buctthesis.ins
%     \end{shell}
% 请注意执行以上命令时会同时生成 \file{buctcover.cls} 和 \file{buctthesis.cls}，只有前者是用于控制封面的。
% \end{enumerate}
% 
% 除此之外，封面使用的方正系列字体未预装于一些操作系统上，
% 可访问\href{https://www.foundertype.com}{方正字库官网}下载和安装，具体步骤从略。
%
% 封面所使用的中文字体清单：
% \begin{enumerate}
%    \item SimSun，中易宋体
%    \item SimHei，中易黑体
%    \item KaiTi，中易楷体
%    \item STXingkai，华文行楷
%    \item FZDaBiaoSong-B06S，方正大标宋简体
%    \item FZXiaoBiaoSong-B05S，方正小标宋简体
% \end{enumerate}
%
%
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \clearpage
% \section{实现细节}\label{sec:implementation}
% \subsection{文档类信息与选项}
%    \begin{macrocode}
%<class|cover>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<*class>
\ProvidesClass{buctthesis}[2021/09/10 v1.2 BUCT Thesis Template]
%    \end{macrocode}
%
% 装载 \pkg{ifxetex} 宏包，并通过 \cs{RequireXeTeX} 命令检查编译命令。
% 若未使用 \XeTeX\ 或 \XeLaTeX\ 将强制中止编译并发出警告。
%    \begin{macrocode}
\RequirePackage{ifxetex}
\RequireXeTeX
%    \end{macrocode}
%
% 定义选项和族。
%    \begin{macrocode}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
    family   = buct,
    prefix   = buct@,
    setkeys  = \kvsetkeys,
}
%    \end{macrocode}
%
% 定义载入文档类时的选项：
%
% 模板类型：本科、硕士、博士；
%    \begin{macrocode}
\newif\ifbuct@bachelor\buct@bachelorfalse
\newif\ifbuct@master\buct@masterfalse
\newif\ifbuct@doctor\buct@doctorfalse
\define@key{buct}{type}{\expandafter\csname buct@#1true\endcsname}
%    \end{macrocode}
%
% 是否为最终提交版本，默认否；
%    \begin{macrocode}
\DeclareBoolOption[false]{submit}
%    \end{macrocode}
%
% 每章从任意页或奇数页开始，默认 openright，即每章只从奇数页开始；
%    \begin{macrocode}
\DeclareBoolOption[false]{openany}
\DeclareComplementaryOption{openright}{openany}
%    \end{macrocode}
%
% 是否开启模板调试器，默认否。
%    \begin{macrocode}
\DeclareBoolOption[false]{debugger}
%    \end{macrocode}
%
% 将文档类多余的选项传递给 \pkg{ctexbook} 文档类，并加载相应选项的文档类。
%    \begin{macrocode}
\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{ctexbook}}
\ProcessKeyvalOptions*
%    \end{macrocode}
%
% 由于 \cls{ctexbook} 将会调用 \pkg{xeCJK} 宏包来配置字体，这里使用 \opt{quiet}
% 选项关闭因自定义字体（后述）而产生的警告。
% 最后根据用户选项，加载相应选项的 \cls{ctexbook} 文档类。
%    \begin{macrocode}
\PassOptionsToPackage{quiet}{xeCJK}
\ifbuct@openany\LoadClass[zihao=-4,UTF8,oneside]{ctexbook}
\else\LoadClass[zihao=-4,UTF8,openright]{ctexbook}\fi
%    \end{macrocode}
%
% 必须指定本、硕、博中的一种类型。
%    \begin{macrocode}
\ifbuct@bachelor\relax\else
    \ifbuct@master\relax\else
        \ifbuct@doctor\relax\else
            \ClassError{buctthesis}{%
                Specified thesis type is obligatory: \MessageBreak%
                type = [ bachelor | master | doctor ]%
            }{}
\fi\fi\fi
%    \end{macrocode}
%
% \begin{macro}{\buct@def@key}
% 定义用于定义论文相关信息的内部命令。例如
% \begin{latex}
%   \buct@def@key{ctitle}
% \end{latex}
% 相当于：
% \begin{latex}
%   \newcommand{\ctitle}[1]{\newcommand{\buct@ctitle}{#1}}
%   \define@key{buct}{ctitle}{\ctitle{#1}}
% \end{latex}
%
%    \begin{macrocode}
\newcommand{\buct@def@key}[1]{
    \@namedef{#1}##1{\@namedef{buct@#1}{##1}}
    \define@key{buct}{#1}{\@nameuse{#1}{##1}}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\buctsetup}
% 定义 \cs{buctsetup} 命令方便在正文中设置。
%    \begin{macrocode}
\newcommand{\buctsetup}[1]{\kvsetkeys{buct}{#1}}
\buct@def@key{ctitle}
\buct@def@key{etitle}
\buct@def@key{cauthor}
\buct@def@key{class}
\buct@def@key{studentid}
\buct@def@key{school}
\buct@def@key{major}
\buct@def@key{supervisor}
\buct@def@key{msupervisor}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\buct@def@sep@key}
% 对于 \texttt{ckeywords} 等键接受的是以西文逗号“,”分隔的值，上面的定义就不合适了。
% 所以要对值做分隔。相比 \cs{buct@def@key} 这里多一个参数，为在论文中的分隔符。
% 此处宏展开可参考\href{https://www.zhihu.com/question/26916597}{这篇讨论}。
%    \begin{macrocode}
\newcommand{\buct@def@sep@key}[2]{%
    \@namedef{#1}##1{%
        \@namedef{buct@#1}{}%
        \@for\reserved@a:=##1\do{
            \expandafter\ifx\csname buct@#1\endcsname\@empty\else
            \expandafter\g@addto@macro\csname buct@#1\endcsname{#2}\fi
            \expandafter\expandafter\expandafter\g@addto@macro%
            \expandafter\csname buct@#1\expandafter\endcsname%
            \expandafter{\reserved@a}
        }
    }
    \define@key{buct}{#1}{\@nameuse{#1}{##1}}%
}
\buct@def@sep@key{ckeywords}{\buct@ckeywords@sep}
\buct@def@sep@key{ekeywords}{\buct@ekeywords@sep}
%    \end{macrocode}
% \end{macro}
% \subsection{载入宏包}
%
% 用于调整纸张与页面，这两个宏包提供了方便的命令来设置页面边距和页眉页脚。
%    \begin{macrocode}
\RequirePackage{geometry,fancyhdr}
%    \end{macrocode}
%
% 自定义目录格式。
%    \begin{macrocode}
\RequirePackage{titletoc}
%    \end{macrocode}
%
% \AmS{}系列宏包，包括：
% \begin{enumerate}
%    \item \pkg{amsmath}，提供了各种数学方面的增强型命令，以改进包含数学公式的文档结构；
%    \item \pkg{amsthm}，提供了定理类环境样式规范；
%    \item \pkg{amssymb}，提供各种数学符号。
% \end{enumerate}
% 除此之外，载入 \pkg{unicode-math} 宏包以配置数学字体。
%    \begin{macrocode}
\RequirePackage{amsmath,amsthm,amssymb,unicode-math}
%    \end{macrocode}
%
% 这两个宏包最重要的用途是排版本科的第五级标题。前者用于提供带圈序号，而后者提供了方便的格式控制。
%    \begin{macrocode}
\RequirePackage{pifont,enumitem}
%    \end{macrocode}
%
% 一个适合排版含数值和单位的物理量的宏包，它也提供能使表格中小数点竖直对齐的命令。
%    \begin{macrocode}
\RequirePackage{siunitx}
%    \end{macrocode}
%
% 关于化学式排版的宏包有很多，但这里载入 \pkg{mhchem}。
% 它容易上手，偏向于无机和分析化学（方程）式的排版。
% 至于有机化学的结构式等，使用图片插入可能是一个更好的选择；若时间充裕可学习如 \pkg{chemfig} 等宏包。
%    \begin{macrocode}
\RequirePackage[version = 4]{mhchem}
%    \end{macrocode}
%
% 浮动体系列宏包，控制表格、插图等浮动体及标签格式。
%    \begin{macrocode}
\RequirePackage{float}
\RequirePackage{longtable,threeparttable,tabularx,multirow,booktabs}
\RequirePackage{graphicx}
\RequirePackage[labelformat = simple]{subcaption}
\RequirePackage[format=hang]{caption}
\RequirePackage{bicaption}
%    \end{macrocode}
%
% 一个用于绘图的宏包，模板里用于绘制脚注外的圆圈。
%    \begin{macrocode}
\RequirePackage{tikz}
%    \end{macrocode}
%
% 代码块环境。
%    \begin{macrocode}
\RequirePackage{listings}
%    \end{macrocode}
%
% 该宏包提供了符合要求的参考文献编排格式。这里的选项会传递至 \pkg{natbib}，
% 从而在正文中能数字上标、方括号引用。
%    \begin{macrocode}
\RequirePackage[sort&compress]{gbt7714}
%    \end{macrocode}
%
% 为了方便查看，模板将以彩色标明超链接和代码块中的关键字。
%    \begin{macrocode}
\RequirePackage{xcolor}
%    \end{macrocode}
%
% 用于插入PDF文件的宏包。可以插入封面、声明页（因为二者需要签字）等扫描或不方便排版的PDF文件。
%    \begin{macrocode}
\RequirePackage{pdfpages}
%    \end{macrocode}
%
% \pkg{footmisc} 宏包的选项将脚注的位置固定在页面底端，且跨页重置计数。
%    \begin{macrocode}
\RequirePackage[bottom,perpage]{footmisc}
%    \end{macrocode}
%
% 命令补丁，用于便捷地修改一些复杂命令，而无需重新定义之。
%    \begin{macrocode}
\RequirePackage{xpatch}
%    \end{macrocode}
%
% 在页面画上标尺、边框线，和标注行号。仅当开启调试时。
%    \begin{macrocode}
\ifbuct@debugger
    \RequirePackage[color=blue,type=upperleft,showframe,hshift=2.7cm,vshift=3.5cm]{fgruler}
    \RequirePackage[pagewise]{lineno}
\fi
%    \end{macrocode}
%
% 实现交叉引用与超链接。
%    \begin{macrocode}
\RequirePackage{hyperref}
%    \end{macrocode}
%
% \subsection{字体配置}
% \begin{macro}{\buct@fontsetval}
% 首先来设置中文的字体。在 \pkg{ctex} 宏集中的 \cs{g\_\_ctex\_fontset\_tl} 存储着选项 \opt{fontset} 的值。
% 模板尽可能避免使用 \LaTeX 3 语法，所以先用一个 \cs{buct@fontsetval} 来保存它。
%    \begin{macrocode}
\newcommand\buct@fontsetval{\csname g__ctex_fontset_tl\endcsname}
%    \end{macrocode}
% \end{macro}
%
% 根据\cs{buct@fontsetval} 的值，分别设置不同的字体。
%
%    \begin{macrocode}
\ifthenelse{\equal{\buct@fontsetval}{windows}}{
%    \end{macrocode}
%
% 在 Windows 系统下，需要对中易宋体、中易黑体开启“伪粗”和“伪斜”，并设置相关系数。
%    \begin{macrocode}
    \xeCJKsetup{EmboldenFactor=2.2,SlantFactor=0.2}
    \setCJKmainfont{SimSun}[AutoFakeBold,AutoFakeSlant]
    \setCJKsansfont{SimHei}[AutoFakeBold]
}
%    \end{macrocode}
% 而在非Windows 系统下，则由 \pkg{ctex} 宏集自动检测环境并保留其默认设置，
% 同时警告所使用的字体与《规范》（即默认设置）存在不同。
%    \begin{macrocode}
{
    \ClassWarning{buctthesis}{The fonts differ to the default.}
}
%    \end{macrocode}
%
% \begin{macro}{\bfsong}
% 因设置中易宋体开启“伪粗体”，使用 \cs{bfseries}将产生加粗的效果，
% 这与一般的 \LaTeX\ 常识是相悖的。
% 因此模板提供了更明确的命令 \cs{bfsong}。
%    \begin{macrocode}
\newcommand{\bfsong}{\bfseries}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\bfhei}
%
% 对于黑体同理。此外要注意模板将Windows下预设的无衬线字体（微软雅黑）改为了黑体。
%    \begin{macrocode}
\newcommand{\bfhei}{\sffamily\bfseries}
%    \end{macrocode}
% \end{macro}
%
% 对于西文正文，全部统一设置为Times New Roman。
%    \begin{macrocode}
\setmainfont{Times New Roman}
\setsansfont{Times New Roman}
\setmonofont{Times New Roman}
%    \end{macrocode}
%
% 设置数学公式中的字体。
%    \begin{macrocode}
\IfFontExistsTF{LibertinusMath-Regular.otf}{%
    \setmathfont{latinmodern-math.otf}
    \setmathfont[%
        range = {%
            up/{latin,Latin,num},
            it/{latin,Latin,greek},
            bfit/{latin,Latin},
        }
    ]{LibertinusMath-Regular.otf}
}{}
%    \end{macrocode}
%
%
% 指定 Unicode 中带圈数字 \symbol{"2460}--\symbol{"2469} 使用中文字体。
%    \begin{macrocode}
\xeCJKDeclareCharClass{CJK}{"2460->"2469}
%    \end{macrocode}
% 页眉与页脚的字体。
%    \begin{macrocode}
\newcommand{\buct@headfont}{\zihao{-5}\songti}
\newcommand{\buct@footfont}{\zihao{-5}\songti}
%    \end{macrocode}
%
% 诚信声明（本科），或论文原创性声明和授权声明（硕博）的字体。
%    \begin{macrocode}
\ifbuct@bachelor
    \newcommand{\buct@dcl@titlefont}{\zihao{3}\songti}
    \newcommand{\buct@dcl@ideclarefont}{\zihao{4}\songti}
\else
    \newcommand{\buct@dcl@titlefont}{\zihao{4}\bfseries}
    \newcommand{\buct@dcl@textfont}{\zihao{4}\mdseries}
    \newcommand{\buct@auth@titlefont}{\zihao{4}\bfseries}
    \newcommand{\buct@auth@textfont}{\zihao{4}\mdseries}
\fi
%    \end{macrocode}
%
% 中英文摘要中的字体。
% 这里的 \cs{CJKfamily+} 命令来自于 \pkg{xeCJK} 宏包，用于切换字体族：
% 当参数为空时，则使用当前的 CJK 字体族，且对所有字符类生效。
%    \begin{macrocode}
\ifbuct@bachelor
    \newcommand{\buct@abs@titfont}{\zihao{3}\bfsong}
    \newcommand{\buct@abs@infofont}{\zihao{5}\mdseries}
    \newcommand{\buct@abs@absfont}{\zihao{4}\songti}
    \newcommand{\buct@keywordsfont}{\zihao{4}\heiti\CJKfamily+{}}
    \newcommand{\buct@abs@titfonten}{\zihao{3}\bfseries}
    \newcommand{\buct@abs@absfonten}{\zihao{4}\songti}
    \newcommand{\buct@keywordsfonten}{\zihao{4}\heiti\CJKfamily+{}}
\else
    \newcommand{\buct@abs@titfont}{\zihao{3}\heiti}
    \newcommand{\buct@abs@absfont}{\zihao{-3}\heiti}
    \newcommand{\buct@abs@textfont}{\zihao{4}\songti}
    \newcommand{\buct@keywords@titfont}{\zihao{4}\heiti}
    \newcommand{\buct@keywords@font}{\zihao{4}\songti}
    \newcommand{\buct@abs@titfonten}{\zihao{3}\bfseries}
    \newcommand{\buct@abs@absfonten}{\zihao{-3}\bfseries}
    \newcommand{\buct@keywords@titfonten}{\zihao{4}\bfseries}
    \newcommand{\buct@keywords@fonten}{\zihao{4}\mdseries}
\fi
%    \end{macrocode}
%
% 设置中英文目录、设计图纸目录标题和目录中的各级标题字体。
%    \begin{macrocode}
\ifbuct@bachelor
    \newcommand{\buct@toc@tocfont}{\zihao{4}\mdseries\heiti}
\else
    \newcommand{\buct@toc@tocfont}{\zihao{3}\heiti}
\fi
\newcommand{\buct@toc@chapfont}{\zihao{4}\heiti}
\newcommand{\buct@toc@secfont}{\zihao{4}\songti}
\newcommand{\buct@toc@ssecfont}{\zihao{4}\songti}
\newcommand{\buct@toc@sssecfont}{\zihao{-4}\songti}
\newcommand{\buct@toc@dsgfigfont}{\buct@toc@ssecfont}
\newcommand{\buct@toce@chapfont}{\zihao{4}\bfseries}
%    \end{macrocode}
%
% 正文的各级标题。
%    \begin{macrocode}
\ifbuct@bachelor
    \newcommand{\buct@chapfont}{\zihao{-3}\bfsong\centering}
    \newcommand{\buct@secfont}{\zihao{-3}\bfsong\centering}
    \newcommand{\buct@ssecfont}{\zihao{-4}\bfsong\raggedright}
    \newcommand{\buct@sssecfont}{\zihao{-4}\songti}
\else
    \newcommand{\buct@chapfont}{\zihao{3}\heiti\centering}
    \newcommand{\buct@secfont}{\zihao{4}\heiti\raggedright}
    \newcommand{\buct@ssecfont}{\zihao{-4}\heiti\raggedright}
    \newcommand{\buct@sssecfont}{\buct@ssecfont}
\fi
%    \end{macrocode}
%
% 设置浮动体（包括插图和表格）内容、编号和标题的字体。
%    \begin{macrocode}
\newcommand{\buct@floatfont}{\zihao{5}}
\newcommand{\buct@float@captionfont}{\zihao{5}\songti}
%    \end{macrocode}
%
% 设置代码块的字体。根据是否开启 \opt{submit} 选项，设置关键字、注释的颜色。
% 如果未开启，关键字将会使用深蓝色，注释会使用深灰色。
%    \begin{macrocode}
\newcommand{\buct@codefont}{\ttfamily\songti\zihao{5}}
\newcommand{\buct@codecomfont}{%
    \ttfamily\slshape
    \ifbuct@submit\relax\else\color{gray!80!black}\fi}
\newcommand{\buct@codekeyfont}{%
    \ttfamily\bfseries
    \ifbuct@submit\relax\else\color{blue!80!black}\fi}
%    \end{macrocode}
%
%
% \subsection{常量设置}
%    \begin{macrocode}
\ifbuct@bachelor
    \newcommand\buct@headtext{北京化工大学毕业设计（论文）}
    \newcommand\buct@foottext{\thepage}
    \newcommand\buct@dcl@title{诚信声明}
    \newcommand\buct@dcl@ideclare{本人声明：}
    \newcommand\buct@dcl@text{
        所呈交的学位论文是本人在导师的指导下独立进行研究工作所取得的成果。
        据我所知，除文中已经注明引用的内容外，本论文不包含任何其他个人或集体
        已经发表或撰写过的研究成果，也不包含为获得北京化工大学或其它教育机构
        的学位或证书而使用过的材料。对论文所涉及的研究工作做出贡献的其他个人
        和集体，均已在文中以明确方式标明或致谢。本人完全意识到本声明的法律
        结果由本人承担。
    }
    \newcommand\buct@dcl@sign{本人签名：\hspace{14em}年\hspace{2.5em}月\hspace{2.5em}日}
    \newcommand\buct@task@title{本科生毕业设计（论文）任务书}
    \newcommand\buct@task@pdf{任务书}
    \newcommand\buct@task@ctitle{设计（论文）题目：}
    \newcommand\buct@task@school{学院：}
    \newcommand\buct@task@major{专业：}
    \newcommand\buct@task@class{班级：}
    \newcommand\buct@task@student{学生：}
    \newcommand\buct@task@supervisor{指导教师（含职称）：}
    \newcommand\buct@task@msupervisor{专业负责人：} 
    \newcommand\buct@task@itema{1.设计（论文）的主要任务及目标}
    \newcommand\buct@task@itemb{2.设计（论文）的基本要求和内容}
    \newcommand\buct@task@itemc{3.主要参考文献}
    \newcommand\buct@task@itemd{4.进度安排}
    \newcommand\buct@cabstract@title{摘要}
    \newcommand\buct@eabstract@title{ABSTRACT}
    \newcommand\buct@ckeywords@title{关键词：}
    \newcommand\buct@ekeywords@title{Keywords:~}
    \newcommand\buct@ckeywords@sep{\quad}
    \newcommand\buct@ekeywords@sep{; }
    \newcommand\buct@supervisor@title{指导教师：}
    \newcommand\buct@content@title{目\hspace{\ccwd}录}
    \newcommand\buct@dfigurename{设计图纸}
    \newcommand\buct@dfigure@content@title{设计图纸目录}
    \newcommand\buct@foreword@title{前言}
    \newcommand\buct@concl@title{结论}
    \newcommand\buct@trans@title{翻译}
    \newcommand\buct@ack@title{致谢}
    \newcommand\buct@deno@title{符号说明}
    \renewcommand\lstlistingname{代码}
\else
    \newcommand\buct@headtext{\leftmark}
    \newcommand\buct@foottext{\thepage}
    \newcommand\buct@dcl@title{北京化工大学学位论文原创性声明}
    \newcommand\buct@dcl@text{
        本人郑重声明：所呈交的学位论文，是本人在导师的指导下，独立
        进行研究工作所取得的成果。除文中已经注明引用的内容外，本论
        文不含任何其他个人或集体已经发表或撰写过的作品成果。对本文
        的研究做出重要贡献的个人和集体，均已在文中以明确方式标明。
        本人完全意识到本声明的法律结果由本人承担。
    }
    \newcommand\buct@auth@title{关于论文使用授权的说明}
    \newcommand\buct@auth@text{
        学位论文作者完全了解北京化工大学有关保留和使用学位论文的规定，
        即：研究生在校攻读学位期间论文工作的知识产权单位属北京化工大学。
        学校有权保留并向国家有关部门或机构送交论文的复印件和磁盘，允许
        学位论文被查阅和借阅；学校可以公布学位论文的全部或部分内容，
        可以允许采用影印、缩印或其它复制手段保存、汇编学位论文。

        $\Box$ 论文暂不公开（或保密）注释：本学位论文属于暂不公开
        （或保密）范围，在\rule{1.5em}{.6pt}年解密后适用本授权书。

        $\Box$ 非暂不公开（或保密）论文注释：本学位论文不属于暂不公开
        （或保密）范围，适用本授权书。
    }
    \newcommand\buct@dcl@pdf{版权页}
    \newcommand\buct@sign@author{作者签名：\rule{7em}{.6pt}\qquad{日期：}\rule{7em}{.6pt}}
    \newcommand\buct@sign@supervisor{导师签名：\rule{7em}{.6pt}\qquad{日期：}\rule{7em}{.6pt}}
    \newcommand\buct@cabstract@title{摘\hspace{\ccwd}要}
    \newcommand\buct@eabstract@title{ABSTRACT}
    \newcommand\buct@ckeywords@title{关键词：}
    \newcommand\buct@ekeywords@title{KEY WORDS:~}
    \newcommand\buct@ckeywords@sep{，}
    \newcommand\buct@ekeywords@sep{,~}
    \newcommand\buct@content@title{目\hspace{\ccwd}录}
    \newcommand\econtentsname{Contents}
    \newcommand\buct@deno@title{符号和缩略词说明}
    \newcommand\buct@ack@title{致谢}
    \newcommand\buct@eack@title{Acknowledgement}
    \newcommand\buct@achi@title{研究成果及发表的学术论文}
    \newcommand\buct@eachi@title{Research Results and Published Academic Papaers}
    \newcommand\buct@resu@title{作者及导师简介}
    \newcommand\buct@eresu@title{About the Author}
    \newcommand\equationname{式}
    \newcommand\buct@bitable@name{Table}
    \newcommand\buct@bifigure@name{Figure}
    \newcommand\buct@ebib@title{Bibliography}
    \renewcommand\lstlistingname{代码}
\fi
%    \end{macrocode}
%
% \subsection{页面设置}
% \subsubsection{纸张与边距}
% 使用 \pkg{geometry} 宏包设置各边距为：（单双页打印、本硕博相同）
% 上 \SI{3.5}{cm}、下 \SI{2.6}{cm}、左右 \SI{2.7}{cm}，页眉 \SI{2.4}{cm}、页脚 \SI{2}{cm}。
%    \begin{macrocode}
\geometry{%
    a4paper,nomarginpar,
    top = 3.5cm, bottom = 2.6cm, left = 2.7cm, right = 2.7cm,
    headheight = 1.1cm, footskip = 0.6cm,
}
%    \end{macrocode}
%
% \subsubsection{页眉和页脚}
% 使用 \pkg{fancyhdr} 宏包设置页眉页脚的文字和线宽。
%    \begin{macrocode}
\fancypagestyle{plain}{%
    \fancyhf{}
    \fancyhead[C]{\buct@headfont\buct@headtext}
    \fancyfoot[C]{\buct@footfont\buct@foottext}
    \renewcommand\headrulewidth{0.6pt}
    \renewcommand\footrulewidth{0pt}
}
\pagestyle{plain}
%    \end{macrocode}
%
% \begin{macro}{\frontmatter}
% 修改命令 \cs{frontmatter} ，仅将页码从小写罗马字母改为大写，用于“第一章”之前的部分。
%    \begin{macrocode}
\xpatchcmd{\frontmatter}
    {\pagenumbering{roman}}
    {\pagenumbering{Roman}}
    {}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\cleardoublepage}
% 修改命令 \cs{cleardoublepage}，使之能在插入一张完全空白页的同时
% 保持页码的连续，适合章页右开的情况。
%    \begin{macrocode}
\xpatchcmd{\cleardoublepage}
    {\newpage}
    {\thispagestyle{empty}\newpage}
    {}{}
%    \end{macrocode}
% \end{macro}
%
% \subsection{前置部分}
% \begin{macro}{\buct@pdfmark}
% 为了方便查看，模板将前置部分编入PDF书签，实现跳转。
% 这里定义了一个命令用于简化代码。
%    \begin{macrocode}
\newcommand{\buct@pdfmark}[2]{%
    \hypertarget{#2}{}
    \pdfbookmark{#1}{#2}
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{声明页}
% \begin{macro}{\buct@makedeclare}
% 本科为“诚信声明”，硕博为“原创性声明”与“使用授权说明”。这里定义不使用扫描页的命令。
%    \begin{macrocode}
\newcommand{\buct@makedeclare}{
    \ifbuct@bachelor
        \centerline{\buct@dcl@titlefont\buct@dcl@title}\par\vspace{1em}
        \leftline{\buct@dcl@ideclarefont\buct@dcl@ideclare}%
        \buct@dcl@text
        \par\vspace{2em}\hfill{\buct@dcl@sign}
    \else{
        \thispagestyle{empty}
        \linespread{1.5534}
        \setlength{\parskip}{9pt}
        \begin{center}
            \buct@dcl@titlefont\buct@dcl@title
        \end{center}

        \buct@dcl@textfont\buct@dcl@text

        \vspace{6pt}\buct@sign@author\vspace{6pt}

        \begin{center}
            \buct@auth@titlefont\buct@auth@title
        \end{center}

        \buct@auth@textfont\buct@auth@text

        \vspace{6pt}\buct@sign@author

        \vspace{6pt}\buct@sign@supervisor
    }\fi
    \clearpage\normalsize
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makedeclare}
% 定义一个带可选参数的命令 \cs{makedeclare}，可选参数为扫面页的相对路径；
% 若不加参数则使用 \cs{buct@makedeclare} 来插入文本。
%    \begin{macrocode}
\NewDocumentCommand{\makedeclare}{ o }{%
    \buct@pdfmark{\ifbuct@bachelor\buct@dcl@title\else\buct@dcl@pdf\fi}{declare}
    \IfNoValueTF{#1}{\buct@makedeclare}{%
        \includepdf[pages=-]{#1}
    }
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{任务书}
% \begin{environment}{taskbook}
% 环境 \env{taskbook} 用于插入任务书部分，该部分排在诚信声明之后。
%    \begin{macrocode}
\ifbuct@bachelor
    \newenvironment{taskbook}{%
        \cleardoublepage%
        \buct@pdfmark{\buct@task@pdf}{taskbook}%
        \section*{\buct@task@title}%
    }{\clearpage}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\buct@ul}
% “任务书”开头部分的下划线。
%    \begin{macrocode}
    \NewDocumentCommand{\buct@ul}{ o m }{\underline{\makebox[#1][c]{#2}}}
%    \end{macrocode}
% \end{macro}
%
% 在这个环境中有如下的排版命令和环境：
% \begin{macro}{\taskinfo*}
% 命令 \cs{taskinfo} 或 \cs{taskinfo*}：
% 后者是学校样例的实现，但是由于换行、空位少造成书写不便，且不甚美观；
% 而前者比后者多了一次换行且设置了文本和横线的对齐，适合文字较多时使用。
%    \begin{macrocode}
    \NewDocumentCommand\taskinfo{ s }{%
        \noindent%
        \begin{minipage}{\textwidth}%
            \punctstyle{plain}\linespread{1.94}%
                \buct@task@ctitle\buct@ul[27em]{\buct@ctitle}\\[3pt]
            \IfBooleanTF{#1}{% less lines break
                \buct@task@school\buct@ul[10em]{\buct@school}\quad
                \buct@task@major\buct@ul[10em]{\buct@major}\quad
                \buct@task@class\buct@ul[5em]{\buct@class}\\[3pt]
                \buct@task@student\buct@ul[5em]{\buct@cauthor}\quad
                \buct@task@supervisor\buct@ul[6em]{\buct@supervisor}\quad
                \buct@task@msupervisor\buct@ul[4em]{\buct@msupervisor}%
            }{% more lines break
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\taskinfo}
% 更多的换行，相比之下会更加整齐一些。
%    \begin{macrocode}
                \buct@task@school\buct@ul[15em]{\buct@school}\qquad
                \buct@task@major\buct@ul[13em]{\buct@major}\\[3pt]
                \buct@task@class\buct@ul[15em]{\buct@class}\qquad
                \buct@task@student\buct@ul[13em]{\buct@cauthor}\\[3pt]
                \buct@task@supervisor\buct@ul[8em]{\buct@supervisor}\qquad
                \buct@task@msupervisor\buct@ul[10em]{\buct@msupervisor}%
            }
        \end{minipage}\vspace{1.5em}
    }
%    \end{macrocode}
% \end{macro}
%
% 命令 \cs{taskitem} ：用于排版任务书中“设计（论文）的主要任务及目标”等四项标题。
% 该命令只能使用四次，超过则会报错且给予修正提示。
%    \begin{macrocode}
    \newcounter{taskitemcnt}
    \newcommand{\buct@taskitem}{%
        \stepcounter{taskitemcnt}%
        \ifcase\value{taskitemcnt}\relax\or%
        {\buct@task@itema}\or%
        {\buct@task@itemb}\or%
        {\buct@task@itemc}\or%
        {\buct@task@itemd}\else%
        \ClassError{buctthesis}{Too many \protect\taskitem\space used}%
        {Keep \protect\taskitem\space no more than 4 times.}\fi
    }
%    \end{macrocode}
% \begin{macro}{\taskitem}
% 这里相比学校的样例，段前增加了一点空白。
%    \begin{macrocode}
    \newcommand{\taskitem}{\vspace{1em}\noindent\buct@taskitem\par}
\fi
%    \end{macrocode}
% \end{macro}
%
%
% \begin{environment}{bibenumerate}
% 定义 \env{bibenumerate} 环境：可以生成带有方括号、阿拉伯数字的列表。
% 该命令可用于本科的“任务书”中罗列主要参考文献，
% 亦可用于硕博“研究成果及发表的学术论文”中罗列发表的论文与专利。
%    \begin{macrocode}
\newenvironment{bibenumerate}{%
    \begin{enumerate}[label={[\arabic*]},leftmargin=3em]
}{\end{enumerate}}
%    \end{macrocode}
% \end{environment}
%
% \subsubsection{摘要}
% \begin{environment}{cabstract}
% 中文摘要，使用 \env{cabstract} 环境。
%    \begin{macrocode}
\ifbuct@bachelor
    \newenvironment{cabstract}{%
        \cleardoublepage
        \buct@pdfmark{\buct@cabstract@title}{cabstract}
        \begin{center}
            \buct@abs@titfont\buct@ctitle
            \vskip22pt
            \buct@abs@infofont\buct@cauthor\quad%
            \buct@class\quad\buct@studentid\quad%
            \buct@supervisor@title\buct@supervisor%
            \vskip22pt
            \buct@abs@absfont\buct@cabstract@title
        \end{center}\par\vspace{18pt}
    }{\vskip1em\noindent\buct@keywordsfont\buct@ckeywords@title\buct@ckeywords}
\else
    \newenvironment{cabstract}{%
        \cleardoublepage
        \buct@pdfmark{\buct@cabstract@title}{cabstract}\markboth{\buct@cabstract@title}{}
        \begin{center}
            \buct@abs@titfont\buct@ctitle
            \vskip24pt
            \buct@abs@absfont\buct@cabstract@title
        \end{center}\par\vspace{12pt}
        \buct@abs@textfont
    }{\vskip24pt%
    \noindent\buct@keywords@titfont\buct@ckeywords@title\buct@keywords@font\buct@ckeywords}
\fi
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{eabstract}
% 英文摘要，使用 \env{eabstract} 环境。
%    \begin{macrocode}
\ifbuct@bachelor
    \newenvironment{eabstract}{%
        \cleardoublepage%
        \buct@pdfmark{\buct@eabstract@title}{abstracten}
        \begin{center}
            \buct@abs@titfonten\buct@etitle\vskip22pt
            \buct@abs@absfonten\buct@eabstract@title
        \end{center}
        \par\vspace{22pt}
    }{\vskip1em\noindent\buct@keywordsfonten \buct@ekeywords@title\buct@ekeywords}
\else
    \newenvironment{eabstract}{%
        \cleardoublepage%
        \buct@pdfmark{\buct@eabstract@title}{eabstract}\markboth{\buct@eabstract@title}{} 
            \begin{center}
                \setlength{\leftskip}{3em plus 1em minus .5em}
                \setlength{\rightskip}{3em plus 1em minus .5em}
                \buct@abs@titfonten\buct@etitle\vskip76pt
                \buct@abs@absfonten\buct@eabstract@title
            \end{center}\par\vspace{40pt}
        \buct@abs@textfont
    }{\vskip48pt%
    \noindent\buct@keywords@titfonten\buct@ekeywords@title\buct@keywords@fonten\buct@ekeywords}
\fi
%    \end{macrocode}
% \end{environment}
%
% \subsubsection{目录}
% 正文中三级小节（subsubsubsection）不予编号；
% 本科：编目层次至小节（subsection），硕博：编目层次至小小节（subsubsection）。
%    \begin{macrocode}
\setcounter{secnumdepth}{3}
\ifbuct@bachelor
    \setcounter{tocdepth}{2}
\else
    \setcounter{tocdepth}{3}
\fi
%    \end{macrocode}
%
% \begin{macro}{\tableofcontents}
% 重定义中文目录标题样式。该部分编入书签，同时在目录中不出现“目录”项。
%    \begin{macrocode}
\renewcommand\tableofcontents{%
    \cleardoublepage
    \pdfbookmark{\contentsname}{toc}%
    \chapter*{\buct@toc@tocfont\buct@content@title}%
    \ifbuct@bachelor\relax\else\markboth{\buct@content@title}\fi
    \@starttoc{toc}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\tableofcontentsEN}
% 定义英文目录，条目格式与中文目录相同。
%    \begin{macrocode}
\ifbuct@bachelor\relax\else
    \newcommand\tableofcontentsEN{%
        \cleardoublepage
        \pdfbookmark{\econtentsname}{toce}%
        \chapter*{%
            \em\econtentsname%
            \ifbuct@bachelor\relax\else\markboth{\econtentsname}\fi%
        }%
        \@starttoc{toce}
    }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\buct@addengcontents}
% 加入英文目录项。
%    \begin{macrocode}
    \newcommand\buct@addengcontents[3]{%
        \addcontentsline{toce}{#1}{\protect\numberline{#3\@nameuse{the#1}}#2}
    }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\echapter}
% \begin{macro}{\esection}
% \begin{macro}{\esubsection}
% \begin{macro}{\esubsubsection}
% 定义将不同层次标题加入英文目录中的命令。
%    \begin{macrocode}
    \newcommand\echapter[1]{\buct@addengcontents{chapter}{#1}{\buct@toce@chapfont}}
    \newcommand\esection[1]{\buct@addengcontents{section}{#1}{}}
    \newcommand\esubsection[1]{\buct@addengcontents{subsection}{#1}{}}
    \newcommand\esubsubsection[1]{\buct@addengcontents{subsubsection}{#1}{}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bichapter}
% \begin{macro}{\bisection}
% \begin{macro}{\bisubsection}
% \begin{macro}{\bisubsubsection}
% 类似 \cs{bicaption} 可接受两个参数来生成双语图标注一样，定义 \cs{bichapter} 命令从而更加方便一些。
% \emph{以下定义的命令不可带星号。}
%    \begin{macrocode}
    \NewDocumentCommand{\bichapter}{ o m m }{\chapter[#1]{#2}\echapter{#3}}
    \NewDocumentCommand{\bisection}{ o m m }{\section[#1]{#2}\esection{#3}}
    \NewDocumentCommand{\bisubsection}{ o m m }{\subsection[#1]{#2}\esubsection{#3}}
    \NewDocumentCommand{\bisubsubsection}{ o m m }{\subsubsection[#1]{#2}\esubsubsection{#3}}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% 使用 \pkg{titletoc} 宏包的 \cs{titlecontents} 命令来设置目录项格式。
% 对于硕博论文而言，以下设置会同时影响中文和英文目录。
% \cs{titlecontents} 的语法为：
%
% \begin{syntax}{titlecontents}
% \marg{标题层级}\oarg{左侧间距}
%
% \marg{上间距}
% \marg{标题格式}\marg{引导线与页码}\oarg{下间距}
% \end{syntax}
%
%    \begin{macrocode}
\ifbuct@bachelor
    \titlecontents{chapter}[0em]
        {\buct@toc@chapfont\vspace{3pt}}
        {\thecontentslabel\quad}{}
        {\titlerule*[.4em]{$\cdot$}\bfseries\contentspage}
    \titlecontents{section}[2em]
        {\buct@toc@secfont\vspace{-3pt}}
        {\thecontentslabel\quad}{}
        {\titlerule*[.5em]{$\cdot$}\contentspage}
    \titlecontents{subsection}[5em]
        {\buct@toc@ssecfont\vspace{-3pt}}
        {\thecontentslabel\quad}{}
        {\titlerule*[1em]{$\cdot$}\contentspage}
\else
    \titlecontents{chapter}[0em]
        {\buct@toc@chapfont\vspace{3pt}}
        {\thecontentslabel\quad}{}
        {\titlerule*[.25em]{$\cdot$}\bfseries\contentspage}
    \titlecontents{section}[2.25em]
        {\buct@toc@secfont\vspace{-3pt}}
        {\thecontentslabel\quad}{}
        {\titlerule*[.5em]{$\cdot$}\contentspage}
    \titlecontents{subsection}[5em]
        {\buct@toc@ssecfont\vspace{-3pt}}
        {\thecontentslabel\quad}{}
        {\titlerule*[1em]{$\cdot$}\contentspage}
    \titlecontents{subsubsection}[8.5em]
        {\buct@toc@sssecfont\vspace{-3pt}}
        {\thecontentslabel\quad}{}
        {\titlerule*[1em]{$\cdot$}\contentspage}
\fi
%    \end{macrocode}
%
% 通过重定义 \pkg{natbib} 宏包的 \cs{bibsection}，实现参考文献的编目。
%    \begin{macrocode}
\renewcommand{\bibsection}{
    \chapter*{\bibname}
    \addcontentsline{toc}{chapter}{\bibname}
    \ifbuct@bachelor\relax\else
        \addcontentsline{toce}{chapter}{\buct@toce@chapfont\buct@ebib@title}
        \markboth{\bibname}
    \fi
}
%    \end{macrocode}
%
% 对于本科的设计图纸的两种编目方式：一是加入主目录，另一种是单独生成目录。
%
% \begin{macro}{\dcaption}
% 定义命令 \cs{dcaption}，在 \cs{caption} 的基础上将设计图纸加入主目录。
% 模板设置“设计图纸”的目录级别和小节相同，但却没有小节的编号。
% 为保证在目录中的文字对齐，所以增加其缩进。
%    \begin{macrocode}
\ifbuct@bachelor
    \newcommand{\dcaption}[1]{%
        \caption{#1}\addcontentsline{toc}{subsection}{%
            \hspace{2.5em}\buct@dfigurename~\thefigure\hspace{1em}{#1}%
        }
    }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\buct@listof}
% 另外新定义“设计图纸目录”。如果需要单独编目，可使用 \cs{listofdesignfigures} 命令生成。
% 这里按照 \pkg{float}宏包的 \cs{listof} 命令来定义我们的 \cs{buct@listof} 命令。
%    \begin{macrocode}
    \newcommand{\buct@listof}[2]{%
        \xpatchcmd{\@dottedtocline}{\hbox{.}}{\hbox{$\cdot$}}{}{}
        \renewcommand{\@dotsep}{1.7}%
        \@ifundefined{ext@#1}{\float@error{#1}}{%
            \@namedef{l@#1}{\@dottedtocline{1}{0em}{2em}}
            \float@listhead{\buct@toc@tocfont{}#2}%
            \begingroup\setlength{\parskip}{\z@}%
            \buct@toc@dsgfigfont\@starttoc{\@nameuse{ext@#1}}%
            \endgroup%
        }
    }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\listofdesignfigures}
% “设计图纸目录”跟主目录相似。
%    \begin{macrocode}
    \newcommand{\listofdesignfigures}{%
        \cleardoublepage%
        \buct@pdfmark{\buct@dfigure@content@title}{dfigure}%
        \buct@listof{dfigure}{\buct@dfigure@content@title}
    }
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{前言}
% \begin{environment}{foreword}
% 仅本科。定义环境 \env{foreword} 插入前言部分。
%    \begin{macrocode}
\newenvironment{foreword}{%
    \cleardoublepage
    \buct@pdfmark{\buct@foreword@title}{foreword}
    \chapter*{\buct@foreword@title}
}{}
%    \end{macrocode}
% \end{environment}
%
% \subsection{主文档部分}
% \subsubsection{行距设置}
% 计算公式：
% \[
%     1.2 \times \meta{LineSpread} \times \meta{FontSize} = \meta{BaselineSkip}
% \]
% 其中，正文的 \meta{FontSize} 为小四号，而 \meta{BaselineSkip} 取
% 本科行距 22 磅、硕博 20 磅，故可求得 \meta{LineSpread}。
%    \begin{macrocode}
\ifbuct@bachelor
    \linespread{1.5221}
\else
    \linespread{1.3837}
\fi
%    \end{macrocode}
%
% \subsubsection{标题格式}
%    \begin{macrocode}
\ifbuct@bachelor
    \ctexset{%
        chapter = {%
            name        = {第,章},
            number      = \arabic{chapter},
            format      = \buct@chapfont,
            beforeskip  = 12 pt,
            afterskip   = 32 pt,
            fixskip     = true,
            aftername   = \qquad,
        },
        section = {%
            name        = {第,节},
            format      = \buct@secfont,
            aftername   = \quad,
            beforeskip  = 29 pt,
            afterskip   = 32 pt,
            fixskip     = true,
        },
        subsection = {%
            format      = \buct@ssecfont,
            aftername   = \quad,
            beforeskip  = 3 pt,
            afterskip   = 3 pt,
        },
        subsubsection = {%
            name        = {(,)},
            format      = \buct@sssecfont,
            number      = \arabic{subsubsection},
            beforeskip  = 3 pt,
            afterskip   = 3 pt,
            aftername   = \hspace{0.5em},
            indent      = 0.5em,
        },
    }
\else
    \ctexset{%
        chapter = {%
            name        = {第,章},
            number      = \chinese{chapter},
            format      = \buct@chapfont,
            beforeskip  = 12 pt,
            afterskip   = 46 pt,
            fixskip     = true,
            aftername   = \qquad,
        },
        section = {%
            format      = \buct@secfont,
            aftername   = \quad,
            beforeskip  = 26 pt,
            afterskip   = 28 pt,
            fixskip     = true,
        },
        subsection = {%
            format      = \buct@ssecfont,
            beforeskip  = 3 pt,
            afterskip   = 3 pt,
        },
        subsubsection = {%
            format      = \buct@sssecfont,
            beforeskip  = 3 pt,
            afterskip   = 3 pt,
        },
    }
\fi
%    \end{macrocode}
%
% \subsubsection{列表环境}
% \begin{environment}{enumerate}
% \begin{environment}{itemize}
% \begin{environment}{description}
% 使用 \pkg{enumitem} 宏包分别设置编号列表、无编号列表、描述列表环境的间距。
% 这里将三种列表默认增加的垂直间距全部清除，即各行间距与正文行间距相同，以符合中文习惯。
%
% 如果一级列表环境作为标题（对应《本科规范》中的五级标题，即带圈序号），
% 则不设置加粗、不增加段间距。由于列表间的垂直间距减小了，所以
% 相应地稍微调小列表序号和文字之间的距离，使得文字更紧凑。
%
% 另外，一级编号列表环境的序号改为 \pkg{pifont} 宏包提供的带圈数字，
% 二级及之后的列表、无编号列表保持默认设置。
%    \begin{macrocode}
\setlist{%
    leftmargin = 2em,
    nosep,
}
\setlist[enumerate,1]{%
    label    = \lower 0.1em\hbox{\large{\ding{\numexpr191+\value{enumi}}}},
    labelsep = 2pt,
}
\setlist[enumerate,2]{%
    labelsep = 6pt,
}
\setlist[description]{%
    labelsep = 1em,
}
%    \end{macrocode}
% \end{environment}
% \end{environment}
% \end{environment}
%
% \subsubsection{数学类}
% 使用 \pkg{unicode-math} 宏包配置数学标准字形、粗体字形，并设置偏微分算子为直立体。
%    \begin{macrocode}
\unimathsetup{
    math-style  = ISO,
    bold-style  = ISO,
    partial     = upright,
}
%    \end{macrocode}
%
% 修改 \cs{mathbb}，使得字母显示正确。
%    \begin{macrocode}
\let\mathbb\relax
\DeclareMathAlphabet{\mathbb}{U}{msb}{m}{n}%
%    \end{macrocode}
%
% 使用 \pkg{amsthm} 宏包来进行定理类环境的格式控制，并预设如下定理类环境。编号跨章重置计数。
%    \begin{macrocode}
\newtheoremstyle{buctthm}%  name
{3pt}%                      Space above
{3pt}%                      Space below
{}%                         Body font
{}%                         Indent amount
{\bfseries}%                Theorem head font
{:}%                        Punctuation after theorem head
{.5em}%                     Space after theorem head
{}%                         Theorem head spec
\theoremstyle{buctthm}
\newtheorem{axiom}{公理}[chapter]
\newtheorem{theorem}{定理}[chapter]
\newtheorem{corollary}{推论}[chapter]
\newtheorem{remark}{注解}[chapter]
\newtheorem{assumption}{假设}[chapter]
\newtheorem{definition}{定义}[chapter]
\newtheorem{property}{性质}[chapter]
\newtheorem{proposition}{命题}[chapter]
\newtheorem{lemma}{引理}[chapter]
%    \end{macrocode}
%
% \begin{environment}{proof}
% 按照 \pkg{amsthm} 宏包说明重定义 \env{proof}：
%    \begin{macrocode}
\renewenvironment{proof}[1][\proofname]{\par
    \pushQED{\qed}%
    \normalfont\topsep6\p@\@plus6\p@\relax
    \trivlist
    \item\relax
    {#1\@addpunct{.}}\hspace\labelsep\ignorespaces
}{\popQED\endtrivlist\@endpefalse}
%    \end{macrocode}
% \end{environment}
%
% \subsubsection{部分宏包汉化设置}
% 对 \pkg{siunitx} 宏包汉化处理，并将连接符改为“$\sim$”，符合中文习惯。
%    \begin{macrocode}
\sisetup{%
    list-final-separator = { 和 },
    list-pair-separator = { 和 },
    range-phrase = {$\sim$},
}
%    \end{macrocode}
%
% \subsubsection{浮动体}
% \begin{environment}{dfigure}
% 本科：
% 使用 \pkg{float} 宏包新定义浮动体环境 \env{dfigure}，用于排版设计图纸。
% 设计图纸与普通插图的区别在于：
% \begin{itemize}
%     \item 标签不同，如：“设计图纸 1-1” 与 “图 1-1”；
%     \item 编号相互独立；
%     \item 仅设计图纸编入目录，且此目录独立于主目录。
% \end{itemize}
%
%    \begin{macrocode}
\ifbuct@bachelor
    \newfloat{dfigure}{htbp}{lodf}[chapter]
    \floatname{dfigure}{\buct@dfigurename}
%    \end{macrocode}
% \end{environment}
%
% 硕博：
% 使用 \pkg{bicaption} 宏包设置双语标题，其中第二语言为英语。
%
%    \begin{macrocode}
\else
    \DeclareCaptionOption{english}[]{
        \renewcommand\figurename{\buct@bifigure@name}
        \renewcommand\tablename{\buct@bitable@name}
    }
    \captionsetup[bi-second]{english}
\fi
%    \end{macrocode}
%
% 《研究生规范》中规定表格单元格里的字号为五号，而未规定行距，这里保留前设的伸缩因子。
% 其中 \cs{AtBeginEnvironment} 是 \pkg{etoolbox} 宏包中的命令，可给环境打补丁。
%
%    \begin{macrocode}
\ifbuct@bachelor\relax\else
    \AtBeginEnvironment{tabular}{\buct@floatfont}
    \AtBeginEnvironment{tabularx}{\buct@floatfont}
\fi
%    \end{macrocode}
%
% 对于 \pkg{longtable} 宏包的设置则稍有不同：
% 在“符号说明表”中我们嵌套了 \env{longtable} 环境，但其中的字号仍应为小四号。
% 因此这里需要保留原先的定义。
%    \begin{macrocode}
    \let\oldlongtable\longtable
    \let\endoldlongtable\endlongtable
\ifbuct@bachelor\relax\else
    \def\longtable{\zihao{5}\oldlongtable}
    \AtEndEnvironment{longtable}{\normalsize}
\fi
%    \end{macrocode}
%
% 设置插图的文件路径。
%    \begin{macrocode}
\graphicspath{{figure/}}
%    \end{macrocode}
%
% 使用 \pkg{caption} 宏包重定义图、表等浮动体的标签样式。
%
%    \begin{macrocode}
\renewcommand{\captionfont}{\buct@float@captionfont}
\renewcommand{\captionlabelfont}{\buct@float@captionfont}
\DeclareCaptionLabelSeparator{capspace}{\quad}
\captionsetup{labelsep=capspace}
\captionsetup[table]{%
    position  = top,
    aboveskip = 0.5em,
    belowskip = 0.5em,
}
\captionsetup[figure]{%
    position  = bottom,
    aboveskip = 0.5em,
    belowskip = -0.5em,
}
\captionsetup[dfigure]{%
    position  = bottom,
    aboveskip = 1em,
    belowskip = 1em,
}
%    \end{macrocode}
%
% 更改图、表、公式和代码的编号格式。其中重定义 \cs{thelstlisting} 须在 \cs{AtBeginDocument} 中。
%    \begin{macrocode}
\AtBeginDocument{%
    \renewcommand{\thesubtable}{(\alph{subtable})}
    \renewcommand{\thetable}{\thechapter-\arabic{table}}
    \renewcommand{\thesubfigure}{(\alph{subfigure})}
    \renewcommand{\thefigure}{\arabic{chapter}-\arabic{figure}}
    \ifbuct@bachelor
        \renewcommand{\thedfigure}{\thechapter-\arabic{dfigure}}
        \renewcommand{\theequation}{\thechapter-\arabic{equation}}
    \else
        \renewcommand{\eqref}[1]{\equationname~\textup{(\ref{#1})}}
        \renewcommand{\theequation}{\thechapter-\arabic{equation}}
    \fi
    \renewcommand{\thelstlisting}{\thechapter-\arabic{lstlisting}}
}
%    \end{macrocode}
%
% \subsubsection{数学公式}
% 硕博公式需要加入点线连接公式与编号。这里通过重定义 \file{source2e}
% 中的 \env{equation} 环境，故仅在 \env{equation} 环境中生效。
%    \begin{macrocode}
\ifbuct@bachelor\relax\else
    \xpatchcmd{\dotfill}{.44em}{.3em}{}{}
    \renewenvironment{equation}{
        \@beginparpenalty\predisplaypenalty
        \@endparpenalty\postdisplaypenalty
        \refstepcounter{equation}%
        \trivlist \item[]\leavevmode
        \hb@xt@\linewidth\bgroup $\m@th% $
        \displaystyle\hfill}
        {$\;\dotfill % $
        \displaywidth\linewidth\hbox{\@eqnnum}%
        \egroup
        \endtrivlist}
\fi
%    \end{macrocode}
%
% \subsubsection{代码块}
%    \begin{macrocode}
\lstset{%
    aboveskip        = 0.5em,
    belowskip        = 0.5em,
    tabsize          = 4,
    basicstyle       = \buct@codefont,
    frame            = single,
    basewidth        = {.5em,.4em},
    xleftmargin      = 1.5em,
    xrightmargin     = 1.5em,
    commentstyle     = \buct@codecomfont,
    keywordstyle     = \buct@codekeyfont,
    backgroundcolor  = \color{lightgray!10},
    showtabs         = false,
    showspaces       = false,
    showstringspaces = false,
    captionpos       = t,
    breaklines       = true,
    numbers          = left,
    numberstyle      = \tiny,
    numbersep        = 6 pt,
    stepnumber       = 1,
    extendedchars    = false,
    escapechar       = {@*},
}
%    \end{macrocode}
%
% \subsection{后置部分}
% 与前言不同的是，这几部分模板默认编入目录。
%
% \begin{environment}{conclusion}
% 结论，仅本科。
%    \begin{macrocode}
\ifbuct@bachelor
    \newenvironment{conclusion}{%
        \chapter*{\buct@concl@title}
        \addcontentsline{toc}{chapter}{\buct@concl@title}
    }{}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{translation}
% 翻译，仅本科。
%    \begin{macrocode}
    \newenvironment{translation}{%
        \chapter*{\buct@trans@title}
        \addcontentsline{toc}{chapter}{\buct@trans@title}
    }{}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{achievements}
% 研究成果及发表的学术论文，仅硕博。
%    \begin{macrocode}
\else
    \newenvironment{achievements}{%
        \cleardoublepage
        \chapter*{\buct@achi@title}
        \markboth{\buct@achi@title}{}
        \addcontentsline{toc}{chapter}{\buct@achi@title}
        \addcontentsline{toce}{chapter}{\buct@toce@chapfont\buct@eachi@title}
    }{}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{resume}
% 作者及导师简介，仅硕博。
%    \begin{macrocode}
    \newenvironment{resume}{%
        \cleardoublepage
        \chapter*{\buct@resu@title}
        \markboth{\buct@resu@title}{}
        \addcontentsline{toc}{chapter}{\buct@resu@title}
        \addcontentsline{toce}{chapter}{\buct@toce@chapfont\buct@eresu@title}
    }{}
\fi
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{acknowledgement}
% 致谢。
%    \begin{macrocode}
\newenvironment{acknowledgement}{%
    \chapter*{\buct@ack@title}
    \ifbuct@bachelor\relax\else
        \markboth{\buct@ack@title}{}
        \addcontentsline{toce}{chapter}{\buct@toce@chapfont\buct@eack@title}
    \fi
    \addcontentsline{toc}{chapter}{\buct@ack@title}
}{}
%    \end{macrocode}
% \end{environment}
%
% \subsubsection{符号说明表}
% \begin{environment}{denotation}
% 关于章节编目同前。这里使用一个可跨页的无线长表格。
% 为了防止符号较长，这里定义的环境需要一个可选参数用于在必要时控制第二列列宽。
%    \begin{macrocode}
\NewDocumentEnvironment{denotation}{ O{10cm} +b }{%
    \cleardoublepage
    \chapter*{\buct@deno@title}%
    \ifbuct@bachelor
        \addcontentsline{toc}{chapter}{\buct@deno@title}
    \else
        \buct@pdfmark{\buct@deno@title}{denotation}
        \markboth{\buct@deno@title}{}
    \fi
    \vspace{-1em}%
    \begin{oldlongtable}[c]{l@{\extracolsep{3em}}p{#1}}
        #2
}{\end{oldlongtable}}
%    \end{macrocode}
% \end{environment}
%
% \subsubsection{参考文献}
% 一方面，主文件中调用了符合要求的参考文献格式控制文件，使参考文献章节的格式规范化；
% 另一方面，调用 \pkg{gbt7714}（和 \pkg{natbib} ）宏包时已经填入相关选项，
% 在文章中引用文献的格式也符合了要求。这里将本科模板罗列的各条参考文献之间距离稍微调小一些，而将硕博模板字号设为 5 号，行距 20 磅。
%    \begin{macrocode}
\ifbuct@bachelor
    \setlength{\bibsep}{3pt}
\else
    \setlength{\bibsep}{0pt}
    \renewcommand\bibfont{\linespread{1.5814}\zihao{5}}
\fi
%    \end{macrocode}
%
% \subsection{其他设置}
% \subsubsection{强调}
% \begin{macro}{\emph}
% 中西文统一使用粗体。
%    \begin{macrocode}
\renewcommand{\emph}[1]{\textbf{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\em}
%    \begin{macrocode}
\renewcommand{\em}{\bfsong}
%    \end{macrocode}
% \end{macro}

% \subsubsection{脚注}
% \begin{macro}{\footnote}
% 使用带圈圈的脚注。尽管 \LaTeX\ 自带了 \cs{textcircled} 命令，但是效果并不如意。
% 为了和一级列表环境的序号区分，这里使用 \pkg{tikz} 宏包来绘制一个围着阿拉伯数字脚注的圈。
% 为了突出标号以便更加明确、清楚地显示，对编号设置了悬挂缩进。
%    \begin{macrocode}
\newcommand{\buct@ftntcircled}[1]{%
    \lower 0.15em\hbox{%
        \tikz\draw (0pt, 0pt) circle (0.4 em) node {#1};%
    }%
}
\renewcommand\thefootnote{\protect\buct@ftntcircled{\tiny\arabic{footnote}}}
\renewcommand{\@makefntext}[1]{%
    \setlength{\leftskip}{1.5\ccwd}%
    \noindent\llap{\lower 1pt \hbox{\@thefnmark}\,}#1%
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{超链接}
% 实现PDF书签和交叉引用的跳转。
%    \begin{macrocode}
\urlstyle{same}
\hypersetup{%
    colorlinks         = true,
    bookmarksnumbered  = true,
    pdfhighlight       = /N,
    breaklinks         = true,
    citecolor          = cyan,
}
%    \end{macrocode}
%
% 根据模板文档类是否打开 \opt{submit} 选项，设置是否关闭超链接颜色。
%    \begin{macrocode}
\ifbuct@submit
    \hypersetup{hidelinks}
\fi
%    \end{macrocode}
%
% 根据模板文档类是否打开 \opt{debugger} 选项，设置是否标注行号。
%    \begin{macrocode}
\ifbuct@debugger
    \AtBeginDocument{\linenumbers}
\fi
%</class>
%    \end{macrocode}
%
%
% \subsection{封面}
% 由于学校会统一印制封面，这里仅提供\emph{硕博论文封面}的一个参考实现。
%    \begin{macrocode}
%<*cover>
\ProvidesClass{buctcover}[2021/04/24 Cover Maker for BUCTthesis]
\RequirePackage{ifxetex}
\RequireXeTeX
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
    family   = buct,
    prefix   = buct@,
    setkeys  = \kvsetkeys,
}
\newif\ifbuct@bachelor\buct@bachelorfalse
\newif\ifbuct@master\buct@masterfalse
\newif\ifbuct@doctor\buct@doctorfalse
\define@key{buct}{type}{\expandafter\csname buct@#1true\endcsname}
\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{ctexbook}}
\ProcessKeyvalOptions*
\PassOptionsToPackage{quiet}{xeCJK}
\LoadClass[zihao=-4]{ctexbook}
%    \end{macrocode}
%
% 目前封面的 \opt{type} 选项仅允许硕博。
%    \begin{macrocode}
\ifbuct@bachelor%
    \ClassError{buctcover}{%
        type `bachelor' is unavailable. \MessageBreak%
        type = [ master | doctor ]%
    }{}\else
    \ifbuct@master\relax\else
        \ifbuct@doctor\relax\else
            \ClassError{buctthesis}{%
                Specified thesis type is obligatory: \MessageBreak%
                type = [ master | doctor ]%
            }{}
\fi\fi\fi
%    \end{macrocode}
%
% 定义用于定义论文相关信息的内部命令。
% 与 \cls{buctthesis} 不同的是：这里仅能通过 \cs{coversetup} 定义论文信息。其中 \opt{titleA} 和 \opt{titleB} 分别用于封面标题的第一行与第二行。
%    \begin{macrocode}
\newcommand{\coversetup}[1]{\kvsetkeys{buct}{#1}}
\DeclareStringOption[学号未定义]{studentid}
\DeclareStringOption[题目首行未定义]{titleA}
\DeclareStringOption[题目次行未定义]{titleB}
\DeclareStringOption[专业未定义]{major}
\DeclareStringOption[作者未定义]{author}
\DeclareStringOption[导师未定义]{supervisor}
\DeclareStringOption[\the\year-\two@digits{\month}-\two@digits{\day}]{date}
%    \end{macrocode}
%
% 页边距设置。经过测量，各边距值比正文部分都要小。
%    \begin{macrocode}
\RequirePackage[a4paper,nomarginpar,
    top = 2.1cm, bottom = 2.2cm, left = 2cm, right = 2cm,
    headheight = 0cm, footskip = 0cm
]{geometry}
%    \end{macrocode}
%
% 载入表格、插图、计算尺寸的宏包。
%    \begin{macrocode}
\RequirePackage{array,graphicx,calc,hyperref}
%    \end{macrocode}
%
% 清空页眉页脚。
%    \begin{macrocode}
\pagestyle{empty}
%    \end{macrocode}
%
% 字体配置。
%
% 开启伪粗体，并且应比正文更粗一些。
%    \begin{macrocode}
\xeCJKsetup{EmboldenFactor=2.3}
%    \end{macrocode}
%
% 各种字体的声明与设置。分别是：中易宋体、中易黑体、华文行楷、中易楷体、方正小标宋和方正大标宋。
% 后二者需前往方正字库网站下载。
%    \begin{macrocode}
\setCJKmainfont{SimSun}[AutoFakeBold]
\setCJKsansfont{SimHei}[AutoFakeBold]
\newCJKfontfamily[xingkai]\xingkai{STXingkai}
\newCJKfontfamily[zhkai]  \zhkai  {KaiTi} [AutoFakeBold]
\newCJKfontfamily[xbsong] \xbsong {FZXiaoBiaoSong-B05S}
\newCJKfontfamily[dbsong] \dbsong {FZDaBiaoSong-B06S}
%    \end{macrocode}
%
% 标尺，用于调试。
%    \begin{macrocode}
% \usepackage[unit=cm,type=upperleft,hshift=0cm,vshift=0cm]{fgruler}
%    \end{macrocode}
%
% 定义下划线命令，这里利用了 \pkg{calc} 宏包的 \cs{widthof} 命令，
% 取 \cs{buct@titleA} （即首行标题）的长度，用以固定下划线的长度。
%    \begin{macrocode}
\newcommand\buct@title@ul[1]{%
    \CJKunderline{\makebox[\widthof{\buct@titleA\enspace}][l]{#1}}
}
%    \end{macrocode}
% 日期格式处理，将输入的 \cs{buct@date} 拆分。
%    \begin{macrocode}
\newcommand\buct@format@date[1]{%
    \edef\buct@@date{\buct@date}%
    \def\buct@@process@date##1-##2-##3\@nil{%
        #1{##1}{##2}{##3}%
    }%
    \expandafter\buct@@process@date\buct@@date\@nil
}
%    \end{macrocode}
%
% \cs{@zhdate} 命令接受三个数字，将“年”转换为中文数字串，“月”和“日”转换为中文数字；其中“年”中的 0 映射为“〇”而非“零”。
%    \begin{macrocode}
\newcommand\@zhdate[3]{%
    \Large\bfseries\zhkai\ziju{.1}%
    日\hspace{1.5\ccwd}期：\zhdigits{#1}年\zhnumber{#2}月\zhnumber{#3}日%
}
%    \end{macrocode}
%
% \begin{macro}{\buct@makecover}
% 定义 \cs{buct@makecover} 命令来生成封面。
%    \begin{macrocode}
\newcommand{\buct@makecover}{%
%    \end{macrocode}
%
% 封面右上角的“单位代码”和“学号”。
%    \begin{macrocode}
    \begin{table}[h]
        \renewcommand{\arraystretch}{1.3}
        \raggedleft\large
        \begin{tabular}{l@{}l}
            \xbsong 单位代码 & ：\CJKfamily+{zhsong}\mbox{10010}\\
            \xbsong 学\hspace{2\ccwd}号 & ：\CJKfamily+{zhsong}\mbox{\buct@studentid}\\
        \end{tabular}
    \end{table}
    \vspace{26bp}
%    \end{macrocode}
%
% 校徽与校名。前者是插图，后者是文字。
%    \begin{macrocode}
    \begin{minipage}[c][][c]{2.35cm}
        \includegraphics[width = 2.35cm]{BUCT-badge.pdf}
    \end{minipage}
    \qquad
    \begin{minipage}[c][2.35cm][c]{9cm}
        \ziju{-0.02}\xingkai\zihao{0}{北京化工大学}
    \end{minipage}
    \vspace{18bp}
%    \end{macrocode}
%
% 标题。
%    \begin{macrocode}
    \begin{center}
        % \ziju{-0.05}
        {\dbsong\fontsize{38bp}{60bp}\selectfont
        \ifbuct@master{硕}\else{博}\fi{}士研究生学位论文}
    \end{center}
        \vspace{76bp}
%    \end{macrocode}
%
% 论文信息。
%    \begin{macrocode}
    \begin{center}
        \fontsize{20}{36}\selectfont
%    \end{macrocode}
%
% 禁用下划线的断点，调整粗细。
%    \begin{macrocode}
        \xeCJKsetup{
            underline = {
                skip      = false, 
                thickness = 1.2pt,
            }
        }
%    \end{macrocode}
%
% 使用一个表格来排版论文的信息。
%    \begin{macrocode}
        \begin{tabular}{
            >{\begin{CJKfilltwosides}[b]{4\ccwd}\sffamily\bfseries}r%
            <{\end{CJKfilltwosides}}%
            @{}>{\enspace\zihao{3}\bfseries}l%
            <{\vspace{.2em}}%
        }
%    \end{macrocode}
%
% 题目需要手动断行，且长度控制在 \SI{36}{em} 以内。
% 因表格本身的横线与文字间距较大，这里采用下划线的方式来划线。
%    \begin{macrocode}
            题目     & \buct@title@ul{\buct@titleA}\\
                    &\buct@title@ul{\buct@titleB}\\
            专业     & \buct@title@ul{\zihao{4}\buct@major}\\
            研究生   & \buct@title@ul{\zihao{4}\buct@author}\\
            指导教师 & \buct@title@ul{\zihao{4}\buct@supervisor}\\
        \end{tabular}
    \end{center}
%    \end{macrocode}
%
% 在页面底部书写日期。
%    \begin{macrocode}
    \vfill{%
        \begin{center}%
            \buct@format@date{\@zhdate}%
        \end{center}%
    }
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makecover}
% 文档命令 \cs{makecover} 类似 \cs{makedeclare}，
% 接受一个可选参数用于插入扫描页，否则调用 \cs{buct@makecover} 生成封面。
%    \begin{macrocode}
\ifbuct@bachelor\relax\else
    \NewDocumentCommand{\makecover}{ o }{%
    \hypertarget{cover}{}
    \pdfbookmark{封面}{cover}
        \IfNoValueTF{#1}{\buct@makecover}{%
            \includepdf[pages=-]{#1}
        }
    }
\fi
%</cover>
%    \end{macrocode}
% \end{macro}
%
%
% \iffalse
%    \begin{macrocode}
%<*manual>
\ProvidesPackage{manual}[2021/09/25 document style for BUCTthesis]
\RequirePackage{hypdoc}
\PassOptionsToPackage{AutoFakeSlant}{xeCJK}
\RequirePackage[UTF8, heading, fontset = none, linespread = 1.2,]{ctex}
\RequirePackage[toc]{multitoc}
\RequirePackage{
    listings,
    float,
    tabularx,
    booktabs,
    siunitx,
    unicode-math,
    xcolor,
    caption,
    enumitem,
    metalogo,
}
\RequirePackage[bottom,perpage]{footmisc}
\RequirePackage[
    a4paper,
    hmargin={40mm,20mm},vmargin={25mm,15mm},footskip=7mm,
]{geometry}

\ctexset{
    fontset,
    abstractname   = 简介,
    indexname      = 代码索引,
    section        = {
        format = \Large\bfseries\raggedright,
        name   = {第,节},
    },
}
\xeCJKDeclareCharClass{CJK}{"2460->"2469}
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{3}
\setmainfont{TeX Gyre Pagella}
\setmonofont[
    HyphenChar = None ,
    UprightFont=* Light, BoldFont=* Bold,
    SlantedFont=* Light Oblique]{CMU Typewriter Text}
\captionsetup{strut=off, labelsep=quad, labelfont+=bf}
\lstdefinestyle{base}{
    aboveskip        = 0 pt,
    belowskip        = 0 pt,
    tabsize          = 2,
    basicstyle       = \ttfamily\small,
    columns          = flexible,
    frame            = single,
    framerule        = 1 pt,
    xleftmargin      = 1 em,
    aboveskip        = 6 pt,
    belowskip        = 6 pt,
    commentstyle     = \slshape\color{gray},
    keywordstyle     = \color{blue},
    backgroundcolor  = \color{lightgray!10},
    showtabs         = false,
    showspaces       = false,
    showstringspaces = true,
    captionpos       = t,
    breaklines       = true,
    numbers          = none,
    extendedchars    = false,
    escapechar       = {@*},
    gobble           = 4,
}
\lstdefinestyle{latex}{%
    style=base,
    rulecolor=\color{cyan},
    language=[LaTeX]TeX,
}
\lstdefinestyle{shell}{%
    style=base,
    rulecolor=\color{violet!65},
    language=bash,
}
\lstnewenvironment{latex}{\lstset{style=latex}}{}
\lstnewenvironment{shell}{\lstset{style=shell}}{}
\let\oldCodelineNo\theCodelineNo
\def\theCodelineNo{\textcolor{gray}{\oldCodelineNo}}
\setlist{
    leftmargin = 0em,
    nosep
}
\setlist[description]{%
    itemindent = 2.5em,
}
\setlist[enumerate]{%
    itemindent = 2em,
}
\newcommand\without\CJKsout
\newcommand\Arg[1]{ \texttt{\char`\{} \meta{#1} \texttt{\char`\}} }
\providecommand\marg[1]{ \Arg{#1} }
\providecommand\oarg[1]{ \texttt[ \meta{#1} \texttt] }
\providecommand\parg[1]{ \texttt( \meta{#1} \texttt) }
\DeclareRobustCommand{\opt}{\texttt}
\DeclareRobustCommand{\env}{\texttt}
\DeclareRobustCommand{\pkg}{\textsf}
\DeclareRobustCommand{\cls}{\textsf}
\DeclareRobustCommand{\file}{\textsf}
\def\DescribeOpt{\leavevmode\@bsphack%
    \begingroup\MakePrivateLetters\Describe@Opt}
\def\Describe@Opt#1{\endgroup%
        \marginpar{\raggedleft\PrintDescribeOpt{#1}}%
        \SpecialOptIndex{#1}\@esphack\ignorespaces}
\def\PrintDescribeOpt#1{\strut \MacroFont #1\ }
\def\SpecialOptIndex#1{\@bsphack%
    \begingroup%
        \HD@target%
        \let\HDorg@encapchar\encapchar%
        \edef\encapchar usage{%
            \HDorg@encapchar hdclindex{\the\c@HD@hypercount}{usage}%
        }%
    \@bsphack
    \index{#1\actualchar{\protect\ttfamily#1}
            (option)\encapchar usage}%
    \index{options:\levelchar#1\actualchar%
            {\protect\ttfamily#1}\encapchar usage}\@esphack%
    \endgroup\@esphack}
\NewDocumentEnvironment{syntax}{ m }{%
    \linespread{1}\xeCJKsetup{PunctStyle=plain}\xeCJKsetup{CJKecglue}%
    \cs{#1}\ignorespaces%
}{\vspace{0.5em}}
\def\glossaryname{版本历史}
\GlossaryPrologue{\section{\glossaryname}}
\IndexPrologue{%
    \clearpage\section{\indexname}
    \textit{意大利体的数字表示描述对应索引项的页码；
    带下划线的数字表示定义对应索引项的代码行号；
    罗马字体的数字表示使用对应索引项的代码行号。}
}
\def\IndexLayout{%
    \newgeometry{hmargin=15mm,vmargin={25mm,15mm},footskip=7mm}%
    \setlength\IndexMin{.5\textheight}%
    \ctexset{section/numbering=false}%
}
\hypersetup{
    pdftitle  = {BUCTthesis：北京化工大学学位论文模板},
    pdfauthor = {Miracle0565},
}
\CodelineIndex
\EnableCrossrefs
\RecordChanges
\endinput
%</manual>
%    \end{macrocode}
% \fi
%
%
% \Finale
\endinput