texlive[61314] Master/texmf-dist: spbmark (15dec21)

commits+karl at tug.org commits+karl at tug.org
Wed Dec 15 22:31:42 CET 2021


Revision: 61314
          http://tug.org/svn/texlive?view=revision&revision=61314
Author:   karl
Date:     2021-12-15 22:31:41 +0100 (Wed, 15 Dec 2021)
Log Message:
-----------
spbmark (15dec21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/spbmark/spbmark.pdf
    trunk/Master/texmf-dist/doc/latex/spbmark/spbmark.tex
    trunk/Master/texmf-dist/tex/latex/spbmark/spbmark.sty

Modified: trunk/Master/texmf-dist/doc/latex/spbmark/spbmark.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/spbmark/spbmark.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/spbmark/spbmark.tex	2021-12-15 21:31:28 UTC (rev 61313)
+++ trunk/Master/texmf-dist/doc/latex/spbmark/spbmark.tex	2021-12-15 21:31:41 UTC (rev 61314)
@@ -6,8 +6,8 @@
   {
     package           = spbmark,
     title             = the spbmark package,
-    version           = v1.1J,
-    date              = 2021/11/10,
+    version           = v1.2,
+    date              = 2021/12/15,
     authors           = Qu Yi,
     info              = Customize superscript and subscript,
     email             = q1jx at foxmail.com,
@@ -61,90 +61,101 @@
 \section{User commands}
 There are currently three commands to set superscript and subscript. Their format can be set temporarily using the optional parameters of the command, or set globally using a key-value list, see section \ref{sec:global control interface}.
 \begin{commands}
-  \command{super}[\sarg\oarg{vshift}\splitoarg{height}{depth}\darg{code}\marg{content}\oarg{hshift}]
-  This is a superscript output command. If \meta{vshift} or \meta{hshift} is a positive value, the superscript moves up or to the right, if it's negative, the superscript moves down or to the left.
-  \command{sub}[\sarg\oarg{vshift}\splitoarg{height}{depth}\darg{code}\marg{content}\oarg{hshift}]
-  This is a subscript output command. If \meta{vshift} or \meta{hshift} is a positive value, the subscript moves down or to the right, if it's negative, the subscript moves up or to the left.
-  \command{supersub}[\sarg\oarg{vsep}\darg{align}\marg{sup cont}\marg{sub cont}\oarg{hshift}\splitdarg{sup code}{sub code}]
-  This is a command that outputs both superscript and subscript at the same time. You can also use the shorter command \cs{spb} instead of it. The \meta{vsep} represents the vertical spacing between superscript and subscript, same as option \option{supersubsep}. The parameters of \meta{align} are the same as the \option{supersubalign}.
+  \command{super}[\oarg{kv list}\splitoarg{height}{depth}\marg{content}\oarg{kv list}]
+  This is a superscript output command. The two \meta{kv list} are equivalent.
+  \command{sub}[\oarg{kv list}\splitoarg{height}{depth}\marg{content}\oarg{kv list}]
+  This is a subscript output command. The two \meta{kv list} are equivalent.
+  \command{supersub}[\oarg{kv list}\marg{super cont}\marg{sub cont}\oarg{kv list}]
+  This is a command that outputs both superscript and subscript at the same time. You can also use the shorter command \cs{spb} instead of it. The two \meta{kv list} are equivalent.
 \end{commands}
 
-These commands can match the corresponding pattern depending on whether they are currently in text mode or mathematical mode, or they can use an asterisk variant to force the mathematical pattern. 
-
 The optional parameter \splitmeta{height}{depth} generally does not need to be used. The \meta{height} and \meta{depth} are separated by commas. Only the front part indicates the \meta{height} of the superscript or subscript, and only the back part indicates the \meta{depth}.
 
-The \meta{code} is used to format superscript and subscript, and can insert commands such as fonts or colors. The last command in the code can take an argument, which is either a superscript or a subscript.
+The options common to \meta{kv list} of the three commands are as follows. They can be used in \meta{key-value list} for the \cs{spbset} command. If \option{vshift}, \option{hshift} and \option{cmd} are used in the \cs{spbset} command, it is set according to the type of the previous nearest command.
+\begin{options}
+  \keyval{vshift}{fixed length}\Default{0pt}
+  Vertical shift of superscript or subscript. Represents the vertical distance \option{vsep} between superscript and subscript in the superscript and subscript commands.
+  \keyval{hshift}{fixed length}\Default{0pt}
+  Horizontal shift of superscript or subscript. Represents the common shift in the superscript and subscript commands.
+  \keyval{cmd}{format cmds}\Default
+  The format command of superscript or subscript. The last command can take a parameter, which accepts superscript or subscript. Represents the format of superscript and subscript in the superscript and subscript commands.
+  \keychoice{mode}{text,math,match}\Default{match}
+  The mode of superscript or subscript output can be \code{text} or \code{math} mode. The \code{match} option automatically matches output modes according to the current mode.
+\end{options}
 
-If you need to use the original definitions of \cs{textsuperscript}, \cs{textsubscript}, \cs{sp} and \cs{sb} after using the \option{text} or \option{math} option, then you can use the following commands:
-\begin{commands}
-  \command{spb at textsuperscript@save}[\marg{content}]
-  Save the original definition of the \cs{textsuperscript} command, output superscript in the text.
-  \command{spb at textsubscript@save}[\marg{content}]
-  Save the original definition of the \cs{textsubscript} command, output subscript in the text.
-  \command{spb at sp@save}[\marg{content}]
-  Save the original definition of the \cs{sp} command, output superscript in the math mode.
-  \command{spb at sb@save}[\marg{content}]
-  Save the original definition of the \cs{sb} command, output subscript in the math mode.
-\end{commands}
-
 \section{Global control interface}
 \label{sec:global control interface}
 \begin{commands}
   \command{spbset}[\marg{key-value list}]
-  \pkg*{spbmark} uses the \cs{spbset} command to control the global default format of superscript and subscript. The values ​​set by it will be overwritten by the optional parameters of the superscript and other commands.
+  \pkg*{spbmark} uses the \cs{spbset} command to control the global default format of superscript and subscript. These options also apply to \meta{kv list} of the above commands. The values ​​set by it will be overwritten by the optional parameters of the superscript and other commands.
 \end{commands}
 
-The following list of keys control the format both of superscript or subscript. They are equivalent to the optional parameters of the \cs{super} or \cs{sub} commands.
+The following list of keys control the format both of superscript or subscript.
 \begin{options}
-  \keyval{super-vshift}{fixed length}\Default{0pt}
-  Extra vertical shift of the superscript.
-  \keyval{super-hshift}{fixed length}\Default{0pt}
+  \keyval{spvshift}{fixed length}\Default{0pt}
+  Extra vertical shift of the superscript. 
+  \keyval{sphshift}{fixed length}\Default{0pt}
   Extra horizontal shift of the superscript.
-  \keyval{sub-vshift}{fixed length}\Default{0pt}
+  \keyval{sbvshift}{fixed length}\Default{0pt}
   Extra vertical shift of the subscript.
-  \keyval{sub-hshift}{fixed length}\Default{0pt}
+  \keyval{sbhshift}{fixed length}\Default{0pt}
   Extra horizontal shift of the subscript.
   \opt{nohshift}\Default!
   Cancel the horizontal offset of superscript and subscript at the same time.
   \opt{novshift}\Default!
   Cancel the vertical offset of superscript and subscript at the same time.
-  \keyval{super-format}{format code}\Default
+  \keyval{spcmd}{format code}\Default
   Control the format of superscript, the last command in the code can take an argument, which is a superscript.
-  \keyval{sub-format}{format code}\Default
+  \keyval{sbcmd}{format code}\Default
   Control the format of subscript, the last command in the code can take an argument, which is a subscript.
 \end{options}
 
-The following list of keys control the format of superscript and subscript. They are equivalent to the optional parameters of the \cs{supersub} command.
+If \option{sphshift} is positive, the superscript or subscript moves to the right, and if it is negative, it moves to the left. However, for superscript, if \option{spvshift} is positive, the superscript moves up, and if spvshift is negative, it moves down. For subscripts, if \option{spvshift} is positive, the subscript moves down, and if spvshift is negative, it moves up.
+
+The following list of keys control the format of superscript and subscript.
 \begin{options}
-  \keyval{supersub-hshift}{fixed length}\Default{0pt}
+  \keyval{spbhshift}{fixed length}\Default{0pt}
   Extra vertical shift of the superscript and the subscript.
-  \kvsplit{supersub-format}{super code}{sub code}\Default{0pt}
+  \kvsplit{spbcmd}{super code}{sub code}\Default
   Control the format of superscript or subscript. The first part is in superscript format, and the latter part is in subscript format. The two are separated by commas, or only the first part exists.
-  \keyval{supersubsep}{fixed length}\Default{0.3ex}
+  \keyval{vsep}{fixed length}\Default{0.3ex}
   The distance between superscript and subscript, its default value is \code{0.3ex}.
-  \keychoice{supersubalign}{l,c,r}\Default{l}
+  \keychoice{halign}{l,c,r}\Default{l}
   The alignment of superscript and subscript, which contains \code{l}, \code{c}, and \code{r} parameters respectively for left, center, and right alignment.
 \end{options}
 
 \section{Examples of use}
-Here is a list of the three commands, please pay attention to the delimiter and usage of optional parameters. Note when the horizontal offset is negative, the starting point is at the right end of the mark.
+Here is a list of the three commands, please pay attention to the usage of optional parameters. Note when the horizontal offset is negative, the starting point is at the right end of the mark.
 \begin{example}
-\spbset{supersub-format = {\ttfamily,\color{blue}}}
-A\super[0.2ex](\textcolor{red}){exam}[0.2em]B \\
-$A\sub(\mathsf){exam}B$ \\
-A\supersub[0.3ex](c){examsuper}{sub}B \\
-A\super[5pt]{c}[-1.5pt]B\sub[5pt]{d}[-1pt]AB
+\spbset{spbcmd={\ttfamily,\color{blue}}}
+A\super[vshift=0.2ex,hshift=0.2em,cmd=\textcolor{red}]{exam}B \\
+$A\sub[cmd=\mathsf,mode=math]{exam}B$ \\
+A\supersub[vsep=0.3ex,halign=c]{examsuper}{sub}B \\
+A\super{c}[vshift=5pt,hshift=-1.5pt]B\sub[vshift=5pt,hshift=-1pt]{d}AB
 \end{example}
 
 It can also be used with the \pkg*{siunitx} package to output superscript and subscript in the unit:
 \begin{example}
-\unit[mode = math]{kg.m/s\super*[-1pt]{2}} \\
-\qty[mode = text]{30}{A\supersub{b}{c}[1pt](\color{red})} \\
-\spbset{sub-hshift = 2pt}\unit[mode = text]{A\sub{b}}
+\unit[mode=math]{kg.m/s\super[vshift=-1pt]{2}} \\
+\qty[mode=text]{30}{A\supersub[hshift=1pt,cmd=\color{red}]{b}{c}} \\
+\spbset{sbhshift=2pt}\unit[mode=text]{A\sub{b}}
 \end{example}
 
 \pkg*{spbmark} also patches the footer markers for standard document class and \cls*{KOMA-Script}. You can format the footer markers by redefining the \cs{fnmarkfont} command. Note that extra horizontal shift does not work with footnote markers.
 
+\section{Developer commands}
+If you need to use the original definitions of \cs{textsuperscript}, \cs{textsubscript}, \cs{sp} and \cs{sb} after using the \option{text} or \option{math} option, then you can use the following commands:
+\begin{commands}
+  \command{spb at textsuperscript@save}[\marg{content}]
+  Save the original definition of the \cs{textsuperscript} command, output superscript in the text.
+  \command{spb at textsubscript@save}[\marg{content}]
+  Save the original definition of the \cs{textsubscript} command, output subscript in the text.
+  \command{spb at sp@save}[\marg{content}]
+  Save the original definition of the \cs{sp} command, output superscript in the math mode.
+  \command{spb at sb@save}[\marg{content}]
+  Save the original definition of the \cs{sb} command, output subscript in the math mode.
+\end{commands}
+
 \section{Known issues}
 At present, the vertical and horizontal offsets are effective for the unit commands in the \pkg*{siunitx} macro package. However, due to the special mechanism that the decimal point is not recognized correctly because it's converted to a space in the \cs*{unit} command, it's recommended to use \code{pt} as the unit of offset.
 

Modified: trunk/Master/texmf-dist/tex/latex/spbmark/spbmark.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/spbmark/spbmark.sty	2021-12-15 21:31:28 UTC (rev 61313)
+++ trunk/Master/texmf-dist/tex/latex/spbmark/spbmark.sty	2021-12-15 21:31:41 UTC (rev 61314)
@@ -9,9 +9,15 @@
 %   https://creativecommons.org/licenses/by/4.0/legalcode
 \NeedsTeXFormat{LaTeX2e}[2018/12/31]
 \RequirePackage{xparse,l3keys2e}
-\ProvidesExplPackage{spbmark}{2021/11/10}{1.1J}
+\ProvidesExplPackage{spbmark}{2021/12/15}{1.2}
   {Customize superscripts and subscripts}
 
+\cs_generate_variant:Nn \dim_max:nn { VV }
+\cs_generate_variant:Nn \dim_compare:nNnTF { V }
+\cs_generate_variant:Nn \msg_warning:nnn { nnV }
+\cs_generate_variant:Nn \str_case:nn { x }
+\cs_generate_variant:Nn \tl_if_novalue:nF { V }
+
 \cs_new_protected:Npn \spb_define:n { \keys_define:nn { ctex/style } }
 \cs_new_protected:Npn \spbset { \keys_set:nn { ctex/style } }
 \keys_define:nn { spbmark/option }
@@ -32,35 +38,71 @@
 
 \ProcessKeysOptions{spbmark/option}
 
-\tl_new:N \l__spb_super_script_formatii_tl
-\tl_new:N \l__spb_sub_script_formatii_tl
+\tl_new:N \l__spb_super_cmd_ii_tl
+\tl_new:N \l__spb_sub_cmd_ii_tl
+\tl_new:N \g__spb_hshift_init_tl
+\tl_new:N \g__spb_vshift_init_tl
+\tl_new:N \g__spb_cmd_init_tl
+
+\cs_new_protected:Npn \spb_local_case_init:nnnn #1#2#3#4
+  {
+    \str_case:xn { \tl_use:c { g__spb_#1_init_tl } }
+      {
+        { super } {#2}
+        { sub } {#3}
+        { supersub } {#4}
+      }
+  }
 \spb_define:n
   {
-    super-vshift .dim_set:N     = \l__spb_super_script_vshift_dim,
-    super-vshift .initial:n     = 0pt,
-    super-hshift .dim_set:N     = \l__spb_super_script_hshift_dim,
-    super-hshift .initial:n     = 0pt,
-    sub-vshift .dim_set:N       = \l__spb_sub_script_vshift_dim,
-    sub-vshift .initial:n       = 0pt,
-    sub-hshift .dim_set:N       = \l__spb_sub_script_hshift_dim,
-    sub-hshift .initial:n       = 0pt,
-    supersub-hshift .dim_set:N  = \l__spb_supersub_script_hshift_dim,
-    supersub-hshift .initial:n  = 0pt,
-    nohshift .meta:n = { super-hshift = 0pt,sub-hshift = 0pt },
-    novshift .meta:n = { super-vshift = 0pt,sub-vshift = 0pt },
-    super-format .tl_set:N      = \l__spb_super_script_formati_tl,
-    sub-format .tl_set:N        = \l__spb_sub_script_formati_tl,
-    supersub-format .code:n     = \spb_both_format_assign:n {#1},
-    supersubsep .dim_set:N      = \l__spb_supersub_script_sep_dim,
-    supersubsep .initial:n      = 0.3ex,
-    supersubalign .tl_set:N     = \l__spb_supersub_script_align_tl,
-    supersubalign .initial:n    = l
+    spvshift .dim_set:N   = \l__spb_super_vshift_dim,
+    spvshift .initial:n   = 0pt,
+    sphshift .dim_set:N   = \l__spb_super_hshift_dim,
+    sphshift .initial:n   = 0pt,
+    sbvshift .dim_set:N   = \l__spb_sub_vshift_dim,
+    sbvshift .initial:n   = 0pt,
+    sbhshift .dim_set:N   = \l__spb_sub_hshift_dim,
+    sbhshift .initial:n   = 0pt,
+    spbhshift .dim_set:N  = \l__spb_supersub_hshift_dim,
+    spbhshift .initial:n  = 0pt,
+    vshift .code:n        =
+      {
+        \spb_local_case_init:nnnn { vshift }
+          { \dim_set:Nn \l__spb_super_vshift_dim {#1} }
+          { \dim_set:Nn \l__spb_sub_vshift_dim {#1} }
+          { \dim_set:Nn \l__spb_supersub_vsep_dim {#1} }
+      },
+    hshift .code:n        =
+      {
+        \spb_local_case_init:nnnn { hshift }
+          { \dim_set:Nn \l__spb_super_hshift_dim {#1} }
+          { \dim_set:Nn \l__spb_sub_hshift_dim {#1} }
+          { \dim_set:Nn \l__spb_supersub_hshift_dim {#1} }
+      },
+    nohshift .meta:n      = { sphshift = 0pt,sbhshift = 0pt },
+    novshift .meta:n      = { spvshift = 0pt,sbvshift = 0pt },
+    spcmd .tl_set:N       = \l__spb_super_cmd_i_tl,
+    sbcmd .tl_set:N       = \l__spb_sub_cmd_i_tl,
+    spbcmd .code:n        = \spb_both_cmd_assign:n {#1},
+    cmd .code:n           =
+      {
+        \spb_local_case_init:nnnn { cmd }
+          { \tl_set:Nn \l__spb_super_cmd_i_tl {#1} }
+          { \tl_set:Nn \l__spb_sub_cmd_i_tl {#1} }
+          { \spb_both_cmd_assign:n {#1} }
+      },
+    vsep .dim_set:N       = \l__spb_supersub_vsep_dim,
+    vsep .initial:n       = 0.3ex,
+    halign .tl_set:N      = \l__spb_supersub_align_tl,
+    halign .initial:n     = l,
+    mode .tl_set:N        = \l__spb_mode_value_tl,
+    mode .initial:n       = match
   }
 
 \tl_set:Nn \l__spb_boxa_wd_tl { \box_wd:N \l_tmpa_box }
 \tl_set:Nn \l__spb_boxb_wd_tl { \box_wd:N \l_tmpb_box }
 \tl_set:Nn \l__spb_box_max_wd_tl
-  { \dim_max:nn { \l__spb_boxa_wd_tl } { \l__spb_boxb_wd_tl } }
+  { \dim_max:VV \l__spb_boxa_wd_tl \l__spb_boxb_wd_tl }
 \providecommand{\hbox_overlap_center:n}[1]
   { \hbox_to_zero:n { \hss #1\hss } }
 \cs_new:Npn \spb_boxa_move_up:n #1
@@ -77,32 +119,49 @@
         { sub } { \spb_boxa_move_down:n }
       }
   }
-\cs_new:Npn \spb_hbox_overlap_vshift:n #1#2
+\cs_generate_variant:Nn \spb_boxa_move_up:n { V }
+\cs_generate_variant:Nn \spb_boxb_move_down:n { V }
+\cs_new:Npn \spb_hbox_overlap_vshift:n #1
   {
-    \use:c { hbox_overlap_#2:n } { \spb_boxa_move_up:n {#1} }
-    \use:c { hbox_overlap_#2:n } { \spb_boxb_move_down:n {#1} }
+    \use:c { hbox_overlap_#1:n }
+      { \spb_boxa_move_up:V \l__spb_supersub_vsep_dim }
+    \use:c { hbox_overlap_#1:n }
+      { \spb_boxb_move_down:V \l__spb_supersub_vsep_dim }
   }
-\cs_new:Npn \spb_math_print_store:nnn #1#2#3
+\cs_new:Npn \spb_math_print_store_i:nn #1#2
   {
     \hbox_set:Nn \l_tmpa_box
-      { \ensuremath{#1{\spb_math:nn {#2} {#3}}} }
+      { \ensuremath{\tl_use:c { l__spb_#1_cmd_i_tl }{\spb_math:nn {#1} {#2}}} }
   }
-\cs_new:Npn \spb_text_print_store:nnn #1#2#3
+\cs_new:Npn \spb_text_print_store_i:nn #1#2
   {
     \hbox_set:Nn \l_tmpa_box
-      { #1{\use:c { spb at text#2script at save }{#3}} }
+      { \tl_use:c { l__spb_#1_cmd_i_tl }{\use:c { spb at text#1script at save }{#2}} }
   }
-\cs_new:Npn \spb_math_print_store:nnnn #1#2#3#4
+\cs_new:Npn \spb_math_print_store_ii:nn #1#2
   {
-    \hbox_set:Nn \l_tmpa_box { \ensuremath{#1{\spb at sp@save{#3}}} }
+    \hbox_set:Nn \l_tmpa_box 
+      { \ensuremath{\l__spb_super_cmd_ii_tl{\spb at sp@save{#1}}} }
     \hbox_set:Nn \l_tmpb_box
-      { \ensuremath{\tl_if_novalue:nF {#2} {#2}{\spb at sb@save{#4}}} }
+      {
+        \ensuremath
+          {
+            \tl_if_novalue:VF \l__spb_sub_cmd_ii_tl
+              { \l__spb_sub_cmd_ii_tl }
+              { \spb at sb@save{#2} }
+          } 
+      }
   }
-\cs_new:Npn \spb_text_print_store:nnnn #1#2#3#4
+\cs_new:Npn \spb_text_print_store_ii:nn #1#2
   {
-    \hbox_set:Nn \l_tmpa_box { #1{\spb at textsuperscript@save{#3}} }
+    \hbox_set:Nn \l_tmpa_box
+      { \l__spb_super_cmd_ii_tl{\spb at textsuperscript@save{#1}} }
     \hbox_set:Nn \l_tmpb_box
-      { \tl_if_novalue:nF {#2} {#2}{\spb at textsubscript@save{#4}} }
+      {
+        \tl_if_novalue:VF \l__spb_sub_cmd_ii_tl
+          { \l__spb_sub_cmd_ii_tl }
+          { \spb at textsubscript@save{#2} } 
+      }
   }
 \cs_set_eq:NN \spb at textsuperscript@save \textsuperscript
 \cs_set_eq:NN \spb at textsubscript@save \textsubscript
@@ -121,74 +180,98 @@
     \tl_if_empty:nF {#1} { \box_set_ht:Nn \l_tmpb_box {#1} }
     \tl_if_novalue:nF {#2} { \box_set_dp:Nn \l_tmpb_box {#2} }
   }
-\NewDocumentCommand{\spb_both_format_assign:n}
+\NewDocumentCommand{\spb_both_cmd_assign:n}
   {>{\SplitArgument{1}{,}}m}
-  {\spb_supersub_script_both_format:nn #1}
-\cs_new_protected:Npn \spb_supersub_script_both_format:nn #1#2
+  {\spb_supersub_both_cmd:nn #1}
+\cs_new_protected:Npn \spb_supersub_both_cmd:nn #1#2
   {
-    \tl_set:Nn \l__spb_super_script_formatii_tl {#1}
+    \tl_set:Nn \l__spb_super_cmd_ii_tl {#1}
     \tl_if_novalue:nTF {#2}
-      { \tl_clear:N \l__spb_sub_script_formatii_tl }
-      { \tl_set:Nn \l__spb_sub_script_formatii_tl {#2} }
+      { \tl_clear:N \l__spb_sub_cmd_ii_tl }
+      { \tl_set:Nn \l__spb_sub_cmd_ii_tl {#2} }
   }
+\cs_new_protected:Npn \spb_mode_switch:nnn #1#2#3
+  {
+    \str_case:Vn \l__spb_mode_value_tl
+      {
+        { math } {#1}
+        { text } {#2}
+        { match } {#3}
+      }
+   }
+\cs_new_protected:Npn \spb_local_value_init:n #1
+  {
+    \tl_gset:Nn \g__spb_hshift_init_tl {#1}
+    \tl_gset:Nn \g__spb_vshift_init_tl {#1}
+    \tl_gset:Nn \g__spb_cmd_init_tl {#1}
+  }
 
-\clist_map_inline:nn
-  { super,sub }
+\cs_new_protected:Npn \spb_both_newcmd_map:n #1
   {
     \exp_args:Nc \NewDocumentCommand {#1}
+      {O{}>{\SplitArgument{1}{,}}O{}mO{}}
       {
-        sO{\dim_use:c { l__spb_#1_script_vshift_dim }}
-        >{\SplitArgument{1}{,}}O{}
-        D(){\tl_use:c { l__spb_#1_script_formati_tl }}
-        mO{\dim_use:c { l__spb_#1_script_hshift_dim }}
-      }
-      {
-        \IfBooleanTF{##1}
-          {\spb_math_print_store:nnn {##4} {#1} {##5}}
+        \group_begin:
+        \spb_local_value_init:n {#1}
+        \keys_set:nn { ctex/style } {##1,##4}
+        \spb_mode_switch:nnn
+          { \spb_math_print_store_i:nn {#1} {##3} }
+          { \spb_text_print_store_i:nn {#1} {##3} }
           {
             \mode_if_math:TF
-              { \spb_math_print_store:nnn {##4} {#1} {##5} }
-              { \spb_text_print_store:nnn {##4} {#1} {##5} }
+              { \spb_math_print_store_i:nn {#1} {##3} }
+              { \spb_text_print_store_i:nn {#1} {##3} }
           }
-        \hbox_set:Nn \l_tmpa_box
-          {
-            \dim_compare:nNnTF {##6} < { 0pt }
-              {
-                \hbox_overlap_left:n
-                  {
-                    \hbox_to_wd:nn { \l__spb_boxa_wd_tl - ##6 }
-                      { \spb_boxa_vshift:nn {#1} {##2}\hss }
-                  }
-              }
-              {
-                \hbox_to_wd:nn { \l__spb_boxa_wd_tl + ##6 }
-                  { \hss\spb_boxa_vshift:nn {#1} {##2} }
-              }
-          }
-        \spb_box_ht_dp_assign:nn ##3
+        \spb_content_hbox_set:n {#1}
+        \spb_box_ht_dp_assign:nn ##2
         \box_use:N \l_tmpa_box
+        \group_end:
       }
   }
-\NewDocumentCommand{\supersub}
+\cs_new_protected:Npn \spb_content_hbox_set:n #1
+   {
+     \hbox_set:Nn \l_tmpa_box
+       {
+         \dim_compare:nNnTF { \dim_use:c { l__spb_#1_hshift_dim } } < { 0pt }
+           {
+             \hbox_overlap_left:n
+               {
+                 \hbox_to_wd:nn
+                   { \l__spb_boxa_wd_tl - \dim_use:c { l__spb_#1_hshift_dim } }
+                   {
+                      \spb_boxa_vshift:nn {#1}
+                        { \dim_use:c { l__spb_#1_vshift_dim } }\hss
+                   }
+               }
+           }
+           {
+             \hbox_to_wd:nn
+               { \l__spb_boxa_wd_tl + \dim_use:c { l__spb_#1_hshift_dim } }
+               {
+                  \hss\spb_boxa_vshift:nn {#1}
+                    { \dim_use:c { l__spb_#1_vshift_dim } }
+               }
+           }
+       }
+   }
+\clist_map_inline:nn { super,sub } { \spb_both_newcmd_map:n {#1} }
+
+\cs_new:Npn \spb_supersub_hshift_if_negative:TF #1#2
+  { \dim_compare:VNnTF \l__spb_supersub_hshift_dim < { 0pt } {#1} {#2} }
+\NewDocumentCommand{\supersub}{O{}mmO{}}
   {
-    sO{\l__spb_supersub_script_sep_dim}
-    D(){\l__spb_supersub_script_align_tl}
-    mmO{\l__spb_supersub_script_hshift_dim}
-    >{\SplitArgument{1}{,}}D()
-    {
-      \l__spb_super_script_formatii_tl,
-      \l__spb_sub_script_formatii_tl
-    }
-  }
-  {
-    \IfBooleanTF{#1}
-      {\spb_math_print_store:nnnn #7 {#4} {#5}}
+    \group_begin:
+    \spb_local_value_init:n { supersub }
+    \keys_set:nn { ctex/style } {#1,#4}
+    \spb_mode_switch:nnn
+      { \spb_math_print_store_ii:nn {#2} {#3} }
+      { \spb_text_print_store_ii:nnnn {#2} {#3} }
       {
         \mode_if_math:TF
-          { \spb_math_print_store:nnnn #7 {#4} {#5} }
-          { \spb_text_print_store:nnnn #7 {#4} {#5} }
+          { \spb_math_print_store_ii:nn {#2} {#3} }
+          { \spb_text_print_store_ii:nn {#2} {#3} }
       }
-    \str_case:onF {#3}
+    \str_case:VnF \l__spb_supersub_align_tl
       {
         { l } { \use_i:nnn }
         { c } { \use_ii:nnn }
@@ -199,58 +282,62 @@
         \use_i:nnn
       }
       {
-        \dim_compare:nNnTF {#6} < { 0pt }
+        \spb_supersub_hshift_if_negative:TF
           {
             \hbox_overlap_left:n
               {
-                \spb_hbox_overlap_vshift:n {#2} { right } 
-                \skip_horizontal:n { -#6 }
+                \spb_hbox_overlap_vshift:n { right }
+                \skip_horizontal:n { -\l__spb_supersub_hshift_dim }
               }
           }
           {
             \hbox:n
               {
-                \skip_horizontal:n {#6}
-                \spb_hbox_overlap_vshift:n {#2} { right } 
+                \skip_horizontal:n { \l__spb_supersub_hshift_dim }
+                \spb_hbox_overlap_vshift:n { right } 
                 \skip_horizontal:n { \l__spb_box_max_wd_tl }
               }
           }
       }
       {
-        \dim_compare:nNnTF {#6} < { 0pt }
+        \spb_supersub_hshift_if_negative:TF
           {
             \hbox_overlap_left:n
               {
-                \spb_hbox_overlap_vshift:n {#2} { center } 
-                \skip_horizontal:n { \l__spb_box_max_wd_tl/2 - #6 }
+                \spb_hbox_overlap_vshift:n { center }
+                \skip_horizontal:n
+                  { \l__spb_box_max_wd_tl/2 - \l__spb_supersub_hshift_dim }
               }
           }
           {
             \hbox:n
               {
-                \skip_horizontal:n { \l__spb_box_max_wd_tl/2 + #6 }
-                \spb_hbox_overlap_vshift:n {#2} { center } 
+                \skip_horizontal:n
+                  { \l__spb_box_max_wd_tl/2 + \l__spb_supersub_hshift_dim }
+                \spb_hbox_overlap_vshift:n { center } 
                 \skip_horizontal:n { \l__spb_box_max_wd_tl/2 }
               }
           }
       }
       {
-        \dim_compare:nNnTF {#6} < { 0pt }
+        \spb_supersub_hshift_if_negative:TF
           {
             \hbox_overlap_left:n
               {
-                \spb_hbox_overlap_vshift:n {#2} { left } 
-                \skip_horizontal:n { -#6 }
+                \spb_hbox_overlap_vshift:n { left }
+                \skip_horizontal:n { -\l__spb_supersub_hshift_dim }
               }
           }
           {
             \hbox:n
               {
-                \skip_horizontal:n { \l__spb_box_max_wd_tl + #6 }
-                \spb_hbox_overlap_vshift:n {#2} { left } 
+                \skip_horizontal:n
+                  { \l__spb_box_max_wd_tl + \l__spb_supersub_hshift_dim }
+                \spb_hbox_overlap_vshift:n { left } 
               }
           }
       }
+    \group_end:
   }
 \msg_new:nnn { spbmark } { unsupported-align }
   {



More information about the tex-live-commits mailing list.