forked from HKFoggyU/hkust-thesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhkustthesis.dtx
1749 lines (1735 loc) · 60.5 KB
/
hkustthesis.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
% !TeX program = XeLaTeX
% !TeX encoding = UTF-8
%
% Copyright (C) 2021
% by <HKFoggyU> @ GitHub
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version. The latest version
% of this license is in the file
%
% https://www.latex-project.org/lppl.txt
%
% -----------------------------------------------------------------------
%
% The development version of the template can be found at
%
% https://github.com/HKFoggyU/hkust-thesis
%
% for those people who are interested.
%
%<*internal>
\iffalse
%</internal>
%
%<*internal>
\fi
\begingroup
\def\NameOfLaTeXe{LaTeX2e}
\expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else
\csname fi\endcsname
%</internal>
%
%<*install>
\input l3docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
Copyright (C) 2021
by <HKFoggyU> @ GitHub
This file may be distributed and/or modified under the conditions of
the LaTeX Project Public License, either version 1.3 of this license
or (at your option) any later version. The latest version of this
license is in:
http://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of LaTeX version
2005/12/01 or later.
To produce the documentation run the original source files ending with `.dtx'
through XeTeX.
\endpreamble
\generate{
\usedir{tex/latex/hkustthesis}
\file{\jobname.cls} {\from{\jobname.dtx}{class}}
%</install>
%<*internal>
\usedir{source/latex/hkustthesis}
\file{\jobname.ins} {\from{\jobname.dtx}{install}}
%</internal>
%<*install>
}
\obeyspaces
\Msg{**************************************************************}
\Msg{* *}
\Msg{* To finish the installation you have to move the following *}
\Msg{* files into a directory searched by TeX: *}
\Msg{* *}
\Msg{* The recommended directory is TDS:tex/latex/hkustthesis *}
\Msg{* *}
\Msg{* hkustthesis.cls *}
\Msg{* hkustthesis.ins *}
\Msg{* *}
\Msg{* To produce the documentation, run the file hkustthesis.dtx *}
\Msg{* through XeLaTeX. *}
\Msg{* *}
\Msg{* Happy TeXing! *}
\Msg{* *}
\Msg{**************************************************************}
\endbatchfile
%</install>
%
%<*internal>
\fi
%</internal>
%
%<class>\NeedsTeXFormat{LaTeX2e}
%<class>\RequirePackage{expl3}
%<class>\GetIdInfo $Id: hkustthesis.dtx 0.4 2021-10-28 00:00:00 +0800 HKFoggyU$
%<class> { Thesis template for HKUST }
%<class>\ProvidesExplClass{hkustthesis}
%<class>{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
%
%<*driver>
\ProvidesFile{hkustthesis.dtx}
\documentclass[12pt]{ctxdoc}
\usepackage{float,footnote,listings,soul,xcolor,tabularray}
\setlist[1]{labelindent=0.5em}
\UseTblrLibrary{booktabs,siunitx,diagbox}
\DefTblrTemplate{caption-tag}{default}{Table~\hspace{0.25em}\thetable}
\SetTblrStyle{caption-tag}{font=\bfseries}
\DefTblrTemplate{caption-sep}{default}{\quad}
\definecolor{hkustblue}{RGB}{0, 51, 102}
\definecolor{hkustgold}{RGB}{153, 102, 0}
\definecolor{hkustred}{RGB}{237, 27, 47}
\definecolor{hkustgray}{RGB}{204, 204, 204}
\definecolor{hkustviolet}{RGB}{124, 35, 72}
\definecolor{hkustyellow}{RGB}{255, 212, 0}
\DoNotIndex{\\}
\begin{document}
\DocInput{hkustthesis.dtx}
\clearpage
\PrintChanges
\clearpage
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \def\twodigits#1{\ifnum#1<10 0\fi\the#1}
% \def\dashedtoday{\leavevmode\hbox{\the\year-\twodigits\month-\twodigits\day}}
%
% \title{\color{hkustblue}{The \textsc{HkustThesis} class\\ A \hologo{LaTeX}\textcolor{hkustred}{3} template}}
%
% \author{HKFoggyU}
%
% \date{v0.7.0\\Released \dashedtoday\\{\footnotesize 请确保阅读本文档的\href{https://github.com/HKFoggyU/hkust-thesis/releases}{最新版本}}}
%
% \changes{v0.1}{2021/10/21}{Start development based on \href{https://github.com/nju-lug/NjuThesis}{\textsc{NjuThesis}} class}
% \changes{v0.2}{2021/10/24}{Typesett page stye before main body}
% \changes{v0.3}{2021/10/26}{Change \pkg{cref} settings; add some doc}
% \changes{v0.4}{2021/10/27}{Change theorem environment; make the title name of paperlist customizable}
% \changes{v0.4.1}{2021/10/29}{Add documentation for preamble}
% \changes{v0.4.2}{2021/10/31}{Complete documentation}
% \changes{v0.4.3}{2021/11/01}{Fix typos in documentation}
% \changes{v0.5}{2021/11/05}{Add optional TEC list}
% \changes{v0.5.3}{2021/11/06}{Update documentation about TEC list}
% \changes{v0.5.4}{2021/11/08}{Fix loop ending condition for TEC list}
% \changes{v0.6}{2021/11/09}{Update line spacing according to GS, change to oneside, fine tune signature page for different cases}
% \changes{v0.6.1}{2021/11/09}{Fix TEC external examiner problem}
% \changes{v0.6.2}{2021/11/10}{Fix bm conflicts, merge supervisor title into name, update docs}
% \changes{v0.6.3}{2021/11/17}{Change to Co-supervisor, remove supervisor tile name, optimize code performance and style}
% \changes{v0.7.0}{2021/11/23}{cref format issue, bib style, docs and logo}
%
% {
% \phantomsection
% \addcontentsline{toc}{section}{封面}
% \maketitle
% }
%
% \def\abstractname{简介}
% \begin{abstract}
% \textsc{HkustThesis} 文档类 (class) 意在为香港科技大学 (HKUST) 的研究型硕士 (MPhil) 和博士 (PhD) 生提供一个尽可能符合 \href{https://rpghandbook.hkust.edu.hk/}{RPG Handbook} 要求的毕业论文\hologo{LaTeX}模板。
% \end{abstract}
%
% \vspace{2\baselineskip}
% \def\abstractname{免责声明}
% \begin{abstract}
% 本模板并非官方模板。事实上,除极个别系外,由于 RPG Handbook 的要求,并不存在官方模板。
% 本模板对潜在的漏洞或与 RPG Handbook 的要求不符的情况不负任何责任。
% 本模板仍在开发中,请从本项目的 \href{https://github.com/HKFoggyU/hkust-thesis/}{GitHub 仓库} 获取更新。
% \end{abstract}
%
% \vspace{2\baselineskip}
% \def\abstractname{致谢}
% \begin{abstract}
% 本项目由 \href{https://github.com/nju-lug/NjuThesis}{\textsc{NjuThesis}} 项目修改而来,并得到了 \href{https://github.com/nju-lug}{NJU LUG} 的帮助。
% \end{abstract}
%%
% \clearpage
%
% \setcounter{tocdepth}{4}
% \tableofcontents
% \clearpage
%
% \EnableDocumentation
%^^A \DisableDocumentation
%
% \begin{documentation}
%
% \section{模板介绍}
% \textsc{HkustThesis}是由GitHub组织 \href{https://github.com/HKFoggyU}{@HKFoggyU} 维护的用于香港科技大学研究型硕士和博士生毕业论文排版的\hologo{LaTeX}模板。
%
% \subsection{动机}
% GitHub上已有数个由热心校友(包括但不限于@wenbinf、@onlytailei、@fcyu、@cheedoong)制作的毕业论文\hologo{LaTeX}模板。这些模板均由\hologo{LaTeX2e}语法编写,大部分编写时间久远,缺少必要的文档,鲜有后续更新和维护。
%
%随着时代的进步,更加清晰简明的\hologo{LaTeX3}大大提高了模板的易读性与可维护性。因此,HKFoggyU的成员决定通过\hologo{LaTeX3}语法、参考已有的优秀项目,合作编写并维护一个全新的毕业论文模板。
%
% \subsection{文档结构}
% 本文档的前半部分为用户手册,供使用本模板撰写毕业论文的同学们参考,请仔细阅读;后半部分 (第\ref{sec:implementation}节) 为开发手册,供有意了解或贡献源码的同学参考,普通用户无需阅读。
%
% \section{工欲善其事,必先利其器}
% 有\hologo{LaTeX}基础的用户可以跳过本节。
%
% \subsection{\hologo{LaTeX}入门}
% 本节不会从\hologo{LaTeX}是什么开始讲起。授人以鱼不如授人以渔,本节将更侧重从0入门\hologo{LaTeX}的方法而非具体实现。
%
% 首先,尽量避免对 ``写代码'' 这件事产生抗拒心理。对于绝大多数用户而言,\hologo{LaTeX} 就是一个排版工具,只是用代码来实现,它不比常见的 Word、Photoshop 更难入门。只要认真阅读本文档,一定可以学会。
%
% ``\emph{吾生也有涯,而知也无涯。}''
% 作为一个已经被广泛应用数十年的排版工具,\hologo{LaTeX}的学习、参考资料可以说是浩如烟海。因此,掌握在繁杂的资料中找到问题解决方案的能力比通读各种\hologo{LaTeX}教程更加重要。
%
% 学会使用搜索引擎和技术论坛(如Stack Overflow、LaTeX.org)将大大减少耗费在debug上的时间。
%
% 在中文资料中,北京大学刘海洋的《\hologo{LaTeX}入门》、复旦大学曾祥东的\href{https://github.com/stone-zeng/latex-talk}{《现代\hologo{LaTeX}入门讲座》} 都是非常优秀的。如果觉得书籍难以下咽,不妨抽出3个小时看完本项目 \file{README} 提及的刘海洋的\href{https://www.bilibili.com/video/BV1s7411U7Pr}{视频讲座}。
%
% 结合以上两点,一个初学者就已经具备使用本模板的能力。
%
% \subsection{\hologo{LaTeX}环境}
% 本模板要求的\hologo{LaTeX}发行版为最新版的\hologo{TeXLive} (2021) 或\hologo{MiKTeX}。尽管某些低版本的发行版可以编译通过,但可能存在一些未被发现的问题。
%
% 本模板在各平台、各\hologo{LaTeX}发行版上的编译情况如表 (\ref{tab:environment}) 所示。
%
% \begin{table}[ht]
% \caption{不同平台测试结果}
% \label{tab:environment}
% \centering
% \begin{tabular}{lll}
% \toprule
% Platform & TeX & Test \\
% \midrule
% Overleaf & \hologo{TeX}\,Live 2021 & Pass \\
% Windows 10 & \hologo{TeX}\,Live 2021 & Pass \\
% Windows 10 & \hologo{MiKTeX} 4.4 & Pass \\
% Windows 10 & \hologo{TeX}\,Live 2020 & \verb|ltxhook| problem \\
% macOS 10.15 & \hologo{TeX}\,Live 2021 & Pass \\
% Ubuntu 20.04 & \hologo{TeX}\,Live 2021 & Pass \\
% Ubuntu 20.04 & \hologo{MiKTeX} 4.2.1 & Failed \\
% Termux & \hologo{TeX}\,Live 2021 & Pass \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% 如果本地尚未安装任何\hologo{LaTeX}发行版,那么 \href{https://www.overleaf.com/}{Overleaf} 是作为入门的很好选择。\textbf{强烈建议初学者从 Overleaf 入门,可以避免学习热情被安装配置环境所熄灭。}\\
% 当然,如果希望离线工作,请在上述发行版中选择一个,到其官网下载最新版本的安装程序并安装。
% \begin{itemize}
% \item \href{https://www.tug.org/texlive/}{\hologo{TeXLive}} (macOS 用户请下载对应的 \href{https://www.tug.org/mactex/mactex-download.html}{Mac\hologo{TeX}})
% \item \href{https://miktex.org/download}{\hologo{MiKTeX}}
% \end{itemize}
%
% \subsection{获取本模板}
% \begin{itemize}
% \item (推荐) 请在本项目的 \href{https://github.com/HKFoggyU/hkust-thesis/releases/latest}{GitHub Release} 页面下载本模板最新版本,名为 \file{hkust-thesis-v*.zip} 的压缩文件。
% \item (不推荐) 如果希望获取第一时间的更新,可以克隆本项目仓库,并运行
% \begin{ctexexam}
% xetex hkustthesis.dtx
% \end{ctexexam}
% 生成 \file{hkustthesis.cls} 文件,用于编译。
% \end{itemize}
%
% \subsection{编辑器}
% 本小节仅针对本地编译的用户。Overleaf 用户可以在浏览器内完成工作,无需安装编辑器。
%
% 本文档无意参与 ``什么是世界上最好的编辑器'' 这类争论。对于初学者,建议使用 Visual Studio Code 配合 LaTeX Workshop 插件以获得良好的编辑体验。你可以在\href{https://itxia.github.io/soft/post/ConfigVSCode/}{这里}找到一份 (年久失修但问题不大的) 安装和配置教程。
%
% 除此之外,支持热重载的 PDF 阅读器如 \href{https://www.sumatrapdfreader.org/download-free-pdf-viewer}{Sumatra PDF} 也是一个常用的工具。
%
% \section{编译}
%
% 复读:强烈建议初学者使用 Overleaf 入门。可以先试一次,如果觉得浏览器不方便,再本地安装也不迟。
%
% \subsection{在线编译:使用 Overleaf}
% \begin{enumerate}
% \item 将下载得到的 \file{hkust-thesis-v*.zip} 文件上传到 Overleaf 网站。上传完毕后将自动进入该项目页面。
% \item 点击左上方 ``Menu/菜单'' 按钮,在 ``settings/设置'' 中选择如下设置:
% \begin{itemize}
% \item Compiler: XeLaTeX
% \item TeX Live version: 2021
% \end{itemize}
% \item 返回项目页面,点击 `` Compile/编译 '' 按钮进行编译。
% \end{enumerate}
%
% \subsection{本地编译}
% \subsubsection{VSCode}
% 本项目提供了一份 VSCode 配置文件 \file{.vscode/settings.json}。在安装了 LaTeX Workshop 插件的 VSCode 中的 \hologo{TeX} 侧栏选择 ``build recipe'' 为 ``build_mythesis'' 即可进行编译。
%
% 下面提供了几种其它编译方式。对于初学者,推荐使用 VSCode 编译。
%
% \subsubsection{latexmk}
% 本项目提供了一个定制的 \file{latexmkrc} 配置文件以进行自动化构建。分别运行
% \begin{ctexexam}
% latexmk
% latexmk -c
% \end{ctexexam}
% 以进行编译和删除编译中间产物。
%
% \subsubsection{Make}
% 本项目提供了一个 \file{Makefile}。分别运行
% \begin{ctexexam}
% make
% make clean
% \end{ctexexam}
% 以进行编译和删除编译中间产物。
%
% \subsubsection{\hologo{XeLaTeX}手动编译}
% \begin{ctexexam}
% xelatex mythesis.tex
% biber mythesis
% xelatex mythesis.tex
% xelatex mythesis.tex
% \end{ctexexam}
%
% \section{撰写论文}\label{sec:fileContents}
%
% \subsection{文件结构}
%
% 下载得到的压缩文件内部的文件结构应如表 (\ref{tab:fileStruture}) 所示。其中 \file{figures/} 文件夹如不存在请自行创建。
%
% \begin{table}[H]
% \caption{\cls{hkustthesis}文件结构}
% \label{tab:fileStruture}
% \centering
% \begin{tabular}{lll}
% \toprule
% 文件名 & 类型 & 说明 \\
% \midrule
% \file{.vscode/} & 文件夹 & VSCode 配置文件夹 \\
% \color{hkustgold}\file{chapters/} & 文件夹 & 存放论文各章节 \\
% \color{hkustgold}\file{figures/} & 文件夹 & 存放论文所用图片 \\
% \file{hkustthesis.cls} & 文件 & 模板文档类 \\
% \file{latexmkrc} & 文件 & latexmk 配置文件 \\
% \file{LICENSE} & 文件 & 许可证 \\
% \color{hkustgold}\file{mythesis.bib} & 文件 & 存放论文所用参考文献 \\
% \color{hkustgold}\file{mythesis.tex} & 文件 & 论文主文件 \\
% \file{README.md} & 文件 & 自述文件 \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% 各文件(夹)的作用已经给出。对于使用本模板撰写毕业论文的用户,只需要修改表 (\ref{tab:fileStruture}) 中\textcolor{hkustgold}{金色的文件}。
%
% \subsection{主文件介绍}
% \file{mythesis.tex}是本模板的 \hologo{TeX} 主文件。下面将给出主文件内容的解释。
%
% \subsubsection{模板选项}
% 模板选项是 \verb|\documentclass[]{hkustthesis}| 中方括号 \verb|[]| 内的选项。
%
% 本模板定义了3个模板选项:
%
% \begin{function}{customlatinfont}
% \begin{syntax}
% customlatinfont = <windows|macos|gyre|none>
% \end{syntax}
% 自定义西文字体。
% \end{function}
% 该选项默认被 \verb|%| 注释掉,使模板可以在不同平台上自动选择对应的字体 (不同选项使用的字体如表 (\ref{tab:latinfontset}) 所示)。
% 如果用户希望该模板在所有平台上都使用同样的字体(前提是所用字体存在),可以取消该行注释并修改为希望使用的选项。
% 如果用户希望完全由自己设定字体,则可以填 \opt{none},再通过 \pkg{fontspec} 宏包手动设置字体。
% \begin{table}[htbp]
% \centering
% \caption{西文字体清单}
% \label{tab:latinfontset}
% \begin{tabular}{llll}
% \toprule
% 选项 & 衬线体 & 无衬线体 & 等宽字体 \\
% \midrule
% windows & Times~New~Roman & Arial & Courier~New \\
% macos & Times~New~Roman & Arial & Menlo \\
% gyre & \Hologo{TeX}~Gyre~Termes & \Hologo{TeX}~Gyre~Heros & \Hologo{TeX}~Gyre~Cursor \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \begin{function}{custombibstyle}
% \begin{syntax}
% custombibstyle = <(ieee)|nature|science|apa|mla|phys|chem-acs|nejm>
% \end{syntax}
% 自定义参考文献条目样式。
% \end{function}
% 该选项默认被 \verb|%| 注释掉。\opt{ieee} 为默认样式。如果希望使用的样式不在此列表,可以阅读 \pkg{biblatex} 的文档并自行修改模板代码。
%
% \begin{function}{displaycommittee}
% \begin{syntax}
% displaycommittee = <(false)|true>
% \end{syntax}
% 设置是否在签名页显示答辩委员会成员列表。
% \end{function}
% 该选项默认被 \verb|%| 注释掉,因为 RPG Handbook 提供的示例签名页没有要求列出答辩委员会成员。
% 但某些院系 (如 ECE) 要求在签名页显示答辩委员会成员列表,则需要取消该行注释并设置为 \verb|true|,以及需要在下文提及的 \opt{reviewer}、\opt{reviewerdept} 和 \opt{reviewerext} 选项中填写委员会成员信息。
%
% \subsubsection{论文信息}
%
% \begin{function}{\hkustsetup}
% \begin{syntax}
% \tn{hkustsetup}\Arg{键值列表}
% \end{syntax}
% 论文必要信息。
% \end{function}
% 此选项的内容是以英文逗号 \verb|,| 分隔的键值列表,定义了该论文的必要信息。每一项等号左边为变量名,右边为由花括号 \verb|{}| 包裹的变量值。如果某一项的值不需要填,可以留空,但花括号仍建议保留。
%
% 其中标为\textcolor{hkustblue}{蓝色的选项}为可选填项。如果没有必要,可以留空。同理,标为\textcolor{hkustblue}{蓝色的文字}为可选阅读项,只有填写可选项的用户才需要阅读。
%
% \begin{function}{degree}
% \begin{syntax}
% degree = \Arg{phd|mphil}
% \end{syntax}
% 学位。
% \end{function}
%
% \begin{function}{title}
% \begin{syntax}
% title = \Arg{论文标题}
% \end{syntax}
% 论文标题。
% \end{function}
%
% \begin{function}{keywords, grade, student-id}
% \begin{syntax}
% \textcolor{hkustblue}{keywords} = \Arg{关键词}
% \textcolor{hkustblue}{grade} = \Arg{年级}
% \textcolor{hkustblue}{student-id} = \Arg{学号}
% \end{syntax}
% 关键词列表、年级、学号。关键词列表同样以英文逗号分隔。
% \end{function}
%
% \begin{function}{author}
% \begin{syntax}
% author = \Arg{作者}
% \end{syntax}
% 作者。
% \end{function}
%
% \begin{function}{school, department, program, major}
% \begin{syntax}
% \textcolor{hkustblue}{school} = \Arg{学院}
% department = \Arg{系/部门}
% program = \Arg{项目名称}
% \textcolor{hkustblue}{major} = \Arg{专业}
% \end{syntax}
% 学院。\\
% 系/部门的全名。需填写为 ``Department/Division of XXX''。\\
% 项目名称。请参考 SIS 中的 ``name of program''。多数情况下应和系/部门名相同。\\
% 专业方向。请参考 SIS 中的 ``major''。
% \end{function}
%
% \begin{function}{supervisor, co-supervisor}
% \begin{syntax}
% supervisor = \Arg{导师头衔姓名}
% co-supervisor = \Arg{联培导师头衔姓名}
% \end{syntax}
% 导师信息。如无Co-supervisor,可以留空。
% \end{function}
%
% \begin{function}{submit-month, submit-date, defend-date}
% \begin{syntax}
% submit-month = \Arg{论文提交年月}
% submit-date = \Arg{论文提交日期}
% defend-date = \Arg{论文答辩日期}
% \end{syntax}
% 提交时间和答辩时间。其中,\opt{submit-month} 请只填写 ``月~年'',而 \opt{submit-date} 和 \opt{defend-date} 请填写 ``日~月~年''。
% \end{function}
%
% \begin{function}{depthead, reviewer, reviewerdept, reviewerext}
% \begin{syntax}
% depthead = \Arg{系/部门主任}
% \textcolor{hkustblue}{reviewer} = \Arg{答辩委员会成员}
% \textcolor{hkustblue}{reviewerdept} = \Arg{答辩委员会成员所属机构}
% \textcolor{hkustblue}{reviewerext} = \Arg{答辩委员会外部成员}
% \end{syntax}
% 签名页信息。\\
% 其中,\opt{depthead} 的值需要包括 ``, Head of Department/Division'',如\\
% \verb|depthead = {Prof. XXX, Head of Department}|。\\
% 关于\textcolor{hkustblue}{答辩委员会}:\\
% 某些院系会要求在签名页列出答辩委员会成员列表,此时需要确保上文提及的 \opt{displaycommittee} 选项设置为 \opt{true},然后填写 \opt{reviewer}、\opt{reviewerdept}选项,PhD 还需要填写 \opt{reviewerext}选项。通常来讲,MPhil 答辩委员会需要4名成员,PhD 答辩委员会需要6名成员 (含1名外部成员)。\\
% \textcolor{hkustblue}{\textbf{注意:}} \opt{reviewer} 和 \opt{reviewerdept} 中的每个条目之间需要使用英文逗号分隔;但如果某一条目的部分内容里包含英文逗号,比如 \opt{reviewerext} 中的外部大学名称,则需要用花括号将那一整个部分包裹,否则 \hologo{LaTeX} 程序会在逗号处截断,将其当作两个条目。详见下文给出的示例中的 \opt{reviewerext} 的写法。\\
% \textcolor{hkustblue}{\textbf{注意:}} 根据 ECE 系提供的签名页,PhD的答辩委员会中的 ``External Examiner'' 所属机构的 ``Department'' 和 ``University'' 之间的换行符 \verb|\\| 不能删去,否则会使得对齐出错。如果确实没有第二行内容,可以在 \verb|\\| 后使用 \verb|\phantom{xxx}| 作为占位 (这个命令会占据与 \verb|xxx| 同样大小的空间但不实际显示)。\\
% TODO: \st{add TEC name list on signature page?} Done.
% \end{function}
%
% \begin{function}{city}
% \begin{syntax}
% city = \Arg{地点}
% \end{syntax}
% 地点。
% \end{function}
%
% 一个示例如下:
%
% \begin{ctexexam}
% \hkustsetup {
% info = {
% degree = {phd},
% title = {Triggering\\the Forth Impact},
% keywords = {Neon, Genesis, Evangelion},
% grade = {},
% student-id = {},
% author = {Cruel Angel},
% school = {School of SEELE},
% department = {Department of NERV},
% program = {Human Instrumentality Project},
% major = {},
% supervisor = {Prof. Adams},
% co-supervisor = {Prof. Lilith},
% submit-month = {August 2021},
% submit-date = {13 August 2021},
% defend-date = {8 March 2021},
% depthead = {Prof. Ikari Yui, Head of Department},
% reviewer = {Prof. AAA (Chairperson),
% Prof. BBB (Supervisor),
% Prof. CCC (Co-supervisor),
% Prof. DDD,
% Prof. EEE},
% reviewerdept = {Department of Electronic and Computer Engineering,
% Department of ECE,
% Department of ECE,
% Department of ECE,
% Department of Physics},
% reviewerext = {Prof. FFF (External Examiner),
% Department of EE\\{University of UU, at VV}},
% city = {Geo Front},
% }
% }
% \end{ctexexam}
%
% \subsubsection{导言区剩余部分}
% \begin{itemize}
% \item 用户可以自行添加所需的宏包、设置和其它命令。
% \item \verb|\addbibresource{mythesis.bib}| 导入了存放引用文献的 bib 文件。
% \end{itemize}
%
% \textbf{注意:}本模板使用 \pkg{unicode-math} 设置数学环境字体,请不要使用会与之产生冲突的 \pkg{bm} 宏包,否则会报错。事实上,在 \hologo{XeTeX} 引擎下,\pkg{bm} 已经过时。对于 \pkg{bm} 宏包中的常用命令 \verb|\bm|,本模板已经设置了一个别名,用户可以在正文中直接使用 \verb|\bm|。除此之外,如果还有需要使用的 \pkg{bm} 宏包中的命令,请自行设置别名。
%
% \subsubsection{正文区}
% 正文区按顺序定义或插入了组成论文的各个组件、章节;用户在 \file{chapters} 文件夹下修改或新增章节文件后,需要检查主文件中对应的部分是否正确。
%
% 这样设置文件结构的优点是使得主文件结构清晰可见、各章节便于修改;但如果用户有自己的喜好,也不必拘泥于本模板提供的结构,可以自由发挥。
%
% \subsection{各章节}
%
% 在 \verb|\mainmatter| 之后的内容是以章节的形式呈现的论文正文和附录部分,一般以 Introduction、Chapters、Conclusions、 References 和 Appendix 的顺序组织文字。用户可以根据自己的实际情况修改、增加、删除、重命名对应的章节文件,并确保主文件中使用 \verb|\input{}| 的部分
% \begin{ctexexam}
% \input{chapters/Introduction.tex}
% \input{chapters/...}
% \input{chapters/Conclusions.tex}
% \printbibliography[heading=bibintoc,title=References]
% \appendix
% \input{chapters/Appendix_xxx.tex}
% \end{ctexexam}
% 与之对应。
%
% 值得指出的是,\file{mythesis.tex} 文件所在的目录是编译时的根目录,因此即使在 \file{chapters/xxx.tex} 文件中插入图片,也应该使用 \verb|{figures/xxx.png}| 而非 \verb|{../figures/xxx.png}| 作为图片的路径。
%
% \file{mythesis.tex} 文件和 \file{chapters} 文件夹内的文件给出了一些示例,用户可以基于这些文件撰写自己的毕业论文。其中部分章节文件内的 \verb|\blindtext| 命令用来生成一段用于测试排版效果的 ``乱数假文'' (lorem ipsum),正式撰写论文时请将其删去。
%
% \vfill
%
% \textbf{下面的内容为开发手册,供开发者参考。普通用户无需阅读,请开始你的 \hologo{TeX} 之旅吧!}
%
% \end{documentation}
%
% \clearpage
%
% \begin{implementation}
%
% \section{Implementation}\label{sec:implementation}
%
% \verb|@@| 在 \pkg{l3docstrip} 中表示名空间,在删除注释生成格式文件时会被等号后的字段替换,如在本模板\pkg{hkustthesis}中 |@@=hkust|。
% 尖括号包裹的|<*class>||</class>|用来指定某段代码属于哪个文件。
%
% \begin{macrocode}
%<@@=hkust>
%<*class>
% \end{macrocode}
%
% \subsection{定义常量}
%
% \begin{macro}{\@@_define_name:nn}
%
% 用来定义默认名称的辅助函数。
% \begin{macrocode}
\cs_new_protected:Npn \@@_define_name:nn #1#2
{ \tl_const:cn { c_@@_name_ #1 _tl } {#2} }
% \end{macrocode}
% \end{macro}
%
% 默认名称。注意空格是忽略掉的。
% \begin{macrocode}
\clist_map_inline:nn
{ { pdf_creator } { LaTeX~with~hkustthesis~class }, }
{ \@@_define_name:nn #1 }
\clist_map_inline:nn
{ { keywords } { Keywords:~ }, }
{ \@@_define_name:nn #1 }
% \end{macrocode}
%
% \subsection{模板选项}
%
% 用于配置模板选项的宏包。
% \begin{macrocode}
\RequirePackage{xparse,xtemplate,l3keys2e}
% \end{macrocode}
%
% \begin{variable}{\l_@@_info_degree_tl}
% 用于存储学位名称的变量,注意宏的命名,\verb|l|代表局部变量,\verb|g|代表全局变量。
% \begin{macrocode}
\tl_new:N \l_@@_info_degree_tl
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{\g_@@_latin_fontset_tl, \g_@@_bib_style_tl}
% 用于存储所用字体名称和参考文献样式的全局变量。
% \begin{macrocode}
\tl_new:N \g_@@_latin_fontset_tl
\tl_new:N \g_@@_bib_style_tl
\tl_new:N \g_@@_disp_committee_tl
% \end{macrocode}
% \end{variable}
%
% 学位信息的设置。
% \begin{macrocode}
\keys_define:nn { hkust }
{
% \end{macrocode}
%
% \begin{macro}{customlatinfont}
% 定义字体选项。
% \begin{macrocode}
customlatinfont .choices:nn =
{ gyre, macos, windows, none }
{ \tl_set_eq:NN \g_@@_latin_fontset_tl \l_keys_choice_tl },
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{custombibstyle}
% 定义参考文献样式。
% \begin{macrocode}
custombibstyle .choices:nn =
{ ieee, nature, science, apa, mla, phys, chem-acs, nejm }
{ \tl_set_eq:NN \g_@@_bib_style_tl \l_keys_choice_tl },
custombibstyle .initial:n = ieee,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{displaycommittee}
% 显示委员会成员列表。
% \begin{macrocode}
displaycommittee .choices:nn = { true, flase }
{ \tl_set_eq:NN \g_@@_disp_committee_tl \l_keys_choice_tl },
displaycommittee .initial:n = flase,
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ProcessKeysOptions}
% 在定义完全部设置以后从tex文件导言区输入参数。
% \begin{macrocode}
\ProcessKeysOptions { hkust }
% \end{macrocode}
% \end{macro}
%
% \subsection{论文信息}
% 输入论文的必要信息。
% \begin{macrocode}
\keys_define:nn { hkust }
{ info .meta:nn = { hkust / info } { #1 } }
% \end{macrocode}
%
% \begin{macrocode}
\keys_define:nn { hkust / info }
{
% \end{macrocode}
%
% \begin{macro}{info/degree}
% 学位名称:phd 或 mphil。
% \begin{macrocode}
degree .tl_set:N = \l_@@_info_degree_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/title}
% 论文标题。经测试,本模板最大支持3行标题,如果多于3行,有部分情况会出现溢出页面的问题。
% \begin{macrocode}
title .tl_set:N = \l_@@_info_title_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/keywords}
% 关键词。
% \begin{macrocode}
keywords .clist_set:N = \l_@@_info_keywords_clist,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/grade,info/student-id,info/author}
% 年级、学号、姓名。
% \begin{macrocode}
grade .tl_set:N = \l_@@_info_grade_tl,
student-id .tl_set:N = \l_@@_info_id_tl,
author .tl_set:N = \l_@@_info_author_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/school,info/department,info/program,info/major}
% 学院、系/部门、项目、专业。
% \begin{macrocode}
school .tl_set:N = \l_@@_info_school_tl,
department .tl_set:N = \l_@@_info_department_tl,
program .tl_set:N = \l_@@_name_of_program_tl,
major .tl_set:N = \l_@@_major_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/supervisor,info/co-supervisor}
% 导师。
% \begin{macrocode}
supervisor .tl_set:N = \l_@@_info_supervisor_tl,
co-supervisor .tl_set:N = \l_@@_info_co_supervisor_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/submit-month,info/submit-date,info/defend-date,info/depthead,info/reviewer,info/reviewerdept,info/reviewerext,info/city}
% 提交和答辩。
% \begin{macrocode}
submit-month .tl_set:N = \l_@@_submit_month_tl,
submit-date .tl_set:N = \l_@@_submit_date_tl,
defend-date .tl_set:N = \l_@@_defend_date_tl,
depthead .tl_set:N = \l_@@_info_depthead_tl,
reviewer .clist_set:N = \l_@@_info_reviewer_clist,
reviewerdept .clist_set:N = \l_@@_info_reviewer_dept_clist,
reviewerext .clist_set:N = \l_@@_info_reviewer_ext_clist,
city .tl_set:N = \l_@@_info_city_tl,
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hkustsetup}
% 定义用于设置个人信息的命令。
% \begin{macrocode}
\NewDocumentCommand \hkustsetup { m }
{ \keys_set:nn { hkust } { #1 } }
% \end{macrocode}
% \end{macro}
%
% \subsection{载入文档类}
%
% 使用\pkg{book}文档类。
% \begin{macrocode}
\LoadClass[a4paper,12pt,oneside,UTF8]{book}
% \end{macrocode}
%
% \subsection{载入宏包}
%
% 载入各种宏包。
% \pkg{emptypage}用于清除空白页的页码。
% \begin{macrocode}
\RequirePackage
{
geometry,
caption,
floatrow,
float,
setspace,
lastpage,
emptypage,
fancyhdr,
makecell
}
% \end{macrocode}
%
% 此处为行距设置,FYTGS的邮件确认是 Word 中的 1.5 倍行距。\\
% 关于行距,12pt的 Times~New~Roman 文字在Word里的单倍行距对应的 PDF 行距是1.15,1.5倍 Word 行距对应的 PDF 行距是1.72;而在 \hologo{LaTeX} 中设置 linespread = 1 时生成的 PDF 的行距是 1.2。所以要想得到 1.5 倍 Word 行距 (即 1.72 倍 PDF 行距),需要设置的 linespread 为:
% \[ \frac{1.72}{1.2} = 1.433\]
% 而由于单倍行距在 Word 和 \hologo{LaTeX}生成的PDF 中差别很小,故使用了 \verb|\singlespacing| 命令实现。
% \begin{macrocode}
\linespread{1.43}
%^^A \onehalfspacing
%^^A \setstretch{1.5}
%^^A \setlength{\baselineskip}{18pt}
% \end{macrocode}
%
% 标题、目录和链接。
% \begin{macrocode}
\RequirePackage[explicit]{titlesec} % typesetting titles of chap/sec/...
\RequirePackage[titles]{tocloft}
\RequirePackage[hyphens]{url} % generate better linebreaks in the url
% \end{macrocode}
%
% 用于特定学科的包。
% \begin{macrocode}
\RequirePackage{siunitx} % 用于书写单位符号
\RequirePackage[version=4]{mhchem} % 用于绘制分子式
\RequirePackage{physics} % Physics package
\RequirePackage{braket} % for Dirac notation
% \end{macrocode}
%
% 用于生成可以被插入书签的LaTeX logo。
% \begin{macrocode}
\RequirePackage{hologo}
% \end{macrocode}
%
% \begin{macrocode}
% \RequirePackage{needspace} % prevent page break after sectioning
% \RequirePackage{xspace} % Better print trailing whitespace
% \end{macrocode}
%
% \pkg{amsmath}必须在\pkg{unicode-math}前加载。
% \pkg{unicode-math}指定了\hologo{XeTeX}和\hologo{LuaTeX}下所使用的数学字体。
% 用于配置数学环境的\pkg{mathtools}会与\pkg{unicode-math}发生冲突,此处手动消除其警告。
% \begin{macrocode}
\RequirePackage{amsmath,amsthm,mathtools,thmtools}
\RequirePackage[
warnings-off={mathtools-colon,mathtools-overbracket}
]{unicode-math}
% \end{macrocode}
%
% 配置图片、表格、代码、列表环境。
% \begin{macrocode}
\RequirePackage{graphicx,subcaption,wrapfig,tikz}
\DeclareGraphicsExtensions{.pdf,.eps,.jpg,.png}
\RequirePackage{booktabs,multirow,multicol,listings,enumitem}
% \end{macrocode}
%
% 必须以该顺序加载以下两个关于引用的包。
% \begin{macrocode}
\RequirePackage[
hidelinks,
bookmarksnumbered = true,
psdextra = true,
unicode = true,
colorlinks = true,
linkcolor = black,
urlcolor = blue,
citecolor = red,
anchorcolor = blue,
]{hyperref}
\RequirePackage[capitalise,nameinlink,noabbrev]{cleveref}
% \end{macrocode}
%
% 生成 ``Lorem ipsum'' 测试文字。
% \begin{macrocode}
\RequirePackage{blindtext}
% \end{macrocode}
%
% \subsection{字体设置}
%
% 导入 \pkg{fontspec} 宏包。
% \begin{macrocode}
\RequirePackage{fontspec}
% \end{macrocode}
%
% \subsubsection{操作系统检测}
%
% \begin{variable}{\g_@@_load_system_fontset_bool}
% 定义用于判断是否需要载入系统预装字体的变量。
% \begin{macrocode}
\bool_new:N \g_@@_load_system_fontset_bool
% \end{macrocode}
% \end{variable}
%
% 判断用户是否自定义了英文字体。如果未定义,则使用系统预装字体覆盖字体选项。
% \begin{macrocode}
\tl_if_empty:NTF \g_@@_latin_fontset_tl
{ \bool_gset_true:N \g_@@_load_system_fontset_bool }
{ }
% \end{macrocode}
%
% 进行系统检测。
% 检测 Windows 的命令由\pkg{l3kernal}提供,
% 检测 macOS 的命令 modified from \pkg{ctex},
% 以特定字体判断 macOS 系统。
% \begin{macrocode}
\cs_new_protected:Npn \@@_if_platform_macos:TF
{ \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } }
% \end{macrocode}
%
% 这两种情况外的系统被判断为 Linux,一律使用自由字体。
% \begin{macrocode}
\bool_if:NT \g_@@_load_system_fontset_bool
{
\sys_if_platform_windows:TF
{ \tl_set:Nn \g_@@_latin_fontset_tl { windows } }
{
\@@_if_platform_macos:TF
{ \tl_set:Nn \g_@@_latin_fontset_tl { macos } }
{ \tl_set:Nn \g_@@_latin_fontset_tl { gyre } }
}
}
% \end{macrocode}
%
% \subsubsection{定义英文字库}
%
% 接下来逐个定义所需要使用的字库。
%
% \begin{macro}{\@@_load_latin_font_windows:}
% Windows 西文字体。
% \begin{macrocode}
\cs_new_protected:Npn \@@_load_latin_font_windows:
{
\setmainfont{Times~New~Roman}
\setsansfont{Arial}
\setmonofont{Courier~New}[Scale=MatchLowercase]
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_load_latin_font_macos:}
% macOS 西文字体。
% \begin{macrocode}
\cs_new_protected:Npn \@@_load_latin_font_macos:
{
\setmainfont{Times~New~Roman}
\setsansfont{Arial}
\setmonofont{Menlo}[Scale=MatchLowercase]
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_load_latin_font_gyre:}
% 开源的 gyre 西文字体。
% \begin{macrocode}
\cs_new_protected:Npn \@@_load_latin_font_gyre:
{
\setmainfont{texgyretermes}[
Extension=.otf,
UprightFont=*-regular,
BoldFont=*-bold,
ItalicFont=*-italic,
BoldItalicFont=*-bolditalic]
\setsansfont{texgyreheros}[
Extension=.otf,
UprightFont=*-regular,
BoldFont=*-bold,
ItalicFont=*-italic,
BoldItalicFont=*-bolditalic]
\setmonofont{texgyrecursor}[
Extension=.otf,
UprightFont=*-regular,
BoldFont=*-bold,
ItalicFont=*-italic,
BoldItalicFont=*-bolditalic,
Scale=MatchLowercase,
Ligatures=CommonOff]
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{载入指定字库}
%
% 载入字体命令。
% \begin{macrocode}
\cs_new_protected:Npn \@@_load_font:
{ \use:c { @@_load_latin_font_ \g_@@_latin_fontset_tl : } }
% \end{macrocode}
%
% 载入设置的字体。
% \begin{macrocode}
\@@_load_font:
% \end{macrocode}
%
% 设置数学字体 (XITS, 或者 \href{https://www.stixfonts.org}{STIX}, 与 Times New Roman 最为相近)。
% \begin{macrocode}
% \setmathfont{STIXTwoMath-Regular}[Extension = .otf]
\setmathfont{XITSMath-Regular}[
BoldFont = XITSMath-Bold,
Extension = .otf]
\setmathfont{latinmodern-math.otf}[range={cal,bb,frak}]
% \end{macrocode}
%
% \subsection{页面布局}
%
% \subsubsection{页边距}
%
% 使用\pkg{geometry}设置页边距。
% \begin{macrocode}
\geometry{vmargin = 2.5 cm, hmargin = 2.5 cm}
% \end{macrocode}
%
% \subsubsection{页眉页脚}
%
% \begin{macrocode}
\fancypagestyle{hkustplain}{
\fancyhead{}
\fancyfoot[C]{\thepage}
}
% \end{macrocode}
%
% 载入页眉页脚设置。此处\tn{flushbottom}是为了防止目录页出现underfull \tn{vbox}信息。
% \begin{macrocode}
\tl_set:Nn \headrulewidth {0pt}
\tl_set:Nn \footrulewidth {0pt}
\AtBeginDocument{\pagestyle{hkustplain}\flushbottom}
% \end{macrocode}
%
% \subsection{章节标题}
%
% 由\pkg{titlesec}设置。
% \begin{macrocode}
\titleformat
{\chapter}
[display]
{\centering\onehalfspacing\Large\bfseries\selectfont}