Skip to content

Commit 5a01869

Browse files
committed
Remove unused options
1 parent a740149 commit 5a01869

File tree

1 file changed

+68
-62
lines changed

1 file changed

+68
-62
lines changed

ustcthesis.cls

Lines changed: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
% version 2008 or later.
1111
%
1212

13-
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
13+
\NeedsTeXFormat{LaTeX2e}[2020-10-01]
1414

1515
% 检查 LaTeXe kernel 版本
1616
\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
17-
\IfFormatAtLeastTF{2020/10/01}{}
17+
\IfFormatAtLeastTF{2020-10-01}{}
1818
{\ClassError{ustcthesis}{TeX Live 2021 or later version is required.}{}}
1919

2020
\newcommand\ustcthesisversion{4.0.0-beta.10}
@@ -95,7 +95,9 @@
9595
\bool_new:N \l__ustc_badge_color_black_bool
9696
\bool_new:N \l__ustc_eqn_paren_style_full_bool
9797

98-
\keys_define:nn { ustc }
98+
% \clist_new:N \l__ustc_unknown_options_clist
99+
100+
\keys_define:nn { ustc / options }
99101
{
100102
degree .choices:nn =
101103
{ doctor , master , bachelor }
@@ -106,6 +108,42 @@
106108
{ \bool_set_true:N \l__ustc_degree_graduate_bool }
107109
\l__ustc_degree_hook_tl
108110
} ,
111+
112+
degree-type .code:n = \keys_set:nn { ustc } { degree-type = {#1} } ,
113+
language .code:n = \keys_set:nn { ustc } { language = {#1} } ,
114+
fontset .choices:nn =
115+
{ auto , windows , mac , ubuntu , fandol , none }
116+
{ \str_set:NV \l__ustc_fontset_str \l_keys_choice_tl } ,
117+
font .code:n = \keys_set:nn { ustc } { font = {#1} } ,
118+
cjk-font .code:n = \keys_set:nn { ustc } { cjk-font = {#1} } ,
119+
math-font .code:n = \keys_set:nn { ustc } { math-font = {#1} } ,
120+
math-style .code:n = \keys_set:nn { ustc } { math-style = {#1} } ,
121+
output .choice: ,
122+
output / print .code:n =
123+
{
124+
\bool_set_false:N \l__ustc_output_electronic_bool
125+
\PassOptionsToClass { twoside } { ctexbook }
126+
} ,
127+
output / electronic .code:n =
128+
{
129+
\bool_set_true:N \l__ustc_output_electronic_bool
130+
\PassOptionsToClass { oneside } { ctexbook }
131+
} ,
132+
review .bool_set:N = \l__ustc_review_bool ,
133+
reviewer .bool_set:N = \l__ustc_reviewer_bool ,
134+
section-style .code:n = \keys_set:nn { ustc } { section-style = {#1} } ,
135+
cite-style .code:n = \keys_set:nn { ustc } { cite-style = {#1} } ,
136+
badge-color .code:n = \keys_set:nn { ustc } { badge-color = {#1} } ,
137+
eqn-paren-style .code:n = \keys_set:nn { ustc } { eqn-paren-style = {#1} } ,
138+
unknown .code:n =
139+
{
140+
% \clist_put_right:NV \l__ustc_unknown_options_clist \CurrentOption
141+
\PassOptionsToClass { \CurrentOption } { ctexbook }
142+
} ,
143+
}
144+
145+
\keys_define:nn { ustc }
146+
{
109147
degree-type .choices:nn =
110148
{ academic , professional , engineering }
111149
{ \str_set:NV \l__ustc_degree_type_str \l_keys_choice_tl } ,
@@ -120,9 +158,6 @@
120158
} ,
121159
review .bool_set:N = \l__ustc_review_bool ,
122160
reviewer .bool_set:N = \l__ustc_reviewer_bool ,
123-
fontset .choices:nn =
124-
{ auto , windows , mac , ubuntu , fandol , none }
125-
{ \str_set:NV \l__ustc_fontset_str \l_keys_choice_tl } ,
126161
font .choices:nn =
127162
{ auto , times , termes , stix , xits , libertinus , newcm , lm , newtx , cm , none }
128163
{
@@ -182,11 +217,6 @@
182217
\str_set:NV \l__ustc_cite_style_str \l_keys_choice_tl
183218
\l__ustc_cite_style_hook_tl
184219
} ,
185-
output .choice: ,
186-
output / print .code:n =
187-
{ \bool_set_false:N \l__ustc_output_electronic_bool } ,
188-
output / electronic .code:n =
189-
{ \bool_set_true:N \l__ustc_output_electronic_bool } ,
190220
section-style .choice: ,
191221
section-style / chinese .code:n =
192222
{ \bool_set_true:N \l__ustc_section_style_chinese_bool } ,
@@ -202,18 +232,21 @@
202232
{ \bool_set_true:N \l__ustc_eqn_paren_style_full_bool } ,
203233
eqn-paren-style / half .code:n =
204234
{ \bool_set_false:N \l__ustc_eqn_paren_style_full_bool } ,
205-
unknown .code:n =
206-
{ \PassOptionsToClass { \CurrentOption } { ctexbook } } ,
207235
}
208236

209-
\keys_set:nn { ustc }
237+
\keys_set:nn { ustc / options }
210238
{
211239
degree = doctor ,
240+
fontset = auto ,
241+
output = print ,
242+
}
243+
244+
\keys_set:nn { ustc }
245+
{
212246
degree-type = academic ,
213247
language = chinese ,
214248
review = false ,
215249
reviewer = false ,
216-
fontset = auto ,
217250
font = auto ,
218251
cjk-font = auto ,
219252
math-font = auto ,
@@ -258,17 +291,14 @@
258291
% 载入 \cls{ctexbook}。
259292
% \IfFormatAtLeastTF { 2022-06-01 }
260293
\cs_if_exist:NTF \ProcessKeyOptions
261-
{ \ProcessKeyOptions [ ustc ] }
294+
{ \ProcessKeyOptions [ ustc / options ] }
262295
{
263296
\RequirePackage { l3keys2e }
264-
\ProcessKeysOptions { ustc }
297+
\ProcessKeysOptions { ustc / options }
265298
}
266299

267-
\keys_set:nn { ustc }
268-
{ unknown .undefine: }
269-
270-
\bool_if:NT \l__ustc_output_electronic_bool
271-
{ \PassOptionsToClass { oneside } { ctexbook } }
300+
% \clist_map_inline:Nn \l__ustc_unknown_options_clist
301+
% { \PassOptionsToClass { #1 } { ctexbook } }
272302

273303
\PassOptionsToPackage { no-math } { fontspec }
274304

@@ -278,12 +308,12 @@
278308
% 载入 \cls{ctexbook} 文档类,注意要求为 2.4.9 或更高的版本。
279309
\LoadClass
280310
[ UTF8 , a4paper , scheme = plain , zihao = - 4 , fontset = none ]
281-
{ ctexbook } [ 2017/04/01 ]
311+
{ ctexbook } [ 2021-03-14 ]
282312

283313
% 建议在模板开始处载入全部宏包,不要轻易改变加载顺序。
284314
% \pkg{hyperref} 一般在最后加载。
285315
\RequirePackage { amsmath }
286-
\RequirePackage { fontspec } [ 2017/03/31 ]
316+
\RequirePackage { fontspec }
287317
\RequirePackage { geometry }
288318
\RequirePackage { graphicx }
289319
\RequirePackage { fancyhdr }
@@ -604,14 +634,14 @@
604634
\str_if_eq:VnT \l__ustc_fontset_str { auto }
605635
{
606636
\sys_if_platform_windows:TF
607-
{ \ustcsetup { fontset = windows } }
637+
{ \keys_set:nn { ustc / options } { fontset = windows } }
608638
{
609639
\fontspec_font_if_exist:nTF { SimSun }
610-
{ \ustcsetup { fontset = windows} }
640+
{ \keys_set:nn { ustc / options } { fontset = windows} }
611641
{
612642
\__ustc_if_platform_mac:TF
613-
{ \ustcsetup { fontset = mac } }
614-
{ \ustcsetup { fontset = fandol } }
643+
{ \keys_set:nn { ustc / options } { fontset = mac } }
644+
{ \keys_set:nn { ustc / options } { fontset = fandol } }
615645
}
616646
}
617647
}
@@ -1027,28 +1057,14 @@
10271057
{
10281058
\bool_if:NTF \l__ustc_leq_slanted_bool
10291059
{
1030-
\__ustc_if_preamble:TF
1031-
{
1032-
\AtBeginDocument
1033-
{
1034-
\cs_set_protected_nopar:Npn \le { \leqslant }
1035-
\cs_set_protected_nopar:Npn \ge { \geqslant }
1036-
}
1037-
}
1060+
\hook_gput_code:nnn { begindocument } { . }
10381061
{
10391062
\cs_set_protected_nopar:Npn \le { \leqslant }
10401063
\cs_set_protected_nopar:Npn \ge { \geqslant }
10411064
}
10421065
}
10431066
{
1044-
\__ustc_if_preamble:TF
1045-
{
1046-
\AtBeginDocument
1047-
{
1048-
\cs_set_protected_nopar:Npn \le { \leq }
1049-
\cs_set_protected_nopar:Npn \ge { \geq }
1050-
}
1051-
}
1067+
\hook_gput_code:nnn { begindocument } { . }
10521068
{
10531069
\cs_set_protected_nopar:Npn \le { \leq }
10541070
\cs_set_protected_nopar:Npn \ge { \geq }
@@ -1089,14 +1105,14 @@
10891105
{
10901106
\bool_if:NTF \l__ustc_real_part_roman_bool
10911107
{
1092-
\AtBeginDocument
1108+
\hook_gput_code:nnn { begindocument } { . }
10931109
{
10941110
\cs_set_protected:Npn \Re { \operatorname { Re } }
10951111
\cs_set_protected:Npn \Im { \operatorname { Im } }
10961112
}
10971113
}
10981114
{
1099-
\AtBeginDocument
1115+
\hook_gput_code:nnn { begindocument } { . }
11001116
{
11011117
\cs_set_eq:NN \Re \__ustc_save_real_part:
11021118
\cs_set_eq:NN \Im \__ustc_save_imaginary_part:
@@ -1128,7 +1144,7 @@
11281144
{ }
11291145
{
11301146
\RequirePackage { unicode-math }
1131-
\AtBeginDocument
1147+
\hook_gput_code:nnn { begindocument } { . }
11321148
{
11331149
\cs_set_eq:NN \__ustc_save_real_part: \Re
11341150
\cs_set_eq:NN \__ustc_save_imaginary_part: \Im
@@ -1139,7 +1155,7 @@
11391155
% 兼容 \pkg{amsfonts} 和 \pkg{amssymb} 中的一些命令。
11401156
\cs_new:Npn \square { \mdlgwhtsquare }
11411157
\cs_new:Npn \blacksquare { \mdlgblksquare }
1142-
\AtBeginDocument
1158+
\hook_gput_code:nnn { begindocument } { . }
11431159
{ \cs_set:Npn \checkmark { \ensuremath { ✓ } } }
11441160
% 兼容 \pkg{amsthm} 的 \cs{qedsymbol}。
11451161
\cs_set:Npn \__ustc_qed: { \ensuremath { \QED } }
@@ -1151,13 +1167,13 @@
11511167
{
11521168
\__ustc_load_unimath:
11531169
\__ustc_set_unimath_style:
1154-
\exp_args:NV \setmathfont STIXTwoMath-Regular
1170+
\setmathfont { STIXTwoMath-Regular }
11551171
[
11561172
Extension = .otf ,
11571173
Scale = MatchLowercase ,
11581174
StylisticSet = \__ustc_xits_integral_stylistic_set: ,
11591175
]
1160-
\exp_args:NV \setmathfont STIXTwoMath-Regular
1176+
\setmathfont { STIXTwoMath-Regular }
11611177
[
11621178
Extension = .otf ,
11631179
Scale = MatchLowercase ,
@@ -1747,7 +1763,7 @@
17471763
% 定义校徽颜色
17481764
%
17491765
% 推迟定义颜色以避免调用 \pkg{xcolor} 时的警告
1750-
\AtBeginDocument
1766+
\hook_gput_code:nnn { begindocument } { . }
17511767
{ \definecolor { ustcblue } { cmyk } { 1 , 0.8 , 0 , 0 } }
17521768
17531769
% 添加 PDF 书签,在 \pkg{hyperref} 载入后才有效。
@@ -3639,7 +3655,7 @@
36393655
{ \hypersetup { hidelinks } }
36403656
%
36413657
% 填写 PDF 元信息。
3642-
\AtBeginDocument
3658+
\hook_gput_code:nnn { begindocument } { . }
36433659
{
36443660
\bool_if:NTF \l__ustc_language_chinese_bool
36453661
{
@@ -3675,16 +3691,6 @@
36753691
\cs_set_eq:NN \hspace \@gobble
36763692
}
36773693
%
3678-
% \pkg{hyperref} 与 \pkg{unicode-math} 存在一些兼容性问题,见
3679-
% \href{https://github.com/ustctug/ustcthesis/issues/223}{%
3680-
% ustctug/ustcthesis\#223},
3681-
% \href{https://github.com/ho-tex/hyperref/pull/90}{ho-tex/hyperref\#90} 和
3682-
% \href{https://github.com/ustctug/ustcthesis/issues/235}{%
3683-
% ustctug/ustcthesis/\#235}。
3684-
\@ifpackagelater { hyperref } { 2019/04/27 }
3685-
{ }
3686-
{ \tl_put_right:Nn \psdmapshortnames { \cs_set_eq:NN \mu \textmu } }
3687-
%
36883694
% 设置中文的 \cs{autoref}。
36893695
% \footnote{\url{https://tex.stackexchange.com/a/66150/82731}}
36903696
\cs_new:Npn \__ustc_set_hyperref_autoref_names:

0 commit comments

Comments
 (0)