summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/spbmark
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-12-18 20:56:50 +0000
committerKarl Berry <karl@freefriends.org>2021-12-18 20:56:50 +0000
commitf4c64624856e899e9cacb93d7e957fb2f7d4768e (patch)
tree4c06222c3056906030e35f6831f9b40dfa1ba809 /Master/texmf-dist/tex/latex/spbmark
parent5f692b0c97fc156abcb2eb1bb22cb7d3b5e17ed5 (diff)
spbmark (18dec21)
git-svn-id: svn://tug.org/texlive/trunk@61342 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/spbmark')
-rw-r--r--Master/texmf-dist/tex/latex/spbmark/spbmark.sty224
1 files changed, 115 insertions, 109 deletions
diff --git a/Master/texmf-dist/tex/latex/spbmark/spbmark.sty b/Master/texmf-dist/tex/latex/spbmark/spbmark.sty
index 72c6240a5fe..465a0350668 100644
--- a/Master/texmf-dist/tex/latex/spbmark/spbmark.sty
+++ b/Master/texmf-dist/tex/latex/spbmark/spbmark.sty
@@ -9,7 +9,7 @@
% https://creativecommons.org/licenses/by/4.0/legalcode
\NeedsTeXFormat{LaTeX2e}[2018/12/31]
\RequirePackage{xparse,l3keys2e}
-\ProvidesExplPackage{spbmark}{2021/12/16}{1.2B}
+\ProvidesExplPackage{spbmark}{2021/12/18}{1.2C}
{Customize superscripts and subscripts}
\cs_generate_variant:Nn \dim_max:nn { VV }
@@ -40,8 +40,8 @@
\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_hmove_init_tl
+\tl_new:N \g__spb_vmove_init_tl
\tl_new:N \g__spb_cmd_init_tl
\cs_new_protected:Npn \spb_local_case_init:nnnn #1#2#3#4
@@ -55,48 +55,58 @@
}
\spb_define:n
{
- 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 =
+ spvmove .dim_set:N = \l__spb_super_vmove_dim,
+ spvmove .initial:n = 0pt,
+ sphmove .dim_set:N = \l__spb_super_hmove_dim,
+ sphmove .initial:n = 0pt,
+ sbvmove .dim_set:N = \l__spb_sub_vmove_dim,
+ sbvmove .initial:n = 0pt,
+ sbhmove .dim_set:N = \l__spb_sub_hmove_dim,
+ sbhmove .initial:n = 0pt,
+ spbhmove .dim_set:N = \l__spb_supersub_hmove_dim,
+ spbhmove .initial:n = 0pt,
+ vmove .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} }
+ \spb_local_case_init:nnnn { vmove }
+ { \dim_set:Nn \l__spb_super_vmove_dim {#1} }
+ { \dim_set:Nn \l__spb_sub_vmove_dim {#1} }
{ \dim_set:Nn \l__spb_supersub_vsep_dim {#1} }
},
- hshift .code:n =
+ hmove .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} }
+ \spb_local_case_init:nnnn { hmove }
+ { \dim_set:Nn \l__spb_super_hmove_dim {#1} }
+ { \dim_set:Nn \l__spb_sub_hmove_dim {#1} }
+ { \dim_set:Nn \l__spb_supersub_hmove_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 =
+ nohmove .meta:n = { sphmove = 0pt,sbhmove = 0pt },
+ novmove .meta:n = { spvmove = 0pt,sbvmove = 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{#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} }
+ { \spb@both@cmd@assign{#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
+ spcmd+ .code:n = \tl_put_right:Nn \l__spb_super_cmd_i_tl {#1},
+ sbcmd+ .code:n = \tl_put_right:Nn \l__spb_sub_cmd_i_tl {#1},
+ spbcmd+ .code:n = \spb@both@cmd@assign+{#1},
+ cmd+ .code:n =
+ {
+ \spb_local_case_init:nnnn { cmd }
+ { \tl_put_right:Nn \l__spb_super_cmd_i_tl {#1} }
+ { \tl_put_right:Nn \l__spb_sub_cmd_i_tl {#1} }
+ { \spb@both@cmd@assign+{#1} }
+ },
+ vsep .dim_set:N = \l__spb_supersub_vsep_dim,
+ vsep .initial:n = 0.6ex,
+ halign .tl_set:N = \l__spb_supersub_halign_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 }
@@ -111,7 +121,7 @@
{ \box_move_down:nn {#1} { \box_use:N \l_tmpa_box } }
\cs_new:Npn \spb_boxb_move_down:n #1
{ \box_move_down:nn {#1} { \box_use:N \l_tmpb_box } }
-\cs_new:Npn \spb_boxa_vshift:nn #1
+\cs_new:Npn \spb_boxa_vmove:nn #1
{
\str_case:nn {#1}
{
@@ -121,12 +131,15 @@
}
\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
+\dim_new:N \l__spb_supersub_half_vsep_dim
+\cs_new:Npn \spb_hbox_overlap_vmove:n #1
{
+ \dim_set:Nn \l__spb_supersub_half_vsep_dim
+ { \l__spb_supersub_vsep_dim/2 }
\use:c { hbox_overlap_#1:n }
- { \spb_boxa_move_up:V \l__spb_supersub_vsep_dim }
+ { \spb_boxa_move_up:V \l__spb_supersub_half_vsep_dim }
\use:c { hbox_overlap_#1:n }
- { \spb_boxb_move_down:V \l__spb_supersub_vsep_dim }
+ { \spb_boxb_move_down:V \l__spb_supersub_half_vsep_dim }
}
\cs_set_eq:NN \spb@textsuperscript@save \textsuperscript
\cs_set_eq:NN \spb@textsubscript@save \textsubscript
@@ -170,9 +183,13 @@
\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_cmd_assign:n}
- {>{\SplitArgument{1}{,}}m}
- {\spb_supersub_both_cmd:nn #1}
+\NewDocumentCommand{\spb@both@cmd@assign}
+ {t+>{\SplitArgument{1}{,}}m}
+ {
+ \IfBooleanTF{#1}
+ {\spb_supersub_both_addto_cmd:nn #2}
+ {\spb_supersub_both_cmd:nn #2}
+ }
\cs_new_protected:Npn \spb_supersub_both_cmd:nn #1#2
{
\tl_set:Nn \l__spb_super_cmd_ii_tl {#1}
@@ -180,19 +197,31 @@
{ \tl_clear:N \l__spb_sub_cmd_ii_tl }
{ \tl_set:Nn \l__spb_sub_cmd_ii_tl {#2} }
}
+\cs_new_protected:Npn \spb_supersub_both_addto_cmd:nn #1#2
+ {
+ \tl_put_right:Nn \l__spb_super_cmd_ii_tl {#1}
+ \tl_if_novalue:nF {#2} { \tl_put_right: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}
+ { math }
+ { \use:c { spb_math_print_store_#3:nn } {#1} {#2} }
+ { text }
+ { \use:c { spb_text_print_store_#3:nn } {#1} {#2} }
+ { match }
+ {
+ \mode_if_math:TF
+ { \use:c { spb_math_print_store_#3:nn } {#1} {#2} }
+ { \use:c { spb_text_print_store_#3:nn } {#1} {#2} }
+ }
}
}
\cs_new_protected:Npn \spb_global_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_hmove_init_tl {#1}
+ \tl_gset:Nn \g__spb_vmove_init_tl {#1}
\tl_gset:Nn \g__spb_cmd_init_tl {#1}
}
@@ -204,14 +233,7 @@
\group_begin:
\spb_global_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_i:nn {#1} {##3} }
- { \spb_text_print_store_i:nn {#1} {##3} }
- }
+ \spb_mode_switch:nnn {#1} {##3} { i }
\spb_content_hbox_set:n {#1}
\spb_box_ht_dp_assign:nn ##2
\box_use:N \l_tmpa_box
@@ -219,49 +241,36 @@
}
}
\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 } }
- }
- }
- }
- }
+ {
+ \hbox_set:Nn \l_tmpa_box
+ {
+ \dim_compare:nNnTF { \dim_use:c { l__spb_#1_hmove_dim } } < { 0pt }
+ {
+ \hbox_overlap_left:n
+ {
+ \hbox_overlap_right:n
+ { \spb_boxa_vmove:nn {#1} { \dim_use:c { l__spb_#1_vmove_dim } } }
+ \skip_horizontal:n { -\dim_use:c { l__spb_#1_hmove_dim } }
+ }
+ }
+ {
+ \hbox_to_wd:nn
+ { \l__spb_boxa_wd_tl + \dim_use:c { l__spb_#1_hmove_dim } }
+ { \hss\spb_boxa_vmove:nn {#1} { \dim_use:c { l__spb_#1_vmove_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} }
+\cs_new:Npn \spb_supersub_hmove_if_negative:TF #1#2
+ { \dim_compare:VNnTF \l__spb_supersub_hmove_dim < { 0pt } {#1} {#2} }
\NewDocumentCommand{\supersub}{O{}mmO{}}
{
\group_begin:
\spb_global_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_ii:nn {#2} {#3} }
- { \spb_text_print_store_ii:nn {#2} {#3} }
- }
- \str_case:VnF \l__spb_supersub_align_tl
+ \spb_mode_switch:nnn {#2} {#3} { ii }
+ \str_case:VnF \l__spb_supersub_halign_tl
{
{ l } { \use_i:nnn }
{ c } { \use_ii:nnn }
@@ -272,58 +281,55 @@
\use_i:nnn
}
{
- \spb_supersub_hshift_if_negative:TF
+ \spb_supersub_hmove_if_negative:TF
{
\hbox_overlap_left:n
{
- \spb_hbox_overlap_vshift:n { right }
- \skip_horizontal:n { -\l__spb_supersub_hshift_dim }
+ \spb_hbox_overlap_vmove:n { right }
+ \skip_horizontal:n { -\l__spb_supersub_hmove_dim }
}
}
{
\hbox:n
{
- \skip_horizontal:n { \l__spb_supersub_hshift_dim }
- \spb_hbox_overlap_vshift:n { right }
+ \skip_horizontal:n { \l__spb_supersub_hmove_dim }
+ \spb_hbox_overlap_vmove:n { right }
\skip_horizontal:n { \l__spb_box_max_wd_tl }
}
}
}
{
- \spb_supersub_hshift_if_negative:TF
+ \spb_supersub_hmove_if_negative:TF
{
\hbox_overlap_left:n
{
- \spb_hbox_overlap_vshift:n { center }
- \skip_horizontal:n
- { \l__spb_box_max_wd_tl/2 - \l__spb_supersub_hshift_dim }
+ \spb_hbox_overlap_vmove:n { center }
+ \skip_horizontal:n { \l__spb_box_max_wd_tl/2 - \l__spb_supersub_hmove_dim }
}
}
{
\hbox:n
{
- \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 + \l__spb_supersub_hmove_dim }
+ \spb_hbox_overlap_vmove:n { center }
\skip_horizontal:n { \l__spb_box_max_wd_tl/2 }
}
}
}
{
- \spb_supersub_hshift_if_negative:TF
+ \spb_supersub_hmove_if_negative:TF
{
\hbox_overlap_left:n
{
- \spb_hbox_overlap_vshift:n { left }
- \skip_horizontal:n { -\l__spb_supersub_hshift_dim }
+ \spb_hbox_overlap_vmove:n { left }
+ \skip_horizontal:n { -\l__spb_supersub_hmove_dim }
}
}
{
\hbox:n
{
- \skip_horizontal:n
- { \l__spb_box_max_wd_tl + \l__spb_supersub_hshift_dim }
- \spb_hbox_overlap_vshift:n { left }
+ \skip_horizontal:n { \l__spb_box_max_wd_tl + \l__spb_supersub_hmove_dim }
+ \spb_hbox_overlap_vmove:n { left }
}
}
}