summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/shtthesis/shtthesis.cls
blob: ecaa022e92b1f00ec53ddf610fdabee2e22e81c3 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
% ==============================================================================
% Identification
% ==============================================================================
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{shtthesis}[%
  2020/06/05 %
  v0.2.0 %
  An Unofficial Thesis Template for ShanghaiTech University%
]
\hyphenation{sht-thesis}
\hyphenation{Sht-Thesis}
\RequirePackage{xspace}
\newcommand\shtthesis{\textup{\sffamily shtthesis}\xspace}
\newcommand\ShtThesis{\textup{\sffamily ShtThesis}\xspace}
\newcommand\version{0.2.0\xspace}
\newcommand\versiondate{2020/06/05\xspace}
% ==============================================================================
% Options and Declarations
% ==============================================================================
\RequirePackage{kvdefinekeys}
\RequirePackage{kvsetkeys}
\RequirePackage{kvoptions}
\RequirePackage{datetime}
% ------------------------------------------------------------------------------
%   Define \shtsetup command
%
%   Following key-value setup mechanism is adapted from `thuthesis'.
%   thuthesis (https://github.com/xueruini/thuthesis) is licensed under the
%   conditions of the LaTeX Project Public License, either version 1.3. 
% ------------------------------------------------------------------------------
\SetupKeyvalOptions{
  family = sht,
  prefix = {sht@},
  setkeys = \kvsetkeys,
}
\newcommand\sht@error[1]{%
  \ClassError{shtthesis}{#1}{}%
}
\newcommand\shtsetup{%
  \kvsetkeys{sht}%
}
\newcommand\sht@define@key[1]{%
  \kvsetkeys{sht@key}{#1}%
}
\kv@set@family@handler{sht@key}{%
  \@namedef{sht@#1@@name}{#1}%
  \def\sht@@default{}%
  \def\sht@@choices{}%
  \kv@define@key{sht@value}{name}{%
    \@namedef{sht@#1@@name}{##1}%
  }%
  \kv@define@key{sht@value}{code}{%
    \@namedef{sht@#1@@code}{##1}%
  }%
  \@namedef{sht@#1@@check}{}%
  \@namedef{sht@#1@@code}{}%
  \@namedef{sht@#1@@hook}{%
    \expandafter\ifx\csname\@currname.\@currext-h@@k\endcsname\relax
      \@nameuse{sht@#1@@code}%
    \else
      \AtEndOfClass{%
        \@nameuse{sht@#1@@code}%
      }%
    \fi
  }%
  \kv@define@key{sht@value}{choices}{%
    \def\sht@@choices{##1}%
    \@namedef{sht@#1@@reset}{}%
    \@namedef{sht@#1@@check}{%
      \@ifundefined{%
        ifsht@\@nameuse{sht@#1@@name}@\@nameuse{sht@\@nameuse{sht@#1@@name}}%
      }{%
        \sht@error{Invalid value "#1 = \@nameuse{sht@\@nameuse{sht@#1@@name}}"}%
      }%
      \@nameuse{sht@#1@@reset}%
      \@nameuse{sht@\@nameuse{sht@#1@@name}@\@nameuse{sht@\@nameuse{sht@#1@@name}}true}%
    }%
  }%
  \kv@define@key{sht@value}{default}{%
    \def\sht@@default{##1}%
  }%
  \kvsetkeys{sht@value}{#2}%
  \@namedef{sht@\@nameuse{sht@#1@@name}}{}%
  \kv@set@family@handler{sht@choice}{%
    \ifx\sht@@default\@empty
      \def\sht@@default{##1}%
    \fi
    \expandafter\newif\csname ifsht@\@nameuse{sht@#1@@name}@##1\endcsname
    \expandafter\g@addto@macro\csname sht@#1@@reset\endcsname{%
      \@nameuse{sht@\@nameuse{sht@#1@@name}@##1false}%
    }%
  }%
  \kvsetkeys@expandafter{sht@choice}{\sht@@choices}%
  \expandafter\let\csname sht@\@nameuse{sht@#1@@name}\endcsname\sht@@default
  \expandafter\ifx\csname sht@\@nameuse{sht@#1@@name}\endcsname\@empty\else
    \@nameuse{sht@#1@@check}%
    \@nameuse{sht@#1@@hook}%
  \fi
  \kv@define@key{sht}{#1}{%
    \@namedef{sht@\@nameuse{sht@#1@@name}}{##1}%
    \@nameuse{sht@#1@@check}%
    \@nameuse{sht@#1@@hook}%
  }%
}
% ------------------------------------------------------------------------------
%   Options for \shtsetup
% ------------------------------------------------------------------------------
\sht@define@key{
  degree = {
    choices = {
      bachelor,
      master,
      doctor,
      postdoc,
    },
    default = doctor,
  },
  degree-type = {
    choices = {
      academic,
      professional,
    },
    name = degree@type,
  },
  degree-name = {
    default = {工学博士},
    name    = degree@name,
  },
  degree-name* = {
    default = {Doctor~of~Philosophy},
    name    = degree@name@en,
  },
  language = {
    choices = {
      chinese,
      english,
    },
  },
  secret-level = {
    name = secret@level,
  },
  secret-year = {
    name = secret@year,
  },
  title = {
    default = {标题},
  },
  title* = {
    default = {Title},
    name    = title@en,
  },
  keywords,
  keywords* = {
    name = keywords@en,
  },
  author = {
    default = {姓名},
  },
  author* = {
    default = {Name of author},
    name    = author@en,
  },
  supervisor = {
    default = {导师姓名},
  },
  supervisor* = {
    default = {Name of supervisor},
    name    = supervisor@en,
  },
  supervisor-institution = {
    name = supervisor@institution,
  },
  supervisor-institution* = {
    name = supervisor@institution@en,
  },
  associate-supervisor = {
    name = associate@supervisor,
  },
  associate-supervisor* = {
    name = associate@supervisor@en,
  },
  associate-supervisor-institution = {
    name = associate@supervisor@institution,
  },
  associate-supervisor-institution* = {
    name = associate@supervisor@institution@en,
  },
  joint-supervisor = {
    name = joint@supervisor,
  },
  joint-supervisor* = {
    name = joint@supervisor@en,
  },
  joint-supervisor-institution = {
    name = joint@supervisor@institution,
  },
  joint-supervisor-institution* = {
    name = joint@supervisor@institution@en,
  },
  institution = {
    % default = {上海科技大学信息科学与技术学院},
  },
  institution* = {
    % default = {%
    %   School~of~Information~Science~and~Technology\\%
    %   ShanghaiTech~University%
    % },
    name = institution@en
  },
  discipline = {
    % default = {计算机科学与技术},
  },
  discipline* = {
    % default = {Computer Science and Technology},
    name = discipline@en,
  },
  date = {
    default = {\the\year~年~\the\month~月},
  },
  date* = {
    default = {\monthname,~\the\year},
    name = date@en,
  },
  clc,
  udc,
  id,
  discipline-level-1 = {
    default = {一级学科名称},
    name    = discipline@level@i,
  },
  discipline-level-1* = {
    default = {Name of Level-one Discipline},
    name    = discipline@level@i@en,
  },
  discipline-level-2 = {
    default = {二级学科名称},
    name    = discipline@level@ii,
  },
  discipline-level-2* = {
    default = {Name of Level-two Discipline},
    name    = discipline@level@ii@en,
  },
  start-date = {
    name    = start@date,
    default = {\the\year-\two@digits{\month}-\two@digits{\day}},
  },
  end-date = {
    name    = end@date,
    default = {\the\year-\two@digits{\month}-\two@digits{\day}},
  },
  anonymous-str = {
    name = anonymous@str,
    default = {***},
  }
}
% ------------------------------------------------------------------------------
%   Class options
% ------------------------------------------------------------------------------
\PassOptionsToClass{
  UTF8,
  a4paper,
  twoside, 
  openany, 
  zihao = -4, 
  scheme = plain,
}{ctexbook}
\SetupKeyvalOptions{
  family = sht,
  prefix = sht@,
}
\DeclareBoolOption[false]{anonymous}
\DeclareBoolOption[false]{print}
\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{ctexbook}}
\ProcessKeyvalOptions*
% ------------------------------------------------------------------------------
%   Load minimum mandatory packages
% ------------------------------------------------------------------------------
\LoadClass{ctexbook}
\RequirePackage[hyperref, table]{xcolor}
\RequirePackage{geometry}
\RequirePackage{calc}
\RequirePackage{verbatim}
\RequirePackage{etoolbox}
\RequirePackage{ifthen}
\RequirePackage{graphicx}
\RequirePackage{todonotes}
\RequirePackage{indentfirst}
\RequirePackage[normalem]{ulem}
\RequirePackage{fancyhdr}
\RequirePackage{tocvsec2}
\RequirePackage{letltxmacro}
\RequirePackage{fontspec}[2016/12/27]
\RequirePackage{caption}
\RequirePackage{natbib}
\RequirePackage[shortlabels, inline]{enumitem}
\RequirePackage{amsmath}
\RequirePackage{mathtools}
\RequirePackage[
  mathrm = sym,
  mathit = sym,
  mathbf = sym,
  mathtt = sym,
]{unicode-math}
\AtEndPreamble{
  \RequirePackage{hyperref}
  \hypersetup{
    pdfencoding = auto,
    psdextra = true,
    bookmarksnumbered = true,
    pdftitle = {\sht@title},
    pdfauthor = {\sht@author},
  }
  \ifsht@print
    \hypersetup{
      hidelinks,
      colorlinks = false,
    }
  \else
    \hypersetup{
      colorlinks = true,
      linkcolor = black,
      citecolor = blue,
      urlcolor = blue,
    }
  \fi
}
% ==============================================================================
% Format Specifications
% ==============================================================================
% ------------------------------------------------------------------------------
%   Basic information
% ------------------------------------------------------------------------------
\def\@title{\sht@title}
\def\@author{\sht@author}
\def\contentsname{目\hspace{1\ccwd}录}
\def\listfigurename{图形列表}
\def\listtablename{表格列表}
\def\appendixname{附录}
\def\indexname{索引}
\def\refname{参考文献}
\def\bibname{参考文献}
\def\tablename{表}
\def\figurename{图}
\def\bibetal{等}
\def\biband{和}
% ------------------------------------------------------------------------------
%   Geometry and layouts
% ------------------------------------------------------------------------------
\geometry{
  top = 2.54cm,
  bottom = 2.54cm,
  headheight = 12pt, % 9bp,
  headsep = 17.5pt, % 2.54cm - 9bp,
  footskip = 2.54cm - 1.75cm,
}
\ifsht@print
  \def\binding@width{0.63cm}
  \geometry{
    inner = 3.17cm + \binding@width,
    outer = 3.17cm - \binding@width,
  }
\else
  \geometry{
    inner = 3.17cm,
    outer = 3.17cm,
  }
\fi
\setlength{\parskip}{0.5ex plus 0.25ex minus 0.25ex}
\setlength{\parindent}{2\ccwd}
\linespread{1.6}
\raggedbottom
% ------------------------------------------------------------------------------
%   Headers and footers
% ------------------------------------------------------------------------------
\pagestyle{fancy}
\fancypagestyle{CenteralPageNumbered}{
  \fancyhf{}
  \pagenumbering{Roman}
  \fancyhead[C]{
    \footnotesize
    \ifnumodd{\value{page}}{
      \nouppercase\leftmark
    }{
      \nouppercase\@title
    }
  }
  \fancyfoot[C]{
    \footnotesize
    \thepage
  }
  \renewcommand{\headrulewidth}{0.8pt}
  \renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{LRPageNumbered}{
  \fancyhf{}
  \fancyhead[C]{
    \footnotesize
    \ifnumodd{\value{page}}{
      \nouppercase\leftmark
    }{
      \nouppercase\@title
    }
  }
  \fancyfoot[C]{
    \footnotesize
    \ifnumodd{\value{page}}{
      \hspace*{\fill}
      \thepage
    }{
      \thepage
      \hspace*{\fill}
    }
  }
  \renewcommand{\headrulewidth}{0.8pt}
  \renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{LRPageNumberedAppendix}{
  \fancyhf{}
  \fancyhead[C]{
    \footnotesize
    \ifnumodd{\value{page}}{%
      附\hspace{1\ccwd}录%
    }{
      \nouppercase\@title
    }
  }
  \fancyfoot[C]{
    \footnotesize
    \ifnumodd{\value{page}}{
      \hspace*{\fill}
      \thepage
    }{
      \thepage
      \hspace*{\fill}
    }
  }
  \renewcommand{\headrulewidth}{0.8pt}
  \renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{LRPageNumberedWithoutHead}{
  \fancyhf{}
  \fancyfoot[C]{
    \footnotesize
    \ifnumodd{\value{page}}{
      \hspace*{\fill}
      \thepage
    }{
      \thepage
      \hspace*{\fill}
    }
  }
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{Plain}{}
\providecommand{\frontmatter}{}
\LetLtxMacro{\TmpFrontmatter}{\frontmatter}
\renewcommand{\frontmatter}{%
  \TmpFrontmatter%
  \pagestyle{CenteralPageNumbered}%
}
\providecommand{\mainmatter}{}
\LetLtxMacro{\TmpMainmatter}{\mainmatter}
\renewcommand{\mainmatter}{%
  \TmpMainmatter%
  \pagestyle{LRPageNumbered}%
}
% ------------------------------------------------------------------------------
%   Font utilities
% ------------------------------------------------------------------------------
\newcommand\sht@fontset{\csname g__ctex_fontset_tl\endcsname}
\newcommand\currentfontset{\sht@fontset}
% ------------------------------------------------------------------------------
%   English fonts
% ------------------------------------------------------------------------------
\setmainfont{texgyretermes} [
  Extension      = .otf,
  UprightFont    = *-regular,
  BoldFont       = *-bold,
  ItalicFont     = *-italic,
  BoldItalicFont = *-bolditalic,
  Ligatures      = TeX,
]
\setsansfont{texgyreheros} [
  Extension      = .otf,
  UprightFont    = *-regular,
  BoldFont       = *-bold,
  ItalicFont     = *-italic,
  BoldItalicFont = *-bolditalic,
  Ligatures      = TeX,
]
\setmonofont{texgyrecursor} [
  Extension      = .otf,
  UprightFont    = *-regular,
  BoldFont       = *-bold,
  ItalicFont     = *-italic,
  BoldItalicFont = *-bolditalic,
  Ligatures      = CommonOff,
]
% ------------------------------------------------------------------------------
%   Chinese fonts
% ------------------------------------------------------------------------------
\ifthenelse{\equal{\sht@fontset}{windows}}{
  \def\fake@bold@factor{2.5}
  \IfFileExists{C:/bootfont.bin}{
    \def\windows@kaiti{KaiTi_GB2312}
  }{
    \def\windows@kaiti{KaiTi}
  }
  \setCJKmainfont[
      AutoFakeBold = \fake@bold@factor,
        ItalicFont = \windows@kaiti,
    ]{SimSun}
  \setCJKsansfont[
      AutoFakeBold = \fake@bold@factor,
    ]{SimHei}
  \setCJKfamilyfont{zhsong}[
      AutoFakeBold = \fake@bold@factor,
    ]{SimSun}
  \setCJKfamilyfont{zhhei}[
      AutoFakeBold = \fake@bold@factor,
    ]{SimHei}
  \setCJKfamilyfont{zhkai}[
      AutoFakeBold = \fake@bold@factor,
    ]{\windows@kaiti}
}{
  \ifthenelse{\equal{\sht@fontset}{mac}}{
    \setCJKmainfont[
           UprightFont = * Regular,
              BoldFont = * Bold,
            ItalicFont = Kaiti SC Regular,
        BoldItalicFont = Kaiti SC Bold,
      ]{Songti SC}
    \setCJKsansfont[
        UprightFont = * Light,
           BoldFont = * Medium,
      ]{Heiti SC}
    \setCJKfamilyfont{zhsong}[
        UprightFont = * Regular,
           BoldFont = * Bold,
      ]{Songti SC}
    \setCJKfamilyfont{zhhei}[
        UprightFont = * Light,
           BoldFont = * Medium,
      ]{Heiti SC}
    \setCJKfamilyfont{zhkai}[
        UprightFont = * Regular,
           BoldFont = * Bold,
      ]{Kaiti SC}
  }{
    \IfFontExistsTF{Source Han Serif SC}{
      \def\unix@songti{Source Han Serif SC}
      \def\unix@songti@bold{Source Han Serif SC Bold}
    }{
      \IfFontExistsTF{Noto Serif CJK SC}{
        \def\unix@songti{Noto Serif CJK SC}
        \def\unix@songti@bold{Noto Serif CJK SC Bold}
      }{
        \def\unix@songti{FandolSong-Regular.otf}
        \def\unix@songti@bold{FandolSong-Bold.otf}
      }
    }
    \IfFontExistsTF{Source Han Sans SC}{
      \def\unix@heiti{Source Han Sans SC}
      \def\unix@heiti@bold{Source Han Sans SC Bold}
    }{
      \IfFontExistsTF{Noto Sans CJK SC}{
        \def\unix@heiti{Noto Sans CJK SC}
        \def\unix@heiti@bold{Noto Sans CJK SC Bold}
      }{
        \def\unix@heiti{FandolHei-Regular.otf}
        \def\unix@heiti@bold{FandolHei-Bold.otf}
      }
    }
    \IfFontExistsTF{STKaiti}{
      \def\unix@kaiti{STKaiti}
    }{
      \IfFontExistsTF{Kaiti}{
        \def\unix@kaiti{Kaiti}
      }{
        \def\unix@kaiti{FandolKai-Regular.otf}
      }
    }
    \IfFontExistsTF{STFangsong}{
      \def\unix@fangsong{STFangsong}
    }{
      \IfFontExistsTF{FangSong}{
        \def\unix@fangsong{FangSong}
      }{
        \def\unix@fangsong{FandolFang-Regular.otf}
      }
    }
    \setCJKmainfont[
          BoldFont = \unix@songti@bold,
        ItalicFont = \unix@kaiti,
      ]{\unix@songti}
    \setCJKsansfont[
        BoldFont = \unix@heiti@bold,
      ]{\unix@heiti}
    \setCJKmonofont{\unix@fangsong}
    \setCJKfamilyfont{zhsong}[
        BoldFont = \unix@songti@bold,
      ]{\unix@songti}
    \setCJKfamilyfont{zhhei}[
        BoldFont = \unix@heiti@bold,
      ]{\unix@heiti}
    \setCJKfamilyfont{zhkai}{\unix@kaiti}
    \setCJKfamilyfont{zhfs}{\unix@fangsong}
    \providecommand{\songti}{\CJKfamily{zhsong}}
    \providecommand{\heiti}{\CJKfamily{zhhei}}
    \providecommand{\kaishu}{\CJKfamily{zhkai}}
    \providecommand{\fangsong}{\CJKfamily{zhfs}}
  }
}
% ------------------------------------------------------------------------------
%   Math content specifications
%
%   Following setup is adapted from `thuthesis'
% ------------------------------------------------------------------------------
\unimathsetup{
  math-style = ISO,
  bold-style = ISO,
  nabla      = upright,
  partial    = upright,
}
\protected\def\le{\leqslant}
\protected\def\ge{\geqslant}
\AtBeginDocument{%
  \renewcommand\leq{\leqslant}%
  \renewcommand\geq{\geqslant}%
}
\removenolimits{%
  \int\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
}
\AtBeginDocument{%
  \renewcommand{\Re}{\operatorname{Re}}%
  \renewcommand{\Im}{\operatorname{Im}}%
}
\newcommand\bm{\symbf}
\renewcommand\boldsymbol{\symbf}
\newcommand\square{\mdlgwhtsquare}
\AtBeginDocument{%
  \renewcommand\checkmark{\ensuremath{✓}}%
}
\allowdisplaybreaks[4]
\newtagform{dots}{\ldots\ (}{)}
\usetagform{dots}
\renewcommand{\eqref}[1]{\textup{(\ref{#1})}}
% ------------------------------------------------------------------------------
%   Math fonts
% ------------------------------------------------------------------------------
\IfFontExistsTF{XITSMath-Regular.otf}{
  \setmathfont{XITSMath-Regular} [
    Extension    = .otf,
    BoldFont     = XITSMath-Bold,
    StylisticSet = 8,
  ]
  \setmathfont{XITSMath-Regular.otf} [
    range        = {cal, bfcal},
    StylisticSet = 1,
  ]
  \setmathfont{XITSMath-Regular.otf} [
    range        = {scr, bfscr},
    StylisticSet = 2,
  ]
}{
  \setmathfont{xits-math} [
    Extension    = .otf,
    BoldFont     = *bold,
    StylisticSet = 8,
  ]
  \setmathfont{xits-math.otf} [
    range        = {cal, bfcal},
    StylisticSet = 1,
  ]
  \setmathfont{xits-math.otf} [
    range        = {scr, bfscr},
    StylisticSet = 2,
  ]
}
\IfFontExistsTF{FiraMath-Regular.otf}{
  \setmathfontface\mathsf{FiraMath-Regular.otf}
}{}
% ------------------------------------------------------------------------------
%   Utility functions for ToC and bookmarks
% ------------------------------------------------------------------------------
\newcommand{\artxmaincnt}{%
  \ifcsname c@chapter\endcsname%
    chapter%
  \else%
    section%
  \fi%
}
\long\def\artxaux#1{}
\newcommand{\intotocnostar}[3]{%
  % [<\chapter|...>,<*>,<title>]
  #1#2{%
    \phantomsection%
    \addcontentsline{toc}{\expandafter\artxaux\string#1}{#3}%
    #3%
  }
  \markboth{\MakeUppercase{#3}}{}%
}
\newcommand{\intotocstar}[3][\artxmaincnt]{%
  % [<chapter|...>,<extra commands>,<title>]
  #2%
  \phantomsection%
  \addcontentsline{toc}{#1}{#3}%
  \markboth{\MakeUppercase{#3}}{}%
}
\newcommand{\intotoc}{\@ifstar{\intotocstar}{\intotocnostar}}
\newcommand{\intobmknostar}[4][0]{%
  % [<level>,<\chapter|...>,<*>,<title>]
  #2#3{%
    \phantomsection%
    \Hy@writebookmark%
    {}%
    {#4}%
    {\@currentHref}%
    {#1}%
    {toc}%
    #4%
  }%
  \markboth{\MakeUppercase{#4}}{}%
}
\newcommand{\intobmkstar}[3][0]{%
  % [<level>,<extra commands>,<title>]
  #2%
  \phantomsection%
  \Hy@writebookmark%
  {}%
  {#3}%
  {\@currentHref}%
  {#1}%
  {toc}%
  \markboth{\MakeUppercase{#3}}{}%
}
\newcommand{\intobmk}{\@ifstar{\intobmkstar}{\intobmknostar}}
% ------------------------------------------------------------------------------
%   Table of contents, figures and tables
% ------------------------------------------------------------------------------
\DeclareCaptionFont{wuhaocuti}{\zihao{5}\bfseries}
\captionsetup{
  format = plain,
  hangindent = 2.0em,
  skip = 8pt,
  labelsep = quad,
  font = {wuhaocuti},
}
\def\@dotsep{1.5mu}
\def\@pnumwidth{2em}
\def\@tocrmarg{2em}
\def\@chaptervspace{1ex}
% [<level>,<indent>,<numwidth>,<title>,<page>]
\renewcommand*{\@dottedtocline}[5]{
  \ifnum #1>\c@tocdepth \else
    \vskip \z@ \@plus.2\p@
    {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
    \parindent #2\relax\@afterindenttrue
    \interlinepenalty\@M
    \leavevmode \zihao{-4}\heiti
    \@tempdima #3\relax
    \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
    {#4}\nobreak
    \leaders\hbox{$\m@th\mkern \@dotsep \cdot\mkern \@dotsep$}\hfill
    \nobreak
    \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
    \par\penalty\@highpenalty}%
  \fi
}
% [<title>,<page>]
\renewcommand*{\l@part}[2]{
  \ifnum \c@tocdepth >-2\relax
    \addpenalty{-\@highpenalty}%
    \addvspace{2.25em \@plus\p@}%
    \setlength\@tempdima{3em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      {\leavevmode
      \zihao{4}\heiti #1
      \leaders\hbox{$\m@th\mkern \@dotsep \cdot\mkern \@dotsep$}
      \hfil \hb@xt@\@pnumwidth{\hss #2}}\par
      \nobreak
      \global\@nobreaktrue
      \everypar{\global\@nobreakfalse\everypar{}}%
    \endgroup
  \fi
}
% [<title>,<page>]
\renewcommand*{\l@chapter}[2]{
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip \@chaptervspace \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \zihao{4}\heiti
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak
      \leaders\hbox{$\m@th\mkern \@dotsep \cdot\mkern \@dotsep$}
      \hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi
}
\renewcommand*\l@section{\@dottedtocline{1}{1em}{1.8em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{2em}{2.8em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{3em}{3.8em}}
\renewcommand*\l@paragraph{\@dottedtocline{4}{4em}{4.8em}}
\renewcommand*\l@subparagraph{\@dottedtocline{5}{5em}{5.8em}}
\renewcommand*\l@figure{\@dottedtocline{1}{1em}{1.8em}}
\renewcommand*\l@table{\@dottedtocline{1}{1em}{1.8em}}
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{3}
\newcommand{\makeindices}{%
  \begingroup%
  \linespread{1.2}%
  \intobmk*{\cleardoublepage}{\contentsname}%
  \tableofcontents%
  \intobmk*{\cleardoublepage}{\listfigurename}%
  \listoffigures%
  \intobmk*{\cleardoublepage}{\listtablename}%
  \listoftables%
  \endgroup%
}
% ------------------------------------------------------------------------------
%   Content specifications
% ------------------------------------------------------------------------------
\ctexset {
  chapter = {
    format = \bfseries\heiti\zihao{4}\linespread{1.0}\centering,
    nameformat = {},
    numberformat = \rmfamily,
    titleformat = {},
    name = {第, 章},
    number = \arabic{chapter},
    aftername = \hspace{1\ccwd},
    beforeskip = {7pt},
    afterskip = {18pt},
    pagestyle = Plain,
  },
  section = {
    format = \heiti\normalsize\linespread{1.0}\raggedright,
    nameformat = {},
    numberformat = \rmfamily,
    titleformat = {},
    aftername = \hspace{1\ccwd},
    beforeskip = {24pt},
    afterskip = {6pt},
  },
  subsection = {
    format = \heiti\normalsize\linespread{1.0}\raggedright,
    nameformat = {},
    numberformat = \rmfamily,
    titleformat = {},
    aftername = \hspace{1\ccwd},
    beforeskip = {12pt},
    afterskip = {6pt},
  },
  paragraph = {
    indent = 2\ccwd,
    beforeskip = {0pt},
    afterskip = {1\ccwd},
  },
  punct = quanjiao,
  space = auto,
  autoindent = true,
}
% ------------------------------------------------------------------------------
%   List environments
% ------------------------------------------------------------------------------
\newcommand{\textbf@with@colon}[1]{\textbf{#1:}}
\setlist{
  nosep,
  labelindent = 2\ccwd,
  labelwidth = *,
  labelsep = 0.5\ccwd,
  leftmargin = 0em,
  itemindent = *,
  listparindent = 2\ccwd,
}
\setlist[description]{
  labelsep = 0em,
  format = \normalfont\textbf@with@colon,
}
% ==============================================================================
% Cover Generation
% ==============================================================================
\def\ulhshift{-4em}
\newcommand{\ulunify}[1]{\uline{#1}}
\newcommand{\ulenhance}[2][1pt]{%
  \def\ULthickness{#1}%
  \setlength{\ULdepth}{0.3em}%
  \expandafter\ulunify\expandafter{#2}%
}
\newcommand{\ulextend}[2][350pt]{%
  \hbox to #1 {\hfill \hspace*{\ulhshift} #2 \hfill}%
}
\newcommand\sht@schoollogo{%
  \IfFileExists{shanghaitech-logo.pdf}{%
    \includegraphics[width=10.48cm]{shanghaitech-logo.pdf}%
  }{%
    \missingfigure[figwidth=10.48cm, figheight=2.79cm]{%
      \small 校徽文件 \texttt{shanghaitech-logo.pdf} 缺失,请至\href{https://github.com/lirundong/shtthesis/raw/master/shanghaitech-logo.pdf}{项目主页}下载!%
    }%
  }%
}
\renewcommand{\maketitle}{%
  \ifthenelse{\equal{\sht@degree}{doctor}}{
    \sht@maketitle@graduate{博士}
    \sht@maketitle@graduate@en{dissertation}
  }{
    \ifthenelse{\equal{\sht@degree}{master}}{
      \sht@maketitle@graduate{硕士}
      \sht@maketitle@graduate@en{thesis}
    }{
      \sht@error{Degree type `\sht@degree' is not supported yet}
    }
  }
  \ifthenelse{\not \boolean{sht@anonymous}}{%
    \makedeclarations%
  }{}
}
% ------------------------------------------------------------------------------
%   PhD/Master covers
% ------------------------------------------------------------------------------
\newcommand{\sht@maketitle@graduate}[1]{%
  \intobmk*{\cleardoublepage}{封面}
  \thispagestyle{empty}
  \begin{center}
    \linespread{1.6}\zihao{4}\bfseries
    \hfill{}
    \ifdefempty{\sht@secret@level}{}{%
      密级:%
      \ulenhance{%
        \ulextend[50pt]{%
          \hspace*{-\ulhshift} \zihao{5} \sht@secret@level%
        }%
      }%
    }

    \vspace*{\stretch{4}}

    \sht@schoollogo

    \vspace*{\stretch{2}}

    {\zihao{1}\heiti #1学位论文}

    \vspace*{\stretch{3}}

    {\zihao{-3}\heiti \ulenhance[1.5pt]{\sht@title}}

    \vspace*{\stretch{3}}

    {
      \songti
      \def\tabcolsep{1pt}
      \def\arraystretch{1.3}
      \begin{tabular}{llc}
        作者姓名:&
          \multicolumn{2}{c}{\ulenhance[1.2pt]{\ulextend{%
            \ifsht@anonymous%
              \sht@anonymous@str%
            \else%
              \sht@author%
            \fi%
          }}} \\
        指导教师:&
          \multicolumn{2}{c}{\ulenhance[1.2pt]{\ulextend{%
            \ifsht@anonymous%
              \sht@anonymous@str%
            \else%
              \sht@supervisor%
            \fi%
          }}} \\
        \ifdefempty{\sht@supervisor@institution}{}{ &
          \multicolumn{2}{c}{\ulenhance[1.2pt]{\ulextend{\sht@supervisor@institution}}} \\
        }
        学位类别:&
          \multicolumn{2}{c}{\ulenhance[1.2pt]{\ulextend{\sht@degree@name}}} \\
        一级学科:&
          \multicolumn{2}{c}{\ulenhance[1.2pt]{\ulextend{\sht@discipline@level@i}}} \\
        \multicolumn{2}{l}{学校/学院名称:} &
          \ulenhance[1.2pt]{\ulextend[318pt]{\sht@institution}} \\
      \end{tabular}
    }

    \vspace*{\stretch{4}}

    \sht@date

    \vspace{\stretch{4}}
  \end{center}
  \clearpage
  \thispagestyle{empty}
  \cleardoublepage
}
\newcommand{\sht@maketitle@graduate@en}[1]{
  \intobmk*{\cleardoublepage}{Cover}
  \thispagestyle{empty}
  \begin{center}
    \linespread{1.6}
    \zihao{4}\bfseries

    \vspace*{50pt}

    {\zihao{-3}\bfseries \ulenhance[1.5pt]{\sht@title@en}}

    \vspace*{\stretch{3}}

    {
      A~#1~submitted~to\\
      ShanghaiTech~University\\
      in~partial~fulfillment~of~the~requirement\\
      for~the~degree~of\\
      \ifthenelse{\equal{\sht@degree}{doctor}}{
        Doctor~of~Philosophy\\
      }{
        \sht@degree@name@en\\
      }
      in~\sht@discipline@level@i@en

      By

      \ifsht@anonymous%
        \sht@anonymous@str%
      \else%
        \sht@author@en%
      \fi%

      Supervisor:~%
      \ifsht@anonymous%
        \sht@anonymous@str%
      \else%
        \sht@supervisor@en%
      \fi%
    }

    \vspace*{\stretch{3}}

    {\sht@institution@en}

    \vspace*{\stretch{1}}

    {\sht@date@en}

    \vspace{\stretch{3}}
  \end{center}
  \clearpage
  \thispagestyle{empty}
  \cleardoublepage
}
% ------------------------------------------------------------------------------
%   Declarations
% ------------------------------------------------------------------------------
\newcommand{\makedeclarations}{%
  \intobmk*{\cleardoublepage}{声明}
  \thispagestyle{empty}
  {
    \linespread{1.6}\zihao{-4}

    \vspace*{2ex}

    \begin{center}
      {\zihao{4}\bfseries\sffamily 上海科技大学\\研究生学位论文原创性声明}
    \end{center}

    本人郑重声明:所呈交的学位论文是本人在导师的指导下独立进行研究工作所取得的成果。%
    尽我所知,除文中已经注明引用的内容外,本论文不包含任何其他个人或集体已经发表或撰写%
    过的研究成果。对论文所涉及的研究工作做出贡献的其他个人和集体,均已在文中以明确方式%
    标明或致谢。

    \vspace*{3ex}

    {\hfill{} {作者签名:\hspace*{14em}}}

    {\hfill{} {日\quad\quad 期:\hspace*{14em}}}

    \vspace*{6ex}

    \begin{center}
      {\zihao{4}\bfseries\sffamily 上海科技大学\\学位论文授权使用声明}
    \end{center}

    本人完全了解并同意遵守上海科技大学有关保存和使用学位论文的规定,即上海科技大学有权%
    保留送交学位论文的副本,允许该论文被查阅,可以按照学术研究公开原则和保护知识产权%
    的原则公布该论文的全部或部分内容,可以采用影印、缩印或其他复制手段保存、汇编本%
    学位论文。
    
    涉密及延迟公开的学位论文在解密或延迟期后适用本声明。

    \vspace*{3ex}

    {\hfill{} {作者签名:\hspace*{10em} 导师签名:\hspace*{9em}}}

    {\hfill{} {日\quad\quad 期:\hspace*{10em} 日\quad\quad 期:\hspace*{9em}}}

    \vspace{3ex}
  }
  \clearpage
  \thispagestyle{empty}
  \cleardoublepage
}
% ------------------------------------------------------------------------------
%   Abstract
% ------------------------------------------------------------------------------
\newenvironment{abstract}{%
  \cleardoublepage%
  \intobmk\chapter*{摘\hspace{1\ccwd}要}%
}{%
  \vspace{\baselineskip}%
  \par\noindent{\bfseries 关键词:} \sht@keywords%
}
\newenvironment{abstract*}{%
  \cleardoublepage%
  \intobmk\chapter*{Abstract}%
}{%
  \vspace{\baselineskip}%
  \par\noindent{\bfseries Key Words:} \sht@keywords@en%
}
% ------------------------------------------------------------------------------
%   Nomenclatures
% ------------------------------------------------------------------------------
\newcounter{sht@nomenclature@cnt}
\setcounter{sht@nomenclature@cnt}{0}
\def\sht@null@arg{}
\newenvironment{nomenclatures}[1][\sht@null@arg]{%
  \ifnum\thesht@nomenclature@cnt=0
    \cleardoublepage
    \intobmk\chapter*{符号列表}%
  \fi
  \stepcounter{sht@nomenclature@cnt}
  \ifthenelse{\not \equal{#1}{\sht@null@arg}}{
    \section*{#1}
  }{
    \par\vspace{24pt}
  }
  \renewcommand{\item}[3][\sht@null@arg]{
    \ifthenelse{\not \equal{##1}{\sht@null@arg}}{
      \par\noindent\makebox[0.15\columnwidth][l]{##2}{{##3}\hfill{##1}}
    }{
      \par\noindent\makebox[0.15\columnwidth][l]{##2}{##3}
    }
  }
  \providecommand{\header}[3][\sht@null@arg]{
    \item[\textbf{##1}]{\textbf{##2}}{\textbf{##3}}
  }
}{
}
% ------------------------------------------------------------------------------
%   Bibliography
% ------------------------------------------------------------------------------
\providecommand{\bibstyle@authoryear}{\bibpunct{(}{)}{;}{a}{,}{,}}
\citestyle{authoryear}
\bibliographystyle{shtthesis-gbt7714-plain}
\setlength{\bibsep}{0.0ex plus 0.2ex minus 0.2ex}
\renewcommand*{\bibfont}{\small}
\providecommand{\makebiblio}[1][reference]{%
  \intotoc*{\cleardoublepage}{\bibname}%
  \bibliography{#1}%
}
% ------------------------------------------------------------------------------
%   Appendix
% ------------------------------------------------------------------------------
\LetLtxMacro{\origin@appendix}{\appendix}
\renewcommand{\appendix}{%
  \origin@appendix
  \intotoc*{\cleardoublepage}{\appendixname}%
  \settocdepth{part}%
  \pagestyle{LRPageNumberedAppendix}%
}
% ------------------------------------------------------------------------------
%   Backmatter
% ------------------------------------------------------------------------------
\providecommand{\backmatter}{}
\LetLtxMacro{\origin@backmatter}{\backmatter}
\renewcommand{\backmatter}{%
  \origin@backmatter%
  \settocdepth{chapter}%
  \pagestyle{LRPageNumbered}%
}
\newcounter{sht@resume@cnt}
\setcounter{sht@resume@cnt}{0}
\newcommand{\sht@check@resume@title}{
  \ifnum\thesht@resume@cnt=0
    \cleardoublepage
    \chapter{作者简历及攻读学位期间发表的学术论文与研究成果}
  \fi
  \stepcounter{sht@resume@cnt}
}
\newenvironment{resume}{%
  \sht@check@resume@title
  \section*{作者简历:}
  \ifsht@anonymous
    \sht@anonymous@str\par
    \comment
  \fi
}{%
  \ifsht@anonymous
    \endcomment
  \fi
}
\newenvironment{publications}{%
  \sht@check@resume@title
  \ifsht@anonymous
    \comment
  \fi
  \section*{已发表(或正式接受)的学术论文:}
}{%
  \ifsht@anonymous
    \endcomment
  \fi
}
\newenvironment{publications*}{%
  \sht@check@resume@title
  \ifthenelse{\not \boolean{sht@anonymous}}{
    \comment
  }{}
  \section*{已发表(或正式接受)的学术论文:}
}{%
  \ifthenelse{\not \boolean{sht@anonymous}}{
    \endcomment
  }{}
}
\renewenvironment{patterns}{%
  \sht@check@resume@title
  \ifsht@anonymous
    \comment
  \fi
  \section*{申请或已获得的专利:}
}{%
  \ifsht@anonymous
    \endcomment
  \fi
}
\newenvironment{patterns*}{%
  \sht@check@resume@title
  \ifthenelse{\not \boolean{sht@anonymous}}{
    \comment
  }{}
  \section*{申请或已获得的专利:}
}{%
  \ifthenelse{\not \boolean{sht@anonymous}}{
    \endcomment
  }{}
}
\newenvironment{projects}{%
  \sht@check@resume@title
  \section*{参加的研究项目及获奖情况:}
  \ifsht@anonymous
    \sht@anonymous@str\par
    \comment
  \fi
}{%
  \ifsht@anonymous
    \endcomment
  \fi
}
\newenvironment{acknowledgement}{%
  \ifsht@anonymous
    \comment
  \else
    \cleardoublepage
    \chapter[致谢]{致\hspace{1\ccwd}谢}\chaptermark{致\hspace{1\ccwd}谢}%
  \fi
}{%
  \ifsht@anonymous
    \endcomment
  \fi
}
% ==============================================================================
% Post-processing
% ==============================================================================
\AtEndDocument{
  \cleardoublepage
}
\endinput