Debian Codegraph @

texmf-dist/source/latex/hitreport/hitreport.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2021 by Xiao Sun <[email protected]>
4 %
5 % This file may be distributed and/or modified under the conditions of
6 % the LaTeX Project Public License, either version 1.3c of this license
7 % or (at your option) any later version. The latest version of this
8 % license is in:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.3c or later is part of all distributions of LaTeX
13 % version 2005/12/01 or later.
14 %
15 % This work has the LPPL maintenance status `maintained'.
16 %
17 % \fi
18 %
19 % \iffalse
20 %<*driver>
21 \ProvidesFile{hitreport.dtx}[2021/01/14 1.0.0 Harbin Institute of Technology Report Template]
22 \documentclass{ltxdoc}
23 \usepackage{dtx-style}
24
25 \EnableCrossrefs
26 \CodelineIndex
27
28 \begin{document}
29 \DocInput{hitreport.dtx}
30 \end{document}
31 %</driver>
32 % \fi
33 %
34 % \CharacterTable
35 % {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
36 % 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
37 % Digits \0\1\2\3\4\5\6\7\8\9
38 % Exclamation \! Double quote \" Hash (number) \#
39 % Dollar \$ Percent \% Ampersand \&
40 % Acute accent \' Left paren \( Right paren \)
41 % Asterisk \* Plus \+ Comma \,
42 % Minus \- Point \. Solidus \/
43 % Colon \: Semicolon \; Less than \<
44 % Equals \= Greater than \> Question mark \?
45 % Commercial at \@ Left bracket \[ Backslash \\
46 % Right bracket \] Circumflex \^ Underscore \_
47 % Grave accent \` Left brace \{ Vertical bar \|
48 % Right brace \} Tilde \~}
49 %
50 % \DoNotIndex{\newenvironment,\@bsphack,\@empty,\@esphack,\sfcode}
51 % \DoNotIndex{\addtocounter,\label,\let,\linewidth,\newcounter}
52 % \DoNotIndex{\noindent,\normalfont,\par,\parskip,\phantomsection}
53 % \DoNotIndex{\providecommand,\ProvidesPackage,\refstepcounter}
54 % \DoNotIndex{\RequirePackage,\setcounter,\setlength,\string,\strut}
55 % \DoNotIndex{\textbackslash,\texttt,\ttfamily,\usepackage}
56 % \DoNotIndex{\begin,\end,\begingroup,\endgroup,\par,\\}
57 % \DoNotIndex{\if,\ifx,\ifdim,\ifnum,\ifcase,\else,\or,\fi}
58 % \DoNotIndex{\let,\def,\xdef,\edef,\newcommand,\renewcommand}
59 % \DoNotIndex{\expandafter,\csname,\endcsname,\relax,\protect}
60 % \DoNotIndex{\Huge,\huge,\LARGE,\Large,\large,\normalsize}
61 % \DoNotIndex{\small,\footnotesize,\scriptsize,\tiny}
62 % \DoNotIndex{\normalfont,\bfseries,\slshape,\sffamily,\interlinepenalty}
63 % \DoNotIndex{\textbf,\textit,\textsf,\textsc}
64 % \DoNotIndex{\hfil,\par,\hskip,\vskip,\vspace,\quad}
65 % \DoNotIndex{\centering,\raggedright,\ref}
66 % \DoNotIndex{\c@secnumdepth,\@startsection,\@setfontsize}
67 % \DoNotIndex{\ ,\@plus,\@minus,\p@,\z@,\@m,\@M,\@ne,\m@ne}
68 % \DoNotIndex{\@@par,\DeclareOperation,\RequirePackage,\LoadClass}
69 % \DoNotIndex{\AtBeginDocument,\AtEndDocument}
70 %
71 % \changes{v1.0.0}{2021/01/14}{Initial version}
72 %
73 % \GetFileInfo{\jobname.dtx}
74 %
75 % \def\indexname{索引}
76 % \def\glossaryname{修改记录}
77 % \IndexPrologue{\section{\indexname}}
78 % \GlossaryPrologue{\section{\glossaryname}}
79
80 % \title{\bfseries\color{violet} \hitreport: 哈尔滨工业大学本科生泛用报告}
81 % \author{孙骁 \\[5pt]\texttt{[email protected]}}
82 % \date{\fileversion\ (\filedate)}
83 % \maketitle\thispagestyle{empty}
84 %
85 % \begin{abstract}\noindent
86 % 此宏包旨在建立一个免于配置的、指令相对简单的哈尔滨工业大学作业、实验报告通用模板。
87 % \end{abstract}
88 %
89 %
90 % \vskip2cm
91 % \def\abstractname{免责声明}
92 % \begin{abstract}
93 % \noindent
94 % \begin{enumerate}
95 % \item 本模板的发布遵守 \LaTeX\ Project Public License,使用前请认真阅读协议内
96 % 容。
97 % \item \textbf{本模板为作者编写的报告模板,与哈尔滨工业大学官方没有任何关系}。本模板的格式无法兼顾所有课程要求,
98 % 但已经适配了绝大多数的需求场景。
99 % 任何使用本宏包进行实验报告制作时,请\textbf{务必根据课程要求进行写作}。
100 % 由于使用本模板而引起的作业验收问题,
101 % 均与本模板作者无关。
102 % \item 任何个人或组织以本模板为基础进行修改、扩展而生成的新的专用模板,
103 % 请严格遵守 \LaTeX\ Project Public License 协议。
104 % 由于违犯协议而引起的任何纠纷争端均与
105 % 本模板作者无关。
106 % \end{enumerate}
107 % \end{abstract}
108 %
109 % \clearpage
110 % \pagestyle{fancy}
111 % \begin{multicols}{2}[
112 % \setlength{\columnseprule}{.4pt}
113 % \setlength{\columnsep}{18pt}]
114 % \tableofcontents
115 % \end{multicols}
116 % \clearpage
117 %
118 % \section{模板介绍}
119 % \hitreport (\textbf{H}arbin \textbf{I}istitute of \textbf{T}echnology \LaTeX\ Versatile \textbf{Report} Template)是为哈尔滨工业大学一校三区的本科生设计的一个免于配置的作业、实验报告模板。希望它可以使你的作业或实验报告不会因形式上的缺陷导致评分的下降。
120 %
121 % 该文档格式基于 ctexbook, 主要完成了除了主体内容以外的几乎\textbf{全部}工作。同时,通过使用 Github 版本宏包,你还可以更好的管理自己的 \LaTeX 文档。
122 %
123 % 本文档将尽量完整的介绍模板的使用方法,如有不清楚之处可以参考示例文档或者根据第 节说明提问,有兴趣者都可以参与完善此手册,也非常欢迎在Github上提出Issues。
124 %
125 % \section{安装}
126 % \label{sec:installation}
127 % \subsection{CTAN}
128 % 本宏包已被收纳于 CTAN 中,凡安装完整版 Texlive 用户可直接使用:
129 % \begin{latex}
130 % \usepackage{hitreport}
131 % \end{latex}
132 % 进行写作,但是通常版本较旧,且不便更新。
133 %
134 % \subsection{Github}
135 % 想获得最新版本的请前往 Github 主页下载:
136 % \url{https://github.com/demerzelsun12/hitreport}
137 %
138 % 同时,面向 Github 版本的说明主要在 README.md 中,
139 % 如果使用的是 Github 版本,请阅读 README.md
140 %
141 % \subsection{Gitee}
142 % 为解决部分同学无法正常访问 GitHub 或者下载速度过慢的情况,
143 % 本模板在 Gitee 上也做同步更新,Gitee下载地址为:
144 % \url{https://gitee.com/demerzel/hitreport}
145 %
146 % 模板支持在 TeX Live、MacTeX 和 MIKTeX 平台下进行编译,
147 % 使用最新版本可以避免 bug。
148 %
149 % \subsection{模板的组成}
150 % 由于报告的短时性的特点,也方便更多零基础的同学使用本模板,
151 % 本模板进最大可能简化了非实际报告文字的配置部分。下表列出了模板的主要文件及其功能介绍:
152 %
153 % \begin{longtable}{l|p{8cm}}
154 % \toprule
155 % {\heiti 文件(夹)} & {\heiti 功能描述}\\\midrule
156 % \endfirsthead
157 % \midrule
158 % {\heiti 文件(夹)} & {\heiti 功能描述}\\\midrule
159 % \endhead
160 % \endfoot
161 % \endlastfoot
162 % hitreport.ins & \textsc{DocStrip} 驱动文件(开发用) \\
163 % hitreport.dtx & \textsc{DocStrip} 源文件(开发用)\\\midrule
164 % ref/ & 示例文档参考文献目录 \\
165 % figures/ & 示例文档图片路径 \\
166 % data/ & 实例文档各章节路径 \\
167 % photo/ & 模板封面引用图片路径 \\
168 % code/ & 示例文档引用代码路径 \\\midrule
169 % report.tex & 示例文档基本配置 \\
170 % hitreport.cls & 模板类文件 \\
171 % hitreport-example.tex & 示例文档主文件\\
172 % hitreport-example.pdf & 示例文档 \\
173 % hitsetup.tex & 示例文档基本配置\\\midrule
174 % Makefile & 自动运行脚本 \\
175 % latexmkrc & latexmk 配置文件 \\
176 % README.md & 说明文件 \\
177 % \textbf{hitreport.pdf} & 用户手册(本文档)\\ \bottomrule
178 % \end{longtable}
179 %
180 % 几点说明:
181 % \begin{itemize}
182 % \item \file{hitreport.cls} 可由 \file{hitreport.ins}
183 % 和 \file{hitreport.dtx} 生成,但为了降低新手用户的使用难度,故
184 % 将 \file{hitreport.cls} 文件一起发布。新手可直接下载 Release 版
185 % 本,Release 版本不包含 \file{hitreport.ins} 和
186 % \file{hitreport.dtx}。
187 % \item 使用模板文件或对模板文件进行修改前请阅读本文档:
188 % \file{hitreport.pdf}。
189 % \end{itemize}
190 %
191 %
192 % \subsection{生成模板}
193 % \label{sec:generate-cls}
194 % 模板的源文件(\file{hitreport.dtx})中包含了大量的注释,需要将注
195 % 释去掉生成轻量级的 \file{.cls} 文件供 \cs{documentclass} 调用。
196 % 使用Makefile或 \XeLaTeX 生成模板文件。
197 % \begin{shell}
198 % $ make cls
199 % \end{shell}
200 % 或
201 % \begin{shell}
202 % $ xelatex hitreport.ins
203 % \end{shell}
204 %
205 % \note[注意:]{如果没有生成的模板 \file{hitreport.cls} 文件
206 % (与 \file{hitreport-example.tex} 在同一目录下),
207 % \LaTeX{} 在编译时可能找到发行版中较旧版本的 \file{.cls},从而造成编译冲突。}
208 %
209 % \subsection{生成报告}
210 % \label{sec:gengrate-report}
211 % 本节介绍几种常见的生成报告的方法。用户可根据自己的情况选择。
212 %
213 % 在撰写报告时,需要注意,代码引用可以使用相对路径,但是图片引用则必须
214 % 放在 figures 文件夹下。如果需要对校徽以及校名图片名称进行修改,
215 % \file{hitreport.cls} 文件中相应位置也需要修改。
216 %
217 % 在撰写报告时,\textbf{不推荐}使用原有的 \file{hitreport-example.tex} 这一名称。
218 % 建议将其复制一份,改为其他的名字(如 \file{report.tex} 或者 \file{main.tex})。
219 % 需要注意,如果使用了来自 \file{data} 目录中的 \file{tex} 文件,
220 % 则重命名主文件后,其顶端的 \texttt{!TeX root} 选项也需要相应修改。
221 %
222 % \subsubsection{GNU make}
223 % \label{sec:make}
224 % 如果用户可以使用 GNU make 工具,这是最方便的办法。
225 % 所以 \hitreport 提供了 \file{Makefile}:
226 % \begin{shell}
227 % $ make report # 生成报告示例 hitreport-example.pdf
228 % $ make doc # 生成说明文档 hitreport.pdf
229 % $ make clean # 清理编译生成的辅助文件
230 % \end{shell}
231 %
232 % 需要注意,如果更改了主文件的名称,则需要修改 \file{Makefile} 顶端的 \texttt{REPORT} 变量定义。
233 %
234 % \subsubsection{latexmk}
235 % latexmk 命令支持全自动生成\LaTeX{}编写的文档,并且支持使用不同的工具链来进行生成,它会自动运行多次工具直到交叉引用都被解决。下面给出了一个用 latexmk 调用 xelatex 生成最终文档的示例:
236 % \begin{shell}
237 % $ latexmk hitreport-example.tex # 生成示例报告
238 % $ latexmk hitreport.dtx # 生成说明文档hitreport.pdf
239 % $ latexmk -c # 清理编译生成的辅助文件
240 % \end{shell}
241 % \texttt{latexmk} 的编译过程是通过 \file{latexmkrc} 文件来配置的,如果要进一步了解,
242 % 可以参考 \pkg{latexmk} 文档。
243 %
244 %
245 % \subsubsection{\XeLaTeX}
246 % \label{sec:xelatex}
247 % 如果用户无法使用以上两种较为方便的编译方法,就只能按照以下复杂的办法手动编译。
248 %
249 % 首先,更新模板:
250 % \begin{shell}
251 % $ xetex hitreport.ins # 生成 hitreport.cls
252 % \end{shell}
253 %
254 % 然后,生成论文:
255 % \begin{shell}
256 % $ xelatex hitreport-example.tex
257 % $ bibtex hitreport-example.aux # 生成 bbl 文件
258 % $ xelatex hitreport-example.tex # 解决引用
259 % $ xelatex hitreport-example.tex # 生成报告 PDF
260 %
261 % \end{shell}
262 %
263 % 使用下面的命令用来生成用户手册:
264 % \begin{shell}
265 % $ xelatex -shell-escape hitreport.dtx
266 % $ makeindex -s gind.ist -o hitreport.ind hitreport.idx
267 % $ xelatex -shell-escape hitreport.dtx
268 % $ xelatex -shell-escape hitreport.dtx # 生成说明文档 hitreport.pdf
269 % \end{shell}
270 %
271 % \subsection{升级}
272 % \label{sec:upgrade}
273 % 如果需要升级 \hitreport{},应当从 GitHub 下载最新的版本,
274 % 将 \file{hitreport.dtx},\file{hitreport.ins},拷贝至工作目录覆盖相应的文件,然后按照
275 % 第~\ref{sec:generate-cls} 节的内容生成新的模板和使用说明。
276 %
277 % 有时模板可能进行了重要的修改,不兼容已写好的正文内容,用户应按照示例
278 % 文档重新调整。
279 %
280 %
281 % \section{使用说明}
282 % \label{sec:usage}
283 % \subsection{示例文件}
284 % 推荐从模板自带的示例文档入手,其中包括了写作用到的所有命令及其使用方法,只需要用自己的内容进行相应替换就可以。对于不清楚的命令可以查阅本手册。下面的例子描述了模板中章节的组织形式,来自于示例文档,具体内容可以参考模板附带的 \file{hitreport-example.tex}。
285 %
286 % \subsection{选项}
287 % \label{sec:option}
288 % 报告的语言是中文,暂不支持英文。
289 % \DescribeOption{open}
290 % 正规出版物的章节出现在奇数页,也就是右手边的页面,这就是 \option{right},。在这种情况下,如果前一章的最后一页也是奇数,那么模板会自动生成一个纯粹的空白页。
291 % 提交的作业如果是电子稿的话,可以使用连续页,即使用\option{any}
292 % \DescribeOption{wide}
293 % 是否使用宽页面。如果生成作业的话,宽页面或许好看。
294 % \DescribeOption{draft}
295 % 是否生成水印。生成的水印为 Draft 表示此文档尚为草稿
296 %
297 % \subsection{字体配置}
298 % \label{sec:font-config}
299 % 模板默认可以自动检测操作系统,并配置改平台上合适的字体,
300 % 具体的配置策略如表~\ref{tab:font}。
301 % \begin{table}[htb]
302 % \centering
303 % \caption{hitreport 自动配置字体策略}
304 % \label{tab:font}
305 % \begin{tabular}{ccc}
306 % \toprule
307 % Windows & macOS & 其他 \\
308 % \midrule
309 % Times New Roman & Times New Roman & TeX Gyre Termes \\
310 % Arial & Arial & TeX Gyre Heros \\
311 % Courier & Menlo & TeX Gyre Cursor \\
312 % 中易宋体 & 华文宋体 & Noto 宋体 \\
313 % 中易黑体 & 华文黑体 & Noto 黑体 \\
314 % \bottomrule
315 % \end{tabular}
316 % \end{table}
317 %
318 % 然而自动配置的字体只能保证编译通过,但是还存在一些问题:
319 % \begin{enumerate}
320 % \item 在其他平台上配置的 TeX Gyre 系列字体,虽然在风格上比较接近 Times 和 Arial,
321 % 但是毕竟跟部分课程要求的字体不完全一致;
322 % \item 华文字库虽然不违反一般的写作要求,
323 % 但是其字形跟中易字库有所差别,可能被批改老师认为格式不符合要求。
324 % \end{enumerate}
325 %
326 % 所以建议在提交最终版前使用 Windows 平台的字体进行编译。
327 %
328 % 用户也可以在调用 hitreport 时手动指定使用的字库,如:
329 %
330 % \begin{latex}
331 % \documentclass[fontset=windows]{hitreport}
332 % \end{latex}
333 %
334 % 允许的选项有 \option{windows}、\option{mac},详
335 % 见 \pkg{ctex}、\pkg{xeCJK}、\pkg{fontspec} 等宏包的使用说明。
336 %
337 %
338 % \subsection{论文设置}
339 % 论文的设置可以通过统一命令 \cs{hitsetup} 设置 \emph{key=value} 形式完成。
340 %
341 % \DescribeMacro{\hitsetup}
342 % \cs{hitsetup} 用法与常见 \emph{key=value} 命令相同,如下:
343 % \begin{latex}
344 % \hitsetup{
345 % key1 = value1,
346 % key2 = {a value, with comma},
347 % }
348 % % 可以多次调用
349 % \hitsetup{
350 % key3 = value3,
351 % key1 = value11, % 覆盖 value1
352 % }
353 % \end{latex}
354 %
355 % \note[注意:]{\cs{hitsetup} 使用 \pkg{kvsetkeys} 机制,所以配置项之间不能有空行,否则
356 % 会报错。}
357 %
358 %
359 %
360 % \subsection{封面信息}
361 %
362 % \label{sec:titlepage}
363 % 封面信息可以通过统一设置命令 \cs{hitsetup} 设置 \emph{key=value} 形式完成;
364 %
365 % \subsubsection{报告校区}
366 % 选择不同校区的校名。备选为harbin、shenzhen、weihai。
367 % \begin{latex}
368 % \hitsetup{
369 % campus = {harbin},
370 % }
371 % \end{latex}
372 %
373 %
374 % \subsubsection{报告主标题}
375 % 中文标题。可以在标题内部使用换行|\\|。
376 % \begin{latex}
377 % \hitsetup{
378 % title = {报告主标题},
379 % }
380 % \end{latex}
381 %
382 % \subsubsection{报告副标题}
383 % 中文标题。可以在标题内部使用换行|\\|。
384 % \begin{latex}
385 % \hitsetup{
386 % expand = {报告副标题},
387 % }
388 % \end{latex}
389 %
390 % \subsubsection{院系名称}
391 % 院系名称。
392 % \begin{latex}
393 % \hitsetup{
394 % department = {系名全称},
395 % }
396 % \end{latex}
397 %
398 % \subsubsection{专业名称}
399 %
400 % \begin{latex}
401 % \hitsetup{
402 % discipline = {专业名称},
403 % }
404 % \end{latex}
405 %
406 % \subsubsection{作者姓名}
407 % 作者姓名。
408 % \begin{latex}
409 % \hitsetup{
410 % author = {中文姓名},
411 % }
412 % \end{latex}
413 %
414 % \subsubsection{学号}
415 % 学号。
416 % \begin{latex}
417 % \hitsetup{
418 % student-id = {1180310840},
419 % }
420 % \end{latex}
421 %
422 % \subsubsection{指导教师}
423 % 指导教师。
424 % \begin{latex}
425 % \hitsetup{
426 % supervisor = {指导教师},
427 % }
428 % \end{latex}
429 %
430 % \subsubsection{实验地点}
431 % 直接中文书写实验地点。
432 % \begin{latex}
433 % \hitsetup{
434 % lablocation = {格物207},
435 % }
436 % \end{latex}
437 %
438 % \subsubsection{学期}
439 % 课程学期,直接书写中文即可。
440 % \begin{latex}
441 % \hitsetup{
442 % term = {2021春季学期},
443 % }
444 % \end{latex}
445 %
446 % \subsubsection{成文日期}
447 % 默认为当前日期,也可以自己指定,要求使用 ISO 格式。
448 % \begin{latex}
449 % \hitsetup{
450 % date = {2021-03-01},
451 % }
452 % \end{latex}
453 %
454 %
455 % \myentry{生成封面}
456 % \DescribeMacro{\maketitle}
457 % 生成封面。
458 % \begin{latex}
459 % % 直接生成封面
460 % \maketitle
461 % \end{latex}
462 %
463 % \subsection{正文部分}
464 % \subsubsection{数学符号}
465 % \label{sec:math}
466 % 报告的数学符号默认遵循 GB/T 3102.11—1993《物理科学和技术中使用的数学符号》。
467 % 该标准参照采纳 ISO 31-11:1992,
468 % 但是与 \TeX{} 默认的英美国家的符号习惯有许多差异,主要有:
469 % \newcommand\dif{\mathop{}\!\mathrm{d}}
470 % \begin{enumerate}
471 % \item 大写希腊字母默认为斜体,
472 % 有限增量符号 固定使用正体。
473 % \item 数学常数和特殊函数名用正体。
474 % \item 微分号使用正体。
475 % \item 向量、矩阵和张量用粗斜体。
476 % \item 省略号按照中文的习惯固定居中。
477 % \end{enumerate}
478 %
479 % \DescribeOption{math-style}
480 % 英文论文的数学符号默认使用 \TeX{} 样式。
481 % 如果有必要,也可以通过设置 \option{math-style} 选择数学符号样式,
482 % 可选:\option{GB}(中文默认),\option{TeX}(英文默认),\option{ISO}。
483 % \begin{latex}
484 % \hitsetup{
485 % math-style = ISO,
486 % }
487 % \end{latex}
488 %
489 % 模板使用
490 % \href{http://mirrors.ctan.org/macros/latex/contrib/unicode-math/unicode-math.pdf}{\pkg{unicode-math}}
491 % 配置数学符号的字体。
492 % 全部数学符号的命令参考
493 % \href{http://mirrors.ctan.org/macros/latex/contrib/unicode-math/unimath-symbols.pdf}{\pkg{unimath-symbols}}。
494 % 注意,\pkg{unicode-math} 宏包与 \pkg{amsfonts}、\pkg{amssymb}、\pkg{bm}、
495 % \pkg{mathrsfs}、\pkg{upgreek} 等宏包\emph{不}兼容。
496 % 模板作了处理,用户可以直接使用这些宏包的命令,如 \cs{bm}、\cs{mathscr}、
497 % \cs{uppi}。
498 %
499 %
500 % \subsubsection{定理环境}
501 % \label{sec:theorem}
502 % \hitreport 定义了常用的数学环境:
503 %
504 % \begin{center}
505 % \begin{tabular}{*{7}{l}}\toprule
506 % axiom & theorem & definition & proposition & lemma & conjecture &\\
507 % 公理 & 定理 & 定义 & 命题 & 引理 & 猜想 &\\\midrule
508 % proof & corollary & example & assumption & remark & problem & solution\\
509 % 证明 & 推论 & 例子 & 假设 & 注释 & 问题 & 解\\\bottomrule
510 % \end{tabular}
511 % \end{center}
512 %
513 % 比如:
514 % \begin{latex}
515 % \begin{definition}
516 % 道千乘之国,敬事而信,节用而爱人,使民以时。
517 % \end{definition}
518 % \end{latex}
519 % 产生(自动编号):
520 % \medskip
521 %
522 % \noindent\framebox[\linewidth][l]{{\heiti 定义~1.1~~~} % {道千乘之国,敬事而信,节用而爱人,使民以时。}}
523 %
524 % \smallskip
525 % 列举出来的数学环境毕竟是有限的,如果想用\emph{胡说}这样的数学环境,那么可以定义:
526 % \begin{latex}
527 % \newtheorem{nonsense}{胡说}[chapter]
528 % \end{latex}
529 %
530 % 然后这样使用:
531 % \begin{latex}
532 % \begin{nonsense}
533 % 契丹武士要来中原夺武林秘笈。—— 慕容博
534 % \end{nonsense}
535 % \end{latex}
536 %
537 % 产生(自动编号):
538 %
539 % \medskip
540 % \noindent\framebox[\linewidth][l]{{\heiti 胡说~1.1~~~} % {契丹武士要来中原夺武林秘笈。—— 慕容博}}
541 %
542 % \subsection{其他部分}
543 % \subsubsection{参考文献}
544 % \label{sec:bibliography}
545 %
546 % 参考文献通常可以使用 \hologo{BibTeX} 或 biblatex 生成。
547 % \hologo{BibTeX} 是 LaTeX 处理参考文献的传统的方式,
548 % 需要在使用 \cs{bibliographystyle}\marg{style} 选择样式
549 % 并用 \cs{bibliography} 设置 \file{.bib} 的路径。
550 % 然后使用 \texttt{bibtex} 对 \file{.aux} 文件进行编译得到 \file{.bbl} 文件。
551 % 其中的参考文献表内容会在后续编译时替换到 \cs{bibliography} 的位置。
552 % Biblatex 是较新的方式,需要在载入宏包时通过 \option{style} 选择样式,
553 % 在导言区使用 \cs{addbibresource} 声明数据库的路径,
554 % 并在输出参考文献表的位置使用 \cs{printbibliography} 命令,
555 % 而且编译参考文献的命令需要换为 biber。
556 % 这两种方式各有优缺点,比如 BibTeX 无法对中文按照拼音排序,一些样式更新不够及时;
557 % Biblatex 运行较缓慢,无法对多个参考文献表使用不同样式。
558 % 用户需要根据实际选择合适的方式。
559 %
560 % 由于报告基本不做参考文献的格式要求,此处的制作较为宽泛,采用 APA 格式,
561 % APA 的 BibTeX 样式由 \pkg{apacite} 宏包提供,需要在导言区调用:
562 % \begin{latex}
563 % \usepackage[natbibapa]{apacite}
564 % \bibliographystyle{apacite}
565 % \end{latex}
566 % 其中 \option{natbibapa} 会调用 \pkg{natbib} 来处理引用,
567 % 这也是宏包推荐的用法。
568 % 注意目前的 \pkg{apacite} 只支持到 APA 第 6 版。
569 % 更推荐使用已经更新到 APA 第 7 版的 \pkg{biblatex-apa}:
570 % \begin{latex}
571 % \usepackage[style=apa]{biblatex}
572 % \addbibresource{refs-apa.bib}
573 % \end{latex}
574 % 注意,如果参考文献中引用了中文文献的话,这两种方法都不能正确调整格式,
575 % 需要手动进行修改 \file{.bbl} 文件的内容,
576 % 这时 BibTeX 比 biblatex 更简单些。
577 %
578 %
579 %
580 % \subsubsection{附录}
581 %
582 % 附录由 \cs{appendix} 命令开启,然后像正文一样书写。部分实验报告要求附录
583 % 引用代码,可以使用相对路径引用。
584 % \begin{latex}
585 % \appendix
586 % \chapter{...}
587 % ...
588 % \end{latex}
589 %
590 %
591 % \section{致谢}
592 % 报告一般不需要添加致谢的章节,故本模板不做相应的制作。
593 % 感谢以下宏包的作者,本宏包从中使用了部分代码和借鉴:
594 % \begin{itemize}
595 % \item 清华大学\thuthesis \quad https://github.com/tuna/thuthesis
596 % \item 哈尔滨工业大学 \hithesis \quad https://github.com/dustincys/hithesis
597 % \end{itemize}
598 %
599 % \StopEventually{\PrintIndex}
600 % \clearpage
601 %
602 % \section{实现细节}
603 % \subsection{基本信息}
604 % \begin{macrocode}
605 %<cls>\NeedsTeXFormat{LaTeX2e}[2017/04/15]
606 %<cls>\ProvidesClass{hitreport}
607 %<cls>[2020/12/31 v1.1 Standard LaTeX Template for hitreport]
608 % \end{macrocode}
609 %
610 % 报错
611 % \begin{macrocode}
612 \newcommand\hit@error[1]{%
613 \ClassError{hitreport}{#1}{}%
614 }
615 \newcommand\hit@warning[1]{%
616 \ClassWarning{hitreport}{#1}%
617 }
618 \newcommand\hit@patch@error[1]{%
619 \hit@error{Failed to patch command \protect#1}%
620 }
621 \newcommand\hit@deprecate[2]{%
622 \def\hit@@tmp{#2}%
623 \hit@warning{%
624 The #1 is deprecated%
625 \ifx\hit@@tmp\@empty\else
626 . Use #2 instead%
627 \fi
628 }%
629 }
630 % \end{macrocode}
631 %
632 % 检查 \LaTeXe{} kernel 版本
633 % \begin{macrocode}
634 \@ifl@t@r\fmtversion{2017/04/15}{}{
635 \hit@error{%
636 TeX Live 2017 or later version is required to compile this document%
637 }
638 }
639 % \end{macrocode}
640 %
641 % 检查编译引擎,要求使用 \XeLaTeX。
642 % \begin{macrocode}
643 \RequirePackage{ifxetex}
644 \RequireXeTeX
645 \ifxetex\else
646 \ClassError{hitreport}{You must use the `xelatex' driver\MessageBreak
647 Please choose `xelatex'}{Just choose `xelatex', no `pdflatex' or `latex' and so on.}
648 \fi
649 % \end{macrocode}
650 %
651 % \subsection{定义选项}
652 % \label{sec:defoption}
653 % 初始化信息
654 % \begin{macrocode}
655 %<*cls>
656 \RequirePackage{kvdefinekeys}
657 \RequirePackage{kvsetkeys}
658 \RequirePackage{kvoptions}
659 \SetupKeyvalOptions{
660 family=hit,
661 prefix=hit@,
662 setkeys=\kvsetkeys}
663 % \end{macrocode}
664 %
665 % \begin{macro}{\hitsetup}
666 % 提供一个 \cs{hitsetup} 命令支持 \emph{key-value} 的方式来设置。
667 % \begin{macrocode}
668 \newcommand\hitsetup[1]{%
669 \kvsetkeys{hit}{#1}%
670 }
671 % \end{macrocode}
672 % \end{macro}
673 %
674 % 同时用 \emph{key-value} 的方式来定义这些接口:
675 % \begin{latex}
676 % \hit@define@key{
677 % <key> = {
678 % name = <name>,
679 % choices = {
680 % <choice1>,
681 % <choice2>,
682 % },
683 % default = <default>,
684 % },
685 % }
686 % \end{latex}
687 %
688 % 其中 |choices| 设置允许使用的值,默认为第一个(或者 \meta{default});
689 % \meta{code} 是相应的内容被设置时执行的代码。
690 %
691 % \begin{macrocode}
692 \newcommand\hit@define@key[1]{%
693 \kvsetkeys{hit@key}{#1}%
694 }
695 \kv@set@family@handler{hit@key}{%
696 % \end{macrocode}
697 %
698 % \cs{hitsetup} 会将 \meta{value} 存到 \cs{hit@\meta{key}},
699 % 但是宏的名字包含 “-” 这样的特殊字符时不方便直接调用,比如 |key = math-style|,
700 % 这时可以用 |name| 设置 \meta{key} 的别称,比如 |key = math@style|,
701 % 这样就可以通过 \cs{hit@math@style} 来引用。
702 % |default| 是定义该 \meta{key} 时默认的值,缺省为空。
703 %
704 % \begin{macrocode}
705 \@namedef{hit@#1@@name}{#1}%
706 \def\hit@@default{}%
707 \def\hit@@choices{}%
708 \kv@define@key{hit@value}{name}{%
709 \@namedef{hit@#1@@name}{##1}%
710 }%
711 % \end{macrocode}
712 %
713 % 由于在定义接口时,\cs{hit@\meta{key}@@code} 不一定有定义,
714 % 而且在文档类/宏包中还有可能对该 |key| 的 |code| 进行添加。
715 % 所以 \cs{hit@\meta{key}@@code} 会检查如果在定义文档类/宏包时则推迟执行,否则立即执行。
716 %
717 % \begin{macrocode}
718 \@namedef{hit@#1@@check}{}%
719 \@namedef{hit@#1@@code}{}%
720 % \end{macrocode}
721 %
722 % 保存下 |choices = {}| 定义的内容,在定义 \cs{hit@\meta{name}} 后再执行。
723 %
724 % \begin{macrocode}
725 \kv@define@key{hit@value}{choices}{%
726 \def\hit@@choices{##1}%
727 \@namedef{hit@#1@@reset}{}%
728 % \end{macrocode}
729 %
730 % \cs{hit@\meta{key}@check} 检查 |value| 是否有效,
731 % 并设置 \cs{ifhit@\meta{name}@\meta{value}}。
732 %
733 % \begin{macrocode}
734 \@namedef{hit@#1@@check}{%
735 \@ifundefined{%
736 ifhit@\@nameuse{hit@#1@@name}@\@nameuse{hit@\@nameuse{hit@#1@@name}}%
737 }{%
738 \hit@error{Invalid value "#1 = \@nameuse{hit@\@nameuse{hit@#1@@name}}"}%
739 }%
740 \@nameuse{hit@#1@@reset}%
741 \@nameuse{hit@\@nameuse{hit@#1@@name}@\@nameuse{hit@\@nameuse{hit@#1@@name}}true}%
742 }%
743 }%
744 \kv@define@key{hit@value}{default}{%
745 \def\hit@@default{##1}%
746 }%
747 \kvsetkeys{hit@value}{#2}%
748 \@namedef{hit@\@nameuse{hit@#1@@name}}{}%
749 % \end{macrocode}
750 %
751 % 第一个 \meta{choice} 设为 \meta{default},
752 % 并且对每个 \meta{choice} 定义 \cs{ifhit@\meta{name}@\meta{choice}}。
753 %
754 % \begin{macrocode}
755 \kv@set@family@handler{hit@choice}{%
756 \ifx\hit@@default\@empty
757 \def\hit@@default{##1}%
758 \fi
759 \expandafter\newif\csname ifhit@\@nameuse{hit@#1@@name}@##1\endcsname
760 \expandafter\g@addto@macro\csname hit@#1@@reset\endcsname{%
761 \@nameuse{hit@\@nameuse{hit@#1@@name}@##1false}%
762 }%
763 }%
764 \kvsetkeys@expandafter{hit@choice}{\hit@@choices}%
765 % \end{macrocode}
766 %
767 % 将 \meta{default} 赋值到 \cs{hit@\meta{name}},如果非空则执行相应的代码。
768 %
769 % \begin{macrocode}
770 \expandafter\let\csname hit@\@nameuse{hit@#1@@name}\endcsname\hit@@default
771 \expandafter\ifx\csname hit@\@nameuse{hit@#1@@name}\endcsname\@empty\else
772 \@nameuse{hit@#1@@check}%
773 \fi
774 % \end{macrocode}
775 %
776 % 定义 \cs{hitsetup} 接口。
777 %
778 % \begin{macrocode}
779 \kv@define@key{hit}{#1}{%
780 \@namedef{hit@\@nameuse{hit@#1@@name}}{##1}%
781 \@nameuse{hit@#1@@check}%
782 \@nameuse{hit@#1@@code}%
783 }%
784 }
785 % \end{macrocode}
786 %
787 % 定义接口向 |key| 添加 |code|:
788 %
789 % \begin{macrocode}
790 \newcommand\hit@option@hook[2]{%
791 \expandafter\g@addto@macro\csname hit@#1@@code\endcsname{#2}%
792 }
793 % \end{macrocode}
794 % 报告撰写的校区
795 % \begin{macrocode}
796 \hit@define@key{
797 campus = {
798 name = campus,
799 choices = {
800 harbin,
801 shenzhen,
802 weihai,
803 },
804 },
805 % \end{macrocode}
806 %
807 % 字体
808 % \begin{macrocode}
809 fontset = {
810 choices = {
811 windows,
812 mac,
813 ubuntu,
814 fandol,
815 none,
816 },
817 default = none,
818 },
819 system = {
820 choices = {
821 mac,
822 unix,
823 windows,
824 auto,
825 },
826 default = auto,
827 },
828 font = {
829 choices = {
830 times,
831 termes,
832 xits,
833 libertinus,
834 lm,
835 auto,
836 none,
837 },
838 default = auto,
839 },
840 cjk-font = {
841 name = cjk@font,
842 choices = {
843 windows,
844 mac,
845 noto,
846 fandol,
847 auto,
848 none,
849 },
850 default = auto,
851 },
852 math-font = {
853 name = math@font,
854 choices = {
855 xits,
856 stix,
857 libertinus,
858 lm,
859 none,
860 },
861 default = xits,
862 },
863 math-style = {
864 name = math@style,
865 choices = {
866 GB,
867 ISO,
868 TeX,
869 },
870 default = GB,
871 },
872 }
873 % \end{macrocode}
874 %
875 %
876 % 定义关键字
877 % \begin{macrocode}
878 \newcommand\hit@tokens@keywords{}
879 \ProcessOptions\relax
880 % \end{macrocode}
881 %
882 %
883 %
884 % \subsection{装载宏包}
885 % \label{sec:loadpackage}
886 %
887 % 设置默认 \option{openany}。
888 % \begin{macrocode}
889 \DeclareBoolOption[false]{openright}
890 \DeclareComplementaryOption{openany}{openright}
891 % \end{macrocode}
892 %
893 % \option{raggedbottom} 选项(默认打开)
894 % \begin{macrocode}
895 \DeclareBoolOption[true]{raggedbottom}
896 % \end{macrocode}
897 % 将选项传递给 \pkg{ctexbook}。
898 % \begin{macrocode}
899 \DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{ctexbook}}
900 % \end{macrocode}
901 %
902 % 解析用户传递过来的选项,并加载 \pkg{ctexbook}。
903 % \begin{macrocode}
904 \ProcessKeyvalOptions*
905 % \end{macrocode}
906 %
907 % 设置默认 \option{openany}。
908 % \begin{macrocode}
909 \ifhit@openright
910 \PassOptionsToClass{openright}{book}
911 \else
912 \PassOptionsToClass{openany}{book}
913 \fi
914 % \end{macrocode}
915 %
916 % 使用 \pkg{ctexbook} 宏包,优于调用 \pkg{ctex} 宏包
917 % \begin{macrocode}
918 \PassOptionsToPackage{quiet}{fontspec}
919 \LoadClass[a4paper,UTF8,zihao=-4,scheme=plain,fontset=none]{ctexbook}[2017/04/01]
920 % \end{macrocode}
921 %
922 % 引用宏包和相关定义
923 % \begin{macrocode}
924 \RequirePackage{etoolbox}
925 \RequirePackage{filehook}
926 \RequirePackage{xparse}
927 % \end{macrocode}
928 %
929 % 设置页面布局
930 % \begin{macrocode}
931 \RequirePackage{geometry}
932 \geometry{
933 paper = a4paper, % 210 * 297mm
934 marginparwidth = 2cm,
935 marginparsep = 0.5cm,
936 }
937 \newcommand\hit@set@geometry{%
938 \geometry{
939 margin = 3cm,
940 headheight = 0.5cm,
941 headsep = 0.3cm,
942 footskip = 0.8cm,
943 }%
944 }
945 \hit@set@geometry
946 % \end{macrocode}
947 %
948 % 利用 \pkg{fancyhdr} 设置页眉页脚。
949 % \begin{macrocode}
950 \RequirePackage{fancyhdr}
951 % \end{macrocode}
952 %
953 % 设置目录
954 % \begin{macrocode}
955 \RequirePackage{titletoc}
956 % \end{macrocode}
957 %
958 % 利用 \pkg{notoccite} 避免目录中引用编号混乱。
959 % \begin{macrocode}
960 \RequirePackage{notoccite}
961 % \end{macrocode}
962 %
963 %
964 % 数学宏包,\AmSTeX\ 宏包,用来排公式。
965 % \begin{macrocode}
966 \RequirePackage{amsmath}
967 % \end{macrocode}
968 %
969 % 使用 \pkg{unicode-math} 处理数学字体。
970 % \begin{macrocode}
971 \RequirePackage{unicode-math}
972 % \end{macrocode}
973 %
974 % 支持tikz画图
975 % \begin{macrocode}
976 \RequirePackage{tikz}
977 % \end{macrocode}
978 %
979 % \pkg{pdfpages} 宏包便于插入 PDF 文档。
980 % \begin{macrocode}
981 \RequirePackage{pdfpages}
982 \includepdfset{fitpaper=true}
983 % \end{macrocode}
984 %
985 % 设置颜色
986 % \begin{macrocode}
987 \RequirePackage{xcolor}
988 % \end{macrocode}
989 %
990 % 支持插入图片
991 % \begin{macrocode}
992 \RequirePackage{graphicx}
993 % \end{macrocode}
994 %
995 % 并排图形。\pkg{subfigure}、\pkg{subfig} 已经不再推荐,用新的 \pkg{subcaption}。
996 % 浮动图形和表格标题样式。\pkg{caption2} 已经不推荐使用,采用新的 \pkg{caption}。
997 % \begin{macrocode}
998 \RequirePackage[labelformat=simple]{subcaption}
999 % \end{macrocode}
1000 %
1001 % 支持文章内部引用
1002 % \begin{macrocode}
1003 \RequirePackage{hyperref}
1004 % \end{macrocode}
1005 %
1006 % 支持添加表格
1007 % \begin{macrocode}
1008 \RequirePackage{array}
1009 % \end{macrocode}
1010 %
1011 % 支持表格跨页显示,booktabs 提供了 \cs{toprule} 等命令.
1012 % \begin{macrocode}
1013 \RequirePackage{longtable}
1014 \RequirePackage{booktabs}
1015 % \end{macrocode}
1016 %
1017 % multirow 支持在表格中跨行
1018 % \begin{macrocode}
1019 \RequirePackage{multirow}
1020 % \end{macrocode}
1021 %
1022 % 支持表格过长跨页显示
1023 % \begin{macrocode}
1024 \RequirePackage{threeparttable}
1025 % \end{macrocode}
1026 %
1027 % 调整间隔, 让表格更好看些
1028 % \begin{macrocode}
1029 \RequirePackage{bigstrut}
1030 % \end{macrocode}
1031 %
1032 % 在跨行表格中输入定界符
1033 % \begin{macrocode}
1034 \RequirePackage{bigdelim}
1035 % \end{macrocode}
1036 %
1037 % 设置代码环境
1038 % \begin{macrocode}
1039 \RequirePackage{listings}
1040 % \end{macrocode}
1041 %
1042 % 支持代码根据语言类型高亮
1043 % \begin{macrocode}
1044 \RequirePackage{xcolor}
1045 % \end{macrocode}
1046 %
1047 % 支持url引用
1048 % \begin{macrocode}
1049 \RequirePackage{url}
1050 % \end{macrocode}
1051 %
1052 %
1053 % \subsubsection{\pkg{algorithm} 宏包}
1054 %
1055 % 使 \env{algorithm} 和 \env{listing} 环境的名称随语言设置而改变,
1056 % 并使其在附录中的编号规则与图、表等一致。
1057 %
1058 % \begin{macro}{\listofalgorithm}
1059 % \begin{macro}{\listofalgorithm*}
1060 % \begin{macrocode}
1061 \PassOptionsToPackage{chapter}{algorithm}
1062 \AtEndOfPackageFile*{algorithm}{
1063 \floatname{algorithm}{\thu@algorithm@name}
1064 \renewcommand\listofalgorithms{%
1065 \hit@listof{algorithm}%
1066 }
1067 \renewcommand\listalgorithmname{\hit@list@algorithm@name}
1068 \def\ext@algorithm{loa}
1069 \contentsuse{algorithm}{loa}
1070 \titlecontents{algorithm}
1071 [\z@]{}
1072 {\contentspush{\fname@algorithm~\thecontentslabel\quad}}{}
1073 {\hit@leaders\thecontentspage}
1074 }
1075 % \end{macrocode}
1076 % \end{macro}
1077 % \end{macro}
1078 %
1079 %
1080 % \subsubsection{\pkg{algorithm2e} 宏包}
1081 %
1082 % \begin{macrocode}
1083 \PassOptionsToPackage{algochapter}{algorithm2e}
1084 \AtEndOfPackageFile*{algorithm2e}{
1085 \renewcommand\algorithmcfname{\hit@algorithm@name}
1086 \SetAlgoCaptionLayout{thu@caption@font}
1087 \SetAlCapSty{relax}
1088 \SetAlgoCaptionSeparator{\hspace*{1em}}
1089 \SetAlFnt{\fontsize{11bp}{14.3bp}\selectfont}
1090 \renewcommand\listofalgorithms{%
1091 \hit@listof{algorithmcf}%
1092 }
1093 \renewcommand\listalgorithmcfname{\hit@list@algorithm@name}
1094 \def\ext@algorithmcf{loa}
1095 \contentsuse{algocf}{loa}
1096 \titlecontents{algocf}
1097 [\z@]{}
1098 {\contentspush{\algorithmcfname~\thecontentslabel\quad}}{}
1099 {\hit@leaders\thecontentspage}
1100 }
1101 % \end{macrocode}
1102 %
1103 % \subsubsection{\pkg{minted} 宏包}
1104 %
1105 % \begin{macrocode}
1106 \AtEndOfPackageFile*{minted}{
1107 \newcommand\hit@set@listing@language{%
1108 \floatname{listing}{代码}%
1109 }
1110 \hit@set@listing@language
1111 }
1112 % \end{macrocode}
1113 %
1114 %
1115 %
1116 % 如果用户在导言区未调用 \pkg{biblatex},则自动调用 \pkg{natbib}。
1117 % \begin{macrocode}
1118 \AtEndPreamble{
1119 \@ifpackageloaded{biblatex}{}{
1120 \@ifpackageloaded{apacite}{}{
1121 \RequirePackage{natbib}
1122 }
1123 }
1124 }
1125 \AtEndOfPackageFile*{natbib}{
1126 \@ifpackageloaded{apacite}{}{
1127 \RequirePackage{bibunits}
1128 }
1129 }
1130 % \end{macrocode}
1131 %
1132 % 对冲突的宏包报错。
1133 % \begin{macrocode}
1134 \newcommand\hit@package@conflict[2]{
1135 \AtBeginOfPackageFile*{#2}{
1136 \hit@error{The "#2" package is incompatible with required "#1"}
1137 }
1138 }
1139 \hit@package@conflict{unicode-math}{amscd}
1140 \hit@package@conflict{unicode-math}{amsfonts}
1141 \hit@package@conflict{unicode-math}{amssymb}
1142 \hit@package@conflict{unicode-math}{bbm}
1143 \hit@package@conflict{unicode-math}{bm}
1144 \hit@package@conflict{unicode-math}{eucal}
1145 \hit@package@conflict{unicode-math}{eufrak}
1146 \hit@package@conflict{unicode-math}{mathrsfs}
1147 % \end{macrocode}
1148 %
1149 % 支持文中引用
1150 % \begin{macrocode}
1151 \RequirePackage{cite}
1152 % \end{macrocode}
1153 %
1154 % 插入代码,进行设置
1155 % \begin{macrocode}
1156 \RequirePackage{listings}
1157 \lstset{
1158 numbers=left, %设置行号位置
1159 numberstyle=\tiny, %设置行号大小
1160 keywordstyle=\color{blue}, %设置关键字颜色
1161 commentstyle=\color[cmyk]{1,0,1,0}, %设置注释颜色
1162 frame=single, %设置边框格式
1163 escapeinside=``, %逃逸字符(1左面的键),用于显示中文
1164 breaklines, %自动折行
1165 extendedchars=false, %解决代码跨页时,章节标题,页眉等汉字不显示的问题
1166 xleftmargin=2em,
1167 xrightmargin=2em,
1168 aboveskip=1em, %设置边距
1169 tabsize=4, %设置tab空格数
1170 showspaces=false, %不显示空格
1171 belowskip=3mm,
1172 showstringspaces=false,columns=flexible,
1173 framerule=1pt,
1174 rulecolor=\color{gray!35},
1175 backgroundcolor=\color{gray!5},
1176 basicstyle={\small\ttfamily},
1177 stringstyle=\color{mauve},
1178 breakatwhitespace=true
1179 }
1180 % \end{macrocode}
1181 %
1182 % 重定义颜色
1183 % \begin{macrocode}
1184 \definecolor{dkgreen}{rgb}{0,0.6,0}
1185 \definecolor{gray}{rgb}{0.5,0.5,0.5}
1186 \definecolor{mauve}{rgb}{0.58,0,0.82}
1187 % \end{macrocode}
1188 % 定义首行缩进
1189 % \begin{macrocode}
1190 \RequirePackage{indentfirst}
1191 % \end{macrocode}
1192 % 设置浮动体标题
1193 % \begin{macrocode}
1194 \RequirePackage{caption}
1195 % \end{macrocode}
1196 % 设置列表环境
1197 % \begin{macrocode}
1198 \RequirePackage[shortlabels]{enumitem}
1199 \RequirePackage{environ}
1200 % \end{macrocode}
1201 %
1202 % 禁止 \LaTeX{} 自动调整多余的页面底部空白,并保持脚注仍然在底部。
1203 % 脚注按页编号。
1204 % \begin{macrocode}
1205 \ifhit@raggedbottom
1206 \RequirePackage[bottom,perpage,hang]{footmisc}
1207 \raggedbottom
1208 \else
1209 \RequirePackage[perpage,hang]{footmisc}
1210 \fi
1211 % \end{macrocode}
1212 %
1213 % 利用 \pkg{xeCJKfntef} 实现汉字的下划线和盒子内两段对齐,并可以避免
1214 % \cs{makebox}\oarg{width}\oarg{s} 可能产生的 underful boxes。
1215 % \begin{macrocode}
1216 \RequirePackage{xeCJKfntef}
1217 \RequirePackage{soul}
1218 % \end{macrocode}
1219 %
1220 % 下划线
1221 % \begin{macrocode}
1222 \RequirePackage{ulem}
1223 %
1224 % \end{macrocode}
1225 % 尺寸计算
1226 % \begin{macrocode}
1227 \RequirePackage{calc}
1228 % \end{macrocode}
1229 % 支持插入附录
1230 % \begin{macrocode}
1231 \RequirePackage[titletoc,title]{appendix}
1232 \AtBeginEnvironment{thebibliography}{%
1233 \phantomsection
1234 \addcontentsline{toc}{section}{\refname}
1235 }
1236 % \end{macrocode}
1237 %
1238 % 修改tabular 环境, 设置表格中的行间距为正文行间距.
1239 % \begin{macrocode}
1240 \let\hitreport@oldtabular\tabular
1241 \let\hitreport@endoldtabular\endtabular
1242 \renewenvironment{tabular}%
1243 {\bgroup%
1244 \renewcommand{\arraystretch}{1.2}%
1245 \hitreport@oldtabular}%
1246 {\hitreport@endoldtabular\egroup}
1247 % \end{macrocode}
1248 % 段首缩进两个汉字
1249 % \begin{macrocode}
1250 \setlength\parindent{2em}
1251 % \end{macrocode}
1252 %
1253 % \subsection{主文档格式}
1254 % \label{sec:mainbody}
1255 %
1256 % \subsubsection{Three matters}
1257 % \begin{macro}{\cleardoublepage}
1258 % 对于 \textsl{openright} 选项,必须保证章首页右开,且如果前章末页无内容须
1259 % 清空其页眉页脚。
1260 % \begin{macrocode}
1261 \def\cleardoublepage{%
1262 \clearpage
1263 \if@twoside
1264 \ifodd\c@page
1265 \fi
1266 \fi
1267 }
1268 % \end{macrocode}
1269 % \end{macro}
1270 %
1271 % \begin{macro}{\frontmatter}
1272 % \begin{macro}{\mainmatter}
1273 % \begin{macro}{\backmatter}
1274 % 我们的单面和双面模式与常规的不太一样。
1275 % \begin{macrocode}
1276 \renewcommand\frontmatter{%
1277 \cleardoublepage
1278 \@mainmatterfalse
1279 \pagenumbering{Roman}%
1280 }
1281 \renewcommand\mainmatter{%
1282 \cleardoublepage
1283 \@mainmattertrue
1284 \pagenumbering{arabic}%
1285 }
1286 \renewcommand\backmatter{%
1287 \if@openright
1288 \cleardoublepage
1289 \else
1290 \clearpage
1291 \fi
1292 \@mainmatterfalse
1293 }
1294 % \end{macrocode}
1295 % \end{macro}
1296 % \end{macro}
1297 % \end{macro}
1298 %
1299 %
1300 % \subsubsection{字体}
1301 % \label{sec:font}
1302 % 使用 \pkg{fontspec} 配置字体。
1303 % \begin{macrocode}
1304 \ifhit@fontset@mac
1305 \hitsetup{
1306 font = times,
1307 cjk-font = mac,
1308 }
1309 \else
1310 \ifhit@fontset@windows
1311 \hitsetup{
1312 font = times,
1313 cjk-font = windows,
1314 }
1315 \else
1316 \ifhit@fontset@fandol
1317 \hitsetup{
1318 font = termes,
1319 cjk-font = fandol,
1320 }
1321 \else
1322 \ifhit@fontset@ubuntu
1323 \hitsetup{
1324 font = termes,
1325 cjk-font = noto,
1326 }
1327 \fi
1328 \fi
1329 \fi
1330 \fi
1331 % \end{macrocode}
1332 %
1333 % 检测系统
1334 % \begin{macrocode}
1335 \ifhit@system@auto
1336 \IfFileExists{/System/Library/Fonts/Menlo.ttc}{
1337 \hitsetup{system = mac}
1338 }{
1339 \IfFileExists{/dev/null}{
1340 \IfFileExists{null:}{
1341 \hitsetup{system = windows}
1342 }{
1343 \hitsetup{system = unix}
1344 }
1345 }{
1346 \hitsetup{system = windows}
1347 }
1348 }
1349 \fi
1350 % \end{macrocode}
1351 %
1352 % XITS 字体于 2018-10-03 更改了字体的文件名,所以需要判断。
1353 % 原文件名为 \file{xits-regular.otf}、\file{xits-math.otf} 等,
1354 % 后改为 \file{XITS-Regular.otf}、\file{XITSMath-Regular.otf} 等。
1355 %
1356 % Libertinus 字体同样。
1357 % \begin{macrocode}
1358 \let\hit@font@family@xits\@empty
1359 \newcommand\hit@set@xits@names{%
1360 \ifx\hit@font@family@xits\@empty
1361 \IfFontExistsTF{XITSMath-Regular.otf}{%
1362 \gdef\hit@font@family@xits{XITS}%
1363 \gdef\hit@font@style@xits@rm{Regular}%
1364 \gdef\hit@font@style@xits@bf{Bold}%
1365 \gdef\hit@font@style@xits@it{Italic}%
1366 \gdef\hit@font@style@xits@bfit{BoldItalic}%
1367 \gdef\hit@font@name@xits@math@rm{XITSMath-Regular}%
1368 \gdef\hit@font@name@xits@math@bf{XITSMath-Bold}%
1369 }{%
1370 \gdef\hit@font@family@xits{xits}%
1371 \gdef\hit@font@style@xits@rm{regular}%
1372 \gdef\hit@font@style@xits@bf{bold}%
1373 \gdef\hit@font@style@xits@it{italic}%
1374 \gdef\hit@font@style@xits@bfit{bolditalic}%
1375 \gdef\hit@font@name@xits@math@rm{xits-math}%
1376 \gdef\hit@font@name@xits@math@bf{xits-mathbold}%
1377 }%
1378 \fi
1379 }
1380 \let\hit@font@family@libertinus\@empty
1381 \newcommand\hit@set@libertinus@names{%
1382 \ifx\hit@font@family@libertinus\@empty
1383 \IfFontExistsTF{LibertinusSerif-Regular.otf}{%
1384 \gdef\hit@font@family@libertinus@serif{LibertinusSerif}%
1385 \gdef\hit@font@family@libertinus@sans{LibertinusSans}%
1386 \gdef\hit@font@name@libertinus@math{LibertinusMath-Regular}%
1387 \gdef\hit@font@style@libertinus@rm{Regular}%
1388 \gdef\hit@font@style@libertinus@bf{Bold}%
1389 \gdef\hit@font@style@libertinus@it{Italic}%
1390 \gdef\hit@font@style@libertinus@bfit{BoldItalic}%
1391 }{%
1392 \gdef\hit@font@family@libertinus@serif{libertinusserif}%
1393 \gdef\hit@font@family@libertinus@sans{libertinussans}%
1394 \gdef\hit@font@name@libertinus@math{libertinusmath-regular}%
1395 \gdef\hit@font@style@libertinus@rm{regular}%
1396 \gdef\hit@font@style@libertinus@bf{bold}%
1397 \gdef\hit@font@style@libertinus@it{italic}%
1398 \gdef\hit@font@style@libertinus@bfit{bolditalic}%
1399 }%
1400 \fi
1401 }
1402 % \end{macrocode}
1403 %
1404 % 一般的报告要求西文字体使用 Times New Roman 和 Arial,
1405 % 但是在 Linux 下没有这两个字体,所以使用它们的克隆版 TeX Gyre Termes 和
1406 % TeX Gyre Heros。
1407 % \begin{macrocode}
1408 \ifhit@font@auto
1409 \ifhit@system@unix
1410 \hitsetup{font=termes}
1411 \else
1412 \hitsetup{font=times}
1413 \fi
1414 \fi
1415 \newcommand\hit@load@font@times{%
1416 \setmainfont{Times New Roman}%
1417 \setsansfont{Arial}%
1418 \ifhit@system@mac
1419 \setmonofont{Menlo}[Scale = MatchLowercase]%
1420 \else
1421 \setmonofont{Courier New}[Scale = MatchLowercase]%
1422 \fi
1423 }
1424 \newcommand\hit@load@font@termes{%
1425 \setmainfont{texgyretermes}[
1426 Extension = .otf,
1427 UprightFont = *-regular,
1428 BoldFont = *-bold,
1429 ItalicFont = *-italic,
1430 BoldItalicFont = *-bolditalic,
1431 ]%
1432 \hit@load@texgyre@sans@mono
1433 }
1434 \newcommand\hit@load@texgyre@sans@mono{%
1435 \setsansfont{texgyreheros}[
1436 Extension = .otf,
1437 UprightFont = *-regular,
1438 BoldFont = *-bold,
1439 ItalicFont = *-italic,
1440 BoldItalicFont = *-bolditalic,
1441 ]%
1442 \setmonofont{texgyrecursor}[
1443 Extension = .otf,
1444 UprightFont = *-regular,
1445 BoldFont = *-bold,
1446 ItalicFont = *-italic,
1447 BoldItalicFont = *-bolditalic,
1448 Ligatures = CommonOff,
1449 ]%
1450 }
1451 \newcommand\hit@load@font@xits{%
1452 \hit@set@xits@names
1453 \setmainfont{\hit@font@family@xits}[
1454 Extension = .otf,
1455 UprightFont = *-\hit@font@style@xits@rm,
1456 BoldFont = *-\hit@font@style@xits@bf,
1457 ItalicFont = *-\hit@font@style@xits@it,
1458 BoldItalicFont = *-\hit@font@style@xits@bfit,
1459 ]%
1460 \hit@load@texgyre@sans@mono
1461 }
1462 \newcommand\hit@load@font@libertinus{%
1463 \hit@set@libertinus@names
1464 \setmainfont{\hit@font@family@libertinus@serif}[
1465 Extension = .otf,
1466 UprightFont = *-\hit@font@style@libertinus@rm,
1467 BoldFont = *-\hit@font@style@libertinus@bf,
1468 ItalicFont = *-\hit@font@style@libertinus@it,
1469 BoldItalicFont = *-\hit@font@style@libertinus@bfit,
1470 ]%
1471 \setsansfont{\hit@font@family@libertinus@sans}[
1472 Extension = .otf,
1473 UprightFont = *-\hit@font@style@libertinus@rm,
1474 BoldFont = *-\hit@font@style@libertinus@bf,
1475 ItalicFont = *-\hit@font@style@libertinus@it,
1476 ]%
1477 \setmonofont{lmmonolt10}[
1478 Extension = .otf,
1479 UprightFont = *-regular,
1480 BoldFont = *-bold,
1481 ItalicFont = *-oblique,
1482 BoldItalicFont = *-boldoblique,
1483 ]%
1484 }
1485 \@namedef{hit@load@font@lm}{%
1486 \setmainfont{lmroman10}[
1487 Extension = .otf,
1488 UprightFont = *-regular,
1489 BoldFont = *-bold,
1490 ItalicFont = *-italic,
1491 BoldItalicFont = *-bolditalic,
1492 ]%
1493 \setsansfont{lmsans10}[
1494 Extension = .otf,
1495 UprightFont = *-regular,
1496 BoldFont = *-bold,
1497 ItalicFont = *-oblique,
1498 BoldItalicFont = *-boldoblique,
1499 ]%
1500 \setmonofont{lmmonolt10}[
1501 Extension = .otf,
1502 UprightFont = *-regular,
1503 BoldFont = *-bold,
1504 ItalicFont = *-oblique,
1505 BoldItalicFont = *-boldoblique,
1506 ]%
1507 }
1508 \newcommand\hit@load@font{%
1509 \@nameuse{hit@load@font@\hit@font}%
1510 }
1511 \hit@load@font
1512 \hit@option@hook{font}{\hit@load@font}
1513 % \end{macrocode}
1514 %
1515 % 使用 \pkg{unicode-math} 配置数学符号格式。
1516 % \begin{macrocode}
1517 \newcommand\hit@stix@stylistic@set{%
1518 \ifhit@math@style@TeX\else
1519 8
1520 \fi
1521 }
1522 \newcommand\hit@set@math@style{%
1523 \ifhit@math@style@TeX
1524 \unimathsetup{
1525 math-style = TeX,
1526 bold-style = TeX,
1527 partial = italic,
1528 }%
1529 \else
1530 \unimathsetup{
1531 math-style = ISO,
1532 bold-style = ISO,
1533 partial = upright,
1534 }%
1535 \fi
1536 \ifhit@math@style@GB
1537 \protected\def\le{\leqslant}%
1538 \protected\def\ge{\geqslant}%
1539 \DeclareRobustCommand\mathellipsis{\mathinner{\unicodecdots}}%
1540 \else
1541 \protected\def\le{\leq}%
1542 \protected\def\ge{\geq}%
1543 \DeclareRobustCommand\mathellipsis{\mathinner{\unicodeellipsis}}%
1544 \fi
1545 }
1546 \hitsetup{math-style=GB}%
1547 \hit@set@math@style
1548 \hit@option@hook{math-style}{\hit@set@math@style}
1549 % \end{macrocode}
1550 %
1551 % \begin{macrocode}
1552 \newcommand\hit@load@math@font@xits{%
1553 \hit@set@xits@names
1554 \setmathfont{\hit@font@name@xits@math@rm}[
1555 Extension = .otf,
1556 StylisticSet = \hit@stix@stylistic@set,
1557 ]%
1558 \setmathfont{\hit@font@name@xits@math@rm}[
1559 Extension = .otf,
1560 StylisticSet = 1,
1561 range = {cal,bfcal},
1562 ]%
1563 }
1564 \newcommand\hit@load@math@font@stix{%
1565 \setmathfont{STIX2Math}[
1566 Extension = .otf,
1567 StylisticSet = \hit@stix@stylistic@set,
1568 ]%
1569 \setmathfont{STIX2Math}[
1570 Extension = .otf,
1571 StylisticSet = 1,
1572 range = {cal,bfcal},
1573 ]%
1574 }
1575 \newcommand\hit@load@math@font@libertinus{%
1576 \hit@set@libertinus@names
1577 \setmathfont{\hit@font@name@libertinus@math .otf}%
1578 }
1579 \newcommand\hit@load@math@font@lm{%
1580 \setmathfont{latinmodern-math.otf}%
1581 }
1582 \newcommand\hit@load@math@font{%
1583 \@nameuse{hit@load@math@font@\hit@math@font}
1584 }
1585 \hit@load@math@font
1586 \hit@option@hook{math-font}{\hit@load@math@font}
1587 \hit@option@hook{math-style}{\hit@load@math@font}
1588 % \end{macrocode}
1589 %
1590 %
1591 % 中文字体
1592 % \begin{macrocode}
1593 \ifhit@cjk@font@auto
1594 \ifhit@system@mac
1595 \hitsetup{cjk-font = mac}
1596 \else
1597 \ifhit@system@windows
1598 \hitsetup{cjk-font = windows}
1599 \else
1600 \IfFontExistsTF{Noto Serif CJK SC}{
1601 \hitsetup{cjk-font = noto}
1602 }{
1603 \hitsetup{cjk-font = fandol}
1604 }
1605 \fi
1606 \fi
1607 \fi
1608 \newcommand\hit@load@cjk@font@windows{%
1609 \xeCJKsetup{EmboldenFactor=3}%
1610 \setCJKmainfont{SimSun}[
1611 AutoFakeBold = true,
1612 ItalicFont = KaiTi,
1613 ]%
1614 \setCJKsansfont{SimHei}[AutoFakeBold]%
1615 \setCJKmonofont{FangSong}%
1616 \setCJKfamilyfont{zhsong}{SimSun}[AutoFakeBold]%
1617 \setCJKfamilyfont{zhhei}{SimHei}[AutoFakeBold]%
1618 \setCJKfamilyfont{zhkai}{KaiTi}%
1619 \setCJKfamilyfont{zhfs}{FangSong}%
1620 \setCJKfamilyfont{hwxk}{STXingkai}%
1621 }
1622 \newcommand\hit@load@cjk@font@mac{%
1623 \setCJKmainfont{Songti SC}[
1624 UprightFont = * Light,
1625 BoldFont = * Bold,
1626 ItalicFont = Kaiti SC,
1627 BoldItalicFont = Kaiti SC Bold,
1628 ]%
1629 \setCJKsansfont{Heiti SC}[BoldFont=* Medium]%
1630 \setCJKmonofont{STFangsong}
1631 \setCJKfamilyfont{zhsong}{Songti SC}[
1632 UprightFont = * Light,
1633 BoldFont = * Bold,
1634 ]%
1635 \setCJKfamilyfont{zhhei}{Heiti SC}[
1636 UprightFont = * Light,
1637 BoldFont = * Medium,
1638 ]%
1639 \setCJKfamilyfont{zhfs}{STFangsong}%
1640 \setCJKfamilyfont{hwxk}{STXingkai}%
1641 \setCJKfamilyfont{zhkai}{Kaiti SC}[BoldFont = * Bold]%
1642 \setCJKfamilyfont{zhli}{Baoli SC}%
1643 \setCJKfamilyfont{zhyuan}{Yuanyi SC}[
1644 UprightFont = * Light,
1645 BoldFont = * Bold,
1646 ]%
1647 }
1648 % \end{macrocode}
1649 %
1650 % 注意 Noto CJK 的 regular 字重名字不带“Regular”。
1651 % \begin{macrocode}
1652 \newcommand\hit@load@cjk@font@noto{%
1653 \setCJKmainfont{Noto Serif CJK SC}[
1654 UprightFont = * Light,
1655 BoldFont = * Bold,
1656 ItalicFont = FandolKai-Regular,
1657 ItalicFeatures = {Extension = .otf},
1658 ]%
1659 \setCJKsansfont{Noto Sans CJK SC}[
1660 BoldFont = * Medium,
1661 ]%
1662 \setCJKmonofont{Noto Sans Mono CJK SC}%
1663 \setCJKfamilyfont{zhsong}{Noto Serif CJK SC}[
1664 UprightFont = * Light,
1665 UprightFont = * Bold,
1666 ]%
1667 \setCJKfamilyfont{zhhei}{Noto Sans CJK SC}[
1668 BoldFont = * Medium,
1669 ]%
1670 \setCJKfamilyfont{zhfs}{FandolFang}[
1671 Extension = .otf,
1672 UprightFont = *-Regular,
1673 ]%
1674 \setCJKfamilyfont{zhkai}{FandolKai}[
1675 Extension = .otf,
1676 UprightFont = *-Regular,
1677 ]%
1678 \setCJKfamilyfont{hwxk}{STXingkai}[
1679 Extension = .otf,
1680 UprightFont = *-Regular,
1681 ]%
1682 }
1683 \newcommand\hit@load@cjk@font@fandol{%
1684 \setCJKmainfont{FandolSong}[
1685 Extension = .otf,
1686 UprightFont = *-Regular,
1687 BoldFont = *-Bold,
1688 ItalicFont = FandolKai-Regular,
1689 ]%
1690 \setCJKsansfont{FandolHei}[
1691 Extension = .otf,
1692 UprightFont = *-Regular,
1693 BoldFont = *-Bold,
1694 ]%
1695 \setCJKmonofont{FandolFang}[
1696 Extension = .otf,
1697 UprightFont = *-Regular,
1698 ]%
1699 \setCJKfamilyfont{zhsong}{FandolSong}[
1700 Extension = .otf,
1701 UprightFont = *-Regular,
1702 BoldFont = *-Bold,
1703 ]%
1704 \setCJKfamilyfont{zhhei}{FandolHei}[
1705 Extension = .otf,
1706 UprightFont = *-Regular,
1707 BoldFont = *-Bold,
1708 ]%
1709 \setCJKfamilyfont{zhfs}{FandolFang}[
1710 Extension = .otf,
1711 UprightFont = *-Regular,
1712 ]%
1713 \setCJKfamilyfont{zhkai}{FandolKai}[
1714 Extension = .otf,
1715 UprightFont = *-Regular,
1716 ]%
1717 \setCJKfamilyfont{hwxk}{FandolKai}[
1718 Extension = .otf,
1719 UprightFont = *-Regular,
1720 ]%
1721 }
1722 \ifhit@cjk@font@none\else
1723 \providecommand\songti{\CJKfamily{zhsong}}
1724 \providecommand\heiti{\CJKfamily{zhhei}}
1725 \providecommand\fangsong{\CJKfamily{zhfs}}
1726 \providecommand\kaishu{\CJKfamily{zhkai}}
1727 \providecommand\huawenxingkai{\CJKfamily{hwxk}}
1728 \fi
1729 \newcommand\hit@load@cjk@font{%
1730 \@nameuse{hit@load@cjk@font@\hit@cjk@font}%
1731 }
1732 \hit@load@cjk@font
1733 \hit@option@hook{cjk-font}{\hit@load@cjk@font}
1734 % \end{macrocode}
1735 %
1736 % \begin{macro}{\normalsize}
1737 % 正文小四号 (12bp) 字,行距为固定值 20 bp。
1738 % 其他字号的行距按照相同的比例设置。
1739 %
1740 % 表达式行的行距为单倍行距,段前空 6 磅,段后空 6 磅。
1741 % \begin{macrocode}
1742 \renewcommand\normalsize{%
1743 \@setfontsize\normalsize{12bp}{20bp}%
1744 \abovedisplayskip 6bp%
1745 \abovedisplayshortskip 6bp%
1746 \belowdisplayskip 6bp
1747 \belowdisplayshortskip \abovedisplayshortskip}
1748
1749 \normalsize
1750 \ifx\MakeRobust\@undefined \else
1751 \MakeRobust\normalsize
1752 \fi
1753 \DeclareRobustCommand\small{%
1754 \@setfontsize\small{10.5bp}{17.5bp}%
1755 \abovedisplayskip 6bp%
1756 \abovedisplayshortskip 6bp%
1757 \belowdisplayshortskip 6bp%
1758 \def\@listi{\leftmargin\leftmargini
1759 \topsep \z@skip
1760 \parsep \z@skip
1761 \itemsep \z@skip}%
1762 \belowdisplayskip \abovedisplayskip
1763 }
1764 \DeclareRobustCommand\footnotesize{%
1765 \@setfontsize\footnotesize{9bp}{15bp}%
1766 \abovedisplayskip 6bp%
1767 \abovedisplayshortskip 6bp%
1768 \belowdisplayshortskip 6bp%
1769 \def\@listi{\leftmargin\leftmargini
1770 \topsep \z@skip
1771 \parsep \z@skip
1772 \itemsep \z@skip}%
1773 \belowdisplayskip \abovedisplayskip
1774 }
1775 \DeclareRobustCommand\scriptsize{\@setfontsize\scriptsize{7.5bp}{12.5bp}}
1776 \DeclareRobustCommand\tiny{\@setfontsize\tiny{6.5bp}{10.83bp}}
1777 \DeclareRobustCommand\large{\@setfontsize\large{15bp}{25bp}}
1778 \DeclareRobustCommand\Large{\@setfontsize\Large{18bp}{30bp}}
1779 \DeclareRobustCommand\LARGE{\@setfontsize\LARGE{22bp}{36.67bp}}
1780 \DeclareRobustCommand\huge{\@setfontsize\huge{24bp}{40bp}}
1781 \DeclareRobustCommand\Huge{\@setfontsize\Huge{26bp}{43.33bp}}
1782 % \end{macrocode}
1783 % \end{macro}
1784 %
1785 % WORD 中的字号对应该关系如下(1bp = 72.27/72 pt):
1786 % \begin{center}
1787 % \begin{longtable}{llll}
1788 % \toprule
1789 % 初号 & 42bp & 14.82mm & 42.1575pt \\
1790 % 小初 & 36bp & 12.70mm & 36.135 pt \\
1791 % 一号 & 26bp & 9.17mm & 26.0975pt \\
1792 % 小一 & 24bp & 8.47mm & 24.09pt \\
1793 % 二号 & 22bp & 7.76mm & 22.0825pt \\
1794 % 小二 & 18bp & 6.35mm & 18.0675pt \\
1795 % 三号 & 16bp & 5.64mm & 16.06pt \\
1796 % 小三 & 15bp & 5.29mm & 15.05625pt \\
1797 % 四号 & 14bp & 4.94mm & 14.0525pt \\
1798 % 小四 & 12bp & 4.23mm & 12.045pt \\
1799 % 五号 & 10.5bp & 3.70mm & 10.59375pt \\
1800 % 小五 & 9bp & 3.18mm & 9.03375pt \\
1801 % 六号 & 7.5bp & 2.56mm & \\
1802 % 小六 & 6.5bp & 2.29mm & \\
1803 % 七号 & 5.5bp & 1.94mm & \\
1804 % 八号 & 5bp & 1.76mm & \\\bottomrule
1805 % \end{longtable}
1806 % \end{center}
1807 %
1808 % \begin{macro}{\hit@def@fontsize}
1809 % 根据习惯定义字号。用法:
1810 %
1811 % \cs{hit@def@fontsize}\marg{字号名称}\marg{磅数}
1812 %
1813 % 避免了字号选择和行距的紧耦合。所有字号定义时为单倍行距,并提供选项指定行距倍数。
1814 % \begin{macrocode}
1815 \def\hit@def@fontsize#1#2{%
1816 \expandafter\newcommand\csname #1\endcsname[1][1.3]{%
1817 \fontsize{#2}{##1\dimexpr #2}\selectfont}}
1818 % \end{macrocode}
1819 % \end{macro}
1820 %
1821 %
1822 % \begin{macro}{\chuhao}
1823 % \begin{macro}{\xiaochu}
1824 % \begin{macro}{\yihao}
1825 % \begin{macro}{\xiaoyi}
1826 % \begin{macro}{\erhao}
1827 % \begin{macro}{\xiaoer}
1828 % \begin{macro}{\sanhao}
1829 % \begin{macro}{\xiaosan}
1830 % \begin{macro}{\sihao}
1831 % \begin{macro}{\xiaosi}
1832 % \begin{macro}{\wuhao}
1833 % \begin{macro}{\xiaowu}
1834 % \begin{macro}{\liuhao}
1835 % \begin{macro}{\xiaoliu}
1836 % \begin{macro}{\qihao}
1837 % \begin{macro}{\bahao}
1838 % 一组字号定义。
1839 % \begin{macrocode}
1840 \hit@def@fontsize{chuhao}{42bp}
1841 \hit@def@fontsize{xiaochu}{36bp}
1842 \hit@def@fontsize{yihao}{26bp}
1843 \hit@def@fontsize{xiaoyi}{24bp}
1844 \hit@def@fontsize{erhao}{22bp}
1845 \hit@def@fontsize{xiaoer}{18bp}
1846 \hit@def@fontsize{sanhao}{16bp}
1847 \hit@def@fontsize{xiaosan}{15bp}
1848 \hit@def@fontsize{sihao}{14bp}
1849 \hit@def@fontsize{xiaosi}{12bp}
1850 \hit@def@fontsize{wuhao}{10.5bp}
1851 \hit@def@fontsize{xiaowu}{9bp}
1852 \hit@def@fontsize{liuhao}{7.5bp}
1853 \hit@def@fontsize{xiaoliu}{6.5bp}
1854 \hit@def@fontsize{qihao}{5.5bp}
1855 \hit@def@fontsize{bahao}{5bp}
1856 % \end{macrocode}
1857 % \end{macro}
1858 % \end{macro}
1859 % \end{macro}
1860 % \end{macro}
1861 % \end{macro}
1862 % \end{macro}
1863 % \end{macro}
1864 % \end{macro}
1865 % \end{macro}
1866 % \end{macro}
1867 % \end{macro}
1868 % \end{macro}
1869 % \end{macro}
1870 % \end{macro}
1871 % \end{macro}
1872 % \end{macro}
1873 %
1874 %
1875 % \subsubsection{文章标题设置}
1876 % \label{sec:paragraphlanguage}
1877 %
1878 % 。
1879 % \begin{macrocode}
1880 \newcommand\hit@set@chapter@names{%
1881 \ctexset{
1882 chapter/name = {第,章},
1883 }%
1884 \def\bibname{参考文献}%
1885 \def\appendixname{附录}%
1886 \def\indexname{索引}%
1887 \def\contentsname{目\quad 录}%
1888 \def\listfigurename{插图索引}%
1889 \def\listtablename{表格索引}%
1890 \def\hit@list@figure@table@name{插图和附表索引}%
1891 \def\hit@list@algorithm@name{算法索引}%
1892 \def\listequationname{公式索引}%
1893 }
1894 \hit@set@chapter@names
1895 % \end{macrocode}
1896 %
1897 % \begin{macrocode}
1898 \newcommand\hit@set@names{%
1899 \ctexset{
1900 figurename = 图,
1901 tablename = 表,
1902 }%
1903 \def\hit@algorithm@name{算法}%
1904 \def\hit@equation@name{公式}%
1905 \def\hit@assumption@name{假设}%
1906 \def\hit@definition@name{定义}%
1907 \def\hit@proposition@name{命题}%
1908 \def\hit@lemma@name{引理}%
1909 \def\hit@theorem@name{定理}%
1910 \def\hit@axiom@name{公理}%
1911 \def\hit@corollary@name{推论}%
1912 \def\hit@exercise@name{练习}%
1913 \def\hit@example@name{例}%
1914 \def\hit@remark@name{注释}%
1915 \def\hit@problem@name{问题}%
1916 \def\hit@conjecture@name{猜想}%
1917 \def\hit@proof@name{证明}%
1918 \def\hit@theorem@separator{:}%
1919 }
1920 \hit@set@names
1921 % \end{macrocode}
1922 %
1923 % 带圈数字和星号使用中文字体。
1924 % \begin{macrocode}
1925 \xeCJKDeclareCharClass{CJK}{"2460 -> "2473}
1926 \xeCJKDeclareCharClass{CJK}{"2605}
1927 % \end{macrocode}
1928 %
1929 % \newcommand\unicodechar[1]{U+#1(\symbol{"#1})}
1930 % 由于 Unicode 的一些标点符号是中西文混用的:
1931 % \unicodechar{00B7}、
1932 % \unicodechar{2013}、
1933 % \unicodechar{2014}、
1934 % \unicodechar{2018}、
1935 % \unicodechar{2019}、
1936 % \unicodechar{201C}、
1937 % \unicodechar{201D}、
1938 % \unicodechar{2025}、
1939 % \unicodechar{2026}、
1940 % \unicodechar{2E3A},
1941 % 所以要根据语言设置正确的字体。
1942 % \footnote{\url{https://github.com/CTeX-org/ctex-kit/issues/389}}
1943 % 此外切换语言时,有一部分名称是需要被重新定义的。
1944 % \begin{macrocode}
1945 \newcommand\hit@set@punctuations{%
1946 \xeCJKDeclareCharClass{FullLeft}{"2018, "201C}%
1947 \xeCJKDeclareCharClass{FullRight}{
1948 "00B7, "2019, "201D, "2013, "2014, "2025, "2026, "2E3A,
1949 }%
1950 }
1951 \hit@set@punctuations
1952 % \end{macrocode}
1953 %
1954 % \subsubsection{页眉页脚}
1955 % \label{sec:headerfooter}
1956 %
1957 % \pkg{fancyhdr} 定义页眉页脚很方便,但是有一个非常隐蔽的坑。
1958 % 第一次调用 \pkg{fancyhdr} 定义的样式时会修改 \cs{chaptermark},
1959 % 这会导致页眉信息错误(多余章号并且英文大写)。
1960 % 这是因为在 \cs{ps@fancy} 中对 \cs{chaptermark} 进行重定义,
1961 % 所以我们先调用 \cs{ps@fancy},再修改 \cs{chaptermark}。
1962 % \begin{macrocode}
1963 \pagestyle{fancy}
1964 % \end{macrocode}
1965 %
1966 % 定义页眉和页脚。
1967 % 页眉宋体五号字,居中书写;
1968 % 页码五号 Times New Roman ,位于页面底端,居中书写。
1969 %
1970 % \begin{macrocode}
1971 \fancypagestyle{plain}{%
1972 \fancyhf{}%
1973 \renewcommand\footrulewidth{0pt}%
1974 \renewcommand\headrulewidth{0.75bp}%
1975 \fancyhead[C]{%
1976 \wuhao
1977 \leftmark
1978 }%
1979 \fancyfoot[C]{\wuhao\thepage}%
1980 \let\@mkboth\markboth
1981 \def\chaptermark##1{%
1982 \markboth{\CTEXifname{\CTEXthechapter\quad}{}##1}{}%
1983 }%
1984 \let\sectionmark\@gobble
1985 }
1986 \pagestyle{plain}
1987 % \end{macrocode}
1988 %
1989 % \cs{chapter} 会调用特殊的 page style。
1990 % \begin{macrocode}
1991 \ctexset{chapter/pagestyle = plain}
1992 % \end{macrocode}
1993 %
1994 %
1995 % \subsubsection{段落}
1996 % \label{sec:paragraph}
1997 %
1998 % 全文首行缩进 2 字符,标点符号用全角
1999 % \begin{macrocode}
2000 \ctexset{%
2001 punct=quanjiao,
2002 space=auto,
2003 }
2004 \newcommand\hit@set@indent{%
2005 \ctexset{autoindent=2}%
2006 }
2007 \hit@set@indent
2008 % \end{macrocode}
2009 %
2010 % 设置 url 样式,与上下文一致
2011 % \begin{macrocode}
2012 \urlstyle{same}
2013 % \end{macrocode}
2014 %
2015 % 使用 \pkg{xurl} 的方法,增加 URL 可断行的位置。
2016 % \begin{macrocode}
2017 \g@addto@macro\UrlBreaks{%
2018 \do0\do1\do2\do3\do4\do5\do6\do7\do8\do9%
2019 \do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M
2020 \do\N\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X\do\Y\do\Z
2021 \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j\do\k\do\l\do\m
2022 \do\n\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w\do\x\do\y\do\z
2023 }
2024 \Urlmuskip=0mu plus 0.1mu
2025 % \end{macrocode}
2026 %
2027 % 取消列表的间距,以符合中文习惯。
2028 % \begin{macrocode}
2029 \partopsep=\z@skip
2030 \def\@listi{\leftmargin\leftmargini
2031 \parsep \z@skip
2032 \topsep \z@skip
2033 \itemsep\z@skip}
2034 \let\@listI\@listi
2035 \@listi
2036 \def\@listii {\leftmargin\leftmarginii
2037 \labelwidth\leftmarginii
2038 \advance\labelwidth-\labelsep
2039 \topsep \z@skip
2040 \parsep \z@skip
2041 \itemsep \z@skip}
2042 \def\@listiii{\leftmargin\leftmarginiii
2043 \labelwidth\leftmarginiii
2044 \advance\labelwidth-\labelsep
2045 \topsep \z@skip
2046 \parsep \z@skip
2047 \partopsep \z@skip
2048 \itemsep \z@skip}
2049 % \end{macrocode}
2050 %
2051 % 使用 \pkg{enumitem} 命令调整默认列表环境间的距离,
2052 % \begin{macrocode}
2053 \setlist{nosep}
2054 % \end{macrocode}
2055 %
2056 %
2057 % \subsubsection{脚注}
2058 % \label{sec:footnote}
2059 % 脚注内容采用小五号字,中文用宋体,英文和数字用 Times New Roman 体按两端对齐格式书写,
2060 % 单倍行距,段前段后均空 0 磅。
2061 % 脚注的序号按页编排,不同页的脚注序号不需要连续。
2062 %
2063 % 脚注处序号“1,……,10”的字体是“正文”,不是“上标”,序号与脚注内容文字之间空半个汉字符,
2064 % 脚注的段落格式为:单倍行距,段前空 0 磅,段后空 0 磅,悬挂缩进 1.5 字符;
2065 % 字号为小五号字,汉字用宋体,外文用 Times New Roman 体。
2066 %
2067 % 脚注序号使用带圈数字。
2068 % \begin{macro}{\hit@circled}
2069 % 生成带圈的脚注数字,最多处理到 10。
2070 % \begin{macrocode}
2071 \newcommand\hit@circled[1]{%
2072 \ifnum#1 >10\relax
2073 \hit@error{%
2074 Too many footnotes in this page.
2075 Keep footnote less than 10%
2076 }%
2077 \fi
2078 {\symbol{\the\numexpr#1+"245F\relax}}%
2079 }
2080 \renewcommand{\thefootnote}{\hit@circled{\c@footnote}}
2081 \renewcommand{\thempfootnote}{\hit@circled{\c@mpfootnote}}
2082 % \end{macrocode}
2083 % \end{macro}
2084 %
2085 % 定义脚注分割线,字号(宋体小五),以及悬挂缩进(1.5字符)。
2086 % \begin{macrocode}
2087 \def\footnoterule{\vskip-3\p@\hrule\@width0.3\textwidth\@height0.4\p@\vskip2.6\p@}
2088 \footnotemargin=13.5bp
2089 % \end{macrocode}
2090 %
2091 % 修改 \pkg{footmisc} 定义的脚注格式。
2092 % \begin{macrocode}
2093 \long\def\@makefntext#1{%
2094 \begingroup
2095 % 序号取消上标
2096 \def\@makefnmark{\hbox{\normalfont\@thefnmark}}%
2097 \xiaowu
2098 \ifFN@hangfoot
2099 \bgroup
2100 \setbox\@tempboxa\hbox{%
2101 \ifdim\footnotemargin>\z@
2102 \hb@xt@\footnotemargin{\@makefnmark\hss}%
2103 \else
2104 \@makefnmark
2105 \fi
2106 }%
2107 \leftmargin\wd\@tempboxa
2108 \rightmargin\z@
2109 \linewidth \columnwidth
2110 \advance \linewidth -\leftmargin
2111 \parshape \@ne \leftmargin \linewidth
2112 % \footnotesize
2113 \xiaowu
2114 \@setpar{{\@@par}}%
2115 \leavevmode
2116 \llap{\box\@tempboxa}%
2117 \parskip\hangfootparskip\relax
2118 \parindent\hangfootparindent\relax
2119 \else
2120 \parindent1em%
2121 \noindent
2122 \ifdim\footnotemargin>\z@
2123 \hb@xt@ \footnotemargin{\hss\@makefnmark}%
2124 \else
2125 \ifdim\footnotemargin=\z@
2126 \llap{\@makefnmark}%
2127 \else
2128 \llap{\hb@xt@ -\footnotemargin{\@makefnmark\hss}}%
2129 \fi
2130 \fi
2131 \fi
2132 \footnotelayout#1%
2133 \ifFN@hangfoot
2134 \par\egroup
2135 \fi
2136 \endgroup
2137 }
2138 % \end{macrocode}
2139 %
2140 %
2141 % \subsubsection{摘要}
2142 % \label{sec:abstractformat}
2143 % 摘要两个字设置为 3 号.
2144 % 定义摘要环境
2145 %
2146 % \begin{macro}{\hit@clist@use}
2147 % 不同论文格式关键词之间的分割不太相同,我们用 \option{keywords}
2148 % 来收集关键词列表,然后用本命令来生成符合要求的格式,
2149 % 类似于 \LaTeX3 的 \cs{clist\_use:Nn}。
2150 % \begin{macrocode}
2151 \hit@define@key{
2152 keywords,
2153 }
2154 \newcommand\hit@clist@use[2]{%
2155 \def\hit@@tmp{}%
2156 \def\hit@clist@processor##1{%
2157 \ifx\hit@@tmp\@empty
2158 \def\hit@@tmp{#2}%
2159 \else
2160 #2%
2161 \fi
2162 ##1%
2163 }%
2164 \expandafter\comma@parse\expandafter{#1}{\hit@clist@processor}%
2165 }
2166 % \end{macrocode}
2167 % \end{macro}
2168 %
2169 % \begin{environment}{abstract}
2170 % 中文摘要部分的标题为“\textbf{摘要}”,用黑体三号字。
2171 % 摘要内容用小四号字书写,两端对齐,汉字用宋体,外文字用 Times New Roman 体,
2172 % 标点符号一律用中文输入状态下的标点符号。
2173 % \begin{macrocode}
2174 \newenvironment{abstract}{%
2175 \cleardoublepage
2176 \begingroup
2177 \hit@chapter*{\hit@abstract@name}%
2178 \endgroup
2179 }{%
2180 % \end{macrocode}
2181 %
2182 % 每个关键词之间空两个汉字符宽度, 且为悬挂缩进。
2183 % \begin{macrocode}
2184 \par
2185 \null\par
2186 \textbf{关键词:}%
2187 \hit@clist@use{\hit@keywords}{;}%
2188 \cleardoublepage
2189 }
2190 % \end{macrocode}
2191 % \end{environment}
2192 %
2193 %
2194 % \subsection{数学环境、定理设置}
2195 % \label{sec:mathenv}
2196 %
2197 % \begin{macro}{\bm}
2198 % \begin{macro}{\boldsymbol}
2199 % 兼容旧的粗体命令:\pkg{bm} 的 \cs{bm} 和 \pkg{amsmath} 的 \cs{boldsymbol}。
2200 % \begin{macrocode}
2201 \DeclareRobustCommand\bm[1]{{\symbf{#1}}}
2202 \DeclareRobustCommand\boldsymbol[1]{{\symbf{#1}}}
2203 % \end{macrocode}
2204 % \end{macro}
2205 % \end{macro}
2206 %
2207 % \begin{macro}{\square}
2208 % 兼容 \pkg{amssymb} 中的命令。
2209 % \begin{macrocode}
2210 \newcommand\square{\mdlgwhtsquare}
2211 % \end{macrocode}
2212 % \end{macro}
2213 %
2214 % \begin{macro}{\checkmark}
2215 % 允许在文本模式中使用 \cs{checkmark}。
2216 % \begin{macrocode}
2217 \AtBeginDocument{%
2218 \renewcommand\checkmark{\ensuremath{✓}}%
2219 }
2220 % \end{macrocode}
2221 % \end{macro}
2222 %
2223 % 允许太长的公式断行、分页等。
2224 % \begin{macrocode}
2225 \allowdisplaybreaks[4]
2226 % \end{macrocode}
2227 %
2228 % \subsubsection{浮动对象:插图和表格}
2229 % \label{sec:float}
2230 %
2231 % 图表浮动体的默认位置设为 |h|。
2232 % \begin{macrocode}
2233 \def\fps@figure{h}
2234 \def\fps@table{h}
2235 % \end{macrocode}
2236 %
2237 % 设置浮动对象和文字之间的距离
2238 % \begin{macrocode}
2239 \setlength{\floatsep}{6bp}
2240 \setlength{\textfloatsep}{6bp}
2241 \setlength{\intextsep}{6bp}
2242 \setlength{\@fptop}{0bp \@plus1.0fil}
2243 \setlength{\@fpsep}{12bp \@plus2.0fil}
2244 \setlength{\@fpbot}{0bp \@plus1.0fil}
2245 % \end{macrocode}
2246 %
2247 % 下面这组命令使浮动对象的缺省值稍微宽松一点,从而防止幅度对象占据过多的文本页面,
2248 % 也可以防止在很大空白的浮动页上放置很小的图形。
2249 % \begin{macrocode}
2250 \renewcommand{\textfraction}{0.15}
2251 \renewcommand{\topfraction}{0.85}
2252 \renewcommand{\bottomfraction}{0.65}
2253 \renewcommand{\floatpagefraction}{0.60}
2254 % \end{macrocode}
2255 %
2256 % 允许用户设置图表编号的连接符。
2257 % \begin{macrocode}
2258 \hit@define@key{
2259 figure-number-separator = {
2260 name = figure@number@separator,
2261 default = {.},
2262 },
2263 table-number-separator = {
2264 name = table@number@separator,
2265 default = {.},
2266 },
2267 equation-number-separator = {
2268 name = equation@number@separator,
2269 default = {.},
2270 },
2271 number-separator = {
2272 name = number@separator,
2273 default = {.},
2274 },
2275 }
2276 \renewcommand\thefigure{%
2277 \ifnum\c@chapter>\z@
2278 \thechapter
2279 \hit@figure@number@separator
2280 \fi
2281 \@arabic\c@figure
2282 }
2283 \renewcommand\thetable{%
2284 \ifnum\c@chapter>\z@
2285 \thechapter
2286 \hit@table@number@separator
2287 \fi
2288 \@arabic\c@table
2289 }
2290 \renewcommand\theequation{%
2291 \ifnum\c@chapter>\z@
2292 \thechapter
2293 \hit@equation@number@separator
2294 \fi
2295 \@arabic\c@equation
2296 }
2297 \newcommand\hit@set@number@separator{%
2298 \let\hit@figure@number@separator\hit@number@separator
2299 \let\hit@table@number@separator\hit@number@separator
2300 \let\hit@equation@number@separator\hit@number@separator
2301 }
2302 \hit@option@hook{number-separator}{\hit@set@number@separator}
2303 % \end{macrocode}
2304 %
2305 %
2306 % 对 \pkg{longtable} 跨页表格进行相同的设置。
2307 % \begin{macrocode}
2308 \AtEndOfPackageFile*{longtable}{
2309 \AtBeginEnvironment{longtable}{%
2310 \fontsize{11bp}{20.3bp}\selectfont
2311 }
2312 }
2313 % \end{macrocode}
2314 %
2315 % 定制浮动图形和表格标题样式,以及改变附录中浮动体的编号规则:
2316 % \begin{itemize}
2317 % \item 图表标题字体为 11pt
2318 % \item 去掉图表号后面的冒号,图序与图名文字之间空一个汉字符宽度
2319 % \item 图:caption 在下,段前空 6 磅,段后空 12 磅
2320 % \item 表:caption 在上,段前空 12 磅,段后空 6 磅
2321 % \end{itemize}
2322 % \begin{macrocode}
2323 \DeclareCaptionFont{hit}{%
2324 \fontsize{11bp}{15bp}\selectfont
2325 }
2326 \captionsetup{
2327 font = hit,
2328 labelsep = quad,
2329 aboveskip = 6bp,
2330 belowskip = 6bp,
2331 figureposition = bottom,
2332 tableposition = top,
2333 }
2334 \captionsetup[sub]{font=hit}
2335 \renewcommand{\thesubfigure}{(\alph{subfigure})}
2336 \renewcommand{\thesubtable}{(\alph{subtable})}
2337 % \renewcommand{\p@subfigure}{:}
2338 % \end{macrocode}
2339 %
2340 % 研究生和本科生都推荐使用三线表,并且要求表的上、下边线为单直线,线粗为 1.5 磅;
2341 % 第三条线为单直线,线粗为 1 磅。
2342 % 这里设置 \pkg{booktabs} 线粗的默认值。
2343 % \begin{macrocode}
2344 \heavyrulewidth=1.5bp
2345 \lightrulewidth=1bp
2346 % \end{macrocode}
2347 %
2348 % \begin{macrocode}
2349 \AtEndOfPackageFile*{threeparttable}{
2350 \g@addto@macro\TPT@defaults{\wuhao}
2351 }
2352 % \end{macrocode}
2353 %
2354 % \subsubsection{章节标题}
2355 % \label{sec:theor}
2356 % \begin{macrocode}
2357 \newcommand{\hit@abstract@name}{摘 \quad 要}
2358 \newcommand{\hit@abstract@name@en}{Abstract}
2359 % \end{macrocode}
2360 %
2361 % 各级标题格式设置。
2362 % \begin{macrocode}
2363 \ctexset{%
2364 chapter = {
2365 nameformat = {},
2366 numberformat = {},
2367 titleformat = {},
2368 fixskip = true,
2369 afterindent = true,
2370 lofskip = 0pt,
2371 lotskip = 0pt,
2372 },
2373 section = {
2374 afterindent = true,
2375 },
2376 subsection = {
2377 afterindent = true,
2378 },
2379 subsubsection = {
2380 afterindent = true,
2381 },
2382 paragraph/afterindent = true,
2383 subparagraph/afterindent = true,
2384 }
2385 % \end{macrocode}
2386 %
2387 % 本模板设置:
2388 % \begin{itemize}
2389 % \item 各章标题,例如:“\textsf{第 1 章 引言}”。
2390 %
2391 % 章序号与章名之间空一个汉字符。
2392 % 采用黑体三号字,居中书写,单倍行距,
2393 % 段前空 24 磅,段后空 18 磅。
2394 %
2395 % \item 一级节标题,例如:“\textsf{2.1 实验装置与实验方法}”。
2396 %
2397 % 节标题序号与标题名之间空一个汉字符(下同)。
2398 % 采用黑体四号(14pt)字居左书写,行距为固定值 20 磅,
2399 % 段前空 24 磅,段后空 6 磅。
2400 %
2401 % \item 二级节标题,例如:“\textsf{2.1.1 实验装置}”。
2402 %
2403 % 采用黑体 13pt 字居左书写,行距为固定值 20 磅,
2404 % 段前空 12 磅,段后空 6 磅。
2405 %
2406 % \item 三级节标题,例如:“\textsf{2.1.2.1 归纳法}”。
2407 %
2408 % 采用黑体小四号(12pt)字居左书写,行距为固定值 20 磅,
2409 % 段前空 12 磅,段后空 6 磅。
2410 % \end{itemize}
2411 %
2412 % 这里三级节标题的“中文黑体小四号”取 13pt。
2413 % \begin{macrocode}
2414 \newcommand\hit@set@section@format{%
2415 \ctexset{%
2416 chapter = {
2417 format = \centering\sffamily\sanhao,
2418 nameformat = {},
2419 titleformat = {},
2420 beforeskip = 27bp,
2421 afterskip = 27bp,
2422 aftername = \quad,
2423 },
2424 section = {
2425 format = \sffamily\fontsize{14bp}{20bp}\selectfont,
2426 beforeskip = 24bp,
2427 afterskip = 6bp,
2428 aftername = \quad,
2429 },
2430 subsection = {
2431 format = \sffamily\fontsize{13bp}{20bp}\selectfont,
2432 beforeskip = 12bp,
2433 afterskip = 6bp,
2434 aftername = \quad,
2435 },
2436 subsubsection = {
2437 format = \sffamily\fontsize{12bp}{20bp}\selectfont,
2438 beforeskip = 12bp,
2439 afterskip = 6bp,
2440 aftername = \quad,
2441 },
2442 }%
2443 \ctexset{chapter/number = \thechapter}%
2444 }
2445 \hit@set@section@format
2446 % \end{macrocode}
2447 %
2448 % \begin{macro}{\hit@chapter*}
2449 % 模板定义所有的章都出现在目录里,比如摘要、Abstract、主要符号表等。
2450 %
2451 % \begin{macrocode}
2452 \newcommand\hit@pdfbookmark[2]{}
2453 \newcommand\hit@phantomsection{}
2454 \NewDocumentCommand\hit@chapter{s o m o}{%
2455 \IfBooleanF{#1}{%
2456 \hit@error{You have to use the star form: \string\hit@chapter*}%
2457 }%
2458 \if@openright\cleardoublepage\else\clearpage\fi%
2459 \IfValueTF{#2}{%
2460 \ifthenelse{\equal{#2}{}}{%
2461 \hit@pdfbookmark{0}{#3}%
2462 }{%
2463 \hit@phantomsection
2464 \addcontentsline{toc}{chapter}{#2}%
2465 }%
2466 }{%
2467 \hit@phantomsection
2468 \addcontentsline{toc}{chapter}{#3}%
2469 }%
2470 \ctexset{chapter/beforeskip=40bp}
2471 \chapter*{#3}%
2472 \ctexset{chapter/beforeskip=30bp}
2473 \IfValueTF{#4}{%
2474 \ifthenelse{\equal{#4}{}}{%
2475 \@mkboth{}{}%
2476 }{%
2477 \@mkboth{#4}{#4}%
2478 }%
2479 }{%
2480 \@mkboth{#3}{#3}%
2481 }%
2482 }
2483 % \end{macrocode}
2484 % \end{macro}
2485 %
2486 %
2487 % \subsubsection{目录}
2488 % \label{sec:toc}
2489 % 最多 4 层,即: x.x.x.x,对应的命令和层序号分别是:
2490 % \cs{chapter}(0), \cs{section}(1), \cs{subsection}(2), \cs{subsubsection}(3)。
2491 % \begin{macrocode}
2492 \setcounter{secnumdepth}{3}
2493 \setcounter{tocdepth}{2}
2494 % \end{macrocode}
2495 %
2496 % \begin{macro}{\tableofcontents}
2497 % 目录生成命令。
2498 % \begin{macrocode}
2499 \renewcommand\tableofcontents{%
2500 \hit@chapter*[]{\contentsname}%
2501 \@starttoc{toc}%
2502 }
2503 \hit@define@key{
2504 toc-chapter-style = {
2505 name = toc@chapter@style,
2506 choices = {
2507 arial,
2508 times,
2509 },
2510 default = arial,
2511 },
2512 }
2513 \newcommand\hit@leaders{\titlerule*[4bp]{.}}
2514 \newcommand\hit@set@toc@format{%
2515 \contentsmargin{\z@}%
2516 % \end{macrocode}
2517 %
2518 % 目录从第 1 章开始,每章标题用黑体小四号字,行间距为 20pt,
2519 % 行前空 6pt,行后空 0pt。
2520 % 其它级节标题用宋体小四字,行间距为 20pt。
2521 %
2522 % 注意示例中章标题的字母和数字是衬线体,所以这里用 \cs{heiti}。
2523 % 示例中的一级和二级节标题分别缩进 1 和 1.5 个汉字符。
2524 % \begin{macrocode}
2525 \titlecontents{chapter}
2526 [\z@]{\addvspace{6bp}\sffamily}
2527 {\contentspush{\thecontentslabel\quad}}{}
2528 {\rmfamily\hit@leaders\thecontentspage}%
2529 \titlecontents{section}
2530 [1em]{}
2531 {\contentspush{\thecontentslabel\quad}}{}
2532 {\hit@leaders\thecontentspage}%
2533 \titlecontents{subsection}
2534 [2em]{}
2535 {\contentspush{\thecontentslabel\quad}}{}
2536 {\hit@leaders\thecontentspage}%
2537 }
2538 % \end{macrocode}
2539 %
2540 % \begin{macrocode}
2541 \hit@set@toc@format
2542 % \end{macrocode}
2543 % \end{macro}
2544 %
2545 %
2546 %
2547 % \subsection{参考文献环境设置}
2548 % \label{sec:bib}
2549 %
2550 % 重定义参考文献环境
2551 % \begin{macrocode}
2552 \renewenvironment{thebibliography}[1]
2553 {\section*{\refname}%
2554 \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
2555 \list{\@biblabel{\@arabic\c@enumiv}}%
2556 {\settowidth\labelwidth{\@biblabel{#1}}%
2557 \leftmargin\labelwidth
2558 \advance\leftmargin\labelsep
2559 \@openbib@code
2560 \usecounter{enumiv}%
2561 \let\p@enumiv\@empty
2562 \renewcommand\theenumiv{\@arabic\c@enumiv}}%
2563 \sloppy
2564 \clubpenalty4000
2565 \@clubpenalty \clubpenalty
2566 \widowpenalty4000%
2567 \sfcode`\.\@m}
2568 {\def\@noitemerr
2569 {\@latex@warning{Empty `thebibliography' environment}}%
2570 \endlist}
2571 % \end{macrocode}
2572 %
2573 %
2574 % \subsection{其他环境设置}
2575 % \label{sec:config}
2576 %
2577 % \subsubsection{\pkg{amsthm} 宏包}
2578 %
2579 % 定理标题使用黑体,正文使用宋体,冒号隔开。
2580 % \begin{macrocode}
2581 \AtEndOfPackageFile*{amsthm}{%
2582 \newtheoremstyle{hit}
2583 {\z@}{\z@}
2584 {\normalfont}{\z@}
2585 {\normalfont\sffamily}{\hit@theorem@separator}
2586 {0.5em}{}
2587 \theoremstyle{hit}
2588 \newtheorem{assumption}{\hit@assumption@name}[chapter]%
2589 \newtheorem{definition}{\hit@definition@name}[chapter]%
2590 \newtheorem{proposition}{\hit@proposition@name}[chapter]%
2591 \newtheorem{lemma}{\hit@lemma@name}[chapter]%
2592 \newtheorem{theorem}{\hit@theorem@name}[chapter]%
2593 \newtheorem{axiom}{\hit@axiom@name}[chapter]%
2594 \newtheorem{corollary}{\hit@corollary@name}[chapter]%
2595 \newtheorem{exercise}{\hit@exercise@name}[chapter]%
2596 \newtheorem{example}{\hit@example@name}[chapter]%
2597 \newtheorem{remark}{\hit@remark@name}[chapter]%
2598 \newtheorem{problem}{\hit@problem@name}[chapter]%
2599 \newtheorem{conjecture}{\hit@conjecture@name}[chapter]%
2600 \renewenvironment{proof}[1][\hit@proof@name]{\par
2601 \pushQED{\qed}%
2602 % \normalfont \topsep6\p@\@plus6\p@\relax
2603 \normalfont \topsep\z@\relax
2604 \trivlist
2605 \item[\hskip\labelsep
2606 % \itshape
2607 % #1\@addpunct{.}]\ignorespaces
2608 \sffamily
2609 #1\@addpunct{\hit@theorem@separator}]\ignorespaces
2610 }{%
2611 \popQED\endtrivlist\@endpefalse
2612 }
2613 \renewcommand\qedsymbol{\ensuremath{\QED}}
2614 }
2615 % \end{macrocode}
2616 %
2617 % \subsubsection{\pkg{ntheorem} 宏包}
2618 %
2619 % 定理标题使用黑体,正文使用宋体,冒号隔开。
2620 % \begin{macrocode}
2621 \AtEndOfPackageFile*{ntheorem}{%
2622 \theorembodyfont{\normalfont}%
2623 \theoremheaderfont{\normalfont\sffamily}%
2624 \theoremsymbol{\ensuremath{\QED}}%
2625 \newtheorem*{proof}{\hit@proof@name}%
2626 \theoremstyle{plain}%
2627 \theoremsymbol{}%
2628 \theoremseparator{\hit@theorem@separator}%
2629 \newtheorem{assumption}{\hit@assumption@name}[chapter]%
2630 \newtheorem{definition}{\hit@definition@name}[chapter]%
2631 \newtheorem{proposition}{\hit@proposition@name}[chapter]%
2632 \newtheorem{lemma}{\hit@lemma@name}[chapter]%
2633 \newtheorem{theorem}{\hit@theorem@name}[chapter]%
2634 \newtheorem{axiom}{\hit@axiom@name}[chapter]%
2635 \newtheorem{corollary}{\hit@corollary@name}[chapter]%
2636 \newtheorem{exercise}{\hit@exercise@name}[chapter]%
2637 \newtheorem{example}{\hit@example@name}[chapter]%
2638 \newtheorem{remark}{\hit@remark@name}[chapter]%
2639 \newtheorem{problem}{\hit@problem@name}[chapter]%
2640 \newtheorem{conjecture}{\hit@conjecture@name}[chapter]%
2641 }
2642 % \end{macrocode}
2643 %
2644 % \subsubsection{\pkg{algorithm} 宏包}
2645 %
2646 % 使 \env{algorithm} 和 \env{listing} 环境的名称随语言设置而改变,
2647 % 并使其在附录中的编号规则与图、表等一致。
2648 %
2649 % \begin{macro}{\listofalgorithm}
2650 % \begin{macro}{\listofalgorithm*}
2651 % \begin{macrocode}
2652 \PassOptionsToPackage{chapter}{algorithm}
2653 \AtEndOfPackageFile*{algorithm}{
2654 \floatname{algorithm}{\hit@algorithm@name}
2655 \renewcommand\listofalgorithms{%
2656 \hit@listof{algorithm}%
2657 }
2658 \renewcommand\listalgorithmname{\hit@list@algorithm@name}
2659 \def\ext@algorithm{loa}
2660 \contentsuse{algorithm}{loa}
2661 \titlecontents{algorithm}
2662 [\z@]{}
2663 {\contentspush{\fname@algorithm~\thecontentslabel\quad}}{}
2664 {\hit@leaders\thecontentspage}
2665 }
2666 % \end{macrocode}
2667 % \end{macro}
2668 % \end{macro}
2669 %
2670 % \subsubsection{\pkg{algorithm2e} 宏包}
2671 %
2672 % \begin{macrocode}
2673 \PassOptionsToPackage{algochapter}{algorithm2e}
2674 \AtEndOfPackageFile*{algorithm2e}{
2675 \renewcommand\algorithmcfname{\hit@algorithm@name}
2676 \SetAlgoCaptionLayout{hit@caption@font}
2677 \SetAlCapSty{relax}
2678 \SetAlgoCaptionSeparator{\hspace*{1em}}
2679 \SetAlFnt{\fontsize{11bp}{14.3bp}\selectfont}
2680 \renewcommand\listofalgorithms{%
2681 \hit@listof{algorithmcf}%
2682 }
2683 \renewcommand\listalgorithmcfname{\hit@list@algorithm@name}
2684 \def\ext@algorithmcf{loa}
2685 \contentsuse{algocf}{loa}
2686 \titlecontents{algocf}
2687 [\z@]{}
2688 {\contentspush{\algorithmcfname~\thecontentslabel\quad}}{}
2689 {\hit@leaders\thecontentspage}
2690 }
2691 % \end{macrocode}
2692 %
2693 % \subsubsection{\pkg{minted} 宏包}
2694 %
2695 % \begin{macrocode}
2696 \AtEndOfPackageFile*{minted}{
2697 \newcommand\hit@set@listing@language{%
2698 \floatname{listing}{代码}%
2699 }
2700 \hit@set@listing@language
2701 }
2702 % \end{macrocode}
2703 %
2704 %
2705 % \subsubsection{\pkg{hyperref} 宏包}
2706 %
2707 % \begin{macrocode}
2708 \AtEndOfPackageFile*{hyperref}{
2709 \hypersetup{
2710 linktoc = all,
2711 bookmarksnumbered = true,
2712 bookmarksopen = true,
2713 bookmarksopenlevel = 1,
2714 unicode = true,
2715 psdextra = true,
2716 breaklinks = true,
2717 plainpages = false,
2718 pdfdisplaydoctitle = true,
2719 hidelinks,
2720 }%
2721 % \end{macrocode}
2722 %
2723 % \pkg{hyperref} 与 \pkg{unicode-math} 存在一些兼容性问题,见
2724 % \href{https://github.com/ustctug/ustcthesis/issues/223}{%
2725 % ustctug/ustcthesis\#223},
2726 % \href{https://github.com/ho-tex/hyperref/pull/90}{ho-tex/hyperref\#90} 和
2727 % \href{https://github.com/ustctug/ustcthesis/issues/235}{%
2728 % ustctug/ustcthesis/\#235}。
2729 % \begin{macrocode}
2730 \@ifpackagelater{hyperref}{2019/04/27}{}{%
2731 \g@addto@macro\psdmapshortnames{\let\mu\textmu}
2732 }%
2733 \hypersetup{
2734 pdflang = zh-CN,
2735 }%
2736 \AtBeginDocument{%
2737 \hypersetup{
2738 pdftitle = \hit@title,
2739 pdfauthor = \hit@author,
2740 }%
2741 \hypersetup{
2742 pdfcreator={hitreport-v1.0}}
2743 }%
2744 }
2745 % \end{macrocode}
2746 %
2747 %
2748 % 浮动环境设置
2749 % 默认情况下, \LaTeX{} 要求每页的文字至少占据 20\%,否则该页就只单独放置一个浮动环境,
2750 % 而这通常不是我们想要的, 我们将这个要求降低到 5\%.
2751 % \begin{macrocode}
2752 \renewcommand*{\textfraction}{0.05}
2753 % \end{macrocode}
2754 % 有时如果多个浮动环境连续放在一起, \LaTeX{}会将它们分在几个不同页,即使它们可在同一页放
2755 % 得下. 我们可以通过修改 |\topfraction| 和 |\bottomfraction| 分别设置顶端和底端的浮动环境的最大比例.
2756 % \begin{macrocode}
2757 \renewcommand*{\topfraction}{0.9}
2758 \renewcommand*{\bottomfraction}{0.8}
2759 % \end{macrocode}
2760 % 有时\LaTeX{}会把一个浮动环境单独放在一页,
2761 % 我们要求这个环境至少要占据 85% 才能单独放在一页.
2762 % 注意: |\floatpagefraction| 的数值必须小于 |\topfraction|.
2763 % \begin{macrocode}
2764 \renewcommand*{\floatpagefraction}{0.85}
2765 % \end{macrocode}
2766 % 关于图片 graphicx
2767 % 如果图片没有指定后缀, 依次按下列顺序搜索
2768 % \begin{macrocode}
2769 \DeclareGraphicsExtensions{.pdf,.eps,.jpg,.png}
2770 % \end{macrocode}
2771 % 设置图表搜索路径, 可以给图表文件夹取如下名字
2772 % \begin{macrocode}
2773 \graphicspath{{figures/}{figure/}{pictures/}{picture/}{pic/}{pics/}{image/}{images/}}
2774 % \end{macrocode}
2775 % 图表标题
2776 % \begin{macrocode}
2777 \DeclareCaptionFont{song}{\songti}
2778 \DeclareCaptionFont{minusfour}{\zihao{-4}}
2779 \captionsetup[figure]{
2780 format=hang, %标题从第二行开始都有缩进, 应该和 justification=raggedright 的效果一样.
2781 labelsep=quad, %分隔符是一个空格
2782 font={song,minusfour,bf}, %图的字体, 宋体小四
2783 position=bottom %position=bottom, 不代表标题放在下面, 标题仍放在你放\caption的位置.
2784 }
2785 \captionsetup[table]{%
2786 format=hang, % 标题从第二行开始都有缩进, 应该和 justification=raggedright 的效果一样.
2787 labelsep=quad, % 分隔符是一个空格
2788 font={song,minusfour,bf}, % 表的字体, 宋体小四
2789 position=top % position=bottom, 不代表标题放在下面, 标题仍放在你放\caption的位置.
2790 }
2791 % \end{macrocode}
2792 %
2793 % 列表环境设置
2794 % \begin{macrocode}
2795 \setlist{%
2796 topsep=0.3em, % 列表顶端的垂直空白
2797 partopsep=0pt, % 列表环境前面紧接着一个空白行时其顶端的额外垂直空白
2798 itemsep=0ex plus 0.1ex, % 列表项之间的额外垂直空白
2799 parsep=0pt, % 列表项内的段落之间的垂直空白
2800 leftmargin=1.5em, % 环境的左边界和列表之间的水平距离
2801 rightmargin=0em, % 环境的右边界和列表之间的水平距离
2802 labelsep=0.5em, % 包含标签的盒子与列表项的第一行文本之间的间隔
2803 labelwidth=2em % 包含标签的盒子的正常宽度;若实际宽度更宽,则使用实际宽度。
2804 }
2805 % \end{macrocode}
2806 %
2807 % \subsection{封面信息}
2808 % \label{sec:cover}
2809 %
2810 %
2811 % 报告题目。
2812 % \begin{macrocode}
2813 \hit@define@key{
2814 title = {
2815 default = {标题},
2816 },
2817 % \end{macrocode}
2818 %
2819 % 报告小标题
2820 % \begin{macrocode}
2821 expand = {
2822 default = {小标题},
2823 },
2824 % \end{macrocode}
2825 %
2826 % 姓名、学号、指导老师。
2827 % \begin{macrocode}
2828 author = {
2829 default = {姓名},
2830 },
2831 student-id = {
2832 name = student@id,
2833 },
2834 supervisor = {
2835 default = {导师姓名},
2836 },
2837 % \end{macrocode}
2838 %
2839 % 院系名称。
2840 % \begin{macrocode}
2841 department = {
2842 default = {计算学部},
2843 },
2844 % \end{macrocode}
2845 %
2846 % 专业名称。
2847 % \begin{macrocode}
2848 discipline = {
2849 default = {计算机科学与技术},
2850 },
2851 % \end{macrocode}
2852 %
2853 % 班级序号
2854 % \begin{macrocode}
2855 classnum = {
2856 default = {1803105}
2857 },
2858 % \end{macrocode}
2859 %
2860 % 实验地点
2861 % \begin{macrocode}
2862 lablocation = {
2863 default = {格物207}
2864 },
2865 % \end{macrocode}
2866 %
2867 % 学期
2868 % \begin{macrocode}
2869 term = {
2870 default = {2021春}
2871 },
2872 % \end{macrocode}
2873 %
2874 % 报告成文日期。
2875 % \begin{macrocode}
2876 date = {
2877 default = {\the\year-\two@digits{\month}-\two@digits{\day}},
2878 }
2879 }
2880 % \end{macrocode}
2881 %
2882 % 输出日期的给定格式:\cs{hit@format@date}\marg{format}\marg{date},
2883 % 其中格式 \meta{format} 接受三个参数分别对应年、月、日,
2884 % \meta{date} 是 ISO 格式的日期(yyyy-mm-dd)。
2885 % \begin{macrocode}
2886 \newcommand\hit@format@date[2]{%
2887 \edef\hit@@date{#2}%
2888 \def\hit@@process@date##1-##2-##3\@nil{%
2889 #1{##1}{##2}{##3}%
2890 }%
2891 \expandafter\hit@@process@date\hit@@date\@nil
2892 }
2893 \newcommand\hit@date@zh@digit[3]{#1 年 \number#2 月 \number#3 日}
2894 \newcommand\hit@date@zh@digit@short[3]{#1 年 \number#2 月}
2895 \newcommand\hit@date@zh@short[3]{\zhdigits{#1}年\zhnumber{#2}月}
2896 \newcommand\hit@date@month[1]{%
2897 \ifcase\number#1\or
2898 January\or February\or March\or April\or May\or June\or
2899 July\or August\or September\or October\or November\or December%
2900 \fi
2901 }
2902 \newcommand\hit@date@en@short[3]{\hit@date@month{#2}, #1}
2903 % \end{macrocode}
2904 %
2905 %
2906 % 下划线命令
2907 % \begin{macrocode}
2908 \newcommand\hit@underline[2][6em]{\hskip1pt\underline{\hb@xt@ #1{\hss#2\hss}}\hskip3pt}
2909 \newcommand\hit@CJKunderline[2][6em]{\CJKunderline*{\hb@xt@ #1{\hss#2\hss}}}
2910 % \end{macrocode}
2911 %
2912 %
2913 % 封面表格信息
2914 % \begin{macrocode}
2915 \newcommand\hit@titlepage@info{%
2916 \large
2917 \renewcommand{\arraystretch}{1}
2918 \begin{tabular}{lp{3.5cm}<{\centering}lc}
2919 \makebox[4em][s]{学\hspace{\fill}院}\hit@theorem@separator & {\hit@department} & \hspace{1em} \makebox[4em][s]{专\hspace{\fill}业}\hit@theorem@separator & {\hit@discipline} \\ \cline{2-2} \cline{4-4}
2920 \makebox[4em][s]{班\hspace{\fill}级}\hit@theorem@separator & {\hit@classnum} & \hspace{1em} \makebox[4em][s]{学\hspace{\fill}号}\hit@theorem@separator & {\hit@student@id} \\ \cline{2-2} \cline{4-4}
2921 \makebox[4em][s]{姓\hspace{\fill}名}\hit@theorem@separator & {\hit@author} &\hspace{1em} \makebox[4em][s]{实验地点}\hit@theorem@separator& {\hit@lablocation} \\ \cline{2-2} \cline{4-4}
2922 \makebox[4em][s]{指导老师}\hit@theorem@separator& {\hit@supervisor} &\hspace{1em} \makebox[4em][s]{学\hspace{\fill}期}\hit@theorem@separator & {\hit@term} \\ \cline{2-2} \cline{4-4}
2923 \end{tabular}
2924 }
2925 % \end{macrocode}
2926 %
2927 %
2928 % 论文成文打印的日期,用三号宋体汉字,字距延伸 0.5bp,
2929 % 所以 \cs{CJKglue} 应该设为 1 bp。
2930 % \begin{macrocode}
2931 \newcommand\hit@titlepage@date{%
2932 \begingroup
2933 \sanhao
2934 \def\CJKglue{\hskip 1bp}%
2935 \hit@format@date{\hit@date@zh@short}{\hit@date}\par
2936 \endgroup
2937 }
2938 % \end{macrocode}
2939 %
2940 % 生成封面,使用\cs{maketitle}命令
2941 % \begin{macrocode}
2942 \renewcommand\maketitle{
2943 \cleardoublepage
2944 \pagenumbering{Alph}%
2945 \hit@maketitlepage
2946 \clearpage
2947 }
2948 % \end{macrocode}
2949 %
2950 %
2951 % 根据校区选择校区校徽及校名图片
2952 % \begin{macrocode}
2953 \newcommand\hit@titlepage@fig{
2954 \ifhit@campus@harbin
2955 \begin{center}
2956 \begin{figure}[h]
2957 \includegraphics[scale=0.5]{photo/hithrb.pdf} % 本部校徽图片
2958 \end{figure}
2959 \end{center}
2960 \else
2961 \ifhit@campus@shenzhen
2962 \begin{center}
2963 \begin{figure}[h]
2964 \includegraphics[scale=0.26]{photo/hitsz.pdf} % 深圳校区校徽图片
2965 \end{figure}
2966 \end{center}
2967 \else
2968 \ifhit@campus@weihai
2969 \begin{center}
2970 \begin{figure}[h]
2971 \includegraphics[scale=0.26]{photo/hitwh.pdf} % 校徽图片
2972 \end{figure}
2973 \end{center}
2974 \fi
2975 \fi
2976 \fi
2977 }
2978 % \end{macrocode}
2979 %
2980 % 定义封面
2981 % \begin{macrocode}
2982 \newcommand\hit@maketitlepage{%
2983 \newgeometry{
2984 vmargin = 2.54cm,
2985 hmargin = 3.17cm,
2986 }
2987 \newpage
2988 \hit@titlepage@fig
2989 \vspace{1.5cm}
2990 \begingroup
2991 \centering
2992 \textbf{\huawenxingkai \fontsize{32}{0} \selectfont \hit@title}\\
2993 \endgroup
2994 \vspace{2cm}
2995 \begingroup
2996 \centering
2997 \textbf{\heiti \fontsize{20}{0} \selectfont \hit@expand}\\
2998 \endgroup
2999 \vspace{2.5cm}
3000 \parbox[h][10cm][t]{\textwidth}{\centering\hit@titlepage@info}\par
3001 \begingroup
3002 \centering
3003 {\heiti \sihao\hit@format@date{\hit@date@zh@digit}{\hit@date}\par}%
3004 \endgroup
3005 \thispagestyle{empty}
3006 \restoregeometry
3007 }
3008 % \end{macrocode}
3009 %
3010 % 定义附录
3011 % \begin{macrocode}
3012 \renewcommand{\setthesection}{\appendixname\Alph{section}}
3013 \renewcommand\appendix{\par
3014 \setcounter{section}{0}%
3015 \setcounter{subsection}{0}%
3016 \gdef\thesection{\appendixname\@Alph\c@section}}
3017 % \end{macrocode}
3018 %
3019 % \subsection{其它}
3020 % \label{sec:other}
3021 %
3022 % 借用 \cls{ltxdoc} 和 \cls{l3doc} 里面的几个命令方便写文档。
3023 % \begin{macrocode}
3024 \DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
3025 \DeclareRobustCommand\file{\nolinkurl}
3026 \DeclareRobustCommand\env{\textsf}
3027 \DeclareRobustCommand\pkg{\textsf}
3028 \DeclareRobustCommand\cls{\textsf}
3029 % \end{macrocode}
3030 %
3031 % \begin{macrocode}
3032 \sloppy
3033 %</cls>
3034 % \end{macrocode}
3035 %
3036 %
3037 % \iffalse
3038 % \begin{macrocode}
3039 %<*dtx-style>
3040 \ProvidesPackage{dtx-style}
3041 \RequirePackage{hypdoc}
3042 \RequirePackage{ifthen}
3043 \RequirePackage{fontspec}[2017/01/20]
3044 \RequirePackage{amsmath}
3045 \RequirePackage{unicode-math}
3046 \RequirePackage[UTF8,scheme=chinese]{ctex}
3047 \RequirePackage[
3048 top=25mm, bottom=25mm,
3049 left=40mm, right=20mm,
3050 headsep=3mm]{geometry}
3051 \RequirePackage{hologo}
3052 \RequirePackage{array,longtable,booktabs}
3053 \RequirePackage{listings}
3054 \RequirePackage{fancyhdr}
3055 \RequirePackage{xcolor}
3056 \RequirePackage{enumitem}
3057 \RequirePackage{etoolbox}
3058 \RequirePackage{metalogo}
3059
3060 \unimathsetup{
3061 math-style=ISO,
3062 bold-style=ISO,
3063 }
3064
3065 \DeclareRobustCommand\mathellipsis{\mathinner{\unicodecdots}}
3066 \IfFontExistsTF{XITSMath-Regular.otf}{
3067 \setmathfont[
3068 Extension = .otf,
3069 BoldFont = XITSMath-Bold,
3070 StylisticSet = 8,
3071 ]{XITSMath-Regular}
3072 \setmathfont[range={cal,bfcal},StylisticSet=1]{XITSMath-Regular.otf}
3073 }{
3074 \setmathfont[
3075 Extension = .otf,
3076 BoldFont = *bold,
3077 StylisticSet = 8,
3078 ]{xits-math}
3079 \setmathfont[range={cal,bfcal},StylisticSet=1]{xits-math.otf}
3080 }
3081
3082 \colorlet{hit@macro}{blue!60!black}
3083 \colorlet{hit@env}{blue!70!black}
3084 \colorlet{hit@option}{purple}
3085 \patchcmd{\PrintMacroName}{\MacroFont}{\MacroFont\bfseries\color{hit@macro}}{}{}
3086 \patchcmd{\PrintDescribeMacro}{\MacroFont}{\MacroFont\bfseries\color{hit@macro}}{}{}
3087 \patchcmd{\PrintDescribeEnv}{\MacroFont}{\MacroFont\bfseries\color{hit@env}}{}{}
3088 \patchcmd{\PrintEnvName}{\MacroFont}{\MacroFont\bfseries\color{hit@env}}{}{}
3089
3090 \def\DescribeOption{%
3091 \leavevmode\@bsphack\begingroup\MakePrivateLetters%
3092 \Describe@Option}
3093 \def\Describe@Option#1{\endgroup
3094 \marginpar{\raggedleft\PrintDescribeOption{#1}}%
3095 \hit@special@index{option}{#1}\@esphack\ignorespaces}
3096 \def\PrintDescribeOption#1{\strut \MacroFont\bfseries\sffamily\color{hit@option} #1\ }
3097 \def\hit@special@index#1#2{\@bsphack
3098 \begingroup
3099 \HD@target
3100 \let\HDorg@encapchar\encapchar
3101 \edef\encapchar usage{%
3102 \HDorg@encapchar hdclindex{\the\c@HD@hypercount}{usage}%
3103 }%
3104 \index{#2\actualchar{\string\ttfamily\space#2}
3105 (#1)\encapchar usage}%
3106 \index{#1:\levelchar#2\actualchar
3107 {\string\ttfamily\space#2}\encapchar usage}%
3108 \endgroup
3109 \@esphack}
3110
3111 \lstdefinestyle{lstStyleBase}{%
3112 basicstyle=\small\ttfamily,
3113 aboveskip=\medskipamount,
3114 belowskip=\medskipamount,
3115 lineskip=0pt,
3116 boxpos=c,
3117 showlines=false,
3118 extendedchars=true,
3119 upquote=true,
3120 tabsize=2,
3121 showtabs=false,
3122 showspaces=false,
3123 showstringspaces=false,
3124 numbers=none,
3125 linewidth=\linewidth,
3126 xleftmargin=4pt,
3127 xrightmargin=0pt,
3128 resetmargins=false,
3129 breaklines=true,
3130 breakatwhitespace=false,
3131 breakindent=0pt,
3132 breakautoindent=true,
3133 columns=flexible,
3134 keepspaces=true,
3135 gobble=4,
3136 framesep=3pt,
3137 rulesep=1pt,
3138 framerule=1pt,
3139 backgroundcolor=\color{gray!5},
3140 stringstyle=\color{green!40!black!100},
3141 keywordstyle=\bfseries\color{blue!50!black},
3142 commentstyle=\slshape\color{black!60}}
3143
3144 \lstdefinestyle{lstStyleShell}{%
3145 style=lstStyleBase,
3146 frame=l,
3147 rulecolor=\color{purple},
3148 language=bash}
3149
3150 \lstdefinestyle{lstStyleLaTeX}{%
3151 style=lstStyleBase,
3152 frame=l,
3153 rulecolor=\color{violet},
3154 language=[LaTeX]TeX}
3155
3156 \lstnewenvironment{latex}{\lstset{style=lstStyleLaTeX}}{}
3157 \lstnewenvironment{shell}{\lstset{style=lstStyleShell}}{}
3158
3159 \setlist{nosep}
3160
3161 \DeclareDocumentCommand{\option}{m}{\textsf{#1}}
3162 \DeclareDocumentCommand{\env}{m}{\texttt{#1}}
3163 \DeclareDocumentCommand{\pkg}{s m}{%
3164 \textsf{#2}\IfBooleanF#1{\hit@special@index{package}{#2}}}
3165 \DeclareDocumentCommand{\cls}{s m}{%
3166 \textsf{#2}\IfBooleanF#1{\hit@special@index{package}{#2}}}
3167 \DeclareDocumentCommand{\file}{s m}{%
3168 \nolinkurl{#2}\IfBooleanF#1{\hit@special@index{file}{#2}}}
3169 \newcommand{\myentry}[1]{%
3170 \marginpar{\raggedleft\color{purple}\bfseries\strut #1}}
3171 \newcommand{\note}[2][Note]{{%
3172 \color{magenta}{\bfseries #1}\emph{#2}}}
3173
3174 \DeclareDocumentCommand{\githubuser}{m}{\href{https://github.com/#1}{@#1}}
3175
3176 \def\thuthesis{\textsc{Thu}\-\textsc{Thesis}}
3177 \def\hitreport{\textsc{Hit}\-\textsc{Report}}
3178 \def\hithesis{\textsc{hi}\-\textsc{Thesis}}
3179 %</dtx-style>
3180 % \end{macrocode}
3181 % \fi
3182 %
3183 % \Finale
3184 %
3185 \endinput
3186 % \iffalse
3187 % Local Variables:
3188 % mode: doctex
3189 % TeX-master: t
3190 % End:
3191 % \fi