forked from YinJC/ChinaThesis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchinathesis.dtx
More file actions
2334 lines (2321 loc) · 71.7 KB
/
chinathesis.dtx
File metadata and controls
2334 lines (2321 loc) · 71.7 KB
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-2019 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}}
}
\endbatchfile
%</install>
%<*internal>
\fi
%</internal>
%<*driver>
\ProvidesFile{chinathesis.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{chinathesis}
%<*class>
[2019/05/01 v1.0 A template framework for Chinese dissertations]
%</class>
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage[UTF8]{ctex}
\usepackage{unicode-math}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{hypdoc}
\makeatletter
% 设置字体
\IfFileExists{/System/Library/Fonts/Times.ttc}{
\setmainfont{Times}
\setsansfont[Scale=MatchLowercase]{Helvetica}
\setmonofont[Scale=MatchLowercase]{Menlo}
\xeCJKsetwidth{‘’“”}{1em}
}{}
\unimathsetup{
math-style=ISO,
bold-style=ISO,
}
\setmathfont[
Extension = .otf,
BoldFont = XITSMath-Bold,
StylisticSet = 8,
]{XITSMath-Regular}
% 定义一些命令用于写文档
\newcommand\TeXLive{\TeX{} Live}
\newcommand\unicodechar[1]{U+#1(\symbol{"#1})}
\DeclareRobustCommand\file{\nolinkurl}
\DeclareRobustCommand\env{\texttt}
\DeclareRobustCommand\pkg{\textsf}
\DeclareRobustCommand\cls{\textsf}
\DeclareRobustCommand\opt{\texttt}
% 在 doc 的基础上增加 option 的描述
\def\DescribeOption{\leavevmode\@bsphack\begingroup\MakePrivateLetters
\Describe@Option}
\def\Describe@Option#1{\endgroup
\marginpar{\raggedleft\PrintDescribeOption{#1}}%
\SpecialEnvIndex{#1}\@esphack\ignorespaces}
\@ifundefined{PrintDescribeOption}
{\def\PrintDescribeOption#1{\strut \MacroFont #1\ }}{}
% 调整列表的格式
\setlength\partopsep{\z@}
\def\@listi{\leftmargin\leftmargini
\parsep \z@
\topsep 5\p@ \@plus2\p@ \@minus3\p@
\itemsep2\p@ \@plus\p@ \@minus\p@}
\let\@listI\@listi
\@listi
% 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 = 4,
language = [LaTeX]TeX,
}%
}{}
% 调整版本历史和索引的格式
\renewcommand\glossaryname{版本历史}
\GlossaryPrologue{\section*{\glossaryname}}
\def\changes@#1#2#3{%
\protected@edef\@tempa{%
\noexpand\glossary{#1 (#2)\levelchar
\ifx\saved@macroname\@empty
\space
\actualchar
\else
\saved@indexname
\actualchar
\string\verb\quotechar*%
\verbatimchar\saved@macroname
\verbatimchar
: \levelchar
\fi
#3}}%
\@tempa\endgroup\@esphack}
\renewcommand\indexname{命令索引}
\IndexPrologue{%
\section*{\indexname}
\textit{意大利体的数字表示描述对应索引项的页码;%
带下划线的数字表示定义对应索引项的代码行号;%
罗马字体的数字表示使用对应索引项的代码行号。}%
}
\hypersetup{
allcolors = blue,
bookmarksnumbered = true,
bookmarksopen = true,
}
\makeatother
\EnableCrossrefs
\CodelineIndex
\RecordChanges
% \OnlyDescription
\begin{document}
\DocInput{\jobname.dtx}
\clearpage
\linespread{1.3}
\PrintChanges
\clearpage
\linespread{1}
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \DoNotIndex{\def,\long,\edef,\xdef,\gdef,\let,\global}
% \DoNotIndex{\if,\ifnum,\ifdim,\ifcat,\ifmmode,\ifvmode,\ifhmode,%
% \iftrue,\iffalse,\ifvoid,\ifx,\ifeof,\ifcase,\else,\or,\fi}
% \DoNotIndex{\begin,\end,\bgroup,\egroup,\begingroup,\endgroup}
% \DoNotIndex{\expandafter,\csname,\endcsname}
% \DoNotIndex{\hsize,\vsize,\hskip,\vskip,\kern,\hfil,\hfill,\hss}
% \DoNotIndex{\hspace,\vspace}
% \DoNotIndex{\p@,\m@ne,\z@,\@ne,\tw@,\@plus,\@minus}
% \DoNotIndex{\newcounter,\setcounter,\addtocounter,}
% \DoNotIndex{\newdim,\newlength,\setlength,\addtolength}
% \DoNotIndex{\newcommand,\renewcommand,\providecommand,\DeclareRobustCommand}
% \DoNotIndex{\newenvironment,\renewenvironment}
% \DoNotIndex{\RequirePackage,\LoadClass,\ProvidesClass}
% \DoNotIndex{\DeclareOption,\CurrentOption,\ExecuteOptions,\ProcessOptions}
% \DoNotIndex{\rmfamily,\sffamily,\ttfamily,\bfseries,\mdseries,\itshape,%
% \textrm,\textsf,\texttt,\textbf,\textmd,\textit,\textsl,\textsc}
% \DoNotIndex{\iint,\iiint,\iiiint,\oint,\oiint,\oiiint,%
% \intclockwise,\varointclockwise,\ointctrclockwise,\sumint,%
% \intbar,\intBar,\fint,\cirfnint,\awint,\rppolint,%
% \scpolint,\npolint,\pointint,\sqint,\intlarhk,\intx,%
% \intcap,\intcup,\upint,\lowint}
% \DoNotIndex{\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,%
% \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,%
% \do\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\,,\!,\',\",\/,\*,\-}
% \DoNotIndex{\NAT@@close,\NAT@@open,\NAT@cite,\NAT@citenum,\NAT@citesuper,%
% \NAT@citex,\NAT@citexnum,\NAT@cmt,\NAT@ctype,\NAT@date,%
% \NAT@last@yr,\NAT@mbox,\NAT@penalty,\NAT@spacechar,%
% \@citea,\def@NAT@last@yr,\ifNAT@swa}
% \DoNotIndex{\quad,\par,\relax,\ccwd}
% \DoNotIndex{\bp@}
%
%
%
% \GetFileInfo{\jobname.dtx}
%
% \title{\cls{chinathesis} 使用说明}
% \author{Zeping Lee\thanks{zepinglee AT gmail.com}}
% \date{\filedate\qquad\fileversion}
% \maketitle
%
% \changes{v1.0}{2018/09/19}{Initial version.}
%
%
% \section{简介}
%
% \subsection{文件组成}
% 本模板的主要文件如表~\ref{tab:files}:
% \begin{table}[htb]
% \centering\small
% \caption{模板的文件组成}
% \label{tab:files}
% \begin{tabular}{lll}
% \toprule
% 类别 & 文件 & 说明 \\
% \midrule
% 模板文件 & \file{chinathesis.dtx} & 模板原始代码文件,用户无需使用 \\
% & \file{chinathesis.cls} & 文档类文件 \\
% & \file{chinathesis-*.bst} & 参考文献表格式 \\
% \midrule
% 生成文件 & \file{chinathesis.pdf} & (你正在阅读的)模板使用说明 \\
% \midrule
% 示例文档 & \file{main.tex} & 主文档 \\
% & \file{chapters/*.tex} & 示例文档的各个章节 \\
% & \file{figures/} & 放置图片的目录 \\
% & \file{bib/refs.bib} & \BibTeX{} 示例数据库 \\
% \midrule
% 其他 & \file{README.md} & 基本说明 \\
% & \file{latexmkrc} & latexmk 的配置文件 \\
% & \file{Makefile} & GNU make 的配置文件 \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% 示例文档包括了常用的 \LaTeX{} 命令,建议新手从此入手,用自己的内容进行替换。
%
% 文件 \file{chinathesis.dtx} 是模板的原始代码文件,可以编译生成文档类文件
% \file{chinathesis.cls} 和模板使用说明文件 \file{chinathesis.pdf} 。
% 原始模板文件仅供模板开发者使用,一般用户无需使用。
%
%
% \subsection{依赖宏包}
%
% 本模板要求使用 TeX Live、MacTeX 或 MikTeX 不低于 2016 年的发行版,
% 推荐升级到最新的版本。
%
% 模板直接依赖的宏包有:
% \pkg{amsmath},
% \pkg{caption},
% \pkg{calc},
% \pkg{ctex},
% \pkg{fancyhdr},
% \pkg{footmisc},
% \pkg{geometry},
% \pkg{graphicx},
% \pkg{natbib},
% \pkg{notoccite},
% \pkg{titletoc},
% \pkg{url},
% \pkg{unicode-math}。
%
% 另外,模板还对其他宏包提供了支持,包括:
% \pkg{amsthm},
% \pkg{algorithm2e},
% \pkg{hyperref},
% \pkg{nomencl},
% \pkg{siunitx}。
% 这些宏包并非必需,用户可以根据需要选择使用。
% 模板在检测到这些宏包被调用后会自动进行配置。
%
% 注意,本模板\emph{不}兼容的宏包有:
% \pkg{amsfonts},
% \pkg{amssymb},
% \pkg{biblatex},
% \pkg{bm},
% \pkg{cite},
% \pkg{mathrsfs},
% \pkg{newtx},
% \pkg{upgreek}。
%
%
% \subsection{开始编译}
%
% \begin{enumerate}
%
% \item GNU make \\
% Linux/Mac用户,可以直接使用 GNU make 工具,这是最简单的方法。
% 编译论文 \file{main.pdf}:
% \begin{shell}
% make
% \end{shell}
% 编译说明文档 \file{chinathesis.pdf}:
% \begin{shell}
% make doc
% \end{shell}
% 另外还可以用 \shellcmd{make clean} 清理辅助文件。
%
% \item |latexmk| \\
% Windows 用户可能无法使用GNU make,使用 |latexmk| 也是一个比较简单的方法,
% 配置文件由 \file{latexmkrc} 给出,其参数设置为 |-xelatex|,用户编译论文
% 只需使用命令:
% \begin{shell}
% latexmk -xelatex main.tex
% \end{shell}
% 编译说明文档:
% \begin{shell}
% latexmk -xelatex chinathesis.dtx
% \end{shell}
% 清理辅助文件可以用 \shellcmd{latexmk -c}。图形界面用户应参考编辑器的使用说明。
%
% \item 手动编译 \\
% 手动编译是最繁琐的方法,用户可能需要运行多遍,以确保论文的交叉引用等信息全部正确。
%
% 编译论文 \file{main.pdf}:
% \begin{shell}
% xelatex main
% bibtex main # 如果不使用 BibTeX 可以略过此步
% xelatex main
% xelatex main
% \end{shell}
% 编译说明文档 \file{chinathesis.pdf}:
% \begin{shell}
% xelatex chinathesis.dtx
% makeindex -s gind.ist chinathesis.idx
% makeindex -s gglo.ist -o chinathesis.gls chinathesis.glo
% xelatex chinathesis.dtx
% xelatex chinathesis.dtx
% \end{shell}
% \end{enumerate}
%
%
%
% \section{模板设置}
%
%
% \subsection{文档类参数}
% 模板提供了若干选项,应在载入模板时设置,如:
% \begin{latex}
% \documentclass[doctor,english,pdf]{chinathesis}
% \end{latex}
%
% 全部的选项见表~\ref{tab:options}。
% \begin{table}[htb]
% \centering\small
% \caption{文档类参数}
% \label{tab:options}
% \begin{tabular}{ll}
% \toprule
% 文档类参数 & 说明 \\
% \midrule
% \opt{doctor}* & 博士论文 \\
% \opt{master} & 硕士论文 \\
% \opt{bachelor} & 本科论文 \\
% \opt{chinese}* & 中文 \\
% \opt{english} & English \\
% \opt{print}* & 用于双面打印纸质论文 \\
% \opt{pdf} & 单面打印,并保留超链接颜色 \\
% \opt{super}* & 角标数字式文献引用标注 \\
% \opt{numbers} & 数字式文献引用标注 \\
% \opt{authoryear} & 著者-出版年制文献引用标注 \\
% \opt{arabic} & 阿拉伯数字式章节标题(限本科生)\\
% \bottomrule
% \end{tabular}
% \caption*{\small 注:带 * 号的是默认参数}
% \end{table}
%
%
% \subsection{字体设置}
% 本模板是以 \pkg{XeTeX} + \pkg{fontspec} + \pkg{xeCJK}
% 的方式来配置字体的,
% 所以用户必须使用 UTF-8 编码保存源文件,并且用 |xelatex| 命令进行编译。
%
% \DescribeOption{fontset=\meta{font}}
% 默认情况下,本模板可以自动检测操作系统,并配置合适的字体。
% 用户可以在调用文档类时加入选项
% \opt{fontset=mac/windows/adobe} 指定加载的字库,
% 也可以使用 \opt{fontset=none},然后自行配置,
% 详见 \pkg{ctex}、\pkg{xeCJK}、\pkg{fontspec} 等宏包的使用说明。
%
% 注意,Linux 系统下可能缺失 Times New Roman 等西文字体,
% 而且默认的中文字库 Fandol 也容易出现缺字的情况。
% 我们建议 Linux 用户自行配置合适的字体。
%
%
%
% \section{论文内容}
%
% \subsection{封面}
%
% “封面”的名字让人有些混淆,它既可以指由印刷厂统一制作的硬皮封面(cover),也可
% 以指书打开后的第一页(title page)。在这里指的是后者,所以本模板从 title page
% 开始。
%
% \DescribeMacro{\maketitle}
% \DescribeMacro{\makestatement}
% 封面和声明页分别由 \cs{maketitle} 和 \cs{makestatement} 命令生成,
% 其中的各项信息使用 \cs{\meta{item}\marg{info}} 的方式填写,
% 本模板提供的命令如表~\ref{tab:covercmds},
% 其中带 |en| 前缀的命令是 设置英文封面的命令:
% \begin{table}[htb]
% \centering\small
% \caption{录入封面信息的命令}
% \label{tab:covercmds}
% \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{secretlevel} & \cs{ensecretlevel} & 密级(默认不保密) \\
% \cs{secretyear} & - & 保密年限 \\
% \bottomrule
% \end{tabular}
% \end{table}
%
%
% \subsection{摘要和章节}
% \DescribeEnv{abstract}
% \DescribeEnv{enabstract}
% \DescribeEnv{notation}
% \DescribeEnv{acknowledgements}
% \DescribeEnv{publications}
% 对于特殊的章节,\cls{chinathesis} 还提供了相应的环境:
% \begin{itemize}
% \item 中文摘要:\env{abstract}
% \item 英文摘要:\env{enabstract}
% \item 符号说明:\env{notation}
% \item 致谢: \env{acknowledgements}
% \item 发表成果:\env{publications}
% \end{itemize}
%
% \DescribeMacro{\keywords}
% \DescribeMacro{\enkeywords}
% 摘要的关键词应使用 \cs{keywords} 和 \cs{enkeywords} 命令,
% 并包含在摘要环境中,比如:
% \begin{latex}
% \begin{abstract}
% 这里是摘要。
% \keywords{论文;摘要;关键词}
% \end{abstract}
% \end{latex}
%
% \DescribeMacro{\tableofcontents}
% \DescribeMacro{\listoffigures}
% \DescribeMacro{\listoftables}
% 目录和图、表清单可以使用命令自动生成:
% \begin{itemize}
% \item 目录: \cs{tableofcontents}
% \item 图清单:\cs{listoffigures}
% \item 表清单:\cs{listoftables}
% \end{itemize}
%
%
% \subsection{浮动体}
%
% 图题置于图的下方,表题置于表的上方。
% \LaTeX{} 的 \cs{caption} 命令并不能控制在浮动体中的位置,
% 需要作者注意写在合适的地方。
%
% \DescribeMacro{\note}
% 本模板还提供了 \cs{note}\marg{notes} 命令,用于在图表中添加注释。
%
% 关于图片的并排,推荐使用较新的 \pkg{subcaption} 宏包,不建议使用
% \pkg{subfigure} 或 \pkg{subfig}。
%
% 更多的表格样式参见 \pkg{booktabs}(三线表)、\pkg{longtable}(跨页表格)。
%
% 算法可以使用 \pkg{algorithms} 宏包或者较新的 \pkg{algorithm2e}。
%
%
% \subsection{数学}
%
% \LaTeX{} 默认按照美国的习惯排版数学公式和符号,
% 但是本模板的数学符号依据《GB 3102.11--1993》执行,
% 与 \LaTeX{} 的习惯有所差异。
% 本模板基于 \pkg{unicode-math} 宏包配置数学符号,以遵循国标的规定。
%
% 注意,\pkg{unicode-math} 宏包与 \pkg{amsfonts}, \pkg{amssymb}, \pkg{bm},
% \pkg{mathrsfs}, \pkg{upgreek} 等宏包\emph{不}兼容。
% 本模板作了处理,用户可以直接使用这些宏包的命令,如 \cs{bm}, \cs{mathscr},
% \cs{upGamma}。
%
% \DescribeMacro{\symup}
% \DescribeMacro{\symbf}
% 本模板中数学符号的用法与 \LaTeX{} 传统有些区别:
% \begin{itemize}
% \item 数学常数和特殊函数使用正体,
% 如圆周率 $\symup{\pi}$、$\symup{\Gamma}$ 函数。
% 应使用 \pkg{unicode-math} 宏包提供的 \cs{symup} 命令转为正体,
% 如 |\symup{\pi}|。
% \item 向量、矩阵和张量要求粗斜体,应使用 \cs{symbf} 命令,
% 如 |\symbf{A}|、|\symbf{u}|。
% \item 有限增量符号 $\increment$ (U+2206)应使用 \cs{increment} 命令。
% \item 微分符号 $\mathrm{d}$ 使用正体,本模板提供了 \cs{dif} 命令。
% \end{itemize}
%
% 关于数学符号更多的用法,参见 \pkg{unicode-math} 宏包的使用说明和符号列表
% \pkg{unimath-symbols}。
%
%
% \subsection{参考文献}
%
% \DescribeOption{authoryear}
% \DescribeOption{super}
% \DescribeOption{numbers}
% 按照《GB/T 7714-2015》 的规定,
% 参考文献的标注体系分为“顺序编码制”和“著者-出版年制”(authoryear),
% 其中顺序编码制根据引用标注样式的不同分为角标数字式(super)
% 和与正文平排的数字式(numbers)。
%
% 推荐使用角标数字式顺序编码制(默认),
% 用户也可以在文档类参数中设置,如:
% \begin{latex}
% \documentclass[doctor,authoryear]{chinathesis}
% \end{latex}
%
% \DescribeMacro{\cite}
% 在正文中引用文献时应使用 \cs{cite} 命令。
% 同一处引用多篇文献时,需要将各篇文献的 key 一同写在参数中,
% 如 |\cite{knuth84,lamport94,mittelbach04}|。
% 它可以自动排序并用处理连续编号。
% 更多的引用标注方法可以参考 \pkg{natbib} 宏包的使用说明。
%
% \DescribeMacro{\inlinecite}
% 在使用角标数字式时,如果文献序号作为叙述文字的一部分,
% 需要临时将文献序号与正文平排,可以使用 \cs{inlinecite} 命令,如:
% \begin{latex}
% 文献~\inlinecite{knuth84} 提出了一种新的断行算法
% \end{latex}
%
% 若需要标出引文的页码,可以标在 \cs{cite} 的可选参数中,如
% |\cite[42]{knuth84}|。
%
% \DescribeMacro{\bibliography}
% 参考文献表可以使用 \BibTeX{} 生成,并在文中使用 \cs{bibliography} 命令调用。
% 注意文献列表的样式已经在模板中根据选项设置,
% 用户\emph{不再}需要使用 \cs{bibliographystyle} 命令。
%
% \BibTeX{} 默认情况下可以自动识别文献语言,并自动处理文献类型和载体类型标识,
% 但是在少数情况下需要用户手动指定,如:
% \begin{latex}
% @misc{citekey,
% language = {japanese},
% mark = {Z},
% medium = {DK},
% ...
% \end{latex}
% 可选的语言有 english, chinese, japanese, russian。
%
% 注意,国标规定参考文献表采用著者-出版年制组织时,各篇文献首先按文种集中,
% 然后按著者字顺和出版年排列;
% 中文文献可以按著者汉语拼音字顺排列,也可以按著者的笔画笔顺排列。
% 然而由于 \BibTeX{} 功能的局限性,无法自动获取著者姓名的拼音或笔画笔顺,
% 所以\emph{必须}在 bib 数据库中的 key 域手动录入著者姓名的拼音,如:
% \begin{latex}
% @book{capital,
% author = {马克思 and 恩格斯},
% key = {ma3 ke4 si1 en1 ge2 si1},
% ...
% \end{latex}
%
% \BibTeX{} 对自定义样式的支持比较有限,
% 所以用户只能通过修改 \file{bst} 文件来修改文献列表的格式。
% 本宏包提供了一些接口供用户更方便地修改。
%
% 在 \file{bst} 文件开始处的 |load.config| 函数中,
% 有一组配置参数用来控制样式,表~\ref{tab:config} 列出了每一项的默认值和功能。
% 若变量被设为 |#1| 则表示该项被启用,设为 |#0| 则不启用。
% 默认的值是严格遵循《GB/T 7714-2015》的配置。
%
% \begin{table}[htb]
% \centering\small
% \caption{参考文献表样式的配置参数}
% \label{tab:config}
% \begin{tabular}{lcl}
% \toprule
% 参数值 & 默认值 & 功能 \\
% \midrule
% uppercase.name & |#1| & 将著者姓名转为大写 \\
% max.num.authors & |#3| & 输出著者的最多数量 \\
% period.between.author.year & |#0| & 著者和年份之间使用句点连接 \\
% sentence.case.title & |#1| & 将西文的题名转为 sentence case \\
% link.title & |#0| & 在题名上添加 url 的超链接 \\
% show.mark & |#1| & 显示文献类型标识 \\
% italic.jounal & |#0| & 西文期刊名使用斜体 \\
% show.missing.address.publisher & |#1| & 出版项缺失时显示“出版者不详” \\
% show.url & |#1| & 显示 url \\
% show.doi & |#1| & 显示 doi \\
% show.note & |#0| & 显示 note 域的信息 \\
% \bottomrule
% \end{tabular}
% \end{table}
%
%
% \StopEventually
% \clearpage
% \appendix
%
%
% \section{代码实现}
% \label{sec:code}
% \linespread{1}
%
%
% \subsection{处理选项}
%
% 检查编译引擎,要求使用 XeLaTeX。
% \begin{macrocode}
\RequirePackage{ifxetex}
\RequireXeTeX
% \end{macrocode}
%
% \changes{v3.0.a}{2018/05/16}{更正本科生英文模板的章节格式}
% \begin{macrocode}
\newif\ifustc@doctor
\newif\ifustc@master
\newif\ifustc@bachelor
\newif\ifustc@chinese
\newif\ifustc@numerical
\newif\ifustc@super
\newif\ifustc@pdf
\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{chinese}{\ustc@chinesetrue}
\DeclareOption{english}{\ustc@chinesefalse}
\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*{\PassOptionsToClass{\CurrentOption}{ctexbook}}
\ExecuteOptions{doctor,chinese,print,super}
\ProcessOptions\relax
% \end{macrocode}
%
%
% \subsection{加载文档类和宏包}
%
% \begin{macrocode}
\ifustc@chinese
\PassOptionsToClass{scheme=chinese}{ctexbook}
\else
\PassOptionsToClass{scheme=plain}{ctexbook}
\fi
\ifustc@pdf
\PassOptionsToClass{oneside}{book}
\fi
\PassOptionsToPackage{quiet}{xeCJK}
% \end{macrocode}
%
% 载入 \cls{ctexbook} 文档类,注意要求为 2.2 或更高的版本。
% \begin{macrocode}
\LoadClass[UTF8,a4paper,openright,zihao=-4]{ctexbook}[2016/05/16]
% \end{macrocode}
%
% 检测 ctexbook 版本,如果版本过低会报错
% \begin{macrocode}
\@ifclasslater{ctexbook}{2016/05/16}{}{
\ClassError{chinathesis}{%
This template requires TeX Live\MessageBreak 2016 or later version}{}
}
% \end{macrocode}
%
% 建议在模板开始处载入全部宏包,不要轻易改变加载顺序。
% \pkg{hyperref} 一般在最后加载。
% \begin{macrocode}
\RequirePackage{amsmath}
\RequirePackage{unicode-math}
\RequirePackage{geometry}
\RequirePackage{graphicx}
\RequirePackage{fancyhdr}
\RequirePackage{titletoc}
\RequirePackage{caption}
\RequirePackage[perpage]{footmisc}
\RequirePackage{url}
\RequirePackage{calc}
\ifustc@numerical
\PassOptionsToPackage{sort&compress}{natbib}
\fi
\RequirePackage{natbib}
\RequirePackage{notoccite}
% \end{macrocode}
%
%
% \subsection{字体}
%
% \subsubsection{字体库}
%
% \begin{macro}{\ustc@strifeq}
% 使用 \LaTeX3 的功能判断字符串是否相等。这里也可以使用 \pkg{xstring} 宏包。
% \begin{macrocode}
\newcommand\ustc@strifeq{\csname str_if_eq_x:nnTF\endcsname}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ustc@fontset}
% 将 \pkg{ctex} 的 \opt{fontset} 存在 \cs{ustc@fontset} 方便 \LaTeXe{} 调用。
% \begin{macrocode}
\newcommand\ustc@fontset{\csname g__ctex_fontset_tl\endcsname}
% \end{macrocode}
% \end{macro}
%
% 大部分学位论文都要求西文字体使用 Times New Roman 和 Arial,
% 但是在 Linux 下没有这两个字体,所以使用它们的克隆版 TeX Gyre Termes 和
% TeX Gyre Heros。
% \begin{macrocode}
\ustc@strifeq{\ustc@fontset}{fandol}{
\setmainfont[
Extension = .otf,
UprightFont = *-regular,
BoldFont = *-bold,
ItalicFont = *-italic,
BoldItalicFont = *-bolditalic,
]{texgyretermes}
\setsansfont[
Extension = .otf,
UprightFont = *-regular,
BoldFont = *-bold,
ItalicFont = *-italic,
BoldItalicFont = *-bolditalic,
]{texgyreheros}
\setmonofont[
Extension = .otf,
UprightFont = *-regular,
BoldFont = *-bold,
ItalicFont = *-italic,
BoldItalicFont = *-bolditalic,
Scale = MatchLowercase,
]{texgyrecursor}
\ClassWarningNoLine{chinathesis}{%
You are using Fandol font family.\MessageBreak
Some glyphs may be missing.\MessageBreak
Please switch to a high-quality font set
}
}{
\setmainfont{Times New Roman}
\setsansfont{Arial}
\ustc@strifeq{\ustc@fontset}{mac}{
\setmonofont[Scale=MatchLowercase]{Menlo}
}{
\setmonofont[Scale=MatchLowercase]{Courier New}
}
}
% \end{macrocode}
%
% 中文字体可以由 \pkg{ctex} 自动设置,但是会有问题:
% \begin{enumerate}
% \item 无衬线字体默认会使用微软雅黑或者苹方,这对打印不太友好;
% \item 没有粗体的字体不会开启伪粗;
% \end{enumerate}
% 所以需要重新配置一部分,参考 \pkg{ctex} 宏包。
% \changes{v3.1.01}{2018/10/06}{调整伪粗体的粗细程度}
% \changes{v3.1.02}{2018/10/30}{修正 macOS 的伪粗黑体}
% \begin{macrocode}
\ustc@strifeq{\ustc@fontset}{mac}{
\setCJKmainfont[
UprightFont = * Light,
BoldFont = * Bold,
ItalicFont = Kaiti SC,
BoldItalicFont = Kaiti SC Bold,
]{Songti SC}
\setCJKsansfont[BoldFont=* Medium]{Heiti SC}
\setCJKfamilyfont{zhsong}[
UprightFont = * Light,
BoldFont = * Bold,
]{Songti SC}
\setCJKfamilyfont{zhhei}[BoldFont=* Medium]{Heiti SC}
\setCJKfamilyfont{zhkai}[BoldFont=* Bold]{Kaiti SC}
\xeCJKsetwidth{‘’“”}{1em}
}{
\xeCJKsetup{EmboldenFactor=2}
\ustc@strifeq{\ustc@fontset}{windows}{
\IfFileExists{C:/bootfont.bin}{
\setCJKmainfont[AutoFakeBold,ItalicFont=KaiTi_GB2312]{SimSun}
\setCJKfamilyfont{zhkai}[AutoFakeBold]{KaiTi_GB2312}
}{
\setCJKmainfont[AutoFakeBold,ItalicFont=KaiTi]{SimSun}
\setCJKfamilyfont{zhkai}[AutoFakeBold]{KaiTi}
}
\setCJKsansfont[AutoFakeBold]{SimHei}
\setCJKfamilyfont{zhsong}[AutoFakeBold]{SimSun}
\setCJKfamilyfont{zhhei}[AutoFakeBold]{SimHei}
}{
\ustc@strifeq{\ustc@fontset}{adobe}{
\setCJKmainfont[
AutoFakeBold = true,
ItalicFont = AdobeKaitiStd-Regular,
]{AdobeSongStd-Light}
\setCJKsansfont[AutoFakeBold]{AdobeHeitiStd-Regular}
\setCJKfamilyfont{zhsong}[AutoFakeBold]{AdobeSongStd-Light}
\setCJKfamilyfont{zhhei}[AutoFakeBold]{AdobeHeitiStd-Regular}
\setCJKfamilyfont{zhkai}[AutoFakeBold]{AdobeKaitiStd-Regular}
}{}
}
}
% \end{macrocode}
%
% 使用 \pkg{unicode-math} 配置数学字体。
% \begin{macrocode}
\unimathsetup{
math-style = ISO,
bold-style = ISO,
nabla = upright,
partial = upright,
}
% \end{macrocode}
%
% 使用 XITS Math 作为数学字体。
%
% 注意,\cs{IfFontExistsTF} 是 \pkg{fontspec} 2017/01/20 v2.5c 才提供的;
% 而 XITS 字体于 2018-10-03 更改了字体的文件名。
% \changes{v3.1.01}{2018/10/06}{同步 \pkg{xits} 字体文件名的修改}
% \changes{v3.1.05}{2019/04/21}{使用 XITS Math 作为数学字体}
% \begin{macrocode}
\newif\ifustc@xitsnew
\@ifpackagelater{fontspec}{2017/01/20}{
\IfFontExistsTF{XITSMath-Regular.otf}{
\ustc@xitsnewtrue
}{}
}{}
\ifustc@xitsnew
\setmathfont[
Extension = .otf,
BoldFont = XITSMath-Bold,
StylisticSet = 8,
]{XITSMath-Regular}
\setmathfont[range={cal,bfcal},StylisticSet=1]{XITSMath-Regular.otf}
\else
\setmathfont[
Extension = .otf,
BoldFont = *bold,
StylisticSet = 8,
]{xits-math}
\setmathfont[range={cal,bfcal},StylisticSet=1]{xits-math.otf}
\fi
% \end{macrocode}
%
% \begin{macro}{\ustc@circlefont}
% 五级节标题和脚注需要使用带圈数字,
% 但 Times New Roman 没有这些符号的字形,而华文宋体和中易宋体提供了这些字形,
% 配置在 \cs{ustc@circlefont}。
% \begin{macrocode}
\ustc@strifeq{\ustc@fontset}{mac}{
\newfontfamily\ustc@circlefont{Songti SC Light}
}{
\ustc@strifeq{\ustc@fontset}{windows}{
\newfontfamily\ustc@circlefont{SimSun}
}{
\ifustc@xitsnew
\newfontfamily\ustc@circlefont{XITS-Regular.otf}
\else
\newfontfamily\ustc@circlefont{xits-regular.otf}
\fi
}
}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{字号与行距}
%
% 目前最广泛使用的印刷的长度单位点(磅)通常指 PostScript point
% \footnote{\url{https://en.wikipedia.org/wiki/Point_(typography)}},
% 在 \LaTeX{} 中是 bp,比默认的 pt 略大。
% 这里保存起来可以节约编译时间。
% \begin{macrocode}
\newdimen\bp@
\bp@=1bp
% \end{macrocode}
%
% 字号的设置有两种方法:\cls{ctexbook} 的参数 \opt{zihao=-4} 和 \opt{zihao=5}
% 可以将正文的默认字号分别设为小四(12bp)或五号(10.5bp);
% 如果要求的正文字号不是这两个字号,就必须重定义 \cs{normalsize} 命令,
% 并且按照比例重定义 \cs{small}, \cs{large} 等一系列命令。
%
% \LaTeX{} 的行距是同字号一起设置的,通常规定行距的形式是固定行距,
% 比如要求“字号 12bp,行距 20 bp”。
% 如果使用 \pkg{ctex} 的字号设置,由于默认的基础行距为字号的 $1.2$ 倍,
% 还需要扩大 $20 / 12 / 1.2 \approx 1.39$ 倍,
% 所以应设置 |\linespread{1.39}|;
% 如果重定义 \cs{normalsize},就可以直接设置行距的值
% |\@setfontsize\normalsize{12\bp@}{20\bp@}|, 并设置 |\linespread{1}|;
% 注意这时不应再使用 \pkg{ctex} 的 \cs{zihao} 命令。
%
% 行距的另外一种形式是“$n$ 倍行距”,比如“字号 12bp、单倍行距”。
% 这里指的是 Microsoft Word 的“单倍行距”,其实际行距依赖使用的字体,
% 通常设置中易字体的“单倍行距”,它与字号的比值是 $332 / 256 \approx 1.30$
% \footnote{\url{https://github.com/CTeX-org/ctex-kit/tree/master/zhlineskip}},
% 设置方法与前文类似。
%
% 下面使用重定义 \cs{normalsize} 的方法设置正文字号 12bp,行距 20bp;
% 其他命令按照相同的的比例设置,如表~\ref{tab:fontsize}。
% \begin{table}[htb]
% \centering
% \caption{标准字体命令与字号、行距的对应}
% \label{tab:fontsize}
% \begin{tabular}{llll}
% \toprule
% 字体命令 & 字号 & bp & 行距 \\
% \midrule
% \cs{tiny} & 小六 & 6.5 & 10.83 \\
% \cs{scriptsize} & 六号 & 7.5 & 12.5 \\
% \cs{footnotesize} & 小五 & 9 & 15 \\
% \cs{small} & 五号 & 10.5 & 17.5 \\
% \cs{normalsize} & 小四 & 12 & 20 \\
% \cs{large} & 小三 & 15 & 25 \\
% \cs{Large} & 小二 & 18 & 30 \\
% \cs{LARGE} & 二号 & 22 & 36.67 \\
% \cs{huge} & 小一 & 24 & 40 \\
% \cs{Huge} & 一号 & 26 & 43.33 \\
% \bottomrule
% \end{tabular}
% \end{table}
% \begin{macrocode}
\renewcommand\normalsize{%
\@setfontsize\normalsize{12\bp@}{20\bp@}%
\abovedisplayskip 12\bp@ \@plus3\bp@ \@minus7\bp@
\abovedisplayshortskip \z@ \@plus3\bp@
\belowdisplayshortskip 6.5\bp@ \@plus3.5\bp@ \@minus3\bp@
\belowdisplayskip \abovedisplayskip
\let\@listi\@listI}
\normalsize
% \end{macrocode}
%
% 注意第~\ref{sec:list} 节去掉了列表的间距,所以不再修改 \cs{@listi}。
% \begin{macrocode}
\renewcommand\small{%
\@setfontsize\small{10.5\bp@}{17.5\bp@}%
\abovedisplayskip 10.5\bp@ \@plus3\bp@ \@minus6\bp@
\abovedisplayshortskip \z@ \@plus3\bp@
\belowdisplayshortskip 6.5\bp@ \@plus3.5\bp@ \@minus3\bp@
\belowdisplayskip \abovedisplayskip
}
\renewcommand\footnotesize{%
\@setfontsize\footnotesize{9\bp@}{15\bp@}%
\abovedisplayskip 9\bp@ \@plus2\bp@ \@minus5\bp@
\abovedisplayshortskip \z@ \@plus3\bp@
\belowdisplayshortskip 6\bp@ \@plus3\bp@ \@minus3\bp@
\belowdisplayskip \abovedisplayskip
}
\renewcommand\scriptsize{\@setfontsize\scriptsize{7.5\bp@}{12.5\bp@}}
\renewcommand\tiny{\@setfontsize\tiny{6.5\bp@}{10.83\bp@}}
\renewcommand\large{\@setfontsize\large{15\bp@}{25\bp@}}
\renewcommand\Large{\@setfontsize\Large{18\bp@}{30\bp@}}
\renewcommand\LARGE{\@setfontsize\LARGE{22\bp@}{36.67\bp@}}
\renewcommand\huge{\@setfontsize\huge{24\bp@}{40\bp@}}
\renewcommand\Huge{\@setfontsize\Huge{26\bp@}{43.33\bp@}}
% \end{macrocode}
%
% 设置行距的倍数为 1。
% \begin{macrocode}
\linespread{1}\selectfont
% \end{macrocode}
%
%
% \subsection{处理语言}
%
% 由于 Unicode 的一些标点符号是中西文混用的:
% \unicodechar{00B7}、
% \unicodechar{2013}、
% \unicodechar{2014}、
% \unicodechar{2018}、
% \unicodechar{2019}、
% \unicodechar{201C}、
% \unicodechar{201D}、
% \unicodechar{2025}、
% \unicodechar{2026}、
% \unicodechar{2E3A},
% 所以要根据语言设置正确的字体。
% \footnote{\url{https://github.com/CTeX-org/ctex-kit/issues/389}}
% 所以要根据语言设置正确的字体。
% \changes{v3.1.03}{2019/01/01}{修正英文模式下的 Unicode 引号字体}
% \begin{macrocode}
\newcommand\ustc@setchinese{%