From 2ca606b41366967129514d78b3f2c1c53c257b8a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 16 Mar 2021 22:16:16 +0000 Subject: easybook (16mar21) (branch) git-svn-id: svn://tug.org/texlive/branches/branch2020.0@58453 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/easybook/easybook.cls | 254 ++++++++++++++-------- 1 file changed, 167 insertions(+), 87 deletions(-) (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/easybook/easybook.cls b/Master/texmf-dist/tex/latex/easybook/easybook.cls index cfb30bc1caa..97f532796f2 100644 --- a/Master/texmf-dist/tex/latex/easybook/easybook.cls +++ b/Master/texmf-dist/tex/latex/easybook/easybook.cls @@ -7,9 +7,9 @@ %% conditions of the CC-BY 4.0 License. %% The latest version of this license is in %% https://creativecommons.org/licenses/by/4.0/legalcode -\NeedsTeXFormat{LaTeX2e} +\NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{l3keys2e} -\ProvidesExplClass{easybook}{2021/03/14}{1.23q}{} +\ProvidesExplClass{easybook}{2021/03/16}{1.23s}{} \cs_generate_variant:Nn \keys_define:nn {nx} \cs_generate_variant:Nn \int_to_arabic:n {v} @@ -29,6 +29,7 @@ \bool_set_true:N \l__zhtitle_bool \bool_set_true:N \l__lang_chinese_bool \bool_set_true:N \l__page_twoside_bool +\bool_set_true:N \l__class_book_bool \clist_new:N \g__options_clist \keys_define:nn {easybook} @@ -68,7 +69,13 @@ \__put_ctexbook:n {oneside} }, - unknown .code:n = + class .choice:, + class .value_required:n = true, + class/book .code:n = {}, + class/article .code:n = {\bool_set_false:N \l__class_book_bool}, + class .initial:n = book, + + unknown .code:n = {\clist_gput_right:No \g__options_clist{\CurrentOption}} } @@ -93,7 +100,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 +113,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 +125,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 +143,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,91 +543,113 @@ }{} } } + +\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 +\cs_new_protected:Npn \__ifmultoc_pre_set: + { + \bool_if:NTF \l__class_book_bool + { + \if@twocolumn + \@restonecoltrue + \onecolumn + \bool_if:NT \l__multoc_bool{\twocolumn} + \else + \@restonecolfalse + \bool_if:NT \l__multoc_bool{\twocolumn} + \fi + }{\tl_set:Nn \l__toc_type_tl{article}} + } +\cs_new_protected:Npn \__ifmultoc_after_set: + { + \bool_if:NTF \l__class_book_bool + { + \if@restonecol + \twocolumn + \else + \onecolumn + \fi + }{\tl_set:Nn \l__toc_type_tl{article}} + } +\RenewDocumentCommand{\tableofcontents}{o} { - \if@twocolumn - \@restonecoltrue\onecolumn - \bool_if:NT \l__multoc_bool{\twocolumn} - \else - \@restonecolfalse - \bool_if:NT \l__multoc_bool{\twocolumn} - \fi + \group_begin: + \IfValueT {#1}{\keys_set:nn {listoc}{#1}} + \__ifmultoc_pre_set: \__title_mark:n {\contentsname} \vspace*{\dim_use:N \l__toc_offset_dim} \@starttoc{toc} - \if@restonecol - \twocolumn - \else - \onecolumn - \fi - } -\cs_gset:Npn \listoffigures - { - \if@twocolumn - \@restonecoltrue\onecolumn - \bool_if:NT \l__multoc_bool{\twocolumn} - \else - \@restonecolfalse - \bool_if:NT \l__multoc_bool{\twocolumn} - \fi - \__title_mark_intoc:n {\listfigurename} + \__ifmultoc_after_set: + \group_end: + } +\RenewDocumentCommand{\listoffigures}{so} + { + \group_begin: + \IfValueT {#2}{\keys_set:nn {listoc}{#2}} + \__ifmultoc_pre_set: + \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} - \if@restonecol - \twocolumn - \else - \onecolumn - \fi - } -\cs_gset:Npn \listoftables - { - \if@twocolumn - \@restonecoltrue\onecolumn - \bool_if:NT \l__multoc_bool{\twocolumn} - \else - \@restonecolfalse - \bool_if:NT \l__multoc_bool{\twocolumn} - \fi - \__title_mark_intoc:n {\listtablename} + \__ifmultoc_after_set: + \group_end: + } +\RenewDocumentCommand{\listoftables}{so} + { + \group_begin: + \IfValueT {#2}{\keys_set:nn {listoc}{#2}} + \__ifmultoc_pre_set: + \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} - \if@restonecol - \twocolumn - \else - \onecolumn - \fi - } -\cs_new:Npn \listoflistings - { - \if@twocolumn - \@restonecoltrue\onecolumn - \bool_if:NT \l__multoc_bool{\twocolumn} - \else - \@restonecolfalse - \bool_if:NT \l__multoc_bool{\twocolumn} - \fi - \__title_mark_intoc:n {\lstlistlistingname} + \__ifmultoc_after_set: + \group_end: + } +\NewDocumentCommand{\listoflistings}{so} + { + \group_begin: + \IfValueT {#2}{\keys_set:nn {listoc}{#2}} + \__ifmultoc_pre_set: + \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} - \if@restonecol - \twocolumn - \else - \onecolumn - \fi + \__ifmultoc_after_set: + \group_end: } \makeindex[ @@ -627,9 +661,9 @@ ] \indexsetup { - level = \chapter*, - toclevel = chapter, - firstpagestyle = plain + level = \bool_if:NTF \l__class_book_bool{\chapter*}{\section*}, + toclevel = \bool_if:NTF \l__class_book_bool{chapter}{section}, + firstpagestyle = \bool_if:NTF \l__class_book_bool{plain}{fancy} } \__patch_cmd:Nnn \imki@indexheaders {\@mkboth{\MakeUppercase\indexname}{\MakeUppercase\indexname}} @@ -640,7 +674,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, @@ -682,13 +716,46 @@ \captionsetup[figure][bi-second]{name = Figure} \captionsetup[table][bi-second]{name = Table} \cs_new:Npn \__arabic:n #1{\int_to_arabic:v {c@#1}} -\AtBeginDocument +\cs_new_protected:Npn \__separator_set:n #1 { - \bool_if:NT \l__capdash_bool + \cs_set:cpn {the#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}} + \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 +1161,22 @@ } \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}} + \__ifmultoc_pre_set: + \cs_set:Npn \bibsection + { + \IfBooleanTF {##1} + {\__title_mark:n {\bibname}} + {\__title_mark_intoc:n {\bibname}} + } + \exp_args:NV \bibliography\l__bib_file_tl + \__ifmultoc_after_set: + \group_end: + } } \cs_new_protected:Npn \__put_biblatex:n #1 {\PassOptionsToPackage{#1}{biblatex}} @@ -1119,7 +1198,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 -- cgit v1.2.3