diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/ctex/ctexart.cls')
-rw-r--r-- | Master/texmf-dist/tex/latex/ctex/ctexart.cls | 148 |
1 files changed, 118 insertions, 30 deletions
diff --git a/Master/texmf-dist/tex/latex/ctex/ctexart.cls b/Master/texmf-dist/tex/latex/ctex/ctexart.cls index 3daee3bd597..3612b6c88c7 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexart.cls +++ b/Master/texmf-dist/tex/latex/ctex/ctexart.cls @@ -28,10 +28,10 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx e653f84 2016-08-27 11:05:06 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx b7f83de 2016-09-21 21:27:31 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese adapter for class article (CTEX)} \ProvidesExplClass{ctexart} - {\ExplFileDate}{2.4.3}{\ExplFileDescription} + {\ExplFileDate}{2.4.4}{\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 @@ -65,8 +65,8 @@ \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 +\dim_new:N \l__ctex_tmp_dim \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3 { \use:x @@ -650,6 +650,9 @@ #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , #1 / fixskip .bool_set:N = \exp_not:c { CTEX@#1@fixskip } , #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , + #1 / break .tl_set:N = \exp_not:c { CTEX@#1@break } , + #1 / break+ .code:n = + { \tl_put_right:Nn \exp_not:c { CTEX@#1@break } { ####1 } } , #1 / format+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , #1 / nameformat+ .code:n = @@ -693,9 +696,6 @@ \group_end: \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } } } -\cs_new_protected_nopar:Npn \CTEX@makeheadinganchor { } -\ctex_at_end_package:nn { hyperref } - { \cs_gset_protected_nopar:Npn \CTEX@makeheadinganchor { \phantomsection } } \cs_new_protected_nopar:Npn \CTEX@fixheadingskip { \par @@ -706,9 +706,17 @@ \cs_new_protected_nopar:Npn \CTEX@setheadingskip { \skip_set:Nn \l__ctex_heading_skip } \cs_new_eq:NN \CTEX@headingskip \l__ctex_heading_skip +\ProvideDocumentCommand \partmark { m } + { \markboth { } { } } +\cs_new_eq:NN \CTEXifname \use_i:nn +\cs_new_protected_nopar:Npn \CTEX@ifnametrue + { \cs_set_eq:NN \CTEXifname \use_i:nn } +\cs_new_protected_nopar:Npn \CTEX@ifnamefalse + { \cs_set_eq:NN \CTEXifname \use_ii:nn } \renewcommand\part{% \if@noskipsec \leavevmode \fi \par + \CTEX@part@break \CTEX@setheadingskip \CTEX@part@beforeskip \ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi \addvspace \CTEX@headingskip @@ -721,13 +729,17 @@ \def\@part[#1]#2{% \ifnum \c@secnumdepth >\m@ne \ifodd \CTEX@part@numbering + \CTEX@ifnametrue \refstepcounter{part}% \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% \else - \CTEX@makeheadinganchor + \CTEX@ifnamefalse + \CTEX@makeanchor{part*}% \addcontentsline{toc}{part}{#1}% \fi \else + \CTEX@ifnamefalse + \CTEX@makeanchor@part{part*}% \addcontentsline{toc}{part}{#1}% \fi {\interlinepenalty \@M @@ -736,7 +748,7 @@ \CTEX@partname \CTEX@part@aftername \fi \fi \CTEX@part@titleformat{#2}% - \markboth{}{}% + \partmark{#1}% \CTEX@part@aftertitle}% \nobreak \CTEX@setheadingskip \CTEX@part@afterskip @@ -744,6 +756,8 @@ \vskip \CTEX@headingskip \@afterheading} \def\@spart#1{% + \CTEX@ifnamefalse + \CTEX@makeanchor@spart{part*}% {\interlinepenalty \@M \normalfont \parindent \dimexpr \CTEX@part@indent \relax \CTEX@part@format @@ -766,25 +780,30 @@ \if@nobreak \everypar{}% \else - \addpenalty\@secpenalty + \csname CTEX@#1@break\endcsname \CTEX@setheadingskip{#4}% \ifodd \CTEX@fixskip \CTEX@fixheadingskip \fi \addvspace \CTEX@headingskip \fi \@ifstar - {\@ssect{#3}{#4}{#5}{#6}}% + {\CTEX@makeanchor@ssect{#1*}\@ssect{#3}{#4}{#5}{#6}}% {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} \def\@seccntformat#1{% - \csname CTEX@#1name\endcsname \csname CTEX@#1@aftername\endcsname} + \csname CTEX@#1name\endcsname + \csname CTEX@#1@aftername\endcsname} \def\@sect#1#2#3#4#5#6[#7]#8{% \ifnum #2>\c@secnumdepth + \CTEX@ifnamefalse + \CTEX@makeanchor@sect{#1*}% \let\@svsec\@empty \else \ifodd \csname CTEX@#1@numbering\endcsname + \CTEX@ifnametrue \refstepcounter{#1}% \protected@edef\@svsec{\@seccntformat{#1}\relax}% \else - \CTEX@makeheadinganchor + \CTEX@ifnamefalse + \CTEX@makeanchor{#1*}% \let\@svsec\@empty \fi \fi @@ -798,11 +817,7 @@ \endgroup \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% - \ifnum #2>\c@secnumdepth \else - \ifodd \csname CTEX@#1@numbering\endcsname - \protect\numberline{\csname CTEXthe#1\endcsname}% - \fi - \fi + \CTEXifname{\protect\numberline{\csname CTEXthe#1\endcsname}}{}% #7}% \else \def\@svsechd{% @@ -812,15 +827,12 @@ \csname CTEX@#1@aftertitle\endcsname}% \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% - \ifnum #2>\c@secnumdepth \else - \ifodd \csname CTEX@#1@numbering\endcsname - \protect\numberline{\csname CTEXthe#1\endcsname}% - \fi - \fi + \CTEXifname{\protect\numberline{\csname CTEXthe#1\endcsname}}{}% #7}}% \fi \@xsect{#5}} \def\@ssect#1#2#3#4#5{% + \CTEX@ifnamefalse \unless \ifodd \CTEX@runin \begingroup #4{% @@ -905,6 +917,48 @@ \gdef \CTEX@postsection { \CTEX@postappendix } \gdef \CTEX@section@numbering { \CTEX@appendix@numbering } } +\cs_new_protected_nopar:Npn \CTEX@makeanchor #1 + { } +\seq_new:N \c__ctex_headings_cs_seq +\seq_gset_from_clist:Nn \c__ctex_headings_cs_seq + { part , spart , sect , ssect } +\seq_map_inline:Nn \c__ctex_headings_cs_seq + { + \cs_new_eq:cc { CTEX@ #1 } { @ #1 } + \cs_new_eq:cN { CTEX@makeanchor@ #1 } \CTEX@makeanchor + } +\cs_new_protected_nopar:Npn \CTEX@hyperheadinghook + { + \group_begin: + \ifHy@implicit + \cs_set_eq:NN \H@old@chapter \Hy@org@chapter + \seq_map_inline:Nn \c__ctex_headings_cs_seq + { + \cs_if_eq:ccT { H@old@ ##1 } { CTEX@ ##1 } + { + \cs_gset_eq:cc { @ ##1 } { CTEX@ ##1 } + \cs_gset_eq:cN { CTEX@makeanchor@ ##1 } \CTEX@makeanchor + } + } + \else: + \seq_map_inline:Nn \c__ctex_headings_cs_seq + { \cs_gset_eq:cN { CTEX@makeanchor@ ##1 } \CTEX@makeanchor } + \fi: + \group_end: + } +\ctex_at_end_package:nn { hyperref } + { + \cs_gset_protected_nopar:Npn \CTEX@makeanchor #1 + { + \Hy@MakeCurrentHrefAuto {#1} + \Hy@raisedlink + { + \hyper@anchorstart { \@currentHref } + \hyper@anchorend + } + } + \CTEX@hyperheadinghook + } \cs_new_protected_nopar:Npn \ctex_titlesec_hook: { \@ifpackagewith { titlesec } { explicit } @@ -972,6 +1026,28 @@ { \ctex_titlesec_hook: } } } +\ctex_at_end_package:nn { titlesec } + { + \cs_if_free:NF \ttl@tocpart + { + \cs_set_protected_nopar:Npn \ttl@tocpart + { \tl_set:Nn \ttl@a { \CTEXthepart \hspace { 1em } } } + } + \seq_map_inline:Nn \c__ctex_headings_seq + { + \cs_if_exist:cF { ttl@toc #1 } + { + \cs_new_protected_nopar:cpx { ttl@toc #1 } + { + \tl_set:Nn \exp_not:N \ttl@a + { + \exp_not:N \protect + \exp_not:N \numberline { \exp_not:c { CTEXthe #1 } } + } + } + } + } + } \group_begin: \char_set_catcode_other:N \# \cs_new_protected_nopar:Npn \ctex_titleps_hook: @@ -1009,6 +1085,18 @@ \ctex_at_end_package:nn { titlesec } { \cs_if_free:NF \ttl@settopmark { \ctex_titleps_hook: } } \ctex_at_end_package:nn { titleps } { \ctex_titleps_hook: } +\ctex_at_end_package:nn { titleps } + { + \cs_set_protected_nopar:Npn \ttl@setifthe #1 + { + \exp_args:Nco \cs_set_nopar:Npn { ifthe #1 } + { + \CTEXifname + { \protect \@firstoftwo } + { \protect \@secondoftwo } + } + } + } \cs_new_protected:Npn \CTEX@toc@width@n #1 { \hbox_set:Nn \l__ctex_tmp_box {#1} @@ -1041,21 +1129,21 @@ } } \ctex_patch_cmd:Nnn \ps@headings - { \thesection \quad } - { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } + { \ifnum \c@secnumdepth > \z@ \thesection \quad \fi } + { \CTEXifname { \CTEXthesection \quad } { } } \if@twoside \ctex_patch_cmd:Nnn \ps@headings - { \thesubsection \quad } - { \ifodd \CTEX@subsection@numbering \CTEXthesubsection \quad \fi } + { \ifnum \c@secnumdepth > \@ne \thesubsection \quad \fi } + { \CTEXifname { \CTEXthesubsection \quad } { } } \fi: \ctex_at_end_package:nn { fancyhdr } { \ctex_patch_cmd:Nnn \ps@fancy - { \thesection \hskip 1em \relax } - { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } + { \ifnum \c@secnumdepth > \z@ \thesection \hskip 1em \relax \fi } + { \CTEXifname { \CTEXthesection \quad } { } } \ctex_patch_cmd:Nnn \ps@fancy - { \thesubsection \hskip 1em \relax } - { \ifodd \CTEX@subsection@numbering \CTEXthesubsection \quad \fi } + { \ifnum \c@secnumdepth > \@ne \thesubsection \hskip 1em \relax \fi } + { \CTEXifname { \CTEXthesubsection \quad } { } } } \cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 { |