Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 % !TEX program = XeLaTeX
3 %
4 % DO NOT REMOVE THE MARK MANUALLY (used in l3build) -> %
5 %
6 %<*internal>
7 \iffalse
8 %</internal>
9 %<*internal>
10 \fi
11 \begingroup
12 \def\nameofLaTeXe{LaTeX2e}
13 \expandafter\endgroup\ifx\fmtname\nameofLaTeXe\else
14 \csname fi\endcsname
15 %</internal>
16 %<*install>
17 \input docstrip
18 \keepsilent
19 \askforoverwritefalse
20 \preamble
21
22 Copyright (C) 2013-2014 by Xu Cheng <[email protected]>
23 2014- by hust-latex <https://github.com/hust-latex>
24 2024- by HUANG Yuxi <[email protected]>
25
26 This work may be distributed and/or modified under the
27 conditions of the LaTeX Project Public License, either
28 version 1.3c of this license or (at your option) any later
29 version. This version of this license is in
30 https://www.latex-project.org/lppl/lppl-1-3c.txt
31 and the latest version of this license is in
32 https://www.latex-project.org/lppl.txt
33 and version 1.3c or later is part of all distributions of LaTeX
34 version 2008 or later.
35
36 This work has the LPPL maintenance status "maintained".
37
38 The Current Maintainer of this work is HUANG Yuxi <[email protected]>.
39
40 \endpreamble
41 \postamble
42
43 This work consists of the files \jobname.dtx
44 and the derived files \jobname.ins,
45 \jobname.cls,
46 \jobname-doc.sty,
47 \jobname-m.def,
48 \jobname-d.def,
49 \jobname.cbx,
50 \jobname.bbx.
51
52 \endpostamble
53
54 \generate
55 {
56 %</install>
57 %<*internal>
58 \usedir{source/latex/\jobname}
59 \file{\jobname.ins}{\from{\jobname.dtx}{install}}
60 %</internal>
61 %<*install>
62 \usedir{tex/latex/\jobname}
63 \file{\jobname.cls}{\from{\jobname.dtx}{class}}
64 \file{\jobname-doc.sty}{\from{\jobname.dtx}{doc-sty}}
65 \file{\jobname-m.def}{\from{\jobname.dtx}{def-m}}
66 \file{\jobname-d.def}{\from{\jobname.dtx}{def-d}}
67 \file{\jobname.cbx}{\from{\jobname.dtx}{cbx}}
68 \file{\jobname.bbx}{\from{\jobname.dtx}{bbx}}
69 }
70
71 \Msg{*********************************************************}
72 \Msg{*}
73 \Msg{* To finish the installation you have to move the}
74 \Msg{* following file into a directory searched by TeX:}
75 \Msg{*}
76 \Msg{* \space\space \jobname.cls}
77 \Msg{* \space\space \jobname.cbx}
78 \Msg{* \space\space \jobname.bbx}
79 \Msg{* \space\space \jobname-m.def}
80 \Msg{* \space\space \jobname-d.def}
81 \Msg{*}
82 \Msg{* To produce the documentation run the file \jobname.dtx}
83 \Msg{* through LuaLaTeX.}
84 \Msg{*}
85 \Msg{* Happy TeXing!}
86 \Msg{*}
87 \Msg{*********************************************************}
88
89 \endbatchfile
90 %</install>
91 %<*internal>
92 \fi
93 %</internal>
94
95 %<class>\NeedsTeXFormat{LaTeX2e}[2024-11-01]
96 %<class>\ProvidesExplClass{hustthesis}
97 %<doc-sty>\ProvidesExplClass{hustthesis-doc}
98 %<def-m>\ProvidesExplFile{hustthesis-m.def}
99 %<def-d>\ProvidesExplFile{hustthesis-d.def}
100 %<cbx>\ProvidesFile{hustthesis.cbx}[Citation style for the hustthesis class]
101 %<bbx>\ProvidesFile{hustthesis.bbx}[Bibliography style for the hustthesis class]
102 %<class|doc-sty|def-m|def-d> {2026-03-06}{2.1.0} %
103 %<class> {Thesis Template for Huazhong University of Science and Technology}
104 %<doc-sty> {Documentation for the hustthesis class}
105 %<def-m> {Definition file for the hustthesis class in master thesis}
106 %<def-d> {Definition file for the hustthesis class in doctoral thesis}
107 %<*driver>
108 \documentclass[]{\jobname}
109 \usepackage{useclass}
110 % Protect \maketitile from the redefinition in \cls{article} in \cls{l3doc}.
111 \let\maketitleold=\maketitle
112 \useclass*[full]{l3doc}
113 \let\maketitle=\maketitleold
114 \usepackage{\jobname-doc}
115 \usepackage{mdframed}
116 \begin{filecontents}[overwrite]{\jobname.bib}
117 @online{huang2024useclass,
118 title = {The useclass.sty Package: Load Classes as Packages},
119 author = {Huang, Yuxi},
120 year = {2024},
121 month = {mar},
122 day = {06},
123 url = {https://github.com/huangyxi/useclass},
124 }
125 @online{zeng2023fduthesis,
126 title = {\cls{fduthesis}: 复旦大学论文模板},
127 author = {曾, 祥东},
128 year = {2023},
129 month = {may},
130 day = {27},
131 url = {https://github.com/stone-zeng/fduthesis},
132 }
133 @online{sjtug2024SJTUTeX,
134 title = {\cls{SJTU\TeX}: 上海交通大学文档类集},
135 author = {SJTUG},
136 year = {2024},
137 month = {feb},
138 day = {18},
139 url = {https://github.com/sjtug/SJTUTeX},
140 }
141 @online{njulug2023njuthesis,
142 title = {南京大学学位论文模板},
143 author = {南京大学~Linux~用户组},
144 year = {2023},
145 month = {dec},
146 day = {05},
147 url = {https://github.com/nju-lug/NJUThesis},
148 }
149 @online{hu2024bib,
150 title = {符合 GB/T 7714-2015 标准的 biblatex 参考文献样式},
151 author = {胡振震},
152 year = {2024},
153 month = {nov},
154 day = {15},
155 url = {https://github.com/hushidong/biblatex-gb7714-2015},
156 }
157 \end{filecontents}
158 \begin{filecontents}[overwrite]{\jobname-fmt.bib}
159 @book{YanMingLi2006CFGZhuang,
160 title = {CFG桩复合地基技术及工程实践},
161 author = {{闫明礼} and {张东刚}},
162 date = {2006},
163 edition = {2},
164 publisher = {中国水利水电出版社},
165 location = {北京}
166 }
167 @book{chalfi1998GreenFluo,
168 title = {Green fluorescent protein: properties, applications, and protocols},
169 editor = {Chalfie, Martin and {Steven R. Kain}},
170 date = {1998},
171 publisher = {Wiley-interscience},
172 location = {Hoboken, New Jersey},
173 pagetotal = {385}
174 }
175 @article{ZhanXiangHong2004ZhongYiY,
176 title = {中医药防治阿尔茨海默病实验研究述要},
177 author = {{詹向红} and {李德新}},
178 date = {2004},
179 journaltitle = {中医药学刊},
180 volume = {22},
181 number = {11},
182 pages = {2094--2096}
183 }
184 @article{lein2007Genomewide,
185 title = {Genome-wide atlas of gene expression in the adult mouse brain},
186 author = {Lein, Ed S. and Hawrylycz, Michael J. and Ao, Nancy and Ayres, Mikael and Bensinger, Amy and Bernard, Amy and Boe, Andrew F., et al.},
187 date = {2007-01},
188 journaltitle = {Nature},
189 volume = {445},
190 number = {7124},
191 pages = {168--176},
192 publisher = {Nature Publishing Group}
193 }
194 @article{bouxse2010Guidelines,
195 title = {Guidelines for Assessment of bone microstructure in rodents using micro--computed tomography},
196 author = {Bouxsein, Mary L and Boyd, Stephen K and Christiansen, Blaine A and Guldberg, Robert E and Jepsen, Karl J and M\"uller, Ralph},
197 date = {2010},
198 journaltitle = {Journal of Bone and Mineral Research},
199 volume = {25},
200 number = {7},
201 pages = {1468--1486}
202 }
203 @inproceedings{yamaki2018Performanc,
204 title = {Performance evaluation of phase-only correlation functions from the viewpoint of correlation {{Filters}}},
205 booktitle = {2018 {{Asia-Pacific Signal}} and {{Information Processing Association Annual Summit}} and {{Conference}} ({{APSIPA ASC}})},
206 author = {Yamaki, Shunsuke and Abet, Masahide and Kawamata, Masayuki and Yoshizawa, Makoto},
207 date = {2019},
208 pages = {1361--1364},
209 publisher = {Proceedings of the IEEE},
210 location = {Honolulu, HI, USA, 12-15 Nov. 2018}
211 }
212 @article{yao2017BuildingE,
213 title = {Building efficient key-value stores via a lightweight compaction tree},
214 author = {Yao, Ting and Wan, Jiguang and Huang, Ping and He, Xubin and Wu, Fei and Xie, Changsheng},
215 date = {2017-11-24},
216 journaltitle = {ACM Trans. Storage},
217 volume = {13},
218 number = {4},
219 pages = {1--28}
220 }
221 @patent{LiuJiaLin1993DuoGongN,
222 type = {patent},
223 title = {多功能一次性压舌板},
224 author = {刘加林},
225 holder = {{Individual}},
226 date = {1993-04-14},
227 number = {ZL92214985. 2},
228 location = {中国}
229 }
230 @thesis{LiQingQuan1998JiYuHun,
231 type = {博士学位论文},
232 title = {基于混合结构的三维GIS数据模型与空间分析研究},
233 author = {{李清泉}},
234 namea = {{李德仁}},
235 nameatype = {collaborator},
236 date = {1998},
237 location = {武汉},
238 institution = {武汉大学武汉测绘科技大学}
239 }
240 \end{filecontents}
241 \addbibresource{\jobname-fmt.bib}
242 \addbibresource{\jobname.bib}
243
244 \providecommand{\name}{\jobname}
245 \providecommand{\clsname}{\cls{\name}}
246
247 \begin{document}
248 \DocInput{\jobname.dtx}
249 \PrintChanges
250 \PrintIndex
251 \end{document}
252 %</driver>
253 % \fi
254 %
255 % \changes{v2.0.0}{2024-10-01}{使用 \LaTeX3 语法重构}
256 % \changes{v2.0.0}{2024-10-01}{使用 \cls{useclass} 实现文档类“自举”}
257 % \changes{v2.1.0}{2026-03-06}{使用 \pkg{hustvisual}生成校名,不再依赖PDF文件}
258 %
259 % \hustsetup {
260 % info =
261 % {
262 % title = { \clsname{} v2.1.0:华中科技大学研究生学位论文\LaTeX{}文档类使用说明 }, %
263 % title* = { \clsname{} v2.1.0: \LaTeX{} Thesis Template for Huazhong University of Science and Technology }, %
264 % degree = { academic },
265 % degree* = { Engineering },
266 % author = { 黄宇希 },
267 % author* = { HUANG Yuxi },
268 % major = { \LaTeX{} 文档类设计 },
269 % major* = { \LaTeX{} Template Design },
270 % supervisor = { \TeX{}Book\quad{} 教授 },
271 % supervisor* = { Prof.~ \TeX{}Book },
272 % },
273 % }
274 %
275 % \maketitle
276 % \frontmatter
277 % \begin{abstract}
278 % \clsname{} 是华中科技大学研究生学位论文\LaTeX{}\emph{非官方}文档类。
279 % 2.0.0 起版使用 \LaTeX3 语法重构,并且不再兼容之前的版本。
280 % 目前仅支持\emph{中文硕士和博士}学位论文。
281 %
282 % 本文档类遵循 \LaTeX{} 项目公共许可证 1.3c(\LaTeX Project Public License 1.3c 版)的相关规定进行分发和修改。
283 % 使用本文档类即表示您已知悉并同意该许可证的条款。
284 % 本文档类按“原样”提供,不附带任何明示或暗示的保证,包括但不限于适销性或特定用途的适用性。
285 % 作者不对因使用本文档类导致的任何直接或间接损失承担责任。
286 % 请在修改和分发本文档类时遵循许可证的相关要求,以确保其完整性和可维护性。
287 %
288 % 本项目代码托管在 GitHub \url{https://github.com/hust-latex/hustthesis},
289 % 最新版的 \clsname{} 文档类手册请访问
290 % \url{https://github.com/hust-latex/hustthesis/releases/latest/download/hustthesis.pdf}。
291 %
292 % \keywords 华中科技大学;学位论文文档类;\LaTeX;\LaTeX3
293 % \end{abstract}
294 %
295 % \begin{abstract*}
296 % \clsname{} is an Unofficial \LaTeX{} thesis template for Huazhong University of Science and Technology.
297 % Version 2.0.0 and later are written in \LaTeX3 and are not compatible with previous versions.
298 % Currently, it only supports Science and Engineering master's and doctoral theses in Chinese.
299 %
300 % This template is distributed and modified under the terms of the \LaTeX Project Public License 1.3c.
301 % By using this template, you acknowledge and agree to the terms of this license.
302 % This template is provided ``as is'' without any express or implied warranty, including but not limited to
303 % merchantability or fitness for a particular purpose.
304 % The author is not responsible for any direct or indirect losses arising from the use of this template.
305 % Please follow the relevant requirements of the license when modifying and distributing this template
306 % to ensure its integrity and maintainability.
307 %
308 % This project is hosted on GitHub
309 % \url{github.com/hust-latex/hustthesis},
310 % and the latest version of the \clsname{} documentation can be found at
311 % \url{github.com/hust-latex/hustthesis/releases/latest/download/hustthesis.pdf}.
312 %
313 % \keywords* Huazhong University of Science and Technology, Dissertation Template, \LaTeX, \LaTeX3
314 % \end{abstract*}
315 %
316 % \tableofcontents
317 % \mainmatter
318 %
319 % \begin{documentation}
320 %
321 % \chapter{\clsname{} 介绍}
322 %
323 % \clsname{} 是华中科技大学研究生学位论文\LaTeX{}文档类,
324 % 旨在为华科学生提供一个简单上手,易于使用的学位论文文档类。
325 %
326 % \section{\clsname{} 历史}
327 %
328 % 本文档类 |v1.x| 版本由华中科技大学电子信息学院2014届本科生许铖博士
329 % \footnote{\url{https://github.com/xu-cheng}}开发并维护,
330 % 支持中英文的本科、硕士和博士学位论文撰写。
331 % 作为一个设计精良的 \LaTeXe{} 文档类,自2013年6月1日 |v1.0| 初版
332 % 以 \LaTeX 项目公共许可证 1.3c(\LaTeX{} Project Public License 1.3c 版)发布以来,
333 % 该文档类已为无数华科学子提供了优质的服务。
334 %
335 % 然而,随着学校学位论文格式要求的不断更新,
336 % 原有的文档类逐渐难以满足新的格式要求。
337 % 加之原作者移居海外,难以及时响应日益增多的用户需求。
338 % 同时,随着 \LaTeX3 技术和 C\TeX{} 宏集的逐渐成熟与普及,
339 % 与之相比的 \LaTeXe{} 语法显得难以维护。
340 % 因此,自2024年文档类 |v2.x.x| 版本开始交由华中科技大学博士生黄宇希
341 % \footnote{\url{https://github.com/huangyxi}}接手维护,
342 % 并基于 \LaTeX3 技术和 C\TeX{} 宏集进行了全面重构。
343 %
344 % 此外,|v2.0.0|起,文档类说明手册使用 \pkg{useclass}\cite{huang2024useclass}
345 % 以宏包的方式载入 \pkg{l3doc} 文档类中的众多命令和环境,
346 % 使得 \pkg{l3doc} 文档类能够与 \clsname{} 文档类共存,
347 % 实现 \clsname{} 文档类的“自举”。
348 %
349 % 当前\clsname{} 代码在 GitHub
350 % \url{https://github.com/hust-latex/hustthesis} 上托管,
351 % 欢迎各位同学提出意见和建议。
352 %
353 % \section{学位论文格式规范}
354 %
355 % 目前华中科技大学对于硕士和博士的学位论文格式主要由以下文件规范:
356 % \begin{itemize}
357 % \item \href{http://gs.hust.edu.cn/content.jsp?urltype=news.NewsContentUrl&wbtreeid=1022&wbnewsid=1027}{华中科技大学博士、硕士学位论文撰写规定, 校研〔2009〕39号}
358 % \item \href{http://gs.hust.edu.cn/info/1041/5462.htm}{学位申请相关文档下载},
359 % 发布时间2023-02-10
360 % \end{itemize}
361 %
362 % 由于其中如“参考文献著录作者最多数量”等部分规范尚未统一,
363 % 文档类作者在此仅根据过往已通过的学位论文的格式择取其一实现,
364 % 供同学们参考。
365 % 具体的格式要求请以学校最新的通知为准。
366 %
367 % \section{\clsname{} 发行版本号\label{sec:version}}
368 %
369 % 更新版本往往会带来新功能和修复问题,
370 % 但有时也会不可避免地带来不向后兼容的修改。
371 % 为了清晰地传达版本之间的变化,
372 % 本文档类发行的版本号使用类似但不完全同于语义化版本控制(Semantic Versioning)规范
373 % \footnote{\url{https://semver.org/}}用以标识。
374 % 在本文档类中,对于版本号 |MAJOR.MINOR.PATCH|,递增相应的部分所表示的含义如下:
375 % \begin{itemize}
376 % \item |MAJOR|:递增大版本号,
377 % 表示已在正文文档化的公开接口上存在不向后兼容(backward compatibility)的修改,
378 % 一般对文档代码不经修改无法正常编译;
379 % \item |MINOR|:递增小版本号,
380 % 表示已在正文文档化的非实验性公开接口上\emph{不}存在不向后兼容编译的修改,
381 % 但在实验性公开接口上存在不向后兼容的修改;
382 % 或者文档样式发生比较明显的变化。
383 % 一般对文档代码不作修改或者只需小幅修改就可以正常编译;
384 % \item |PATCH|:递增补丁版本号,
385 % 表示新版本含有向后兼容的 bug 修复,新功能,或者文档样式的细微变化,
386 % 其中未文档化的私有接口可能会发生变化。
387 % \end{itemize}
388 % 用户在更新文档类时,可以根据版本号的变化以及更新日志来判断是否需要修改自己的文档。
389 %
390 %
391 % \chapter{获取途径}
392 %
393 % 获取最新版本的 \clsname{} 文档类主要有两种途径:
394 % 从 CTAN 上下载,或者从 GitHub Releases 页面下载。
395 %
396 % \section{CTAN}
397 %
398 % CTAN \url{https://ctan.org/pkg/hustthesis}
399 % 上的 \clsname{} 文档类是经过打包的版本,
400 % 其中包含了文档类、和文档类手册。
401 %
402 % \section{GitHub Release}
403 %
404 % \cls{hustthesis} 的源码托管在 GitHub
405 % \url{https://github.com/hust-latex/hustthesis} 上,
406 % 其中包含了最新的开发版本。
407 % 由于源码是以 Doc\TeX{} 格式编写,
408 % 对于初学者来说,安装和使用都比较麻烦。
409 % 因此,建议初学者可以直接从 Releases 页面下载打包好的版本,解压后直接使用。
410 % \url{https://github.com/hust-latex/hustthesis/releases/latest/download/hustthesis-user.zip}
411 %
412 % \chapter{使用说明}
413 %
414 % \section{太长不读(TL;DR)}
415 %
416 % 本节将展示两段简化程度不一的代码示例,
417 % 可用于快速了解本文档类的使用方法,
418 % 或者在编译失败的调试阶段作为参考。
419 %
420 % \subsection{最小可用示例}
421 %
422 % 以下代码包含了本文档类的最小可用示例(Minimal Working Example),
423 % 用于展现文档类使用的主体结构。
424 % \begin{latexcode}
425 % \documentclass{hustthesis}
426 % % \hustsetup{} % 设置
427 % \begin{document}
428 % \maketitle
429 % \frontmatter
430 % 摘要部分
431 % \tableofcontents
432 % \mainmatter
433 % 正文部分
434 % \backmatter
435 % 致谢以及参考文献
436 % \appendix
437 % 附录部分
438 % \end{document}
439 % \end{latexcode}
440 %
441 % \subsection{核心示例}
442 %
443 % 本示例包含了较长的一段文档类核心命令和环境,
444 % 更多进阶用法请参考后续小节。
445 % \begin{latexcode}[emph={[1]hustsetup}]
446 % \documentclass[type=doctor]{hustthesis} % 博士学位论文: doctor, 硕士学位论文: master
447 % \hustsetup { % 设置之间一定不能有空行
448 % info =
449 % {
450 % title = { 中文标题 },
451 % title* = { English Title },
452 % degree = { academic }, % 学术型: academic, 专业型: professional
453 % degree* = { Engineering }, % 英文学科
454 % author = { 姓名 },
455 % author* = { Author },
456 % student-id = { D201234567 },
457 % major = { 专业 },
458 % major* = { Major },
459 % supervisor = { 指导老师\quad{} 教授 },
460 % supervisor* = { Prof.~ Supervisor },
461 % date = { 2025-02-26 }, % 不写这行的话会自动生成,写的话一定要按照这个格式
462 % },
463 % }
464 % \addbibresource{references.bib} % % biblatex 参考文献文件名
465 % \begin{document}
466 % \maketitle
467 % \frontmatter
468 % \begin{abstract}
469 % 中文摘要
470 % \keywords 关键词1;关键词2;关键词3
471 % \end{abstract}
472 % \begin{abstract*}
473 % English Abstract
474 % \keywords* keyword1, keyword2, keyword3
475 % \end{abstract*}
476 % \tableofcontents
477 % \mainmatter
478 % \chapter{第一章}
479 % \section{第一节}
480 % ...
481 % \backmatter
482 % \begin{acknowledgements} % 致谢
483 % 感谢 hustthesis 文档类。
484 % \end{acknowledgements}
485 % \printbibliography
486 % \appendix
487 % \chapter{附录}
488 % \end{document}
489 % \end{latexcode}
490 %
491 % \section{编译说明}
492 %
493 % 本文档类仅可使用 \XeLaTeX{} 或者 \LuaLaTeX{} 编译。
494 %
495 % \section{如何阅读本章使用说明}
496 %
497 % 是的,说明文档本身也需要说明文档来说明如何阅读说明文档。
498 %
499 % \subsection{实验性内容\label{sec:exp}}
500 %
501 % 本文档类说明部分的名字含有 “\rexpstar{}” 的键值对选项,设置,命令或环境,
502 % 表示该内容为实验性内容。
503 % 关于实验性内容的更新带来潜在不向后兼容修改的说明,
504 % 请参考 \ref{sec:version} 节。
505 %
506 % \subsection{单选键值对设置}
507 %
508 % \key{key} = <\opt{option},\opt*{default}>,
509 %
510 % 其等号右边的选项 \opt{option},和 \opt*{default} 均表示可选的单选项,
511 % 其中加粗选项 \opt*{default} 表示默认选项。
512 %
513 % 最后的逗号是为了提醒读者,
514 % 如果存在多个键值对,其之间需由半角(英文)逗号分隔。(以下如未特殊说明,逗号均指半角逗号)
515 %
516 % \subsection{自定义键值对设置}
517 %
518 % \key{key} = \marg{value},
519 %
520 % 其等号右边的值 \marg{value} 表示可以自定义的值。
521 %
522 % \section{文档类选项\label{sec:option}}
523 %
524 % 本节介绍的选项仅可在如下文档类选项(中括号中|type=doctor|)中使用。
525 % 多个选项之间也是由逗号分隔。
526 % \begin{latexcode}
527 % \documentclass[type=doctor]{hustthesis}
528 % \end{latexcode}
529 %
530 % \begin{function}[module=option/]{type}
531 % \begin{syntax}
532 % \key{type} = <\opt*{doctor},\opt{master}>,
533 % \end{syntax}
534 % \begin{arguments}
535 % \item[\opt*{doctor}] 博士学位论文
536 % \item[\opt{master}] 硕士学位论文
537 % \end{arguments}
538 % \key{type} 选项用于设置学位论文类型。
539 % \end{function}
540 %
541 % \begin{function}[rEXP, module=option/]{anonymous}
542 % \begin{syntax}
543 % \key{anonymous} = <\opt*{false},\opt{true}>,
544 % \end{syntax}
545 % \begin{arguments}
546 % \item[\opt*{false}] 关闭盲审模式
547 % \item[\opt{true}] 开启盲审模式
548 % \end{arguments}
549 % \key{anonymous} 选项用于设置是否开启盲审模式。
550 % 盲审模式下,\key{anonymous-list} 中的所有信息均会被隐藏。
551 % \end{function}
552 %
553 % \begin{function}[rEXP, module=option/]{anonymous-list}
554 % \begin{syntax}
555 % \key{anonymous-list} = \marg{盲审模式隐藏条目列表},
556 % \end{syntax}
557 % \key{anonymous-list} 选项用于设置在开启盲审模式下需要隐藏的条目。
558 % \marg{匿名条目列表} 是一组由半角(英文)逗号隔开的选项列表。
559 % |info/| 下键值对键名的连接符(|-|)需手动替换为下划线(|_|),
560 % 星号(|*|)需手动替换为|_en|。
561 % 默认值为 \texttt{\{author, student_id, supervisor, author_en, supervisor_en\}}。
562 % \end{function}
563 %
564 % \section{文档信息设置}
565 %
566 % 本节介绍的文档信息设置选项只可在 \tn{hustsetup} 命令的\marg{键值列表}中使用,
567 % 主要用于封面和扉页的标题、作者等信息的输出。
568 %
569 % \begin{function}{\hustsetup}
570 % \begin{syntax}
571 % \tn{hustsetup}\marg{键值列表}
572 % \end{syntax}
573 % \tn{hustsetup} 的参数是一组由半角(英文)逗号隔开的选项列表,
574 % 列表中的选项通常是
575 % \meta{key}|=|\meta{value}的形式。
576 % 对于相同键,后面的值会覆盖前面的值。
577 % “|=|”左右的空格不影响实际设置,
578 % 但需注意,参数列表中不能有空行。
579 % \end{function}
580 %
581 % \begin{function}[module=info/]{info/degree}
582 % \begin{syntax}
583 % \key[info]{degree} = <\opt*{academic},\opt{professional}>,
584 % \end{syntax}
585 % 设置中文学位类型,仅可选学术型或专业型。
586 % \begin{arguments}
587 % \item[\opt*{academic}] 学术型
588 % \item[\opt{professional}] 专业型
589 % \end{arguments}
590 % \end{function}
591 %
592 % \begin{function}[module=info/]{info/degree*}
593 % \begin{syntax}
594 % \key[info]{degree*} = <\opt{Arts},\opt{Science},\opt{Education},\opt*{Engineering},\opt{Law},\opt{Medicine},...>,
595 % \end{syntax}
596 % 设置英文学科门类,
597 % 可选项有:
598 % \begin{arguments}
599 % \item[\opt{Arts}] 文学学位
600 % \item[\opt{Science}] 理学学位
601 % \item[\opt{Education}] 教育学学位
602 % \item[\opt*{Engineering}] 工学学位
603 % \item[\opt{Law}] 法学学位
604 % \item[\opt{Medicine}] 医学学位
605 % \item[...] 其他学科可自行设置
606 % \end{arguments}
607 % \end{function}
608 %
609 % \begin{function}[module=info/]{info/title, info/title*}
610 % \begin{syntax}
611 % \key[info]{title} = \marg{中文标题},
612 % \key[info]{title*} = \marg{英文标题},
613 % \end{syntax}
614 % 设置论文标题。
615 % \end{function}
616 %
617 % \begin{function}[module=info/]{info/author, info/author*}
618 % \begin{syntax}
619 % \key[info]{author} = \marg{姓名中文},
620 % \key[info]{author*} = \marg{姓名英文},
621 % \end{syntax}
622 % 设置学位申请人姓名。
623 % 根据学校要求,英文姓名应该按照中文习惯,
624 % 为姓在前名在后,且姓全部大写。
625 % \end{function}
626 %
627 % \begin{function}[module=info/]{info/major, info/major*}
628 % \begin{syntax}
629 % \key[info]{major} = \marg{专业名称中文},
630 % \key[info]{major*} = \marg{专业名称英文},
631 % \end{syntax}
632 % 设置专业名称。
633 % \end{function}
634 %
635 % \begin{function}[module=info/]{info/supervisor, info/supervisor*}
636 % \begin{syntax}
637 % \key[info]{supervisor} = \marg{指导老师中文姓名},
638 % \key[info]{supervisor*} = \marg{指导老师英文姓名},
639 % \end{syntax}
640 % 设置指导老师姓名。
641 % \end{function}
642 %
643 % \begin{function}[module=info/]{info/date}
644 % \begin{syntax}
645 % \key[info]{date} = \marg{日期},
646 % \end{syntax}
647 % 设置论文提交日期。
648 % 日期格式为 |YYYY-MM-DD|。
649 % 如果不设置该选项,文档类会自动生成日期。
650 % \end{function}
651 %
652 % \begin{function}[module=info/]{info/clc}
653 % \begin{syntax}
654 % \key[info]{clc} = \marg{中图分类号},
655 % \end{syntax}
656 % 设置中图分类号。
657 % \end{function}
658
659 % \begin{function}[module=info/]{info/student-id}
660 % \begin{syntax}
661 % \key[info]{student-id} = \marg{学号},
662 % \end{syntax}
663 % 设置学号。
664 % \end{function}
665 %
666 % \begin{function}[rEXP, module=info/]{info/secret}
667 % \begin{syntax}
668 % \key[info]{secret} = \marg{密级},
669 % \end{syntax}
670 % 实验性内容,设置密级。当前仅影响中文封面的显示,默认为空。
671 % \end{function}
672 %
673 % \begin{function}[module=info/]{info/committee}
674 % \begin{syntax}
675 % \key[info]{committee} = \marg{答辩委员会成员},
676 % \end{syntax}
677 % 设置答辩委员会成员。
678 % 该选项的值是一个逗号分隔委员会成员的列表,
679 % 其中每个成员的姓名,职称和单位之间用 |&| 分割。
680 % 第一个成员为主席,其余成员为委员。
681 % 由于文档类内部实现原因,如果设置该选项,请至少设置3名成员。
682 % 例如:
683 % \begin{latexcode}
684 % \hustsetup {
685 % info/committee =
686 % { 张三 & 教授 & 华中科技大学 , 李四 & 教授 & 武汉大学 , 王五 & 教授 & 武汉理工大学 },
687 % }
688 % \end{latexcode}
689 % 如果不设置该选项,文档类会自动生成7行空白的答辩委员会成员。
690 %
691 % 另外,该选项所对应的页面仅在博士学位论文中会自动生成。
692 % 如果需要手动生成页面,可以使用命令 \tn{makecommittee}。
693 % \end{function}
694 %
695 % \section{文档样式\rexpstar{}}
696 %
697 % \begin{function}[added=2025-10-31, module=style/]{style/toc-depth}
698 % \begin{syntax}
699 % \key[style]{toc-depth} = <\opt*{section},\opt{subsection}>,
700 % \end{syntax}
701 % 设置目录深度。
702 % \end{function}
703 %
704 % \section{内容编写}
705 %
706 % 以下内容须在 |\begin{document}| 和 |\end{document}| 之间编写。
707 %
708 % \subsection{封面扉页}
709 %
710 % \begin{function}{\maketitle}
711 % \begin{syntax}
712 % \tn{maketitle}
713 % \end{syntax}
714 % \tn{maketitle} 命令用于生成中英文封面。
715 % 仅当文档类类型为博士学位论文时,
716 % 在中文和英文封面之间会自动插入答辩relrel委员会成员。
717 % \end{function}
718 %
719 % \begin{function}[rEXP]{\makezhtitle, \makeentitle}
720 % \begin{syntax}
721 % \tn{makezhtitle}
722 % \tn{makeentitle}
723 % \end{syntax}
724 % \tn{makezhtitle} 和 \tn{makeentitle} 命令分别用于生成中文和英文封面。
725 % 一般不需要手动调用这两个命令。
726 % \end{function}
727 %
728 % \begin{function}[rEXP]{\makecommittee}
729 % \begin{syntax}
730 % \tn{makecommittee}
731 % \end{syntax}
732 % \tn{makecommittee} 命令用于生成答辩委员会成员。
733 % 一般也不需要手动调用该命令。
734 % \end{function}
735 %
736 % \subsection{前文}
737 %
738 % \begin{function}{\frontmatter}
739 % \begin{syntax}
740 % \tn{frontmatter}
741 % \end{syntax}
742 % \tn{frontmatter} 命令用于修改页码格式为罗马数字,
743 % 增加页眉和页脚,
744 % 以及设置目录中虚线样式。
745 % 该命令一般需要在 \tn{maketitle} 命令之后,摘要之前调用。
746 % \end{function}
747 %
748 % \begin{environment}{abstract, abstract*}
749 % \begin{latexcode}
750 % \begin{abstract}
751 % 中文摘要
752 % \keywords 关键词1;关键词2;关键词3
753 % \end{abstract}
754 %
755 % \begin{abstract*}
756 % English abstract
757 % \keywords* keyword1, keyword2, keyword3
758 % \end{abstract*}
759 % \end{latexcode}
760 % |abstract| 和 |abstract*| 环境分别用于生成中文和英文摘要。
761 % \end{environment}
762 %
763 % \begin{function}{keywords, keywords*}
764 % \begin{syntax}
765 % \tn{keywords} 关键词1;关键词2;关键词3
766 % \tn{keywords*} Keyword1, Keyword2, Keyword3
767 % \end{syntax}
768 % \tn{keywords} 和 \tn{keywords*} 命令分别用于生成中文和英文关键词。
769 % 一般需要在相应的 |abstract| 和 |abstract*| 环境中的最后一行调用。
770 % \end{function}
771 %
772 % \begin{function}{\tableofcontents}
773 % \begin{syntax}
774 % \tn{tableofcontents}
775 % \end{syntax}
776 % \tn{tableofcontents} 命令用于生成目录。
777 % \end{function}
778 %
779 % \subsection{正文}
780 %
781 % \begin{function}{\mainmatter}
782 % \begin{syntax}
783 % \tn{mainmatter}
784 % \end{syntax}
785 % \tn{mainmatter} 命令用于修改页码格式为阿拉伯数字,
786 % 以及设置目录中虚线样式。
787 % 该命令一般需要在目录之后,正文之前调用。
788 % \end{function}
789 %
790 % \begin{function}{\chapter, \chapter*, \chapter**}
791 % \begin{syntax}
792 % \tn{chapter}\marg{标题名}
793 % \tn{chapter*}\marg{标题名}
794 % \tn{chapter**}\marg{标题名}
795 % \end{syntax}
796 % \tn{chapter} 和 \tn{chapter*} 命令与标准 \LaTeXe-\pkg{book} 文档类中的命令功能相同,
797 % 用于生成章标题。
798 % 前者为有编号的章标题,会在目录中生成对应的条目;
799 % 后者为无编号的章标题,不会在目录中生成对应的条目。
800 %
801 % \tn{chapter**} 命令是本文档类新增的章节标题生成的命令,
802 % 用于生成无编号章节标题,但会在目录中生成对应的条目。
803 % 一般可用于在附录中生成无编号的章节标题。
804 % \end{function}
805 %
806 % \subsection{后文}
807 %
808 % \begin{function}{\backmatter}
809 % \begin{syntax}
810 % \tn{backmatter}
811 % \end{syntax}
812 % \tn{backmatter} 命令用于修改目录中虚线样式。
813 % 该命令一般需要在正文之后,致谢之前调用。
814 % \end{function}
815 %
816 % \begin{environment}{acknowledgements}
817 % \begin{syntax}
818 % |\begin{acknowledgements}|
819 % 致谢
820 % |\end{acknowledgements}|
821 % \end{syntax}
822 % |acknowledgements| 环境用于生成致谢。
823 % \end{environment}
824 %
825 % \begin{function}{\printbibliography}
826 % \begin{syntax}
827 % \tn{printbibliography}
828 % \end{syntax}
829 % \tn{printbibliography} 命令用于生成 \pkg{biblatex} 宏包的参考文献。
830 % \end{function}
831 %
832 % \subsection{附录}
833 %
834 % \begin{function}{\appendix}
835 % \begin{syntax}
836 % \tn{appendix}
837 % \end{syntax}
838 % \tn{appendix} 命令用于修改章节标题格式,
839 % 该命令一般需要在参考文献之后调用。
840 % \end{function}
841 %
842 % 附录的章节如答辩委员会决议等,可以根据需要使用 \tn{chapter} 命令生成有编号的标题,
843 % 也可以使用 \tn{chapter**} 命令生成无编号的标题。
844 %
845 % \section{参考文献说明}
846 %
847 % 这里列举了在学位论文规范文档中的参考文献。
848 % 可以在正文后参考文献列表中查看生成的样式。
849 % \citeauthor{YanMingLi2006CFGZhuang}
850 % \cite{chalfi1998GreenFluo, ZhanXiangHong2004ZhongYiY}
851 % \parencite{lein2007Genomewide,bouxse2010Guidelines,yamaki2018Performanc,yao2017BuildingE,LiuJiaLin1993DuoGongN,LiQingQuan1998JiYuHun}
852 %
853 % \backmatter
854 % \begin{acknowledgements}
855 % 感谢 \cls{fduthesis} 文档类\cite{zeng2023fduthesis},
856 % \cls{SJTU\TeX} 文档类集\cite{sjtug2024SJTUTeX},
857 % 和 \cls{njuthesis} 文档类\cite{njulug2023njuthesis},
858 % 本文档类的许多设计和实现都是参考了上述代码。
859 % 并且特别感谢 \pkg{biblatex-gb7714-2015} 宏包\cite{hu2024bib}及其作者胡振震,
860 % 本人在之前的文档类设计中得到了其很多热情的帮助,
861 % 收获的经验也为本文档类的设计奠定了基础。
862 %
863 % 此外本人开发的宏包 \pkg{useclass}\cite{huang2024useclass}
864 % 也让本文档类手册的文档类“自举”实现可能。
865 % \end{acknowledgements}
866 %
867 % \printbibliography
868 %
869 % \end{documentation}
870 %
871 % \begin{implementation}
872 %
873 % \appendix
874 % \newgeometry{
875 % marginpar = 2.8 cm,
876 % }
877 %
878 % \chapter{\clsname{} 代码实现}
879 % 本文档类使用 \LaTeX3 语法编写,依赖 \pkg{expl3} 环境。
880 %
881 % \begin{macrocode}
882 %<@@=hust>
883 %<*class>
884 % \end{macrocode}
885 %
886 % \section{文档类预处理}
887 %
888 % 本文档类隐式依赖已整合进 \LaTeX--\pkg{base} 的 \pkg{ltkeys} (原 \pkg{l3keys2e}) 和 \pkg{lttemplates}(原 \pkg{xtemplate})。
889 %
890 % \begin{macrocode}
891 \RequirePackage { }
892 % \end{macrocode}
893 %
894 % \subsection{变量声明}
895 %
896 % \begin{variable}{
897 % \l_@@_tmpa_box,
898 % \l_@@_tmpa_clist,
899 % \l_@@_tmpa_dim,
900 % \l_@@_tmpa_skip,
901 % \l_@@_tmpa_tl, \l_@@_tmpb_tl,
902 % }
903 % 临时变量。
904 % \begin{macrocode}
905 \box_new:N \l_@@_tmpa_box
906 \clist_new:N \l_@@_tmpa_clist
907 \dim_new:N \l_@@_tmpa_dim
908 \skip_new:N \l_@@_tmpa_skip
909 \tl_new:N \l_@@_tmpa_tl
910 \tl_new:N \l_@@_tmpb_tl
911 % \end{macrocode}
912 % \end{variable}
913 %
914 % \begin{variable}{\g_@@_degree_type_tl}
915 % 论文类型。
916 % \begin{macrocode}
917 \tl_new:N \g_@@_degree_type_tl
918 % \end{macrocode}
919 % \end{variable}
920 %
921 % \begin{variable}{\g_@@_to_ctex_class_clist, \g_@@_to_hyperref_clist}
922 % 分别保存由 \clsname{} 传入 \cls{ctexbook} 文档类和 \pkg{hyperref} 宏包的选项列表。
923 % \begin{macrocode}
924 \clist_new:N \g_@@_to_ctex_class_clist
925 \clist_new:N \g_@@_to_hyperref_clist
926 % \end{macrocode}
927 % \end{variable}
928 %
929 % \begin{variable}{\g_@@_draft_bool}
930 % 草稿模式。
931 % \begin{macrocode}
932 \bool_new:N \g_@@_draft_bool
933 % \end{macrocode}
934 % \end{variable}
935 %
936 % \begin{variable}{\g_@@_anonymous_bool}
937 % 盲审模式。
938 % \begin{macrocode}
939 \bool_new:N \g_@@_anonymous_bool
940 % \end{macrocode}
941 % \end{variable}
942 %
943 % \begin{variable}{\g_@@_anonymous_clist}
944 % 盲审模式需要隐藏的内容。
945 % \begin{macrocode}
946 \clist_new:N \g_@@_anonymous_clist
947 % \end{macrocode}
948 % \end{variable}
949 %
950 % \begin{variable}{
951 % \g_@@_font_set_tl,
952 % \g_@@_font_latin_tl,
953 % \g_@@_font_cjk_tl,
954 % \g_@@_font_math_tl}
955 % 存储所使用字体名称的全局变量。
956 % \begin{macrocode}
957 \tl_new:N \g_@@_font_set_tl
958 \tl_new:N \g_@@_font_latin_tl
959 \tl_new:N \g_@@_font_cjk_tl
960 \tl_new:N \g_@@_font_math_tl
961 % \end{macrocode}
962 % \end{variable}
963 %
964 % \begin{variable}{\g_@@_font_dir_tl}
965 % 存储字体路径的全局变量。
966 % \begin{macrocode}
967 \tl_new:N \g_@@_font_dir_tl
968 % \end{macrocode}
969 % \end{variable}
970 %
971 % \begin{variable}{\g_@@_font_dir_bool}
972 % 是否使用独立的字体文件。
973 % \begin{macrocode}
974 \bool_new:N \g_@@_font_dir_bool
975 % \end{macrocode}
976 % \end{variable}
977 %
978 % \begin{variable}{\g_@@_config_tl}
979 % 保存配置文件名称。默认为空。
980 % \begin{macrocode}
981 \tl_new:N \g_@@_config_tl
982 % \end{macrocode}
983 % \end{variable}
984 %
985 % \subsection{内部函数}
986 %
987 %
988 % \subsubsection{辅助函数}
989 % \begin{macro}{\@@_patch_cmd:Nnn, \@@_appto_cmd:Nn}
990 % 补丁工具,来自 \pkg{ctexpatch} 宏包。
991 % \begin{macrocode}
992 \cs_new_protected:Npn \@@_patch_cmd:Nnn #1#2#3
993 {
994 \ctex_patch_cmd_once:NnnnTF #1 { } {#2} {#3}
995 { } { \ctex_patch_failure:N #1 }
996 }
997 \cs_new_protected:Npn \@@_appto_cmd:Nn #1#2
998 {
999 \ctex_appto_cmd:NnnTF #1 { } {#2}
1000 { } { \ctex_patch_failure:N #1 }
1001 }
1002 % \end{macrocode}
1003 % \end{macro}
1004 %
1005 % \begin{macro}{\@@_define_fn_style:nn,
1006 % \@@_define_punct:nn,
1007 % \@@_define_name:nn,
1008 % \@@_define_name:nnn}
1009 % 用来定义脚注样式、标点、默认名称的辅助函数。
1010 % \begin{macrocode}
1011 \cs_new_protected:Npn \@@_define_fn_style:nn #1#2
1012 { \tl_const:cn { c_@@_fn_style_ #1 _tl } {#2} }
1013 \cs_new_protected:Npn \@@_define_punct:nn #1#2
1014 { \tl_const:cn { c_@@_ #1 _tl } {#2} }
1015 \cs_new_protected:Npn \@@_define_name:nn #1#2
1016 { \tl_const:cn { c_@@_name_ #1 _tl } {#2} }
1017 \cs_new_protected:Npn \@@_define_name:nnn #1#2#3
1018 {
1019 \tl_const:cn { c_@@_name_ #1 _en_tl } {#2}
1020 \tl_const:cn { c_@@_name_ #1 _zh_tl } {#3}
1021 }
1022 % \end{macrocode}
1023 % \end{macro}
1024 %
1025 %
1026 % \begin{macro}{\@@_msg_new:nn,
1027 % \@@_error:n, \@@_error:nn, \@@_error:nx, \@@_error:nnn, \@@_error:nnnn,
1028 % \@@_warning:n, \@@_warning:nn, \@@_warning:nxx,
1029 % \@@_info:n
1030 %}
1031 % 各种信息函数的缩略形式。
1032 % \begin{macrocode}
1033 \cs_new:Npn \@@_msg_new:nn { \msg_new:nnn { hustthesis } }
1034 \cs_new:Npn \@@_error:n { \msg_error:nn { hustthesis } }
1035 \cs_new:Npn \@@_error:nn { \msg_error:nnn { hustthesis } }
1036 \cs_new:Npn \@@_error:nx { \msg_error:nnx { hustthesis } }
1037 \cs_new:Npn \@@_error:nnn { \msg_error:nnnn { hustthesis } }
1038 \cs_new:Npn \@@_error:nnnn { \msg_error:nnnnn { hustthesis } }
1039 \cs_new:Npn \@@_warning:n { \msg_warning:nn { hustthesis } }
1040 \cs_new:Npn \@@_warning:nn { \msg_warning:nnn { hustthesis } }
1041 \cs_new:Npn \@@_warning:nxx { \msg_warning:nnxx { hustthesis } }
1042 \cs_new:Npn \@@_info:n { \msg_info:nn { hustthesis } }
1043 % \end{macrocode}
1044 % \end{macro}
1045 %
1046 % \subsubsection{\LaTeXe{} 封装}
1047 %
1048 % \begin{macro}[deprecated]{\@@_vspace:N, \@@_vspace:n, \@@_vspace:c}
1049 % 类似 \LaTeXe{} 中的 \tn{vspace*}。
1050 % \begin{macrocode}
1051 \cs_new_protected:Npn \@@_vspace:N #1
1052 {
1053 \dim_set_eq:NN \l_@@_tmpa_dim \tex_prevdepth:D
1054 \tex_hrule:D height \c_zero_dim
1055 \nobreak
1056 \skip_vertical:N #1
1057 \skip_vertical:N \c_zero_skip
1058 \dim_set_eq:NN \tex_prevdepth:D \l_@@_tmpa_dim
1059 }
1060 \cs_new_protected:Npn \@@_vspace:n #1
1061 {
1062 \skip_set:Nn \l_@@_tmpa_skip {#1}
1063 \@@_vspace:N \l_@@_tmpa_skip
1064 }
1065 \cs_generate_variant:Nn \@@_vspace:N { c }
1066 % \end{macrocode}
1067 % \end{macro}
1068 %
1069 % \begin{macro}[deprecated]{\@@_hrule:nn}
1070 % 不改变位置的 \tn{hrule}。
1071 % \begin{arguments}
1072 % \item 线段粗细(高度)
1073 % \item 线段长度(宽度)
1074 % \end{arguments}
1075 % \begin{macrocode}
1076 \cs_new_protected:Npn \@@_hrule:nn #1#2
1077 {
1078 \rule [ -0.5 ex ] { #2 } { #1 }
1079 \skip_horizontal:n { -#2 }
1080 }
1081 % \end{macrocode}
1082 % \end{macro}
1083 %
1084 % \begin{macro}{\@@_ul_to_wd:nnn}
1085 % \begin{arguments}
1086 % \item 下划线粗细
1087 % \item 下划线长度
1088 % \item 内容
1089 % \end{arguments}
1090 % \begin{macrocode}
1091 \dim_new:N \l_@@_ul_dim
1092 \cs_new_protected:Npn \@@_ul_to_wd:nnn #1#2#3
1093 {
1094 \hbox_overlap_right:n { \rule [ - 0.5 ex ] { #2 } { #1 } }
1095 \hbox_to_wd:nn { #2 } { \tex_hfil:D #3 \tex_hfil:D }
1096 }
1097 % \end{macrocode}
1098 % \end{macro}
1099 %
1100 % \begin{macro}{\@@_line_spread:N, \@@_line_spread:n}
1101 % 设置行距。
1102 % \begin{arguments}
1103 % \item 行距倍数, |fp| 变量
1104 % \end{arguments}
1105 % \begin{macrocode}
1106 \cs_new:Npn \@@_line_spread:N #1
1107 {
1108 \tl_set:Nn \baselinestretch { \fp_use:N #1 }
1109 \selectfont
1110 }
1111 \cs_new:Npn \@@_line_spread:n #1
1112 {
1113 \tl_set:Nn \baselinestretch { #1 }
1114 \selectfont
1115 }
1116 % \end{macrocode}
1117 % \end{macro}
1118 %
1119 % \begin{macro}[deprecated]{\@@_arabic:n}
1120 % 等价于 \LaTeXe{} 中的 \tn{arabic}。
1121 % \begin{macrocode}
1122 \cs_new:Npn \@@_arabic:n #1
1123 { \int_to_arabic:v { c@ #1 } }
1124 % \end{macrocode}
1125 % \end{macro}
1126 %
1127 % \subsection{选项处理}
1128 %
1129 % 定义 | hust / option | 键值类,该键值类仅可在文档类选项中使用。
1130 % \begin{macrocode}
1131 \keys_define:nn { hust / option }
1132 {
1133 % \end{macrocode}
1134 %
1135 % \begin{macro}[module=option/]{type}
1136 % 论文类型。目前分为硕士学位论文~\opt{master} 和博士学位论文~\opt{doctor},默认为博士学位论文。
1137 % \begin{macrocode}
1138 type .choices:nn =
1139 { master, doctor }
1140 { \tl_gset_eq:NN \g_@@_degree_type_tl \l_keys_choice_tl },
1141 type .value_required:n = true,
1142 type .initial:n = { doctor },
1143 % \end{macrocode}
1144 % \end{macro}
1145 %
1146 % \begin{macro}[module=option/]{draft}
1147 % 是否启用草稿模式。默认为 \opt{false}。
1148 % \begin{macrocode}
1149 draft .choice:,
1150 draft / true .code:n =
1151 {
1152 \bool_gset_true:N \g_@@_draft_bool
1153 \clist_gput_right:Nn \g_@@_to_ctex_class_clist { draft }
1154 },
1155 draft / false .code:n =
1156 {
1157 \bool_gset_false:N \g_@@_draft_bool
1158 },
1159 draft .default:n = { true },
1160 draft .initial:n = { false },
1161 % \end{macrocode}
1162 % \end{macro}
1163 %
1164 % \begin{macro}[module=option/]{anonymous}
1165 % \changes{v2.0.0}{2025-02-18}{支持盲审模式}
1166 % 是否启用盲审模式。默认为 \opt{false},即显示作者信息。\key[option]{anonymous}
1167 % \begin{macrocode}
1168 anonymous .choice:,
1169 anonymous / true .code:n =
1170 {
1171 \bool_gset_true:N \g_@@_anonymous_bool
1172 },
1173 anonymous / false .code:n =
1174 {
1175 \bool_gset_false:N \g_@@_anonymous_bool
1176 },
1177 anonymous .default:n = { true },
1178 anonymous .initial:n = { false },
1179 % \end{macrocode}
1180 % \end{macro}
1181 %
1182 % \begin{macro}[module=option/]{anonymous-list}
1183 % 在开启盲审模式下需要隐藏的内容。其中连接符(|-|)需替换为下划线(|_|),星号(|*|)需替换为|_en|。
1184 % \begin{macrocode}
1185 anonymous-list .clist_gset:N = \g_@@_anonymous_clist,
1186 % \end{macrocode}
1187 % \end{macro}
1188 %
1189 % \begin{macro}[module=option/]{latin-font, cjk-font}
1190 % 中英文字体选项。\opt{fandol} 和 \opt{gyre} 是等价的。
1191 % \begin{macrocode}
1192 latin-font .choices:nn =
1193 { fandol, gyre, mac, macoffice, win, none, }
1194 { \tl_gset:Nn \g_@@_font_latin_tl {#1} },
1195 cjk-font .choices:nn =
1196 { fandol, founder, mac, macoffice, noto, source, win, none, }
1197 { \tl_gset:Nn \g_@@_font_cjk_tl {#1} },
1198 % \end{macrocode}
1199 % \end{macro}
1200 %
1201 % \begin{macro}[module=option/]{fontset}
1202 % 中英文字体选项。\opt{fontset} 这个名称和 \pkg{ctex} 中的是一致的。
1203 % \begin{macrocode}
1204 fontset .choices:nn =
1205 { fandol, mac, macoffice, win, none, }
1206 { \keys_set:nn { hust / option } { latin-font = #1, cjk-font = #1 } },
1207 % \end{macrocode}
1208 % \end{macro}
1209 %
1210 % \begin{macro}[module=option/]{math-font}
1211 % 数学字体选项。
1212 % 由 \pkg{unicode-math} 指定 \XeTeX 和 \LuaTeX 下使用的数学字体。
1213 % \begin{macrocode}
1214 math-font .choices:nn =
1215 {
1216 asana, cambria, fira, garamond, lm, libertinus, newcm,
1217 stix, bonum, dejavu, pagella, schola, termes, xits, none,
1218 }
1219 { \tl_gset_eq:NN \g_@@_font_math_tl \l_keys_choice_tl },
1220 math-font .initial:n = xits,
1221 % \end{macrocode}
1222 % \end{macro}
1223 %
1224 % \begin{macro}[module=option/]{font-dir}
1225 % 独立字体文件的路径。
1226 % \begin{macrocode}
1227 font-dir .code:n =
1228 {
1229 \bool_gset_true:N \g_@@_font_dir_bool
1230 \tl_gset_eq:NN \g_@@_font_dir_tl \l_keys_value_tl
1231 },
1232 % \end{macrocode}
1233 % \end{macro}
1234 %
1235 % \begin{macro}[module=option/]{config}
1236 % 自定义配置文件名。
1237 % \begin{macrocode}
1238 config .tl_gset:N = \g_@@_config_tl,
1239 % \end{macrocode}
1240 % \end{macro}
1241 %
1242 % 将未知选项传给 \cls{ctexbook} 文档类。
1243 % \begin{macrocode}
1244 unknown .code:n =
1245 { \clist_gput_right:No \g_@@_to_ctex_class_clist { \CurrentOption } }
1246 }
1247 % \end{macrocode}
1248 %
1249 % \begin{macro}[module=option/, int]{option/}
1250 % 将文档类选项传给 |hust / option|。
1251 % \begin{macrocode}
1252 \ProcessKeyOptions [ hust / option ]
1253 % \end{macrocode}
1254 % \end{macro}
1255 %
1256 % \subsection{常量载入}
1257 %
1258 % 载入常量定义文件。
1259 % \begin{macrocode}
1260 \tl_if_empty:NTF \g_@@_config_tl
1261 {
1262 \tl_if_eq:NnT \g_@@_degree_type_tl { master }
1263 { \file_input:n { hustthesis-m.def } }
1264 \tl_if_eq:NnT \g_@@_degree_type_tl { doctor }
1265 { \file_input:n { hustthesis-d.def } }
1266 }
1267 {
1268 \@@_msg_new:nn { load-config-file }
1269 { You~ are~ loading~ config~ file~ "#1". }
1270 \@@_info:n { load-config-file }
1271 \file_input:V { \g_@@_config_tl }
1272 }
1273 % \end{macrocode}
1274 %
1275 % \subsection{宏包载入}
1276 %
1277 % \sout{对不支持粗体斜体的字体进行兼容处理,仅限于 \XeTeX{} 引擎。}\\
1278 % \sout{参考自 \url{https://ask.latexstudio.net/ask/question/17464.html}。}
1279 % \begin{macrocode}
1280 %\sys_if_engine_xetex:T
1281 % {
1282 % \PassOptionsToPackage { AutoFakeBold=4.0 } { xeCJK }
1283 % \AddToHook { package / ctex / before }
1284 % {
1285 % \AddToHook { package / xeCJK / after }
1286 % {
1287 % \keys_define:nn { xeCJK / features }
1288 % {
1289 % BoldFont .code:n = ,
1290 % ItalicFont .code:n =,
1291 % }
1292 % }
1293 % }
1294 % \AddToHook { package / ctex / after }
1295 % {
1296 % \keys_define:nn { xeCJK / features }
1297 % {
1298 % BoldFont .tl_set:N = \l__xeCJK_font_name_bf_tl ,
1299 % ItalicFont .tl_set:N = \l__xeCJK_font_name_it_tl,
1300 % }
1301 % }
1302 % }
1303 % \end{macrocode}
1304 %
1305 % 将选项传入 \cls{ctexbook} 文档类。
1306 % \begin{macrocode}
1307 \PassOptionsToClass
1308 {
1309 a4paper,
1310 UTF8,
1311 scheme = chinese,
1312 fontset = none,
1313 oneside,
1314 heading = true,
1315 zihao = -4,
1316 linespread = \c_@@_line_spread_fp,
1317 \g_@@_to_ctex_class_clist,
1318 }
1319 { ctexbook }
1320 \LoadClass { ctexbook }
1321 % \end{macrocode}
1322 %
1323 % 其中 \pkg{utfsym} 宏包不依赖外部字体,使用 \TikZ{} 宏包绘制 |U+2610|:~☐,|U+2611|:~☑,|U+1F5F9|:~\usym{1F5F9} 等符号。
1324 % \begin{macrocode}
1325 \RequirePackage
1326 {
1327 hustvisual,
1328 amsmath,
1329 geometry,
1330 fancyhdr,
1331 titletoc,
1332 graphicx,
1333 multirow,
1334 longtable,
1335 caption,
1336 utfsym,
1337 }
1338 % \end{macrocode}
1339 %
1340 % 载入基于 \clsname{} 样式的 \pkg{biblatex} 宏包。
1341 % \begin{macrocode}
1342 \RequirePackage[style=hustthesis]{biblatex}
1343 % \end{macrocode}
1344 %
1345 %
1346 % \section{全局样式}
1347 %
1348 % 隐藏盲审模式下需要隐藏的内容。
1349 % \begin{macrocode}
1350 \clist_map_inline:Nn \g_@@_anonymous_clist
1351 {
1352 \tl_gset_eq:cN { g_@@_name_ #1 _tl } \c_empty_tl
1353 }
1354 % \end{macrocode}
1355 %
1356 % \subsection{页面布局}
1357 % 利用 \pkg{geometry} 宏包设置纸张大小、页面边距以及页眉高度。
1358 % \begin{macrocode}
1359 \geometry
1360 {
1361 top = 4.5 cm,
1362 bottom = 2.8 cm,
1363 left = 2.8 cm,
1364 right = 2.8 cm,
1365 headheight = 30 pt,
1366 }
1367 % \end{macrocode}
1368 %
1369 % \subsection{字体设置}
1370 %
1371 % ^^A 本小节初版实现主要来自 \pkg{njuthesis} 文档类。
1372 %
1373 % \pkg{fontspec} 包含于 \pkg{ctex} 宏集,无需另行载入。
1374 %
1375 % \subsubsection{操作系统检测}
1376 %
1377 % \begin{variable}{\c_@@_path_macoffice_tl}
1378 % mac Office 字体路径。
1379 % \begin{macrocode}
1380 \tl_const:Nn \c_@@_path_macoffice_tl
1381 { /Applications/Microsoft~ Word.app/Contents/Resources/DFonts/ }
1382 % \end{macrocode}
1383 % \end{variable}
1384 %
1385 % 操作系统检测。相较于 \pkg{ctex} 提供的 \cs{ctex_detect_platform:},
1386 % 额外增加了对 macOS 上 MS Office 的检测。
1387 % \begin{macrocode}
1388 \sys_if_platform_windows:TF
1389 { \tl_gset:Nn \g_@@_font_set_tl { win } }
1390 {
1391 \ctex_if_platform_macos:TF
1392 {
1393 \file_if_exist:nTF { \c_@@_path_macoffice_tl times.ttf }
1394 { \tl_gset:Nn \g_@@_font_set_tl { macoffice } }
1395 { \tl_gset:Nn \g_@@_font_set_tl { mac } }
1396 }
1397 { \tl_gset:Nn \g_@@_font_set_tl { fandol } }
1398 }
1399 % \end{macrocode}
1400 % 判断用户是否自定义了中英文字体。如果其中任意一种未被定义,
1401 % 则使用系统预装字体覆盖字体选项。
1402 % Windows 或 macOS 外的系统被判断为 Linux,一律使用自由字体。
1403 % \begin{macrocode}
1404 \tl_if_empty:NT \g_@@_font_latin_tl
1405 { \tl_gset_eq:NN \g_@@_font_latin_tl \g_@@_font_set_tl }
1406 \tl_if_empty:NT \g_@@_font_cjk_tl
1407 { \tl_gset_eq:NN \g_@@_font_cjk_tl \g_@@_font_set_tl }
1408 % \end{macrocode}
1409 %
1410 %
1411 % \subsubsection{定义英文字库}
1412 %
1413 % 接下来逐个定义所需要使用的字库。
1414 %
1415 % \begin{macro}{
1416 % \@@_loadfont_latin:n,
1417 % \@@_loadfont_latin_win:,
1418 % \@@_loadfont_latin_mac:,
1419 % }
1420 % Windows 与 macOS 西文字体的区别主要在于默认等宽字体。
1421 % \begin{macrocode}
1422 \cs_new:Npn \@@_loadfont_latin:n #1
1423 {
1424 \__fontspec_main_setmainfont:nn { } { Times~New~Roman }
1425 \__fontspec_main_setsansfont:nn { } { Arial }
1426 \__fontspec_main_setmonofont:nn { Scale = MatchLowercase } {#1}
1427 }
1428 \cs_new_protected:Npn \@@_loadfont_latin_win:
1429 { \@@_loadfont_latin:n { Courier~New } }
1430 \cs_new_protected:Npn \@@_loadfont_latin_mac:
1431 {
1432 \@@_loadfont_latin:n { Menlo }
1433 % \end{macrocode}
1434 % 检测 Times New Roman 是否具有小型大写字母(small caps)字型。
1435 % 这是 macOS 预装的字体版本较旧导致的。
1436 % \begin{macrocode}
1437 \fontspec_if_small_caps:F
1438 {
1439 \@@_warning:n { no-small-caps }
1440 \__fontspec_main_setmainfont:nn
1441 { \c_@@_name_gyrefeature_clist } { texgyretermes }
1442 }
1443 }
1444 \@@_msg_new:nn { no-small-caps }
1445 {
1446 I~ am~ using~ TeX~ Gyre~ Termes~ as~ default~ Roman~ font.\\
1447 This~ is~ because~ the~ "Times~ New~ Roman"~ font~ in~ your~
1448 system~ does~ not~ embed~ glyphs~ for~ small~ capitals.~
1449 You~ can~ ignore~ this~ warning~ if~ you~ do~ not~ need~
1450 \string\textsc.~ For~ more~ information,~
1451 please~ refer~ to~ section~ 3.2.6~ of~ the~ documentation.
1452 }
1453 % \end{macrocode}
1454 % \end{macro}
1455 %
1456 % \begin{macro}{\@@_loadfont_latin_macoffice:}
1457 % mac Office 西文字体。
1458 % \begin{macrocode}
1459 \cs_new_protected:Npn \@@_loadfont_latin_macoffice:
1460 {
1461 \__fontspec_main_setmainfont:nn
1462 { \c_@@_name_macofficefeature_clist } { times }
1463 \__fontspec_main_setsansfont:nn
1464 { \c_@@_name_macofficefeature_clist } { arial }
1465 \__fontspec_main_setmonofont:nn
1466 { Scale = MatchLowercase } { Menlo }
1467 }
1468 % \end{macrocode}
1469 % \end{macro}
1470 %
1471 % \begin{variable}{\c_@@_name_macofficefeature_clist}
1472 % 用于 \pkg{fontspec} 的 mac Office 字体特性列表。
1473 % \begin{macrocode}
1474 \clist_const:Nn \c_@@_name_macofficefeature_clist
1475 {
1476 Path = \c_@@_path_macoffice_tl,
1477 Extension = .ttf,
1478 UprightFont = *,
1479 BoldFont = *bd,
1480 ItalicFont = *i,
1481 BoldItalicFont = *bi,
1482 }
1483 % \end{macrocode}
1484 % \end{variable}
1485 %
1486 % \begin{macro}{\@@_loadfont_latin_gyre:}
1487 % 开源的 \TeX Gyre 西文字体。
1488 % \begin{macrocode}
1489 \cs_new_protected:Npn \@@_loadfont_latin_gyre:
1490 {
1491 \__fontspec_main_setmainfont:nn
1492 { \c_@@_name_gyrefeature_clist } { texgyretermes }
1493 \__fontspec_main_setsansfont:nn
1494 { \c_@@_name_gyrefeature_clist } { texgyreheros }
1495 \__fontspec_main_setmonofont:nn
1496 {
1497 \c_@@_name_gyrefeature_clist,
1498 Scale = MatchLowercase,
1499 Ligatures = CommonOff,
1500 }
1501 { texgyrecursor }
1502 }
1503 % \end{macrocode}
1504 % \end{macro}
1505 %
1506 % \begin{macro}{\@@_loadfont_latin_fandol:}
1507 % 为兼容 \pkg{ctex} 做出的名称改变。
1508 % \begin{macrocode}
1509 \cs_new_eq:NN \@@_loadfont_latin_fandol: \@@_loadfont_latin_gyre:
1510 % \end{macrocode}
1511 % \end{macro}
1512 %
1513 % \begin{variable}{\c_@@_name_gyrefeature_clist}
1514 % 用于 \pkg{fontspec} 的 \TeX Gyre 字体特性列表。
1515 % \begin{macrocode}
1516 \clist_const:Nn \c_@@_name_gyrefeature_clist
1517 {
1518 Extension = .otf,
1519 UprightFont = *-regular,
1520 BoldFont = *-bold,
1521 ItalicFont = *-italic,
1522 BoldItalicFont = *-bolditalic,
1523 }
1524 % \end{macrocode}
1525 % \end{variable}
1526 %
1527 %
1528 % \subsubsection{定义中文字库}
1529 %
1530 % \begin{macro}{\@@_hide_no_script_msg:}
1531 % 隐藏 |does not contain script "CJK"| 警告。
1532 % \begin{macrocode}
1533 \cs_new:Npn \@@_hide_no_script_msg:
1534 { \msg_redirect_name:nnn { fontspec } { no-script } { info } }
1535 % \end{macrocode}
1536 % \end{macro}
1537 %
1538 % \begin{macro}{\@@_loadfont_cjk_win:N, \@@_loadfont_cjk_win:}
1539 % Windows 中文字体。
1540 % \begin{macrocode}
1541 \cs_new:Npn \@@_loadfont_cjk_win:N #1
1542 {
1543 \setCJKmainfont { SimSun } [ #1, ItalicFont = KaiTi ]
1544 \setCJKsansfont { SimHei } [#1]
1545 \setCJKmonofont { FangSong } [#1]
1546 \setCJKfamilyfont { zhsong } { SimSun } [#1]
1547 \setCJKfamilyfont { zhhei } { SimHei } [#1]
1548 \setCJKfamilyfont { zhfs } { FangSong } [#1]
1549 \setCJKfamilyfont { zhkai } { KaiTi } [#1]
1550 \@@_define_stzhongs:nn { STZhongsong } {#1}
1551 }
1552 \cs_new:Npn \@@_loadfont_cjk_win:
1553 { \@@_loadfont_cjk_win:N \c_@@_name_fakebold_tl }
1554 % \end{macrocode}
1555 % \end{macro}
1556 %
1557 % \begin{macro}{\@@_loadfont_cjk_mac:}
1558 % macOS 字体。
1559 % ^^A TODO: 修复 macOS 字体支持,实现开箱即用。
1560 % \begin{macrocode}
1561 \cs_new_protected:Npn \@@_loadfont_cjk_mac:
1562 {
1563 \@@_hide_no_script_msg:
1564 \setCJKmainfont { Songti~SC~Light }
1565 [
1566 BoldFont = Songti~SC~Bold,
1567 ItalicFont = Kaiti~SC,
1568 BoldItalicFont = Kaiti~SC~Bold,
1569 ]
1570 \setCJKsansfont { Heiti~SC~Light } [ BoldFont = Heiti~SC~Medium ]
1571 \setCJKmonofont { STFangsong }
1572 \setCJKfamilyfont { zhsong } { Songti~SC~Light } [ BoldFont = Songti~SC~Bold ]
1573 \setCJKfamilyfont { zhhei } { Heiti~SC~Light } [ BoldFont = Heiti~SC~Medium ]
1574 \setCJKfamilyfont { zhfs } { STFangsong }
1575 \setCJKfamilyfont { zhkai } { Kaiti~SC } [ BoldFont = Kaiti~SC~Bold ]
1576 }
1577 % \end{macrocode}
1578 % \end{macro}
1579 %
1580 % \begin{macro}{\@@_loadfont_cjk_macoffice:n, \@@_loadfont_cjk_macoffice:}
1581 % mac Office 中文字体。
1582 % \begin{macrocode}
1583 \cs_new:Npn \@@_loadfont_cjk_macoffice:n #1
1584 {
1585 \setCJKmainfont { Simsun.ttc } [ ItalicFont = Kaiti.ttf, #1 ]
1586 \setCJKsansfont { SimHei.ttf } [#1]
1587 \setCJKmonofont { Fangsong.ttf } [#1]
1588 \setCJKfamilyfont { zhsong } { Simsun.ttc } [#1]
1589 \setCJKfamilyfont { zhhei } { SimHei.ttf } [#1]
1590 \setCJKfamilyfont { zhfs } { Fangsong.ttf } [#1]
1591 \setCJKfamilyfont { zhkai } { Kaiti.ttf } [#1]
1592 \@@_define_stzhongs:nn { \c__hust_path_macoffice_tl STZHONGS.ttf } {#1}
1593 }
1594 \cs_new:Npn \@@_loadfont_cjk_macoffice:
1595 {
1596 \@@_loadfont_cjk_macoffice:n
1597 { Path = \c_@@_path_macoffice_tl, \c_@@_name_fakebold_tl }
1598 }
1599 % \end{macrocode}
1600 % \end{macro}
1601 %
1602 % \begin{macro}{\@@_loadfont_cjk_fandol:}
1603 % Fandol 字体。
1604 % \begin{macrocode}
1605 \cs_new_protected:Npn \@@_loadfont_cjk_fandol:
1606 {
1607 \@@_hide_no_script_msg:
1608 \setCJKmainfont { FandolSong-Regular }
1609 [
1610 Extension = .otf,
1611 BoldFont = FandolSong-Bold,
1612 ItalicFont = FandolKai-Regular,
1613 ]
1614 \setCJKsansfont { FandolHei-Regular }
1615 [
1616 Extension = .otf,
1617 BoldFont = FandolHei-Bold,
1618 ]
1619 \setCJKmonofont { FandolFang-Regular }
1620 [ Extension = .otf ]
1621 \setCJKfamilyfont { zhsong } { FandolSong-Regular }
1622 [
1623 Extension = .otf,
1624 BoldFont = FandolSong-Bold
1625 ]
1626 \setCJKfamilyfont { zhhei } { FandolHei-Regular }
1627 [
1628 Extension = .otf,
1629 BoldFont = FandolHei-Bold,
1630 ]
1631 \setCJKfamilyfont { zhfs } { FandolFang-Regular }
1632 [ Extension = .otf ]
1633 \setCJKfamilyfont { zhkai } { FandolKai-Regular }
1634 [ Extension = .otf, \c_@@_name_fakebold_tl ]
1635 }
1636 % \end{macrocode}
1637 % \end{macro}
1638 %
1639 % \begin{macro}{\@@_loadfont_cjk_founder:}
1640 % 方正字库(简繁扩展)
1641 % \begin{macrocode}
1642 \cs_new_protected:Npn \@@_loadfont_cjk_founder:
1643 {
1644 % \end{macrocode}
1645 % 调整方正字体括号位置。
1646 % \footnote{\XeTeX 的调整方法来自 \url{https://www.zhihu.com/question/46241367/answer/101660183}。}
1647 % \begin{macrocode}
1648 \sys_if_engine_xetex:T
1649 { \xeCJKEditPunctStyle { quanjiao } { optimize-kerning = true } }
1650 \sys_if_engine_luatex:T
1651 { \defaultCJKfontfeatures { JFM = { zh_CN / { quanjiao, fzpr } } } }
1652 \setCJKmainfont { FZShuSong-Z01 }
1653 [ BoldFont = FZXiaoBiaoSong-B05, ItalicFont = FZKai-Z03 ]
1654 \setCJKsansfont { FZXiHeiI-Z08 } [ BoldFont = FZHei-B01 ]
1655 \setCJKmonofont { FZFangSong-Z02 }
1656 \setCJKfamilyfont { zhsong } { FZShuSong-Z01 }
1657 [ BoldFont = FZXiaoBiaoSong-B05 ]
1658 \setCJKfamilyfont { zhhei } { FZHei-B01 }
1659 [ \c_@@_name_fakebold_tl ]
1660 \setCJKfamilyfont { zhkai } { FZKai-Z03 }
1661 [ \c_@@_name_fakebold_tl ]
1662 \setCJKfamilyfont { zhfs } { FZFangSong-Z02 }
1663 \defaultCJKfontfeatures { }
1664 }
1665 % \end{macrocode}
1666 % \end{macro}
1667 %
1668 % \begin{macro}{\@@_loadfont_cjk_noto:}
1669 % Noto 思源字体。
1670 % \begin{macrocode}
1671 \cs_new_protected:Npn \@@_loadfont_cjk_noto:
1672 {
1673 \setCJKmainfont [ \c_@@_name_notofeature_clist ]
1674 { NotoSerifCJKsc }
1675 \setCJKsansfont [ \c_@@_name_notofeature_clist ]
1676 { NotoSansCJKsc }
1677 \setCJKmonofont { Noto~Sans~Mono~CJK~SC }
1678 \setCJKfamilyfont { zhsong } { Noto~Serif~CJK~SC }
1679 \setCJKfamilyfont { zhhei } { Noto~Sans~CJK~SC }
1680 \setCJKfamilyfont { zhfs } { FZFangSong-Z02 }
1681 \setCJKfamilyfont { zhkai } { FZKai-Z03 }
1682 [ \c_@@_name_fakebold_tl ]
1683 }
1684 % \end{macrocode}
1685 % \end{macro}
1686 %
1687 % \begin{macro}{\@@_loadfont_cjk_source:}
1688 % \begin{macrocode}
1689 \cs_new_protected:Npn \@@_loadfont_cjk_source:
1690 {
1691 \setCJKmainfont [ \c_@@_name_notofeature_clist ]
1692 { SourceHanSerifSC }
1693 \setCJKsansfont [ \c_@@_name_notofeature_clist ]
1694 { SourceHanSansSC }
1695 \setCJKmonofont { FZFangSong-Z02 }
1696 \setCJKfamilyfont { zhsong } { Source~Han~Serif~SC }
1697 \setCJKfamilyfont { zhhei } { Source~Han~Sans~SC }
1698 \setCJKfamilyfont { zhfs } { FZFangSong-Z02 }
1699 \setCJKfamilyfont { zhkai } { FZKai-Z03 }
1700 [ \c_@@_name_fakebold_tl ]
1701 }
1702 % \end{macrocode}
1703 % \end{macro}
1704 %
1705 % \begin{variable}{\c_@@_name_fakebold_tl}
1706 % \begin{macrocode}
1707 \tl_const:Nn \c_@@_name_fakebold_tl { AutoFakeBold = 2.17 }
1708 % \end{macrocode}
1709 % \end{variable}
1710 %
1711 % \begin{variable}{\c_@@_name_notofeature_clist}
1712 % 用于 \pkg{fontspec} 的思源字体特性列表。
1713 % \begin{macrocode}
1714 \clist_const:Nn \c_@@_name_notofeature_clist
1715 {
1716 Extension = .otf,
1717 UprightFont = *-Regular,
1718 BoldFont = *-Bold,
1719 ItalicFont = *-Regular,
1720 BoldItalicFont = *-Bold,
1721 ItalicFeatures = FakeSlant,
1722 BoldItalicFeatures = FakeSlant,
1723 }
1724 % \end{macrocode}
1725 % \end{variable}
1726 %
1727 % \begin{variable}{\l_@@_name_stzhongsopts_tl}
1728 % 华文中宋的字体特性列表,默认为仅使用伪粗体。
1729 % \begin{macrocode}
1730 \tl_new:N \l_@@_name_stzhongsopts_tl
1731 \tl_set_eq:NN \l_@@_name_stzhongsopts_tl \c_@@_name_fakebold_tl
1732 % \end{macrocode}
1733 % \end{variable}
1734 %
1735 % \begin{macro}{\@@_define_stzhongs:nn}
1736 % 中文封面额外需要的华文中宋。
1737 % \begin{macrocode}
1738 \tl_new:N \l_@@_name_stzhongsfile_tl
1739 \cs_new:Npn \@@_define_stzhongs:nn #1#2
1740 {
1741 \tl_set:Nn \l_@@_name_stzhongsfile_tl {#1}
1742 \tl_set:Nn \l_@@_name_stzhongsopts_tl {#2}
1743 }
1744 % \end{macrocode}
1745 % \end{macro}
1746 %
1747 % \begin{macro}{\@@_loadfont_stzhongs:n}
1748 % \begin{macro}{\@@_loadfont_stzhongs:V, \@@_loadfont_stzhongs:, \@@_stzhongs:}
1749 % 研究生封面额外需要的华文中宋。
1750 % \begin{macrocode}
1751 \cs_new:Npn \@@_loadfont_stzhongs:
1752 {
1753 \@@_loadfont_stzhongs:V \l_@@_name_stzhongsfile_tl
1754 }
1755 \cs_new_protected:Npn \@@_loadfont_stzhongs:n #1
1756 {
1757 \fontspec_font_if_exist:nTF { #1 }
1758 {
1759 \newCJKfontfamily \@@_stzhongs: { #1 }
1760 [ \l_@@_name_stzhongsopts_tl ]
1761 }
1762 {
1763 \bool_if:NTF \g_@@_font_dir_bool
1764 {
1765 \newCJKfontfamily \@@_stzhongs: { #1 }
1766 [ Path = \g_@@_font_dir_tl, \c_@@_name_fakebold_tl ]
1767 }
1768 {
1769 \cs_set_eq:NN \@@_stzhongs: \rmfamily
1770 \@@_warning:n { missing-stzhongs }
1771 }
1772 }
1773 }
1774 \@@_msg_new:nn { missing-stzhongs }
1775 {
1776 "STZHONGS.TTF"~ is~ not~ found~ in~ your~ system.\\
1777 The~ font~ is~ normally~ distributed~ with~ MS~ Windows.~
1778 I~ have~ used~ songti~ for~ substitution.
1779 }
1780 \cs_generate_variant:Nn \@@_loadfont_stzhongs:n { V }
1781 % \end{macrocode}
1782 % \end{macro}
1783 % \end{macro}
1784 %
1785 %
1786 % \subsubsection{定义数学字库}
1787 %
1788 % \begin{macro}{\@@_define_math_font:nn}
1789 % 批量定义数学字体配置。
1790 % \begin{macrocode}
1791 \cs_new:Npn \@@_define_math_font:nn #1#2
1792 {
1793 \cs_new:cpn { @@_loadfont_math_ #1 : }
1794 { \__um_setmathfont:nn { } {#2} }
1795 }
1796 % \end{macrocode}
1797 % \end{macro}
1798 %
1799 % \begin{macro}
1800 % {
1801 % \@@_loadfont_math_asana:,
1802 % \@@_loadfont_math_fira:,
1803 % \@@_loadfont_math_garamond:,
1804 % \@@_loadfont_math_lm:,
1805 % \@@_loadfont_math_libertinus:,
1806 % \@@_loadfont_math_stix:,
1807 % \@@_loadfont_math_bonum:,
1808 % \@@_loadfont_math_dejavu:,
1809 % \@@_loadfont_math_pagella:,
1810 % \@@_loadfont_math_schola:,
1811 % \@@_loadfont_math_termes:,
1812 % }
1813 % 批量定义若干数学字体的载入命令。
1814 % \begin{macrocode}
1815 \clist_map_inline:nn
1816 {
1817 { asana } { Asana-Math.otf },
1818 { fira } { FiraMath-Regular.otf },
1819 { garamond } { Garamond-Math.otf },
1820 { lm } { latinmodern-math.otf },
1821 { libertinus } { LibertinusMath-Regular.otf },
1822 { stix } { STIXMath-Regular.otf },
1823 { bonum } { texgyrebonum-math.otf },
1824 { dejavu } { texgyredejavu-math.otf },
1825 { pagella } { texgyrepagella-math.otf },
1826 { schola } { texgyreschola-math.otf },
1827 { termes } { texgyretermes-math.otf },
1828 }
1829 { \@@_define_math_font:nn #1 }
1830 % \end{macrocode}
1831 % \end{macro}
1832 %
1833 % \begin{macro}{\@@_loadfont_math_cambria:}
1834 % Cambria Math 字体配置。
1835 % \begin{macrocode}
1836 \cs_new:Npn \@@_loadfont_math_cambria:
1837 {
1838 \bool_if:NTF \g_@@_font_dir_bool
1839 {
1840 \__um_setmathfont:nn
1841 { Path = \g_@@_font_dir_tl/, FontIndex = 1 }
1842 { cambria.ttc }
1843 }
1844 { \__um_setmathfont:nn { } { Cambria~Math } }
1845 }
1846 % \end{macrocode}
1847 % \end{macro}
1848 %
1849 % \begin{macro}{\@@_loadfont_math_xits:}
1850 % XITS Math 字体。
1851 % \begin{macrocode}
1852 \cs_new:Npn \@@_loadfont_math_xits:
1853 {
1854 \bool_if:NTF \g_@@_opt_math_int_bool
1855 { \tl_set:Nn \l_@@_tmpa_tl { 8 } }
1856 { \tl_clear:N \l_@@_tmpa_tl }
1857 \__um_setmathfont:nn
1858 {
1859 Extension = .otf,
1860 StylisticSet = \l_@@_tmpa_tl,
1861 BoldFont = XITSMath-Bold,
1862 }
1863 { XITSMath-Regular }
1864 \__um_setmathfont:nn
1865 {
1866 Extension = .otf,
1867 StylisticSet = 1,
1868 range = {cal, bfcal},
1869 }
1870 { XITSMath-Regular }
1871 }
1872 % \end{macrocode}
1873 % \end{macro}
1874 %
1875 % \begin{macro}{\@@_loadfont_math_newcm:}
1876 % New Computer Modern Math 字体。
1877 % \begin{macrocode}
1878 \cs_new:Npn \@@_loadfont_math_newcm:
1879 {
1880 \bool_if:NTF \g_@@_opt_math_int_bool
1881 { \tl_set:Nn \l_@@_tmpa_tl { 2 } }
1882 { \tl_clear:N \l_@@_tmpa_tl }
1883 \__um_setmathfont:nn
1884 {
1885 Extension = .otf,
1886 StylisticSet = \l_@@_tmpa_tl,
1887 }
1888 { NewCMMath-Book }
1889 \__um_setmathfont:nn
1890 {
1891 Extension = .otf,
1892 StylisticSet = 1,
1893 range = {scr,bfscr},
1894 }
1895 { NewCMMath-Book }
1896 \__fontspec_main_setmathrm:nn
1897 {
1898 Extension = .otf,
1899 UprightFont = *-Book,
1900 BoldFont = *-Bold,
1901 ItalicFont = *-BookItalic,
1902 BoldItalicFont = *-BoldItalic,
1903 }
1904 { NewCM10 }
1905 \__fontspec_main_setmathsf:nn
1906 {
1907 Extension = .otf,
1908 UprightFont = *-Book,
1909 BoldFont = *-Bold,
1910 ItalicFont = *-BookOblique,
1911 BoldItalicFont = *-BoldOblique,
1912 }
1913 { NewCMSans10 }
1914 \__fontspec_main_setmathtt:nn
1915 {
1916 Extension = .otf,
1917 UprightFont = *-Book,
1918 ItalicFont = *-BookItalic,
1919 BoldFont = *-Bold,
1920 BoldItalicFont = *-BoldOblique,
1921 }
1922 { NewCMMono10 }
1923 }
1924 % \end{macrocode}
1925 % \end{macro}
1926 %
1927 % \begin{macro}{\@@_loadfont_math_none:}
1928 % 不进行数学字体配置。
1929 % \begin{macrocode}
1930 \cs_set_eq:NN \@@_loadfont_math_none: \tex_relax:D
1931 % \end{macrocode}
1932 % \end{macro}
1933 %
1934 %
1935 % \subsubsection{载入指定字库}
1936 %
1937 % \begin{macro}{\@@_loadfont:}
1938 % 载入字体命令。
1939 % \begin{macrocode}
1940 \cs_new_protected:Npn \@@_loadfont:
1941 {
1942 \use:c { @@_loadfont_latin_ \g_@@_font_latin_tl : }
1943 \use:c { @@_loadfont_cjk_ \g_@@_font_cjk_tl : }
1944 % \end{macrocode}
1945 % 自行定义 \pkg{ctex} 中的四类字体命令。
1946 % \begin{macrocode}
1947 \NewDocumentCommand \songti { } { \CJKfamily { zhsong } }
1948 \NewDocumentCommand \heiti { } { \CJKfamily { zhhei } }
1949 \NewDocumentCommand \fangsong { } { \CJKfamily { zhfs } }
1950 \NewDocumentCommand \kaishu { } { \CJKfamily { zhkai } }
1951 }
1952 % \end{macrocode}
1953 % \end{macro}
1954 %
1955 % 载入设置的字体。^^A 为了吸收导言区的设置,放在其后载入。
1956 % \begin{macrocode}
1957 % \BeforeBeginEnvironment { document } { \@@_loadfont: }
1958 \@@_loadfont:
1959 % \end{macrocode}
1960 %
1961 % 将华文中宋放在文档类最后载入。
1962 % \begin{macrocode}
1963 \ctex_at_end_preamble:n { \@@_loadfont_stzhongs: }
1964 % \end{macrocode}
1965 %
1966 % \subsection{页眉页脚}
1967 %
1968 % 清除默认页眉页脚格式。
1969 % \begin{macrocode}
1970 \fancyhf {}
1971 % \end{macrocode}
1972 %
1973 % 设置页眉页脚颜色。
1974 % \changes{v2.0.0}{2025-02-21}{使用 \pkg{l3color},不再依赖 \pkg{xcolor}}
1975 % \begin{macrocode}
1976 \color_set:nn { headfoot } { red }
1977 % \providecolor { headfoot } { rgb } { 1, 0, 0 }
1978 % \end{macrocode}
1979 %
1980 % \begin{macro}{\@@_draw_hf_hline:n}
1981 % 绘制页眉页脚横线。
1982 % \begin{arguments}
1983 % \item 页眉页脚线的高度(粗细)
1984 % \end{arguments}
1985 % \begin{macrocode}
1986 \cs_new_protected:Npn \@@_draw_hf_hline:n #1
1987 {
1988 { \color_select:n { headfoot } \tex_hrule:D height #1 }
1989 }
1990 % \end{macrocode}
1991 % \end{macro}
1992 %
1993 % \sout{设置页眉格式。仅在非盲审模式~\key{anonymous} 下显示学校名称。}
1994 % \begin{macrocode}
1995 %\bool_if:NF \g_@@_anonymous_bool
1996 % {
1997 \chead
1998 {
1999 \zihao{3} \ziju{0.75} \bfseries \kaishu
2000 \color_group_begin:
2001 \color_select:n { headfoot }
2002 \c_@@_header_tl
2003 \color_group_end:
2004 }
2005 % }
2006 \tl_set:Nn { \headrulewidth } { 1 pt }
2007 \tl_set:Nn { \headrule }
2008 {
2009 \skip_vertical:n { 3 pt }
2010 \@@_draw_hf_hline:n \headrulewidth
2011 \skip_vertical:n \headrulewidth
2012 \@@_draw_hf_hline:n \headrulewidth
2013 }
2014 % \end{macrocode}
2015 %
2016 % 设置页脚格式。
2017 % \begin{macrocode}
2018 \cfoot { \zihao{-5} \thepage }
2019 \tl_set:Nn { \footrulewidth } { 0.5 pt }
2020 \tl_set:Nn { \footrule }
2021 {
2022 \@@_draw_hf_hline:n \footrulewidth
2023 \skip_vertical:n { 3 pt }
2024 }
2025 % \end{macrocode}
2026 %
2027 % \pkg{ctex} 宏包使用 |heading| 选项后,会把页面格式设置为 |headings|。
2028 % 因此必须在 \pkg{ctex} 调用之后重新设置 \tn{pagestyle} 为 |fancy|。
2029 % \begin{macrocode}
2030 \pagestyle { fancy }
2031 % \end{macrocode}
2032 %
2033 %
2034 % \section{封面扉页样式}
2035 %
2036 % 定义中英文封面,答辩委员会页,声明页样式,即在正文前不含有页眉页脚的特殊页面样式。
2037 %
2038 % \subsection{信息录入}
2039 %
2040 % \begin{variable}{
2041 % \g_@@_info_title_tl,
2042 % \g_@@_info_degree_tl,
2043 % \g_@@_info_author_tl,
2044 % \g_@@_info_major_tl,
2045 % \g_@@_info_supervisor_tl,
2046 % \g_@@_info_date_tl,
2047 % \g_@@_info_clc_tl,
2048 % \g_@@_info_student_id_tl,
2049 % \g_@@_info_school_id_tl,
2050 % \g_@@_info_secret_tl,
2051 % }
2052 % 声明中文封面信息。
2053 % \begin{macrocode}
2054 \tl_new:N \g_@@_info_title_tl
2055 \tl_new:N \g_@@_info_degree_type_tl
2056 \tl_new:N \g_@@_info_author_tl
2057 \tl_new:N \g_@@_info_major_tl
2058 \tl_new:N \g_@@_info_supervisor_tl
2059 \tl_new:N \g_@@_info_date_tl
2060 \tl_new:N \g_@@_info_clc_tl
2061 \tl_new:N \g_@@_info_student_id_tl
2062 \tl_new:N \g_@@_info_school_id_tl
2063 \tl_new:N \g_@@_info_secret_tl
2064 % \end{macrocode}
2065 % \end{variable}
2066 %
2067 % \begin{variable}{
2068 % \g_@@_info_title_en_tl,
2069 % \g_@@_info_author_en_tl,
2070 % \g_@@_info_major_en_tl,
2071 % \g_@@_info_supervisor_en_tl,
2072 % \g_@@_info_date_en_tl,
2073 % \g_@@_info_degree_en_tl,
2074 % }
2075 % 声明英文封面信息。
2076 % \begin{macrocode}
2077 \tl_new:N \g_@@_info_title_en_tl
2078 \tl_new:N \g_@@_info_author_en_tl
2079 \tl_new:N \g_@@_info_major_en_tl
2080 \tl_new:N \g_@@_info_supervisor_en_tl
2081 \tl_new:N \g_@@_info_date_en_tl
2082 \tl_new:N \g_@@_info_degree_en_tl
2083 % \end{macrocode}
2084 % \end{variable}
2085 %
2086 % \begin{macro}{\g_@@_info_committee_seq}
2087 % 声明答辩委员会成员列表。
2088 % \begin{macrocode}
2089 \seq_new:N \g_@@_info_committee_seq
2090 % \end{macrocode}
2091 % \end{macro}
2092 %
2093 % \begin{variable}{\l_@@_info_title_sanitized_tl,\l_@@_info_title_en_sanitized_tl}
2094 % 处理后的论文标题。
2095 % \begin{macrocode}
2096 \tl_new:N \l_@@_info_title_sanitized_tl
2097 \tl_new:N \l_@@_info_title_en_sanitized_tl
2098 % \end{macrocode}
2099 % \end{variable}
2100 %
2101 % \begin{macro}[do-not-index={\1, \2}]{\@@_set_title:nn}
2102 % 设置论文标题,并删除其中的 |\\| 和汉字间的空格。
2103 % \begin{macrocode}
2104 \cs_new_protected:Npn \@@_set_title:nn #1#2
2105 {
2106 \tl_gset:cn { g_@@_info_ #1 _tl } { #2 }
2107 \tl_set:cn { l_@@_info_ #1 _sanitized_tl } { #2 }
2108 \tl_replace_all:cnn { l_@@_info_ #1 _sanitized_tl } { \\ } { ~ }
2109 \regex_replace_all:nnc
2110 { \s+ } { \ }
2111 { l_@@_info_ #1 _sanitized_tl }
2112 \regex_replace_all:nnc
2113 { ([\x{4e00}-\x{9fff}]) \s+ ([\x{4e00}-\x{9fff}]) } { \1 \2 }
2114 { l_@@_info_ #1 _sanitized_tl }
2115 }
2116 % \end{macrocode}
2117 % \end{macro}
2118 %
2119 % \begin{macro}{\@@_set_date:n}
2120 % 设置论文提交日期。
2121 % \begin{macrocode}
2122 \cs_new:Npn \@@_set_date:n #1
2123 {
2124 \@@_set_date_aux:w #1 \q_stop
2125 }
2126 \cs_new_protected:Npn \@@_set_date_aux:w #1 - #2 - #3 \q_stop
2127 {
2128 \tl_gset:Nn \g_@@_info_date_tl { {#1} 年 {#2} 月 {#3} 日 }
2129 \tl_gset:Nn \g_@@_info_date_en_tl
2130 { \clist_item:Nn \c_@@_month_clist {#2},~ {#1} }
2131 }
2132 \clist_const:Nn \c_@@_month_clist
2133 {
2134 January, February, March, April, May, June,
2135 July, August, September, October, November, December,
2136 }
2137 % \end{macrocode}
2138 % \end{macro}
2139 %
2140 % 定义 |hust/info| 键值类。
2141 % \begin{macrocode}
2142 \keys_define:nn { hust / info }
2143 {
2144 % \end{macrocode}
2145 %
2146 % \begin{macro}[module=info/]{info/title, info/title*}
2147 % 论文题目。以下带星号的项目均表示相应的英文字段。
2148 % \begin{macrocode}
2149 title .tl_gset:N = \g_@@_info_title_tl,
2150 title* .tl_gset:N = \g_@@_info_title_en_tl,
2151 % title .code:n = { \@@_set_title:nn { title } { #1 } },
2152 % title* .code:n = { \@@_set_title:nn { title_en } { #1 } },
2153 % \end{macrocode}
2154 % \end{macro}
2155 %
2156 % \begin{macro}[module=info/]{info/degree, info/degree*}
2157 % 学位类型(中文)或学科(英文)。
2158 % 中文类型~\key[info]{degree} 分为学术型~\opt{academic},和专业型~\opt{professional};
2159 % 英文学科~\key[info]{degree*}\footnote{为保持命名一致性,学科 degree discipline 在此处仍使用键名 |degree*|} 包括文学~\opt{Arts},理学~\opt{Science},教育学~\opt{Education},工学~\opt{Engineering},法学~\opt{Laws},医学~\opt{Medicine},以及其他~\opt{XXX}。
2160 % \begin{macrocode}
2161 degree .choices:nn =
2162 { academic, professional }
2163 {
2164 \tl_gset_eq:NN \g_@@_info_degree_tl \l_keys_choice_tl
2165 },
2166 degree .default:n = { academic },
2167 degree* .tl_gset:N = \g_@@_info_degree_en_tl,
2168 % \end{macrocode}
2169 % \end{macro}
2170 %
2171 % \begin{macro}[module=info/]{info/author, info/author*}
2172 % 学位申请人姓名。
2173 % \begin{macrocode}
2174 author .tl_gset:N = \g_@@_info_author_tl,
2175 author* .tl_gset:N = \g_@@_info_author_en_tl,
2176 % \end{macrocode}
2177 % \end{macro}
2178 %
2179 % \begin{macro}[module=info/]{info/major, info/major*}
2180 % 专业名称。
2181 % \begin{macrocode}
2182 major .tl_gset:N = \g_@@_info_major_tl,
2183 major* .tl_gset:N = \g_@@_info_major_en_tl,
2184 % \end{macrocode}
2185 % \end{macro}
2186 %
2187 % \begin{macro}[module=info/]{info/supervisor, info/supervisor*}
2188 % 指导老师。
2189 % \begin{macrocode}
2190 supervisor .tl_gset:N = \g_@@_info_supervisor_tl,
2191 supervisor* .tl_gset:N = \g_@@_info_supervisor_en_tl,
2192 % \end{macrocode}
2193 % \end{macro}
2194 %
2195 % \begin{macro}[module=info/]{info/date}
2196 % 论文提交日期。
2197 % \begin{macrocode}
2198 date .code:n = { \@@_set_date:n { #1 } },
2199 % \end{macrocode}
2200 % \end{macro}
2201 %
2202 % \begin{macro}[module=info/]{info/clc}
2203 % 中图分类号。
2204 % \begin{macrocode}
2205 clc .tl_gset:N = \g_@@_info_clc_tl,
2206 % \end{macrocode}
2207 % \end{macro}
2208 %
2209 % \begin{macro}[module=info/]{info/student-id, info/school-id}
2210 % 学号和学校代码。
2211 % \begin{macrocode}
2212 student-id .tl_gset:N = \g_@@_info_student_id_tl,
2213 school-id .tl_gset:N = \g_@@_info_school_id_tl,
2214 % \end{macrocode}
2215 % \end{macro}
2216 %
2217 % \begin{macro}[module=info/]{info/secret}
2218 % 密级。
2219 % \begin{macrocode}
2220 secret .tl_gset:N = \g_@@_info_secret_tl,
2221 % \end{macrocode}
2222 % \end{macro}
2223 %
2224 % \begin{macro}[module=info/]{info/committee}
2225 % 答辩委员会成员列表。
2226 % \begin{macrocode}
2227 committee .code:n =
2228 {
2229 \seq_gset_from_clist:Nn \g_@@_info_committee_seq { #1 }
2230 },
2231 % \end{macrocode}
2232 % \end{macro}
2233 %
2234 % \begin{macrocode}
2235 }
2236 % \end{macrocode}
2237 %
2238 % \subsubsection{定义内部函数}
2239 %
2240 % \begin{macro}{\@@_spread_box:nn, \@@_spread_box:no}
2241 % 分散对齐的水平盒子。
2242 % \begin{arguments}
2243 % \item 宽度
2244 % \item 内容
2245 % \end{arguments}
2246 % 利用 \cs{tl_map_inline:nn} 在字符间插入 \tn{hfil};紧随其后的 \tn{unskip}
2247 % 将会去掉最后一个 \tn{hfil}。见 \url{https://tex.stackexchange.com/q/169689}。
2248 % \begin{macrocode}
2249 \cs_new_protected:Npn \@@_spread_box:nn #1#2
2250 {
2251 \mode_leave_vertical:
2252 \hbox_to_wd:nn {#1} { \tl_map_inline:nn {#2} { ##1 \hfil } \unskip }
2253 }
2254 \cs_generate_variant:Nn \@@_spread_box:nn { no }
2255 % \end{macrocode}
2256 % \end{macro}
2257 %
2258 % \begin{macro}{\@@_center_box:nn, \@@_center_box:Vn}
2259 % 居中对齐的水平盒子。
2260 % \begin{macrocode}
2261 \cs_new_protected:Npn \@@_center_box:nn #1#2
2262 {
2263 \mode_leave_vertical:
2264 \hbox_to_wd:nn {#1} { \tex_hfil:D #2 \tex_hfil:D }
2265 }
2266 \cs_generate_variant:Nn \@@_center_box:nn { Vn }
2267 % \end{macrocode}
2268 % \end{macro}
2269 %
2270 % \begin{macro}{\@@_fixed_width_box:nn}
2271 % 限宽盒子(允许换行)。
2272 % \begin{macrocode}
2273 \cs_new:Npn \@@_fixed_width_box:nn #1#2
2274 { \parbox {#1} {#2} }
2275 % \end{macrocode}
2276 % \end{macro}
2277 %
2278 % \begin{macro}{\@@_fixed_width_center_box:nn}
2279 % 居中对齐的限宽盒子(允许换行)。
2280 % \begin{macrocode}
2281 \cs_new:Npn \@@_fixed_width_center_box:nn #1#2
2282 { \parbox {#1} { \centering #2 } }
2283 % \end{macrocode}
2284 % \end{macro}
2285 %
2286 % \begin{macro}{\@@_get_text_width:Nn, \@@_get_text_width:NV}
2287 % 获取文本宽度,并存入 |dim| 型变量。
2288 % \begin{arguments}
2289 % \item |dim| 型变量
2290 % \item 内容
2291 % \end{arguments}
2292 % \begin{macrocode}
2293 \cs_new:Npn \@@_get_text_width:Nn #1#2
2294 {
2295 \hbox_set:Nn \l_@@_tmpa_box {#2}
2296 \dim_set:Nn #1 { \box_wd:N \l_@@_tmpa_box }
2297 }
2298 \cs_generate_variant:Nn \@@_get_text_width:Nn { NV }
2299 % \end{macrocode}
2300 % \end{macro}
2301 %
2302 % \begin{macro}[deprecated]{\@@_blank_underline:n}
2303 % 下划线占位符。|#1|: 长度。
2304 % \begin{macrocode}
2305 \cs_new:Npn \@@_blank_underline:n #1
2306 { \rule [ -0.5 ex ] {#1} { 0.4 pt } }
2307 % \end{macrocode}
2308 % \end{macro}
2309 %
2310 % \subsection{封面模板}
2311 %
2312 % \begin{macro}[int, module=component/]{component/}
2313 % 封面组件。
2314 % \begin{arguments}
2315 % \item[\opt{content}] 组件主体内容
2316 % \item[\opt{format}] 组件字体/段落格式
2317 % \item[\opt{height}] 组件固定高度,不设置则自动计算。主要用于行数不确定,需要固定高度的情况
2318 % \item[\opt{top-lines}] 顶部空出的行数,按照设定的段落格式计算
2319 % \item[\opt{top-skip}] 顶部间距(建议优先配置底部间距,顶部间距仅在特殊情况使用)
2320 % \item[\opt{bottom-skip}] 底部间距
2321 % \item[\opt{bottom-lines}] 底部空出的行数,按照设定的段落格式计算
2322 % \item[\opt{align}] 对齐方式,可选值为靠左对齐~\opt{left},靠右对齐~\opt{right},居中对齐~\opt{center},以及两端对齐~\opt{justify}。默认为居中对齐
2323 % \end{arguments}
2324 % \begin{macrocode}
2325 \NewTemplateType { hust / component } { 0 }
2326 \DeclareTemplateInterface { hust / component } { plain } { 0 }
2327 {
2328 content : tokenlist = \c_empty_tl,
2329 format : tokenlist = \c_empty_tl,
2330 width: skip = \c_zero_skip,
2331 height: skip = \c_zero_skip,
2332 top-lines : integer = \c_zero_int,
2333 top-skip : skip = \c_zero_skip,
2334 bottom-skip : skip = \c_zero_skip,
2335 bottom-lines : integer = \c_zero_int,
2336 align : choice { left, right, center, justify } = center,
2337 }
2338 \DeclareTemplateCode { hust / component } { plain } { 0 }
2339 {
2340 content = \l_@@_component_content_tl,
2341 format = \l_@@_component_format_tl,
2342 width = \l_@@_component_width_skip,
2343 height = \l_@@_component_height_skip,
2344 top-lines = \l_@@_component_top_lines_int,
2345 top-skip = \l_@@_component_top_skip,
2346 bottom-skip = \l_@@_component_bottom_skip,
2347 bottom-lines = \l_@@_component_bottom_lines_int,
2348 align =
2349 {
2350 left =
2351 \cs_set_eq:NN \l_@@_component_align: \raggedright,
2352 right =
2353 \cs_set_eq:NN \l_@@_component_align: \raggedleft,
2354 center =
2355 \cs_set_eq:NN \l_@@_component_align: \centering,
2356 justify =
2357 \cs_set_eq:NN \l_@@_component_align: \prg_do_nothing:,
2358 }
2359 }
2360 {
2361 \AssignTemplateKeys
2362 \l_@@_component_format_tl
2363 \int_step_inline:nn { \l_@@_component_top_lines_int }
2364 {
2365 \mode_leave_vertical:
2366 \tex_par:D
2367 }
2368 \dim_compare:nNnTF { \l_@@_component_height_skip } > { \c_zero_skip }
2369 {
2370 \box_clear_new:N \l_@@_component_box
2371 \vbox_set_to_ht:Nnn \l_@@_component_box { \l_@@_component_height_skip }
2372 {
2373 \skip_vertical:N \l_@@_component_top_skip
2374 \l_@@_component_align:
2375 \l_@@_component_content_tl
2376 \tex_vfill:D
2377 }
2378 \box_use:N \l_@@_component_box
2379 }
2380 {
2381 \skip_vertical:N \l_@@_component_top_skip
2382 \l_@@_component_align:
2383 \l_@@_component_content_tl
2384 \tex_par:D
2385 }
2386 \int_step_inline:nn { \l_@@_component_bottom_lines_int }
2387 {
2388 \mode_leave_vertical:
2389 \tex_par:D
2390 }
2391 \skip_vertical:N \l_@@_component_bottom_skip
2392 \skip_vertical:N \c_zero_skip
2393 }
2394 % \end{macrocode}
2395 % \end{macro}
2396 %
2397 % \begin{macro}[int, module=hust/page]{page/}
2398 % 页面模板。
2399 % \begin{arguments}
2400 % \item[\opt{prefix}] 组件共用前缀
2401 % \item[\opt{components}] 组件列表
2402 % \item[\opt{style}] 页面样式 (可使用 \tn{thispagestyle} 配置)
2403 % \item[\opt{format}] 页面字体/段落格式
2404 % \item[\opt{top-skip}] 顶部间距
2405 % \end{arguments}
2406 % \begin{macrocode}
2407 \NewTemplateType { hust / page } { 0 }
2408 \DeclareTemplateInterface { hust / page } { title } { 0 }
2409 {
2410 prefix : tokenlist,
2411 components : commalist,
2412 style : tokenlist = empty,
2413 format : tokenlist = \linespread { } \selectfont,
2414 top-skip : skip = \c_zero_skip,
2415 }
2416 \DeclareTemplateCode { hust / page } { title } { 0 }
2417 {
2418 prefix = \l_@@_page_prefix_tl,
2419 components = \l_@@_page_components_clist,
2420 style = \l_@@_page_style_tl,
2421 format = \l_@@_page_format_tl,
2422 top-skip = \l_@@_page_top_skip,
2423 }
2424 {
2425 \AssignTemplateKeys
2426 \skip_vertical:N \l_@@_page_top_skip
2427 \group_begin:
2428 \exp_args:No \thispagestyle { \l_@@_page_style_tl }
2429 \l_@@_page_format_tl
2430 \clist_map_inline:Nn \l_@@_page_components_clist
2431 {
2432 \group_begin:
2433 \UseInstance { hust / component } { \l_@@_page_prefix_tl / ##1 }
2434 \group_end:
2435 }
2436 \group_end:
2437 \clearpage
2438 }
2439 % \end{macrocode}
2440 % \end{macro}
2441 %
2442 % \begin{macro}{
2443 % \@@_declare_component_instance:nnn,
2444 % \@@_declare_page_instance:nn,
2445 % }
2446 % 声明模板实例的辅助函数。
2447 % \begin{macrocode}
2448 \cs_new_protected:Npn \@@_declare_component_instance:nnn #1#2#3
2449 { \DeclareInstance { hust / component } { #1/#2 } { plain } {#3} }
2450 \cs_new_protected:Npn \@@_declare_page_instance:nn #1#2
2451 {
2452 \DeclareInstance { hust / page } {#1} { title }
2453 {
2454 prefix = #1,
2455 #2,
2456 }
2457 }
2458 % \end{macrocode}
2459 % \end{macro}
2460 %
2461 % \subsection{封面组件}
2462 %
2463 % \subsubsection{中文封面}
2464 %
2465 % \begin{macro}[int, module=component/]{title zh/identifiers}
2466 % 分类号,学号,学校代码,密级。
2467 % \begin{macrocode}
2468 \@@_declare_component_instance:nnn { title zh } { identifiers }
2469 {
2470 content =
2471 {
2472 \@@_title_zh_ids_aux:nn { 6em } { clc } % 3 em
2473 \skip_horizontal:n { \linewidth - 19em }
2474 \@@_title_zh_ids_aux:nn { 8em } { student_id } % 4 em
2475 \tex_par:D
2476 \@@_title_zh_ids_aux:nn { 5em } { school_id } % 4 em
2477 \skip_horizontal:n { \linewidth - 19em }
2478 \@@_title_zh_ids_aux:nn { 8em } { secret } % 4 em
2479 },
2480 format =
2481 {
2482 \zihao{-4} \bfseries \rmfamily \songti
2483 \@@_line_spread:n { 1.5 }
2484 },
2485 bottom-skip = 2 cm,
2486 }
2487 \cs_new:Npn \@@_title_zh_ids_aux:nn #1#2
2488 {
2489 \tl_use:c { c_@@_name_ #2 _tl }
2490 \@@_ul_to_wd:nnn { 1 pt } { #1 }
2491 { \tl_use:c { g_@@_info_ #2 _tl } }
2492 }
2493 % \end{macrocode}
2494 % \end{macro}
2495 %
2496 % \begin{macro}[int, module=hust/component/]{title zh/logo}
2497 % 校名图片。
2498 % \begin{macrocode}
2499 \@@_declare_component_instance:nnn { title zh } { logo }
2500 {
2501 content =
2502 {
2503 \mode_leave_vertical:
2504 \hustvi [ height = 1.4 cm, temp = black, ] { name }
2505 },
2506 bottom-skip = 0.5 cm,
2507 }
2508 % \end{macrocode}
2509 % \end{macro}
2510 %
2511 % \begin{macro}[int, module=hust/component/]{title zh/type}
2512 % 学位级别。
2513 % \begin{macrocode}
2514 \__ctex_save_font_size:nn { a } { 45 bp } % 大初号
2515 \@@_declare_component_instance:nnn { title zh } { type }
2516 {
2517 content = { \c_@@_name_type_zh_tl },
2518 format = { \zihao { a } \bfseries \songti \ziju { 0.1 } },
2519 bottom-skip = 0.5 cm,
2520 }
2521 % \end{macrocode}
2522 % \end{macro}
2523 %
2524 % \begin{macro}[int, module=hust/component/]{title zh/degree}
2525 % 学位类型。
2526 % \begin{macrocode}
2527 \@@_declare_component_instance:nnn { title zh } { degree }
2528 {
2529 content =
2530 {
2531 (
2532 \c_@@_name_academic_zh_tl
2533 \tl_if_eq:NnTF \g_@@_info_degree_tl { academic }
2534 { \c_@@_checkbox_tl }
2535 { \c_@@_emptybox_tl }
2536 \skip_horizontal:n { 2.5 em }
2537 \c_@@_name_professional_zh_tl
2538 \tl_if_eq:NnTF \g_@@_info_degree_tl { professional }
2539 { \c_@@_checkbox_tl }
2540 { \c_@@_emptybox_tl }
2541 )
2542 },
2543 format = { \zihao { -3 } \c_@@_name_degree_font_tl },
2544 bottom-skip = 1.5 cm,
2545 }
2546 % \end{macrocode}
2547 % \end{macro}
2548 %
2549 % \begin{macro}[int, module=hust/component/]{title zh/title}
2550 % 论文题目。
2551 % \begin{macrocode}
2552 \@@_declare_component_instance:nnn { title zh } { title }
2553 {
2554 content = { \g_@@_info_title_tl },
2555 format =
2556 {
2557 \zihao { 1 } \bfseries \songti
2558 \@@_line_spread:n { 1.5 }
2559 },
2560 height = 4.8 cm,
2561 bottom-skip = 1 cm,
2562 }
2563 % \end{macrocode}
2564 % \end{macro}
2565 %
2566 % \begin{macro}[int, module=hust/component/]{title zh/info}
2567 % 信息表格。
2568 % \begin{macrocode}
2569 \@@_declare_component_instance:nnn { title zh } { info }
2570 {
2571 content =
2572 {
2573 \tl_set:Nn \arraystretch { 2 }
2574 \begin{tabular}{p{5em}@{:\hspace{1em}}l}
2575 \c_@@_name_author_zh_tl & \g_@@_info_author_tl \\
2576 \c_@@_name_major_zh_tl & \g_@@_info_major_tl \\
2577 \c_@@_name_supervisor_zh_tl & \g_@@_info_supervisor_tl \\
2578 \c_@@_name_date_tl & \g_@@_info_date_tl \\
2579 \end{tabular}
2580 },
2581 format = { \zihao { -3 } \bfseries \rmfamily \songti },
2582 bottom-skip = 30 pt,
2583 }
2584 % \end{macrocode}
2585 % \end{macro}
2586 %
2587 % \subsubsection{英文封面}
2588 %
2589 % \begin{macro}[int, module=hust/component/]{title en/degree}
2590 % 学位级别和学科。
2591 % \begin{macrocode}
2592 \@@_declare_component_instance:nnn { title en } { degree }
2593 {
2594 content =
2595 {
2596 \c_@@_name_type_en_tl
2597 \tl_if_eq:NnTF \g_@@_info_degree_tl { academic }
2598 { \c_@@_name_academic_en_tl }
2599 { \c_@@_name_professional_en_tl }
2600 \g_@@_info_degree_en_tl
2601 },
2602 format =
2603 {
2604 \zihao { -3 } \bfseries \rmfamily
2605 \@@_line_spread:n { 1.5 }
2606 },
2607 bottom-skip = 5.5 cm,
2608 }
2609 % \end{macrocode}
2610 % \end{macro}
2611 %
2612 % \begin{macro}[int, module=hust/component/]{title en/title}
2613 % 论文题目。
2614 % \begin{macrocode}
2615 \@@_declare_component_instance:nnn { title en } { title }
2616 {
2617 content = { \g_@@_info_title_en_tl },
2618 format =
2619 {
2620 \zihao { -2 } \bfseries \rmfamily
2621 \@@_line_spread:n { 1.5 }
2622 },
2623 height = 3 cm,
2624 bottom-skip = 3 cm,
2625 }
2626 % \end{macrocode}
2627 % \end{macro}
2628 %
2629 % \begin{macro}[int, module=hust/component/]{title en/info}
2630 % 信息表格。
2631 % \begin{macrocode}
2632 \@@_declare_component_instance:nnn { title en } { info }
2633 {
2634 content =
2635 {
2636 \begin{tabular}{l@{\hspace{0.5em}:\hspace{0.5em}}l}
2637 \c_@@_name_author_en_tl & \g_@@_info_author_en_tl \\
2638 \c_@@_name_major_en_tl & \g_@@_info_major_en_tl \\
2639 \c_@@_name_supervisor_en_tl & \g_@@_info_supervisor_en_tl \\
2640 \end{tabular}
2641 },
2642 format =
2643 {
2644 \zihao { -3 } \bfseries \rmfamily
2645 \@@_line_spread:n { 1.5 }
2646 },
2647 bottom-skip = 4 cm,
2648 }
2649 % \end{macrocode}
2650 % \end{macro}
2651 %
2652 % \begin{macro}[int, module=hust/component/]{title en/address}
2653 % 学校名称和地址。
2654 % \begin{macrocode}
2655 \@@_declare_component_instance:nnn { title en } { address }
2656 {
2657 content = { \c_@@_address_tl },
2658 format =
2659 {
2660 \zihao { -3 } \bfseries \rmfamily
2661 \@@_line_spread:n { 1.5 }
2662 },
2663 }
2664 % \end{macrocode}
2665 % \end{macro}
2666 %
2667 % \begin{macro}[int, module=hust/component/]{title en/date}
2668 % \begin{macrocode}
2669 \@@_declare_component_instance:nnn { title en } { date }
2670 {
2671 content = { \tl_use:N \g_@@_info_date_en_tl },
2672 format =
2673 {
2674 \zihao { -3 } \bfseries \rmfamily
2675 \@@_line_spread:n { 1.5 }
2676 },
2677 }
2678 % \end{macrocode}
2679 % \end{macro}
2680 %
2681 % \subsubsection{答辩委员会页}
2682 %
2683 % \begin{macro}[int, module=hust/component/]{committee/title}
2684 % 答辩委员会标题。
2685 % \begin{macrocode}
2686 \@@_declare_component_instance:nnn { committee } { title }
2687 {
2688 content = { \c_@@_name_committee_tl },
2689 format =
2690 {
2691 \zihao { 3 } \bfseries \sffamily
2692 \@@_line_spread:n { 1.5 }
2693 },
2694 bottom-lines = 1,
2695 }
2696 \tl_const:Nn \c_@@_name_committee_tl { 答辩委员会 }
2697 % \end{macrocode}
2698 % \end{macro}
2699 %
2700 % \begin{macro}[int, module=hust/component/]{committee/members}
2701 % 答辩委员会成员列表。
2702 % \begin{macrocode}
2703 \@@_declare_component_instance:nnn { committee } { members }
2704 {
2705 content =
2706 {
2707 \tl_set:Nn \arraystretch { 1.5 }
2708 \begin{tabular}
2709 { |c|c|c|c| }
2710 \hline
2711 \c_@@_committee_header_tl \\
2712 \hline
2713 \int_const:Nn \l_@@_info_committee_count_int
2714 { \seq_count:N \g_@@_info_committee_seq }
2715 \seq_map_indexed_inline:Nn \g_@@_info_committee_seq
2716 {
2717 \int_case:nnF { #1 }
2718 {
2719 { 1 }
2720 {
2721 \clist_item:Nn \c_@@_committee_role_clist { 1 }
2722 & #2 \\ \hline
2723 }
2724 { 2 }
2725 {
2726 \multirow
2727 { \int_eval:n { \l_@@_info_committee_count_int - 1 } }
2728 { * }
2729 { \clist_item:Nn \c_@@_committee_role_clist { 2 } }
2730 & #2 \\ \cline{2-4}
2731 }
2732 { \l_@@_info_committee_count_int }
2733 { & #2 }
2734 }
2735 { & #2 \\ \cline{2-4} }
2736 }
2737 \\ \hline
2738 \end{tabular}
2739 },
2740 format =
2741 {
2742 \zihao { 4 } \sffamily
2743 \@@_line_spread:n { 1.5 }
2744 },
2745 top-lines = 1,
2746 }
2747 \tl_const:Nn \c_@@_committee_header_tl
2748 { \makebox[3em]{} & \makebox[4em][c]{姓名} & \makebox[4em][c]{职称} & \makebox[12em][c]{单位} }
2749 \clist_const:Nn \c_@@_committee_role_clist
2750 { 主席, 委员, }
2751 \tl_new:N \l_@@_committee_member_tl
2752 % \end{macrocode}
2753 % \end{macro}
2754 %
2755 % \subsubsection{声明页}
2756 %
2757 % \begin{macro}[int, module=hust/component/]{decl/orig title}
2758 % 独创性声明标题。
2759 % \begin{macrocode}
2760 \@@_declare_component_instance:nnn { decl } { orig title }
2761 {
2762 content = { \c_@@_orig_decl_title_tl },
2763 format =
2764 {
2765 \zihao { 3 } \bfseries \heiti
2766 },
2767 bottom-lines = 1,
2768 }
2769 % \end{macrocode}
2770 % \end{macro}
2771 %
2772 % \begin{macro}[int, module=hust/component/]{decl/orig text}
2773 % 独创性声明正文。
2774 % \begin{macrocode}
2775 \@@_declare_component_instance:nnn { decl } { orig text }
2776 {
2777 content = { \c_@@_orig_decl_text_tl },
2778 align = justify,
2779 bottom-lines = 1,
2780 }
2781 % \end{macrocode}
2782 % \end{macro}
2783 %
2784 % \begin{macro}[int, module=hust/component/]{decl/orig sign}
2785 % 独创性声明签名。
2786 % \begin{macrocode}
2787 \@@_declare_component_instance:nnn { decl } { orig sign }
2788 {
2789 content =
2790 {
2791 \clist_map_inline:Nn \c_@@_orig_decl_sign_clist
2792 {
2793 #1 \\
2794 }
2795 },
2796 align = right,
2797 bottom-lines = 3,
2798 }
2799 % \end{macrocode}
2800 % \end{macro}
2801 %
2802 % \begin{macro}[int, module=hust/component/]{decl/auth title}
2803 % 学位论文版权使用授权书标题。
2804 % \begin{macrocode}
2805 \@@_declare_component_instance:nnn { decl } { auth title }
2806 {
2807 content = { \c_@@_auth_decl_title_tl },
2808 format =
2809 {
2810 \zihao { 3 } \bfseries \heiti
2811 },
2812 top-lines = 1,
2813 bottom-lines = 1,
2814 }
2815 % \end{macrocode}
2816 % \end{macro}
2817 %
2818 % \begin{macro}[int, module=hust/component/]{decl/auth text}
2819 % 学位论文版权使用授权书正文。
2820 % \begin{macrocode}
2821 \@@_declare_component_instance:nnn { decl } { auth text }
2822 {
2823 content = { \c_@@_auth_decl_text_tl },
2824 align = justify,
2825 bottom-skip = 0.5 cm,
2826 }
2827 % \end{macrocode}
2828 % \end{macro}
2829 %
2830 % \begin{macro}[int, module=hust/component/]{decl/auth secr}
2831 % 学位论文保密使用保密选项。
2832 % \begin{macrocode}
2833 \@@_declare_component_instance:nnn { decl } { auth secr }
2834 {
2835 content =
2836 {
2837 \mode_leave_vertical:
2838 \hbox_overlap_right:n
2839 { \clist_item:Nn \c_@@_auth_decl_secr_clist { 1 } }
2840 \skip_vertical:n { -1.2 cm }
2841 \skip_horizontal:n { 6 em }
2842 \clist_item:Nn \c_@@_auth_decl_secr_clist { 2 }
2843 \tex_par:D
2844 \skip_horizontal:n { 6 em }
2845 \clist_item:Nn \c_@@_auth_decl_secr_clist { 3 }
2846 \tex_par:D
2847 \clist_item:Nn \c_@@_auth_decl_secr_clist { 4 }
2848 },
2849 align = justify,
2850 bottom-lines = 1,
2851 }
2852 % \end{macrocode}
2853 % \end{macro}
2854 %
2855 % \begin{macro}[int, module=hust/component/]{decl/auth sign}
2856 % \begin{macrocode}
2857 \@@_declare_component_instance:nnn { decl } { auth sign }
2858 {
2859 content =
2860 {
2861 \clist_map_inline:Nn \c_@@_auth_decl_sign_clist
2862 {
2863 #1
2864 \tex_par:D
2865 }
2866 },
2867 align = justify,
2868 }
2869 % \end{macrocode}
2870 % \end{macro}
2871 %
2872 % \subsection{绘制封面}
2873 %
2874 % \begin{macro}{\makezhtitle}
2875 % 中文标题页。
2876 % \begin{macrocode}
2877 \@@_declare_page_instance:nn { title zh }
2878 {
2879 components = { identifiers, logo, type, degree, title, info, },
2880 }
2881 \DeclareDocumentCommand \makezhtitle { }
2882 {
2883 \UseInstance { hust / page } { title zh }
2884 }
2885 % \end{macrocode}
2886 % \end{macro}
2887 %
2888
2889 % \begin{macro}{\makeentitle}
2890 % 英文标题页。
2891 % \begin{macrocode}
2892 \@@_declare_page_instance:nn { title en }
2893 {
2894 components = { degree, title, info, address, date, },
2895 }
2896 \DeclareDocumentCommand \makeentitle { }
2897 {
2898 \UseInstance { hust / page } { title en }
2899 }
2900 % \end{macrocode}
2901 % \end{macro}
2902 %
2903 % \begin{macro}{\makecommittee}
2904 % 答辩委员会页。
2905 % \begin{macrocode}
2906 \@@_declare_page_instance:nn { committee }
2907 {
2908 components = { title, members, },
2909 }
2910 \DeclareDocumentCommand \makecommittee { }
2911 {
2912 \UseInstance { hust / page } { committee }
2913 }
2914 % \end{macrocode}
2915 % \end{macro}
2916 %
2917 % \begin{macro}{\makedecl}
2918 % 声明页。
2919 % \begin{macrocode}
2920 \@@_declare_page_instance:nn { decl }
2921 {
2922 components =
2923 {
2924 orig title, orig text, orig sign,
2925 auth title, auth text, auth secr, auth sign,
2926 },
2927 format =
2928 {
2929 \zihao { -4 } \rmfamily
2930 \@@_line_spread:n { 1.5 }
2931 }
2932 }
2933 \DeclareDocumentCommand \makedecl { }
2934 {
2935 \UseInstance { hust / page } { decl }
2936 }
2937 % \end{macrocode}
2938 % \end{macro}
2939 %
2940 % \begin{macro}{\maketitle}
2941 % 封面。
2942 % \begin{macrocode}
2943 \DeclareDocumentCommand \maketitle { }
2944 {
2945 \makezhtitle
2946 \tl_if_eq:NnT \g_@@_degree_type_tl { doctor }
2947 { \makecommittee }
2948 \makeentitle
2949 \makedecl
2950 }
2951 % \end{macrocode}
2952 % \end{macro}
2953 %
2954 %
2955 % \section{前文样式}
2956 %
2957 % 定义从摘要到目录的样式,即有页眉页脚,含有大写罗马数字页码页的样式。
2958 %
2959 % \begin{macro}{\frontmatter}
2960 % \begin{macrocode}
2961 \@@_appto_cmd:Nn \frontmatter
2962 {
2963 \pagestyle { fancy }
2964 \pagenumbering { Roman }
2965 \@@_toc_chapter_frontmatter:
2966 }
2967 % \end{macrocode}
2968 % \end{macro}
2969 %
2970 % \subsection{摘要样式}
2971 %
2972 % \begin{environment}{abstract, abstract*}
2973 % 摘要环境。
2974 % \begin{macrocode}
2975 \NewDocumentEnvironment { abstract } { }
2976 {
2977 \chapter**{\c_@@_name_abstract_zh_tl}
2978 }
2979 { }
2980 \NewDocumentEnvironment { abstract* } { }
2981 {
2982 \chapter**{\c_@@_name_abstract_en_tl}
2983 }
2984 { }
2985 % \end{macrocode}
2986 % \end{environment}
2987 %
2988 % \begin{macro}{\keywords, \keywords*}
2989 % 关键词命令。
2990 % \begin{macrocode}
2991 \NewDocumentCommand \keywords { s }
2992 {
2993 \IfBooleanTF { #1 }
2994 { \@@_keywords:nw { en } }
2995 { \@@_keywords:nw { zh } }
2996 }
2997 \cs_new_nopar:Npn \@@_keywords:nw #1 #2
2998 {
2999 \zihao{-4} \rmfamily
3000 \tex_par:D
3001 \skip_horizontal:n \c_zero_skip
3002 \tex_par:D
3003 \tex_noindent:D
3004 \group_begin:
3005 \bfseries \heiti
3006 \tl_use:c { c_@@_name_keywords_ #1 _tl }
3007 \group_end:
3008 \c_space_tl
3009 #2
3010 }
3011 % \end{macrocode}
3012 % \end{macro}
3013 %
3014 % \subsection{目录样式}
3015 %
3016 % \begin{macrocode}
3017 \tl_set:Nn \contentsname { 目\hspace{1em}录 }
3018 % \end{macrocode}
3019 %
3020 % \begin{macro}[module=style/]{style/toc-depth}
3021 % \changes{v2.0.1}{2025-10-31}{支持设置目录章节显示深度}
3022 % 设置目录章节显示深度。
3023 % \begin{macrocode}
3024 \keys_define:nn { hust / style }
3025 {
3026 toc-depth .choices:nn = { section, subsection }
3027 {
3028 \keys_set:nn { ctex } { tocdepth = \tl_use:N \l_keys_choice_tl }
3029 },
3030 toc-depth .initial:n = section,
3031 }
3032 % \end{macrocode}
3033 % \end{macro}
3034 %
3035 % 设置目录项右边距。
3036 % \begin{macrocode}
3037 \contentsmargin { 0 pt }
3038 % \end{macrocode}
3039 %
3040 % \begin{macro}{\@@_toc_format:nnnn}
3041 % 设置目录项格式。
3042 % \begin{arguments}
3043 % \item 章节类型
3044 % \item 编号与章节名称间距
3045 % \item 章节名称样式
3046 % \item 章节页码格式(|\thecontentspage|表示页码)
3047 % \end{arguments}
3048 % \begin{macrocode}
3049 \cs_new_protected:Npn \@@_toc_format:nnnn #1#2#3#4
3050 {
3051 \titlecontents
3052 { #1 }
3053 [ 0 pt ]
3054 { #3 }
3055 { \thecontentslabel \hspace{#2} #3 }
3056 { #3 }
3057 { #4 }
3058 }
3059 % \end{macrocode}
3060 % \end{macro}
3061 %
3062 % \begin{macro}{\ddotfill}
3063 % 实现更密的虚线。该命令仅可使用 \LaTeXe 命令实现。
3064 % \begin{macrocode}
3065 \cs_new:Npn \ddotfill
3066 {
3067 \leavevmode \leaders \hbox to .22em {\hss .\hss } \hfill \kern 0pt
3068 }
3069 % \end{macrocode}
3070 % \end{macro}
3071 %
3072 % \begin{macro}{
3073 % \@@_toc_chapter_frontmatter:
3074 % \@@_toc_chapter_mainmatter:
3075 % \@@_toc_chapter_backmatter:
3076 % }
3077 % 设置章的三种样式,分别是在前文部分有虚线,不带括号页码的格式;
3078 % 正文无虚线,带括号页码的格式;
3079 % 以及附录部分有虚线,带括号页码的格式。
3080 % \begin{macrocode}
3081 \cs_new_protected:Npn \@@_toc_chapter_frontmatter:
3082 {
3083 \@@_toc_format:nnnn
3084 { chapter }
3085 { 1 em}
3086 { \zihao{4} \bfseries \rmfamily \heiti }
3087 { \mdseries \ddotfill \thecontentspage }
3088 }
3089 \cs_new_protected:Npn \@@_toc_chapter_mainmatter:
3090 {
3091 \@@_toc_format:nnnn
3092 { chapter }
3093 { 1 em }
3094 { \zihao{4} \bfseries \rmfamily \heiti }
3095 { \mdseries \hfill (\thecontentspage) }
3096 }
3097 \cs_new_protected:Npn \@@_toc_chapter_backmatter:
3098 {
3099 \@@_toc_format:nnnn
3100 { chapter }
3101 { 1 em }
3102 { \zihao{4} \bfseries \rmfamily \heiti }
3103 { \mdseries \ddotfill (\thecontentspage) }
3104 }
3105 % \end{macrocode}
3106 % \end{macro}
3107 %
3108 % 设置节的样式。
3109 % \begin{macrocode}
3110 \@@_toc_format:nnnn
3111 { section }
3112 { 2 em }
3113 { \zihao{4} \rmfamily }
3114 { \ddotfill (\thecontentspage) }
3115 \@@_toc_format:nnnn
3116 { subsection }
3117 { 2 em }
3118 { \zihao{4} \rmfamily }
3119 { \ddotfill (\thecontentspage) }
3120 % \end{macrocode}
3121 %
3122 % \section{正文样式}
3123 %
3124 % \begin{macrocode}
3125 \@@_appto_cmd:Nn \mainmatter
3126 {
3127 \pagestyle { fancy }
3128 \pagenumbering { arabic }
3129 \@@_toc_chapter_mainmatter:
3130 }
3131 % \end{macrocode}
3132 %
3133 % \subsection{章节样式}
3134 %
3135 % \begin{macrocode}
3136 \keys_set:nn { ctex }
3137 {
3138 % \end{macrocode}
3139 % 设置章(chapter)、节(section)与小节(sub-section)标题样式。
3140
3141 % \begin{macrocode}
3142 chapter =
3143 {
3144 format = \zihao{3} \bfseries \rmfamily \heiti \centering \linespread{1.5},
3145 name = {},
3146 beforeskip = 15.5 bp,
3147 afterskip = 14 bp + \CTEX@chapter@lofskip,
3148 number = \arabic{ chapter },
3149 pagestyle = fancy,
3150 fixskip = true,
3151 },
3152 section =
3153 {
3154 format = \zihao{4} \bfseries \rmfamily \heiti \raggedright,
3155 numberformat = \rmfamily,
3156 beforeskip = 10 bp,
3157 afterskip = 7 bp,
3158 },
3159 subsection =
3160 {
3161 format = \zihao{-4} \bfseries \rmfamily \heiti \raggedright,
3162 numberformat = \rmfamily,
3163 beforeskip = 7 bp,
3164 afterskip = 4 bp,
3165 }
3166 }
3167 % \end{macrocode}
3168 %
3169 % \begin{macro}{\chapter, \chapter*, \chapter**}
3170 % 对带有星号的章节指令补丁,使得其能够在目录中显示。
3171 % \begin{macrocode}
3172 \NewCommandCopy \@@_chapter:w \chapter
3173 \RenewDocumentCommand \chapter { s s o m }
3174 {
3175 \IfNoValueTF{#3}
3176 {
3177 \IfBooleanTF{#1}
3178 {
3179 \@@_chapter:w*{#4}
3180 \IfBooleanT{#2}
3181 { \CTEX@addtocline{chapter}{#4} }
3182 }
3183 { \@@_chapter:w{#4} }
3184 }
3185 {
3186 \IfBooleanTF{#1}
3187 {
3188 \@@_chapter:w*{#4}
3189 \IfBooleanT{#2}
3190 { \CTEX@addtocline{chapter}{#3} }
3191 }
3192 { \@@_chapter:w[#3]{#4} }
3193
3194 }
3195 }
3196 % \end{macrocode}
3197 % \end{macro}
3198 %
3199 % \section{后文样式}
3200 %
3201 % \begin{macro}{\backmatter}
3202 % \begin{macrocode}
3203 \@@_appto_cmd:Nn \backmatter
3204 {
3205 \@@_toc_chapter_backmatter:
3206 }
3207 % \end{macrocode}
3208 % \end{macro}
3209 %
3210 %
3211 % \subsection{致谢页}
3212 %
3213 % \begin{environment}{acknowledgements}
3214 % \begin{macrocode}
3215 \NewDocumentEnvironment { acknowledgements } { }
3216 {
3217 \chapter**{致\hspace{1em}谢}
3218 }
3219 { }
3220 % \end{macrocode}
3221 % \end{environment}
3222 %
3223 % \subsection{参考文献}
3224 %
3225 % \begin{macro}{\printbibliography}
3226 % 在使用 \tn{printbibliography} 的同时添加目录项。
3227 % \begin{macrocode}
3228 \cs_if_exist:NT \printbibliography
3229 {
3230 \defbibheading{bibliography}[\refname]{%
3231 \chapter**{#1}%
3232 }
3233 }
3234 % \end{macrocode}
3235 % \end{macro}
3236 %
3237 % \section{附录样式}
3238 %
3239 % \begin{macrocode}
3240 \@@_appto_cmd:Nn \appendix
3241 {
3242 }
3243 % \end{macrocode}
3244 %
3245 % \begin{macrocode}
3246 \keys_set:nn { ctex / appendix }
3247 {
3248 number = \arabic{chapter},
3249 }
3250 % \end{macrocode}
3251 %
3252 % \subsection{答辩委员会决议}
3253 %
3254 % \subsection{成果论文对应关系}
3255 %
3256 % \subsection{中英文缩写对照表}
3257 %
3258 % \subsection{程序代码样式}
3259 %
3260 % \section{文档类后处理}
3261 %
3262 % \section{用户接口}
3263 %
3264 % \begin{macro}[module=info/]{info/}
3265 % \begin{macro}[module=style/]{style/}
3266 % 定义元(meta)键值对。
3267 % \begin{macrocode}
3268 \keys_define:nn { hust }
3269 {
3270 info .meta:nn = { hust / info } {#1},
3271 style .meta:nn = { hust / style } {#1}
3272 }
3273 % \end{macrocode}
3274 % \end{macro}
3275 % \end{macro}
3276 %
3277 % 文档类初始设置。学校代码默认为 \opt{10487}。
3278 % \begin{macrocode}
3279 \keys_set_known:nn { hust }
3280 {
3281 info =
3282 {
3283 degree = { academic },
3284 secret = ,
3285 school-id = { 10487 },
3286 date =
3287 {
3288 \int_use:N \c_sys_year_int -
3289 \int_use:N \c_sys_month_int -
3290 \int_use:N \c_sys_day_int
3291 },
3292 anonymous-list =
3293 {
3294 author, student_id, supervisor,
3295 author_en, supervisor_en,
3296 },
3297 committee =
3298 {
3299 { &~&~ },
3300 { &~&~ },
3301 { &~&~ },
3302 { &~&~ },
3303 { &~&~ },
3304 { &~&~ },
3305 { &~&~ },
3306 }
3307 }
3308 }
3309 % \end{macrocode}
3310 %
3311 % \begin{macro}{\hustsetup}
3312 % 用户设置接口。
3313 % \changes{v2.0.0}{2025-02-11}{实现统一用户接口配置选项}
3314 % \begin{macrocode}
3315 \NewDocumentCommand \hustsetup { m }
3316 { \keys_set:nn { hust } {#1} }
3317 % \end{macrocode}
3318 % \end{macro}
3319 %
3320 % \begin{macrocode}
3321 %</class>
3322 % \end{macrocode}
3323 %
3324 % \section{常量定义}
3325 %
3326 % \begin{macrocode}
3327 %<*def-m|def-d>
3328 % \end{macrocode}
3329 %
3330 % \subsection{全局常量}
3331 %
3332 % \begin{variable}{\c_@@_name_school_zh_tl, \c_@@_name_school_en_tl}
3333 % 学校名称。
3334 % \begin{macrocode}
3335 \tl_const:Nn \c_@@_name_school_zh_tl { 华中科技大学 }
3336 \tl_const:Nn \c_@@_name_school_en_tl { Huazhong~ University~ of~ Science~
3337 and~ Technology }
3338 % \end{macrocode}
3339 % \end{variable}
3340 %
3341 % 常用标点符号,见表~\ref{tab:punctuations},定义为 |\c_@@_ #1 _tl|。
3342 % \begin{macrocode}
3343 \clist_map_inline:nn
3344 {
3345 { ideo_comma } { ^^^^3001 },
3346 { ideo_full_stop } { ^^^^3002 },
3347 { fwid_comma } { ^^^^ff0c },
3348 { fwid_full_stop } { ^^^^ff0e },
3349 { fwid_colon } { ^^^^ff1a },
3350 { fwid_semicolon } { ^^^^ff1b },
3351 { fwid_left_paren } { ^^^^ff08 },
3352 { fwid_right_paren } { ^^^^ff09 }
3353 }
3354 { \@@_define_punct:nn #1 }
3355 % \end{macrocode}
3356 %
3357 % \begin{table}[ht]
3358 % \caption{常用标点符号}
3359 % \label{tab:punctuations}
3360 % \centering
3361 % \begin{tabular}{cccc}
3362 % \toprule
3363 % \textbf{中文名称} &
3364 % \textbf{英文名称} &
3365 % \textbf{符号} &
3366 % \textbf{Unicode 码位} \\
3367 % \midrule
3368 % 中文顿号 & Ideographic comma & ^^^^3001 & U+3001 \\
3369 % 中文句号 & Ideographic full stop & ^^^^3002 & U+3002 \\
3370 % 中文逗号 & Fullwidth comma & ^^^^ff0c & U+FF0C \\
3371 % 全角西文句点 & Fullwidth full stop & ^^^^ff0e & U+FF0E \\
3372 % 中文冒号 & Fullwidth colon & ^^^^ff1a & U+FF1A \\
3373 % 中文分号 & Fullwidth semicolon & ^^^^ff1b & U+FF1B \\
3374 % 中文左圆括号 & Fullwidth left parenthesis & ^^^^ff08 & U+FF08 \\
3375 % 中文右圆括号 & Fullwidth right parenthesis & ^^^^ff09 & U+FF09 \\
3376 % \bottomrule
3377 % \end{tabular}
3378 % \end{table}
3379 %
3380 % \begin{variable}{\c_@@_line_spread_fp}
3381 % 设置行距倍数1.5倍。
3382 % \begin{macrocode}
3383 \fp_const:Nn \c_@@_line_spread_fp { 1.5 }
3384 % \end{macrocode}
3385 % \end{variable}
3386 %
3387 % \begin{variable}{\c_@@_emptybox_tl, \c_@@_checkbox_tl}
3388 % \begin{macrocode}
3389 \tl_const:Nn \c_@@_emptybox_tl { \usym{2610} }
3390 \tl_const:Nn \c_@@_checkbox_tl { \usym{2611} }
3391 % \end{macrocode}
3392 % \end{variable}
3393 %
3394 % \subsection{封面页常量}
3395 % \begin{variable}{
3396 % \c_@@_name_degree_font_tl,
3397 % \c_@@_name_professional_tl,
3398 % \c_@@_name_date_tl,
3399 % \c_@@_name_clc_tl,
3400 % \c_@@_name_student_id_tl,
3401 % \c_@@_name_school_id_tl,
3402 % \c_@@_name_secret_tl,
3403 % \c_@@_school_id_tl,
3404 % }
3405 % 中文封面页常量。
3406 % \begin{macrocode}
3407 \clist_map_inline:nn
3408 {
3409 %<def-m> { degree_font } { \bfseries \songti },
3410 %<def-d> { degree_font } { \heiti },
3411 { date } { 答\hfill 辩\hfill 日\hfill 期 },
3412 { clc } { 分类号 },
3413 { student_id } { 学号 },
3414 { school_id } { 学校代码 },
3415 { secret } { 密级 },
3416 }
3417 { \@@_define_name:nn #1 }
3418 \tl_const:Nn \c_@@_school_id_tl { 10487 }
3419 % \end{macrocode}
3420 % \end{variable}
3421 %
3422 % \begin{variable}{
3423 % \c_@@_address_tl
3424 % }
3425 % 英文封面页常量。
3426 % \begin{macrocode}
3427 \tl_const:Nn \c_@@_address_tl
3428 {
3429 Huazhong~ University~ of~ Science~ and~ Technology\\
3430 Wuhan~ 430074,~ P.~ R.~ China
3431 }
3432 % \end{macrocode}
3433 % \end{variable}
3434 %
3435 % \begin{variable}{
3436 % \c_@@_name_type_en_tl,
3437 % \c_@@_name_type_zh_tl,
3438 % \c_@@_name_academic_en_tl,
3439 % \c_@@_name_academic_zh_tl,
3440 % \c_@@_name_professional_en_tl,
3441 % \c_@@_name_professional_zh_tl,
3442 % \c_@@_name_author_en_tl,
3443 % \c_@@_name_author_zh_tl,
3444 % \c_@@_name_major_en_tl,
3445 % \c_@@_name_major_zh_tl,
3446 % \c_@@_name_supervisor_en_tl,
3447 % \c_@@_name_supervisor_zh_tl,
3448 % }
3449 % 中英文页共用常量。
3450 % \begin{macrocode}
3451 \clist_map_inline:nn
3452 {
3453 { type }
3454 { A~ Dissertation~ Submitted~ in~ Partial~ Fulfillment~ of~
3455 %<def-m> the~
3456 %<def-d> The~
3457 Requirements~ for~ }
3458 %<def-m> { 硕士学位论文 },
3459 %<def-d> { 博士学位论文 },
3460 %<*def-m>
3461 { academic } { the~ Master~ Degree~ in } { 学术型 },
3462 { professional } { the~ Professional~ Master~ Degree~ in } { 专业型 },
3463 { author } { Candidate } { 学\hfill 位\hfill 申\hfill 请\hfill 人 },
3464 %</def-m>
3465 %<*def-d>
3466 { academic } { The~ Degree~ of~ Doctor~ of } { 学术型 },
3467 { professional } { The~ Degree~ of~ Doctor~ of } { 专业型 }, % no diff in English
3468 { author } { Ph.D.~ Candidate } { 学\hfill 位\hfill 申\hfill 请\hfill 人 },
3469 %</def-d>
3470 { major } { Major } { 学\hfill 科\hfill 专\hfill 业 },
3471 { supervisor } { Supervisor } { 指\hfill 导\hfill 老\hfill 师 },
3472 }
3473 { \@@_define_name:nnn #1 }
3474 % \end{macrocode}
3475 % \end{variable}
3476 %
3477 % \subsection{声明页常量}
3478 %
3479 % \begin{variable}{\c_@@_orig_decl_title_tl, \c_@@_orig_decl_text_tl}
3480 % 独创性声明。
3481 % \begin{macrocode}
3482 \tl_const:Nn \c_@@_orig_decl_title_tl { 独创性声明 }
3483 \tl_const:Nn \c_@@_orig_decl_text_tl
3484 {
3485 本人声明所呈交的学位论文是我个人在导师指导下进行的研究工作及取得的研
3486 究成果。尽我所知,除文中已经标明引用的内容外,本论文不包含任何其他个人或
3487 集体已经发表或撰写过的研究成果。对本文的研究做出贡献的个人和集体,均已在
3488 文中以明确方式标明。本人完全意识到本声明的法律结果由本人承担。
3489 }
3490 % \end{macrocode}
3491 % \end{variable}
3492 %
3493 % \begin{variable}{\c_@@_orig_decl_sign_clist}
3494 % 独创性声明签名项目。
3495 % \begin{macrocode}
3496 \clist_const:Nn \c_@@_orig_decl_sign_clist
3497 {
3498 学位论文作者签名:\hspace{2em}\mbox{},
3499 日期:\hspace{2em}年\hspace{1.5em}月\hspace{1.5em}日
3500 }
3501 % \end{macrocode}
3502 % \end{variable}
3503 %
3504 % \begin{variable}{\c_@@_auth_decl_title_tl, \c_@@_auth_decl_text_tl}
3505 % 学位论文版权使用授权书。
3506 % \begin{macrocode}
3507 \tl_const:Nn \c_@@_auth_decl_title_tl { 学位论文版权使用授权书 }
3508 \tl_const:Nn \c_@@_auth_decl_text_tl
3509 {
3510 本学位论文作者完全了解学校有关保留、使用学位论文的规定,即:学校有权
3511 保留并向国家有关部门或机构送交论文的复印件和电子版,允许论文被查阅和借阅。
3512 本人授权华中科技大学可以将本学位论文的全部或部分内容编入有关数据库进行检
3513 索,可以采用影印、缩印或扫描等复制手段保存和汇编本学位论文。
3514 }
3515 % \end{macrocode}
3516 % \end{variable}
3517 %
3518 % \begin{variable}{\c_@@_auth_decl_secr_clist, \c_@@_auth_decl_sign_clist}
3519 % 学位论文版权使用授权书填写项目:保密与签名。
3520 % \begin{macrocode}
3521 \clist_const:Nn \c_@@_auth_decl_secr_clist
3522 {
3523 本论文属于,
3524 保\hspace{1em}密□,在\underline{\hspace{3em}}年解密后适用本授权书。,
3525 不保密□。,
3526 (请在以上方框内打“√”)
3527 }
3528 \clist_const:Nn \c_@@_auth_decl_sign_clist
3529 {
3530 学位论文作者签名:\hfill{} 指导教师签名:\hspace*{5em} \mbox{},
3531 日期:\hspace*{2em}年\hspace*{1.5em}月\hspace*{1.5em}日 \hfill{}
3532 日期:\hspace*{2em}年\hspace*{1.5em}月\hspace*{1.5em}日\hspace*{1em} \mbox{}
3533 }
3534 % \end{macrocode}
3535 % \end{variable}
3536 %
3537 % \subsection{摘要页常量}
3538 % \begin{variable}{
3539 % \c_@@_name_abstract_zh_tl,
3540 % \c_@@_name_abstract_en_tl,
3541 % \c_@@_name_keywords_zh_tl,
3542 % \c_@@_name_keywords_en_tl,
3543 % \c_@@_sep_keywords_zh_tl,
3544 % \c_@@_sep_keywords_en_tl,
3545 % }
3546 % \begin{macrocode}
3547 \clist_map_inline:nn
3548 {
3549 { abstract } { Abstract } { 摘\hspace{1em}要 },
3550 { keywords } { Key~ words: } { 关键词: },
3551 }
3552 { \@@_define_name:nnn #1 }
3553 \tl_const:Nn \c_@@_sep_keywords_zh_tl { ; }
3554 \tl_const:Nn \c_@@_sep_keywords_en_tl { , }
3555 % \end{macrocode}
3556 % \end{variable}
3557 %
3558 % \subsection{正文常量}
3559 % \begin{variable}{\c_@@_header_tl}
3560 % 页眉。
3561 % \begin{macrocode}
3562 %<def-m>\tl_const:Nn \c_@@_header_tl { 华中科技大学硕士学位论文 }
3563 %<def-d>\tl_const:Nn \c_@@_header_tl { 华中科技大学博士学位论文 }
3564 % \end{macrocode}
3565 % \end{variable}
3566 %
3567 % \begin{macrocode}
3568 %</def-m|def-d>
3569 % \end{macrocode}
3570
3571 % \section{文献样式}
3572 %
3573 % \changes{v2.0.0}{2025-02-26}{实现基于\pkg{biblatex}的文献样式}
3574 %
3575 % \subsection{标注样式}
3576 %
3577 % \begin{macrocode}
3578 %<*cbx>
3579 % \end{macrocode}
3580 %
3581 % 无须修改标注样式。
3582 % \begin{macrocode}
3583 \RequireCitationStyle{gb7714-2015}
3584 % \end{macrocode}
3585 %
3586 % \begin{macrocode}
3587 %</cbx>
3588 % \end{macrocode}
3589 %
3590 % \subsection{著录样式}
3591 %
3592 % \begin{macrocode}
3593 %<*bbx>
3594 % \end{macrocode}
3595 %
3596 % 基于 \pkg{biblatex-gb7714-2015} 的著录样式。
3597 % \begin{macrocode}
3598 \RequireBibliographyStyle{gb7714-2015}
3599 % \end{macrocode}
3600 %
3601 % 设置 \pkg{biblatex-gb7714-2015} 通用著录样式选项。
3602 % \begin{macrocode}
3603 \ExecuteBibliographyOptions
3604 {
3605 isbn = false,
3606 url = false,
3607 doi = false,
3608 gbnamefmt = givenahead,
3609 gbtype = false,
3610 gbpunctin = false,
3611 maxbibnames = 6,
3612 minbibnames = 6,
3613 }
3614 % \end{macrocode}
3615 %
3616 % 删除著录项末尾的标点符号。
3617 % \begin{macrocode}
3618 \renewcommand{\finentrypunct}{}
3619 % \end{macrocode}
3620 %
3621 % \subsubsection{专著}
3622 %
3623 % 设置专著版本样式,并使用 \pkg{zhnumber} 将中文专著的阿拉伯数字版本号自动转换为中文数字。
3624 % \begin{macrocode}
3625 \newcommand\HUST@bib@zhedition[1]{(#1)}
3626 \newcommand\HUST@bib@enedition[1]{(#1)}
3627 \DeclareFieldFormat{edition}{\bibtitlefont%源来自biblatex.DEF
3628 \testCJKfirst{userd}%
3629 \iftoggle{ifCJKforgbt}%
3630 {\ifinteger{#1}
3631 {%
3632 \ifnumgreater{#1}{1}{\printtext{
3633 %#1\str@edition
3634 \HUST@bib@zhedition{第\zhnumber{#1}版}
3635 }}{}
3636 }%
3637 %{#1\isdot}}%
3638 {\HUST@bib@zhedition{#1}}
3639 \addspace
3640 }%
3641 {\ifinteger{#1}%
3642 {\ifnumgreater{#1}{1}{
3643 %\mkbibordedition{#1}~\bibstring{edition}
3644 \HUST@bib@enedition{\mkbibordedition{#1}~\bibstring{edition}}
3645 }{}
3646 }%
3647 %{#1\isdot}}%
3648 {\HUST@bib@enedition{#1}\isdot}
3649 }
3650 }
3651 \DeclareBibliographyDriver{book}{%源来自standard.bbx文件
3652 \usebibmacro{bibindex}%
3653 \usebibmacro{begentry}%
3654 \usebibmacro{author/editor+others/translator+others}%
3655 \ifnameundef{namea}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
3656 % \end{macrocode}
3657 % 删除版本前的标点符号。
3658 % \begin{macrocode}
3659 \if false
3660 \usebibmacro{maintitle+title}%
3661 \iftoggle{bbx:gbstrict}{}{%
3662 \newunit
3663 \printlist{language}%
3664 \newunit\newblock%
3665 \usebibmacro{byauthor}%
3666 \newunit\newblock
3667 }%
3668 \usebibmacro{byeditor+others}%
3669 \newunit
3670 \fi
3671 \printfield[titlecase]{title}%
3672 \printfield{edition}%
3673 \newunit\newblock%%
3674 \iftoggle{bbx:gbstrict}{}{%
3675 \iffieldundef{maintitle}%
3676 {%\printfield{volume}%
3677 \printfield{part}}%
3678 {}%
3679 \newunit%
3680 \printfield{volumes}%
3681 \newunit\newblock%
3682 \usebibmacro{series+number}}%
3683 \newunit\newblock%
3684 %\printfield{note}%
3685 %\newunit\newblock%
3686 \usebibmacro{publisher+location+date}%
3687 %\newunit\newblock %这里标点去掉
3688 \usebibmacro{chapter+pages}%
3689 \iffieldundef{url}{}{%当没有网址时也不输出
3690 \usebibmacro{modifydate}}%带括号的修改或更新日期,
3691 \usebibmacro{doi+eprint+url}%从下面移动到上面来,因为gbt2015的url需直接放在页码后面。
3692 % \end{macrocode}
3693 % 删除专著的页码。
3694 % \begin{macrocode}
3695 \if false
3696 \newunit\newblock%
3697 \printfield{pagetotal}%
3698 \fi
3699 \newunit\newblock%
3700 \iftoggle{bbx:isbn}
3701 {\printfield{isbn}}
3702 {}%
3703 \newunit\newblock
3704 %\usebibmacro{doi+eprint+url}%
3705 %\newunit\newblock
3706 \usebibmacro{addendum+pubstate}%
3707 \setunit{\bibpagerefpunct}\newblock
3708 \usebibmacro{pageref}%
3709 \newunit\newblock
3710 \iftoggle{bbx:related}
3711 {\usebibmacro{related:init}%
3712 \usebibmacro{related}}
3713 {}%
3714 \usebibmacro{annotation}\usebibmacro{finentry}
3715 }
3716 % \end{macrocode}
3717 %
3718 % \subsubsection{析出文献}
3719 %
3720 % 设置包括会议论文在内的析出文献著录样式。
3721 % 修改 Driver: inbook $\rightarrow$ macro: |inbook:parent|
3722 % $\rightarrow$ |publisher+location+date|。
3723 % 将会议论文析出文献中的会议地址(含会议日期)后面的冒号改为逗号。
3724 % \begin{macrocode}
3725 \newbibmacro*{HUSTinbook_publisher+location+date}{\bibpubfont%
3726 \iftoggle{bbx:gbpub}%
3727 {\testCJKfirst{userd}%
3728 \ifboolexpr{ test {\iflistundef{location}} and test {\iflistundef{publisher}} }%
3729 {\iffieldequalstr{entrysubtype}{standard}{}
3730 {\iftoggle{ifCJKforgbt}{\printtext{\gbleftbracket\str@noaddress}\space :\space\str@nopublisher\gbrightbracket}
3731 {\printtext{\gbleftbracket S.l.\space :\space s.n.\adddot\gbrightbracket}}}
3732 }%
3733 {
3734 \iflistundef{location}{%\adddot
3735 \iffieldequalstr{entrysubtype}{standard}{}%%从gbt7714-2015标准第19页看到,标准存在出版项时输出,没有时完全省略。
3736 {\iftoggle{ifCJKforgbt}{\printtext{\gbleftbracket\str@noaddress\gbrightbracket}\addcolon\addspace}%
3737 {\printtext{\gbleftbracket S.l.\adddot\gbrightbracket}\publocpunct}}
3738 }% \bibstring{noaddress}
3739 {\printlist{location}\publocpunct}%%\addcolon\addspace%
3740 \iflistundef{publisher}{%
3741 \iffieldequalstr{entrysubtype}{standard}{}%
3742 {\iftoggle{ifCJKforgbt}{\printtext{\gbleftbracket\str@nopublisher\gbrightbracket}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}%
3743 {\printtext{\mkbibbrackets{s.n.}}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}}}%
3744 {\printlist{publisher}}
3745 }%
3746 \pubdatadelim%\addcomma\addspace%
3747 \usebibmacro{date}%%\newunit %去掉这个标点
3748 }%
3749 {\printlist{location}%
3750 \iflistundef{publisher}
3751 {\locnopubdelim}
3752 % \end{macrocode}
3753 % 始终使用逗号。
3754 % \begin{macrocode}
3755 %{\setunit*{\publocpunct}}%
3756 {\locnopubdelim}
3757 \printlist{publisher}%
3758 \pubdatadelim%
3759 \usebibmacro{date}%%\newunit
3760 }%
3761 }
3762 \renewbibmacro*{inbook:parent}{%
3763 \usebibmacro{bybookauthor}%
3764 \ifnameundef{bookauthor}{%
3765 \ifnameundef{editor}{}{\newunit}%
3766 }{\newunit}%替换下一句
3767 %\newunit\newblock
3768 \iffieldundef{series}{}
3769 {\usebibmacro{series+number}\setunit{\addcolon\addspace}}%为处理一些存在series的情况而增加
3770 \usebibmacro{maintitle+booktitle}%
3771 \iffieldundef{volume}{}{\setunit{\addcolon\addspace}\printfield{volume}}%
3772 \iffieldundef{number}{}{\setunit{\addcolon\addspace}\printfield{number}}%增加卷和册信息
3773 \newunit\newblock%
3774 % \usebibmacro{byeditor+others}%
3775 % \newunit\newblock
3776 \printfield{edition}%
3777 \newunit
3778 \iftoggle{bbx:gbstrict}{}{%
3779 % \iffieldundef{maintitle}
3780 % {\printfield{volume}%
3781 % \printfield{part}}
3782 % {}%
3783 % \newunit
3784 % \printfield{volumes}%
3785 % \newunit\newblock
3786 % \usebibmacro{series+number}
3787 }%
3788 \newunit\newblock
3789 %\printfield{note}%
3790 %\newunit\newblock
3791 % \end{macrocode}
3792 % 由于 |publisher+location+date| 在不只这里使用,
3793 % 因此将其移植到宏 |HUSTinbook_publisher+location+date| 中。
3794 % \begin{macrocode}
3795 %\usebibmacro{publisher+location+date}
3796 \usebibmacro{HUSTinbook_publisher+location+date}%
3797 }
3798 % \end{macrocode}
3799 %
3800 % \subsubsection{期刊}
3801 %
3802 % 暂时没发现需要修改的。
3803 %
3804 % \subsubsection{专利}
3805 %
3806 % 设置专利著录样式。
3807 % \begin{macrocode}
3808 \DeclareFieldFormat[book]{title}{#1}
3809 \renewbibmacro*{patenttitle}{%原输出来自biblatex.def文件
3810 \ifboolexpr{%
3811 test{\iffieldundef{title}}%
3812 and%
3813 test{\iffieldundef{subtitle}}%
3814 }%
3815 {}%
3816 { \printtext[title]{\bibtitlefont%
3817 \printfield[titlecase]{title}%
3818 \newunit
3819 \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题
3820 {}%
3821 {\setunit{\subtitlepunct}\printfield[titlecase]{subtitle}}%
3822 \iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格
3823 {\setunit{\subtitlepunct}\printfield{titleaddon}}%
3824 % \end{macrocode}
3825 % 修改标题后面标点;将地点,专利号移植到标题中;并强制显示 GB/T 7714-2015 中的文献类型(|[P]|)。
3826 % \begin{macrocode}
3827 \if false
3828 \setunit{\subtitlepunct}\printfield{number}%写专利号
3829 \iftoggle{bbx:gbtype}{\printfield[gbtypeflag]{usera}}{}%
3830 %\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点
3831 %\newunit
3832 \fi
3833 \iflistundef{location}
3834 {}
3835 %{\setunit*{\addspace}%
3836 {\setunit*{\subtitlepunct}
3837 \printtext{%[parens]
3838 \printlist[][-\value{listtotal}]{location}}}%
3839 \setunit{\addcomma\space}\printfield{number}%写专利号
3840 \setunit{\addspace}\printfield[gbtypeflag]{usera}
3841 }%
3842 }%
3843 \setunit{\subtitlepunct}%
3844 }
3845 \DeclareBibliographyDriver{patent}{%源来自standard.BBX
3846 \usebibmacro{bibindex}%
3847 \usebibmacro{begentry}%
3848 \usebibmacro{author}%
3849 \ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
3850 %\usebibmacro{title}%
3851 \usebibmacro{patenttitle}%给出专利专用的标题输出
3852 \iftoggle{bbx:gbstrict}{}{%
3853 \newunit%
3854 \printlist{language}%
3855 \newunit\newblock
3856 \usebibmacro{byauthor}
3857 }%
3858 \newunit\newblock
3859 % \end{macrocode}
3860 % 以下部分,抑或移除,抑或移至标题块 |patenttitle| 中。
3861 % \begin{macrocode}
3862 \if false
3863 \printfield{type}%
3864 \setunit*{\addspace}%
3865 %\printfield{number}%已放到patenttitle中处理
3866 \iflistundef{location}
3867 {}
3868 {\setunit*{\addspace}%
3869 \printtext{%[parens]
3870 \printlist[][-\value{listtotal}]{location}}}%
3871 \newunit\newblock
3872 \usebibmacro{byholder}%
3873 \newunit\newblock
3874 \fi
3875 \printfield{note}%
3876 \newunit\newblock
3877 % \end{macrocode}
3878 % 日期只显示到年。
3879 % \begin{macrocode}
3880 %\usebibmacro{newsdate}%
3881 \usebibmacro{date}%
3882 %\newunit\newblock
3883 \usebibmacro{doi+eprint+url}%
3884 \newunit\newblock
3885 \usebibmacro{addendum+pubstate}%
3886 \setunit{\bibpagerefpunct}\newblock
3887 \usebibmacro{pageref}%
3888 \newunit\newblock
3889 \iftoggle{bbx:related}
3890 {\usebibmacro{related:init}%
3891 \usebibmacro{related}}
3892 {}%
3893 \usebibmacro{annotation}\usebibmacro{finentry}
3894 }
3895 % \end{macrocode}
3896 %
3897 % \subsubsection{学位论文}
3898 %
3899 % 覆盖原 |manual| 的别名。
3900 % \begin{macrocode}
3901 \DeclareBibliographyDriver{thesis}{%
3902 \usebibmacro{bibindex}%
3903 \usebibmacro{begentry}%
3904 \usebibmacro{author/editor+others/translator+others}%
3905 \ifnameundef{namea}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
3906 % \end{macrocode}
3907 % 增加学位论文类型的显示。
3908 % \begin{macrocode}
3909 %\usebibmacro{title}%
3910 \printfield[titlecase]{title}%
3911 \printfield[gbtypeflag]{type}
3912 \iftoggle{bbx:gbstrict}{}{%
3913 \newunit%
3914 \printlist{language}%
3915 \newunit\newblock
3916 \usebibmacro{byauthor}}%
3917 \newunit\newblock
3918 \usebibmacro{byeditor+others}%增加的译者信息
3919 \newunit\newblock
3920 \iftoggle{bbx:gbfieldtype}{%
3921 \printfield{type}%
3922 \setunit*{\addspace}}{}%
3923 \printfield{number}%
3924 \newunit\newblock
3925 \printfield{version}%
3926 \newunit
3927 \printfield{note}%
3928 \newunit\newblock
3929 \usebibmacro{institution+location+date}%
3930 %\newunit\newblock
3931 \usebibmacro{chapter+pages}%
3932 \iffieldundef{url}{}{%当没有网址时也不输出修改或更新日期
3933 \usebibmacro{modifydate}}%修改或更新日期为带括号的时间
3934 \usebibmacro{doi+eprint+url}%
3935 \newunit
3936 \printfield{pagetotal}%
3937 \newunit\newblock
3938 \iftoggle{bbx:isbn}
3939 {\printfield{isrn}}
3940 {}%
3941 \newunit\newblock
3942 % \usebibmacro{doi+eprint+url}%
3943 % \newunit\newblock
3944 \usebibmacro{addendum+pubstate}%
3945 \setunit{\bibpagerefpunct}\newblock
3946 \usebibmacro{pageref}%
3947 \newunit\newblock
3948 \iftoggle{bbx:related}
3949 {\usebibmacro{related:init}%
3950 \usebibmacro{related}}
3951 {}%
3952 \usebibmacro{annotation}\usebibmacro{finentry}
3953 }
3954 % \end{macrocode}
3955 %
3956 % \begin{macrocode}
3957 %</bbx>
3958 % \end{macrocode}
3959 %
3960 % \section{文档样式}
3961 %
3962 % ^^A 本小节初版实现主要来自 \pkg{fduthesis} 文档类。
3963 %
3964 % \begin{macrocode}
3965 %<*doc-sty>
3966 %<@@=hustdoc>
3967 \RequirePackage
3968 {
3969 ulem,
3970 xcolor-material,
3971 zref-base,
3972 listings,
3973 }
3974 % \end{macrocode}
3975 %
3976 % \subsection{内部函数}
3977 %
3978 % \begin{macro}{\@@_patch_cmd:Nnn, \@@_preto_cmd:Nn, \@@_appto_cmd:Nn}
3979 % 补丁工具。
3980 % \begin{macrocode}
3981 \cs_new_protected:Npn \@@_patch_cmd:Nnn #1#2#3
3982 {
3983 \ctex_patch_cmd_once:NnnnTF #1 { } {#2} {#3}
3984 { } { \ctex_patch_failure:N #1 }
3985 }
3986 \cs_new_protected:Npn \@@_preto_cmd:Nn #1#2
3987 {
3988 \ctex_preto_cmd:NnnTF #1 { } {#2}
3989 { } { \ctex_patch_failure:N #1 }
3990 }
3991 \cs_new_protected:Npn \@@_appto_cmd:Nn #1#2
3992 {
3993 \ctex_appto_cmd:NnnTF #1 { } {#2}
3994 { } { \ctex_patch_failure:N #1 }
3995 }
3996 % \end{macrocode}
3997 % \end{macro}
3998 %
3999 % \subsection{\cls{l3doc} 补丁}
4000 %
4001 % \begin{macrocode}
4002 %<@@=codedoc>
4003 % \end{macrocode}
4004 %
4005 % \begin{macro}{\@@_typeset_functions:}
4006 % 减少展开标记(用来表明中英文模板中的不同用法)前的空格。
4007 % \begin{macrocode}
4008 \__hustdoc_patch_cmd:Nnn \@@_typeset_expandability:
4009 { & } { & \skip_horizontal:n { -0.5em } }
4010 % \end{macrocode}
4011 % \end{macro}
4012 %
4013 % \begin{macro}{\@@_typeset_functions:, \@@_macro_init:,
4014 % \@@_macro_dump:}
4015 % 左侧边注的函数列表采用单倍行距。
4016 % \begin{macrocode}
4017 \__hustdoc_preto_cmd:Nn \@@_typeset_functions:
4018 { \MacroFont }
4019 \__hustdoc_patch_cmd:Nnn \@@_macro_init:
4020 { \hbox:n } { \MacroFont \hbox:n }
4021 \__hustdoc_patch_cmd:Nnn \@@_macro_dump:
4022 { \hbox_unpack_drop:N } { \MacroFont \hbox_unpack_drop:N }
4023 % \end{macrocode}
4024 % \end{macro}
4025 %
4026 % \begin{macro}{\@@_macro_typeset_one:nN}
4027 % 在 \env{macro} 环境的侧边栏中,\cls{l3doc} 根据命令的长短,分别用
4028 % 普通字体和紧缩字体输出。然而很长的命令还是会超出页边。这里用缩放
4029 % 盒子的手段使得长命令也可正常显示。
4030 % \begin{macrocode}
4031 \cs_set_protected:Npn \@@_macro_typeset_one:nN #1#2
4032 {
4033 \vbox_set:Nn \l_@@_macro_box
4034 {
4035 \MacroFont
4036 \vbox_unpack_drop:N \l_@@_macro_box
4037 \hbox_set:Nn \l_tmpa_box
4038 { \@@_print_macroname:nN {#1} #2 }
4039 % \end{macrocode}
4040 % \tn{marginparwidth} 和 \tn{marginparsep} 分别是边注的宽度及其到版心的距离,
4041 % \tn{labelsep} 则是编号盒子右端与条目首行文本之间的距离。
4042 % \begin{macrocode}
4043 \dim_set:Nn \l_tmpa_dim
4044 { \marginparwidth - \labelsep - \marginparsep }
4045 \dim_compare:nNnT { \box_wd:N \l_tmpa_box } > \l_tmpa_dim
4046 {
4047 \box_resize_to_wd_and_ht:Nnn \l_tmpa_box
4048 { \l_tmpa_dim } { \box_ht:N \l_tmpa_box }
4049 }
4050 \hbox_overlap_left:n
4051 {
4052 \box_use:N \l_tmpa_box
4053 \skip_horizontal:n { \marginparsep - \labelsep }
4054 }
4055 }
4056 \int_incr:N \l_@@_macro_int
4057 }
4058 % \end{macrocode}
4059 % \end{macro}
4060 %
4061 % \subsection{文档层命令}
4062 %<@@=hustdoc>
4063 %
4064 % \begin{macro}[no-user-doc]{\key}
4065 % 用于在文档中输出自定义索引的命令,主要用于键值对的键的索引。仅当索引项的父分类为 |option| 时,即用于文档类选项时,隐藏父分类。
4066 % \begin{arguments}
4067 % \item 在索引中显示项的父分类,默认为 \opt{option}。
4068 % \item 命令本体。
4069 % \end{arguments}
4070 % \begin{macrocode}
4071 \DeclareDocumentCommand \key { O{option} m }
4072 {
4073 \tl_if_eq:nnTF { #1 } { option }
4074 { \cmd[module=#1/]{#2} }
4075 { \cmd[module=#1/]{#1/#2} }
4076 }
4077 % \end{macrocode}
4078 % \end{macro}
4079 %
4080 % \begin{macro}[no-user-doc]{\opt}
4081 % 输出键值对的值。
4082 % \begin{macrocode}
4083 \DeclareDocumentCommand \opt { s m }
4084 { \IfBooleanTF {#1} { \texttt{\bfseries \upshape #2} } { \texttt{\upshape #2} } }
4085 % \end{macrocode}
4086 % \end{macro}
4087 %
4088 % \begin{macro}[no-user-doc]{\expstar, \rexpstar}
4089 % \begin{macrocode}
4090 \newcommand\expstar{\hyperref[sec:exp]{$\star$}}
4091 \newcommand\rexpstar{\hyperref[sec:exp]{\ding{73}}}
4092 % \end{macrocode}
4093 % \end{macro}
4094 %
4095 % \begin{macro}[int]{\TeX, \LaTeX, \LaTeXe,
4096 % \pdfTeX, \pdfLaTeX, \XeTeX, \XeLaTeX, \LuaTeX, \LuaLaTeX,
4097 % \AmSLaTeX, \TeXLive, \MiKTeX, \BibTeX, \biber, \TikZ
4098 % }
4099 % \TeX{} 相关标志。
4100 % \begin{macrocode}
4101 \def\TeX{\hologo{TeX}}
4102 \def\LaTeX{\hologo{LaTeX}}
4103 \def\LaTeXe{\hologo{LaTeXe}}
4104 \def\pdfTeX{\hologo{pdfTeX}}
4105 \def\pdfLaTeX{\hologo{pdfLaTeX}}
4106 \def\XeTeX{\hologo{XeTeX}}
4107 \def\XeLaTeX{\hologo{XeLaTeX}}
4108 \def\LuaTeX{\hologo{LuaTeX}}
4109 \def\LuaLaTeX{\hologo{LuaLaTeX}}
4110 \def\AmSLaTeX{\hologo{AmSLaTeX}}
4111 \def\TeXLive{\TeX\ Live}
4112 \def\MiKTeX{\hologo{MiKTeX}}
4113 \def\BibTeX{\hologo{BibTeX}}
4114 \def\biber{\hologo{biber}}
4115 % \end{macrocode}
4116 % 该定义来自 \file{pgfmanual-en-macros.tex}。
4117 % \begin{macrocode}
4118 \def\TikZ{Ti\emph{k}Z}
4119 % \end{macrocode}
4120 % \end{macro}
4121 %
4122 % \subsection{文档样式}
4123 %
4124 % \begin{environment}{bashecode, latexcode}
4125 % \begin{macrocode}
4126 \lstdefinestyle{style@base}
4127 {
4128 basewidth = 0.5 em,
4129 gobble = 3,
4130 lineskip = 3 pt,
4131 frame = l,
4132 framerule = 1 pt,
4133 framesep = 0 pt,
4134 xleftmargin = 2 em,
4135 xrightmargin = 3 em,
4136 escapeinside = {(*}{*)},
4137 breaklines = true,
4138 basicstyle = \small\ttfamily,
4139 keywordstyle = \bfseries\color{purple},
4140 commentstyle = \itshape\color{white!50!gray},
4141 stringstyle = \color{red},
4142 backgroundcolor = \color{white!95!gray}
4143 }
4144 \lstdefinestyle{style@bash}
4145 {
4146 style = style@base,
4147 rulecolor = \color{pink},
4148 language = bash,
4149 alsoletter = {-},
4150 emphstyle = \color{green}
4151 }
4152 \lstdefinestyle{style@latex}
4153 {
4154 style = style@base,
4155 rulecolor = \color{blue},
4156 language = [LaTeX]TeX,
4157 alsoletter = {*, -, .},
4158 texcsstyle = *\color{purple},
4159 emphstyle = [1]\color{orange},
4160 emphstyle = [2]\color{green},
4161 emphstyle = [3]\bfseries\color{yellow}
4162 }
4163 \lstnewenvironment{bashecode}[1][]{%
4164 \lstset{style=style@bash, #1}}{}
4165 \lstnewenvironment{latexcode}[1][]{%
4166 \lstset{style=style@latex, #1}}{}
4167 % \end{macrocode}
4168 % \end{environment}
4169 %
4170 % \subsection{\env{macrocode}环境}
4171 %
4172 % \subsubsection{代码行处理}
4173 %
4174 % \begin{macro}[int]{\xmacro@code,\sxmacro@code}
4175 % 重新实现 \env{macrocode} 与 \env{macrocode*} 环境的核心功能,将对代码逐行
4176 % 处理。后者会将空格显示为“\verb*| |”。
4177 % \begin{macrocode}
4178 \cs_set_protected_nopar:Npn \xmacro@code
4179 { \@@_marco_code:w }
4180 \cs_set_protected_nopar:Npn \sxmacro@code
4181 {
4182 \fontspec_print_visible_spaces:
4183 \xmacro@code
4184 }
4185 % \end{macrocode}
4186 % \end{macro}
4187 %
4188 % \begin{macro}{\@@_marco_code:w}
4189 % \begin{macrocode}
4190 \cs_new_protected_nopar:Npn \@@_marco_code:w
4191 {
4192 % \end{macrocode}
4193 % 根据 \tn{codeline@index} 是否为 |true| 选择是否显示行号。
4194 % \begin{macrocode}
4195 \ifcodeline@index
4196 \@@_marco_code_every_par:n { \@@_code_line_no: }
4197 \else:
4198 \@@_marco_code_every_par:n { }
4199 \fi:
4200 % \end{macrocode}
4201 % 设置代码段结束标记为“\verb*|% \end{macrocode}^^M|”。
4202 % \begin{macrocode}
4203 \@@_make_finish_tag:x { \@currenvir }
4204 % \end{macrocode}
4205 % 开始 \env{macrocode}。
4206 % \begin{macrocode}
4207 \@@_macro_code_start:w
4208 }
4209 % \end{macrocode}
4210 % \end{macro}
4211 %
4212 % \begin{macro}{\@@_marco_code_every_par:n}
4213 % 在每段之前插入内容。这里每段即相当于每行。
4214 % \begin{macrocode}
4215 \cs_new_protected:Npn \@@_marco_code_every_par:n #1
4216 {
4217 \everypar
4218 {
4219 \everypar {#1}
4220 \if@inlabel
4221 \global \@inlabelfalse \@noparlistfalse
4222 \llap { \box \@labels \hskip \leftskip }
4223 \fi
4224 #1
4225 }
4226 }
4227 % \end{macrocode}
4228 % \end{macro}
4229 %
4230 % 设置 \tn{endlinechar} 为 $-1$,表示行末不插入任何字符(实际上相当于在行尾
4231 % 插入注释符 |%|)。
4232 % \begin{macrocode}
4233 \group_begin:
4234 \int_set:Nn \tex_endlinechar:D { -1 }
4235 % \end{macrocode}
4236 %
4237 % \begin{variable}{\c_@@_active_space_tl}
4238 % 活动字符类的空格(ASCII 码为 32)。
4239 % \begin{macrocode}
4240 \use:n
4241 {
4242 \char_set_catcode_active:n { 32 }
4243 \tl_const:Nn \c_@@_active_space_tl
4244 }
4245 { }
4246 \group_end:
4247 % \end{macrocode}
4248 % \end{variable}
4249 %
4250 % ASCII 码 13 是回车符 |^^M|。将其设置为活动字符。
4251 % \begin{macrocode}
4252 \group_begin:
4253 \char_set_catcode_active:n { 13 }
4254 % \end{macrocode}
4255 %
4256 % \begin{macro}{\@@_make_finish_tag:n,\@@_make_finish_tag:x}
4257 % \env{macrocode} 结尾标记。展开后变成“\verb*|% \end{#1}^^M|”。
4258 % \begin{macrocode}
4259 \cs_new_protected:Npx \@@_make_finish_tag:n #1
4260 {
4261 \tl_set:Nn \exp_not:N \l_@@_macro_code_finish_tl
4262 {
4263 \c_percent_str
4264 \prg_replicate:nn { 4 }
4265 { \exp_not:o { \c_@@_active_space_tl } }
4266 \exp_not:o { \active@escape@char } end
4267 \c_left_brace_str #1 \c_right_brace_str
4268 \exp_not:N ^^M
4269 }
4270 }
4271 \cs_generate_variant:Nn \@@_make_finish_tag:n { x }
4272 % \end{macrocode}
4273 % \end{macro}
4274 %
4275 % \begin{macro}{\@@_macro_code_start:w}
4276 % 开始代码环境。此命令主要是为了防止 |\begin{macrocode}| 后出现多余的空行。
4277 % \begin{macrocode}
4278 \cs_new_protected:Npn \@@_macro_code_start:w #1
4279 {
4280 \str_if_eq:nnTF {#1} { ^^M }
4281 { \@@_macro_code_read_line:w }
4282 { \@@_macro_code_read_line:w #1 }
4283 }
4284 % \end{macrocode}
4285 % \end{macro}
4286 %
4287 % \begin{macro}{\@@_macro_code_read_line:w}
4288 % 逐行读取代码,并连同行尾回车符一并存入 \cs{l_@@_macro_code_line_tl}。如果该行
4289 % 与结束标记“\verb*|% \end{macrocode}^^M|”相同,则结束此 \env{macrocode};
4290 % 否则继续处理该行代码。
4291 % \begin{macrocode}
4292 \cs_new_protected:Npn \@@_macro_code_read_line:w #1 ^^M
4293 {
4294 \tl_set:Nn \l_@@_macro_code_line_tl { #1 ^^M }
4295 \tl_if_eq:NNTF
4296 \l_@@_macro_code_line_tl \l_@@_macro_code_finish_tl
4297 { \exp_args:Nx \end { \@currenvir } }
4298 {
4299 \@@_macro_code_process_line:
4300 \@@_macro_code_read_line:w
4301 }
4302 }
4303 % \end{macrocode}
4304 % \end{macro}
4305 %
4306 % \begin{macro}{\@@_swap_cr:,\@@_swap_cr_aux:w}
4307 % 把 \cs{l_@@_macro_code_line_tl} 中的回车符 |^^M| 挪到外面。
4308 % \begin{macrocode}
4309 \cs_new_protected:Npn \@@_swap_cr:
4310 {
4311 \exp_after:wN
4312 \@@_swap_cr_aux:w \l_@@_macro_code_line_tl
4313 }
4314 \cs_new_protected:Npn \@@_swap_cr_aux:w #1 ^^M
4315 {
4316 \group_insert_after:N ^^M
4317 \tl_set:Nn \l_@@_macro_code_line_tl {#1}
4318 }
4319 % \end{macrocode}
4320 % \end{macro}
4321 %
4322 % \begin{variable}{\c_@@_active_cr_tl}
4323 % 活动字符类的回车符。
4324 % \begin{macrocode}
4325 \tl_const:Nn \c_@@_active_cr_tl { ^^M }
4326 \group_end:
4327 % \end{macrocode}
4328 % \end{variable}
4329 %
4330 % \begin{variable}{\l_@@_macro_code_line_tl,
4331 % \l_@@_macro_code_finish_tl,
4332 % \g_@@_macro_code_verbatim_stop_tl}
4333 % 分别用来存储代码行、\env{macrocode} 结束标记以及抄录停止标记。
4334 % \begin{macrocode}
4335 \tl_new:N \l_@@_macro_code_line_tl
4336 \tl_new:N \l_@@_macro_code_finish_tl
4337 \tl_new:N \g_@@_macro_code_verbatim_stop_tl
4338 % \end{macrocode}
4339 % \end{variable}
4340 %
4341 % \begin{macro}{\@@_process_normal_line:}
4342 % 普通代码行根据开头字符分别处理。
4343 % \begin{macrocode}
4344 \cs_new_protected_nopar:Npn \@@_process_normal_line:
4345 {
4346 \str_case_e:nnF
4347 { \str_head:N \l_@@_macro_code_line_tl }
4348 {
4349 % \end{macrocode}
4350 % 以 |%| 开头的行先由 \cs{tl_tail:N} 去掉 |%|,之后再检查 |<|。
4351 % \begin{macrocode}
4352 { \c_percent_str }
4353 {
4354 \@@_check_angle:x
4355 { \tl_tail:N \l_@@_macro_code_line_tl }
4356 }
4357 % \end{macrocode}
4358 % 以 |#| 开头的行按注释的格式输出。
4359 % \begin{macrocode}
4360 { \c_hash_str }
4361 { \@@_output_comment_line: }
4362 }
4363 % \end{macrocode}
4364 % 其余正常输出。
4365 % \begin{macrocode}
4366 { \@@_output_line: }
4367 }
4368 % \end{macrocode}
4369 % \end{macro}
4370 %
4371 % \begin{macro}{\@@_process_verbatim_line:}
4372 % 处理抄录代码行(不检查 |%| 与 |<|)。
4373 % \begin{macrocode}
4374 \cs_new_protected_nopar:Npn \@@_process_verbatim_line:
4375 {
4376 % \end{macrocode}
4377 % 将该行与抄录停止标记进行比较。
4378 % \begin{macrocode}
4379 \tl_if_eq:NNTF \l_@@_macro_code_line_tl
4380 \g_@@_macro_code_verbatim_stop_tl
4381 % \end{macrocode}
4382 % 若相同,则结束抄录环境,清空抄录停止标记,并输出该标记;
4383 % \begin{macrocode}
4384 {
4385 \tl_gclear:N \g_@@_macro_code_verbatim_stop_tl
4386 \cs_gset_eq:NN \@@_macro_code_process_line:
4387 \@@_process_normal_line:
4388 \@@_output_module:nn
4389 { \color { verb@guard } }
4390 {
4391 \@@_swap_cr:
4392 \@@_module_pop:n { \l_@@_macro_code_line_tl }
4393 }
4394 }
4395 % \end{macrocode}
4396 % 否则直接输出抄录代码。
4397 % \begin{macrocode}
4398 { \tl_use:N \l_@@_macro_code_line_tl }
4399 }
4400 % \end{macrocode}
4401 % \end{macro}
4402 %
4403 % \begin{macro}{\@@_macro_code_process_line:}
4404 % 处理代码行。该命令的作用如下:
4405 % \begin{itemize}
4406 % \item 正常情况下,等同于 \cs{@@_process_normal_line:};
4407 % \item 在 \cs{DontCheckModules} 之后,等价于 \cs{@@_output_line:},
4408 % 即不检查模块标记,直接输出;
4409 % \item 在抄录环境中,等价于 \cs{@@_process_verbatim_line:},
4410 % 此时将不再特殊处理以 |%| 开头的代码行。
4411 % \end{itemize}
4412 % \begin{macrocode}
4413 \cs_new_eq:NN \@@_macro_code_process_line:
4414 \@@_process_normal_line:
4415 % \end{macrocode}
4416 % \end{macro}
4417 %
4418 % \subsubsection{模块标记处理}
4419 %
4420 % \begin{macro}[int]{\CheckModules, \DontCheckModules}
4421 % 选择是否检查模块标记。这两个命令在 \pkg{doc} 宏包中已有定义,此处重新声明。
4422 % \begin{macrocode}
4423 \DeclareDocumentCommand \CheckModules { }
4424 {
4425 \cs_set_eq:NN \@@_macro_code_process_line:
4426 \@@_process_normal_line:
4427 }
4428 \DeclareDocumentCommand \DontCheckModules { }
4429 {
4430 \cs_set_eq:NN \@@_macro_code_process_line:
4431 \@@_output_line:
4432 }
4433 % \end{macrocode}
4434 % \end{macro}
4435 %
4436 % \begin{macro}{\@@_check_angle:n,\@@_check_angle:x}
4437 % 检查第一个字符是否是 |<|。若是,则检查模块;否则立刻输出改行。
4438 % 该函数的参数不带 |%|。
4439 % \begin{macrocode}
4440 \cs_new_protected:Npn \@@_check_angle:n #1
4441 {
4442 \str_if_eq:eeTF { \str_head:n {#1} } { < }
4443 { \@@_check_module:x { \tl_tail:n {#1} } }
4444 { \@@_output_comment_line: }
4445 }
4446 \cs_generate_variant:Nn \@@_check_angle:n { x }
4447 % \end{macrocode}
4448 % \end{macro}
4449 %
4450 % \begin{macro}{\@@_check_module:n,\@@_check_module:x}
4451 % 检查紧跟 |<| 之后的字符。共有四种情况:
4452 % \begin{itemize}
4453 % \item |*|:模块开始(|%<*|\meta{module}|>|);
4454 % \item |/|:模块结束(|%</|\meta{module}|>|);
4455 % \item |@|:名字空间(|%<@@=|\meta{namespace}|>|);
4456 % \item |<|:抄录环境开始(|%<<|\meta{end-tag})。
4457 % \end{itemize}
4458 % 若不是这几种情况,则为单独一行的独立模块(|%<|\meta{module}|>|)。
4459 % \begin{macrocode}
4460 \cs_new_protected:Npn \@@_check_module:n #1
4461 {
4462 \str_case_e:nnF { \str_head:n {#1} }
4463 {
4464 { * } { \@@_module_star:w }
4465 { / } { \@@_module_slash:w }
4466 { @ } { \@@_module_at:w }
4467 { < } { \@@_module_verb:w }
4468 }
4469 { \@@_module_pm:w }
4470 % \end{macrocode}
4471 % 参数 |#1| 将被上面几个 |:w| 型函数吃掉。
4472 % \begin{macrocode}
4473 #1 \q_stop
4474 }
4475 \cs_generate_variant:Nn \@@_check_module:n { x }
4476 % \end{macrocode}
4477 % \end{macro}
4478 %
4479 % 设置 |>| 为活动字符。
4480 % \begin{macrocode}
4481 \group_begin:
4482 \char_set_catcode_active:N \>
4483 % \end{macrocode}
4484 %
4485 % \begin{macro}{\@@_module_star:w}
4486 % 模块开始标记。
4487 % \begin{arguments}
4488 % \item |*|\meta{module}
4489 % \item 之后的代码
4490 % \end{arguments}
4491 % \begin{macrocode}
4492 \cs_new_protected:Npn \@@_module_star:w #1 > #2 \q_stop
4493 {
4494 % \end{macrocode}
4495 % 临时变量 \cs{l_@@_tmpa_tl} 保存 |<*|\meta{module}|>| 之后的部分,即真实代码。
4496 % \begin{macrocode}
4497 \tl_set:Nn \l_@@_tmpa_tl {#2}
4498 % \end{macrocode}
4499 % 判断该行是否为空(只含一个回车符 |^^M|)。
4500 % \begin{macrocode}
4501 \tl_if_eq:NNTF \l_@@_tmpa_tl \c_@@_active_cr_tl
4502 % \end{macrocode}
4503 % 若是,则将 |<|\meta{module}|>| 放在行号的右侧;
4504 % \begin{macrocode}
4505 {
4506 \@@_output_module:nn
4507 { \@@_star_color: }
4508 {
4509 \@@_module_push:n
4510 { \@@_module_angle:n {#1} }
4511 }
4512 }
4513 % \end{macrocode}
4514 % 否则放在左侧,并输出相应代码。
4515 % \begin{macrocode}
4516 {
4517 \@@_output_module_left:nn
4518 { \@@_star_color: }
4519 {
4520 \@@_module_push:n
4521 { \@@_module_angle:n {#1} }
4522 }
4523 }
4524 \@@_output_line:n {#2}
4525 }
4526 % \end{macrocode}
4527 % \end{macro}
4528 %
4529 % \begin{macro}{\@@_module_slash:w}
4530 % 模块结束标记。结构与 \cs{@@_module_star:w} 相同。
4531 % \begin{arguments}
4532 % \item |/|\meta{module}
4533 % \item 之后的代码
4534 % \end{arguments}
4535 % \begin{macrocode}
4536 \cs_new_protected:Npn \@@_module_slash:w #1 > #2 \q_stop
4537 {
4538 \tl_set:Nn \l_@@_tmpa_tl {#2}
4539 \tl_if_eq:NNTF \l_@@_tmpa_tl \c_@@_active_cr_tl
4540 {
4541 \@@_output_module:nn
4542 { \@@_slash_color: }
4543 {
4544 \@@_module_pop:n
4545 { \@@_module_angle:n {#1} }
4546 }
4547 }
4548 {
4549 \@@_output_module_left:nn
4550 { \@@_slash_color: }
4551 {
4552 \@@_module_pop:n
4553 { \@@_module_angle:n {#1} }
4554 }
4555 }
4556 \@@_output_line:n {#2}
4557 }
4558 % \end{macrocode}
4559 % \end{macro}
4560 %
4561 % \begin{macro}{\@@_module_at:w}
4562 % 名字空间。
4563 % \begin{arguments}
4564 % \item 名字空间的名称(不含 |@@=|)
4565 % \item 之后的代码
4566 % \end{arguments}
4567 % \begin{macrocode}
4568 \cs_new_protected:Npn \@@_module_at:w @ @ = #1 > #2 \q_stop
4569 {
4570 \@@_output_module:nn
4571 { \color { at@guard } }
4572 { \@@_module_angle:n { @ @ = #1 } }
4573 % \end{macrocode}
4574 % 设置名字空间为 |#1|。\cls{l3doc} 中将名字空间称为“模块”(module),
4575 % 注意不要混淆。
4576 % \begin{macrocode}
4577 \tl_gset:Nn \g__codedoc_module_name_tl {#1}
4578 \@@_output_line:n {#2}
4579 }
4580 % \end{macrocode}
4581 % \end{macro}
4582 %
4583 % \begin{macro}{\@@_module_verb:w}
4584 % 抄录开始。|#1|: |<|\meta{end-tag},只有一个 |<|。\meta{end-tag} 的最后会
4585 % 带有一个回车符 |^^M|。
4586 % \begin{macrocode}
4587 \cs_new_protected:Npn \@@_module_verb:w #1 \q_stop
4588 {
4589 % \end{macrocode}
4590 % 重定义 \cs{@@_macro_code_process_line:},用以输出抄录行。
4591 % \begin{macrocode}
4592 \cs_gset_eq:NN \@@_macro_code_process_line:
4593 \@@_process_verbatim_line:
4594 % \end{macrocode}
4595 % 设置抄录停止标记。用 \cs{tl_tail:n} 去掉开头的 |<|。
4596 % \begin{macrocode}
4597 \tl_gset:Nx \g_@@_macro_code_verbatim_stop_tl
4598 { \c_percent_str \tl_tail:n {#1} }
4599 % \end{macrocode}
4600 % 输出 |%<<|\meta{end-tag}。
4601 % \begin{macrocode}
4602 \@@_output_module:nn
4603 { \color { verb@guard } }
4604 {
4605 \@@_swap_cr:
4606 \@@_module_push:n { \l_@@_macro_code_line_tl }
4607 }
4608 }
4609 % \end{macrocode}
4610 % \end{macro}
4611 %
4612 % \begin{macro}{\@@_module_pm:w}
4613 % 处理单独一行的模块。|<|\meta{module}|>| 放在行号的左侧。
4614 % \begin{arguments}
4615 % \item \meta{module}
4616 % \item 之后的代码
4617 % \end{arguments}
4618 % \begin{macrocode}
4619 \cs_new_protected:Npn \@@_module_pm:w #1 > #2 \q_stop
4620 {
4621 \@@_output_module_left:nn
4622 { \@@_pm_color: }
4623 { \@@_module_angle:n {#1} }
4624 \@@_output_line:n {#2}
4625 }
4626 \group_end:
4627 % \end{macrocode}
4628 % \end{macro}
4629 %
4630 % \begin{macro}{\@@_output_line:n,\@@_output_line:}
4631 % 输出代码行。参数将被存入 \cs{l_@@_macro_code_line_tl},
4632 % 再由不带参数的版本调用。
4633 % \begin{macrocode}
4634 \cs_new_protected:Npn \@@_output_line:n #1
4635 {
4636 \tl_set:Nn \l_@@_macro_code_line_tl {#1}
4637 % \end{macrocode}
4638 % 若为空行(只含一个 |^^M|),则直接输出(换行)。
4639 % \begin{macrocode}
4640 \tl_if_eq:NNTF
4641 \l_@@_macro_code_line_tl \c_@@_active_cr_tl
4642 { \tl_use:N \l_@@_macro_code_line_tl }
4643 {
4644 % \end{macrocode}
4645 % 检查开头是否为 |%|,据此分别处理。
4646 % \begin{macrocode}
4647 \str_if_eq:eeTF
4648 { \str_head:N \l_@@_macro_code_line_tl } { \c_percent_str }
4649 { \@@_output_comment_line: } { \@@_output_line: }
4650 }
4651 }
4652 \cs_new_protected_nopar:Npn \@@_output_line:
4653 {
4654 \tex_noindent:D
4655 % \end{macrocode}
4656 % 此处将把 |@@| 替换为相应的名字空间。
4657 % \begin{macrocode}
4658 \@@_replace_at_at:N \l_@@_macro_code_line_tl
4659 \tl_use:N \l_@@_macro_code_line_tl
4660 }
4661 % \end{macrocode}
4662 % \end{macro}
4663 %
4664 % \begin{macro}{\@@_output_comment_line:}
4665 % 输出注释代码行。用灰色、斜体显示。
4666 % \begin{macrocode}
4667 \cs_new_protected:Npn \@@_output_comment_line:
4668 {
4669 \tex_noindent:D
4670 \group_begin:
4671 \__hustdoc_swap_cr:
4672 \color { code@gray } \slshape \@@_output_line:
4673 \group_end:
4674 }
4675 % \end{macrocode}
4676 % \end{macro}
4677 %
4678 % \begin{macro}{\@@_replace_at_at:N,
4679 % \@@_replace_at_at_aux:Nn,\@@_replace_at_at_aux:No}
4680 % 把 |@@| 替换为相应的名字空间。其名称存放在全局变量
4681 % \cs{g__codedoc_module_name_tl} 中。它为空时(|%<@@=>|),不做替换。
4682 % \begin{macrocode}
4683 \cs_new_protected:Npn \@@_replace_at_at:N #1
4684 {
4685 \tl_if_empty:NF \g__codedoc_module_name_tl
4686 { \@@_replace_at_at_aux:No #1 \g__codedoc_module_name_tl }
4687 }
4688 \cs_new_protected:Npn \@@_replace_at_at_aux:Nn #1#2
4689 {
4690 % \end{macrocode}
4691 % 以下代码分别对应两种名字空间的替换:
4692 % \begin{itemize}
4693 % \item 内部变量:|\|\meta{type}|_@@_|\meta{name} $\to$
4694 % |\|\meta{type}|__|\meta{namespace}|_|\meta{name};
4695 % \item 内部函数:|\@@_|\meta{name}” $\to$
4696 % |\__|\meta{namespace}|_|\meta{name}”)。
4697 % \end{itemize}
4698 % \begin{macrocode}
4699 \tl_replace_all:Nnn #1 { _ @ @ } { _ _ #2 }
4700 \tl_replace_all:Nnn #1 { @ @ } { _ _ #2 }
4701 }
4702 \cs_generate_variant:Nn \@@_replace_at_at_aux:Nn { No }
4703 % \end{macrocode}
4704 % \end{macro}
4705 %
4706 % \begin{macro}{\@@_module_push:n,
4707 % \@@_module_push_aux:nn,\@@_module_push_aux:on}
4708 % 将模块名压入栈中。此处的栈主要用来处理模块名(包括抄录标记)之间的超链接。
4709 % \begin{macrocode}
4710 \cs_new_protected_nopar:Npn \@@_module_push:n
4711 { \@@_module_push_aux:on { \int_use:N \c@HD@hypercount } }
4712 \cs_new_protected:Npn \@@_module_push_aux:nn #1
4713 {
4714 \seq_gpush:Nn \g_@@_module_dest_seq {#1}
4715 \hypersetup { hidelinks }
4716 \exp_args:Nx \hdclindex
4717 { \zref@extractdefault { HD.#1 } { guard@end } { 1 } } { }
4718 }
4719 \cs_generate_variant:Nn \@@_module_push_aux:nn { on }
4720 % \end{macrocode}
4721 % \end{macro}
4722 %
4723 % \begin{macro}{\@@_module_pop:n,
4724 % \@@_module_pop_aux:nn,\@@_module_pop_aux:on}
4725 % 将模块名释放出栈。
4726 % \begin{macrocode}
4727 \cs_new_protected_nopar:Npn \@@_module_pop:n
4728 {
4729 \seq_gpop:NNTF \g_@@_module_dest_seq \l_@@_tmpa_tl
4730 { \@@_module_pop_aux:on { \l_@@_tmpa_tl } }
4731 { \BOOM \use:n }
4732 }
4733 \cs_new_protected:Npn \@@_module_pop_aux:nn #1
4734 {
4735 \zref@labelbylist { HD.#1 } { hustdoc }
4736 \hypersetup { hidelinks }
4737 \hdclindex {#1} { }
4738 }
4739 \cs_generate_variant:Nn \@@_module_pop_aux:nn { on }
4740 % \end{macrocode}
4741 % \end{macro}
4742 %
4743 % \begin{variable}{\g_@@_module_dest_seq}
4744 % 存放模块名的序列(栈)。
4745 % \begin{macrocode}
4746 \seq_new:N \g_@@_module_dest_seq
4747 % \end{macrocode}
4748 % \end{variable}
4749 %
4750 % 处理行号超链接。使用 \pkg{zref} 宏包。
4751 % \begin{macrocode}
4752 \zref@newlist { hustdoc }
4753 \zref@newprop { guard@end } [ 1 ]
4754 { \int_eval:n { \c@HD@hypercount - 1 } }
4755 \zref@addprop { hustdoc } { guard@end }
4756 % \end{macrocode}
4757 %
4758 % \subsubsection{格式处理}
4759 %
4760 % \begin{macro}[int]{\MacroFont}
4761 % 代码部分的字体。
4762 % \begin{macrocode}
4763 \cs_set_protected:Npn \MacroFont
4764 {
4765 \linespread { 1.05 }
4766 \small \ttfamily \mdseries \upshape
4767 }
4768 % \end{macrocode}
4769 % \end{macro}
4770 %
4771 % \begin{macro}{\@@_output_module:nn,\@@_output_module_left:nn}
4772 % 输出模块名(分行内和行号左侧两种)。
4773 % \begin{arguments}
4774 % \item 颜色等样式
4775 % \item 模块名
4776 % \end{arguments}
4777 % \begin{macrocode}
4778 \cs_new_protected:Npn \@@_output_module:nn #1#2
4779 {
4780 \tex_noindent:D
4781 \group_begin:
4782 #1
4783 \footnotesize \normalfont \sffamily #2
4784 \group_end:
4785 }
4786 \cs_new_protected:Npn \@@_output_module_left:nn #1#2
4787 {
4788 \tex_noindent:D
4789 \hbox_overlap_left:n
4790 {
4791 \@@_output_module:nn {#1} {#2}
4792 \skip_horizontal:n { \leftskip + \smallskipamount }
4793 }
4794 }
4795 % \end{macrocode}
4796 % \end{macro}
4797 %
4798 % \begin{macro}{\@@_star_color:,\@@_slash_color:,\@@_pm_color:}
4799 % 选择模块标记的颜色。模块标记的颜色会根据嵌套层次而改变。
4800 % \begin{macrocode}
4801 \cs_new_protected_nopar:Npn \@@_star_color:
4802 {
4803 \seq_gpop:NNTF \g_@@_star_color_seq \current@color
4804 { \set@color }
4805 { \@@_select_color: }
4806 \seq_gpush:No \g_@@_slash_color_seq { \current@color }
4807 }
4808 \cs_new_protected_nopar:Npn \@@_slash_color:
4809 {
4810 \seq_gpop:NNTF \g_@@_slash_color_seq \current@color
4811 {
4812 \set@color
4813 \seq_gpush:No \g_@@_star_color_seq { \current@color }
4814 }
4815 % TODO: 需要报错:star 与 slash 没有匹配
4816 { \BOOM }
4817 }
4818 \cs_new_protected_nopar:Npn \@@_pm_color:
4819 {
4820 \seq_get:NNTF \g_@@_star_color_seq \current@color
4821 { \set@color }
4822 {
4823 \@@_select_color:
4824 \seq_gpush:No \g_@@_star_color_seq { \current@color }
4825 }
4826 }
4827 % \end{macrocode}
4828 % \end{macro}
4829 %
4830 % \begin{variable}{\g_@@_star_color_seq,\g_@@_slash_color_seq}
4831 % 存放模块标记颜色的序列。
4832 % \begin{macrocode}
4833 \seq_new:N \g_@@_star_color_seq
4834 \seq_new:N \g_@@_slash_color_seq
4835 % \end{macrocode}
4836 % \end{variable}
4837 %
4838 % \begin{macro}{\@@_select_color:}
4839 % \begin{macro}[int]{guard@series}
4840 % 设置模块标记的色系。
4841 % \begin{macrocode}
4842 \cs_new_protected_nopar:Npn \@@_select_color:
4843 { \color { guard@series!!+ } }
4844 \definecolorseries { guard@series }
4845 { cmyk } { last } { blue } { purple }
4846 % \end{macrocode}
4847 % \end{macro}
4848 % \end{macro}
4849 %
4850 % 设置色系的增量大小。可选参数 |3| 意味着基色(blue)与末色(purple)之间将被
4851 % 等分为三份。该数字比嵌套最大深度小 1。
4852 % \begin{macrocode}
4853 \resetcolorseries [ 3 ] { guard@series }
4854 % \end{macrocode}
4855 %
4856 % \begin{macro}[int]{verb@guard,at@guard,code@gray}
4857 % 设置颜色。
4858 % \begin{macrocode}
4859 \definecolor { verb@guard } { named } { MaterialLime600 }
4860 \definecolor { at@guard } { named } { MaterialPink }
4861 \definecolor { code@gray } { named } { MaterialGrey }
4862 % \end{macrocode}
4863 % \end{macro}
4864 %
4865 % \begin{macro}{\@@_module_angle:n}
4866 % 输出“$\langle\cdots\rangle$”。
4867 % \begin{macrocode}
4868 \cs_new_protected:Npn \@@_module_angle:n #1
4869 { < #1 > }
4870 % { \textlangle #1 \textrangle }
4871 % { \ensuremath \langle #1 \ensuremath \rangle }
4872 % \end{macrocode}
4873 % \end{macro}
4874 %
4875 % \begin{macro}{\@@_code_line_no:}
4876 % 行号。设置为阿拉伯数字。
4877 % \begin{macrocode}
4878 \cs_new_protected_nopar:Npn \@@_code_line_no:
4879 {
4880 \int_gincr:N \c@CodelineNo
4881 \hbox_overlap_left:n
4882 {
4883 \hbox_to_wd:nn
4884 { \MacroIndent }
4885 {
4886 \HD@target
4887 \tex_hss:D \@@_code_line_no_style:
4888 \theCodelineNo \enspace
4889 }
4890 \tex_kern:D \@totalleftmargin
4891 }
4892 }
4893 \tl_set:Nn \theCodelineNo { \arabic { CodelineNo } }
4894 % \end{macrocode}
4895 % \end{macro}
4896 %
4897 % \begin{macro}{\@@_code_line_no_style:}
4898 % 行号格式。
4899 % \begin{macrocode}
4900 \cs_new_protected_nopar:Npn \@@_code_line_no_style:
4901 { \color { code@gray } \normalfont \sffamily \tiny }
4902 % \end{macrocode}
4903 % \end{macro}
4904 %
4905 % \begin{macro}[int]{\HD@SetMacroIndent}
4906 % 设置代码缩进(行号一栏的宽度)。该命令会写进 |.aux| 辅助文件,
4907 % 以便在二次编译时确定最大行号宽度。
4908 % \begin{macrocode}
4909 \cs_set_protected:Npn \HD@SetMacroIndent #1
4910 {
4911 \group_begin:
4912 \settowidth \MacroIndent
4913 {
4914 \@@_code_line_no_style:
4915 \prg_replicate:nn { \tl_count:n {#1} } { 0 }
4916 \enspace
4917 }
4918 \dim_gset_eq:NN \MacroIndent \MacroIndent
4919 \group_end:
4920 }
4921 % \end{macrocode}
4922 % \end{macro}
4923 %
4924
4925 % \subsection{修订记录}
4926 %
4927 % \begin{macro}{\@@_ltx_changes:nnn}
4928 % 保存 \pkg{doc} 中 \tn{changes@} 的定义。
4929 % \begin{macrocode}
4930 \cs_new_eq:NN \@@_ltx_changes:nnn \changes@
4931 % \end{macrocode}
4932 % \end{macro}
4933 %
4934 % \begin{macro}[int]{\changes@}
4935 % 重定义 \tn{changes@},在版本号一行显示修改日期。
4936 % \begin{macrocode}
4937 \cs_set_protected:Npn \changes@ #1#2
4938 {
4939 \@@_save_version_date:nn {#1} {#2}
4940 \@@_ltx_changes:nnn {#1} {#2}
4941 }
4942 % \end{macrocode}
4943 % \end{macro}
4944 %
4945 % \begin{variable}{\g_@@_version_date_prop}
4946 % 存放版本号与对应的修改日期。其中键为版本号,值为 |{开始日期,结束日期}|。
4947 % 开始日期与结束日期可以相同。
4948 % \begin{macrocode}
4949 \prop_new:N \g_@@_version_date_prop
4950 % \end{macrocode}
4951 % \end{variable}
4952 %
4953 % \begin{macro}{\@@_save_version_date:nn}
4954 % |nn| 版本最终将被 \tn{changes@} 调用。
4955 % \begin{arguments}
4956 % \item 版本号
4957 % \item 日期
4958 % \end{arguments}
4959 % 它们分别对应 \tn{change} 的前两个参数(第三个是说明文字)。
4960 % \begin{macrocode}
4961 \cs_new_protected:Npn \@@_save_version_date:nn #1#2
4962 {
4963 \prop_get:NnNTF \g_@@_version_date_prop
4964 {#1} \l_@@_tmpa_tl
4965 {
4966 % \end{macrocode}
4967 % \cs{l_@@_tmpa_tl} 相当于两个参数(开始日期、结束日期),因此需要提前展开。
4968 % \begin{macrocode}
4969 \exp_after:wN
4970 \@@_save_version_date_aux:nnnn \l_@@_tmpa_tl
4971 {#2} {#1}
4972 }
4973 { \@@_save_version_date_aux:nnn {#1} {#2} {#2} }
4974 }
4975 % \end{macrocode}
4976 % \end{macro}
4977 %
4978 % \begin{macro}{\@@_save_version_date_aux:nnnn}
4979 % \begin{arguments}
4980 % \item 原开始日期
4981 % \item 原结束日期(显然应有 |#1| < |#2|)
4982 % \item 新读入的日期
4983 % \item 版本号
4984 % \end{arguments}
4985 % 如果 |#3| < |#1|,则读入日期 |#3|、|#2|;
4986 % 如果 |#3| > |#2|,则读入日期 |#1|、|#3|。
4987 % \begin{macrocode}
4988 \cs_new_protected:Npn \@@_save_version_date_aux:nnnn #1#2#3#4
4989 {
4990 \@@_if_date_later:nnTF {#1} {#3}
4991 { \@@_save_version_date_aux:nnn {#4} {#3} {#2} }
4992 {
4993 \@@_if_date_later:nnT {#3} {#2}
4994 { \@@_save_version_date_aux:nnn {#4} {#1} {#3} }
4995 }
4996 }
4997 % \end{macrocode}
4998 % \end{macro}
4999 %
5000 % \begin{macro}{\@@_save_version_date_aux:nnn}
5001 % 将版本号和日期存入 \cs{g_@@_version_date_prop}。
5002 % \begin{arguments}
5003 % \item 版本号
5004 % \item 开始日期
5005 % \item 结束日期
5006 % \end{arguments}
5007 % \begin{macrocode}
5008 \cs_new_protected:Npn \@@_save_version_date_aux:nnn #1#2#3
5009 { \prop_gput:Nnn \g_@@_version_date_prop {#1} { {#2} {#3} } }
5010 % \end{macrocode}
5011 % \end{macro}
5012 %
5013 % \begin{macro}[TF]{\@@_if_date_later:nn}
5014 % \begin{macro}{\@@_parse_date:w}
5015 % 比较两个日期。如果 |#1| 在 |#2| 之后,则为 |true|;反之为 |false|。
5016 % 日期的格式为 |YYYY-MM-DD|。比较方法是直接将日期化成 8 位数字,
5017 % 所以月、日前的 0 不可以省略。
5018 % \begin{macrocode}
5019 \prg_new_conditional:Npnn \@@_if_date_later:nn #1#2 { TF, T }
5020 {
5021 \if_int_compare:w
5022 \@@_parse_date:w #1 / / / 0 \q_stop >
5023 \@@_parse_date:w #2 / / / 0 \q_stop \exp_stop_f:
5024 \prg_return_true:
5025 \else:
5026 \prg_return_false:
5027 \fi:
5028 }
5029 \cs_new:Npn \@@_parse_date:w #1-#2-#3/ #4 \q_stop
5030 { #1#2#3 }
5031 % \end{macrocode}
5032 % \end{macro}
5033 % \end{macro}
5034 %
5035 % \begin{macro}[int]{\CTEX@versionitem}
5036 % 版本条目标签。如果版本号不在 \cs{g_@@_version_date_prop} 里面,
5037 % 则利用未定义的 \cs{BOOM} 报错。
5038 % \begin{macrocode}
5039 \cs_new_protected:Npn \CTEX@versionitem #1 \efill
5040 {
5041 \@idxitem
5042 \prop_get:NnNTF \g_@@_version_date_prop
5043 {#1} \l_@@_tmpa_tl
5044 {
5045 \exp_after:wN
5046 \@@_print_version_date:nnn \l_@@_tmpa_tl
5047 {#1}
5048 }
5049 { \BOOM }
5050 }
5051 % \end{macrocode}
5052 % \end{macro}
5053 %
5054 % \begin{macro}{\@@_print_version_date:nnn}
5055 % 输出版本号和日期。如果开始日期和结束日期相同,则只输出一项。
5056 % \begin{arguments}
5057 % \item 开始日期
5058 % \item 结束日期
5059 % \item 版本号
5060 % \end{arguments}
5061 % \begin{macrocode}
5062 \cs_new_protected:Npn \@@_print_version_date:nnn #1#2#3
5063 {
5064 \noindent
5065 \Hy@raisedlink { \belowpdfbookmark {#3} { HD.#3 } }
5066 \textbf {#3} \hfill
5067 \hbox:n
5068 {
5069 \footnotesize
5070 \str_if_eq:nnTF {#1} {#2}
5071 { ( #1 ) } { ( #1 \c_space_tl \c_tilde_str \c_space_tl #2 ) }
5072 }
5073 \par \nopagebreak
5074 }
5075 % \end{macrocode}
5076 % \end{macro}
5077 %
5078 % \begin{macro}[int]{\HDorg@theglossary}
5079 % 该命令由 \pkg{hypdoc} 宏包定义,用于存放标准文档类 \cls{book} 中定义的
5080 % \tn{theindex} 命令。此处的补丁将在版本号一行最后加上修改日期。
5081 % \begin{macrocode}
5082 \ctex_patch_cmd:Nnn \HDorg@theglossary
5083 { \let \item \@idxitem }
5084 { \let \item \CTEX@versionitem }
5085 % \end{macrocode}
5086 % \end{macro}
5087 %
5088 % \begin{macro}[int]{\@wrglossary}
5089 % 该命令由 \LaTeXe{} 内核定义,又由 \pkg{hypdoc} 宏包作了修改。
5090 % 此处的补丁使得修订记录条目的页码能够指向对应行。
5091 % \begin{macrocode}
5092 \ctex_patch_cmd:Nnn \@wrglossary
5093 { hdpindex }
5094 {
5095 \ifnum \c@HD@hypercount = \z@
5096 hdpindex
5097 \else
5098 hdclindex { \the \c@HD@hypercount }
5099 \fi
5100 }
5101 % \end{macrocode}
5102 % \end{macro}
5103 %
5104 % \begin{macrocode}
5105 %</doc-sty>
5106 % \end{macrocode}
5107 %
5108 % \end{implementation}