diff options
Diffstat (limited to 'macros/latex/contrib/easybook/easybook.cls')
-rw-r--r-- | macros/latex/contrib/easybook/easybook.cls | 161 |
1 files changed, 131 insertions, 30 deletions
diff --git a/macros/latex/contrib/easybook/easybook.cls b/macros/latex/contrib/easybook/easybook.cls index cfb30bc1ca..4d3c1759ca 100644 --- a/macros/latex/contrib/easybook/easybook.cls +++ b/macros/latex/contrib/easybook/easybook.cls @@ -9,7 +9,7 @@ %% https://creativecommons.org/licenses/by/4.0/legalcode \NeedsTeXFormat{LaTeX2e} \RequirePackage{l3keys2e} -\ProvidesExplClass{easybook}{2021/03/14}{1.23q}{} +\ProvidesExplClass{easybook}{2021/03/15}{1.23r}{} \cs_generate_variant:Nn \keys_define:nn {nx} \cs_generate_variant:Nn \int_to_arabic:n {v} @@ -93,7 +93,6 @@ \__put_ctexbook:n {\g__options_clist} \LoadClass[UTF8]{ctexbook} -\bool_new:N \l__capdash_bool \bool_new:N \l__multoc_bool \bool_new:N \l__chap_withpart_bool \bool_new:N \l__foot_perpart_bool @@ -107,7 +106,7 @@ style .meta:nn = {ctex/style}{#1}, link .meta:nn = {ctex/link}{#1}, spread .meta:nn = {ctex/spread}{#1}, - elfont .meta:nn = {ctex/elfont}{#1}, + elsefont .meta:nn = {ctex/elsefont}{#1}, bibset .meta:nn = {ctex/bibset}{#1}, thmset .meta:nn = {ctex/thmset}{#1}, geoset .meta:nn = {ctex/geoset}{#1}, @@ -119,12 +118,8 @@ } \__ctex_define:nn {style} { - capdash .bool_set:N = \l__capdash_bool, - capdash .default:n = true, - capdash .initial:n = false, multoc .bool_set:N = \l__multoc_bool, multoc .default:n = true, - multoc .initial:n = false, withpart .bool_set:N = \l__chap_withpart_bool, withpart .default:n = true, withpart .initial:n = false, @@ -141,7 +136,17 @@ rulewidth .initial:n = 0.75pt, uppercase .bool_set:N = \l__uppercase_bool, uppercase .default:n = true, - uppercase .initial:n = true + uppercase .initial:n = true, + figure-sep .tl_set:N = \l__figure_separator_tl, + table-sep .tl_set:N = \l__table_separator_tl, + listing-sep .tl_set:N = \l__lstlisting_separator_tl, + equation-sep .tl_set:N = \l__equation_separator_tl, + number-sep .meta:n = + { + figure-sep = {#1},table-sep = {#1}, + listing-sep = {#1},equation-sep = {#1} + }, + number-sep .initial:n = {.} } \RequirePackage @@ -531,19 +536,40 @@ }{} } } + +\tl_set:Nn \l__toc_type_tl{book} +\keys_define:nn {listoc} + { + article .code:n = \tl_set:Nn \l__toc_type_tl{article}, + book .code:n = {}, + multoc .bool_set:N = \l__multoc_bool, + multoc .default:n = true, + multoc .initial:n = false + } + \cs_new_protected:Npn \__title_mark_intoc:n #1 { - \chapter*{\phantomsection#1} - \CTEX@addtocline{chapter}{#1} + \tl_if_eq:NnTF \l__toc_type_tl{book} + { + \chapter*{\phantomsection#1} + \CTEX@addtocline{chapter}{#1} + }{ + \section*{\phantomsection#1} + \CTEX@addtocline{section}{#1} + } \__markboth:n {#1} } \cs_new_protected:Npn \__title_mark:n #1 { - \chapter*{\phantomsection#1} + \tl_if_eq:NnTF \l__toc_type_tl{book} + {\chapter*{\phantomsection#1}} + {\section*{\phantomsection#1}} \__markboth:n {#1} } -\cs_gset:Npn \tableofcontents +\RenewDocumentCommand{\tableofcontents}{o} { + \group_begin: + \IfValueT {#1}{\keys_set:nn {listoc}{#1}} \if@twocolumn \@restonecoltrue\onecolumn \bool_if:NT \l__multoc_bool{\twocolumn} @@ -559,9 +585,12 @@ \else \onecolumn \fi + \group_end: } -\cs_gset:Npn \listoffigures +\RenewDocumentCommand{\listoffigures}{so} { + \group_begin: + \IfValueT {#2}{\keys_set:nn {listoc}{#2}} \if@twocolumn \@restonecoltrue\onecolumn \bool_if:NT \l__multoc_bool{\twocolumn} @@ -569,7 +598,9 @@ \@restonecolfalse \bool_if:NT \l__multoc_bool{\twocolumn} \fi - \__title_mark_intoc:n {\listfigurename} + \IfBooleanTF {#1} + {\__title_mark:n {\listfigurename}} + {\__title_mark_intoc:n {\listfigurename}} \dim_add:NV \l__toc_offset_dim\l__toc_listsoffset_dim \vspace*{\dim_use:N \l__toc_offset_dim} \@starttoc{lof} @@ -578,9 +609,12 @@ \else \onecolumn \fi + \group_end: } -\cs_gset:Npn \listoftables +\RenewDocumentCommand{\listoftables}{so} { + \group_begin: + \IfValueT {#2}{\keys_set:nn {listoc}{#2}} \if@twocolumn \@restonecoltrue\onecolumn \bool_if:NT \l__multoc_bool{\twocolumn} @@ -588,7 +622,9 @@ \@restonecolfalse \bool_if:NT \l__multoc_bool{\twocolumn} \fi - \__title_mark_intoc:n {\listtablename} + \IfBooleanTF {#1} + {\__title_mark:n {\listtablename}} + {\__title_mark_intoc:n {\listtablename}} \dim_add:NV \l__toc_offset_dim\l__toc_listsoffset_dim \vspace*{\dim_use:N \l__toc_offset_dim} \@starttoc{lot} @@ -597,9 +633,12 @@ \else \onecolumn \fi + \group_end: } -\cs_new:Npn \listoflistings +\NewDocumentCommand{\listoflistings}{so} { + \group_begin: + \IfValueT {#2}{\keys_set:nn {listoc}{#2}} \if@twocolumn \@restonecoltrue\onecolumn \bool_if:NT \l__multoc_bool{\twocolumn} @@ -607,7 +646,9 @@ \@restonecolfalse \bool_if:NT \l__multoc_bool{\twocolumn} \fi - \__title_mark_intoc:n {\lstlistlistingname} + \IfBooleanTF {#1} + {\__title_mark:n {\lstlistlistingname}} + {\__title_mark_intoc:n {\lstlistlistingname}} \dim_add:NV \l__toc_offset_dim\l__toc_listsoffset_dim \vspace*{\dim_use:N \l__toc_offset_dim} \@starttoc{lol} @@ -616,6 +657,7 @@ \else \onecolumn \fi + \group_end: } \makeindex[ @@ -627,9 +669,9 @@ ] \indexsetup { - level = \chapter*, - toclevel = chapter, - firstpagestyle = plain + level = \int_compare:nTF {\c@chapter > 0}{\chapter*}{\section*}, + toclevel = \int_compare:nTF {\c@chapter > 0}{chapter}{section}, + firstpagestyle = \int_compare:nTF {\c@chapter > 0}{plain}{fancy} } \__patch_cmd:Nnn \imki@indexheaders {\@mkboth{\MakeUppercase\indexname}{\MakeUppercase\indexname}} @@ -640,7 +682,7 @@ \tl_new:N \l__font_listing_tl \tl_new:N \l__font_footnote_tl -\__ctex_define:nn {elfont} +\__ctex_define:nn {elsefont} { table-cap .tl_set:N = \l__font_table_tl, table-cap .initial:n = \sffamily\small, @@ -684,11 +726,47 @@ \cs_new:Npn \__arabic:n #1{\int_to_arabic:v {c@#1}} \AtBeginDocument { - \bool_if:NT \l__capdash_bool + \cs_new_protected:Npn \__separator_set:n #1 { - \cs_gset:Npn \thefigure{\thechapter\textendash\__arabic:n {figure}} - \cs_gset:Npn \thetable{\thechapter\textendash\__arabic:n {table}} - \cs_gset:Npn \thelstlisting{\thechapter\textendash\__arabic:n {lstlisting}} + \cs_set:cpn {the#1} + { + \int_compare:nT {\c@chapter > 0} + { + \thechapter + \use:c {l__#1_separator_tl} + } + \__arabic:n {#1} + } + } + \cs_gset:cpn {thesection} + { + \int_compare:nT {\c@chapter > 0}{\thechapter.} + \__arabic:n {section} + } + \clist_map_inline:nn + {{figure},{table},{lstlisting},{equation}} + {\__separator_set:n {#1}} + \cs_gset_protected:Npn \appendix + { + \int_compare:nNnTF {\c@chapter} > {0} + { + \setcounter{chapter}{0} + \setcounter{section}{0} + \gdef\thechapter{\@Alph\c@chapter} + \gdef\CTEX@prechapter{\CTEX@preappendix} + \gdef\CTEX@thechapter{\CTEX@appendix@number} + \gdef\CTEX@postchapter{\CTEX@postappendix} + \gdef\CTEX@chapter@numbering{\CTEX@appendix@numbering} + }{ + \setcounter{section}{0} + \setcounter{subsection}{0} + \gdef\thesection{\@Alph\c@section} + \gdef\CTEX@presection{\CTEX@preappendix} + \gdef\CTEX@thesection{\CTEX@appendix@number} + \gdef\CTEX@postsection{\CTEX@postappendix} + \gdef\CTEX@section@numbering{\CTEX@appendix@numbering} + \ctex_set:nn {appendix}{number = {\@Alph\c@section},name = {}} + } } } \AtBeginEnvironment{tabularx} @@ -1094,10 +1172,32 @@ } \tl_if_empty:NF \l__bib_citestyle_tl {\exp_args:NV \setcitestyle\l__bib_citestyle_tl} - \cs_set:Npn \bibsection{\__title_mark_intoc:n \bibname} \skip_set:Nn \bibsep{0ex} - \NewDocumentCommand{\printbibliography}{o} - {\exp_args:NV \bibliography\l__bib_file_tl} + \NewDocumentCommand{\printbibliography}{so} + { + \group_begin: + \IfValueT {##2}{\keys_set:nn {listoc}{##2}} + \if@twocolumn + \@restonecoltrue\onecolumn + \bool_if:NT \l__multoc_bool{\twocolumn} + \else + \@restonecolfalse + \bool_if:NT \l__multoc_bool{\twocolumn} + \fi + \cs_set:Npn \bibsection + { + \IfBooleanTF {##1} + {\__title_mark:n {\bibname}} + {\__title_mark_intoc:n {\bibname}} + } + \exp_args:NV \bibliography\l__bib_file_tl + \if@restonecol + \twocolumn + \else + \onecolumn + \fi + \group_end: + } } \cs_new_protected:Npn \__put_biblatex:n #1 {\PassOptionsToPackage{#1}{biblatex}} @@ -1119,7 +1219,8 @@ \cs_new_protected:Npn \__biblatex_after_set: { \exp_args:NV \addbibresource\l__bib_file_tl - \defbibheading{bibliography}[\bibname]{\__title_mark_intoc:n {##1}} + \cs_gset:Npn \blx@default@theheading{bibintoc} + \defbibheading{bibintoc}[\bibname]{\__title_mark_intoc:n {##1}} \skip_set:Nn \bibitemsep{0ex} } \ctex_at_end_preamble:n |