|
10 | 10 | % version 2008 or later. |
11 | 11 | % |
12 | 12 |
|
13 | | -\NeedsTeXFormat{LaTeX2e}[2020/10/01] |
| 13 | +\NeedsTeXFormat{LaTeX2e}[2020-10-01] |
14 | 14 |
|
15 | 15 | % 检查 LaTeXe kernel 版本 |
16 | 16 | \providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} |
17 | | -\IfFormatAtLeastTF{2020/10/01}{} |
| 17 | +\IfFormatAtLeastTF{2020-10-01}{} |
18 | 18 | {\ClassError{ustcthesis}{TeX Live 2021 or later version is required.}{}} |
19 | 19 |
|
20 | 20 | \newcommand\ustcthesisversion{4.0.0-beta.10} |
|
95 | 95 | \bool_new:N \l__ustc_badge_color_black_bool |
96 | 96 | \bool_new:N \l__ustc_eqn_paren_style_full_bool |
97 | 97 |
|
98 | | -\keys_define:nn { ustc } |
| 98 | +% \clist_new:N \l__ustc_unknown_options_clist |
| 99 | + |
| 100 | +\keys_define:nn { ustc / options } |
99 | 101 | { |
100 | 102 | degree .choices:nn = |
101 | 103 | { doctor , master , bachelor } |
|
106 | 108 | { \bool_set_true:N \l__ustc_degree_graduate_bool } |
107 | 109 | \l__ustc_degree_hook_tl |
108 | 110 | } , |
| 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 | + { |
109 | 147 | degree-type .choices:nn = |
110 | 148 | { academic , professional , engineering } |
111 | 149 | { \str_set:NV \l__ustc_degree_type_str \l_keys_choice_tl } , |
|
120 | 158 | } , |
121 | 159 | review .bool_set:N = \l__ustc_review_bool , |
122 | 160 | 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 } , |
126 | 161 | font .choices:nn = |
127 | 162 | { auto , times , termes , stix , xits , libertinus , newcm , lm , newtx , cm , none } |
128 | 163 | { |
|
182 | 217 | \str_set:NV \l__ustc_cite_style_str \l_keys_choice_tl |
183 | 218 | \l__ustc_cite_style_hook_tl |
184 | 219 | } , |
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 } , |
190 | 220 | section-style .choice: , |
191 | 221 | section-style / chinese .code:n = |
192 | 222 | { \bool_set_true:N \l__ustc_section_style_chinese_bool } , |
|
202 | 232 | { \bool_set_true:N \l__ustc_eqn_paren_style_full_bool } , |
203 | 233 | eqn-paren-style / half .code:n = |
204 | 234 | { \bool_set_false:N \l__ustc_eqn_paren_style_full_bool } , |
205 | | - unknown .code:n = |
206 | | - { \PassOptionsToClass { \CurrentOption } { ctexbook } } , |
207 | 235 | } |
208 | 236 |
|
209 | | -\keys_set:nn { ustc } |
| 237 | +\keys_set:nn { ustc / options } |
210 | 238 | { |
211 | 239 | degree = doctor , |
| 240 | + fontset = auto , |
| 241 | + output = print , |
| 242 | + } |
| 243 | + |
| 244 | +\keys_set:nn { ustc } |
| 245 | + { |
212 | 246 | degree-type = academic , |
213 | 247 | language = chinese , |
214 | 248 | review = false , |
215 | 249 | reviewer = false , |
216 | | - fontset = auto , |
217 | 250 | font = auto , |
218 | 251 | cjk-font = auto , |
219 | 252 | math-font = auto , |
|
258 | 291 | % 载入 \cls{ctexbook}。 |
259 | 292 | % \IfFormatAtLeastTF { 2022-06-01 } |
260 | 293 | \cs_if_exist:NTF \ProcessKeyOptions |
261 | | - { \ProcessKeyOptions [ ustc ] } |
| 294 | + { \ProcessKeyOptions [ ustc / options ] } |
262 | 295 | { |
263 | 296 | \RequirePackage { l3keys2e } |
264 | | - \ProcessKeysOptions { ustc } |
| 297 | + \ProcessKeysOptions { ustc / options } |
265 | 298 | } |
266 | 299 |
|
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 } } |
272 | 302 |
|
273 | 303 | \PassOptionsToPackage { no-math } { fontspec } |
274 | 304 |
|
|
278 | 308 | % 载入 \cls{ctexbook} 文档类,注意要求为 2.4.9 或更高的版本。 |
279 | 309 | \LoadClass |
280 | 310 | [ UTF8 , a4paper , scheme = plain , zihao = - 4 , fontset = none ] |
281 | | - { ctexbook } [ 2017/04/01 ] |
| 311 | + { ctexbook } [ 2021-03-14 ] |
282 | 312 |
|
283 | 313 | % 建议在模板开始处载入全部宏包,不要轻易改变加载顺序。 |
284 | 314 | % \pkg{hyperref} 一般在最后加载。 |
285 | 315 | \RequirePackage { amsmath } |
286 | | -\RequirePackage { fontspec } [ 2017/03/31 ] |
| 316 | +\RequirePackage { fontspec } |
287 | 317 | \RequirePackage { geometry } |
288 | 318 | \RequirePackage { graphicx } |
289 | 319 | \RequirePackage { fancyhdr } |
|
604 | 634 | \str_if_eq:VnT \l__ustc_fontset_str { auto } |
605 | 635 | { |
606 | 636 | \sys_if_platform_windows:TF |
607 | | - { \ustcsetup { fontset = windows } } |
| 637 | + { \keys_set:nn { ustc / options } { fontset = windows } } |
608 | 638 | { |
609 | 639 | \fontspec_font_if_exist:nTF { SimSun } |
610 | | - { \ustcsetup { fontset = windows} } |
| 640 | + { \keys_set:nn { ustc / options } { fontset = windows} } |
611 | 641 | { |
612 | 642 | \__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 } } |
615 | 645 | } |
616 | 646 | } |
617 | 647 | } |
|
1027 | 1057 | { |
1028 | 1058 | \bool_if:NTF \l__ustc_leq_slanted_bool |
1029 | 1059 | { |
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 } { . } |
1038 | 1061 | { |
1039 | 1062 | \cs_set_protected_nopar:Npn \le { \leqslant } |
1040 | 1063 | \cs_set_protected_nopar:Npn \ge { \geqslant } |
1041 | 1064 | } |
1042 | 1065 | } |
1043 | 1066 | { |
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 } { . } |
1052 | 1068 | { |
1053 | 1069 | \cs_set_protected_nopar:Npn \le { \leq } |
1054 | 1070 | \cs_set_protected_nopar:Npn \ge { \geq } |
|
1089 | 1105 | { |
1090 | 1106 | \bool_if:NTF \l__ustc_real_part_roman_bool |
1091 | 1107 | { |
1092 | | - \AtBeginDocument |
| 1108 | + \hook_gput_code:nnn { begindocument } { . } |
1093 | 1109 | { |
1094 | 1110 | \cs_set_protected:Npn \Re { \operatorname { Re } } |
1095 | 1111 | \cs_set_protected:Npn \Im { \operatorname { Im } } |
1096 | 1112 | } |
1097 | 1113 | } |
1098 | 1114 | { |
1099 | | - \AtBeginDocument |
| 1115 | + \hook_gput_code:nnn { begindocument } { . } |
1100 | 1116 | { |
1101 | 1117 | \cs_set_eq:NN \Re \__ustc_save_real_part: |
1102 | 1118 | \cs_set_eq:NN \Im \__ustc_save_imaginary_part: |
|
1128 | 1144 | { } |
1129 | 1145 | { |
1130 | 1146 | \RequirePackage { unicode-math } |
1131 | | - \AtBeginDocument |
| 1147 | + \hook_gput_code:nnn { begindocument } { . } |
1132 | 1148 | { |
1133 | 1149 | \cs_set_eq:NN \__ustc_save_real_part: \Re |
1134 | 1150 | \cs_set_eq:NN \__ustc_save_imaginary_part: \Im |
|
1139 | 1155 | % 兼容 \pkg{amsfonts} 和 \pkg{amssymb} 中的一些命令。 |
1140 | 1156 | \cs_new:Npn \square { \mdlgwhtsquare } |
1141 | 1157 | \cs_new:Npn \blacksquare { \mdlgblksquare } |
1142 | | - \AtBeginDocument |
| 1158 | + \hook_gput_code:nnn { begindocument } { . } |
1143 | 1159 | { \cs_set:Npn \checkmark { \ensuremath { ✓ } } } |
1144 | 1160 | % 兼容 \pkg{amsthm} 的 \cs{qedsymbol}。 |
1145 | 1161 | \cs_set:Npn \__ustc_qed: { \ensuremath { \QED } } |
|
1151 | 1167 | { |
1152 | 1168 | \__ustc_load_unimath: |
1153 | 1169 | \__ustc_set_unimath_style: |
1154 | | - \exp_args:NV \setmathfont STIXTwoMath-Regular |
| 1170 | + \setmathfont { STIXTwoMath-Regular } |
1155 | 1171 | [ |
1156 | 1172 | Extension = .otf , |
1157 | 1173 | Scale = MatchLowercase , |
1158 | 1174 | StylisticSet = \__ustc_xits_integral_stylistic_set: , |
1159 | 1175 | ] |
1160 | | - \exp_args:NV \setmathfont STIXTwoMath-Regular |
| 1176 | + \setmathfont { STIXTwoMath-Regular } |
1161 | 1177 | [ |
1162 | 1178 | Extension = .otf , |
1163 | 1179 | Scale = MatchLowercase , |
|
1747 | 1763 | % 定义校徽颜色 |
1748 | 1764 | % |
1749 | 1765 | % 推迟定义颜色以避免调用 \pkg{xcolor} 时的警告 |
1750 | | -\AtBeginDocument |
| 1766 | +\hook_gput_code:nnn { begindocument } { . } |
1751 | 1767 | { \definecolor { ustcblue } { cmyk } { 1 , 0.8 , 0 , 0 } } |
1752 | 1768 |
|
1753 | 1769 | % 添加 PDF 书签,在 \pkg{hyperref} 载入后才有效。 |
|
3639 | 3655 | { \hypersetup { hidelinks } } |
3640 | 3656 | % |
3641 | 3657 | % 填写 PDF 元信息。 |
3642 | | - \AtBeginDocument |
| 3658 | + \hook_gput_code:nnn { begindocument } { . } |
3643 | 3659 | { |
3644 | 3660 | \bool_if:NTF \l__ustc_language_chinese_bool |
3645 | 3661 | { |
|
3675 | 3691 | \cs_set_eq:NN \hspace \@gobble |
3676 | 3692 | } |
3677 | 3693 | % |
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 | | - % |
3688 | 3694 | % 设置中文的 \cs{autoref}。 |
3689 | 3695 | % \footnote{\url{https://tex.stackexchange.com/a/66150/82731}} |
3690 | 3696 | \cs_new:Npn \__ustc_set_hyperref_autoref_names: |
|
0 commit comments