summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ctex/ctexbook.cls
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/ctex/ctexbook.cls')
-rw-r--r--Master/texmf-dist/tex/latex/ctex/ctexbook.cls217
1 files changed, 128 insertions, 89 deletions
diff --git a/Master/texmf-dist/tex/latex/ctex/ctexbook.cls b/Master/texmf-dist/tex/latex/ctex/ctexbook.cls
index 9c713e37a3f..3e6a5d76736 100644
--- a/Master/texmf-dist/tex/latex/ctex/ctexbook.cls
+++ b/Master/texmf-dist/tex/latex/ctex/ctexbook.cls
@@ -28,10 +28,16 @@
%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\GetIdInfo$Id: ctex.dtx 3216ced 2015-05-16 11:29:03 +0800 Qing Lee <sobenlee@gmail.com> $
+\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $
{Chinese adapter for class book (CTEX)}
\ProvidesExplClass{ctexbook}
- {\ExplFileDate}{2.0.2}{\ExplFileDescription}
+ {\ExplFileDate}{2.1}{\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
+\cs_new_eq:cN { ver@ctexcap. \@pkgextension } \c__ctex_version_tl
+\cs_new_eq:cN { ver@ctexsize. \@pkgextension } \c__ctex_version_tl
+\cs_new_eq:cN { ver@ctexheading. \@pkgextension } \c__ctex_version_tl
\RequirePackage { xparse , l3keys2e }
\msg_new:nnnn { ctex } { l3-too-old }
{ Support~package~`#1'~too~old. }
@@ -44,43 +50,24 @@
{ \msg_error:nnn { ctex } { l3-too-old } { expl3 } }
\@ifpackagelater { l3keys2e } { 2014/05/05 } { }
{ \msg_error:nnn { ctex } { l3-too-old } { l3keys2e } }
-\RequirePackage { etoolbox , ifpdf , fix-cm , everysel }
+\RequirePackage { etoolbox }
+\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
-\msg_new:nnnn { ctex } { package-too-old }
- { Support~package~`#1'~too~old. }
- {
- Please~update~an~up~to~date~version~of~the~package~`#1'\\
- using~your~TeX~package~manager~or~from~CTAN.
- }
-\cs_new_eq:NN \ctex_lua_now_x:n \luatex_directlua:D
-\ifpdf
- \cs_new_eq:NN \ctex_if_pdfmode:TF \use_i:nn
-\else:
- \cs_new_eq:NN \ctex_if_pdfmode:TF \use_ii:nn
-\fi:
-\prg_new_conditional:Npnn \ctex_if_preamble: { TF }
- {
- \if_meaning:w \@onlypreamble \@notprerr
- \prg_return_false:
- \else:
- \prg_return_true:
- \fi:
- }
\cs_new_protected:Npn \ctex_at_end_package:nn #1#2
{
- \@ifpackageloaded { #1 }
- { #2 }
- { \ctex_add_hook:cn { g__ctex_at_end_ #1 _hook_tl } { #2 } }
+ \@ifpackageloaded {#1}
+ {#2}
+ { \ctex_gadd_hook:cn { g__ctex_at_end_ #1 _hook_tl } {#2} }
}
-\cs_new_protected:Npn \ctex_add_hook:Nn #1#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 }
+ \tl_gput_right:Nn #1 {#2}
}
-\cs_generate_variant:Nn \ctex_add_hook:Nn { c }
+\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 }
@@ -88,7 +75,10 @@
}
\cs_generate_variant:Nn \ctex_package_end_hook:n { o }
\tl_put_left:Nn \@popfilename
- { \ctex_package_end_hook:o { \@currname } }
+ {
+ \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
@@ -138,15 +128,15 @@
\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
+ \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
{
- \group_end:
\exp_args:Nc #6
{
\str_case:nnTF {#1}
@@ -175,9 +165,9 @@
\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:Npn \ctex_patch_cmd:NnnTF { \ctex_parse_name:NN \patchcmd }
-\cs_new_protected:Npn \ctex_preto_cmd:NnTF { \ctex_parse_name:NN \pretocmd }
-\cs_new_protected:Npn \ctex_appto_cmd:NnTF { \ctex_parse_name:NN \apptocmd }
+\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:
@@ -205,6 +195,29 @@
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. }
+ {
+ Please~update~an~up~to~date~version~of~the~package~`#1'\\
+ using~your~TeX~package~manager~or~from~CTAN.
+ }
+\cs_new_eq:NN \ctex_lua_now_x:n \luatex_directlua:D
+\cs_if_exist:NTF \pdftex_pdfoutput:D
+ {
+ \int_compare:nNnTF \pdftex_pdfoutput:D > \c_zero
+ {
+ \cs_new_eq:NN \ifctexpdf \tex_iftrue:D
+ \cs_new_eq:NN \ctex_if_pdfmode:TF \use_i:nn
+ }
+ }
+ { \use:n }
+ {
+ \cs_new_eq:NN \ifctexpdf \tex_iffalse:D
+ \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 }
\cs_new:Npn \ctex_set_default_ccwd:Nn #1#2
{
\dim_compare:nNnTF
@@ -228,7 +241,6 @@
\tl_new:N \l__ctex_encoding_tl
\tl_set:Nx \l__ctex_encoding_tl
{ \pdftex_if_engine:TF { GBK } { UTF8 } }
-\cs_new_eq:NN \g__ctex_section_depth_flag \c_two
\bool_new:N \g__ctex_zhmCJK_bool
\tl_new:N \l__ctex_autoindent_tl
\cs_new_eq:NN \ctex_if_autoindent_touched:F \use:n
@@ -328,7 +340,7 @@
Option~ `fontset=adobe'~ is~ set.~ It~ is~ better~ to~ use~
fontset~ option.
}
- \keys_set:nn { ctex / option } { fontset = none }
+ \keys_set:nn { ctex / option } { fontset = adobe }
} ,
winfonts .code:n =
{
@@ -337,7 +349,7 @@
Option~ `fontset=windows'~ is~ set.~ It~ is~ better~ to~ use~
fontset~ option.
}
- \keys_set:nn { ctex / option } { fontset = none }
+ \keys_set:nn { ctex / option } { fontset = windows }
} ,
nofonts .value_forbidden: ,
winfonts .value_forbidden: ,
@@ -391,9 +403,15 @@
} ,
nospace .value_forbidden: ,
heading .bool_set:N = \l__ctex_heading_bool ,
+ sub3section .code:n =
+ { \cs_gset_eq:NN \g__ctex_section_depth_flag \c_three } ,
+ sub4section .code:n =
+ { \cs_gset_eq:NN \g__ctex_section_depth_flag \c_four } ,
+ sub3section .value_forbidden: ,
+ sub4section .value_forbidden: ,
scheme .tl_set:N = \l__ctex_scheme_tl ,
- scheme .default:n = { chinese },
- scheme .initial:n = { chinese },
+ scheme .default:n = { chinese } ,
+ scheme .initial:n = { chinese } ,
cap .code:n =
{
\msg_warning:nnn { ctex } { deprecated-option }
@@ -408,12 +426,6 @@
} ,
cap .value_forbidden: ,
nocap .value_forbidden: ,
- sub3section .code:n =
- { \cs_gset_eq:NN \g__ctex_section_depth_flag \c_three } ,
- sub4section .code:n =
- { \cs_gset_eq:NN \g__ctex_section_depth_flag \c_four } ,
- sub3section .value_forbidden: ,
- sub4section .value_forbidden: ,
fntef .code:n =
{
\msg_warning:nnn { ctex } { deprecated-option }
@@ -423,12 +435,17 @@
{
\msg_warning:nnn { ctex } { deprecated-option }
{ `fancyhdr'~ package~ is~ loaded. }
- \RequirePackage{ fancyhdr }
+ \RequirePackage { fancyhdr }
} ,
hyperref .code:n =
{
\msg_warning:nnn { ctex } { deprecated-option }
{ `hyperref'~ package~ will~ be~ loaded. }
+ \ctex_at_end:n
+ {
+ \cs_if_exist:NF \hypersetup
+ { \cs_new_eq:NN \hypersetup \ctex_hypersetup:n }
+ }
\AtEndPreamble { \RequirePackage { hyperref } }
} ,
}
@@ -466,12 +483,7 @@
\tl_const:Nn \c__ctex_class_tl { book }
\PassOptionsToClass { \g__ctex_std_options_clist } { book }
\LoadClass { book }
-\tl_set_eq:Nc \l__ctex_tmp_tl { ver@ \@currname . \@currext }
-\cs_new_eq:cN { ver@ctex. \@pkgextension } \l__ctex_tmp_tl
-\cs_new_eq:cN { ver@ctexcap. \@pkgextension } \l__ctex_tmp_tl
-\cs_new_eq:cN { ver@ctexsize. \@pkgextension } \l__ctex_tmp_tl
-\NewDocumentCommand \ctexset { +m }
- { \keys_set:nn { ctex } {#1} }
+\NewDocumentCommand \ctexset { } { \keys_set:nn { ctex } }
\NewDocumentCommand \CTEXsetup { +o > { \TrimSpaces } m }
{
\msg_warning:nnnn { ctex } { deprecated-command } { \CTEXsetup }
@@ -493,7 +505,6 @@
\cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
{ \PassOptionsToPackage {#1} { hyperref } }
}
-\ctex_hypersetup:n { colorlinks = true }
\pdftex_if_engine:TF
{
\tl_set:Nx \l__ctex_encoding_tl { \l__ctex_encoding_tl }
@@ -704,16 +715,18 @@
\tl_const:cx { CTEX@#1name }
{
\exp_not:c { CTEX@#1@nameformat }
- \exp_not:c { CTEX@pre#1 }
- \exp_not:N \tl_if_empty:NTF \exp_not:c { CTEX@#1@numberformat }
- { \exp_not:c { CTEX@the#1 } }
{
- \group_begin:
- \exp_not:c { CTEX@#1@numberformat }
- \exp_not:c { CTEX@the#1 }
- \group_end:
+ \exp_not:c { CTEX@pre#1 }
+ \exp_not:N \tl_if_empty:NTF \exp_not:c { CTEX@#1@numberformat }
+ { \exp_not:c { CTEX@the#1 } }
+ {
+ \group_begin:
+ \exp_not:c { CTEX@#1@numberformat }
+ \exp_not:c { CTEX@the#1 }
+ \group_end:
+ }
+ \exp_not:c { CTEX@post#1 }
}
- \exp_not:c { CTEX@post#1 }
\exp_not:c { CTEX@#1@aftername }
}
}
@@ -730,19 +743,34 @@
#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 =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } ,
+ #1 / format~+ .code:n =
+ { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } ,
#1 / nameformat+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } ,
+ #1 / nameformat~+ .code:n =
+ { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } ,
#1 / numberformat+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } ,
+ #1 / numberformat~+ .code:n =
+ { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } ,
#1 / aftername+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } ,
+ #1 / aftername~+ .code:n =
+ { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } ,
#1 / titleformat+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } ,
+ #1 / titleformat~+ .code:n =
+ { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } ,
+ #1 / aftertitle+ .code:n =
+ { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } ,
+ #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 ,
@@ -761,7 +789,11 @@
{ \tl_clear:c { CTEX@post#1 } }
{ \tl_set:cn { CTEX@post#1 } {#3} }
}
-\tl_clear:N \l__ctex_tmp_tl
+\tl_set:Nn \l__ctex_tmp_tl
+ {
+ part / pagestyle .tl_set:N = \CTEX@part@pagestyle ,
+ chapter / pagestyle .tl_set:N = \CTEX@chapter@pagestyle ,
+ }
\seq_map_inline:Nn \c__ctex_headings_seq
{
\__ctex_initial_heading:n {#1}
@@ -769,11 +801,6 @@
}
\use:x { \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } } }
\tl_clear:N \l__ctex_tmp_tl
-\keys_define:nn { ctex }
- {
- part / pagestyle .tl_set:N = \CTEX@part@pagestyle ,
- chapter / pagestyle .tl_set:N = \CTEX@chapter@pagestyle
- }
\def\@part[#1]#2{%
\thispagestyle{\CTEX@part@pagestyle}%
\ifnum \c@secnumdepth >-2\relax
@@ -788,12 +815,14 @@
\ifnum \c@secnumdepth >-2\relax
\CTEX@partname
\fi
- \CTEX@part@titleformat{#2}\par}%
+ \CTEX@part@titleformat{#2}%
+ \CTEX@part@aftertitle}%
\@endpart}
\def\@spart#1{%
{\interlinepenalty \@M
\normalfont \CTEX@part@format
- \CTEX@part@titleformat{#1}\par}%
+ \CTEX@part@titleformat{#1}%
+ \CTEX@part@aftertitle}%
\@endpart}
\def\@chapter[#1]#2{%
\ifnum \c@secnumdepth >\m@ne
@@ -833,7 +862,9 @@
\fi
\fi
\interlinepenalty\@M
- \CTEX@chapter@titleformat{#1}\par\nobreak
+ \CTEX@chapter@titleformat{#1}%
+ \CTEX@chapter@aftertitle
+ \nobreak
\vskip \CTEX@chapter@afterskip
}}
\def\@makeschapterhead#1{%
@@ -847,7 +878,9 @@
\vspace*{\@tempskipa}%
{\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format
\interlinepenalty\@M
- \CTEX@chapter@titleformat{#1}\par\nobreak
+ \CTEX@chapter@titleformat{#1}
+ \CTEX@chapter@aftertitle
+ \nobreak
\vskip \CTEX@chapter@afterskip
}}
\def\@seccntformat#1{%
@@ -867,7 +900,8 @@
#6{%
\@hangfrom{\hskip #3\relax\@svsec}%
\interlinepenalty \@M
- \csname CTEX@#1@titleformat\endcsname{#8}\@@par}%
+ \csname CTEX@#1@titleformat\endcsname{#8}%
+ \csname CTEX@#1@aftertitle\endcsname}%
\endgroup
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
@@ -880,7 +914,9 @@
\else
\def\@svsechd{%
#6{\hskip #3\relax
- \@svsec \csname CTEX@#1@titleformat\endcsname{#8}}%
+ \@svsec
+ \csname CTEX@#1@titleformat\endcsname{#8}%
+ \csname CTEX@#1@aftertitle\endcsname}%
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
@@ -898,15 +934,20 @@
#4{%
\@hangfrom{\hskip #1}%
\interlinepenalty \@M
- \CTEX@titleformat@n{#5}\@@par}%
+ \CTEX@titleformat@n{#5}%
+ \CTEX@aftertitle}%
\endgroup
\else
- \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}}}%
+ \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}\CTEX@aftertitle}}%
\fi
\@xsect{#3}}
\cs_new_protected_nopar:Npn \CTEX@set@titleformat@n #1
- { \cs_set_eq:Nc \CTEX@titleformat@n { CTEX@#1@titleformat } }
+ {
+ \cs_set_eq:Nc \CTEX@titleformat@n { CTEX@#1@titleformat }
+ \cs_set_eq:Nc \CTEX@aftertitle { CTEX@#1@aftertitle }
+ }
\cs_new_eq:NN \CTEX@titleformat@n \use:n
+\cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing:
\int_zero:N \l__ctex_tmp_int
\clist_map_inline:nn
{ section , subsection , subsubsection , paragraph , subparagraph }
@@ -925,15 +966,15 @@
}
}
}
-\tl_new:N \CTEX@preappendix
-\tl_new:N \CTEX@postappendix
\keys_define:nn { ctex }
- { appendix .meta:nn = { ctex / appendix } {#1} }
-\keys_define:nn { ctex / appendix }
{
- name .code:n = { \ctex_assign_heading_name:nn { appendix } {#1} } ,
- number .tl_set:N = \CTEX@appendixnumber
+ appendix .meta:nn = { ctex / appendix } {#1} ,
+ appendix / name .code:n =
+ { \ctex_assign_heading_name:nn { appendix } {#1} } ,
+ appendix / number .tl_set:N = \CTEX@appendixnumber
}
+\tl_new:N \CTEX@preappendix
+\tl_new:N \CTEX@postappendix
\cs_new_eq:NN \CTEX@save@appendix \appendix
\cs_gset_protected_nopar:Npn \appendix
{
@@ -1119,11 +1160,8 @@
\normalsize
\NewDocumentCommand \CTeX { }
{ \ifincsname CTeX \else: C \TeX \fi: }
-\AtBeginDocument
- {
- \cs_if_exist_use:NT \pdfstringdefDisableCommands
- { { \tl_set:Nn \CTeX { CTeX } } }
- }
+\ctex_at_end_package:nn { hyperref }
+ { \pdfstringdefDisableCommands { \tl_set:Nn \CTeX { CTeX } } }
\keys_define:nn { ctex }
{
captiondelimiter .code:n =
@@ -1227,6 +1265,7 @@
%% ctex.sty,
%% ctexcap.sty,
%% ctexsize.sty,
+%% ctexheading.sty,
%% ctexart.cls,
%% ctexbook.cls,
%% ctexrep.cls,