| 1 |
%% |
| 2 |
%% This is file `ctexart.cls', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% ctex.dtx (with options: `class,article') |
| 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 article (CTEX)} |
| 32 |
\ProvidesExplClass{ctexart} |
| 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 } { ctexart } |
| 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 { article } |
| 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 = \refname |
| 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 { part } |
| 590 |
\cs_new_protected:Npn \__ctex_initial_heading:n #1 |
| 591 |
{ |
| 592 |
\tl_new:c { CTEX@pre#1 } |
| 593 |
\tl_new:c { CTEX@post#1 } |
| 594 |
\tl_const:cx { CTEXthe#1 } |
| 595 |
{ |
| 596 |
\exp_not:c { CTEX@pre#1 } |
| 597 |
\exp_not:c { CTEX@the#1 } |
| 598 |
\exp_not:c { CTEX@post#1 } |
| 599 |
} |
| 600 |
\tl_const:cx { CTEX@#1name } |
| 601 |
{ |
| 602 |
\group_begin: |
| 603 |
\exp_not:c { CTEX@#1@nameformat } |
| 604 |
{ |
| 605 |
\exp_not:c { CTEX@pre#1 } |
| 606 |
\exp_not:N \tl_if_empty:NTF |
| 607 |
\exp_not:c { CTEX@#1@numberformat } |
| 608 |
{ \exp_not:c { CTEX@the#1 } } |
| 609 |
{ |
| 610 |
\group_begin: |
| 611 |
\exp_not:c { CTEX@#1@numberformat } |
| 612 |
\exp_not:c { CTEX@the#1 } |
| 613 |
\group_end: |
| 614 |
} |
| 615 |
\exp_not:c { CTEX@post#1 } |
| 616 |
} |
| 617 |
\group_end: |
| 618 |
} |
| 619 |
} |
| 620 |
\cs_new_protected:Npn \__ctex_def_heading_keys:n #1 |
| 621 |
{ |
| 622 |
\exp_args:NNe \tl_put_right:Nn \l__ctex_tmp_tl |
| 623 |
{ |
| 624 |
#1 .meta:nn = { ctex / #1 } { ##1 } , |
| 625 |
#1 / name .code:n = |
| 626 |
{ \ctex_assign_heading_name:nn {#1} { ##1 } } , |
| 627 |
#1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , |
| 628 |
#1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , |
| 629 |
#1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , |
| 630 |
#1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , |
| 631 |
#1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , |
| 632 |
#1 / numbering .initial:n = true , |
| 633 |
#1 / beforeskip .initial:n = \c_zero_skip , |
| 634 |
#1 / afterskip .initial:n = \c_zero_skip , |
| 635 |
#1 / indent .initial:n = \c_zero_dim , |
| 636 |
#1 / beforeskip .value_required:n = true , |
| 637 |
#1 / afterskip .value_required:n = true , |
| 638 |
#1 / indent .value_required:n = true , |
| 639 |
#1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , |
| 640 |
#1 / fixskip .bool_set:N = \exp_not:c { CTEX@#1@fixskip } , |
| 641 |
#1 / hang .bool_set:N = \exp_not:c { CTEX@#1@hang } , |
| 642 |
#1 / hang .initial:n = true , |
| 643 |
#1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , |
| 644 |
#1 / tocline .cs_set:Np = \exp_not:c { CTEX@#1@tocline } ##1##2 , |
| 645 |
\__ctex_plus_key_aux:nn {#1} { break } , |
| 646 |
\__ctex_plus_key_aux:nn {#1} { format } , |
| 647 |
\__ctex_plus_key_aux:nn {#1} { nameformat } , |
| 648 |
\__ctex_plus_key_aux:nn {#1} { numberformat } , |
| 649 |
\__ctex_plus_key_aux:nn {#1} { titleformat } , |
| 650 |
\__ctex_plus_key_aux:nn {#1} { aftername } , |
| 651 |
\__ctex_plus_key_aux:nn {#1} { aftertitle } , |
| 652 |
} |
| 653 |
} |
| 654 |
\cs_new:Npn \__ctex_plus_key_aux:nn #1#2 |
| 655 |
{ |
| 656 |
#1 / #2 .tl_set:N = \exp_not:c { CTEX@#1@#2 } , |
| 657 |
#1 / #2 + .code:n = |
| 658 |
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ##1 } } , |
| 659 |
#1 / #2 ~ + .code:n = |
| 660 |
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ##1 } } |
| 661 |
} |
| 662 |
\NewDocumentCommand \ctex_assign_heading_name:nn |
| 663 |
{ m > { \SplitArgument { 1 } { , } } +m } |
| 664 |
{ \__ctex_assign_heading_name:nnn {#1} #2 } |
| 665 |
\cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3 |
| 666 |
{ |
| 667 |
\tl_set:cn { CTEX@pre#1 } {#2} |
| 668 |
\tl_if_novalue:nTF {#3} |
| 669 |
{ \tl_clear:c { CTEX@post#1 } } |
| 670 |
{ \tl_set:cn { CTEX@post#1 } {#3} } |
| 671 |
} |
| 672 |
\group_begin: |
| 673 |
\tl_clear:N \l__ctex_tmp_tl |
| 674 |
\seq_map_inline:Nn \c__ctex_headings_seq |
| 675 |
{ |
| 676 |
\__ctex_initial_heading:n {#1} |
| 677 |
\__ctex_def_heading_keys:n {#1} |
| 678 |
} |
| 679 |
\exp_args:NNo \group_end: \ctex_define:n { \l__ctex_tmp_tl } |
| 680 |
\cs_new_protected:Npn \CTEX@heading@format@initial |
| 681 |
{ |
| 682 |
\normalfont |
| 683 |
\tl_clear:N \l__ctex_autoindent_tl |
| 684 |
\int_set:Nn \tex_interlinepenalty:D { 10 000 } |
| 685 |
\tex_noindent:D |
| 686 |
} |
| 687 |
\cs_new_protected:Npn \ctex_indent_box:n #1 |
| 688 |
{ |
| 689 |
\dim_set:Nn \tex_parindent:D {#1} |
| 690 |
\__ctex_insert_indent: |
| 691 |
} |
| 692 |
\cs_new_protected:Npn \__ctex_insert_indent: |
| 693 |
{ |
| 694 |
\dim_compare:nNnF \tex_parindent:D = \c_zero_dim |
| 695 |
{ \tex_indent:D } |
| 696 |
} |
| 697 |
\cs_new_eq:NN \CTEX@indentbox \ctex_indent_box:n |
| 698 |
\cs_new_protected:Npn \CTEX@fixheadingskip |
| 699 |
{ |
| 700 |
\par |
| 701 |
\dim_set:Nn \tex_prevdepth:D { -1000pt } |
| 702 |
\skip_sub:Nn \l__ctex_heading_skip { \tex_parskip:D } |
| 703 |
} |
| 704 |
\skip_new:N \l__ctex_heading_skip |
| 705 |
\cs_new_protected:Npn \CTEX@setheadingskip |
| 706 |
{ \skip_set:Nn \l__ctex_heading_skip } |
| 707 |
\cs_new_eq:NN \CTEX@headingskip \l__ctex_heading_skip |
| 708 |
\ProvideDocumentCommand \partmark { m } |
| 709 |
{ \markboth { } { } } |
| 710 |
\cs_new_eq:NN \CTEXifname \use_ii:nn |
| 711 |
\cs_new_protected:Npn \CTEX@ifnametrue |
| 712 |
{ \cs_set_eq:NN \CTEXifname \use_i:nn } |
| 713 |
\cs_new_protected:Npn \CTEX@ifnamefalse |
| 714 |
{ \cs_set_eq:NN \CTEXifname \use_ii:nn } |
| 715 |
\cs_new_protected:Npn \CTEX@addtocline #1#2 |
| 716 |
{ \addcontentsline { toc } {#1} { \use:c { CTEX@#1@tocline } {#1} {#2} } } |
| 717 |
\renewcommand\part{% |
| 718 |
\if@noskipsec \leavevmode \fi |
| 719 |
\par |
| 720 |
\CTEX@part@break |
| 721 |
\CTEX@setheadingskip \CTEX@part@beforeskip |
| 722 |
\ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi |
| 723 |
\addvspace \CTEX@headingskip |
| 724 |
\ifodd \CTEX@part@afterindent |
| 725 |
\@afterindenttrue |
| 726 |
\else |
| 727 |
\@afterindentfalse |
| 728 |
\fi |
| 729 |
\secdef\@part\@spart} |
| 730 |
\def\@part[#1]#2{% |
| 731 |
\ifnum \c@secnumdepth >\m@ne |
| 732 |
\ifodd \CTEX@part@numbering |
| 733 |
\CTEX@ifnametrue |
| 734 |
\refstepcounter{part}% |
| 735 |
\else |
| 736 |
\CTEX@ifnamefalse |
| 737 |
\CTEX@makeanchor{part*}% |
| 738 |
\fi |
| 739 |
\else |
| 740 |
\CTEX@ifnamefalse |
| 741 |
\CTEX@makeanchor{part*}% |
| 742 |
\fi |
| 743 |
\CTEX@gettitle{#1}% |
| 744 |
\CTEX@addtocline{part}{#1}% |
| 745 |
\partmark{#1}% |
| 746 |
\begingroup |
| 747 |
\CTEX@heading@format@initial |
| 748 |
\CTEX@part@format{% |
| 749 |
\CTEX@headinghang{part}% |
| 750 |
{\CTEXifname{\CTEX@partname\CTEX@part@aftername}{}}% |
| 751 |
\CTEX@part@titleformat{#2}% |
| 752 |
\CTEX@part@aftertitle}\par |
| 753 |
\endgroup |
| 754 |
\nobreak |
| 755 |
\CTEX@setheadingskip \CTEX@part@afterskip |
| 756 |
\ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi |
| 757 |
\vskip \CTEX@headingskip |
| 758 |
\@afterheading} |
| 759 |
\def\@spart#1{% |
| 760 |
\CTEX@ifnamefalse |
| 761 |
\CTEX@makeanchor@spart{part*}% |
| 762 |
\CTEX@gettitle{#1}% |
| 763 |
\begingroup |
| 764 |
\CTEX@heading@format@initial |
| 765 |
\CTEX@part@format{% |
| 766 |
\CTEX@headinghang{part}{}% |
| 767 |
\CTEX@part@titleformat{#1}% |
| 768 |
\CTEX@part@aftertitle}\par |
| 769 |
\endgroup |
| 770 |
\nobreak |
| 771 |
\CTEX@setheadingskip \CTEX@part@afterskip |
| 772 |
\ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi |
| 773 |
\vskip \CTEX@headingskip |
| 774 |
\@afterheading} |
| 775 |
\def\@startsection#1#2#3#4#5#6{% |
| 776 |
\if@noskipsec \leavevmode \fi |
| 777 |
\par |
| 778 |
\CTEX@update@sectionformat@n{#1}% |
| 779 |
\ifodd \CTEX@afterindent |
| 780 |
\@afterindenttrue |
| 781 |
\else |
| 782 |
\@afterindentfalse |
| 783 |
\fi |
| 784 |
\if@nobreak |
| 785 |
\everypar{}% |
| 786 |
\else |
| 787 |
\csname CTEX@#1@break\endcsname |
| 788 |
\CTEX@setheadingskip{#4}% |
| 789 |
\ifodd \CTEX@fixskip \CTEX@fixheadingskip \fi |
| 790 |
\addvspace \CTEX@headingskip |
| 791 |
\fi |
| 792 |
\@ifstar |
| 793 |
{\CTEX@makeanchor@ssect{#1*}\@ssect{#3}{#4}{#5}{#6}}% |
| 794 |
{\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} |
| 795 |
\def\@seccntformat#1{% |
| 796 |
\csname CTEX@#1name\endcsname |
| 797 |
\csname CTEX@#1@aftername\endcsname} |
| 798 |
\def\@sect#1#2#3#4#5#6[#7]#8{% |
| 799 |
\ifnum #2>\c@secnumdepth |
| 800 |
\CTEX@ifnamefalse |
| 801 |
\CTEX@makeanchor@sect{#1*}% |
| 802 |
\let\@svsec\@empty |
| 803 |
\else |
| 804 |
\ifodd \csname CTEX@#1@numbering\endcsname |
| 805 |
\CTEX@ifnametrue |
| 806 |
\refstepcounter{#1}% |
| 807 |
\protected@edef\@svsec{\@seccntformat{#1}\relax}% |
| 808 |
\else |
| 809 |
\CTEX@ifnamefalse |
| 810 |
\CTEX@makeanchor{#1*}% |
| 811 |
\let\@svsec\@empty |
| 812 |
\fi |
| 813 |
\fi |
| 814 |
\CTEX@gettitle{#7}% |
| 815 |
\unless \ifodd \CTEX@runin |
| 816 |
\begingroup |
| 817 |
\CTEX@heading@format@initial |
| 818 |
#6{% |
| 819 |
\CTEX@sectionhang{#3}{\@svsec}% |
| 820 |
\csname CTEX@#1@titleformat\endcsname{#8}% |
| 821 |
\csname CTEX@#1@aftertitle\endcsname}\par |
| 822 |
\endgroup |
| 823 |
\csname #1mark\endcsname{#7}% |
| 824 |
\CTEX@addtocline{#1}{#7}% |
| 825 |
\else |
| 826 |
\def\@svsechd{% |
| 827 |
#6{% |
| 828 |
{\CTEX@indentbox{#3}}\@svsec |
| 829 |
\csname CTEX@#1@titleformat\endcsname{#8}% |
| 830 |
\csname CTEX@#1@aftertitle\endcsname}% |
| 831 |
\csname #1mark\endcsname{#7}% |
| 832 |
\CTEX@addtocline{#1}{#7}}% |
| 833 |
\fi |
| 834 |
\@xsect{#5}} |
| 835 |
\def\@ssect#1#2#3#4#5{% |
| 836 |
\CTEX@ifnamefalse |
| 837 |
\CTEX@gettitle{#5}% |
| 838 |
\unless \ifodd \CTEX@runin |
| 839 |
\begingroup |
| 840 |
\CTEX@heading@format@initial |
| 841 |
#4{% |
| 842 |
\CTEX@sectionhang{#1}{}% |
| 843 |
\CTEX@titleformat@n{#5}% |
| 844 |
\CTEX@aftertitle}\par |
| 845 |
\endgroup |
| 846 |
\else |
| 847 |
\def\@svsechd{#4{{\CTEX@indentbox{#1}}% |
| 848 |
\CTEX@titleformat@n{#5}\CTEX@aftertitle}}% |
| 849 |
\fi |
| 850 |
\@xsect{#3}} |
| 851 |
\def\@xsect#1{% |
| 852 |
\unless \ifodd \CTEX@runin |
| 853 |
\par \nobreak |
| 854 |
\CTEX@setheadingskip{#1}% |
| 855 |
\ifodd \CTEX@fixskip \CTEX@fixheadingskip \fi |
| 856 |
\vskip \CTEX@headingskip |
| 857 |
\@afterheading |
| 858 |
\else |
| 859 |
\@nobreakfalse |
| 860 |
\global\@noskipsectrue |
| 861 |
\everypar{% |
| 862 |
\if@noskipsec |
| 863 |
\global\@noskipsecfalse |
| 864 |
{\setbox\z@\lastbox}% |
| 865 |
\clubpenalty\@M |
| 866 |
\begingroup \@svsechd \endgroup |
| 867 |
\unskip |
| 868 |
\CTEX@heading@glue{#1}% |
| 869 |
\else |
| 870 |
\clubpenalty \@clubpenalty |
| 871 |
\everypar{}% |
| 872 |
\fi}% |
| 873 |
\fi |
| 874 |
\ignorespaces} |
| 875 |
\cs_new_protected:Npn \CTEX@headinghang #1 |
| 876 |
{ |
| 877 |
\ctex_heading_hang:cnn |
| 878 |
{ CTEX@#1@hang } |
| 879 |
{ \use:c { CTEX@#1@indent } } |
| 880 |
} |
| 881 |
\cs_new_protected:Npn \CTEX@sectionhang |
| 882 |
{ \ctex_heading_hang:Nnn \CTEX@hang } |
| 883 |
\cs_new_protected:Npn \ctex_heading_hang:Nnn #1#2#3 |
| 884 |
{ |
| 885 |
\dim_set:Nn \tex_parindent:D {#2} |
| 886 |
\bool_if:NTF #1 |
| 887 |
{ \ctex_hang_from:n } |
| 888 |
{ \use:n } |
| 889 |
{ \__ctex_insert_indent: #3 } |
| 890 |
} |
| 891 |
\cs_new_protected:Npn \ctex_hang_from:n #1 |
| 892 |
{ |
| 893 |
\tex_noindent:D |
| 894 |
\hbox_set:Nn \l__ctex_tmp_box {#1} |
| 895 |
\tex_hangindent:D = \box_wd:N \l__ctex_tmp_box |
| 896 |
\box_use_drop:N \l__ctex_tmp_box |
| 897 |
} |
| 898 |
\cs_generate_variant:Nn \ctex_heading_hang:Nnn { c } |
| 899 |
\cs_new_protected:Npn \ctex_heading_glue:n #1 |
| 900 |
{ |
| 901 |
\group_begin: |
| 902 |
\skip_set:Nn \l__ctex_heading_skip {#1} |
| 903 |
\dim_compare:nNnF \l__ctex_heading_skip = \c_zero_dim |
| 904 |
{ \skip_horizontal:N \l__ctex_heading_skip } |
| 905 |
\group_end: |
| 906 |
} |
| 907 |
\cs_new_eq:NN \CTEX@heading@glue \ctex_heading_glue:n |
| 908 |
\cs_new_protected:Npn \CTEX@update@sectionformat@n #1 |
| 909 |
{ |
| 910 |
\cs_set_eq:Nc \CTEX@titleformat@n { CTEX@#1@titleformat } |
| 911 |
\cs_set_eq:Nc \CTEX@aftertitle { CTEX@#1@aftertitle } |
| 912 |
\cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } |
| 913 |
\cs_set_eq:Nc \CTEX@fixskip { CTEX@#1@fixskip } |
| 914 |
\cs_set_eq:Nc \CTEX@hang { CTEX@#1@hang } |
| 915 |
\cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } |
| 916 |
} |
| 917 |
\cs_new_eq:NN \CTEX@titleformat@n \use:n |
| 918 |
\cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: |
| 919 |
\cs_new_eq:NN \CTEX@afterindent \c_true_bool |
| 920 |
\cs_new_eq:NN \CTEX@fixskip \c_false_bool |
| 921 |
\cs_new_eq:NN \CTEX@hang \c_true_bool |
| 922 |
\cs_new_eq:NN \CTEX@runin \c_false_bool |
| 923 |
\cs_new:Npn \CTEX@part@tocline #1#2 |
| 924 |
{ |
| 925 |
\CTEXifname |
| 926 |
{ \CTEXthepart \hspace { 1em } } |
| 927 |
{ } |
| 928 |
#2 |
| 929 |
} |
| 930 |
\cs_new:Npn \CTEXnumberline #1 |
| 931 |
{ |
| 932 |
\CTEXifname |
| 933 |
{ \protect \numberline { \use:c { CTEXthe #1 } } } |
| 934 |
{ } |
| 935 |
} |
| 936 |
\int_zero:N \l__ctex_tmp_int |
| 937 |
\seq_map_inline:Nn \c__ctex_section_headings_seq |
| 938 |
{ |
| 939 |
\int_incr:N \l__ctex_tmp_int |
| 940 |
\cs_gset_protected:cpx {#1} |
| 941 |
{ |
| 942 |
\exp_not:N \@startsection {#1} |
| 943 |
{ \int_use:N \l__ctex_tmp_int } |
| 944 |
{ \exp_not:c { CTEX@#1@indent } } |
| 945 |
{ \exp_not:c { CTEX@#1@beforeskip } } |
| 946 |
{ \exp_not:c { CTEX@#1@afterskip } } |
| 947 |
{ \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } |
| 948 |
} |
| 949 |
\cs_new:cpn { CTEX@#1@tocline } ##1##2 |
| 950 |
{ \CTEXnumberline { ##1 } ##2 } |
| 951 |
} |
| 952 |
\ctex_define:n |
| 953 |
{ |
| 954 |
appendix .meta:nn = { ctex / appendix } {#1} , |
| 955 |
appendix / name .code:n = |
| 956 |
{ \ctex_assign_heading_name:nn { appendix } {#1} } , |
| 957 |
appendix / number .tl_set:N = \CTEX@appendix@number , |
| 958 |
appendix / numbering .bool_set:N = \CTEX@appendix@numbering , |
| 959 |
appendix / numbering .initial:n = true |
| 960 |
} |
| 961 |
\tl_new:N \CTEX@preappendix |
| 962 |
\tl_new:N \CTEX@postappendix |
| 963 |
\cs_new_eq:NN \CTEX@save@appendix \appendix |
| 964 |
\cs_gset_protected:Npn \appendix |
| 965 |
{ |
| 966 |
\CTEX@save@appendix |
| 967 |
\gdef \CTEX@presection { \CTEX@preappendix } |
| 968 |
\gdef \CTEX@thesection { \CTEX@appendix@number } |
| 969 |
\gdef \CTEX@postsection { \CTEX@postappendix } |
| 970 |
\gdef \CTEX@section@numbering { \CTEX@appendix@numbering } |
| 971 |
} |
| 972 |
\cs_new_protected:Npn \CTEX@makeanchor #1 |
| 973 |
{ } |
| 974 |
\seq_const_from_clist:Nn \c__ctex_headings_cs_seq |
| 975 |
{ part , spart , sect , ssect } |
| 976 |
\seq_map_inline:Nn \c__ctex_headings_cs_seq |
| 977 |
{ |
| 978 |
\cs_new_eq:cc { CTEX@ #1 } { @ #1 } |
| 979 |
\cs_new_eq:cN { CTEX@makeanchor@ #1 } \CTEX@makeanchor |
| 980 |
} |
| 981 |
\cs_new_protected:Npn \CTEX@hyperheadinghook |
| 982 |
{ |
| 983 |
\group_begin: |
| 984 |
\legacy_if:nTF { Hy@implicit } |
| 985 |
{ |
| 986 |
\cs_set_eq:NN \H@old@chapter \Hy@org@chapter |
| 987 |
\seq_map_inline:Nn \c__ctex_headings_cs_seq |
| 988 |
{ |
| 989 |
\cs_if_eq:ccT { H@old@ ##1 } { CTEX@ ##1 } |
| 990 |
{ |
| 991 |
\cs_gset_eq:cc { @ ##1 } { CTEX@ ##1 } |
| 992 |
\cs_gset_eq:cN { CTEX@makeanchor@ ##1 } \CTEX@makeanchor |
| 993 |
} |
| 994 |
} |
| 995 |
} |
| 996 |
{ |
| 997 |
\seq_map_inline:Nn \c__ctex_headings_cs_seq |
| 998 |
{ \cs_gset_eq:cN { CTEX@makeanchor@ ##1 } \CTEX@makeanchor } |
| 999 |
} |
| 1000 |
\group_end: |
| 1001 |
} |
| 1002 |
\ctex_at_end_package:nn { hyperref } |
| 1003 |
{ |
| 1004 |
\cs_gset_protected:Npn \CTEX@makeanchor #1 |
| 1005 |
{ |
| 1006 |
\Hy@MakeCurrentHrefAuto {#1} |
| 1007 |
\Hy@raisedlink |
| 1008 |
{ |
| 1009 |
\hyper@anchorstart { \@currentHref } |
| 1010 |
\hyper@anchorend |
| 1011 |
} |
| 1012 |
} |
| 1013 |
\CTEX@hyperheadinghook |
| 1014 |
} |
| 1015 |
\cs_new_protected:Npn \CTEX@gettitle #1 |
| 1016 |
{ } |
| 1017 |
\ctex_at_end_package:nn { nameref } |
| 1018 |
{ |
| 1019 |
\cs_gset_protected:Npn \CTEX@gettitle { \NR@gettitle } |
| 1020 |
\seq_map_inline:Nn \c__ctex_headings_cs_seq |
| 1021 |
{ |
| 1022 |
\cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 } |
| 1023 |
{ \cs_gset_eq:cc { @ #1 } { CTEX@ #1 } } |
| 1024 |
} |
| 1025 |
} |
| 1026 |
\cs_new_protected:Npn \ctex_titlesec_hook: |
| 1027 |
{ |
| 1028 |
\@ifpackagewith { titlesec } { explicit } |
| 1029 |
{ |
| 1030 |
\cs_set_eq:NN \__ctex_titlesec_format:Nn |
| 1031 |
\__ctex_titlesec_format_explicit:Nn |
| 1032 |
} |
| 1033 |
{ } |
| 1034 |
\clist_map_inline:nn |
| 1035 |
{ indentafter , noindentafter , indentfirst , nonindentfirst } |
| 1036 |
{ |
| 1037 |
\@ifpackagewith { titlesec } { ##1 } |
| 1038 |
{ |
| 1039 |
\clist_map_break:n |
| 1040 |
{ \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n } |
| 1041 |
} |
| 1042 |
{ } |
| 1043 |
} |
| 1044 |
\seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n |
| 1045 |
} |
| 1046 |
\cs_new_protected:Npn \__ctex_titlesec_hook:n #1 |
| 1047 |
{ |
| 1048 |
\__ctex_titlesec_format:n {#1} |
| 1049 |
\exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1} |
| 1050 |
} |
| 1051 |
\cs_new_protected:Npn \__ctex_titlesec_format:n #1 |
| 1052 |
{ |
| 1053 |
\cs_if_free:cF { ttlf@#1 } |
| 1054 |
{ \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} } |
| 1055 |
} |
| 1056 |
\cs_new_protected:Npn \__ctex_titlesec_format:Nn #1#2 |
| 1057 |
{ |
| 1058 |
\tl_set:Nx #1 |
| 1059 |
{ |
| 1060 |
\bool_if:cTF { CTEX@#2@runin } |
| 1061 |
{ \exp_not:N \ttlh@runin } |
| 1062 |
{ \exp_not:N \ttlh@hang } |
| 1063 |
\tl_tail:N #1 |
| 1064 |
} |
| 1065 |
} |
| 1066 |
\cs_new_protected:Npn \__ctex_titlesec_format_explicit:Nn #1#2 |
| 1067 |
{ |
| 1068 |
\cs_set_nopar:Npx #1 ##1 |
| 1069 |
{ |
| 1070 |
\bool_if:cTF { CTEX@#2@runin } |
| 1071 |
{ \exp_not:N \ttlh@runin } |
| 1072 |
{ \exp_not:N \ttlh@hang } |
| 1073 |
\exp_args:No \tl_tail:n { #1 { } } |
| 1074 |
} |
| 1075 |
} |
| 1076 |
\cs_new_protected:Npn \__ctex_titlesec_spacing:Nn #1#2 |
| 1077 |
{ \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } } |
| 1078 |
\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6 |
| 1079 |
{ |
| 1080 |
\exp_not:n { {#1} {#2} {#3} {#4} } |
| 1081 |
{ \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } |
| 1082 |
} |
| 1083 |
\@ifpackageloaded { titlesec } |
| 1084 |
{ } |
| 1085 |
{ |
| 1086 |
\ctex_at_end_package:nn { titlesec } |
| 1087 |
{ |
| 1088 |
\@ifpackagewith { titlesec } { loadonly } |
| 1089 |
{ } |
| 1090 |
{ \ctex_titlesec_hook: } |
| 1091 |
} |
| 1092 |
} |
| 1093 |
\ctex_at_end_package:nn { titlesec } |
| 1094 |
{ |
| 1095 |
\cs_if_free:NF \ttl@tocpart |
| 1096 |
{ |
| 1097 |
\cs_set_protected:Npn \ttl@tocpart |
| 1098 |
{ \tl_set:Nn \ttl@a { \CTEXthepart \hspace { 1em } } } |
| 1099 |
} |
| 1100 |
\seq_map_inline:Nn \c__ctex_headings_seq |
| 1101 |
{ |
| 1102 |
\cs_if_exist:cF { ttl@toc #1 } |
| 1103 |
{ |
| 1104 |
\cs_new_protected:cpx { ttl@toc #1 } |
| 1105 |
{ |
| 1106 |
\tl_set:Nn \exp_not:N \ttl@a |
| 1107 |
{ |
| 1108 |
\exp_not:N \protect |
| 1109 |
\exp_not:N \numberline { \exp_not:c { CTEXthe #1 } } |
| 1110 |
} |
| 1111 |
} |
| 1112 |
} |
| 1113 |
} |
| 1114 |
} |
| 1115 |
\ctex_at_end_package:nn { titlesec } |
| 1116 |
{ |
| 1117 |
\ctex_patch_cmd:Nnn \ttl@labelling |
| 1118 |
{ \let \ifttl@toclabel \ifttl@label } |
| 1119 |
{ |
| 1120 |
\let \ifttl@toclabel \ifttl@label |
| 1121 |
\CTEX@updatettlifname |
| 1122 |
} |
| 1123 |
\cs_new_protected:Npn \CTEX@updatettlifname |
| 1124 |
{ \legacy_if:nTF { ttl@label } { \CTEX@ifnametrue } { \CTEX@ifnamefalse } } |
| 1125 |
} |
| 1126 |
\group_begin: |
| 1127 |
\char_set_catcode_other:N \# |
| 1128 |
\cs_new_protected:Npn \ctex_titleps_hook: |
| 1129 |
{ |
| 1130 |
\ctex_patch_cmd:Nnn \ttl@settopmark |
| 1131 |
{ \protect \@namedef { the#1 } { \@nameuse { the#1 } } } |
| 1132 |
{ |
| 1133 |
\protect \@namedef { the#1 } { \@nameuse { the#1 } } |
| 1134 |
\CTEX@titlepslabel@set {#1} |
| 1135 |
} |
| 1136 |
\ctex_patch_cmd:Nnn \ttl@setsubmark |
| 1137 |
{ \protect \@namedef { the#1 } { } } |
| 1138 |
{ |
| 1139 |
\protect \@namedef { the#1 } { } |
| 1140 |
\CTEX@titlepslabel@clear {#1} |
| 1141 |
} |
| 1142 |
\ctex_patch_cmd:Nnn \ttl@setsubmark |
| 1143 |
{ \protect \@namedef { the#2 } { \@nameuse { the#2 } } } |
| 1144 |
{ |
| 1145 |
\protect \@namedef { the#2 } { \@nameuse { the#2 } } |
| 1146 |
\CTEX@titlepslabel@set {#2} |
| 1147 |
} |
| 1148 |
} |
| 1149 |
\group_end: |
| 1150 |
\cs_new:Npn \CTEX@titlepslabel@set #1 |
| 1151 |
{ |
| 1152 |
\cs_if_free:cF { CTEXthe#1 } |
| 1153 |
{ \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } } |
| 1154 |
} |
| 1155 |
\cs_new:Npn \CTEX@titlepslabel@clear #1 |
| 1156 |
{ |
| 1157 |
\cs_if_free:cF { CTEXthe#1 } |
| 1158 |
{ \protect \@namedef { CTEXthe#1 } { } } |
| 1159 |
} |
| 1160 |
\ctex_at_end_package:nn { titlesec } |
| 1161 |
{ \cs_if_free:NF \ttl@settopmark { \ctex_titleps_hook: } } |
| 1162 |
\ctex_at_end_package:nn { titleps } { \ctex_titleps_hook: } |
| 1163 |
\ctex_at_end_package:nn { titleps } |
| 1164 |
{ |
| 1165 |
\cs_set_protected:Npn \ttl@setifthe #1 |
| 1166 |
{ |
| 1167 |
\exp_args:Nco \cs_set:Npn { ifthe #1 } |
| 1168 |
{ |
| 1169 |
\CTEXifname |
| 1170 |
{ \protect \@firstoftwo } |
| 1171 |
{ \protect \@secondoftwo } |
| 1172 |
} |
| 1173 |
} |
| 1174 |
\seq_map_function:NN \c__ctex_headings_seq \ttl@setifthe |
| 1175 |
} |
| 1176 |
\cs_new_protected:Npn \CTEX@toc@width@n #1 |
| 1177 |
{ |
| 1178 |
\hbox_set:Nn \l__ctex_tmp_box {#1} |
| 1179 |
\dim_set:Nn \@tempdima |
| 1180 |
{ |
| 1181 |
\dim_max:nn { \@tempdima } |
| 1182 |
{ \box_wd:N \l__ctex_tmp_box + \f@size \p@ / 2 } |
| 1183 |
} |
| 1184 |
} |
| 1185 |
\group_begin: |
| 1186 |
\char_set_catcode_other:N \# |
| 1187 |
\use:n |
| 1188 |
{ |
| 1189 |
\group_end: |
| 1190 |
\ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } |
| 1191 |
{ \CTEX@toc@width@n {#1} } |
| 1192 |
{ } |
| 1193 |
{ \ctex_patch_failure:N \numberline } |
| 1194 |
\cs_new_protected:Npn \__ctex_patch_toc_width:n \c_parameter_token 1 |
| 1195 |
{ |
| 1196 |
\@ifpackageloaded { \c_parameter_token 1 } |
| 1197 |
{ } |
| 1198 |
{ |
| 1199 |
\ctex_at_end_package:nn { \c_parameter_token 1 } |
| 1200 |
{ |
| 1201 |
\ctex_preto_cmd:NnnTF \numberline |
| 1202 |
{ \char_set_catcode_letter:n { 64 } } |
| 1203 |
{ \CTEX@toc@width@n {#1} } |
| 1204 |
{ } |
| 1205 |
{ \ctex_patch_failure:N \numberline } |
| 1206 |
} |
| 1207 |
} |
| 1208 |
} |
| 1209 |
} |
| 1210 |
\__ctex_patch_toc_width:n { tocloft } |
| 1211 |
\__ctex_patch_toc_width:n { titletoc } |
| 1212 |
\legacy_if:nTF { @twoside } |
| 1213 |
{ |
| 1214 |
\ctex_patch_cmd:Nnn \ps@headings |
| 1215 |
{ \ifnum \c@secnumdepth > \z@ \thesection \quad \fi } |
| 1216 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 1217 |
\ctex_patch_cmd:Nnn \ps@headings |
| 1218 |
{ \ifnum \c@secnumdepth > \@ne \thesubsection \quad \fi } |
| 1219 |
{ \CTEXifname { \CTEXthesubsection \quad } { } } |
| 1220 |
} |
| 1221 |
{ |
| 1222 |
\ctex_patch_cmd:Nnn \ps@headings |
| 1223 |
{ \ifnum \c@secnumdepth > \m@ne \thesection \quad \fi } |
| 1224 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 1225 |
} |
| 1226 |
\ctex_at_end_package:nn { fancyhdr } |
| 1227 |
{ |
| 1228 |
\ctex_patch_cmd:Nnn \f@nch@initialise |
| 1229 |
{ \ifnum \c@secnumdepth > \z@ \thesection \hskip 1em \relax \fi } |
| 1230 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 1231 |
\ctex_patch_cmd:Nnn \f@nch@initialise |
| 1232 |
{ \ifnum \c@secnumdepth > \@ne \thesubsection \hskip 1em \relax \fi } |
| 1233 |
{ \CTEXifname { \CTEXthesubsection \quad } { } } |
| 1234 |
\ctex_patch_cmd:Nnn \f@nch@initialise |
| 1235 |
{ \ifnum \c@secnumdepth > \m@ne \@chapapp\ \thechapter . ~ \ \fi } |
| 1236 |
{ \CTEXifname { \CTEXthechapter \quad } { } } |
| 1237 |
\ctex_patch_cmd:Nnn \f@nch@initialise |
| 1238 |
{ \ifnum \c@secnumdepth > \z@ \thesection . ~ \ \fi } |
| 1239 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 1240 |
\f@nch@initialise |
| 1241 |
\@ifpackagewith { fancyhdr } { headings } |
| 1242 |
{ |
| 1243 |
\legacy_if:nTF { @twoside } |
| 1244 |
{ |
| 1245 |
\ctex_patch_cmd:Nnn \ps@headings |
| 1246 |
{ \ifnum \c@secnumdepth > \z@ \thesection \quad \fi } |
| 1247 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 1248 |
\ctex_patch_cmd:Nnn \ps@headings |
| 1249 |
{ \ifnum \c@secnumdepth > \@ne \thesubsection \quad \fi } |
| 1250 |
{ \CTEXifname { \CTEXthesubsection \quad } { } } |
| 1251 |
} |
| 1252 |
{ |
| 1253 |
\ctex_patch_cmd:Nnn \ps@headings |
| 1254 |
{ \ifnum \c@secnumdepth > \z@ \thesection \quad \fi } |
| 1255 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 1256 |
} |
| 1257 |
} |
| 1258 |
{ } |
| 1259 |
} |
| 1260 |
\ctex_define:n |
| 1261 |
{ |
| 1262 |
secnumdepth .code:n = \ctex_heading_depth:ne { secnumdepth } {#1} , |
| 1263 |
secnumdepth .value_required:n = true , |
| 1264 |
tocdepth .code:n = \ctex_heading_depth:ne { tocdepth } {#1} , |
| 1265 |
tocdepth .value_required:n = true |
| 1266 |
} |
| 1267 |
\cs_new_protected:Npn \ctex_heading_depth:nn #1#2 |
| 1268 |
{ |
| 1269 |
\prop_get:NnNTF \c__ctex_heading_level_prop {#2} \l__ctex_tmp_tl |
| 1270 |
{ \setcounter {#1} { \l__ctex_tmp_tl } } |
| 1271 |
{ \setcounter {#1} { \int_eval:n {#2} } } |
| 1272 |
} |
| 1273 |
\cs_generate_variant:Nn \ctex_heading_depth:nn { ne } |
| 1274 |
\prop_const_from_keyval:Nn \c__ctex_heading_level_prop |
| 1275 |
{ |
| 1276 |
part = 0 , |
| 1277 |
section = 1 , |
| 1278 |
subsection = 2 , |
| 1279 |
subsubsection = 3 , |
| 1280 |
paragraph = 4 , |
| 1281 |
subparagraph = 5 |
| 1282 |
} |
| 1283 |
\cs_new_protected:Npn \CTEX@setcurrentlabel@n #1 |
| 1284 |
{ |
| 1285 |
\protected@edef \@currentlabel |
| 1286 |
{ |
| 1287 |
\cs_if_exist:cTF { CTEX@the#1 } |
| 1288 |
{ \exp_args:cc { p@#1 } { CTEX@the#1 } } |
| 1289 |
{ \exp_not:o { \@currentlabel } } |
| 1290 |
} |
| 1291 |
} |
| 1292 |
\cs_new_protected:Npn \ctex_varioref_hook: |
| 1293 |
{ |
| 1294 |
\seq_map_inline:Nn \c__ctex_headings_seq |
| 1295 |
{ \ctex_fix_varioref_label:n { ##1 } } |
| 1296 |
\ctex_at_end_package:nn { cleveref } { \ctex_cleveref_hook: } |
| 1297 |
} |
| 1298 |
\cs_new_protected:Npn \ctex_fix_varioref_label:n #1 |
| 1299 |
{ |
| 1300 |
\tl_if_empty:cT { p@#1 } |
| 1301 |
{ \exp_args:Nnx \labelformat {#1} { \exp_not:c { CTEX@the#1 } } } |
| 1302 |
} |
| 1303 |
\cs_new_protected:Npn \ctex_cleveref_hook: |
| 1304 |
{ |
| 1305 |
\@ifpackageloaded { hyperref } |
| 1306 |
{ |
| 1307 |
\@ifpackagewith { hyperref } { implicit = false } |
| 1308 |
{ } |
| 1309 |
{ \__ctex_cleveref_hook_aux:N \H@refstepcounter } |
| 1310 |
} |
| 1311 |
{ |
| 1312 |
\__ctex_cleveref_hook_aux:N \refstepcounter@noarg |
| 1313 |
\__ctex_cleveref_hook_aux:N \refstepcounter@optarg |
| 1314 |
} |
| 1315 |
\__ctex_cleveref_hook_aux:N \appendix |
| 1316 |
} |
| 1317 |
\cs_new_protected:Npn \__ctex_cleveref_hook_aux:N #1 |
| 1318 |
{ |
| 1319 |
\ctex_patch_cmd_all:NnnnTF #1 |
| 1320 |
{ |
| 1321 |
\ExplSyntaxOff |
| 1322 |
\char_set_catcode_letter:n { 64 } |
| 1323 |
} |
| 1324 |
{ \endcsname \csname the } |
| 1325 |
{ \expandafter \endcsname \csname the } |
| 1326 |
{ } |
| 1327 |
{ \ctex_patch_failure:N #1 } |
| 1328 |
} |
| 1329 |
\cs_if_exist:NTF \labelformat |
| 1330 |
{ \ctex_varioref_hook: } |
| 1331 |
{ |
| 1332 |
\cs_new_eq:NN \CTEX@save@refstepcounter \refstepcounter |
| 1333 |
\RenewDocumentCommand \refstepcounter { m } |
| 1334 |
{ |
| 1335 |
\CTEX@save@refstepcounter {#1} |
| 1336 |
\CTEX@setcurrentlabel@n {#1} |
| 1337 |
} |
| 1338 |
\ctex_at_end_package:nn { varioref } { \ctex_varioref_hook: } |
| 1339 |
} |
| 1340 |
\ctex_scheme_input:o { \l__ctex_scheme_tl } |
| 1341 |
\NewDocumentCommand \zihao { m } |
| 1342 |
{ \exp_args:Nx \ctex_zihao:n {#1} \tex_ignorespaces:D } |
| 1343 |
\cs_new_protected:Npn \ctex_zihao:n #1 |
| 1344 |
{ |
| 1345 |
\prop_get:NnNTF \c__ctex_font_size_prop {#1} \l__ctex_font_size_tl |
| 1346 |
{ \exp_after:wN \fontsize \l__ctex_font_size_tl \selectfont } |
| 1347 |
{ \msg_error:nnn { ctex } { fontsize } {#1} } |
| 1348 |
} |
| 1349 |
\msg_new:nnnn { ctex } { fontsize } |
| 1350 |
{ Undefined~Chinese~font~size~`#1'~in~command~\token_to_str:N \zihao.} |
| 1351 |
{ |
| 1352 |
The~old~font~size~is~used~if~you~continue.\\ |
| 1353 |
The~available~font~sizes~are~listed~as~follow.\\ |
| 1354 |
\seq_use:Nnnn \c__ctex_font_size_seq { ~and~ } { ,~ } { ,~and~ }. |
| 1355 |
} |
| 1356 |
\prop_new:N \c__ctex_font_size_prop |
| 1357 |
\seq_new:N \c__ctex_font_size_seq |
| 1358 |
\cs_new_protected:Npn \__ctex_save_font_size:nn #1#2 |
| 1359 |
{ |
| 1360 |
\use:e |
| 1361 |
{ |
| 1362 |
\prop_gput:Nnn \exp_not:N \c__ctex_font_size_prop {#1} |
| 1363 |
{ |
| 1364 |
{ \dim_to_decimal:n {#2} } |
| 1365 |
{ \dim_to_decimal:n { (#2) * 6 / 5 } } |
| 1366 |
} |
| 1367 |
} |
| 1368 |
\seq_gput_right:Nn \c__ctex_font_size_seq {#1} |
| 1369 |
} |
| 1370 |
\clist_map_inline:nn |
| 1371 |
{ |
| 1372 |
{ 8 } { 5 bp } , |
| 1373 |
{ 7 } { 5.5 bp } , |
| 1374 |
{ -6 } { 6.5 bp } , |
| 1375 |
{ 6 } { 7.5 bp } , |
| 1376 |
{ -5 } { 9 bp } , |
| 1377 |
{ 5 } { 10.5 bp } , |
| 1378 |
{ -4 } { 12 bp } , |
| 1379 |
{ 4 } { 14 bp } , |
| 1380 |
{ -3 } { 15 bp } , |
| 1381 |
{ 3 } { 16 bp } , |
| 1382 |
{ -2 } { 18 bp } , |
| 1383 |
{ 2 } { 22 bp } , |
| 1384 |
{ -1 } { 24 bp } , |
| 1385 |
{ 1 } { 26 bp } , |
| 1386 |
{ -0 } { 36 bp } , |
| 1387 |
{ 0 } { 42 bp } |
| 1388 |
} |
| 1389 |
{ \__ctex_save_font_size:nn #1 } |
| 1390 |
\cs_new_protected:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4 |
| 1391 |
{ |
| 1392 |
\__ctex_get_font_sizes:Nn \l__ctex_font_size_tl { {#1} {#2} {#3} {#4} } |
| 1393 |
\exp_after:wN \DeclareMathSizes \l__ctex_font_size_tl |
| 1394 |
} |
| 1395 |
\cs_new_protected:Npn \__ctex_get_font_sizes:Nn #1#2 |
| 1396 |
{ |
| 1397 |
\tl_clear:N #1 |
| 1398 |
\tl_map_inline:nn {#2} |
| 1399 |
{ |
| 1400 |
\prop_get:NnNTF \c__ctex_font_size_prop {##1} \l__ctex_tmp_tl |
| 1401 |
{ \tl_put_right:Nx #1 { { \tl_head:N \l__ctex_tmp_tl } } } |
| 1402 |
{ \tl_put_right:Nx #1 { { \dim_to_decimal:n { ##1 } } } } |
| 1403 |
} |
| 1404 |
} |
| 1405 |
\clist_map_inline:nn |
| 1406 |
{ |
| 1407 |
{ 8 }{ 8 }{ 5pt }{ 5pt } , |
| 1408 |
{ 7 }{ 7 }{ 5pt }{ 5pt } , |
| 1409 |
{ -6 }{ -6 }{ 5pt }{ 5pt } , |
| 1410 |
{ 6 }{ 6 }{ 5pt }{ 5pt } , |
| 1411 |
{ -5 }{ -5 }{ 6pt }{ 5pt } , |
| 1412 |
{ 5 }{ 5 }{ 7pt }{ 5pt } , |
| 1413 |
{ -4 }{ -4 }{ 8pt }{ 6pt } , |
| 1414 |
{ 4 }{ 4 }{ 5 }{ 6 } , |
| 1415 |
{ -3 }{ -3 }{ -4 }{ -5 } , |
| 1416 |
{ 3 }{ 3 }{ 4 }{ 5 } , |
| 1417 |
{ -2 }{ -2 }{ -3 }{ -4 } , |
| 1418 |
{ 2 }{ 2 }{ 3 }{ 4 } , |
| 1419 |
{ -1 }{ -1 }{ -2 }{ -3 } , |
| 1420 |
{ 1 }{ 1 }{ 2 }{ 3 } , |
| 1421 |
{ -0 }{ -0 }{ -1 }{ -2 } , |
| 1422 |
{ 0 }{ 0 }{ 1 }{ 2 } |
| 1423 |
} |
| 1424 |
{ \ctex_declare_math_sizes:nnnn #1 } |
| 1425 |
\cs_new_protected:Npn \ctex_set_font_size:Nnn #1#2#3 |
| 1426 |
{ |
| 1427 |
\prop_get:NnNTF \c__ctex_font_size_prop {#2} \l__ctex_font_size_tl |
| 1428 |
{ \exp_after:wN \__ctex_set_font_size:nnNn \l__ctex_font_size_tl #1 {#3} } |
| 1429 |
{ \msg_error:nnn { ctex } { fontsize } {#2} } |
| 1430 |
} |
| 1431 |
\cs_new_protected:Npn \__ctex_set_font_size:nnNn #1#2#3#4 |
| 1432 |
{ \cs_set_protected:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } } |
| 1433 |
\int_case:nn { \g__ctex_font_size_int } |
| 1434 |
{ |
| 1435 |
{ 0 } { \file_input:n { ctex-c5size.clo } } |
| 1436 |
{ 1 } { \file_input:n { ctex-cs4size.clo } } |
| 1437 |
} |
| 1438 |
\fp_if_nan:nF { \l__ctex_line_spread_fp } |
| 1439 |
{ |
| 1440 |
\exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp } |
| 1441 |
\group_begin: \footnotesize \exp_args:NNNo \group_end: |
| 1442 |
\dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox } |
| 1443 |
} |
| 1444 |
\normalsize |
| 1445 |
\NewDocumentCommand \CTeX { } |
| 1446 |
{ C \TeX } |
| 1447 |
\ctex_at_end_package:nn { hyperref } |
| 1448 |
{ \pdfstringdefDisableCommands { \tl_set:Nn \CTeX { CTeX } } } |
| 1449 |
\ctex_define:n |
| 1450 |
{ |
| 1451 |
captiondelimiter .code:n = |
| 1452 |
{ |
| 1453 |
\ctex_deprecated_option:n |
| 1454 |
{ You~can~load~the~package~`caption'~to~get~its~functionality. } |
| 1455 |
} |
| 1456 |
} |
| 1457 |
\cs_new_protected:Npn \ctex_fontset_error:n #1 |
| 1458 |
{ \msg_critical:nnn { ctex } { fontset-unavailable } {#1} } |
| 1459 |
\msg_new:nnn { ctex } { fontset-unavailable } |
| 1460 |
{ CTeX~fontset~`#1'~is~unavailable~in~current~mode. } |
| 1461 |
\cs_new:Npx \ctex_fontset_case:nnn #1#2#3 |
| 1462 |
{ |
| 1463 |
\sys_if_engine_pdftex:TF |
| 1464 |
{#1} |
| 1465 |
{ \sys_if_engine_uptex:TF {#2} {#3} } |
| 1466 |
} |
| 1467 |
\cs_new:Npx \ctex_fontset_case:nnnn #1#2#3#4 |
| 1468 |
{ |
| 1469 |
\sys_if_engine_pdftex:TF |
| 1470 |
{ \sys_if_output_pdf:TF {#1} {#2} } |
| 1471 |
{ \sys_if_engine_uptex:TF {#3} {#4} } |
| 1472 |
} |
| 1473 |
\cs_new_protected:Npn \ctex_detect_platform: |
| 1474 |
{ |
| 1475 |
\sys_if_platform_windows:TF |
| 1476 |
{ \tl_gset:Nn \g__ctex_fontset_tl { windows } } |
| 1477 |
{ |
| 1478 |
\ctex_if_platform_macos:TF |
| 1479 |
{ \tl_gset:Nn \g__ctex_fontset_tl { mac } } |
| 1480 |
{ \tl_gset:Nn \g__ctex_fontset_tl { fandol } } |
| 1481 |
} |
| 1482 |
} |
| 1483 |
\cs_new_protected:Npn \ctex_if_platform_macos:TF |
| 1484 |
{ \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } } |
| 1485 |
\cs_new_protected:Npn \ctex_load_fontset: |
| 1486 |
{ |
| 1487 |
\tl_if_empty:NTF \g__ctex_fontset_tl |
| 1488 |
{ \ctex_detect_platform: } |
| 1489 |
{ |
| 1490 |
\bool_lazy_or:nnTF |
| 1491 |
{ \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsnew } } |
| 1492 |
{ \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsold } } |
| 1493 |
{ |
| 1494 |
\msg_warning:nnxx { ctex } { deprecated-fontset } |
| 1495 |
{ \g__ctex_fontset_tl } { windows } |
| 1496 |
\tl_gset:Nn \g__ctex_fontset_tl { windows } |
| 1497 |
} |
| 1498 |
{ |
| 1499 |
\file_if_exist:nF { ctex-fontset- \g__ctex_fontset_tl .def } |
| 1500 |
{ |
| 1501 |
\use:e |
| 1502 |
{ |
| 1503 |
\ctex_detect_platform: |
| 1504 |
\msg_error:nnxx { ctex } { fontset-not-found } |
| 1505 |
{ \g__ctex_fontset_tl } { \exp_not:N \g__ctex_fontset_tl } |
| 1506 |
} |
| 1507 |
} |
| 1508 |
} |
| 1509 |
} |
| 1510 |
\ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def } |
| 1511 |
} |
| 1512 |
\msg_new:nnn { ctex } { deprecated-fontset } |
| 1513 |
{ CTeX~fontset~`#1'~is~deprecated.\\ Fontset~`#2'~will~be~used~instead. } |
| 1514 |
\msg_new:nnnn { ctex } { fontset-not-found } |
| 1515 |
{ CTeX~fontset~`#1'~could~not~be~found.\\ Fontset~`#2'~will~be~used~instead. } |
| 1516 |
{ You~may~run~`mktexlsr'~firstly. } |
| 1517 |
\@onlypreamble \ctex_load_fontset: |
| 1518 |
\ctex_define:n |
| 1519 |
{ |
| 1520 |
fontset .code:n = |
| 1521 |
{ |
| 1522 |
\ctex_if_preamble:TF |
| 1523 |
{ |
| 1524 |
\str_if_eq:eeTF {#1} { none } |
| 1525 |
{ \msg_warning:nnn { ctex } { invalid-value } {#1} } |
| 1526 |
{ |
| 1527 |
\str_if_eq:onTF { \g__ctex_fontset_tl } { none } |
| 1528 |
{ |
| 1529 |
\tl_gset:Nx \g__ctex_fontset_tl {#1} |
| 1530 |
\ctex_load_fontset: |
| 1531 |
} |
| 1532 |
{ |
| 1533 |
\msg_error:nnxx { ctex } { fontset-loaded } |
| 1534 |
{ \g__ctex_fontset_tl } {#1} |
| 1535 |
} |
| 1536 |
} |
| 1537 |
} |
| 1538 |
{ \msg_error:nn { ctex } { fontset-only-preamble } } |
| 1539 |
} |
| 1540 |
} |
| 1541 |
\msg_new:nnnn { ctex } { fontset-loaded } |
| 1542 |
{ |
| 1543 |
CTeX~fontset~`#1'~has~been~loaded. |
| 1544 |
\str_if_eq:nnF {#1} {#2} { \\ Fontset~`#2'~will~be~ignored. } |
| 1545 |
} |
| 1546 |
{ Only~one~fontset~can~be~loaded~in~the~preamble. } |
| 1547 |
\msg_new:nnn { ctex } { fontset-only-preamble } |
| 1548 |
{ The~`fontset'~option~can~be~used~only~in~preamble. } |
| 1549 |
\str_if_eq:onF { \g__ctex_fontset_tl } { none } |
| 1550 |
{ \ctex_load_fontset: } |
| 1551 |
\ctex_at_end:n { \ctex_file_input:n { ctex.cfg } } |
| 1552 |
%% |
| 1553 |
%% This package consists of the files ctex.dtx, |
| 1554 |
%% ctxdoc.cls, |
| 1555 |
%% ctxdocstrip.tex, |
| 1556 |
%% ctex-zhconv.lua, |
| 1557 |
%% ctex-zhconv-make.lua, |
| 1558 |
%% and the derived files ctex.pdf, |
| 1559 |
%% ctex.ins, |
| 1560 |
%% ctex.sty, |
| 1561 |
%% ctexsize.sty, |
| 1562 |
%% ctexheading.sty, |
| 1563 |
%% ctexart.cls, |
| 1564 |
%% ctexbook.cls, |
| 1565 |
%% ctexrep.cls, |
| 1566 |
%% ctexbeamer.cls, |
| 1567 |
%% ctexcap.sty, |
| 1568 |
%% ctexhook.sty, |
| 1569 |
%% ctexpatch.sty, |
| 1570 |
%% ctex-c5size.clo, |
| 1571 |
%% ctex-cs4size.clo, |
| 1572 |
%% ctex-heading-article.def, |
| 1573 |
%% ctex-heading-book.def, |
| 1574 |
%% ctex-heading-report.def, |
| 1575 |
%% ctex-heading-beamer.def, |
| 1576 |
%% ctex-scheme-plain.def, |
| 1577 |
%% ctex-scheme-plain-article.def, |
| 1578 |
%% ctex-scheme-plain-book.def, |
| 1579 |
%% ctex-scheme-plain-report.def, |
| 1580 |
%% ctex-scheme-plain-beamer.def, |
| 1581 |
%% ctex-scheme-chinese.def, |
| 1582 |
%% ctex-scheme-chinese-article.def, |
| 1583 |
%% ctex-scheme-chinese-book.def, |
| 1584 |
%% ctex-scheme-chinese-report.def, |
| 1585 |
%% ctex-scheme-chinese-beamer.def, |
| 1586 |
%% ctex-name-gbk.cfg, |
| 1587 |
%% ctex-name-utf8.cfg, |
| 1588 |
%% ctex.cfg, |
| 1589 |
%% ctexopts.cfg, |
| 1590 |
%% ctexbackend.cfg, |
| 1591 |
%% ctex-engine-pdftex.def, |
| 1592 |
%% ctex-engine-xetex.def, |
| 1593 |
%% ctex-engine-luatex.def, |
| 1594 |
%% ctex-engine-aptex.def, |
| 1595 |
%% ctex-engine-uptex.def, |
| 1596 |
%% c19rm.fd, |
| 1597 |
%% c19sf.fd, |
| 1598 |
%% c19tt.fd, |
| 1599 |
%% c70rm.fd, |
| 1600 |
%% c70sf.fd, |
| 1601 |
%% c70tt.fd, |
| 1602 |
%% jy2zhrm.fd, |
| 1603 |
%% jy2zhsf.fd, |
| 1604 |
%% jy2zhtt.fd, |
| 1605 |
%% jt2zhrm.fd, |
| 1606 |
%% jt2zhsf.fd, |
| 1607 |
%% jt2zhtt.fd, |
| 1608 |
%% ctex-fontset-adobe.def, |
| 1609 |
%% ctex-fontset-fandol.def, |
| 1610 |
%% ctex-fontset-founder.def, |
| 1611 |
%% ctex-fontset-mac.def, |
| 1612 |
%% ctex-fontset-macnew.def, |
| 1613 |
%% ctex-fontset-macold.def, |
| 1614 |
%% ctex-fontset-ubuntu.def, |
| 1615 |
%% ctex-fontset-windows.def, |
| 1616 |
%% ctexspa.def, |
| 1617 |
%% ctexpunct.spa, |
| 1618 |
%% ctex-spa-make.tex, |
| 1619 |
%% ctex-spa-macro.tex, |
| 1620 |
%% ctex-zhmap-adobe.tex, |
| 1621 |
%% ctex-zhmap-fandol.tex, |
| 1622 |
%% ctex-zhmap-founder.tex, |
| 1623 |
%% ctex-zhmap-mac.tex, |
| 1624 |
%% ctex-zhmap-ubuntu.tex, |
| 1625 |
%% ctex-zhmap-windows.tex, |
| 1626 |
%% ctex-zhconv-index.lua, |
| 1627 |
%% translator-theorem-dictionary-ChineseGBK.dict, |
| 1628 |
%% translator-theorem-dictionary-ChineseUTF8.dict, and |
| 1629 |
%% README.md. |
| 1630 |
%% |
| 1631 |
%% End of file `ctexart.cls'. |