Debian Codegraph @

texmf-dist/tex/latex/ctex/ctexrep.cls

raw
1 %%
2 %% This is file `ctexrep.cls',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% ctex.dtx (with options: `class,report')
8 %%
9 %% Copyright (C) 2003--2022
10 %% CTEX.ORG and any individual authors listed in the documentation.
11 %% ---------------------------------------------------------------------
12 %%
13 %% This work may be distributed and/or modified under the
14 %% conditions of the LaTeX Project Public License, either
15 %% version 1.3c of this license or (at your option) any later
16 %% version. This version of this license is in
17 %% http://www.latex-project.org/lppl/lppl-1-3c.txt
18 %% and the latest version of this license is in
19 %% http://www.latex-project.org/lppl.txt
20 %% and version 1.3 or later is part of all distributions of
21 %% LaTeX version 2005/12/01 or later.
22 %%
23 %% This work has the LPPL maintenance status "maintained".
24 %%
25 %% ---------------------------------------------------------------------
26 %%
27 \NeedsTeXFormat{LaTeX2e}
28 \input{ctexbackend.cfg}
29 \RequirePackage{expl3}
30 \GetIdInfo$Id: ctex.dtx 13a2256 2022-07-14 18:54:09 +0800 Qing Lee <[email protected]> $
31 {Chinese adapter for class report (CTEX)}
32 \ProvidesExplClass{ctexrep}
33 {\ExplFileDate}{2.5.10}{\ExplFileDescription}
34 \cs_if_exist:NF \NewDocumentCommand
35 { \RequirePackage { xparse } }
36 \prop_gput:Nnn \g_msg_module_type_prop { ctex } { Class }
37 \prop_gput:Nnn \g_msg_module_name_prop { ctex } { ctexrep }
38 \msg_new:nnnn { ctex } { l3-too-old }
39 { Support~package~`#1'~too~old. }
40 {
41 Please~update~an~up-to-date~version~of~the~bundles\\\\
42 `l3kernel'~and~`l3packages'\\\\
43 using~your~TeX~package~manager~or~from~CTAN.
44 }
45 \@ifpackagelater { expl3 } { 2021/02/10 } { }
46 { \msg_error:nnn { ctex } { l3-too-old } { expl3 } }
47 \str_const:Nx \c__ctex_engine_str
48 { \cs_if_exist:NTF \ngostype { aptex } { \c_sys_engine_str } }
49 \msg_new:nnnn { ctex } { engine-not-supported }
50 { Engine~`#1'~is~not~yet~supported,~ctex~will~abort! }
51 { You~can~switch~to~xelatex,~lualatex,~pdflatex,~uplatex,~or~aplatex. }
52 \file_if_exist:nTF { ctex-engine- \c__ctex_engine_str .def }
53 {
54 \str_const:Nx \c__ctex_engine_file_str
55 { ctex-engine- \c__ctex_engine_str .def }
56 }
57 { \msg_critical:nnx { ctex } { engine-not-supported } { \c__ctex_engine_str } }
58 \RequirePackage { ctexhook , ctexpatch }
59 \RequirePackage { fix-cm }
60 \ctex_disable_package:n { ctex }
61 \ctex_disable_package:n { ctexcap }
62 \ctex_disable_package:n { ctexsize }
63 \ctex_disable_package:n { ctexheading }
64 \ctex_if_format_at_least:nTF { 2021/06/01 }
65 { \bool_const:Nn \c__ctex_everysel_loaded_bool { \c_false_bool } }
66 {
67 \RequirePackage { everysel }
68 \bool_const:Nn \c__ctex_everysel_loaded_bool { \c_true_bool }
69 }
70 \tl_clear_new:N \l__ctex_tmp_tl
71 \int_new:N \l__ctex_tmp_int
72 \box_new:N \l__ctex_tmp_box
73 \dim_new:N \l__ctex_tmp_dim
74 \cs_new_protected:Npn \ctex_define_option:n
75 { \keys_define:nn { ctex / option } }
76 \cs_new_protected:Npn \ctex_define:n
77 { \keys_define:nn { ctex } }
78 \cs_new_protected:Npn \ctex_set:n
79 { \keys_set:nn { ctex } }
80 \cs_new_protected:Npn \ctex_set:nn #1
81 { \keys_set:nn { ctex / #1 } }
82 \cs_new_protected:Npn \ctex_scheme_input:n #1
83 {
84 \ctex_push_file:
85 \tl_if_exist:NTF \c__ctex_class_tl
86 {
87 \file_if_exist_input:nF { ctex-scheme- #1 - \c__ctex_class_tl .def }
88 { \file_input:n { ctex-scheme- #1 .def } }
89 }
90 { \file_input:n { ctex-scheme- #1 .def } }
91 \ctex_pop_file:
92 }
93 \cs_generate_variant:Nn \ctex_scheme_input:n { o }
94 \int_new:N \g__ctex_section_depth_int
95 \int_gset:Nn \g__ctex_section_depth_int { 2 }
96 \msg_new:nnnn { ctex } { package-too-old }
97 { Support~package~`#1'~too~old. }
98 {
99 Please~update~an~up-to-date~version~of~the~package~`#1'\\
100 using~your~TeX~package~manager~or~from~CTAN.
101 }
102 \sys_if_output_pdf:TF
103 { \cs_new_eq:NN \ifctexpdf \if_true: }
104 { \cs_new_eq:NN \ifctexpdf \if_false: }
105 \cs_new_eq:NN \ctex_if_preamble:TF \use_i:nn
106 \ctex_after_end_preamble:n { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn }
107 \cs_new_protected:Npn \ctex_set_default_ccwd:Nn #1#2
108 { \tl_set:Nx #1 { \__ctex_default_ccwd_aux:n {#2} } }
109 \cs_new:Npn \__ctex_default_ccwd_aux:n #1
110 {
111 \exp_not:n {#1}
112 \exp_after:wN \__ctex_default_ccwd_aux:w
113 \dim_use:N \tex_dimexpr:D #1 pt \scan_stop: \q_stop
114 }
115 \exp_last_unbraced:NNNNo
116 \cs_new:Npn \__ctex_default_ccwd_aux:w #1 { \tl_to_str:n { pt } } #2 \q_stop
117 { \tl_if_empty:nT {#2} { \ccwd } }
118 \tl_new:N \g__ctex_encoding_tl
119 \bool_new:N \g__ctex_zhmCJK_bool
120 \tl_new:N \l__ctex_autoindent_tl
121 \cs_new_eq:NN \ctex_if_autoindent_touched:F \use:n
122 \cs_new_eq:NN \ctex_zhmap_case:nnn \use_ii:nnn
123 \cs_new_protected:Npn \ctex_at_end:n { \AtEndOfClass }
124 \cs_new_protected:Npn \ctex_load_std_class:n #1
125 {
126 \tl_const:Nn \c__ctex_class_tl {#1}
127 \exp_args:No \PassOptionsToClass
128 { \g__ctex_std_options_clist }
129 {#1}
130 \LoadClass {#1}
131 }
132 \clist_new:N \g__ctex_std_options_clist
133 \msg_new:nnn { ctex } { invalid-option }
134 { Option~`\l_keys_key_tl'~is~invalid~in~current~mode. }
135 \msg_new:nnn { ctex } { invalid-value }
136 { Value~`#1'~is~invalid~for~the~key~`\l_keys_key_tl'. }
137 \cs_new_protected:Npn \ctex_deprecated_option:n
138 { \msg_warning:nnn { ctex } { deprecated-option } }
139 \cs_new_protected:Npn \ctex_set_deprecated_option:n #1
140 {
141 \ctex_deprecated_option:n { Option~`#1'~is~set. }
142 \ctex_set:nn { option } {#1}
143 }
144 \cs_new_protected:Npn \ctex_deprecated_command:Nn #1#2
145 {
146 \msg_warning:nnxx { ctex } { deprecated-command }
147 { \token_to_str:N #1 } { \exp_not:n {#2} }
148 }
149 \msg_new:nnn { ctex } { deprecated-option }
150 { Option~`\l_keys_key_tl'~is~deprecated.\\ #1 }
151 \msg_new:nnn { ctex } { deprecated-command }
152 { Command~`#1'~is~deprecated.\\ #2 }
153 \int_new:N \g__ctex_font_size_int
154 \int_gset:Nn \g__ctex_font_size_int { -1 }
155 \ctex_define_option:n
156 {
157 zihao .choice: ,
158 zihao .value_required:n = true ,
159 zihao / 5 .code:n = { \int_gset:Nn \g__ctex_font_size_int { 0 } } ,
160 zihao / -4 .code:n = { \int_gset:Nn \g__ctex_font_size_int { 1 } } ,
161 zihao / false .code:n = { \int_gset:Nn \g__ctex_font_size_int { 2 } } ,
162 c5size .code:n = { \ctex_set_deprecated_option:n { zihao = 5 } } ,
163 cs4size .code:n = { \ctex_set_deprecated_option:n { zihao = -4 } } ,
164 c5size .value_forbidden:n = true ,
165 cs4size .value_forbidden:n = true ,
166 linespread .fp_set:N = \l__ctex_line_spread_fp ,
167 linespread .initial:n = { \c_nan_fp } ,
168 linespread .value_required:n = true ,
169 autoindent .choice: ,
170 autoindent .default:n = { true } ,
171 autoindent / true .code:n =
172 {
173 \tl_set:Nn \l__ctex_autoindent_tl { 2 \ccwd }
174 \cs_set_eq:NN \ctex_if_autoindent_touched:F \use_none:n
175 } ,
176 autoindent / false .code:n =
177 {
178 \tl_clear:N \l__ctex_autoindent_tl
179 \cs_set_eq:NN \ctex_if_autoindent_touched:F \use_none:n
180 } ,
181 autoindent / unknown .code:n =
182 {
183 \ctex_set_default_ccwd:Nn \l__ctex_autoindent_tl {#1}
184 \cs_set_eq:NN \ctex_if_autoindent_touched:F \use_none:n
185 } ,
186 indent .code:n =
187 {
188 \ctex_deprecated_option:n
189 {
190 The~functionality~has~been~removed.\\
191 It's~better~to~set~the~heading~styles~via~`afterindent'~option.
192 }
193 } ,
194 indent .value_forbidden:n = true ,
195 noindent .code:n =
196 {
197 \ctex_deprecated_option:n
198 {
199 The~functionality~has~been~removed.\\
200 It's~better~to~set~the~heading~styles~via~`afterindent'~option.
201 }
202 } ,
203 noindent .value_forbidden:n = true ,
204 GBK .code:n =
205 {
206 \sys_if_engine_pdftex:TF
207 { \tl_gset:Nn \g__ctex_encoding_tl { GBK } }
208 {
209 \msg_warning:nn { ctex } { invalid-option }
210 \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
211 }
212 } ,
213 UTF8 .code:n = { \tl_gset:Nn \g__ctex_encoding_tl { UTF8 } } ,
214 GBK .value_forbidden:n = true ,
215 UTF8 .value_forbidden:n = true ,
216 fontset .tl_gset:N = \g__ctex_fontset_tl ,
217 nofonts .code:n = { \ctex_set_deprecated_option:n { fontset = none } } ,
218 adobefonts .code:n = { \ctex_set_deprecated_option:n { fontset = adobe } } ,
219 winfonts .code:n = { \ctex_set_deprecated_option:n { fontset = windows } } ,
220 nofonts .value_forbidden:n = true ,
221 winfonts .value_forbidden:n = true ,
222 adobefonts .value_forbidden:n = true ,
223 zhmap .choice: ,
224 zhmap .default:n = { true } ,
225 zhmap / zhmCJK .code:n =
226 {
227 \bool_gset_true:N \g__ctex_zhmCJK_bool
228 \cs_gset_eq:NN \ctex_zhmap_case:nnn \use_i:nnn
229 } ,
230 zhmap / true .code:n =
231 {
232 \bool_gset_false:N \g__ctex_zhmCJK_bool
233 \cs_gset_eq:NN \ctex_zhmap_case:nnn \use_ii:nnn
234 } ,
235 zhmap / false .code:n =
236 {
237 \bool_gset_false:N \g__ctex_zhmCJK_bool
238 \cs_gset_eq:NN \ctex_zhmap_case:nnn \use_iii:nnn
239 } ,
240 nozhmap .code:n =
241 { \ctex_set_deprecated_option:n { zhmap = false } } ,
242 nozhmap .value_forbidden:n = true ,
243 punct .tl_set:N = \l__ctex_punct_tl ,
244 punct .default:n = { quanjiao } ,
245 punct .initial:n = { quanjiao } ,
246 nopunct .code:n = \ctex_set_deprecated_option:n { punct = plain } ,
247 nopunct .value_forbidden:n = true ,
248 space .choices:nn =
249 { true , auto , false }
250 {
251 \exp_args:Ne \ctex_at_end:n
252 { \ctex_set:n { space = \l_keys_choice_tl } }
253 } ,
254 space .default:n = { true } ,
255 nospace .code:n = { \ctex_deprecated_option:nn { space = false } } ,
256 nospace .value_forbidden:n = true ,
257 heading .bool_set:N = \l__ctex_heading_bool ,
258 sub3section .code:n =
259 { \int_gset:Nn \g__ctex_section_depth_int { 3 } } ,
260 sub4section .code:n =
261 { \int_gset:Nn \g__ctex_section_depth_int { 4 } } ,
262 sub3section .value_forbidden:n = true ,
263 sub4section .value_forbidden:n = true ,
264 scheme .tl_set:N = \l__ctex_scheme_tl ,
265 scheme .default:n = { chinese } ,
266 scheme .initial:n = { chinese } ,
267 cap .code:n = { \ctex_set_deprecated_option:n { scheme = chinese } } ,
268 nocap .code:n = { \ctex_set_deprecated_option:n { scheme = plain } } ,
269 cap .value_forbidden:n = true ,
270 nocap .value_forbidden:n = true ,
271 fntef .code:n =
272 {
273 \sys_if_engine_xetex:TF
274 {
275 \ctex_deprecated_option:n { `xeCJKfntef'~package~is~loaded. }
276 \ctex_at_end:n { \RequirePackage { xeCJKfntef } }
277 }
278 {
279 \sys_if_engine_pdftex:TF
280 {
281 \ctex_deprecated_option:n { `CJKfntef'~package~is~loaded. }
282 \ctex_at_end:n { \RequirePackage { CJKfntef } }
283 }
284 {
285 \ctex_deprecated_option:n
286 { Furthermore,~option~`fntef'~is~invalid~in~current~mode. }
287 }
288 }
289 } ,
290 fancyhdr .code:n =
291 {
292 \ctex_deprecated_option:n { `fancyhdr'~package~is~loaded. }
293 \ctex_at_end:n { \RequirePackage { fancyhdr } }
294 } ,
295 hyperref .code:n =
296 {
297 \ctex_deprecated_option:n { `hyperref'~package~will~be~loaded. }
298 \ctex_at_end:n
299 {
300 \cs_if_exist:NF \hypersetup
301 { \cs_new_eq:NN \hypersetup \ctex_hypersetup:n }
302 }
303 \ctex_at_end_preamble:n { \RequirePackage { hyperref } }
304 } ,
305 }
306 \tl_clear_new:N \l__ctex_tmp_tl
307 \clist_map_inline:nn
308 {
309 10pt , 11pt , 12pt ,
310 8pt , 9pt , 14pt , 17pt , 20pt , 25pt , 30pt , 36pt , 48pt , 60pt
311 }
312 {
313 \tl_put_right:Nn \l__ctex_tmp_tl
314 {
315 #1 .code:n =
316 {
317 \int_gset:Nn \g__ctex_font_size_int { 2 }
318 \clist_gput_right:Nn \g__ctex_std_options_clist {#1}
319 } ,
320 #1 .value_forbidden:n = true ,
321 }
322 }
323 \exp_args:No \ctex_define_option:n { \l__ctex_tmp_tl }
324 \tl_clear:N \l__ctex_tmp_tl
325 \ctex_define_option:n
326 {
327 unknown .code:n =
328 { \clist_gput_right:No \g__ctex_std_options_clist { \CurrentOption } }
329 }
330 \ctex_file_input:n { ctexopts.cfg }
331 \cs_if_exist:NTF \ProcessKeyOptions
332 { \ProcessKeyOptions [ ctex / option ] }
333 {
334 \RequirePackage { l3keys2e }
335 \ProcessKeysOptions { ctex / option }
336 }
337 \msg_new:nnn { ctex } { pdftex-utf8 }
338 { UTF8~will~be~used~as~the~default~encoding. }
339 \tl_if_empty:NT \g__ctex_encoding_tl
340 {
341 \sys_if_engine_pdftex:T
342 { \msg_warning:nn { ctex } { pdftex-utf8 } }
343 \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
344 }
345 \int_case:nn { \g__ctex_font_size_int }
346 {
347 { 0 } { \clist_gput_right:Nn \g__ctex_std_options_clist { 10pt } }
348 { 1 } { \clist_gput_right:Nn \g__ctex_std_options_clist { 12pt } }
349 }
350 \ctex_load_std_class:n { report }
351 \@ifpackageloaded { hyperref }
352 {
353 \cs_new_protected:Npn \ctex_hypersetup:n #1
354 { \hypersetup {#1} }
355 }
356 {
357 \cs_new_protected:Npn \ctex_hypersetup:n #1
358 { \PassOptionsToPackage {#1} { hyperref } }
359 }
360 \ctex_file_input:n { \c__ctex_engine_file_str }
361 \NewDocumentCommand \ctexset { } { \ctex_set:n }
362 \NewDocumentCommand \CTEXsetup { +O { } > { \TrimSpaces } m }
363 {
364 \tl_if_blank:nTF {#1}
365 { \ctex_deprecated_command:Nn \CTEXsetup { } }
366 {
367 \ctex_deprecated_command:Nn \CTEXsetup
368 { \ctexset {~#2~=~{~#1~}~}~is~set. }
369 \ctex_set:nn {#2} {#1}
370 }
371 }
372 \NewDocumentCommand \CTEXoptions { +O { } }
373 {
374 \tl_if_blank:nTF {#1}
375 { \ctex_deprecated_command:Nn \CTEXoptions { } }
376 {
377 \ctex_deprecated_command:Nn \CTEXoptions
378 { \ctexset {~#1~}~is~set. }
379 \ctex_set:n {#1}
380 }
381 }
382 \ctex_define:n
383 {
384 autoindent .choice: ,
385 autoindent .default:n = { true } ,
386 autoindent / true .code:n =
387 {
388 \tl_set:Nn \l__ctex_autoindent_tl { 2 \ccwd }
389 \ctex_select_size:
390 } ,
391 autoindent / false .code:n =
392 { \tl_clear:N \l__ctex_autoindent_tl } ,
393 autoindent / unknown .code:n =
394 {
395 \ctex_set_default_ccwd:Nn \l__ctex_autoindent_tl {#1}
396 \ctex_select_size:
397 }
398 }
399 \NewDocumentCommand \CTEXsetfont { } { \ctex_select_size: }
400 \cs_new_protected:Npn \ctex_select_size:
401 { \cs_if_free:NTF \size@update { \ctex_update_size: } { \selectfont } }
402 \cs_new_protected:Npn \ctex_update_size:
403 {
404 \tl_if_eq:NNTF \l__ctex_ziju_tl \c__ctex_zero_tl
405 {
406 \ctex_update_stretch:
407 \ctex_update_parindent:
408 }
409 { \ctex_update_ziju: }
410 }
411 \tl_const:Nx \c__ctex_zero_tl { \fp_use:N \c_zero_fp }
412 \tl_new:N \l__ctex_ziju_tl
413 \tl_set_eq:NN \l__ctex_ziju_tl \c__ctex_zero_tl
414 \ctex_add_to_selectfont:n
415 { \cs_if_free:NF \size@update { \ctex_update_size: } }
416 \ctex_define:n
417 {
418 linestretch .code:n =
419 {
420 \ctex_set_default_ccwd:Nn \l__ctex_line_stretch_tl {#1}
421 \ctex_select_size:
422 } ,
423 linestretch .value_required:n = true
424 }
425 \tl_new:N \l__ctex_line_stretch_tl
426 \tl_set:Nn \l__ctex_line_stretch_tl { \ccwd }
427 \cs_new_protected:Npn \ctex_update_stretch:
428 {
429 \ctex_update_em_unit:
430 \dim_set:Nn \l__ctex_tmp_dim { \l__ctex_line_stretch_tl }
431 \dim_compare:nNnTF \l__ctex_tmp_dim = \c_max_dim
432 { \__ctex_update_stretch_auxi: }
433 { \__ctex_update_stretch_auxii: }
434 }
435 \cs_new_protected:Npn \__ctex_update_stretch_auxi:
436 {
437 \ctex_if_ccglue_touched:TF
438 { \ctex_update_ccwd: }
439 {
440 \dim_set:Nn \l__ctex_tmp_dim
441 { \baselinestretch \tex_glueexpr:D \f@baselineskip \scan_stop: }
442 \skip_set:Nn \l__ctex_ccglue_skip
443 { \c_zero_dim plus .08 \l__ctex_tmp_dim }
444 \ctex_update_ccglue:
445 }
446 }
447 \cs_new_protected:Npn \__ctex_update_stretch_auxii:
448 {
449 \int_set:Nn \l__ctex_tmp_int
450 { \tex_dimexpr:D \linewidth - \ccwd - \l__ctex_tmp_dim \scan_stop: }
451 \tex_divide:D \l__ctex_tmp_int \ccwd
452 \int_compare:nNnTF \l__ctex_tmp_int > \c_zero_int
453 {
454 \skip_set:Nn \l__ctex_ccglue_skip
455 {
456 \c_zero_dim plus \dim_eval:n
457 {
458 ( \linewidth - \ccwd - \l__ctex_tmp_int \ccwd ) /
459 \l__ctex_tmp_int
460 }
461 }
462 }
463 { \skip_zero:N \l__ctex_ccglue_skip }
464 \ctex_update_ccglue:
465 }
466 \cs_new_protected:Npn \ctex_update_parindent:
467 {
468 \tl_if_empty:NF \l__ctex_autoindent_tl
469 {
470 \dim_compare:nNnF \parindent = \c_zero_dim
471 { \dim_set:Nn \parindent { \l__ctex_autoindent_tl } }
472 }
473 }
474 \NewDocumentCommand \ziju { m }
475 { \exp_args:Nx \ctex_ziju:n {#1} \tex_ignorespaces:D }
476 \cs_new_protected:Npn \ctex_ziju:n #1
477 {
478 \tl_set:Nx \l__ctex_ziju_tl { \fp_eval:n {#1} }
479 \ctex_select_size:
480 }
481 \cs_new_protected:Npn \ctex_update_ziju:
482 {
483 \ctex_update_em_unit:
484 \dim_set:Nn \l__ctex_ziju_dim { \l__ctex_ziju_tl \ccwd }
485 \dim_add:Nn \ccwd { \l__ctex_ziju_dim }
486 \dim_compare:nNnTF \ccwd > \c_zero_dim
487 {
488 \dim_set:Nn \l__ctex_tmp_dim
489 { \linewidth - \ccwd + \l__ctex_ziju_dim }
490 \int_set:Nn \l__ctex_tmp_int { \l__ctex_tmp_dim }
491 \tex_divide:D \l__ctex_tmp_int \ccwd
492 \dim_sub:Nn \l__ctex_tmp_dim { \l__ctex_tmp_int \ccwd }
493 \dim_compare:nNnF \parindent = \c_zero_dim
494 {
495 \int_compare:nNnF \l__ctex_tmp_int < 3
496 { \int_sub:Nn \l__ctex_tmp_int { 2 } }
497 }
498 \skip_set:Nn \l__ctex_ccglue_skip
499 {
500 \l__ctex_ziju_dim
501 plus \dim_eval:n { \l__ctex_tmp_dim / \l__ctex_tmp_int }
502 minus \dim_min:nn { \dim_abs:n { \l__ctex_ziju_dim } }
503 { ( \ccwd - \l__ctex_tmp_dim ) / ( \l__ctex_tmp_int + 1 ) }
504 }
505 }
506 { \skip_set:Nn \l__ctex_ccglue_skip { \l__ctex_ziju_dim } }
507 \ctex_update_ccglue:
508 \ctex_update_parindent:
509 }
510 \dim_new:N \l__ctex_ziju_dim
511 \NewDocumentCommand \CTEXindent { }
512 {
513 \ctex_deprecated_command:Nn \CTEXindent
514 { \parindent is~set~to~2\ccwd. }
515 \ctex_update_ccwd:
516 \dim_set:Nn \parindent { 2 \ccwd }
517 }
518 \NewDocumentCommand \CTEXnoindent { }
519 {
520 \ctex_deprecated_command:Nn \CTEXnoindent
521 { \parindent is~set~to~0pt. }
522 \dim_zero:N \parindent
523 }
524 \exp_args:Ne \PassOptionsToPackage
525 { encoding = \g__ctex_encoding_tl }
526 { zhnumber }
527 \RequirePackage { zhnumber }
528 \cs_new:Npn \chinese { \zhnum_counter:n }
529 \cs_new_eq:NN \@chinese \@zhnum
530 \cs_new_eq:NN \Chinese \chinese
531 \cs_new_eq:NN \CTEXcounter \use_none:n
532 \ctex_at_end_package:nn { enumitem }
533 {
534 \cs_if_free:NF \AddEnumerateCounter
535 {
536 \AddEnumerateCounter * { \zhnum } { \@zhnum } { 1 }
537 \AddEnumerateCounter * { \zhdig } { \@zhdig } { 1 }
538 \AddEnumerateCounter * { \chinese } { \@chinese } { 1 }
539 }
540 }
541 \NewDocumentCommand \CTEXnumber { m m }
542 { \protected@edef #1 { \zhnumber {#2} } }
543 \NewDocumentCommand \CTEXdigits { m m }
544 { \protected@edef #1 { \zhdigits {#2} } }
545 \cs_set_eq:NN \CTEX@todayold \today
546 \ctex_define:n
547 {
548 today .choice: ,
549 today / old .code:n =
550 { \cs_set_eq:NN \today \CTEX@todayold } ,
551 today / small .code:n =
552 {
553 \cs_set_eq:NN \today \zhtoday
554 \zhnumsetup { time = Arabic }
555 } ,
556 today / big .code:n =
557 {
558 \cs_set_eq:NN \today \zhtoday
559 \zhnumsetup { time = Chinese }
560 } ,
561 today / unknown .code:n =
562 { \msg_error:nnx { ctex } { today-undef } {#1} }
563 }
564 \msg_new:nnnn { ctex } { today-undef }
565 { Today~format~`#1'~is~undefined. }
566 { Available~today~formats~are~`old',~`small',~and~`big'. }
567 \tl_if_exist:NF \proofname
568 {
569 \tl_new:N \proofname
570 \tl_set:Nn \proofname { Proof }
571 }
572 \ctex_define:n
573 {
574 contentsname .tl_set:N = \contentsname ,
575 listfigurename .tl_set:N = \listfigurename ,
576 listtablename .tl_set:N = \listtablename ,
577 figurename .tl_set:N = \figurename ,
578 tablename .tl_set:N = \tablename ,
579 abstractname .tl_set:N = \abstractname ,
580 indexname .tl_set:N = \indexname ,
581 appendixname .tl_set:N = \appendixname ,
582 proofname .tl_set:N = \proofname ,
583 bibname .tl_set:N = \bibname
584 }
585 \seq_const_from_clist:Nn \c__ctex_section_headings_seq
586 { section , subsection , subsubsection , paragraph , subparagraph }
587 \seq_new:N \c__ctex_headings_seq
588 \seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq
589 \seq_gput_left:Nn \c__ctex_headings_seq { chapter }
590 \seq_gput_left:Nn \c__ctex_headings_seq { part }
591 \cs_new_protected:Npn \__ctex_initial_heading:n #1
592 {
593 \tl_new:c { CTEX@pre#1 }
594 \tl_new:c { CTEX@post#1 }
595 \tl_const:cx { CTEXthe#1 }
596 {
597 \exp_not:c { CTEX@pre#1 }
598 \exp_not:c { CTEX@the#1 }
599 \exp_not:c { CTEX@post#1 }
600 }
601 \tl_const:cx { CTEX@#1name }
602 {
603 \group_begin:
604 \exp_not:c { CTEX@#1@nameformat }
605 {
606 \exp_not:c { CTEX@pre#1 }
607 \exp_not:N \tl_if_empty:NTF
608 \exp_not:c { CTEX@#1@numberformat }
609 { \exp_not:c { CTEX@the#1 } }
610 {
611 \group_begin:
612 \exp_not:c { CTEX@#1@numberformat }
613 \exp_not:c { CTEX@the#1 }
614 \group_end:
615 }
616 \exp_not:c { CTEX@post#1 }
617 }
618 \group_end:
619 }
620 }
621 \cs_new_protected:Npn \__ctex_def_heading_keys:n #1
622 {
623 \exp_args:NNe \tl_put_right:Nn \l__ctex_tmp_tl
624 {
625 #1 .meta:nn = { ctex / #1 } { ##1 } ,
626 #1 / name .code:n =
627 { \ctex_assign_heading_name:nn {#1} { ##1 } } ,
628 #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } ,
629 #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } ,
630 #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} ,
631 #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } ,
632 #1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } ,
633 #1 / numbering .initial:n = true ,
634 #1 / beforeskip .initial:n = \c_zero_skip ,
635 #1 / afterskip .initial:n = \c_zero_skip ,
636 #1 / indent .initial:n = \c_zero_dim ,
637 #1 / beforeskip .value_required:n = true ,
638 #1 / afterskip .value_required:n = true ,
639 #1 / indent .value_required:n = true ,
640 #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } ,
641 #1 / fixskip .bool_set:N = \exp_not:c { CTEX@#1@fixskip } ,
642 #1 / hang .bool_set:N = \exp_not:c { CTEX@#1@hang } ,
643 #1 / hang .initial:n = true ,
644 #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } ,
645 #1 / tocline .cs_set:Np = \exp_not:c { CTEX@#1@tocline } ##1##2 ,
646 \__ctex_plus_key_aux:nn {#1} { break } ,
647 \__ctex_plus_key_aux:nn {#1} { format } ,
648 \__ctex_plus_key_aux:nn {#1} { nameformat } ,
649 \__ctex_plus_key_aux:nn {#1} { numberformat } ,
650 \__ctex_plus_key_aux:nn {#1} { titleformat } ,
651 \__ctex_plus_key_aux:nn {#1} { aftername } ,
652 \__ctex_plus_key_aux:nn {#1} { aftertitle } ,
653 }
654 }
655 \cs_new:Npn \__ctex_plus_key_aux:nn #1#2
656 {
657 #1 / #2 .tl_set:N = \exp_not:c { CTEX@#1@#2 } ,
658 #1 / #2 + .code:n =
659 { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ##1 } } ,
660 #1 / #2 ~ + .code:n =
661 { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ##1 } }
662 }
663 \NewDocumentCommand \ctex_assign_heading_name:nn
664 { m > { \SplitArgument { 1 } { , } } +m }
665 { \__ctex_assign_heading_name:nnn {#1} #2 }
666 \cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3
667 {
668 \tl_set:cn { CTEX@pre#1 } {#2}
669 \tl_if_novalue:nTF {#3}
670 { \tl_clear:c { CTEX@post#1 } }
671 { \tl_set:cn { CTEX@post#1 } {#3} }
672 }
673 \group_begin:
674 \tl_set:Nn \l__ctex_tmp_tl
675 {
676 part / pagestyle .tl_set:N = \CTEX@part@pagestyle ,
677 chapter / pagestyle .tl_set:N = \CTEX@chapter@pagestyle ,
678 chapter / lofskip .tl_set:N = \CTEX@chapter@lofskip ,
679 chapter / lotskip .tl_set:N = \CTEX@chapter@lotskip ,
680 chapter / lofskip .initial:n = \c_zero_skip ,
681 chapter / lotskip .initial:n = \c_zero_skip ,
682 chapter / lofskip .value_required:n = true ,
683 chapter / lotskip .value_required:n = true ,
684 }
685 \seq_map_inline:Nn \c__ctex_headings_seq
686 {
687 \__ctex_initial_heading:n {#1}
688 \__ctex_def_heading_keys:n {#1}
689 }
690 \exp_args:NNo \group_end: \ctex_define:n { \l__ctex_tmp_tl }
691 \cs_new_protected:Npn \CTEX@heading@format@initial
692 {
693 \normalfont
694 \tl_clear:N \l__ctex_autoindent_tl
695 \int_set:Nn \tex_interlinepenalty:D { 10 000 }
696 \tex_noindent:D
697 }
698 \cs_new_protected:Npn \ctex_indent_box:n #1
699 {
700 \dim_set:Nn \tex_parindent:D {#1}
701 \__ctex_insert_indent:
702 }
703 \cs_new_protected:Npn \__ctex_insert_indent:
704 {
705 \dim_compare:nNnF \tex_parindent:D = \c_zero_dim
706 { \tex_indent:D }
707 }
708 \cs_new_eq:NN \CTEX@indentbox \ctex_indent_box:n
709 \cs_new_protected:Npn \CTEX@fixtopskip
710 {
711 \CTEX@fixheadingskip
712 \dim_compare:nNnF \tex_pagegoal:D < \c_max_dim
713 { \skip_sub:Nn \l__ctex_heading_skip { \tex_topskip:D } }
714 }
715 \cs_new_protected:Npn \CTEX@fixheadingskip
716 {
717 \par
718 \dim_set:Nn \tex_prevdepth:D { -1000pt }
719 \skip_sub:Nn \l__ctex_heading_skip { \tex_parskip:D }
720 }
721 \skip_new:N \l__ctex_heading_skip
722 \cs_new_protected:Npn \CTEX@setheadingskip
723 { \skip_set:Nn \l__ctex_heading_skip }
724 \cs_new_eq:NN \CTEX@headingskip \l__ctex_heading_skip
725 \cs_new_protected:Npn \CTEX@setthispagestyle #1
726 { \exp_args:Ne \thispagestyle { \use:c { CTEX@#1@pagestyle } } }
727 \ProvideDocumentCommand \partmark { m }
728 { \markboth { } { } }
729 \cs_new_eq:NN \CTEXifname \use_ii:nn
730 \cs_new_protected:Npn \CTEX@ifnametrue
731 { \cs_set_eq:NN \CTEXifname \use_i:nn }
732 \cs_new_protected:Npn \CTEX@ifnamefalse
733 { \cs_set_eq:NN \CTEXifname \use_ii:nn }
734 \cs_new_protected:Npn \CTEX@addloflotskip #1
735 {
736 \skip_set:Nn \l__ctex_heading_skip { \use:c { CTEX@#1@lofskip } }
737 \skip_if_eq:nnF { \l__ctex_heading_skip } { \c_zero_skip }
738 {
739 \addtocontents { lof }
740 { \protect \addvspace { \skip_use:N \l__ctex_heading_skip } }
741 }
742 \skip_set:Nn \l__ctex_heading_skip { \use:c { CTEX@#1@lotskip } }
743 \skip_if_eq:nnF { \l__ctex_heading_skip } { \c_zero_skip }
744 {
745 \addtocontents { lot }
746 { \protect \addvspace { \skip_use:N \l__ctex_heading_skip } }
747 }
748 }
749 \cs_new_protected:Npn \CTEX@addtocline #1#2
750 { \addcontentsline { toc } {#1} { \use:c { CTEX@#1@tocline } {#1} {#2} } }
751 \renewcommand\part{%
752 \CTEX@part@break
753 \CTEX@setthispagestyle{part}%
754 \if@twocolumn
755 \onecolumn
756 \@tempswatrue
757 \else
758 \@tempswafalse
759 \fi
760 \CTEX@setheadingskip \CTEX@part@beforeskip
761 \ifodd \CTEX@part@fixskip \CTEX@fixtopskip \fi
762 \vspace*{\CTEX@headingskip}%
763 \secdef\@part\@spart}
764 \def\@part[#1]#2{%
765 \ifnum \c@secnumdepth >-2\relax
766 \ifodd \CTEX@part@numbering
767 \CTEX@ifnametrue
768 \refstepcounter{part}%
769 \else
770 \CTEX@ifnamefalse
771 \CTEX@makeanchor{part*}%
772 \fi
773 \else
774 \CTEX@ifnamefalse
775 \CTEX@makeanchor{part*}%
776 \fi
777 \CTEX@gettitle{#1}%
778 \CTEX@addtocline{part}{#1}%
779 \partmark{#1}%
780 \begingroup
781 \CTEX@heading@format@initial
782 \CTEX@part@format{%
783 \CTEX@headinghang{part}%
784 {\CTEXifname{\CTEX@partname\CTEX@part@aftername}{}}%
785 \CTEX@part@titleformat{#2}%
786 \CTEX@part@aftertitle}\par
787 \endgroup
788 \@endpart}
789 \def\@spart#1{%
790 \CTEX@ifnamefalse
791 \CTEX@makeanchor@spart{part*}%
792 \CTEX@gettitle{#1}%
793 \begingroup
794 \CTEX@heading@format@initial
795 \CTEX@part@format{%
796 \CTEX@headinghang{part}{}%
797 \CTEX@part@titleformat{#1}%
798 \CTEX@part@aftertitle}\par
799 \endgroup
800 \@endpart}
801 \def\@endpart{%
802 \CTEX@setheadingskip \CTEX@part@afterskip
803 \ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi
804 \vskip \CTEX@headingskip
805 \newpage
806 \if@twoside
807 \if@openright
808 \null
809 \thispagestyle{empty}%
810 \newpage
811 \fi
812 \fi
813 \if@tempswa
814 \twocolumn
815 \fi}
816 \renewcommand\chapter{%
817 \CTEX@chapter@break
818 \CTEX@setthispagestyle{chapter}%
819 \global\@topnum\z@
820 \ifodd \CTEX@chapter@afterindent
821 \@afterindenttrue
822 \else
823 \@afterindentfalse
824 \fi
825 \secdef\@chapter\@schapter}
826 \def\@chapter[#1]#2{%
827 \ifnum \c@secnumdepth >\m@ne
828 \ifodd \CTEX@chapter@numbering
829 \CTEX@ifnametrue
830 \refstepcounter{chapter}%
831 \typeout{\CTEXthechapter}%
832 \else
833 \CTEX@ifnamefalse
834 \CTEX@makeanchor{\Hy@chapapp*}%
835 \fi
836 \else
837 \CTEX@ifnamefalse
838 \CTEX@makeanchor@chapter{\Hy@chapapp*}%
839 \fi
840 \CTEX@gettitle{#1}%
841 \CTEX@addtocline{chapter}{#1}%
842 \chaptermark{#1}%
843 \CTEX@addloflotskip{chapter}%
844 \if@twocolumn
845 \@topnewpage[\@makechapterhead{#2}]%
846 \else
847 \@makechapterhead{#2}%
848 \@afterheading
849 \fi}
850 \def\@schapter#1{%
851 \CTEX@ifnamefalse
852 \CTEX@makeanchor@schapter{\Hy@chapapp*}%
853 \CTEX@gettitle{#1}%
854 \if@twocolumn
855 \@topnewpage[\@makeschapterhead{#1}]%
856 \else
857 \@makeschapterhead{#1}%
858 \@afterheading
859 \fi}
860 \def\@makechapterhead#1{%
861 \CTEX@setheadingskip \CTEX@chapter@beforeskip
862 \ifodd \CTEX@chapter@fixskip \CTEX@fixtopskip \fi
863 \vspace*{\CTEX@headingskip}%
864 \begingroup
865 \CTEX@heading@format@initial
866 \CTEX@chapter@format{%
867 \CTEX@headinghang{chapter}%
868 {\CTEXifname{\CTEX@chaptername\CTEX@chapter@aftername}{}}%
869 \CTEX@chapter@titleformat{#1}%
870 \CTEX@chapter@aftertitle}\par
871 \endgroup
872 \nobreak
873 \CTEX@setheadingskip \CTEX@chapter@afterskip
874 \ifodd \CTEX@chapter@fixskip \CTEX@fixheadingskip \fi
875 \vskip \CTEX@headingskip}
876 \def\@makeschapterhead#1{%
877 \CTEX@setheadingskip \CTEX@chapter@beforeskip
878 \ifodd \CTEX@chapter@fixskip \CTEX@fixtopskip \fi
879 \vspace*{\CTEX@headingskip}%
880 \begingroup
881 \CTEX@heading@format@initial
882 \CTEX@chapter@format{%
883 \CTEX@headinghang{chapter}{}%
884 \CTEX@chapter@titleformat{#1}%
885 \CTEX@chapter@aftertitle}\par
886 \endgroup
887 \nobreak
888 \CTEX@setheadingskip \CTEX@chapter@afterskip
889 \ifodd \CTEX@chapter@fixskip \CTEX@fixheadingskip \fi
890 \vskip \CTEX@headingskip}
891 \def\@startsection#1#2#3#4#5#6{%
892 \if@noskipsec \leavevmode \fi
893 \par
894 \CTEX@update@sectionformat@n{#1}%
895 \ifodd \CTEX@afterindent
896 \@afterindenttrue
897 \else
898 \@afterindentfalse
899 \fi
900 \if@nobreak
901 \everypar{}%
902 \else
903 \csname CTEX@#1@break\endcsname
904 \CTEX@setheadingskip{#4}%
905 \ifodd \CTEX@fixskip \CTEX@fixheadingskip \fi
906 \addvspace \CTEX@headingskip
907 \fi
908 \@ifstar
909 {\CTEX@makeanchor@ssect{#1*}\@ssect{#3}{#4}{#5}{#6}}%
910 {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}
911 \def\@seccntformat#1{%
912 \csname CTEX@#1name\endcsname
913 \csname CTEX@#1@aftername\endcsname}
914 \def\@sect#1#2#3#4#5#6[#7]#8{%
915 \ifnum #2>\c@secnumdepth
916 \CTEX@ifnamefalse
917 \CTEX@makeanchor@sect{#1*}%
918 \let\@svsec\@empty
919 \else
920 \ifodd \csname CTEX@#1@numbering\endcsname
921 \CTEX@ifnametrue
922 \refstepcounter{#1}%
923 \protected@edef\@svsec{\@seccntformat{#1}\relax}%
924 \else
925 \CTEX@ifnamefalse
926 \CTEX@makeanchor{#1*}%
927 \let\@svsec\@empty
928 \fi
929 \fi
930 \CTEX@gettitle{#7}%
931 \unless \ifodd \CTEX@runin
932 \begingroup
933 \CTEX@heading@format@initial
934 #6{%
935 \CTEX@sectionhang{#3}{\@svsec}%
936 \csname CTEX@#1@titleformat\endcsname{#8}%
937 \csname CTEX@#1@aftertitle\endcsname}\par
938 \endgroup
939 \csname #1mark\endcsname{#7}%
940 \CTEX@addtocline{#1}{#7}%
941 \else
942 \def\@svsechd{%
943 #6{%
944 {\CTEX@indentbox{#3}}\@svsec
945 \csname CTEX@#1@titleformat\endcsname{#8}%
946 \csname CTEX@#1@aftertitle\endcsname}%
947 \csname #1mark\endcsname{#7}%
948 \CTEX@addtocline{#1}{#7}}%
949 \fi
950 \@xsect{#5}}
951 \def\@ssect#1#2#3#4#5{%
952 \CTEX@ifnamefalse
953 \CTEX@gettitle{#5}%
954 \unless \ifodd \CTEX@runin
955 \begingroup
956 \CTEX@heading@format@initial
957 #4{%
958 \CTEX@sectionhang{#1}{}%
959 \CTEX@titleformat@n{#5}%
960 \CTEX@aftertitle}\par
961 \endgroup
962 \else
963 \def\@svsechd{#4{{\CTEX@indentbox{#1}}%
964 \CTEX@titleformat@n{#5}\CTEX@aftertitle}}%
965 \fi
966 \@xsect{#3}}
967 \def\@xsect#1{%
968 \unless \ifodd \CTEX@runin
969 \par \nobreak
970 \CTEX@setheadingskip{#1}%
971 \ifodd \CTEX@fixskip \CTEX@fixheadingskip \fi
972 \vskip \CTEX@headingskip
973 \@afterheading
974 \else
975 \@nobreakfalse
976 \global\@noskipsectrue
977 \everypar{%
978 \if@noskipsec
979 \global\@noskipsecfalse
980 {\setbox\z@\lastbox}%
981 \clubpenalty\@M
982 \begingroup \@svsechd \endgroup
983 \unskip
984 \CTEX@heading@glue{#1}%
985 \else
986 \clubpenalty \@clubpenalty
987 \everypar{}%
988 \fi}%
989 \fi
990 \ignorespaces}
991 \cs_new_protected:Npn \CTEX@headinghang #1
992 {
993 \ctex_heading_hang:cnn
994 { CTEX@#1@hang }
995 { \use:c { CTEX@#1@indent } }
996 }
997 \cs_new_protected:Npn \CTEX@sectionhang
998 { \ctex_heading_hang:Nnn \CTEX@hang }
999 \cs_new_protected:Npn \ctex_heading_hang:Nnn #1#2#3
1000 {
1001 \dim_set:Nn \tex_parindent:D {#2}
1002 \bool_if:NTF #1
1003 { \ctex_hang_from:n }
1004 { \use:n }
1005 { \__ctex_insert_indent: #3 }
1006 }
1007 \cs_new_protected:Npn \ctex_hang_from:n #1
1008 {
1009 \tex_noindent:D
1010 \hbox_set:Nn \l__ctex_tmp_box {#1}
1011 \tex_hangindent:D = \box_wd:N \l__ctex_tmp_box
1012 \box_use_drop:N \l__ctex_tmp_box
1013 }
1014 \cs_generate_variant:Nn \ctex_heading_hang:Nnn { c }
1015 \cs_new_protected:Npn \ctex_heading_glue:n #1
1016 {
1017 \group_begin:
1018 \skip_set:Nn \l__ctex_heading_skip {#1}
1019 \dim_compare:nNnF \l__ctex_heading_skip = \c_zero_dim
1020 { \skip_horizontal:N \l__ctex_heading_skip }
1021 \group_end:
1022 }
1023 \cs_new_eq:NN \CTEX@heading@glue \ctex_heading_glue:n
1024 \cs_new_protected:Npn \CTEX@update@sectionformat@n #1
1025 {
1026 \cs_set_eq:Nc \CTEX@titleformat@n { CTEX@#1@titleformat }
1027 \cs_set_eq:Nc \CTEX@aftertitle { CTEX@#1@aftertitle }
1028 \cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent }
1029 \cs_set_eq:Nc \CTEX@fixskip { CTEX@#1@fixskip }
1030 \cs_set_eq:Nc \CTEX@hang { CTEX@#1@hang }
1031 \cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin }
1032 }
1033 \cs_new_eq:NN \CTEX@titleformat@n \use:n
1034 \cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing:
1035 \cs_new_eq:NN \CTEX@afterindent \c_true_bool
1036 \cs_new_eq:NN \CTEX@fixskip \c_false_bool
1037 \cs_new_eq:NN \CTEX@hang \c_true_bool
1038 \cs_new_eq:NN \CTEX@runin \c_false_bool
1039 \cs_new:Npn \CTEX@part@tocline #1#2
1040 {
1041 \CTEXifname
1042 { \CTEXthepart \hspace { 1em } }
1043 { }
1044 #2
1045 }
1046 \cs_new:Npn \CTEX@chapter@tocline #1#2
1047 {
1048 \CTEXifname
1049 { \protect \numberline { \CTEXthechapter \hspace { .3em } } }
1050 { }
1051 #2
1052 }
1053 \cs_new:Npn \CTEXnumberline #1
1054 {
1055 \CTEXifname
1056 { \protect \numberline { \use:c { CTEXthe #1 } } }
1057 { }
1058 }
1059 \int_zero:N \l__ctex_tmp_int
1060 \seq_map_inline:Nn \c__ctex_section_headings_seq
1061 {
1062 \int_incr:N \l__ctex_tmp_int
1063 \cs_gset_protected:cpx {#1}
1064 {
1065 \exp_not:N \@startsection {#1}
1066 { \int_use:N \l__ctex_tmp_int }
1067 { \exp_not:c { CTEX@#1@indent } }
1068 { \exp_not:c { CTEX@#1@beforeskip } }
1069 { \exp_not:c { CTEX@#1@afterskip } }
1070 { \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } }
1071 }
1072 \cs_new:cpn { CTEX@#1@tocline } ##1##2
1073 { \CTEXnumberline { ##1 } ##2 }
1074 }
1075 \ctex_define:n
1076 {
1077 appendix .meta:nn = { ctex / appendix } {#1} ,
1078 appendix / name .code:n =
1079 { \ctex_assign_heading_name:nn { appendix } {#1} } ,
1080 appendix / number .tl_set:N = \CTEX@appendix@number ,
1081 appendix / numbering .bool_set:N = \CTEX@appendix@numbering ,
1082 appendix / numbering .initial:n = true
1083 }
1084 \tl_new:N \CTEX@preappendix
1085 \tl_new:N \CTEX@postappendix
1086 \cs_new_eq:NN \CTEX@save@appendix \appendix
1087 \cs_gset_protected:Npn \appendix
1088 {
1089 \CTEX@save@appendix
1090 \gdef \CTEX@prechapter { \CTEX@preappendix }
1091 \gdef \CTEX@thechapter { \CTEX@appendix@number }
1092 \gdef \CTEX@postchapter { \CTEX@postappendix }
1093 \gdef \CTEX@chapter@numbering { \CTEX@appendix@numbering }
1094 }
1095 \cs_new_protected:Npn \CTEX@makeanchor #1
1096 { }
1097 \seq_const_from_clist:Nn \c__ctex_headings_cs_seq
1098 { part , spart , chapter , schapter , sect , ssect }
1099 \seq_map_inline:Nn \c__ctex_headings_cs_seq
1100 {
1101 \cs_new_eq:cc { CTEX@ #1 } { @ #1 }
1102 \cs_new_eq:cN { CTEX@makeanchor@ #1 } \CTEX@makeanchor
1103 }
1104 \cs_new_protected:Npn \CTEX@hyperheadinghook
1105 {
1106 \group_begin:
1107 \legacy_if:nTF { Hy@implicit }
1108 {
1109 \cs_set_eq:NN \H@old@chapter \Hy@org@chapter
1110 \seq_map_inline:Nn \c__ctex_headings_cs_seq
1111 {
1112 \cs_if_eq:ccT { H@old@ ##1 } { CTEX@ ##1 }
1113 {
1114 \cs_gset_eq:cc { @ ##1 } { CTEX@ ##1 }
1115 \cs_gset_eq:cN { CTEX@makeanchor@ ##1 } \CTEX@makeanchor
1116 }
1117 }
1118 }
1119 {
1120 \seq_map_inline:Nn \c__ctex_headings_cs_seq
1121 { \cs_gset_eq:cN { CTEX@makeanchor@ ##1 } \CTEX@makeanchor }
1122 }
1123 \group_end:
1124 }
1125 \ctex_at_end_package:nn { hyperref }
1126 {
1127 \cs_gset_protected:Npn \CTEX@makeanchor #1
1128 {
1129 \Hy@MakeCurrentHrefAuto {#1}
1130 \Hy@raisedlink
1131 {
1132 \hyper@anchorstart { \@currentHref }
1133 \hyper@anchorend
1134 }
1135 }
1136 \CTEX@hyperheadinghook
1137 }
1138 \cs_new_protected:Npn \CTEX@gettitle #1
1139 { }
1140 \ctex_at_end_package:nn { nameref }
1141 {
1142 \cs_gset_protected:Npn \CTEX@gettitle { \NR@gettitle }
1143 \seq_map_inline:Nn \c__ctex_headings_cs_seq
1144 {
1145 \cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 }
1146 { \cs_gset_eq:cc { @ #1 } { CTEX@ #1 } }
1147 }
1148 }
1149 \cs_new_protected:Npn \ctex_titlesec_hook:
1150 {
1151 \@ifpackagewith { titlesec } { explicit }
1152 {
1153 \cs_set_eq:NN \__ctex_titlesec_format:Nn
1154 \__ctex_titlesec_format_explicit:Nn
1155 }
1156 { }
1157 \clist_map_inline:nn
1158 { indentafter , noindentafter , indentfirst , nonindentfirst }
1159 {
1160 \@ifpackagewith { titlesec } { ##1 }
1161 {
1162 \clist_map_break:n
1163 { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n }
1164 }
1165 { }
1166 }
1167 \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n
1168 }
1169 \cs_new_protected:Npn \__ctex_titlesec_hook:n #1
1170 {
1171 \__ctex_titlesec_format:n {#1}
1172 \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1}
1173 }
1174 \cs_new_protected:Npn \__ctex_titlesec_format:n #1
1175 {
1176 \cs_if_free:cF { ttlf@#1 }
1177 { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} }
1178 }
1179 \cs_new_protected:Npn \__ctex_titlesec_format:Nn #1#2
1180 {
1181 \tl_set:Nx #1
1182 {
1183 \bool_if:cTF { CTEX@#2@runin }
1184 { \exp_not:N \ttlh@runin }
1185 { \exp_not:N \ttlh@hang }
1186 \tl_tail:N #1
1187 }
1188 }
1189 \cs_new_protected:Npn \__ctex_titlesec_format_explicit:Nn #1#2
1190 {
1191 \cs_set_nopar:Npx #1 ##1
1192 {
1193 \bool_if:cTF { CTEX@#2@runin }
1194 { \exp_not:N \ttlh@runin }
1195 { \exp_not:N \ttlh@hang }
1196 \exp_args:No \tl_tail:n { #1 { } }
1197 }
1198 }
1199 \cs_new_protected:Npn \__ctex_titlesec_spacing:Nn #1#2
1200 { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } }
1201 \cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6
1202 {
1203 \exp_not:n { {#1} {#2} {#3} {#4} }
1204 { \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } }
1205 }
1206 \@ifpackageloaded { titlesec }
1207 { }
1208 {
1209 \ctex_at_end_package:nn { titlesec }
1210 {
1211 \@ifpackagewith { titlesec } { loadonly }
1212 { }
1213 { \ctex_titlesec_hook: }
1214 }
1215 }
1216 \ctex_at_end_package:nn { titlesec }
1217 {
1218 \tl_set:Nn \ttl@chapterout { \typeout { \CTEXthechapter } }
1219 \cs_if_free:NF \ttl@tocpart
1220 {
1221 \cs_set_protected:Npn \ttl@tocpart
1222 { \tl_set:Nn \ttl@a { \CTEXthepart \hspace { 1em } } }
1223 }
1224 \seq_map_inline:Nn \c__ctex_headings_seq
1225 {
1226 \cs_if_exist:cF { ttl@toc #1 }
1227 {
1228 \cs_new_protected:cpx { ttl@toc #1 }
1229 {
1230 \tl_set:Nn \exp_not:N \ttl@a
1231 {
1232 \exp_not:N \protect
1233 \exp_not:N \numberline { \exp_not:c { CTEXthe #1 } }
1234 }
1235 }
1236 }
1237 }
1238 }
1239 \ctex_at_end_package:nn { titlesec }
1240 {
1241 \ctex_patch_cmd:Nnn \ttl@labelling
1242 { \let \ifttl@toclabel \ifttl@label }
1243 {
1244 \let \ifttl@toclabel \ifttl@label
1245 \CTEX@updatettlifname
1246 }
1247 \cs_new_protected:Npn \CTEX@updatettlifname
1248 { \legacy_if:nTF { ttl@label } { \CTEX@ifnametrue } { \CTEX@ifnamefalse } }
1249 }
1250 \group_begin:
1251 \char_set_catcode_other:N \#
1252 \cs_new_protected:Npn \ctex_titleps_hook:
1253 {
1254 \ctex_patch_cmd:Nnn \ttl@settopmark
1255 { \protect \@namedef { the#1 } { \@nameuse { the#1 } } }
1256 {
1257 \protect \@namedef { the#1 } { \@nameuse { the#1 } }
1258 \CTEX@titlepslabel@set {#1}
1259 }
1260 \ctex_patch_cmd:Nnn \ttl@setsubmark
1261 { \protect \@namedef { the#1 } { } }
1262 {
1263 \protect \@namedef { the#1 } { }
1264 \CTEX@titlepslabel@clear {#1}
1265 }
1266 \ctex_patch_cmd:Nnn \ttl@setsubmark
1267 { \protect \@namedef { the#2 } { \@nameuse { the#2 } } }
1268 {
1269 \protect \@namedef { the#2 } { \@nameuse { the#2 } }
1270 \CTEX@titlepslabel@set {#2}
1271 }
1272 }
1273 \group_end:
1274 \cs_new:Npn \CTEX@titlepslabel@set #1
1275 {
1276 \cs_if_free:cF { CTEXthe#1 }
1277 { \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } }
1278 }
1279 \cs_new:Npn \CTEX@titlepslabel@clear #1
1280 {
1281 \cs_if_free:cF { CTEXthe#1 }
1282 { \protect \@namedef { CTEXthe#1 } { } }
1283 }
1284 \ctex_at_end_package:nn { titlesec }
1285 { \cs_if_free:NF \ttl@settopmark { \ctex_titleps_hook: } }
1286 \ctex_at_end_package:nn { titleps } { \ctex_titleps_hook: }
1287 \ctex_at_end_package:nn { titleps }
1288 {
1289 \cs_set_protected:Npn \ttl@setifthe #1
1290 {
1291 \exp_args:Nco \cs_set:Npn { ifthe #1 }
1292 {
1293 \CTEXifname
1294 { \protect \@firstoftwo }
1295 { \protect \@secondoftwo }
1296 }
1297 }
1298 \seq_map_function:NN \c__ctex_headings_seq \ttl@setifthe
1299 }
1300 \cs_new_protected:Npn \CTEX@toc@width@n #1
1301 {
1302 \hbox_set:Nn \l__ctex_tmp_box {#1}
1303 \dim_set:Nn \@tempdima
1304 {
1305 \dim_max:nn { \@tempdima }
1306 { \box_wd:N \l__ctex_tmp_box + \f@size \p@ / 2 }
1307 }
1308 }
1309 \group_begin:
1310 \char_set_catcode_other:N \#
1311 \use:n
1312 {
1313 \group_end:
1314 \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff }
1315 { \CTEX@toc@width@n {#1} }
1316 { }
1317 { \ctex_patch_failure:N \numberline }
1318 \cs_new_protected:Npn \__ctex_patch_toc_width:n \c_parameter_token 1
1319 {
1320 \@ifpackageloaded { \c_parameter_token 1 }
1321 { }
1322 {
1323 \ctex_at_end_package:nn { \c_parameter_token 1 }
1324 {
1325 \ctex_preto_cmd:NnnTF \numberline
1326 { \char_set_catcode_letter:n { 64 } }
1327 { \CTEX@toc@width@n {#1} }
1328 { }
1329 { \ctex_patch_failure:N \numberline }
1330 }
1331 }
1332 }
1333 }
1334 \__ctex_patch_toc_width:n { tocloft }
1335 \__ctex_patch_toc_width:n { titletoc }
1336 \ctex_patch_cmd:Nnn \ps@headings
1337 {
1338 \ifnum \c@secnumdepth > \m@ne
1339 \@chapapp \ \thechapter . ~ \ %
1340 \fi
1341 }
1342 { \CTEXifname { \CTEXthechapter \quad } { } }
1343 \legacy_if:nT { @twoside }
1344 {
1345 \ctex_patch_cmd:Nnn \ps@headings
1346 { \ifnum \c@secnumdepth > \z@ \thesection . ~ \ \fi }
1347 { \CTEXifname { \CTEXthesection \quad } { } }
1348 }
1349 \ctex_at_end_package:nn { fancyhdr }
1350 {
1351 \ctex_patch_cmd:Nnn \f@nch@initialise
1352 { \ifnum \c@secnumdepth > \z@ \thesection \hskip 1em \relax \fi }
1353 { \CTEXifname { \CTEXthesection \quad } { } }
1354 \ctex_patch_cmd:Nnn \f@nch@initialise
1355 { \ifnum \c@secnumdepth > \@ne \thesubsection \hskip 1em \relax \fi }
1356 { \CTEXifname { \CTEXthesubsection \quad } { } }
1357 \ctex_patch_cmd:Nnn \f@nch@initialise
1358 { \ifnum \c@secnumdepth > \m@ne \@chapapp\ \thechapter . ~ \ \fi }
1359 { \CTEXifname { \CTEXthechapter \quad } { } }
1360 \ctex_patch_cmd:Nnn \f@nch@initialise
1361 { \ifnum \c@secnumdepth > \z@ \thesection . ~ \ \fi }
1362 { \CTEXifname { \CTEXthesection \quad } { } }
1363 \f@nch@initialise
1364 \@ifpackagewith { fancyhdr } { headings }
1365 {
1366 \ctex_patch_cmd:Nnn \ps@headings
1367 {
1368 \ifnum \c@secnumdepth > \m@ne
1369 \@chapapp \ \thechapter . ~ \ %
1370 \fi
1371 }
1372 { \CTEXifname { \CTEXthechapter \quad } { } }
1373 \legacy_if:nT { @twoside }
1374 {
1375 \ctex_patch_cmd:Nnn \ps@headings
1376 { \ifnum \c@secnumdepth > \z@ \thesection . ~ \ \fi }
1377 { \CTEXifname { \CTEXthesection \quad } { } }
1378 }
1379 }
1380 { }
1381 }
1382 \ctex_define:n
1383 {
1384 secnumdepth .code:n = \ctex_heading_depth:ne { secnumdepth } {#1} ,
1385 secnumdepth .value_required:n = true ,
1386 tocdepth .code:n = \ctex_heading_depth:ne { tocdepth } {#1} ,
1387 tocdepth .value_required:n = true
1388 }
1389 \cs_new_protected:Npn \ctex_heading_depth:nn #1#2
1390 {
1391 \prop_get:NnNTF \c__ctex_heading_level_prop {#2} \l__ctex_tmp_tl
1392 { \setcounter {#1} { \l__ctex_tmp_tl } }
1393 { \setcounter {#1} { \int_eval:n {#2} } }
1394 }
1395 \cs_generate_variant:Nn \ctex_heading_depth:nn { ne }
1396 \prop_const_from_keyval:Nn \c__ctex_heading_level_prop
1397 {
1398 part = -1 ,
1399 chapter = 0 ,
1400 section = 1 ,
1401 subsection = 2 ,
1402 subsubsection = 3 ,
1403 paragraph = 4 ,
1404 subparagraph = 5
1405 }
1406 \cs_new_protected:Npn \CTEX@setcurrentlabel@n #1
1407 {
1408 \protected@edef \@currentlabel
1409 {
1410 \cs_if_exist:cTF { CTEX@the#1 }
1411 { \exp_args:cc { p@#1 } { CTEX@the#1 } }
1412 { \exp_not:o { \@currentlabel } }
1413 }
1414 }
1415 \cs_new_protected:Npn \ctex_varioref_hook:
1416 {
1417 \seq_map_inline:Nn \c__ctex_headings_seq
1418 { \ctex_fix_varioref_label:n { ##1 } }
1419 \ctex_at_end_package:nn { cleveref } { \ctex_cleveref_hook: }
1420 }
1421 \cs_new_protected:Npn \ctex_fix_varioref_label:n #1
1422 {
1423 \tl_if_empty:cT { p@#1 }
1424 { \exp_args:Nnx \labelformat {#1} { \exp_not:c { CTEX@the#1 } } }
1425 }
1426 \cs_new_protected:Npn \ctex_cleveref_hook:
1427 {
1428 \@ifpackageloaded { hyperref }
1429 {
1430 \@ifpackagewith { hyperref } { implicit = false }
1431 { }
1432 { \__ctex_cleveref_hook_aux:N \H@refstepcounter }
1433 }
1434 {
1435 \__ctex_cleveref_hook_aux:N \refstepcounter@noarg
1436 \__ctex_cleveref_hook_aux:N \refstepcounter@optarg
1437 }
1438 \__ctex_cleveref_hook_aux:N \appendix
1439 }
1440 \cs_new_protected:Npn \__ctex_cleveref_hook_aux:N #1
1441 {
1442 \ctex_patch_cmd_all:NnnnTF #1
1443 {
1444 \ExplSyntaxOff
1445 \char_set_catcode_letter:n { 64 }
1446 }
1447 { \endcsname \csname the }
1448 { \expandafter \endcsname \csname the }
1449 { }
1450 { \ctex_patch_failure:N #1 }
1451 }
1452 \cs_if_exist:NTF \labelformat
1453 { \ctex_varioref_hook: }
1454 {
1455 \cs_new_eq:NN \CTEX@save@refstepcounter \refstepcounter
1456 \RenewDocumentCommand \refstepcounter { m }
1457 {
1458 \CTEX@save@refstepcounter {#1}
1459 \CTEX@setcurrentlabel@n {#1}
1460 }
1461 \ctex_at_end_package:nn { varioref } { \ctex_varioref_hook: }
1462 }
1463 \ctex_scheme_input:o { \l__ctex_scheme_tl }
1464 \NewDocumentCommand \zihao { m }
1465 { \exp_args:Nx \ctex_zihao:n {#1} \tex_ignorespaces:D }
1466 \cs_new_protected:Npn \ctex_zihao:n #1
1467 {
1468 \prop_get:NnNTF \c__ctex_font_size_prop {#1} \l__ctex_font_size_tl
1469 { \exp_after:wN \fontsize \l__ctex_font_size_tl \selectfont }
1470 { \msg_error:nnn { ctex } { fontsize } {#1} }
1471 }
1472 \msg_new:nnnn { ctex } { fontsize }
1473 { Undefined~Chinese~font~size~`#1'~in~command~\token_to_str:N \zihao.}
1474 {
1475 The~old~font~size~is~used~if~you~continue.\\
1476 The~available~font~sizes~are~listed~as~follow.\\
1477 \seq_use:Nnnn \c__ctex_font_size_seq { ~and~ } { ,~ } { ,~and~ }.
1478 }
1479 \prop_new:N \c__ctex_font_size_prop
1480 \seq_new:N \c__ctex_font_size_seq
1481 \cs_new_protected:Npn \__ctex_save_font_size:nn #1#2
1482 {
1483 \use:e
1484 {
1485 \prop_gput:Nnn \exp_not:N \c__ctex_font_size_prop {#1}
1486 {
1487 { \dim_to_decimal:n {#2} }
1488 { \dim_to_decimal:n { (#2) * 6 / 5 } }
1489 }
1490 }
1491 \seq_gput_right:Nn \c__ctex_font_size_seq {#1}
1492 }
1493 \clist_map_inline:nn
1494 {
1495 { 8 } { 5 bp } ,
1496 { 7 } { 5.5 bp } ,
1497 { -6 } { 6.5 bp } ,
1498 { 6 } { 7.5 bp } ,
1499 { -5 } { 9 bp } ,
1500 { 5 } { 10.5 bp } ,
1501 { -4 } { 12 bp } ,
1502 { 4 } { 14 bp } ,
1503 { -3 } { 15 bp } ,
1504 { 3 } { 16 bp } ,
1505 { -2 } { 18 bp } ,
1506 { 2 } { 22 bp } ,
1507 { -1 } { 24 bp } ,
1508 { 1 } { 26 bp } ,
1509 { -0 } { 36 bp } ,
1510 { 0 } { 42 bp }
1511 }
1512 { \__ctex_save_font_size:nn #1 }
1513 \cs_new_protected:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
1514 {
1515 \__ctex_get_font_sizes:Nn \l__ctex_font_size_tl { {#1} {#2} {#3} {#4} }
1516 \exp_after:wN \DeclareMathSizes \l__ctex_font_size_tl
1517 }
1518 \cs_new_protected:Npn \__ctex_get_font_sizes:Nn #1#2
1519 {
1520 \tl_clear:N #1
1521 \tl_map_inline:nn {#2}
1522 {
1523 \prop_get:NnNTF \c__ctex_font_size_prop {##1} \l__ctex_tmp_tl
1524 { \tl_put_right:Nx #1 { { \tl_head:N \l__ctex_tmp_tl } } }
1525 { \tl_put_right:Nx #1 { { \dim_to_decimal:n { ##1 } } } }
1526 }
1527 }
1528 \clist_map_inline:nn
1529 {
1530 { 8 }{ 8 }{ 5pt }{ 5pt } ,
1531 { 7 }{ 7 }{ 5pt }{ 5pt } ,
1532 { -6 }{ -6 }{ 5pt }{ 5pt } ,
1533 { 6 }{ 6 }{ 5pt }{ 5pt } ,
1534 { -5 }{ -5 }{ 6pt }{ 5pt } ,
1535 { 5 }{ 5 }{ 7pt }{ 5pt } ,
1536 { -4 }{ -4 }{ 8pt }{ 6pt } ,
1537 { 4 }{ 4 }{ 5 }{ 6 } ,
1538 { -3 }{ -3 }{ -4 }{ -5 } ,
1539 { 3 }{ 3 }{ 4 }{ 5 } ,
1540 { -2 }{ -2 }{ -3 }{ -4 } ,
1541 { 2 }{ 2 }{ 3 }{ 4 } ,
1542 { -1 }{ -1 }{ -2 }{ -3 } ,
1543 { 1 }{ 1 }{ 2 }{ 3 } ,
1544 { -0 }{ -0 }{ -1 }{ -2 } ,
1545 { 0 }{ 0 }{ 1 }{ 2 }
1546 }
1547 { \ctex_declare_math_sizes:nnnn #1 }
1548 \cs_new_protected:Npn \ctex_set_font_size:Nnn #1#2#3
1549 {
1550 \prop_get:NnNTF \c__ctex_font_size_prop {#2} \l__ctex_font_size_tl
1551 { \exp_after:wN \__ctex_set_font_size:nnNn \l__ctex_font_size_tl #1 {#3} }
1552 { \msg_error:nnn { ctex } { fontsize } {#2} }
1553 }
1554 \cs_new_protected:Npn \__ctex_set_font_size:nnNn #1#2#3#4
1555 { \cs_set_protected:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
1556 \int_case:nn { \g__ctex_font_size_int }
1557 {
1558 { 0 } { \file_input:n { ctex-c5size.clo } }
1559 { 1 } { \file_input:n { ctex-cs4size.clo } }
1560 }
1561 \fp_if_nan:nF { \l__ctex_line_spread_fp }
1562 {
1563 \exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp }
1564 \group_begin: \footnotesize \exp_args:NNNo \group_end:
1565 \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox }
1566 }
1567 \normalsize
1568 \NewDocumentCommand \CTeX { }
1569 { C \TeX }
1570 \ctex_at_end_package:nn { hyperref }
1571 { \pdfstringdefDisableCommands { \tl_set:Nn \CTeX { CTeX } } }
1572 \ctex_define:n
1573 {
1574 captiondelimiter .code:n =
1575 {
1576 \ctex_deprecated_option:n
1577 { You~can~load~the~package~`caption'~to~get~its~functionality. }
1578 }
1579 }
1580 \cs_new_protected:Npn \ctex_fontset_error:n #1
1581 { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} }
1582 \msg_new:nnn { ctex } { fontset-unavailable }
1583 { CTeX~fontset~`#1'~is~unavailable~in~current~mode. }
1584 \cs_new:Npx \ctex_fontset_case:nnn #1#2#3
1585 {
1586 \sys_if_engine_pdftex:TF
1587 {#1}
1588 { \sys_if_engine_uptex:TF {#2} {#3} }
1589 }
1590 \cs_new:Npx \ctex_fontset_case:nnnn #1#2#3#4
1591 {
1592 \sys_if_engine_pdftex:TF
1593 { \sys_if_output_pdf:TF {#1} {#2} }
1594 { \sys_if_engine_uptex:TF {#3} {#4} }
1595 }
1596 \cs_new_protected:Npn \ctex_detect_platform:
1597 {
1598 \sys_if_platform_windows:TF
1599 { \tl_gset:Nn \g__ctex_fontset_tl { windows } }
1600 {
1601 \ctex_if_platform_macos:TF
1602 { \tl_gset:Nn \g__ctex_fontset_tl { mac } }
1603 { \tl_gset:Nn \g__ctex_fontset_tl { fandol } }
1604 }
1605 }
1606 \cs_new_protected:Npn \ctex_if_platform_macos:TF
1607 { \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } }
1608 \cs_new_protected:Npn \ctex_load_fontset:
1609 {
1610 \tl_if_empty:NTF \g__ctex_fontset_tl
1611 { \ctex_detect_platform: }
1612 {
1613 \bool_lazy_or:nnTF
1614 { \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsnew } }
1615 { \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsold } }
1616 {
1617 \msg_warning:nnxx { ctex } { deprecated-fontset }
1618 { \g__ctex_fontset_tl } { windows }
1619 \tl_gset:Nn \g__ctex_fontset_tl { windows }
1620 }
1621 {
1622 \file_if_exist:nF { ctex-fontset- \g__ctex_fontset_tl .def }
1623 {
1624 \use:e
1625 {
1626 \ctex_detect_platform:
1627 \msg_error:nnxx { ctex } { fontset-not-found }
1628 { \g__ctex_fontset_tl } { \exp_not:N \g__ctex_fontset_tl }
1629 }
1630 }
1631 }
1632 }
1633 \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
1634 }
1635 \msg_new:nnn { ctex } { deprecated-fontset }
1636 { CTeX~fontset~`#1'~is~deprecated.\\ Fontset~`#2'~will~be~used~instead. }
1637 \msg_new:nnnn { ctex } { fontset-not-found }
1638 { CTeX~fontset~`#1'~could~not~be~found.\\ Fontset~`#2'~will~be~used~instead. }
1639 { You~may~run~`mktexlsr'~firstly. }
1640 \@onlypreamble \ctex_load_fontset:
1641 \ctex_define:n
1642 {
1643 fontset .code:n =
1644 {
1645 \ctex_if_preamble:TF
1646 {
1647 \str_if_eq:eeTF {#1} { none }
1648 { \msg_warning:nnn { ctex } { invalid-value } {#1} }
1649 {
1650 \str_if_eq:onTF { \g__ctex_fontset_tl } { none }
1651 {
1652 \tl_gset:Nx \g__ctex_fontset_tl {#1}
1653 \ctex_load_fontset:
1654 }
1655 {
1656 \msg_error:nnxx { ctex } { fontset-loaded }
1657 { \g__ctex_fontset_tl } {#1}
1658 }
1659 }
1660 }
1661 { \msg_error:nn { ctex } { fontset-only-preamble } }
1662 }
1663 }
1664 \msg_new:nnnn { ctex } { fontset-loaded }
1665 {
1666 CTeX~fontset~`#1'~has~been~loaded.
1667 \str_if_eq:nnF {#1} {#2} { \\ Fontset~`#2'~will~be~ignored. }
1668 }
1669 { Only~one~fontset~can~be~loaded~in~the~preamble. }
1670 \msg_new:nnn { ctex } { fontset-only-preamble }
1671 { The~`fontset'~option~can~be~used~only~in~preamble. }
1672 \str_if_eq:onF { \g__ctex_fontset_tl } { none }
1673 { \ctex_load_fontset: }
1674 \ctex_at_end:n { \ctex_file_input:n { ctex.cfg } }
1675 %%
1676 %% This package consists of the files ctex.dtx,
1677 %% ctxdoc.cls,
1678 %% ctxdocstrip.tex,
1679 %% ctex-zhconv.lua,
1680 %% ctex-zhconv-make.lua,
1681 %% and the derived files ctex.pdf,
1682 %% ctex.ins,
1683 %% ctex.sty,
1684 %% ctexsize.sty,
1685 %% ctexheading.sty,
1686 %% ctexart.cls,
1687 %% ctexbook.cls,
1688 %% ctexrep.cls,
1689 %% ctexbeamer.cls,
1690 %% ctexcap.sty,
1691 %% ctexhook.sty,
1692 %% ctexpatch.sty,
1693 %% ctex-c5size.clo,
1694 %% ctex-cs4size.clo,
1695 %% ctex-heading-article.def,
1696 %% ctex-heading-book.def,
1697 %% ctex-heading-report.def,
1698 %% ctex-heading-beamer.def,
1699 %% ctex-scheme-plain.def,
1700 %% ctex-scheme-plain-article.def,
1701 %% ctex-scheme-plain-book.def,
1702 %% ctex-scheme-plain-report.def,
1703 %% ctex-scheme-plain-beamer.def,
1704 %% ctex-scheme-chinese.def,
1705 %% ctex-scheme-chinese-article.def,
1706 %% ctex-scheme-chinese-book.def,
1707 %% ctex-scheme-chinese-report.def,
1708 %% ctex-scheme-chinese-beamer.def,
1709 %% ctex-name-gbk.cfg,
1710 %% ctex-name-utf8.cfg,
1711 %% ctex.cfg,
1712 %% ctexopts.cfg,
1713 %% ctexbackend.cfg,
1714 %% ctex-engine-pdftex.def,
1715 %% ctex-engine-xetex.def,
1716 %% ctex-engine-luatex.def,
1717 %% ctex-engine-aptex.def,
1718 %% ctex-engine-uptex.def,
1719 %% c19rm.fd,
1720 %% c19sf.fd,
1721 %% c19tt.fd,
1722 %% c70rm.fd,
1723 %% c70sf.fd,
1724 %% c70tt.fd,
1725 %% jy2zhrm.fd,
1726 %% jy2zhsf.fd,
1727 %% jy2zhtt.fd,
1728 %% jt2zhrm.fd,
1729 %% jt2zhsf.fd,
1730 %% jt2zhtt.fd,
1731 %% ctex-fontset-adobe.def,
1732 %% ctex-fontset-fandol.def,
1733 %% ctex-fontset-founder.def,
1734 %% ctex-fontset-mac.def,
1735 %% ctex-fontset-macnew.def,
1736 %% ctex-fontset-macold.def,
1737 %% ctex-fontset-ubuntu.def,
1738 %% ctex-fontset-windows.def,
1739 %% ctexspa.def,
1740 %% ctexpunct.spa,
1741 %% ctex-spa-make.tex,
1742 %% ctex-spa-macro.tex,
1743 %% ctex-zhmap-adobe.tex,
1744 %% ctex-zhmap-fandol.tex,
1745 %% ctex-zhmap-founder.tex,
1746 %% ctex-zhmap-mac.tex,
1747 %% ctex-zhmap-ubuntu.tex,
1748 %% ctex-zhmap-windows.tex,
1749 %% ctex-zhconv-index.lua,
1750 %% translator-theorem-dictionary-ChineseGBK.dict,
1751 %% translator-theorem-dictionary-ChineseUTF8.dict, and
1752 %% README.md.
1753 %%
1754 %% End of file `ctexrep.cls'.