From 6da255ad9866692554851503a48c7bd5f5183f13 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 13 Jan 2021 22:14:08 +0000
Subject: easybook (13jan21)

git-svn-id: svn://tug.org/texlive/trunk@57413 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/easybook/easybook.cls | 380 +++++++++++++---------
 1 file changed, 231 insertions(+), 149 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/easybook/easybook.cls')

diff --git a/Master/texmf-dist/tex/latex/easybook/easybook.cls b/Master/texmf-dist/tex/latex/easybook/easybook.cls
index 3102ff922fa..5806182a9e7 100644
--- a/Master/texmf-dist/tex/latex/easybook/easybook.cls
+++ b/Master/texmf-dist/tex/latex/easybook/easybook.cls
@@ -9,7 +9,7 @@
 %%   https://creativecommons.org/licenses/by/4.0/legalcode
 \NeedsTeXFormat{LaTeX2e}
 \RequirePackage{l3keys2e}
-\ProvidesExplClass{easybook}{2021/01/12}{v1.21b}{}
+\ProvidesExplClass{easybook}{2021/01/13}{v1.21c}{}
 
 \cs_generate_variant:Nn \keys_define:nn {nx}
 \cs_generate_variant:Nn \int_to_arabic:n {v}
@@ -28,7 +28,6 @@
 \bool_set_false:N \l__myfont_bool
 \bool_set_true:N  \l__zhtitle_bool
 \bool_set_true:N  \l__lang_chinese_bool
-\bool_set_true:N  \l__paper_afour_bool
 \bool_set_true:N  \l__page_twoside_bool
 \clist_new:N      \g__options_clist
 
@@ -64,10 +63,9 @@
 
     paper         .choice:,
     paper         .value_required:n = true,
-    paper/a4      .code:n = {},
-    paper/b5      .code:n =
-      {\bool_set_false:N \l__paper_afour_bool},
-    paper         .initial:n = a4,
+    paper/unknown .code:n =
+      {\PassOptionsToPackage{#1}{geometry}},
+    paper         .initial:n = a4paper,
 
     oneside       .value_forbidden:n = true,
     twoside       .value_forbidden:n = true,
@@ -95,13 +93,12 @@
 \LoadClass[UTF8]{ctexbook}
 
 \bool_set_true:N \l__backend_bibtex_bool
-\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
-\bool_new:N   \l__foot_perpage_bool
-\clist_new:N  \l__hyperref_clist
-\tl_new:N     \g__config_tl
+\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
+\bool_new:N \l__foot_perpage_bool
+\tl_new:N   \g__config_tl
 
 \ctex_define:n
   {
@@ -111,6 +108,9 @@
     elfont              .meta:nn = {ctex/elfont}{#1},
     bibset              .meta:nn = {ctex/bibset}{#1},
     thmset              .meta:nn = {ctex/thmset}{#1},
+    geoset              .meta:nn = {ctex/geoset}{#1},
+    hdrset              .meta:nn = {ctex/hdrset}{#1},
+    tocset              .meta:nn = {ctex/tocset}{#1},
     config              .tl_set:N = \g__config_tl,
     lstlistlistingname  .tl_set:N = \lstlistlistingname,
     lstlistingname      .tl_set:N = \lstlistingname
@@ -218,7 +218,7 @@
   {\__set_zhfont_kaishu:nn {#1}{\__option_zhfont:}}
 \cs_new_protected:Npx \__set_zhfont_fangsong:n #1
   {\__set_zhfont_fangsong:nn {#1}{\__option_zhfont:}}
-  
+
 \bool_if:NT \l__myfont_bool
   {
     \__setmainfont:nn {NotoSerif}
@@ -260,35 +260,30 @@
   }
 \cs_if_exist:NF \kaishu{\cs_gset_eq:NN \kaishu\normalfont}
 
-\bool_if:NTF \l__paper_afour_bool
+\clist_new:N \g__geometry_clist
+\__ctex_define:n {geoset}
   {
-    \geometry
+    unknown .code:n =
       {
-        a4paper,
-        columnsep = 2\ccwd,
-        vmargin = 2.54cm,
-        hmargin = 3.17cm,
-        headheight = 2.04cm,
-        headsep = 0.5cm,
-        footskip = 0.79cm,
-        footnotesep = 0.5cm,
-        marginparsep = 8pt,
-        marginparwidth = 2.54cm
-      }
-  }{
-    \geometry
-      {
-        b5paper,
-        columnsep = 2\ccwd,
-        margin = 2.54cm,
-        headheight = 2.09cm,
-        headsep = 0.45cm,
-        footskip = 0.7cm,
-        footnotesep = 0.45cm,
-        marginparsep = 0.25cm,
-        marginparwidth = 2.25cm
+        \clist_gput_right:Nx \g__geometry_clist
+          {
+            \l_keys_key_str
+            \tl_if_empty:NF \l_keys_value_tl{ = {#1}}
+          }
       }
   }
+\geometry
+  {
+    vmargin = 2.54cm,
+    hmargin = 3.17cm,
+    columnsep = 2\ccwd,
+    headheight = 2.04cm,
+    headsep = 0.5cm,
+    footskip = 0.79cm,
+    footnotesep = 0.5cm,
+    marginparsep = 8pt,
+    marginparwidth = 2.54cm
+  }
 
 \cs_gset:Npn \cleardoublepage
   {
@@ -305,127 +300,214 @@
     \@mainmatterfalse
     \pagenumbering{Roman}
   }
-\pagestyle{fancy}
-\fancyhf{}
-\bool_if:NTF \l__page_twoside_bool
+
+\__ctex_define:n {hdrset}
+  {
+    elhead  .tl_set:N = \l__fancyhead_EL_tl,
+    elhead  .initial:n = \color{ctex@frame}\thepage,
+    echead  .tl_set:N = \l__fancyhead_EC_tl,
+    echead  .initial:n = \color{ctex@frame}\kaishu\leftmark,
+    erhead  .tl_set:N = \l__fancyhead_ER_tl,
+    erhead  .initial:n = {},
+    olhead  .tl_set:N = \l__fancyhead_OL_tl,
+    olhead  .initial:n = {},
+    ochead  .tl_set:N = \l__fancyhead_OC_tl,
+    ochead  .initial:n = \color{ctex@frame}\kaishu\rightmark,
+    orhead  .tl_set:N = \l__fancyhead_OR_tl,
+    orhead  .initial:n = \color{ctex@frame}\thepage,
+    elfoot  .tl_set:N = \l__fancyfoot_EL_tl,
+    elfoot  .initial:n = {},
+    ecfoot  .tl_set:N = \l__fancyfoot_EC_tl,
+    ecfoot  .initial:n = {},
+    erfoot  .tl_set:N = \l__fancyfoot_ER_tl,
+    erfoot  .initial:n = {},
+    olfoot  .tl_set:N = \l__fancyfoot_OL_tl,
+    olfoot  .initial:n = {},
+    ocfoot  .tl_set:N = \l__fancyfoot_OC_tl,
+    ocfoot  .initial:n = {},
+    orfoot  .tl_set:N = \l__fancyfoot_OR_tl,
+    orfoot  .initial:n = {}
+  }
+
+\ctex_at_end_preamble:n
   {
-    \cs_gset:Npn \chaptermark#1
+    \exp_args:NV \geometry\g__geometry_clist
+    \pagestyle{fancy}
+    \fancyhf{}
+    \bool_if:NTF \l__page_twoside_bool
       {
-        \markboth
+        \cs_gset:Npn \chaptermark#1
           {
-            \MakeUppercase
+            \markboth
               {
-                \ifnum\c@secnumdepth>\m@ne
-                  \if@mainmatter
-                    \ifodd\CTEX@chapter@numbering
-                      \CTEXthechapter\hspace{\ccwd}
-                    \fi
-                  \fi
-                \fi#1
+                \MakeUppercase
+                  {
+                    \ifnum\c@secnumdepth>\m@ne
+                      \if@mainmatter
+                        \ifodd\CTEX@chapter@numbering
+                          \CTEXthechapter\hspace{\ccwd}
+                        \fi
+                      \fi
+                    \fi#1
+                  }
+              }{
+                \MakeUppercase
+                  {
+                    \ifnum\c@secnumdepth>\m@ne
+                      \if@mainmatter
+                        \ifodd\CTEX@chapter@numbering
+                          \CTEXthechapter\hspace{\ccwd}
+                        \fi
+                      \fi
+                    \fi#1
+                  }
               }
-          }{
-            \MakeUppercase
+          }
+        \fancyhead[EL]{\l__fancyhead_EL_tl}
+        \fancyhead[EC]{\l__fancyhead_EC_tl}
+        \fancyhead[ER]{\l__fancyhead_ER_tl}
+        \fancyhead[OL]{\l__fancyhead_OL_tl}
+        \fancyhead[OC]{\l__fancyhead_OC_tl}
+        \fancyhead[OR]{\l__fancyhead_OR_tl}
+        \fancyfoot[EL]{\l__fancyfoot_EL_tl}
+        \fancyfoot[EC]{\l__fancyfoot_EC_tl}
+        \fancyfoot[ER]{\l__fancyfoot_ER_tl}
+        \fancyfoot[OL]{\l__fancyfoot_OL_tl}
+        \fancyfoot[OC]{\l__fancyfoot_OC_tl}
+        \fancyfoot[OR]{\l__fancyfoot_OR_tl}
+        \cs_gset_eq:NN \ps@plain\ps@empty
+      }{
+        \cs_gset:Npn \chaptermark#1
+          {
+            \markboth
               {
-                \ifnum\c@secnumdepth>\m@ne
-                  \if@mainmatter
-                    \ifodd\CTEX@chapter@numbering
-                      \CTEXthechapter\hspace{\ccwd}
-                    \fi
-                  \fi
-                \fi#1
-              }
+                \MakeUppercase
+                  {
+                    \ifnum\c@secnumdepth>\m@ne
+                      \if@mainmatter
+                        \ifodd\CTEX@chapter@numbering
+                          \CTEXthechapter\hspace{\ccwd}
+                        \fi
+                      \fi
+                    \fi#1
+                  }
+              }{}
           }
+        \fancyhead[L]{\l__fancyhead_OL_tl}
+        \fancyhead[C]{\l__fancyhead_OC_tl}
+        \fancyhead[R]{\l__fancyhead_OR_tl}
+        \fancyfoot[L]{\l__fancyfoot_OL_tl}
+        \fancyfoot[C]{\l__fancyfoot_OC_tl}
+        \fancyfoot[R]{\l__fancyfoot_OR_tl}
+        \cs_gset_eq:NN \ps@plain\ps@empty
       }
-    \fancyhead[EC]{\color{ctex@frame}\kaishu\leftmark}
-    \fancyhead[OC]{\color{ctex@frame}\kaishu\rightmark}
-    \fancyhead[EL,OR]{\color{ctex@frame}\thepage}
-    \cs_gset_eq:NN \ps@plain\ps@empty
-  }{
-    \cs_gset:Npn \chaptermark#1
+    \cs_gset:Npn \sectionmark#1
       {
-        \markboth
+        \markright
           {
-            \MakeUppercase
-              {
-                \ifnum\c@secnumdepth>\m@ne
-                  \if@mainmatter
-                    \ifodd\CTEX@chapter@numbering
-                      \CTEXthechapter\hspace{\ccwd}
-                    \fi
-                  \fi
-                \fi#1
-              }
-          }{}
+            \ifnum\c@secnumdepth>\z@
+              \ifodd\CTEX@section@numbering
+                \CTEXthesection\hspace{0.5\ccwd}
+              \fi
+            \fi#1
+          }
       }
-    \fancyhead[L]{\color{ctex@frame}\kaishu\leftmark}
-    \fancyhead[R]{\color{ctex@frame}\kaishu\rightmark}
-    \fancyfoot[C]{\color{ctex@frame}\thepage}
-    \fancypagestyle{plain}
+    \cs_gset:Npn \headrule
       {
-        \fancyhf{}\cs_set:Npn \headrule{}
-        \fancyfoot[C]{\color{ctex@frame}\thepage}
+        \color{ctex@frame}\vspace{2.5pt}
+        \hrule width\textwidth height 0.75pt
       }
-  }
-\cs_gset:Npn \sectionmark#1
-  {
-    \markright
+    \bool_if:NT \l__draft_bool
       {
-        \ifnum\c@secnumdepth>\z@
-          \ifodd\CTEX@section@numbering
-            \CTEXthesection\hspace{0.5\ccwd}
-          \fi
-        \fi#1
+        \bool_if:NTF \l__page_twoside_bool
+          {\fancyfoot[C]{\color{gray!60}\sffamily\today}}
+          {\fancyhead[L]{\color{gray!60}\sffamily\today}}
+        \geometry{showframe}
       }
   }
-\cs_gset:Npn \headrule
+
+\ctex_define:n
   {
-    \color{ctex@frame}\vspace{2.5pt}
-    \hrule width\textwidth height 0.75pt
+    tocset/part       .meta:nn = {ctex/tocset/part}{#1},
+    tocset/chapter    .meta:nn = {ctex/tocset/chapter}{#1},
+    tocset/section    .meta:nn = {ctex/tocset/section}{#1},
+    tocset/subsection .meta:nn = {ctex/tocset/subsection}{#1},
+    tocset/list       .meta:nn = {ctex/tocset/list}{#1},
   }
-\bool_if:NT \l__draft_bool
+\__ctex_define:n {tocset}
   {
-    \bool_if:NTF \l__page_twoside_bool
-      {\fancyfoot[C]{\color{gray!60}\sffamily\today}}
-      {\fancyhead[C]{\color{gray!60}\sffamily\today}}
-    \geometry{showframe}
+    part/format       .tl_set:N = \l__toc_part_format_tl,
+    part/format       .initial:n = 
+      {\addvspace{1pc}\sffamily\large},
+    part/indent       .tl_set:N = \l__toc_part_indent_tl,
+    part/indent       .initial:n = 0\ccwd,
+    part/rule         .tl_set:N = \l__toc_part_rule_tl,
+    part/rule         .initial:n = \tocrule{}[\bfseries],
+
+    chapter/format    .tl_set:N = \l__toc_chap_format_tl,
+    chapter/format    .initial:n =
+      {\addvspace{1pc}\sffamily\large},
+    chapter/indent    .tl_set:N = \l__toc_chap_indent_tl,
+    chapter/indent    .initial:n = 0\ccwd,
+    chapter/rule      .tl_set:N = \l__toc_chap_rule_tl,
+    chapter/rule      .initial:n = \tocrule{$\cdot$}[\bfseries],
+
+    section/format    .tl_set:N = \l__toc_sec_format_tl,
+    section/format    .initial:n = \addvspace{0.35pc},
+    section/indent    .tl_set:N = \l__toc_sec_indent_tl,
+    section/indent    .initial:n = 1.5\ccwd,    
+    section/rule      .tl_set:N = \l__toc_sec_rule_tl,
+    section/rule      .initial:n = \tocrule{$\cdot$},
+
+    subsection/format .tl_set:N = \l__toc_subsec_format_tl,
+    subsection/forma  .initial:n = \addvspace{0.35pc},
+    subsection/indent .tl_set:N = \l__toc_subsec_indent_tl,
+    subsection/indent .initial:n = 3.8\ccwd,
+    subsection/rule   .tl_set:N = \l__toc_subsec_rule_tl,
+    subsection/rule   .initial:n = \tocrule{$\cdot$},
+
+    lists/format      .tl_set:N = \l__toc_lists_format_tl,
+    lists/format      .initial:n = \addvspace{0.2pc},
+    lists/indent      .tl_set:N = \l__toc_lists_indent_tl,
+    lists/indent      .initial:n = 0\ccwd,
+    lists/rule        .tl_set:N = \l__toc_lists_rule_tl,
+    lists/rule        .initial:n = \tocrule{$\cdot$}
   }
 
+\NewDocumentCommand{\tocrule}{O{0.7pc}O{1.2}mO{}}
+  {
+    \normalsize\normalfont
+    \titlerule*[#1]{\scalebox{#2}{#3}}#4\contentspage
+  }
 \titlecontents{part}
-  [0\ccwd]
-  {\addvspace{1pc}\sffamily\large}
-  {}{}
-  {\normalsize\titlerule*{}\bf\contentspage}
+  [\l__toc_part_indent_tl]
+  {\l__toc_part_format_tl}{}{}
+  {\l__toc_part_rule_tl}
 \titlecontents{chapter}
-  [0\ccwd]
-  {\addvspace{1pc}\sffamily\large}
-  {}{}
-  {\normalsize\titlerule*[0.65pc]{\scalebox{1.2}{$\cdot$}}\bf\contentspage}
+  [\l__toc_chap_indent_tl]
+  {\l__toc_chap_format_tl}{}{}
+  {\l__toc_chap_rule_tl}
 \titlecontents{section}
-  [1.5\ccwd]
-  {\addvspace{0.35pc}}
-  {}{}
-  {\titlerule*[0.65pc]{\scalebox{1.2}{$\cdot$}}\contentspage}
+  [\l__toc_sec_indent_tl]
+  {\l__toc_sec_format_tl}{}{}
+  {\l__toc_sec_rule_tl}
 \titlecontents{subsection}
-  [3.8\ccwd]
-  {\addvspace{0.35pc}}
-  {}{}
-  {\titlerule*[0.65pc]{\scalebox{1.2}{$\cdot$}}\contentspage}
+  [\l__toc_subsec_indent_tl]
+  {\l__toc_subsec_format_tl}{}{}
+  {\l__toc_subsec_rule_tl}
 \titlecontents{figure}
-  [0\ccwd]
-  {\addvspace{0.2pc}}
-  {}{}
-  {\titlerule*[0.65pc]{\scalebox{1.2}{$\cdot$}}\contentspage}
+  [\l__toc_lists_indent_tl]
+  {\l__toc_lists_format_tl}{}{}
+  {\l__toc_lists_rule_tl}
 \titlecontents{table}
-  [0\ccwd]
-  {\addvspace{0.2pc}}
-  {}{}
-  {\titlerule*[0.65pc]{\scalebox{1.2}{$\cdot$}}\contentspage}
+  [\l__toc_lists_indent_tl]
+  {\l__toc_lists_format_tl}{}{}
+  {\l__toc_lists_rule_tl}
 \contentsuse{lstlisting}{lol}
 \titlecontents{lstlisting}
-  [0\ccwd]
-  {\addvspace{0.2pc}}
-  {}{}
-  {\titlerule*[0.65pc]{\scalebox{1.2}{$\cdot$}}\contentspage}
+  [\l__toc_lists_indent_tl]
+  {\l__toc_lists_format_tl}{}{}
+  {\l__toc_lists_rule_tl}
 \ctex_patch_cmd:Nnn \caption@@@addcontentsline
   {\addcontentsline{#1}{#2}{\protect\numberline{#3}{#4}}}
   {\addcontentsline{#1}{#2}{#3\hspace{\ccwd}#4}}
@@ -951,6 +1033,7 @@
     backend/bibtex      .code:n = {},
     backend/biblatex    .code:n =
       {\bool_set_false:N \l__backend_bibtex_bool},
+
     bibstyle            .choice:,
     bibstyle            .value_required:n = true,
     bibstyle/number     .code:n =
@@ -966,6 +1049,7 @@
     bibstyle/unknown    .code:n =
       {\tl_set_eq:NN \l__bib_mysty_tl\l_keys_value_tl},
     bibstyle            .initial:n = number,
+
     citestyle           .code:n =
       {\tl_set:Nn \l__bib_citesty_tl{#1}},
     bibfile             .tl_set:N = \l__bib_file_tl,
@@ -976,14 +1060,14 @@
   {
     \tl_if_empty:NTF \l__bib_mysty_tl
       {
-        \tl_if_eq:VnTF \l__bib_style_tl{numerber}
+        \tl_if_eq:VnT \l__bib_style_tl{number}
           {
             \bibliographystyle{gbt7714-numerical}
-          }{
-            \tl_if_eq:VnT \l__bib_style_tl{authoryear}
-              {\bibliographystyle{gbt7714-author-year}}
-            \cs_set_eq:NN \cite\citep
+            \setcitestyle{square,comma,super}
           }
+        \tl_if_eq:VnT \l__bib_style_tl{authoryear}
+          {\bibliographystyle{gbt7714-author-year}}
+        \cs_set_eq:NN \cite\citep
       }{
         \exp_args:NV \bibliographystyle\l__bib_mysty_tl
       }
@@ -998,13 +1082,10 @@
   {
     \tl_if_empty:NTF \l__bib_mysty_tl
       {
-        \tl_if_eq:VnTF \l__bib_style_tl{number}
-          {
-            \__put_biblatex:n {style = gb7714-2015}
-          }{
-            \tl_if_eq:VnT \l__bib_style_tl{authoryear}
-              {\__put_biblatex:n {style = gb7714-2015ay}}
-          }
+        \tl_if_eq:VnT \l__bib_style_tl{number}
+          {\__put_biblatex:n {style = gb7714-2015}}
+        \tl_if_eq:VnT \l__bib_style_tl{authoryear}
+          {\__put_biblatex:n {style = gb7714-2015ay}}
       }{
         \__put_biblatex:n {style = \l__bib_mysty_tl}
       }
@@ -1021,7 +1102,7 @@
   {
     \bool_if:NTF \l__backend_bibtex_bool
       {
-        \RequirePackage[sort&compress]{gbt7714}
+        \RequirePackage[sort&compress]{natbib}
         \__bibtex_set:
       }{
         \__biblatex_pre_set:
@@ -1107,7 +1188,8 @@
 \lstloadlanguages{C,C++,Java,Python,Matlab}
 \AtBeginEnvironment{verbatim}{\microtypesetup{activate=false}}
 
-\cs_new_protected:Npn \__clist_put_hyperref:n #1
+\clist_new:N \l__hyperref_clist
+\cs_new_protected:Npn \__put_hyperref:n #1
   {\clist_put_right:Nn \l__hyperref_clist{#1}}
 \cs_new_protected:Npn \__define_linkcolor:nnn #1#2#3
   {\definecolorset{HTML}{ctex@}{}{link,#1;url,#2;cite,#3}}
@@ -1121,7 +1203,7 @@
           {\clist_item:nn {#1}{2}}
           {\clist_item:nn {#1}{3}}
           {\clist_item:nn {#1}{4}}
-        \__clist_put_hyperref:n
+        \__put_hyperref:n
           {
             linkcolor = ctex@link,linkbordercolor = ctex@link,
             urlcolor = ctex@url,urlbordercolor = ctex@url,
@@ -1154,8 +1236,8 @@
   {
     hyperlink         .choice:,
     hyperlink/edge    .code:n = {},
-    hyperlink/various .code:n = {\__clist_put_hyperref:n {colorlinks}},
-    hyperlink/none    .code:n = {\__clist_put_hyperref:n {hidelinks}},
+    hyperlink/various .code:n = {\__put_hyperref:n {colorlinks}},
+    hyperlink/none    .code:n = {\__put_hyperref:n {hidelinks}},
     hyperlink         .default:n = edge,
     hyperlink         .initial:n = edge,
 
@@ -1172,7 +1254,7 @@
     linkcolor         .initial:n = graphite,
 
     linktopage        .choice:,
-    linktopage/true   .code:n = {\__clist_put_hyperref:n {linktocpage}},
+    linktopage/true   .code:n = {\__put_hyperref:n {linktocpage}},
     linktopage/false  .code:n = {},
     linktopage        .default:n = true,
     linktopage        .initial:n = false
-- 
cgit v1.2.3

