forked from ustctug/ustcthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ustcthesis.dtx
4656 lines (4465 loc) · 125 KB
/
ustcthesis.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
%
% Copyright (C) 2015-2018 by Zeping Lee <zepinglee AT gmail.com>
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
%<*internal>
\iffalse
\fi
\begingroup
\def\nameoflatex{LaTeX2e}
\expandafter\endgroup\ifx\nameoflatex\fmtname\else
\csname fi\endcsname
%</internal>
%<*install>
\input docstrip.tex
\preamble
Copyright (C) 2015-\the\year by Zeping Lee <zepinglee AT gmail.com>
This file may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3c
of this license or (at your option) any later version.
The latest version of this license is in
https://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of LaTeX
version 2005/12/01 or later.
\endpreamble
\keepsilent
\askforoverwritefalse
\nopostamble
\generate{
\file{\jobname.cls}{\from{\jobname.dtx}{class}}
\file{\jobname-numerical.bst}{\from{\jobname.dtx}{numerical}}
\file{\jobname-authoryear.bst}{\from{\jobname.dtx}{authoryear}}
\file{\jobname-bachelor.bst}{\from{\jobname.dtx}{bachelor,numerical}}
}
\endbatchfile
%</install>
%<*internal>
\fi
%</internal>
%<*driver>
\ProvidesFile{ustcthesis.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{ustcthesis}
%<*class>
[2018/05/04 v3.0.10 USTC thesis template]
%</class>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[paper=a4paper,hmargin={1.5in,1in},vmargin=1.5in]{geometry}
\usepackage{hypdoc}
\hypersetup{
bookmarksopen=true,
bookmarksnumbered=true,
CJKbookmarks=true,
unicode=true,
allcolors=blue,
}
\usepackage[UTF8]{ctex}
\IfFileExists{/System/Library/Fonts/Times.ttc}{%
\setmainfont{Times}
\setsansfont[Scale=MatchLowercase]{Helvetica}
\setmonofont[Scale=MatchLowercase]{Menlo}
}{\relax}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{listings}
\lstdefinestyle{lstshell}{
basicstyle=\small\ttfamily,
backgroundcolor=\color{lightgray},
gobble=2,% 重要!否则会生成注释符号"%"
language=bash}
\newcommand\shellcmd[1]{%
\colorbox{lightgray}{\lstinline[style=lstshell]|#1|}}
\lstnewenvironment{shell}{\lstset{style=lstshell}}{}
\lstnewenvironment{latex}{%
\lstset{%
basicstyle=\small\ttfamily,
frame=single,
gobble=2,
language=[LaTeX]TeX}}{}
\lstnewenvironment{pseudocode}{%
\lstset{%
basicstyle=\ttfamily,
frame=single,
gobble=2,
language=bash}}{}
% 模仿 l3doc 的定义
\DeclareRobustCommand\file{\nolinkurl}
\DeclareRobustCommand\env{\texttt}
\DeclareRobustCommand\pkg{\textsf}
\DeclareRobustCommand\cls{\textsf}
\DeclareRobustCommand\opt{\texttt}
\renewcommand\glossaryname{版本历史}
\GlossaryPrologue{\section*{\glossaryname}}
\makeatletter
\renewcommand*{\changes@}[3]{%
\protected@edef\@tempa{%
\noexpand\glossary{#1 (#2)\levelchar
\ifx\saved@macroname\@empty
\space\actualchar\generalname
\else
\expandafter\@gobble\saved@macroname
\actualchar
\string\verb\quotechar*\verbatimchar\saved@macroname\verbatimchar
\fi
:\levelchar #3}}%
\@tempa
\endgroup
\@esphack
}
\makeatother
\renewcommand\indexname{命令索引}
\IndexPrologue{%
\section*{\indexname}
\textit{意大利体的数字表示描述对应索引项的页码;
带下划线的数字表示定义对应索引项的代码行号;
罗马字体的数字表示使用对应索引项的代码行号。}}
\newcommand\TeXLive{\TeX\ Live}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\OnlyDescription
\begin{document}
\DocInput{\jobname.dtx}
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \DoNotIndex{\newenvironment,\@bsphack,\@empty,\@esphack,\sfcode}
% \DoNotIndex{\addtocounter,\label,\let,\linewidth,\newcounter}
% \DoNotIndex{\noindent,\normalfont,\par,\parskip,\phantomsection}
% \DoNotIndex{\providecommand,\ProvidesPackage,\refstepcounter}
% \DoNotIndex{\RequirePackage,\setcounter,\setlength,\string,\strut}
% \DoNotIndex{\textbackslash,\texttt,\ttfamily,\usepackage}
% \DoNotIndex{\begin,\end,\begingroup,\endgroup,\par,\\}
% \DoNotIndex{\if,\ifx,\ifdim,\ifnum,\ifcase,\else,\or,\fi}
% \DoNotIndex{\let,\def,\xdef,\edef,\newcommand,\renewcommand}
% \DoNotIndex{\expandafter,\csname,\endcsname,\relax,\protect}
% \DoNotIndex{\Huge,\huge,\LARGE,\Large,\large,\normalsize}
% \DoNotIndex{\small,\footnotesize,\scriptsize,\tiny}
% \DoNotIndex{\normalfont,\bfseries,\slshape,\sffamily,\interlinepenalty}
% \DoNotIndex{\textbf,\textit,\textsf,\textsc}
% \DoNotIndex{\hfil,\par,\hskip,\vskip,\vspace,\quad}
% \DoNotIndex{\centering,\raggedright,\ref}
% \DoNotIndex{\c@secnumdepth,\@startsection,\@setfontsize}
% \DoNotIndex{\ ,\@plus,\@minus,\p@,\z@,\@m,\@M,\@ne,\m@ne}
% \DoNotIndex{\@@par,\DeclareOperation,\RequirePackage,\LoadClass}
% \DoNotIndex{\AtBeginDocument,\AtEndDocument}
% \DoNotIndex{\.,\DeclareCaptionLabelSeparator,\DeclareComplementaryOption}
%
%
%
% \GetFileInfo{\jobname.dtx}
%
% \title{\cls{ustcthesis} 使用说明}
% \author{Zeping Lee\thanks{zepinglee AT gmail.com} \and
% seisman\thanks{seisman.info AT gmail.com} }
% \date{\filedate\qquad\fileversion}
% \maketitle
%
%
%
% \PrintChanges
%
% \section{简介}
%
% \cls{ustcthesis}是用于排版中国科学技术大学本科和研究生学位论文的\LaTeX{}模板,
% 按照《\href{http://gradschool.ustc.edu.cn/ylb/material/xw/wdxz/32.pdf}
% {中国科学技术大学研究生学位论文撰写手册}》
% 和《\href{http://www.teach.ustc.edu.cn/document/doc-administration/4032.html}
% {关于本科毕业论文(设计)格式和统一封面的通知}》 的要求编写。
%
% 其前身是中国科学技术大学本科论文模板(作者 XPS,最后维护 ywg)和中国科学技术大学研究生论文
% 模板(作者 Liuqs,主要维护 Liuqs、Guolicai)。
% 后来两模板进行了整合梳理,由 ywg 维护。
% 2015 年,seisman 和 zepinglee 基于 \pkg{ctex} 2.0 重新编写了模板。
% 2017 年,随着学校发布了新版的《撰写手册》,本模板也更新到 v3.0。
%
% \cls{ustcthesis} 的下载地址:
% \begin{itemize}
% \item 主要地址:\url{https://github.com/ustctug/ustcthesis/releases}
% \item 学校镜像:\url{https://git.ustclug.org/ustctug/ustcthesis/tags}
% \item 研究生院网站:\url{http://gradschool.ustc.edu.cn/ylb/xw.html}
% \end{itemize}
%
%
%
% \section{编译方法}
%
% \subsection{文件组成}
% 本模板的主要文件如表~\ref{tab:files}:
% \begin{table}[htbp]
% \centering
% \begin{tabular}{lll}
% \toprule
% 类别 & 文件 & 说明 \\
% \midrule
% 模板文件 & \file{ustcthesis.dtx} & 模板原始代码文件,用户无需使用 \\
% & \file{ustcthesis.cls} & 文档类文件 \\
% & \file{ustcextra.sty} & 模板的附加宏包 \\
% & \file{ustcauthoryear.bst} & author-year 风格的参考文献格式 \\
% & \file{ustcnumerical.bst} & numerical 风格的参考文献格式 \\
% & \file{figures/ustc_*.pdf} & 校名和校徽图片 \\
% \midrule
% 生成文件 & \file{ustcthesis.pdf} & (你正在阅读的)模板使用说明 \\
% \midrule
% 示例文档 & \file{main.tex} & 主文档 \\
% & \file{chapters/*.tex} & 示例文档的各个章节 \\
% & \file{figures/} & 放置图片的目录 \\
% & \file{bib/tex.bib} & \BibTeX{} 示例数据库 \\
% \midrule
% 其他 & \file{README.md} & 基本说明 \\
% & \file{.latexmkrc} & latexmk 的配置文件 \\
% & \file{Makefile} & GNU make 的配置文件 \\
% \bottomrule
% \end{tabular}
% \caption{模板的文件组成}
% \label{tab:files}
% \end{table}
%
% 示例文档包括了常用的 \LaTeX{} 命令,建议新手从此入手,用自己的内容进行替换。
%
% 文件 \file{ustcthesis.dtx} 是模板的原始代码文件,其可以自动生成文档类文件
% \file{ustcthesis.cls} 和模板使用说明文件 \file{ustcthesis.pdf} 。
% 原始模板文件仅供模板开发者使用,一般用户无需使用。
%
% \subsection{依赖宏包}
%
% \cls{ustcthesis} 直接依赖的宏包有:
% \pkg{amssymb},
% \pkg{caption},
% \pkg{calc},
% \pkg{ctex},
% \pkg{etoolbox},
% \pkg{fancyhdr},
% \pkg{geometry},
% \pkg{hyperref},
% \pkg{natbib},
% \pkg{pifont},
% \pkg{titletoc},
% \pkg{tikz},
% \pkg{upgreek},
% \pkg{xparse}
%
% 注意 \pkg{ctex} 必须为 2.0 以上版本,所以要求 TeX Live、MacTeX、MikTeX
% 的版本不低于 2015 年的发行版。
%
% \subsection{开始编译}
%
% \begin{enumerate}
%
% \item GNU make \\
% Linux/Mac用户,可以直接使用 GNU make 工具,这是最简单的方法。
% 编译论文 \file{main.pdf}:
% \begin{shell}
% make
% \end{shell}
% 编译说明文档 \file{ustcthesis.pdf}:
% \begin{shell}
% make doc
% \end{shell}
% 另外还可以用 \shellcmd{make clean} 清理辅助文件。
%
% \item |latexmk| \\
% Windows 用户可能无法使用GNU make,使用 |latexmk| 也是一个比较简单的方法,
% 配置文件由 \file{.latexmkrc} 给出,其参数设置为 |-xelatex|,用户编译论文
% 只需使用命令:
% \begin{shell}
% latexmk main
% \end{shell}
% 编译说明文档:
% \begin{shell}
% latexmk ustcthesis.dtx
% \end{shell}
% 清理辅助文件可以用 \shellcmd{latexmk -c}。图形界面用户应参考编辑器的使用说明。
%
% \item 手动编译 \\
% 手动编译是最繁琐的方法,用户可能需要运行多遍,以确保论文的交叉引用等信息全部正确。
%
% 编译论文 \file{main.pdf}:
% \begin{shell}
% xelatex main
% bibtex main # 如果不使用 BibTeX 可以略过此步
% xelatex main
% xelatex main
% \end{shell}
% 编译说明文档 \file{ustcthesis.pdf}:
% \begin{shell}
% xelatex ustcthesis.dtx
% makeindex -s gind.ist ustcthesis.idx
% makeindex -s gglo.ist -o ustcthesis.gls ustcthesis.glo
% xelatex ustcthesis.dtx
% xelatex ustcthesis.dtx
% \end{shell}
% \end{enumerate}
%
%
%
% \section{模板设置}
%
% \subsection{文档类参数}
% \cls{ustcthesis} 提供了若干选项,应在论文开始时设置,如:
% \begin{latex}
% \documentclass[doctor,english,pdf]{ustcthesis}
% \end{latex}
%
% 全部的选项见表~\ref{tab:options}
% \begin{table}[htbp]
% \centering
% \begin{tabular}{lll}
% \toprule
% 必需参数 & \opt{bachelor} & 本科论文 \\
% & \opt{master} & 硕士论文 \\
% & \opt{doctor} & 博士论文 \\
% \midrule
% 可选参数 & \opt{professional} & 专业学位 \\
% & \opt{chinese} & 中文,默认 \\
% & \opt{english} & English \\
% & \opt{print} & 用于双面打印纸质论文,默认 \\
% & \opt{pdf} & 单面打印,并保留超链接颜色 \\
% & \opt{super} & 角标数字式参考文献引用标注,默认 \\
% & \opt{numbers} & 数字式参考文献引用标注 \\
% & \opt{authoryear} & 著者-出版年制参考文献 \\
% & \opt{arabic} & 使用阿拉伯数字式章节标题(本科生)\\
% \bottomrule
% \end{tabular}
% \caption{文档类参数}
% \label{tab:options}
% \end{table}
%
% \subsection{字体设置}
% \cls{ustcthesis} 是以 \pkg{XeTeX} + \pkg{fontspec} + \pkg{xeCJK}
% 的方式来配置字体的,
% 所以用户必须使用 UTF-8 编码保存源文件,并且用 |xelatex| 命令进行编译。
%
% 默认情况下,本模板可以自动检测用户的操作系统, 并配置合适的字体。
% 默认配置的策略如表~\ref{tab:fonts}:
% \begin{table}[htbp]
% \centering
% \begin{tabular}{cll}
% \toprule
% 字体类型 & Mac & Windows \\
% \midrule
% 衬线体 & Times New Roman & Times New Roman \\
% 非衬线体 & Arial & Arial \\
% 等宽体 & Menlo & Courier New \\
% 中文字体 & 华文字库 & 中易字库 \\
% \bottomrule
% \end{tabular}
% \caption{默认字体配置}
% \label{tab:fonts}
% \end{table}
%
% 对于中文字体,用户以在调用文档类时加入选项
% \opt{fontset=mac/windows/adobe/founder} 指定加载的字库,
% 也可以使用 \opt{fontset=none},然后自行配置,
% 详见 \pkg{ctex}、\pkg{xeCJK}、\pkg{fontspec} 等宏包的。
%
% Linux 系统下可能缺失 Times New Roman 等西文字体,
% 默认配置的中文字库 Fandol 也容易出现缺字的情况。
% 我们建议 Linux 用户自行配置合适的字体。
%
%
%
% \section{论文内容}
%
% 研究生论文的内t容按如下顺序排列:
% \begin{description}
% \item[封面] 中文封面,英文封面,原创性声明及授权使用说明
% \item[front matter] 中、英文摘要,目录,图、表清单,符号说明
% \item[main matter] 正文章节,参考文献
% \item[appendix] 附录
% \item[back matter] 致谢,已发表论文列表
% \end{description}
%
% 本科生论文的内容按如下顺序排列:
% \begin{description}
% \item[封面] 中文封面,英文封面,原创性声明及授权使用说明
% \item[front matter] 致谢,目录,中、英文摘要
% \item[main matter] 正文章节,参考文献
% \item[appendix] 附录
% \end{description}
%
% 示例文档 \file{main.tex} 中的致谢、目录等章节的顺序,是按照研究生论文的格式组
% 织内容的,\emph{本科生需要手动调整顺序}。
%
% 如果使用文档类选项 \opt{print} (默认),“原创性声明” 页则会加在封面后;
% 若为 \opt{pdf},则没有声明页。
%
%
% \subsection{封面}
%
% “封面”的名字让人有些混淆,它既可以指由印刷厂统一制作的硬皮封面(cover),也可
% 以指书打开后的第一页(title page)。在这里指的是后者,所以本模板从 title page
% 开始。
%
% 封面由 \cs{maketitle} 命令生成,其中的各项信息使用 \cs{\meta{item}\marg{info}}
% 的方式填写,本模板提供的命令如表~\ref{tab:covercmds},其中带 |en| 前缀的命令是
% 设置英文封面的命令:
% \begin{table}[htbp]
% \centering
% \begin{tabular}{lll}
% \toprule
% 命令 & 命令(英文) & 说明 \\
% \midrule
% \cs{title} & \cs{entitle} & 论文标题 \\
% \cs{author} & \cs{enauthor} & 作者姓名 \\
% \cs{major} & \cs{enmajor} & 学科专业 \\
% \cs{supervisor} & \cs{ensupervisor} & 导师姓名 \\
% \cs{cosupervisor} & \cs{encosupervisor} & 副导师姓名 \\
% \cs{date} & \cs{endate} & 完成时间(默认为今天) \\
% \cs{secrettext} & \cs{ensecrettext} & 密级信息(默认不保密) \\
% \bottomrule
% \end{tabular}
% \caption{用来定义封面项目}
% \label{tab:covercmds}
% \end{table}
%
% \subsection{摘要等环境}
% \DescribeEnv{abstract}
% \DescribeEnv{enabstract}
% \DescribeEnv{notation}
% \DescribeEnv{acknowledgements}
% \DescribeEnv{publications}
% 对于特殊的章节,\cls{ustcthesis} 还提供了相应的环境,如表~\ref{tab:environments}。
% \begin{table}[htbp]
% \centering
% \begin{tabular}{ll}
% \toprule
% 环境 & 说明 \\
% \midrule
% \env{abstract} & 中文摘要 \\
% \env{enabstract} & 英文摘要 \\
% \env{notation} & 符号 \\
% \env{acknowledgements} & 致谢 \\
% \env{publications} & 发表成果 \\
% \bottomrule
% \end{tabular}
% \caption{特殊章节的环境}
% \label{tab:environments}
% \end{table}
%
% \DescribeMacro{\keywords}
% \DescribeMacro{\enkeywords}
% 其中,摘要的关键词应使用 \cs{keywords} 和 \cs{enkeywords} 命令,并包含在摘要环
% 境中;
% \begin{latex}
% \begin{abstract}
% 这里是摘要。
% \keywords{论文;摘要;关键词}
% \end{abstract}
% \end{latex}
%
% \subsection{目录和图表}
% 生成目录、插图和表格的索引命令分别如表~\ref{tab:tocs}:
% \DescribeMacro{\tableofcontents}
% \DescribeMacro{\listoffigures}
% \DescribeMacro{\listoftables}
% \begin{table}[htbp]
% \centering
% \begin{tabular}{ll}
% \toprule
% 命令 & 说明 \\
% \midrule
% \cs{tableofcontents} & 目录 \\
% \cs{listoffigures} & 图目录 \\
% \cs{listoftables} & 表目录 \\
% \cs{listofalgorithms} & 算法目录 \\
% \bottomrule
% \end{tabular}
% \caption{各种目录的环境}
% \label{tab:tocs}
% \end{table}
%
% \LaTeX{} 的图表索引,是通过 \cs{caption} 命令完成的,因此它们必须出现在浮动环
% 境中,否则不被计数。
% 如果不想让某个表格或者图片出现在索引里面,那么应使用命令 \cs{caption*},
% 这个命令不会给表格编号,也就是出来的只有标题文字而没有“表~xx”,“图~xx”。
%
% \DescribeMacro{\note}
% 本模板还提供了 \cs{note\marg{text}} 命令,用于在图表中添加注释。
%
% \subsection{数学}
%
% 模板中定义了一些使用正体的数学符号(表~\ref{tab:symbols})。
% \begin{table}
% \centering
% \begin{tabular}{rl}
% \toprule
% 符号 & 命令 \\
% \midrule
% 常数$\mathrm{e}$ & \cs{eu} \\
% 复数单位$\mathrm{i}$ & \cs{iu} \\
% 微分符号$\mathrm{d}$ & \cs{diff} \\
% $\arg\,\max$ & \cs{argmax} \\
% $\arg\,\min$ & \cs{argmin} \\
% \bottomrule
% \end{tabular}
% \caption{模板定义的数学符号}
% \label{tab:symbols}
% \end{table}
%
% \file{ustcextra.sty} 定义了数学定理格式 |ustcplain|(默认使用)以及一些常用的
% 环境,如表~\ref{tab:theorems}。
% \begin{table}[htbp]
% \centering
% \begin{tabular}{*{5}{l}}
% \toprule
% theorem & assertion & axiom & corollary & lemma \\
% 定理 & 断言 & 公理 & 推论 & 引理 \\
% \midrule
% proposition & definition & example & remark & proof \\
% 命题 & 定义 & 例 & 注 & 证明 \\
% \bottomrule
% \end{tabular}
% \caption{数学定理相关的环境}
% \label{tab:theorems}
% \end{table}
%
% 注意\env{proof} 环境与其它不同的是,其第二个参数会完全取代“证明”标题,
% 并且会在末尾加一个 \cs{qed}。
%
% \DescribeMacro{\newtheorem}
% 用户可以使用 \cs{newtheorem} 命令来分别定义新的数学环境,比如定义并使用“传说”环境:
% \begin{latex}
% \newtheorem{legend}{传说}
% \begin{legend}
% 龙生龙,凤生凤,华罗庚的弟子会打洞。
% \end{legend}
% \end{latex}
%
% \DescribeMacro{\newtheoremstyle}
% 用户还可以用 \cs{newtheoremstyle} 定义环境的格式,具体参见 \pkg{amsthm} 宏包。
%
% \subsection{参考文献}
%
% 参考文献和引用标注支持的风格见表~\ref{tab:bib},默认为角标数字式,
% \begin{table}[htbp]
% \centering
% \begin{tabular}{lll}
% \toprule
% 参考文献列表 & 引用标注 & 参数 \\
% \midrule
% 顺序编码制 & 角标数字 & super \\
% & 数字 & numbers \\
% 著者-出版年制 & 著者-出版年 & authoryear \\
% \bottomrule
% \end{tabular}
% \caption{参考文献列表和引用标注风格}
% \label{tab:bib}
% \end{table}
%
% 如果要使用其他风格,可以在载入文档类时加入相应的参数:
% \begin{latex}
% \documentclass[doctor,authoryear]{ustcthesis}
% \end{latex}
%
% 在使用著者-出版年制时,需要将中文参考文献按照拼音或者笔画排序,
% 然而 Unicode 中的汉字是根据康熙字典排序的,
% 而且由于 \BibTeX{} 功能的局限性,我们无法根据著者姓名读取拼音,
% 所以只能手动处理:在 bib 数据库中设置对应条目的 key 域为著者姓名拼音,如:
% \begin{latex}
% @book{capital,
% author = {马克思 and 恩格斯},
% key = {ma3 ke4 si1 en1 ge2 si1},
% ...
% \end{latex}
%
% \BibTeX{} 默认情况下可以自动识别文献语言,并自动处理文献类型和载体类型标识,
% 但是在少数情况下需要用户手动指定,如:
% \begin{latex}
% @article{citekey,
% language = {japanese},
% mark = {M},
% medium = {CD},
% ...
% \end{latex}
% 可选的语言有 english, chinese, japanese, russian,
% 目前对日语和俄语的支持较为有限。
%
%
%
% \clearpage
% \appendix
%
% \section{代码实现}
% \label{sec:code}
%
% \subsection{声明选项}
% \begin{macrocode}
%<*class>
\newif\if@ustc@doctor
\newif\if@ustc@master
\newif\if@ustc@bachelor
\newif\if@ustc@professional
\newif\if@ustc@english
\newif\if@ustc@numerical
\newif\if@ustc@super
\newif\if@ustc@pdf
\newif\if@ustc@arabic
\DeclareOption{doctor}{\@ustc@doctortrue\@ustc@masterfalse\@ustc@bachelorfalse}
\DeclareOption{master}{\@ustc@doctorfalse\@ustc@mastertrue\@ustc@bachelorfalse}
\DeclareOption{bachelor}{\@ustc@doctorfalse\@ustc@masterfalse\@ustc@bachelortrue}
\DeclareOption{professional}{\@ustc@professionaltrue}
\DeclareOption{chinese}{\@ustc@englishfalse}
\DeclareOption{english}{\@ustc@englishtrue\@ustc@arabictrue}
\DeclareOption{print}{\@ustc@pdffalse}
\DeclareOption{pdf}{\@ustc@pdftrue}
\DeclareOption{super}{\@ustc@numericaltrue\@ustc@supertrue}
\DeclareOption{numbers}{\@ustc@numericaltrue\@ustc@superfalse}
\DeclareOption{authoryear}{\@ustc@numericalfalse}
\DeclareOption{arabic}{\@ustc@arabictrue}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{ctexbook}}
\ExecuteOptions{doctor,chinese,print,super}
\ProcessOptions\relax
\newif\if@ustc@addtocspace
\if@ustc@bachelor
\@ustc@addtocspacetrue
\fi
\if@ustc@english
\PassOptionsToClass{scheme=plain}{ctexbook}
\fi
\if@ustc@pdf
\PassOptionsToClass{oneside}{book}
\fi
% \end{macrocode}
%
% 默认情况下 \pkg{fontspec} 会将 \cs{mathrm} 的字体更改为 Times New Roman,
% 而 \cs{mathnormal} 依然为 Computer Modern,比 Times New Roman 要细,
% 所以设置 \pkg{fontspec} 不处理数学字体
% \begin{macrocode}
\PassOptionsToPackage{no-math}{fontspec}
% \end{macrocode}
%
% 载入 \cls{ctexbook} 文档类,注意要求 \pkg{ctex} 为 2.0 以及更高的版本。
% \changes{v3.0}{2017/07/01}{正文新的一章另面起}
% \begin{macrocode}
\LoadClass[UTF8, a4paper, openany, zihao=-4]{ctexbook}[2015/05/14]
\RequirePackage{etoolbox}
% \end{macrocode}
% 检测 ctexbook 版本,如果版本过低会报错
% \begin{macrocode}
\@ifclasslater{ctexbook}{2015/05/14}{}{%
\ClassError{ustcthesis}{%
Requiring ctex 2.0 or later version!\MessageBreak
Please update the package using your\MessageBreak
TeX package manager or from CTAN.
}{%
See ustcthesis.pdf for more detailed update guide.
}
}
% \end{macrocode}
%
% \subsection{设置字体}
% 设置西文字体
% \begin{macrocode}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\IfFileExists{/System/Library/Fonts/Menlo.ttc}{%
\setmonofont[Scale=MatchLowercase]{Menlo}
}{
\setmonofont[Scale=MatchLowercase]{Courier New}
}
% \end{macrocode}
%
% 中文字体可以由 \pkg{ctex} 自动设置,但是会有问题:
% 1. 无衬线字体使用对打印不太友好的微软雅黑或者苹方;
% 2. 没有粗体的字体不会开启伪粗;
% 所以必须做一些调整。
% \changes{v3.0.6}{2018/04/12}{取消使用微软雅黑}
% \begin{macrocode}
\ExplSyntaxOn
\RequirePackage{xstring}
\str_if_eq:onT { \g__ctex_fontset_tl } { mac }
{
\setCJKmainfont
[
UprightFont = *~Light,
BoldFont = *~Bold,
ItalicFont = Kaiti~SC,
BoldItalicFont = Kaiti~SC~Bold
] { Songti~SC }
\setCJKsansfont { Heiti~SC }
\setCJKfamilyfont { zhsong }
[
UprightFont = *~Light,
BoldFont = *~Bold,
] { Songti~SC }
\setCJKfamilyfont { zhhei } { Heiti~SC }
\setCJKfamilyfont { zhkai } { Kaiti~SC }
}
\str_if_eq:onT { \g__ctex_fontset_tl } { windows }
{
\file_if_exist:nTF { C:/bootfont.bin }
{
\setCJKmainfont
[ AutoFakeBold , ItalicFont = KaiTi_GB2312 ] { SimSun }
}
{
\setCJKmainfont
[ AutoFakeBold , ItalicFont = KaiTi ] { SimSun }
}
\setCJKsansfont [ AutoFakeBold ] { SimHei }
\setCJKfamilyfont { zhsong } [ AutoFakeBold ] { SimSun }
\setCJKfamilyfont { zhhei } [ AutoFakeBold ] { SimHei }
}
\str_if_eq:onT { \g__ctex_fontset_tl } { adobe }
{
\setCJKmainfont
[
AutoFakeBold ,
ItalicFont = AdobeKaitiStd-Regular
] { AdobeSongStd-Light }
\setCJKsansfont [ AutoFakeBold ] { AdobeHeitiStd-Regular}
\setCJKfamilyfont { zhsong } [ AutoFakeBold ] { AdobeSongStd-Light }
\setCJKfamilyfont { zhhei } [ AutoFakeBold ] { AdobeHeitiStd-Regular }
}
\ExplSyntaxOff
% \end{macrocode}
%
% \subsection{超链接与书签}
% \begin{macrocode}
\RequirePackage{hyperref}
\hypersetup{
bookmarksopen=true,
bookmarksnumbered=true,
bookmarksopenlevel=1,
CJKbookmarks=true,
pdfborder=0 0 0,
unicode=true,
linktoc=all,
}
% \end{macrocode}
% 如果为 |pdf| 样式,设置 hyperlink 颜色
% \begin{macrocode}
\if@ustc@pdf
\hypersetup{
colorlinks=true,
allcolors=blue,
}
\fi
% \end{macrocode}
% 设置 pdf 的信息
% \begin{macrocode}
\pdfstringdefDisableCommands{
\let\\\empty%
}
\AtBeginDocument{
\hypersetup{
pdftitle={\ustc@title},
pdfauthor={\ustc@author}
}
}
% \end{macrocode}
%
% \subsection{定义命令}
% \begin{macro}{\setfontsize}
% 直接设置字体大小的命令,可选设置行距,默认单倍行距。
% 注意:该命令的定义中的空格会影响最终效果,因而需要在一行内写完命令,见
% \href{https://github.com/ustctug/ustcthesis/issues/42}{Issue 42}
% \begin{macrocode}
\RequirePackage{xparse}
\NewDocumentCommand\setfontsize{mo}{\IfValueTF{#2}{\fontsize{#1}{#2}}{\fontsize{#1}{2\dimexpr#1}}\linespread{1}\selectfont\relax}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\zhspace}
% 生成整数倍汉字宽度的空格,默认为 1
% \begin{macrocode}
\newcommand\zhspace[1][1]{\hspace{#1\ccwd}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ustc@underline}
% 生成空的下划线
% \begin{macrocode}
\newcommand\ustc@underline[2][6em]{%
\hskip1pt\underline{\hb@xt@ #1{\hss#2\hss}}\hskip3pt\relax
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ustc@define@term}
% 声明“作者姓名”等项目的命令
% \begin{macrocode}
\def\ustc@define@term#1{%
\expandafter\gdef\csname #1\endcsname##1{%
\expandafter\gdef\csname ustc@#1\endcsname{##1}%
}%
\csname #1\endcsname{}%
}
\ustc@define@term{professionaltype}
\ustc@define@term{title}
\ustc@define@term{secrettext}
\ustc@define@term{author}
\ustc@define@term{major}
\ustc@define@term{supervisor}
\ustc@define@term{cosupervisor}
\ustc@define@term{date}
\ustc@define@term{enprofessionaltype}
\ustc@define@term{entitle}
\ustc@define@term{ensecrettext}
\ustc@define@term{enauthor}
\ustc@define@term{enmajor}
\ustc@define@term{ensupervisor}
\ustc@define@term{encosupervisor}
\ustc@define@term{endate}
\date{\zhnumsetup{time=Chinese}\zhtoday}
\endate{\CTEX@todayold}
% \end{macrocode}
% \end{macro}
%
% \subsection{设置语言}
% 这里设置了中英文的各种名字。
% \begin{macrocode}
\if@ustc@english
\renewcommand\figurename{Fig.}
\newcommand\ustc@notesname{\textbf{Notes}: }
\newcommand\ustc@acknowledgementsname{Acknowledgements}
\newcommand\ustc@publicationsname{Publications}
\newcommand\ustc@notationname{Notation}
\else
\renewcommand\listfigurename{图目录}
\renewcommand\listtablename{表目录}
\newcommand\ustc@notesname{\textbf{注}:}
\newcommand\ustc@acknowledgementsname{致谢}
\newcommand\ustc@publicationsname{在读期间发表的学术论文与取得的研究成果}
\newcommand\ustc@notationname{符号说明}
\def\equationautorefname~#1\null{公式~(#1)\null}%
\def\footnoteautorefname{脚注}%
\def\itemautorefname~#1\null{第~#1~项\null}%
\def\figureautorefname{图}%
\def\tableautorefname{表}%
\def\partautorefname~#1\null{第~#1~部分\null}%
\def\appendixautorefname{附录}%
\def\chapterautorefname~#1\null{第~#1~章\null}%
\def\sectionautorefname~#1\null{第~#1~节\null}%
\def\subsectionautorefname~#1\null{第~#1~小节\null}%
\def\subsubsectionautorefname~#1\null{第~#1~小小节\null}%
\def\paragraphautorefname~#1\null{第~#1~段\null}%
\def\subparagraphautorefname~#1\null{第~#1~小段\null}%
\def\theoremautorefname{定理}%
\def\pageautorefname~#1\null{第~#1~页\null}%
\fi
% \end{macrocode}
%
% \subsection{页面设置}
% 首先用 \pkg{geometry} 宏包设置纸张和页面。
% \begin{macrocode}
\RequirePackage{geometry}
\geometry{
paper=a4paper,
top=2.54cm, bottom=2.54cm,
left=3.17cm, right=3.17cm,
headheight=0.75cm, headsep=0.29cm,
footskip=0.79cm}
% \end{macrocode}
%
% 再用 \pkg{fancyhdr} 宏包设置页眉页码。
% \changes{v3.0}{2017/07/01}{页码全部居中}
% \changes{v3.0.2}{2017/03/16}{修正本科生的页码}
% \changes{v3.0.7}{2018/04/18}{修正页眉英文大写的错误}
%
% \begin{macrocode}
\RequirePackage{fancyhdr}
\renewcommand{\headrulewidth}{0.4pt}
\if@ustc@bachelor
\fancypagestyle{ustc@headings}{%
\fancyhf{}%
\fancyhead[C]{\setfontsize{9\bp@}中国科学技术大学本科毕业论文}%
\fancyfoot[C]{\setfontsize{9\bp@}\thepage}}%
\else
\fancypagestyle{ustc@headings}{%
\fancyhf{}%
\fancyhead[C]{\setfontsize{10.5\bp@}\leftmark}%
\fancyfoot[C]{\setfontsize{10.5\bp@}\thepage}}%
\fi
\fancypagestyle{ustc@notation}{\fancyfoot{}}
\pagestyle{ustc@headings}
\patchcmd\chaptermark{\MakeUppercase}{}{}{}
\patchcmd\chaptermark{#1}{\protect\ustc@spacetitle{#1}}{}{}
% \end{macrocode}
%
% 空白页不加页眉。
% \changes{v3.0}{2017/07/01}{空白页不加页眉}
% \begin{macrocode}
\renewcommand*{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
% \end{macrocode}
%
% 将 frontmatter 的页码改为大写的罗马数字,并调整页面风格。
% \begin{macrocode}
\g@addto@macro\frontmatter{%
\if@ustc@bachelor
\pagenumbering{gobble}%
\else
\pagenumbering{Roman}%
\fi}
\renewcommand\mainmatter{%
\if@ustc@bachelor
\clearpage
\else
\cleardoublepage
\pagenumbering{arabic}%
\fi
\@mainmattertrue
}
\renewcommand\chapter{%
\if@openright\cleardoublepage\else\clearpage\fi
\global\@topnum\z@
\@afterindenttrue
\if@ustc@bachelor
\if@mainmatter
\ctexset{chapter/format = \centering\sffamily\setfontsize{16\bp@}}%
\else
\ctexset{chapter/format = \centering\sffamily\setfontsize{18\bp@}}%
\fi
\if@ustc@addtocspace
\addtocontents{toc}{\protect\addvspace{12\bp@}}%
\fi
\fi
\secdef\@chapter\@schapter
}
% \end{macrocode}
%
% \subsection{章节标题}
%
% 用 \pkg{ctex} 的接口设置全局的章节标题格式,注意由于 \pkg{ctex} 2.1 以下版本的 bug,
% chapter 的 nameformat 和 titleformat 的这两行必须置空。
%
% \pkg{ctex} 2.4.3 以下版本的bug会导致章节标题前后的距离的实际值偏大,
% 临时的解决方案是手动调整,偏移值为beforeskip=-31bp, afterskip=-10bp。
% 但是\pkg{ctex} 2.2 前的beforeskip的符号有特殊意义,所以临时解决方案只用于
% \pkg{ctex} 2.2 以及以上版本。
%
% 首先设置带圈的数字:
%
% \begin{macrocode}
\RequirePackage{pifont}
\def\ustc@textcircled#1{%
\ifnum\value{#1}>9\relax%
\ClassError{ustcthesis}{Cannot display more than 10 footnotes.}{}%
\fi
\ding{\the\numexpr\value{#1}+191\relax}}
% \end{macrocode}
%
% 研究生规定章题为两字时中间空两字,三字时空一字,四字时空半字,四字以上不空。
% 另外,\pkg{stringstrings} 宏包会导致范数命令 \verb+\|+ 被修改,所以用
% \pkg{xstring}。
% \changes{v3.0}{2017/07/01}{章题为两字时中间空两字,三字时空一字,
% 四字时空半字,四字以上不空}
% \changes{v3.0.1}{2017/12/12}{修正范数命令失效的错误}
%
% \begin{macrocode}
\newcommand\ustc@spacetitle[1]{%
\StrLen{#1}[\titlelength]%
\if@ustc@bachelor
\if@mainmatter\relax\else
\ifnum\titlelength=2\ziju{1}\else
\ifnum\titlelength=4\ziju{0.5}%
\fi
\fi
\fi
\else
\ifnum\titlelength=2\ziju{2}\else
\ifnum\titlelength=3\ziju{1}\else
\ifnum\titlelength=4\ziju{0.5}%
\fi
\fi