diff options
author | Karl Berry <karl@freefriends.org> | 2016-09-25 21:05:03 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-09-25 21:05:03 +0000 |
commit | cdbf5b2c845ca6b373fff9043f2e00b14807950a (patch) | |
tree | 21be6d681fafea69eabe39b80de24707f9a13d14 /Master/texmf-dist/tex/latex/ctex/ctexrep.cls | |
parent | d74756a7c618d3f8e58046afb5f5f7d5a07e429f (diff) |
ctex
git-svn-id: svn://tug.org/texlive/trunk@42148 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 | 182 |
1 files changed, 140 insertions, 42 deletions
diff --git a/Master/texmf-dist/tex/latex/ctex/ctexrep.cls b/Master/texmf-dist/tex/latex/ctex/ctexrep.cls index 7434d7e5ac2..08df376a680 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 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 report (CTEX)} \ProvidesExplClass{ctexrep} - {\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 @@ -651,6 +651,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 = @@ -698,9 +701,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@fixtopskip { \CTEX@fixheadingskip @@ -717,12 +717,15 @@ \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@openright - \cleardoublepage - \else - \clearpage - \fi + \CTEX@part@break \thispagestyle{\CTEX@part@pagestyle}% \if@twocolumn \onecolumn @@ -737,16 +740,20 @@ \def\@part[#1]#2{% \ifnum \c@secnumdepth >-2\relax \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 - \markboth{}{}% + \partmark{#1}% {\interlinepenalty \@M \normalfont \CTEX@part@format \ifnum \c@secnumdepth >-2\relax \ifodd \CTEX@part@numbering @@ -756,6 +763,8 @@ \CTEX@part@aftertitle}% \@endpart} \def\@spart#1{% + \CTEX@ifnamefalse + \CTEX@makeanchor@spart{part*}% {\interlinepenalty \@M \normalfont \CTEX@part@format \CTEX@part@titleformat{#1}% @@ -776,7 +785,8 @@ \if@tempswa \twocolumn \fi} -\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi +\renewcommand\chapter{% + \CTEX@chapter@break \thispagestyle{\CTEX@chapter@pagestyle}% \global\@topnum\z@ \ifodd \CTEX@chapter@afterindent @@ -788,15 +798,19 @@ \def\@chapter[#1]#2{% \ifnum \c@secnumdepth >\m@ne \ifodd \CTEX@chapter@numbering + \CTEX@ifnametrue \refstepcounter{chapter}% \typeout{\CTEXthechapter}% \addcontentsline{toc}{chapter} {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% \else - \CTEX@makeheadinganchor + \CTEX@ifnamefalse + \CTEX@makeanchor{\Hy@chapapp*}% \addcontentsline{toc}{chapter}{#1}% \fi \else + \CTEX@ifnamefalse + \CTEX@makeanchor@chapter{\Hy@chapapp*}% \addcontentsline{toc}{chapter}{#1}% \fi \chaptermark{#1}% @@ -808,17 +822,22 @@ \@makechapterhead{#2}% \@afterheading \fi} +\def\@schapter#1{% + \CTEX@ifnamefalse + \CTEX@makeanchor@schapter{\Hy@chapapp*}% + \if@twocolumn + \@topnewpage[\@makeschapterhead{#1}]% + \else + \@makeschapterhead{#1}% + \@afterheading + \fi} \def\@makechapterhead#1{% \CTEX@setheadingskip \CTEX@chapter@beforeskip \ifodd \CTEX@chapter@fixskip \CTEX@fixtopskip \fi \vspace*{\CTEX@headingskip}% {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax \CTEX@chapter@format - \ifnum \c@secnumdepth >\m@ne - \ifodd \CTEX@chapter@numbering - \CTEX@chaptername \CTEX@chapter@aftername - \fi - \fi + \CTEXifname{\CTEX@chaptername\CTEX@chapter@aftername}{}% \interlinepenalty\@M \CTEX@chapter@titleformat{#1}% \CTEX@chapter@aftertitle @@ -853,25 +872,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 @@ -885,11 +909,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{% @@ -899,15 +919,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{% @@ -992,6 +1009,48 @@ \gdef \CTEX@postchapter { \CTEX@postappendix } \gdef \CTEX@chapter@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 , chapter , schapter , 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 } @@ -1059,6 +1118,29 @@ { \ctex_titlesec_hook: } } } +\ctex_at_end_package:nn { titlesec } + { + \tl_set:Nn \ttl@chapterout { \typeout { \CTEXthechapter } } + \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: @@ -1096,6 +1178,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} @@ -1128,21 +1222,25 @@ } } \ctex_patch_cmd:Nnn \ps@headings - { \@chapapp\ \thechapter.~\ } - { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } + { + \ifnum \c@secnumdepth > \m@ne \if@mainmatter + \@chapapp \ \thechapter . ~ \ + \fi \fi + } + { \CTEXifname { \CTEXthechapter \quad } { } } \if@twoside \ctex_patch_cmd:Nnn \ps@headings - { \thesection.~\ } - { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } + { \ifnum \c@secnumdepth > \z@ \thesection . ~ \ \fi } + { \CTEXifname { \CTEXthesection } { } } \fi: \ctex_at_end_package:nn { fancyhdr } { \ctex_patch_cmd:Nnn \ps@fancy - { \@chapapp\ \thechapter.~\ } - { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } + { \ifnum \c@secnumdepth > \m@ne \@chapapp \ \thechapter . ~ \ \fi } + { \CTEXifname { \CTEXthechapter \quad } { } } \ctex_patch_cmd:Nnn \ps@fancy - { \thesection.~\ } - { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } + { \ifnum \c@secnumdepth > \z@ \thesection . ~ \ \fi } + { \CTEXifname { \CTEXthesection } { } } } \cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 { |