diff options
author | Karl Berry <karl@freefriends.org> | 2015-06-30 21:26:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-06-30 21:26:14 +0000 |
commit | aaec8ff3cf7236ae9429a6d9238b1838af2441d6 (patch) | |
tree | 7d00cf0ec8459200ac8e721eed28d09e155012c9 /Master/texmf-dist/tex/latex/ctex/ctexrep.cls | |
parent | 56e4ae7a5ecbbf9bf7b858d20cb0c3e0d21edc8a (diff) |
ctex (30jun15)
git-svn-id: svn://tug.org/texlive/trunk@37720 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ctex/ctexrep.cls')
-rw-r--r-- | Master/texmf-dist/tex/latex/ctex/ctexrep.cls | 521 |
1 files changed, 287 insertions, 234 deletions
diff --git a/Master/texmf-dist/tex/latex/ctex/ctexrep.cls b/Master/texmf-dist/tex/latex/ctex/ctexrep.cls index 0f7dfdeff5a..c9f8798891e 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexrep.cls +++ b/Master/texmf-dist/tex/latex/ctex/ctexrep.cls @@ -28,10 +28,10 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese adapter for class report (CTEX)} \ProvidesExplClass{ctexrep} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \tl_const:Nx \c__ctex_version_tl { \cs_if_exist_use:cF { ver@ \@currname . \@currext } { 9999/99/99 } } \cs_new_eq:cN { ver@ctex. \@pkgextension } \c__ctex_version_tl @@ -50,35 +50,12 @@ { \msg_error:nnn { ctex } { l3-too-old } { expl3 } } \@ifpackagelater { l3keys2e } { 2014/05/05 } { } { \msg_error:nnn { ctex } { l3-too-old } { l3keys2e } } -\RequirePackage { etoolbox } +\RequirePackage { ctexhook , ctexpatch } \RequirePackage { fix-cm , everysel } \tl_new:N \l__ctex_tmp_tl \int_new:N \l__ctex_tmp_int \dim_new:N \l__ctex_tmp_dim \box_new:N \l__ctex_tmp_box -\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 - { - \@ifpackageloaded {#1} - {#2} - { \ctex_gadd_hook:cn { g__ctex_at_end_ #1 _hook_tl } {#2} } - } -\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 - { - \tl_if_exist:NF #1 { \tl_new:N #1 } - \tl_gput_right:Nn #1 {#2} - } -\cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } -\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 - { - \cs_if_exist_use:cT { g__ctex_at_end_ #1 _hook_tl } - { \cs_undefine:c { g__ctex_at_end_ #1 _hook_tl } } - } -\cs_generate_variant:Nn \ctex_package_end_hook:n { o } -\tl_put_left:Nn \@popfilename - { - \cs_if_eq:NNT \@currext \@pkgextension - { \ctex_package_end_hook:o { \@currname } } - } \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3 { \use:x @@ -111,90 +88,6 @@ { } } \cs_generate_variant:Nn \ctex_scheme_input:n { o } -\cs_new_protected:Npn \ctex_parse_name:NN #1#2 - { \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } -\group_begin: -\char_set_lccode:nn { `\< } { `\{ } -\char_set_lccode:nn { `\/ } { `\\ } -\char_set_lccode:nn { `\A } { `\t } -\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N -\tex_lowercase:D - { - \group_end: - \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3 - { - \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } } - { - \group_begin: - \use:x - { - \group_end: - \__ctex_parse_name:nNNNnN { \token_get_replacement_spec:N #2 } - \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 } - } {#3} #1 - } - { #1#2 } - } - \cs_new_protected:Npn \__ctex_parse_name:nNNNnN #1#2#3#4#5#6 - { - \exp_args:Nc #6 - { - \str_case:nnTF {#1} - { - { \protect #3 } { } - { \x@protect #2 \protect #3 } { } - } - { - \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } } - { - \exp_last_unbraced:Nf \__ctex_parse_name:w - \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop - } - { /#5 ~ } { #5 ~ } - } - { - \str_case:onTF { \__ctex_parse_name:w #1 AESAOPA ~ < \q_stop } - { - { /@protected@ #2 #4 } { } - { /@ #4 } { } - } - { /#5 } {#5} - } - } - } - \cs_new:Npn \__ctex_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 } - } -\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } -\cs_new_protected_nopar:Npn \ctex_patch_cmd:NnnTF { \ctex_parse_name:NN \patchcmd } -\cs_new_protected_nopar:Npn \ctex_preto_cmd:NnTF { \ctex_parse_name:NN \pretocmd } -\cs_new_protected_nopar:Npn \ctex_appto_cmd:NnTF { \ctex_parse_name:NN \apptocmd } -\cs_new_protected:Npn \ctex_patch_cmd:Nnn - { - \group_begin: - \char_set_catcode_other:N \# - \__ctex_patch_cmd:Nnn - } -\cs_new_protected:Npn \__ctex_patch_cmd:Nnn #1#2#3 - { - \group_end: - \group_begin: - \ExplSyntaxOff - \ctex_patch_cmd:NnnTF #1 {#2} {#3} - { - \cs_gset_eq:NN \__ctex_tmp:w #1 - \group_end: - \cs_set_eq:NN #1 \__ctex_tmp:w - \cs_undefine:N \__ctex_tmp:w - } - { \group_end: \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \ctex_patch_failure:N #1 - { \msg_warning:nnx { ctex } { patch-failure } { \token_to_str:N #1 } } -\msg_new:nnn { ctex } { patch-failure } - { - Patching~command~`#1'~failed.\\ - ctex~may~not~work~as~expected. - } \cs_new_eq:NN \g__ctex_section_depth_flag \c_two \msg_new:nnnn { ctex } { package-too-old } { Support~package~`#1'~too~old. } @@ -217,7 +110,7 @@ \cs_new_eq:NN \ctex_if_pdfmode:TF \use_ii:nn } \cs_new_eq:NN \ctex_if_preamble:TF \use_i:nn -\AfterEndPreamble { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } +\ctex_after_end_preamble:n { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } \cs_new:Npn \ctex_set_default_ccwd:Nn #1#2 { \dim_compare:nNnTF @@ -303,8 +196,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options.~ } } , @@ -313,8 +206,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options. } } , @@ -446,7 +339,7 @@ \cs_if_exist:NF \hypersetup { \cs_new_eq:NN \hypersetup \ctex_hypersetup:n } } - \AtEndPreamble { \RequirePackage { hyperref } } + \ctex_at_end_preamble:n { \RequirePackage { hyperref } } } , } \tl_clear:N \l__ctex_tmp_tl @@ -658,6 +551,14 @@ \cs_new_eq:NN \chinese \zhnum \cs_new_eq:NN \Chinese \chinese \cs_new_eq:NN \CTEXcounter \use_none:n +\ctex_at_end_package:nn { enumitem } + { + \cs_if_free:NF \AddEnumerateCounter + { + \AddEnumerateCounter * { \zhnum } { \zhnum_int:n } { 1 } + \AddEnumerateCounter * { \chinese } { \zhnum_int:n } { 1 } + } + } \NewDocumentCommand \CTEXnumber { m m } { \protected@edef #1 { \zhnumber {#2} } } \NewDocumentCommand \CTEXdigits { m m } @@ -696,12 +597,14 @@ appendixname .tl_set:N = \appendixname , bibname .tl_set:N = \bibname } + +\seq_new:N \c__ctex_section_headings_seq +\seq_gset_from_clist:Nn \c__ctex_section_headings_seq + { section , subsection , subsubsection , paragraph , subparagraph } \seq_new:N \c__ctex_headings_seq -\seq_gset_from_clist:Nn \c__ctex_headings_seq - { - part , chapter , section , subsection , subsubsection , - paragraph , subparagraph - } +\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq +\seq_gput_left:Nn \c__ctex_headings_seq { chapter } +\seq_gput_left:Nn \c__ctex_headings_seq { part } \cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1 { \tl_new:c { CTEX@pre#1 } @@ -734,49 +637,53 @@ { \tl_put_right:Nx \l__ctex_tmp_tl { - #1 .meta:nn = { ctex / #1 } { ####1 } , - #1 / name .code:n = + #1 .meta:nn = { ctex / #1 } { ####1 } , + #1 / name .code:n = { \ctex_assign_heading_name:nn {#1} { ####1 } } , - #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , - #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , - #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , - #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , - #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , - #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , - #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , - #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , - #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , - #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , - #1 / format+ .code:n = + #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , + #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , + #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , + #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , + #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , + #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , + #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , + #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , + #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , + #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , + #1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , + #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , + #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , + #1 / format+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / format~+ .code:n = + #1 / format~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / nameformat+ .code:n = + #1 / nameformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / nameformat~+ .code:n = + #1 / nameformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / numberformat+ .code:n = + #1 / numberformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / numberformat~+ .code:n = + #1 / numberformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / aftername+ .code:n = + #1 / aftername+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / aftername~+ .code:n = + #1 / aftername~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / titleformat+ .code:n = + #1 / titleformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / titleformat~+ .code:n = + #1 / titleformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / aftertitle+ .code:n = + #1 / aftertitle+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / aftertitle~+ .code:n = + #1 / aftertitle~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / beforeskip .initial:n = \c_zero_skip , - #1 / afterskip .initial:n = \c_zero_skip , - #1 / indent .initial:n = \c_zero_dim , - #1 / beforeskip .value_required: , - #1 / afterskip .value_required: , - #1 / indent .value_required: , + #1 / numbering .initial:n = true , + #1 / beforeskip .initial:n = \c_zero_skip , + #1 / afterskip .initial:n = \c_zero_skip , + #1 / indent .initial:n = \c_zero_dim , + #1 / beforeskip .value_required: , + #1 / afterskip .value_required: , + #1 / indent .value_required: , } } \NewDocumentCommand \ctex_assign_heading_name:nn @@ -801,20 +708,42 @@ } \use:x { \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } } } \tl_clear:N \l__ctex_tmp_tl -\def\@part[#1]#2{% +\cs_new_protected_nopar:Npn \CTEX@makeheadinganchor { } +\ctex_at_end_package:nn { hyperref } + { \cs_gset_protected_nopar:Npn \CTEX@makeheadinganchor { \phantomsection } } +\renewcommand\part{% + \if@openright + \cleardoublepage + \else + \clearpage + \fi \thispagestyle{\CTEX@part@pagestyle}% + \if@twocolumn + \onecolumn + \@tempswatrue + \else + \@tempswafalse + \fi + \null\vskip \glueexpr \CTEX@part@beforeskip \relax + \secdef\@part\@spart} +\def\@part[#1]#2{% \ifnum \c@secnumdepth >-2\relax - \refstepcounter{part}% - \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \ifodd \CTEX@part@numbering + \refstepcounter{part}% + \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{part}{#1}% + \fi \else \addcontentsline{toc}{part}{#1}% \fi \markboth{}{}% {\interlinepenalty \@M \normalfont \CTEX@part@format - \ifnum \c@secnumdepth >-2\relax + \ifnum \c@secnumdepth >-2\relax \ifodd \CTEX@part@numbering \CTEX@partname - \fi + \fi \fi \CTEX@part@titleformat{#2}% \CTEX@part@aftertitle}% \@endpart} @@ -824,12 +753,39 @@ \CTEX@part@titleformat{#1}% \CTEX@part@aftertitle}% \@endpart} +\def\@endpart{% + \vskip \glueexpr \CTEX@part@afterskip \relax + \newpage + \if@twoside + \if@openright + \null + \thispagestyle{empty}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi} +\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi + \thispagestyle{\CTEX@chapter@pagestyle}% + \global\@topnum\z@ + \ifodd \CTEX@chapter@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \secdef\@chapter\@schapter} \def\@chapter[#1]#2{% \ifnum \c@secnumdepth >\m@ne - \refstepcounter{chapter}% - \typeout{\CTEXthechapter}% - \addcontentsline{toc}{chapter} - {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \ifodd \CTEX@chapter@numbering + \refstepcounter{chapter}% + \typeout{\CTEXthechapter}% + \addcontentsline{toc}{chapter} + {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{chapter}{#1}% + \fi \else \addcontentsline{toc}{chapter}{#1}% \fi @@ -843,40 +799,47 @@ \@afterheading \fi} \def\@makechapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \ifnum \c@secnumdepth >\m@ne - \CTEX@chaptername + \ifodd \CTEX@chapter@numbering + \CTEX@chaptername + \fi \fi \interlinepenalty\@M \CTEX@chapter@titleformat{#1}% \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} \def\@makeschapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \interlinepenalty\@M \CTEX@chapter@titleformat{#1} \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par + \CTEX@update@sectionformat@n{#1}% + \ifodd \CTEX@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty\addvspace{\glueexpr #4\relax}% + \fi + \@ifstar + {\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} \def\@seccntformat#1{% \@ifundefined{CTEX@#1name}% {\csname the#1\endcsname\quad}% @@ -885,14 +848,18 @@ \ifnum #2>\c@secnumdepth \let\@svsec\@empty \else - \refstepcounter{#1}% - \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \ifodd \csname CTEX@#1@numbering\endcsname + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \else + \CTEX@makeheadinganchor + \let\@svsec\@empty + \fi \fi - \@tempskipa #5\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #6{% - \@hangfrom{\hskip #3\relax\@svsec}% + \@hangfrom{\hskip\glueexpr #3\relax\@svsec}% \interlinepenalty \@M \csname CTEX@#1@titleformat\endcsname{#8}% \csname CTEX@#1@aftertitle\endcsname}% @@ -900,51 +867,80 @@ \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}% \else \def\@svsechd{% - #6{\hskip #3\relax + #6{\hskip\glueexpr #3\relax \@svsec \csname CTEX@#1@titleformat\endcsname{#8}% \csname CTEX@#1@aftertitle\endcsname}% \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}}% \fi \@xsect{#5}} \def\@ssect#1#2#3#4#5{% - \@tempskipa #3\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #4{% - \@hangfrom{\hskip #1}% + \@hangfrom{\hskip\glueexpr #1\relax}% \interlinepenalty \@M \CTEX@titleformat@n{#5}% \CTEX@aftertitle}% \endgroup \else - \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% + \def\@svsechd{#4{\hskip\glueexpr #1\relax + \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% \fi \@xsect{#3}} -\cs_new_protected_nopar:Npn \CTEX@set@titleformat@n #1 +\def\@xsect#1{% + \unless \ifodd \CTEX@runin + \par \nobreak + \vskip\glueexpr #1\relax + \@afterheading + \else + \@nobreakfalse + \global\@noskipsectrue + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + {\setbox\z@\lastbox}% + \clubpenalty\@M + \begingroup \@svsechd \endgroup + \unskip + \hskip\glueexpr #1\relax + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}% + \fi + \ignorespaces} +\cs_new_protected_nopar:Npn \CTEX@update@sectionformat@n #1 { \cs_set_eq:Nc \CTEX@titleformat@n { CTEX@#1@titleformat } \cs_set_eq:Nc \CTEX@aftertitle { CTEX@#1@aftertitle } + \cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } + \cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } } \cs_new_eq:NN \CTEX@titleformat@n \use:n \cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: +\cs_new_eq:NN \CTEX@afterindent \c_true_bool +\cs_new_eq:NN \CTEX@runin \c_false_bool \int_zero:N \l__ctex_tmp_int -\clist_map_inline:nn - { section , subsection , subsubsection , paragraph , subparagraph } +\seq_map_inline:Nn \c__ctex_section_headings_seq { \int_incr:N \l__ctex_tmp_int \cs_gset_protected_nopar:cpx {#1} @@ -954,18 +950,17 @@ { \exp_not:c { CTEX@#1@indent } } { \exp_not:c { CTEX@#1@beforeskip } } { \exp_not:c { CTEX@#1@afterskip } } - { - \CTEX@set@titleformat@n {#1} - \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } - } + { \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } } } \keys_define:nn { ctex } { - appendix .meta:nn = { ctex / appendix } {#1} , - appendix / name .code:n = + appendix .meta:nn = { ctex / appendix } {#1} , + appendix / name .code:n = { \ctex_assign_heading_name:nn { appendix } {#1} } , - appendix / number .tl_set:N = \CTEX@appendixnumber + appendix / number .tl_set:N = \CTEX@appendix@number , + appendix / numbering .bool_set:N = \CTEX@appendix@numbering , + appendix / numbering .initial:n = true } \tl_new:N \CTEX@preappendix \tl_new:N \CTEX@postappendix @@ -974,8 +969,76 @@ { \CTEX@save@appendix \gdef \CTEX@prechapter { \CTEX@preappendix } - \gdef \CTEX@thechapter { \CTEX@appendixnumber } + \gdef \CTEX@thechapter { \CTEX@appendix@number } \gdef \CTEX@postchapter { \CTEX@postappendix } + \gdef \CTEX@chapter@numbering { \CTEX@appendix@numbering } + } +\cs_new_protected_nopar:Npn \ctex_titlesec_hook: + { + \@ifpackagewith { titlesec } { explicit } + { + \cs_set_eq:NN \__ctex_titlesec_format:Nn + \__ctex_titlesec_format_explicit:Nn + } + { } + \clist_map_inline:nn + { indentafter , noindentafter , indentfirst , nonindentfirst } + { + \@ifpackagewith { titlesec } { ##1 } + { + \clist_map_break:n + { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n } + } + { } + } + \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1 + { + \__ctex_titlesec_format:n {#1} + \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1} + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1 + { + \cs_if_free:cF { ttlf@#1 } + { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2 + { + \tl_set:Nx #1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \tl_tail:N #1 + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2 + { + \cs_set_nopar:Npx #1 ##1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \exp_args:No \tl_tail:n { #1 { } } + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2 + { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } } +\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6 + { + \exp_not:n { {#1} {#2} {#3} {#4} } + { \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } + } +\@ifpackageloaded { titlesec } + { } + { + \ctex_at_end_package:nn { titlesec } + { + \@ifpackagewith { titlesec } { loadonly } + { } + { \ctex_titlesec_hook: } + } } \cs_new_protected:Npn \CTEX@toc@width@n #1 { @@ -991,31 +1054,39 @@ \use:n { \group_end: - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } \@ifpackageloaded { tocloft } { } { \ctex_at_end_package:nn { tocloft } { - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline + { \char_set_catcode_letter:n { 64 } } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } } } - \ExplSyntaxOn } \ctex_patch_cmd:Nnn \ps@headings - { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } + { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \if@twoside - \ctex_patch_cmd:Nnn \ps@headings { \thesection.~\ } { \CTEXthesection \quad } + \ctex_patch_cmd:Nnn \ps@headings + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \fi: \ctex_at_end_package:nn { fancyhdr } { \ctex_patch_cmd:Nnn \ps@fancy - { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } + { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \ctex_patch_cmd:Nnn \ps@fancy - { \thesection.~\ } { \CTEXthesection \quad } + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } } \cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 { @@ -1147,7 +1218,7 @@ \fi: \fp_compare:nNnF { \l__ctex_line_spread_fp } ? { \c_zero_fp } { - \linespread { \fp_use:N \l__ctex_line_spread_fp } + \exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp } \group_begin: \footnotesize \exp_args:NNNo \group_end: \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox } } @@ -1164,26 +1235,6 @@ { You~can~load~the~package~`caption'~to~get~its~functionality. } } } -\group_begin: -\char_set_catcode_other:N \# -\use:n - { - \group_end: - \ExplSyntaxOff - \ctex_at_end_package:nn { breqn } - { - \ctex_patch_cmd:NnnTF \end { \csname end#1 \endcsname } - { - \csuse { @end@#1@hook } - \csname end#1 \endcsname - } { } - { - \ctex_preto_cmd:NnTF \end { \csuse { @end@#1@hook } } - { } { \ctex_patch_failure:N \end } - } - } - \ExplSyntaxOn - } \cs_new_protected_nopar:Npn \ctex_fontset_error:n #1 { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} } \msg_new:nnn { ctex } { fontset-unavailable } @@ -1257,12 +1308,14 @@ %% and the derived files ctex.pdf, %% ctex.ins, %% ctex.sty, -%% ctexcap.sty, %% ctexsize.sty, %% ctexheading.sty, %% ctexart.cls, %% ctexbook.cls, %% ctexrep.cls, +%% ctexcap.sty, +%% ctexhook.sty, +%% ctexpatch.sty, %% ctex-c5size.clo, %% ctex-cs4size.clo, %% ctex-article.def, |