diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/easybook/easybase.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/easybook/easybase.sty | 244 |
1 files changed, 128 insertions, 116 deletions
diff --git a/Master/texmf-dist/tex/latex/easybook/easybase.sty b/Master/texmf-dist/tex/latex/easybook/easybase.sty index 0a2be5abd09..9644680bda2 100644 --- a/Master/texmf-dist/tex/latex/easybook/easybase.sty +++ b/Master/texmf-dist/tex/latex/easybook/easybase.sty @@ -13,8 +13,8 @@ %% https://creativecommons.org/licenses/by/4.0/legalcode \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{etoolbox} -\ProvidesExplPackage{easybase}{2021/07/06}{1.26u} - {Typeset Chinese books or notes} +\ProvidesExplPackage{easybase}{2021/07/06}{1.26x} + {Typeset Chinese theses or books} \cs_generate_variant:Nn \eb_ctex_define:nn { nx } \cs_generate_variant:Nn \int_to_arabic:n { v } @@ -62,28 +62,28 @@ \eb_clist_map_inline:nn {#1} { \AtBeginEnvironment{##1}{#2} } } -\cs_new_protected:Npn \eb_match_package_name:n #1 +\cs_new_protected:Npn \eb_match_load_package:n #1 { \tl_if_in:nnTF {#1} { [ } { - \regex_split:nnNT { \[ } {#1} \l_tmpa_seq - { \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl } - \@ifpackageloaded{\l_tmpa_tl}{} + \seq_set_split:Nnn \l_tmpa_seq { [ } {#1} + \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl + \IfFileExists{\l_tmpa_tl.sty} { \exp_last_unbraced:Nx \RequirePackage { [\seq_use:Nn \l_tmpa_seq { , } }{\l_tmpa_tl} - } + }{} } - { \@ifpackageloaded{#1}{}{\RequirePackage{#1}} } + { \IfFileExists{#1.sty}{\RequirePackage{#1}}{} } } -\NewDocumentCommand{\eb@package@load}{O{}m} +\NewDocumentCommand{\LoadPackage}{O{}m} { - \seq_set_split:Nnn \l__eb_package_name_seq { + } {#2} + \seq_set_split:Nnn \l__eb_package_names_seq { + } {#2} \int_compare:oNnT - { \seq_count:N \l__eb_package_name_seq } = { 1 } + { \seq_count:N \l__eb_package_names_seq } = { 1 } { \PassOptionsToPackage{#1}{#2} } \seq_map_function:NN - \l__eb_package_name_seq \eb_match_package_name:n + \l__eb_package_names_seq \eb_match_load_package:n } \cs_new_protected:Npn \eb_at_end_preamble:n { \BeforeBeginEnvironment{document} } @@ -98,11 +98,10 @@ \keys_define:nn { easybase } { - draft .code:n = - { \bool_set_true:N \l__eb_compile_draft_bool }, - floatpage .bool_set:N = \l__eb_float_page_bool, - floatpage .default:n = true, - floatpage .initial:n = false, + draft .code:n = \bool_set_true:N \l__eb_compile_draft_bool, + floatpage .bool_set:N = \l__eb_float_page_bool, + floatpage .default:n = true, + floatpage .initial:n = false, paper .choice:, paper .value_required:n = true, @@ -117,7 +116,9 @@ \bool_set_false:N \l__eb_class_book_bool \bool_set_false:N \l__eb_page_twoside_bool }, - class .initial:n = book + class .initial:n = book, + book .meta:n = { class = #1 }, + article .meta:n = { class = #1 } } \clist_map_inline:nn @@ -187,32 +188,10 @@ uppercase .bool_set:N = \l__eb_mark_uppercase_bool, uppercase .default:n = true, uppercase .initial:n = true, - figurepath .tl_set:N = \l_eb_graphics_path_tl, - - footwith .choices:nn = - { part,page,chapter } - { - \tl_set_eq:NN - \l__eb_foot_counter_parent_choice_tl \l_keys_choice_tl - }, - footwith .value_required:n = true, - footwith .initial:n = chapter, - - figure-con .tl_set:N = \l__eb_figure_connector_tl, - table-con .tl_set:N = \l__eb_table_connector_tl, - listing-con .tl_set:N = \l__eb_lstlisting_connector_tl, - equation-con .tl_set:N = \l__eb_equation_connector_tl, - number-con .meta:n = - { - figure-con = #1, - table-con = #1, - listing-con = #1, - equation-con = #1 - }, - number-con .initial:n = { . } + figurepath .tl_set:N = \l_eb_graphics_path_tl } -\eb@package@load +\LoadPackage { footmisc[stable,bottom]+ spbmark[ctex]+ @@ -227,9 +206,9 @@ setspace+ listings } -\cs_new_protected:Npn \eb_package_later_bool:nn #1#2 +\cs_new_protected:Npn \eb_package_date_check:nn #1#2 { - \@ifpackagelater{#1}{#2} + \IfPackageAtLeastTF{#1}{#2} {}{\msg_warning:nnn { easybase } { package-old } {#1}} } \msg_new:nnn { easybase } { package-old } @@ -247,9 +226,10 @@ { thmtools } { 2020/08/01 }, { caption } { 2020/08/24 }, { fancyhdr } { 2021/01/28 }, - { siunitx } { 2021/06/22 } + { siunitx } { 2021/06/22 }, + { tabularray } { 2021/07/01 } } - { \eb_package_later_bool:nn #1 } + { \eb_package_date_check:nn #1 } \includepdfset{fitpaper = true} \geometry @@ -422,7 +402,7 @@ { \bool_if:NTF \l__eb_mark_uppercase_bool { \eb_mark_uppercase:n } - { \eb_mark_nouppercase:n }{\use:c { eb_fancyhf_#1_mark:n } {#2}} + { \eb_mark_nouppercase:n } { \use:c { eb_fancyhf_#1_mark:n } {#2} } } \cs_new:Npn \eb@level@markdouble #1#2 { @@ -466,6 +446,17 @@ \cs_if_exist:NF \kaishu { \cs_gset_eq:NN \kaishu \itshape } } +\eb_ctex_define:nn { style } + { + footwith .choices:nn = + { part,page,chapter } + { + \tl_set_eq:NN + \l__eb_foot_counter_parent_choice_tl \l_keys_choice_tl + }, + footwith .value_required:n = true, + footwith .initial:n = chapter + } \eb_at_end_preamble:n { \group_begin: @@ -492,6 +483,8 @@ \selectfont\ignorespaces \l__eb_subfont_footnote_tl } +\providecommand{\super}{\textsuperscript} +\providecommand{\spb@textsuperscript@save}{\textsuperscript} \ctex_after_end_preamble:n { \ExplSyntaxOn\char_set_catcode_letter:N \@ @@ -581,14 +574,19 @@ } } -\cs_new:Npn \EBNumberLine #1 +\cs_set:Npn \CTEXnumberline #1 { \CTEXifname { - \use:c { CTEXthe#1 } - \hspace{\use:c { eb@toc@#1@numsep }} + \ifbool{eb@titletoc@hang@fix} + { \protect\numberline{\use:c { CTEXthe#1 }} } + { + \use:c { CTEXthe#1 } + \hspace{\use:c { eb@toc@#1@numsep }} + } }{} } +\cs_set_eq:NN \EBNumberLine \CTEXnumberline \newbool{eb@titletoc@hang@fix} \eb_ctex_define:nn { tocset } { @@ -624,25 +622,8 @@ }, hang .choice:, - hang/true .code:n = - { - \booltrue{eb@titletoc@hang@fix} - \ctex_set:n - { - chapter/tocline = \CTEXnumberline{##1}##2, - section/tocline = \CTEXnumberline{##1}##2, - subsection/tocline = \CTEXnumberline{##1}##2 - } - }, - hang/false .code:n = - { - \ctex_set:n - { - chapter/tocline = \EBNumberLine{##1}##2, - section/tocline = \EBNumberLine{##1}##2, - subsection/tocline = \EBNumberLine{##1}##2 - } - }, + hang/true .code:n = \booltrue{eb@titletoc@hang@fix}, + hang/false .code:n = { }, hang .default:n = true, hang .initial:n = false, @@ -672,6 +653,13 @@ list/rule = #1 } } +\ctex_set:n + { + part/tocline = \CTEXnumberline{#1}#2, + chapter/tocline = \CTEXnumberline{#1}#2, + section/tocline = \CTEXnumberline{#1}#2, + subsection/tocline = \CTEXnumberline{#1}#2 + } \NewDocumentCommand{\tocrule}{sO{0.7pc}D(){1.2}mO{}} { @@ -752,7 +740,7 @@ \tl_use:c { the#1 } } } -\NewDocumentCommand{\EBUseCounter}{soD(){arabic}mmO{.}d()} +\NewDocumentCommand{\UseCounter}{soD(){arabic}mmO{.}d()} { \IfBooleanF{#1}{\stepcounter{#4}} \IfValueT{#7}{\setcounter{#4}{#7}} @@ -775,22 +763,10 @@ \cs_set:Npn \thebisection { \eb_section_counter_prefix:n { bi } } \cs_set:Npn \thebisubsection { \thebisection.\eb_arabic:n { bisubsection } } \cs_set:Npn \thesection { \eb_section_counter_prefix:n { } } -\eb_clist_map_inline:nn - { figure,table,lstlisting,equation } - { - \cs_set:cpn { the#1 } - { - \int_compare:nNnT { \c@chapter } > { 0 } - { - \thechapter - \tl_use:c { l__eb_#1_connector_tl } - } - \eb_arabic:n {#1} - } - } + \contentsuse{}{tec} \tl_new:N \eb@before@addbitoc@hook -\NewDocumentCommand{\EBeforeAddBitoc}{sm} +\NewDocumentCommand{\BeforeAddBitoc}{sm} { \IfBooleanTF{#1} {\tl_gset:Nn \eb@before@addbitoc@hook {#2}} @@ -842,6 +818,35 @@ } } +\eb_ctex_define:nn { style } + { + figure-con .tl_set:N = \l__eb_figure_connector_tl, + table-con .tl_set:N = \l__eb_table_connector_tl, + listing-con .tl_set:N = \l__eb_lstlisting_connector_tl, + equation-con .tl_set:N = \l__eb_equation_connector_tl, + number-con .meta:n = + { + figure-con = #1, + table-con = #1, + listing-con = #1, + equation-con = #1 + }, + number-con .initial:n = { . } + } +\eb_clist_map_inline:nn + { figure,table,lstlisting,equation } + { + \cs_set:cpn { the#1 } + { + \int_compare:nNnT { \c@chapter } > { 0 } + { + \thechapter + \tl_use:c { l__eb_#1_connector_tl } + } + \eb_arabic:n {#1} + } + } + \tl_set:Nx \l__eb_toc_type_tl { \bool_if:NTF \l__eb_class_book_bool { chapter } { section } } \tl_new:N \eb@bitoc@title @@ -1093,7 +1098,7 @@ { scholax } { \eb_put_newtxmath:n { nc,noOT1 } } { charter } { \eb_put_newtxmath:n { charter,noOT1 } } } - { \eb@package@load{newtxmath+bm} } + { \LoadPackage{newtxmath+bm} } } \fp_new:N \l__eb_spread_line_fp @@ -1154,14 +1159,17 @@ \captionsetup[figure][bi-second]{name = Figure} \captionsetup[table][bi-second]{name = Table} } -\SetTblrDefault +\IfPackageAtLeastTF{tabularray}{2021/07/01} { - rows = {abovesep = 4pt,belowsep = 2pt}, - stretch = \fp_use:N \l__eb_spread_table_fp - } -\NewTableCommand{\toprule}[1][1pt]{\hline[#1]} -\NewTableCommand{\midrule}[1][0.5pt]{\hline[#1]} -\NewTableCommand{\bottomrule}[1][1pt]{\hline[#1]} + \SetTblrInner + { + rows = {abovesep = 4pt,belowsep = 2pt}, + stretch = \fp_use:N \l__eb_spread_table_fp + } + \NewTableCommand{\toprule}[1][1pt]{\hline[#1]} + \NewTableCommand{\midrule}[1][0.5pt]{\hline[#1]} + \NewTableCommand{\bottomrule}[1][1pt]{\hline[#1]} + }{} \eb_at_begin_environment:nn { tabular,tabularx } { \exp_args:Nx \linespread { \fp_use:N \l__eb_spread_table_fp } @@ -1240,7 +1248,7 @@ { \tl_const:cn { c__eb_name_#1_tl } {#3} } { \tl_const:cn { c__eb_name_#1_tl } {#2} } } -\NewDocumentCommand{\EBNewTheorem} +\NewDocumentCommand{\DeclareTheorem} {mO{\text_titlecase_first:n {#1}}mD(){tc-theorem}O{}} { \ctex_at_end_preamble:n @@ -1259,6 +1267,7 @@ \labelformat{#1}{\tl_use:c { c__eb_name_#1_tl }~##1} } } +\cs_set_eq:NN \EBNewTheorem \DeclareTheorem \cs_set_eq:NN \eb@declare@theorem@save \declaretheorem \RenewDocumentCommand{\declaretheorem}{O{}m} {\AfterPreamble{\eb@declare@theorem@save[#1]{#2}}} @@ -1335,7 +1344,7 @@ { remark } { 注 } [ numbered = no ], { { proof } { 证明 } [ numbered = no,qed = \qedsymbol ] } } - { \EBNewTheorem #1 } + { \DeclareTheorem #1 } } \setchemformula @@ -1344,19 +1353,22 @@ charge-hshift = 0.25\ccwd, subscript-vshift = -0.2ex } -\sisetup +\IfPackageAtLeastTF{siunitx}{2021/06/22} { - mode = match, - table-parse-only, - text-family-to-math, - text-series-to-math, - reset-text-family = false, - reset-text-series = false, - reset-text-shape = false, - range-phrase = \ensuremath{\sim}, - range-units = single, - group-digits = none - } + \sisetup + { + mode = match, + table-parse-only, + text-family-to-math, + text-series-to-math, + reset-text-family = false, + reset-text-series = false, + reset-text-shape = false, + range-phrase = \ensuremath{\sim}, + range-units = single, + group-digits = none + } + }{} \eb_at_begin_environment:nn { array,matrix,pmatrix,bmatrix,Bmatrix,vmatrix,Vmatrix, @@ -1406,7 +1418,7 @@ { \keys_set:nn { eb/exercise } {#1} } \ctex_at_end_package:nn { tcolorbox } { - \eb_package_later_bool:nn { tcolorbox } { 2020/10/09 } + \eb_package_date_check:nn { tcolorbox } { 2020/10/09 } \file_if_exist_input:n { eb-tcolorbox.cfg } } @@ -1447,7 +1459,7 @@ bitoc-title .initial:n = Reference } -\cs_new_protected:Npn \EBibtexSet +\cs_new_protected:Npn \BibtexPostset { \tl_if_empty:NTF \l__eb_bib_otherstyle_tl { @@ -1483,7 +1495,7 @@ } \cs_new_protected:Npn \eb_put_biblatex:n #1 { \PassOptionsToPackage{#1}{biblatex} } -\cs_new_protected:Npn \EBiblatexPreset +\cs_new_protected:Npn \BiblatexPreset { \tl_if_empty:NTF \l__eb_bib_otherstyle_tl { @@ -1497,7 +1509,7 @@ { \eb_put_biblatex:n { citestyle = \l__eb_bib_citestyle_tl } } \eb_put_biblatex:n { backend = biber } } -\cs_new_protected:Npn \EBiblatexPostset +\cs_new_protected:Npn \BiblatexPostset { \clist_map_function:NN \l__eb_bib_datafile_clist \addbibresource \tl_gset:Nn \blx@default@theheading { bibintoc } @@ -1511,13 +1523,13 @@ { \bool_if:NTF \l__eb_backend_bibtex_bool { - \eb@package@load[sort&compress]{natbib} - \EBibtexSet + \LoadPackage[sort&compress]{natbib} + \BibtexPostset } { - \EBiblatexPreset - \eb@package@load{biblatex} - \EBiblatexPostset + \BiblatexPreset + \LoadPackage{biblatex} + \BiblatexPostset } } } @@ -1707,7 +1719,7 @@ } \ctex_at_end_preamble:n { - \eb@package@load{hyperref} + \LoadPackage{hyperref} \urlstyle{same} \eb_allow_urlbreak: \ctex_hypersetup:n { pdfstartview = FitH } |