summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/spbmark/spbmark.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/spbmark/spbmark.sty')
-rw-r--r--macros/latex/contrib/spbmark/spbmark.sty108
1 files changed, 81 insertions, 27 deletions
diff --git a/macros/latex/contrib/spbmark/spbmark.sty b/macros/latex/contrib/spbmark/spbmark.sty
index c1ce4837a5..ada39cfc91 100644
--- a/macros/latex/contrib/spbmark/spbmark.sty
+++ b/macros/latex/contrib/spbmark/spbmark.sty
@@ -8,8 +8,8 @@
% The latest version of this license is in
% https://creativecommons.org/licenses/by/4.0/legalcode
\NeedsTeXFormat{LaTeX2e}[2018/12/31]
-\RequirePackage{xparse,l3keys2e}
-\ProvidesExplPackage{spbmark}{2024/05/19}{1.46j}
+\RequirePackage{xparse}
+\ProvidesExplPackage{spbmark}{2024/10/31}{1.46t}
{Customize superscripts and subscripts}
\cs_generate_variant:Nn \box_set_ht:Nn { cv }
@@ -32,6 +32,16 @@
\cs_new_protected:Npn \spb_define:n { \keys_define:nn { ctex/tools } }
\cs_new_protected:Npn \spb_set:n { \keys_set:nn { ctex/tools } }
\cs_set_eq:NN \spbset \spb_set:n
+\cs_new_protected:Npn \spb_mark_core_set_trad:n #1
+ {
+ \cs_set_eq:cc { spb@text#1script@core } { spb@text#1script@save }
+ \cs_set_eq:cc { spb@math@#1@core } { spb@math@#1@save }
+ }
+\cs_new_protected:Npn \spb_mark_core_set_none:n #1
+ {
+ \cs_set_eq:cN { spb@text#1script@core } \use:n
+ \cs_set_eq:cN { spb@math@#1@core } \use:n
+ }
\keys_define:nn { spbmark/option }
{
@@ -43,8 +53,8 @@
},
text/false .code:n =
{
- \cs_set:Npn \textsuperscript { \spb@textsuperscript@save }
- \cs_set:Npn \textsubscript { \spb@textsubscript@save }
+ \cs_set:Npn \textsuperscript { \spb@textsuperscript@core }
+ \cs_set:Npn \textsubscript { \spb@textsubscript@core }
},
text .default:n = true,
math .choice:,
@@ -55,8 +65,8 @@
},
math/false .code:n =
{
- \cs_set:Npn \sp { \spb@math@super@save }
- \cs_set:Npn \sb { \spb@math@sub@save }
+ \cs_set:Npn \sp { \spb@math@super@core }
+ \cs_set:Npn \sb { \spb@math@sub@core }
},
math .default:n = true,
foot .choice:,
@@ -71,7 +81,17 @@
both .meta:n = { text = #1,math = #1 },
both .default:n = true,
all .meta:n = { text = #1,math = #1,foot = #1 },
- all .default:n = true
+ all .default:n = true,
+ spcore .choice:,
+ spcore .value_required:n = true,
+ spcore/trad .code:n = \spb_mark_core_set_trad:n { super },
+ spcore/none .code:n = \spb_mark_core_set_none:n { super },
+ spcore .initial:n = trad,
+ sbcore .choice:,
+ sbcore .value_required:n = true,
+ sbcore/trad .code:n = \spb_mark_core_set_trad:n { sub },
+ sbcore/none .code:n = \spb_mark_core_set_none:n { sub },
+ sbcore .initial:n = trad
}
\char_set_catcode_active:N \~
\keys_define:nn { spbmark/option }
@@ -108,7 +128,12 @@
{ \tl_set_eq:NN \fnmarkfont \ftntm@font }
{ \tl_set_eq:NN \fnmarkfont \normalfont }
-\ProcessKeysOptions{spbmark/option}
+\cs_if_exist:NTF \ProcessKeyOptions
+ { \ProcessKeyOptions[spbmark/option] }
+ {
+ \RequirePackage{l3keys2e}
+ \ProcessKeysOptions{spbmark/option}
+ }
\tl_new:N \g__spb_mark_case_init_tl
\cs_new_protected:Npn \spb_local_case_init:nnn #1#2#3
@@ -208,7 +233,7 @@
\cs_generate_variant:Nn \spb_box_super_move_up_ii:n { V }
\cs_generate_variant:Nn \spb_box_sub_move_down_ii:n { V }
\providecommand{\hbox_overlap_center:n}[1]
- { \hbox_to_zero:n { \hss #1\hss } }
+ {\hbox_to_zero:n { \hss #1\hss }}
\cs_new:Npn \spb_hbox_overlap_vmove_ii:n #1
{
\use:c { hbox_overlap_#1:n }
@@ -308,40 +333,68 @@
\tl_set:Nn \maxwd { \dim_max:VV \superwd \subwd }
\tl_set:Nn \l__spb_box_super_wd_i_tl { \box_wd:N \g__super_i_inner_box }
\tl_set:Nn \l__spb_box_sub_wd_i_tl { \box_wd:N \g__sub_i_inner_box }
-\cs_new:Npn \spb_math_print_store_i:nn #1#2
+\providecommand{\NewHookWithArguments}[2]{}
+\providecommand{\UseHookWithArguments}[4]{}
+\NewHookWithArguments{spb/super/before}{2}
+\NewHookWithArguments{spb/super/after}{2}
+\NewHookWithArguments{spb/sub/before}{2}
+\NewHookWithArguments{spb/sub/after}{2}
+\NewHookWithArguments{spb/super*/before}{2}
+\NewHookWithArguments{spb/super*/after}{2}
+\NewHookWithArguments{spb/sub*/before}{2}
+\NewHookWithArguments{spb/sub*/after}{2}
+\NewHookWithArguments{cmd+/super/after}{2}
+\NewHookWithArguments{cmd+/sub/after}{2}
+\cs_new:Npn \spb_math_print_store_i:nnnn #1#2#3#4
{
\hbox_gset:cn { g__#1_i_inner_box }
{
- \ensuremath
- {
- \use:c { spb@math@#1@save }
- { \tl_use:c { l__spb_#1_cmd_i_tl }{#2} }
+ #3{
+ \UseHookWithArguments{spb/#1/before}{2}{#1}{#2}
+ \use:c {#4} { \tl_use:c { l__spb_#1_cmd_i_tl }{#2} }
+ \UseHookWithArguments{spb/#1/after}{2}{#1}{#2}
}
}
\dim_gset:Nv \rlastwd { l__spb_box_#1_wd_i_tl }
}
+\cs_new:Npn \spb_math_print_store_i:nn #1#2
+ {
+ \spb_math_print_store_i:nnnn
+ {#1} {#2} { \ensuremath } { spb@math@#1@core }
+ }
\cs_new:Npn \spb_text_print_store_i:nn #1#2
{
- \hbox_gset:cn { g__#1_i_inner_box }
+ \spb_math_print_store_i:nnnn
+ {#1} {#2} { \use:n } { spb@text#1script@core }
+ }
+\cs_new:Npn \spb_math_print_store_ii:nnnnn #1#2#3#4#5
+ {
+ \hbox_gset:Nn \g__super_ii_box
{
- \use:c { spb@text#1script@save }
- { \tl_use:c { l__spb_#1_cmd_i_tl }{#2} }
+ #3{
+ \UseHookWithArguments{spb/super*/before}{2}{super}{#1}
+ #4{\l__spb_super_cmd_ii_tl{#1}}
+ \UseHookWithArguments{spb/super*/after}{2}{super}{#1}
+ }
+ }
+ \hbox_gset:Nn \g__sub_ii_box
+ {
+ #3{
+ \UseHookWithArguments{spb/sub*/before}{2}{sub}{#2}
+ #5{\l__spb_sub_cmd_ii_tl{#2}}
+ \UseHookWithArguments{spb/sub*/after}{2}{sub}{#2}
+ }
}
- \dim_gset:Nv \rlastwd { l__spb_box_#1_wd_i_tl }
}
\cs_new:Npn \spb_math_print_store_ii:nn #1#2
{
- \hbox_gset:Nn \g__super_ii_box
- { \ensuremath{\spb@math@super@save{\l__spb_super_cmd_ii_tl{#1}}} }
- \hbox_gset:Nn \g__sub_ii_box
- { \ensuremath{\spb@math@sub@save{\l__spb_sub_cmd_ii_tl{#2}}} }
+ \spb_math_print_store_ii:nnnnn {#1} {#2}
+ { \ensuremath } { \spb@math@super@core } { \spb@math@sub@core }
}
\cs_new:Npn \spb_text_print_store_ii:nn #1#2
{
- \hbox_gset:Nn \g__super_ii_box
- { \spb@textsuperscript@save{\l__spb_super_cmd_ii_tl{#1}} }
- \hbox_gset:Nn \g__sub_ii_box
- { \spb@textsubscript@save{\l__spb_sub_cmd_ii_tl{#2}} }
+ \spb_math_print_store_ii:nnnnn {#1} {#2}
+ { \use:n } { \spb@textsuperscript@core } { \spb@textsubscript@core }
}
\cs_set_eq:NN \spbifmath \use_ii:nn
\cs_new:Npn \spb@ifmathtrue { \cs_set_eq:NN \spbifmath \use_i:nn }
@@ -445,6 +498,7 @@
\exp_last_unbraced:Nx
\group_end:
{
+ \UseHookWithArguments{cmd+/#1/after}{2}{#1}{##4}
\exp_args:Nv \str_if_eq:nnT
{ l__spb_#1_thiswd_mode_tl } { auto }
{ \spb_clear_thiswd:n {#1} }
@@ -585,7 +639,7 @@
{
\ifaltsbsp@spbmark
\SetAltSubSupCommands{\relax}
- \else\fi
+ \fi
}
}{}
\cs_set_eq:NN \spb \supersub