diff options
author | Karl Berry <karl@freefriends.org> | 2022-01-23 21:12:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-01-23 21:12:21 +0000 |
commit | ae51dd95270e1fff9fc6fcc539b6ffcf1efc5fff (patch) | |
tree | 4b1ec60a08aa3a7ecaa381c459b8a8209eb0e483 /Master/texmf-dist/tex/latex | |
parent | 9d71acd9035aa121c64f6b4fa53ac3e2cf9147c6 (diff) |
spbmark (23jan22)
git-svn-id: svn://tug.org/texlive/trunk@61716 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/spbmark/spbmark.sty | 138 |
1 files changed, 81 insertions, 57 deletions
diff --git a/Master/texmf-dist/tex/latex/spbmark/spbmark.sty b/Master/texmf-dist/tex/latex/spbmark/spbmark.sty index 16e168baa2b..bc2aeab66f9 100644 --- a/Master/texmf-dist/tex/latex/spbmark/spbmark.sty +++ b/Master/texmf-dist/tex/latex/spbmark/spbmark.sty @@ -1,7 +1,7 @@ % % ***************** THE SPBMARK PACKAGE ***************** % -% Copyright (C) 2021 by Qu Yi <q1jx@foxmail.com> +% Copyright (C) 2021-2022 by Qu Yi <q1jx@foxmail.com> % % This work may be distributed and/or modified under the % conditions of the CC-BY 4.0 License. @@ -9,9 +9,11 @@ % https://creativecommons.org/licenses/by/4.0/legalcode \NeedsTeXFormat{LaTeX2e}[2018/12/31] \RequirePackage{xparse,l3keys2e} -\ProvidesExplPackage{spbmark}{2021/12/22}{1.2H} +\ProvidesExplPackage{spbmark}{2022/01/23}{1.3} {Customize superscripts and subscripts} +\cs_generate_variant:Nn \box_set_ht:Nn { cv } +\cs_generate_variant:Nn \box_set_dp:Nn { cv } \cs_generate_variant:Nn \dim_max:nn { VV } \cs_generate_variant:Nn \dim_compare:nNnTF { V } \cs_generate_variant:Nn \msg_warning:nnn { nnV } @@ -40,17 +42,15 @@ \tl_new:N \l__spb_super_cmd_ii_tl \tl_new:N \l__spb_sub_cmd_ii_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 +\tl_new:N \g__spb_mark_case_init_tl -\cs_new_protected:Npn \spb_local_case_init:nnnn #1#2#3#4 +\cs_new_protected:Npn \spb_local_case_init:nnn #1#2#3 { - \str_case:xn { \tl_use:c { g__spb_#1_init_tl } } + \str_case:Vn \g__spb_mark_case_init_tl { - { super } {#2} - { sub } {#3} - { supersub } {#4} + { super } {#1} + { sub } {#2} + { supersub } {#3} } } \cs_new_protected:Npn \defspbstyle #1#2 @@ -75,14 +75,14 @@ spbhmove .initial:n = 0pt, vmove .code:n = { - \spb_local_case_init:nnnn { vmove } + \spb_local_case_init:nnn { \tl_set:Nn \l__spb_super_vmove_tl {#1} } { \tl_set:Nn \l__spb_sub_vmove_tl {#1} } { \tl_set:Nn \l__spb_supersub_vsep_tl {#1} } }, hmove .code:n = { - \spb_local_case_init:nnnn { hmove } + \spb_local_case_init:nnn { \tl_set:Nn \l__spb_super_hmove_tl {#1} } { \tl_set:Nn \l__spb_sub_hmove_tl {#1} } { \tl_set:Nn \l__spb_supersub_hmove_tl {#1} } @@ -94,7 +94,7 @@ spbcmd .code:n = \spb@both@cmd@assign{#1}, cmd .code:n = { - \spb_local_case_init:nnnn { cmd } + \spb_local_case_init:nnn { \tl_set:Nn \l__spb_super_cmd_i_tl {#1} } { \tl_set:Nn \l__spb_sub_cmd_i_tl {#1} } { \spb@both@cmd@assign{#1} } @@ -104,11 +104,31 @@ spbcmd+ .code:n = \spb@both@cmd@assign+{#1}, cmd+ .code:n = { - \spb_local_case_init:nnnn { cmd } + \spb_local_case_init:nnn { \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} } }, + spheight .tl_set:N = \l__super_height_i_tl, + sbheight .tl_set:N = \l__sub_height_i_tl, + spbheight .tl_set:N = \l__super_height_ii_tl, + height .code:n = + { + \spb_local_case_init:nnn + { \tl_set:Nn \l__super_height_i_tl {#1} } + { \tl_set:Nn \l__sub_height_i_tl {#1} } + { \tl_set:Nn \l__super_height_ii_tl {#1} } + }, + spdepth .tl_set:N = \l__super_depth_i_tl, + sbdepth .tl_set:N = \l__sub_depth_i_tl, + spbdepth .tl_set:N = \l__sub_depth_ii_tl, + depth .code:n = + { + \spb_local_case_init:nnn + { \tl_set:Nn \l__super_depth_i_tl {#1} } + { \tl_set:Nn \l__sub_depth_i_tl {#1} } + { \tl_set:Nn \l__sub_depth_ii_tl {#1} } + }, vsep .tl_set:N = \l__spb_supersub_vsep_tl, vsep .initial:n = 0.6ex, halign .tl_set:N = \l__spb_supersub_halign_tl, @@ -123,9 +143,13 @@ \cs_set_eq:NN \spb@textsubscript@save \textsubscript \cs_set_eq:NN \spb@math@super@save \sp \cs_set_eq:NN \spb@math@sub@save \sb +\box_new:N \l__super_i_box +\box_new:N \l__sub_i_box +\box_new:N \l__super_ii_box +\box_new:N \l__sub_ii_box \cs_new:Npn \spb_math_print_store_i:nn #1#2 { - \hbox_set:Nn \l_tmpa_box + \hbox_set:cn { l__#1_i_box } { \ensuremath { @@ -136,7 +160,7 @@ } \cs_new:Npn \spb_text_print_store_i:nn #1#2 { - \hbox_set:Nn \l_tmpa_box + \hbox_set:cn { l__#1_i_box } { \use:c { spb@text#1script@save } { \tl_use:c { l__spb_#1_cmd_i_tl }{#2} } @@ -144,16 +168,16 @@ } \cs_new:Npn \spb_math_print_store_ii:nn #1#2 { - \hbox_set:Nn \l_tmpa_box + \hbox_set:Nn \l__super_ii_box { \ensuremath{\spb@math@super@save{\l__spb_super_cmd_ii_tl{#1}}} } - \hbox_set:Nn \l_tmpb_box + \hbox_set:Nn \l__sub_ii_box { \ensuremath{\spb@math@sub@save{\l__spb_sub_cmd_ii_tl{#2}}} } } \cs_new:Npn \spb_text_print_store_ii:nn #1#2 { - \hbox_set:Nn \l_tmpa_box + \hbox_set:Nn \l__super_ii_box { \spb@textsuperscript@save{\l__spb_super_cmd_ii_tl{#1}} } - \hbox_set:Nn \l_tmpb_box + \hbox_set:Nn \l__sub_ii_box { \spb@textsubscript@save{\l__spb_sub_cmd_ii_tl{#2}} } } \cs_set_eq:NN \spbifmath \use_ii:nn @@ -187,42 +211,41 @@ } } } -\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_super_wd_i_tl { \box_wd:N \l__super_i_box } +\tl_set:Nn \l__spb_box_sub_wd_i_tl { \box_wd:N \l__sub_i_box } +\tl_set:Nn \l__spb_box_super_wd_ii_tl { \box_wd:N \l__super_ii_box } +\tl_set:Nn \l__spb_box_sub_wd_ii_tl { \box_wd:N \l__sub_ii_box } \tl_set:Nn \l__spb_box_max_wd_tl - { \dim_max:VV \l__spb_boxa_wd_tl \l__spb_boxb_wd_tl } + { \dim_max:VV \l__spb_box_super_wd_ii_tl \l__spb_box_sub_wd_ii_tl } \providecommand{\hbox_overlap_center:n}[1] { \hbox_to_zero:n { \hss #1\hss } } -\cs_new:Npn \spb_boxa_move_up:n #1 - { \box_move_up:nn {#1} { \box_use:N \l_tmpa_box } } -\cs_new:Npn \spb_boxa_move_down:n #1 - { \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_vmove:nn #1 +\cs_new:Npn \spb_box_super_move_i_up:n #1 + { \box_move_up:nn {#1} { \box_use:N \l__super_i_box } } +\cs_new:Npn \spb_box_sub_move_i_down:n #1 + { \box_move_down:nn {#1} { \box_use:N \l__sub_i_box } } +\cs_new:Npn \spb_box_super_move_ii_up:n #1 + { \box_move_up:nn {#1} { \box_use:N \l__super_ii_box } } +\cs_new:Npn \spb_box_sub_move_ii_down:n #1 + { \box_move_down:nn {#1} { \box_use:N \l__sub_ii_box } } +\cs_new:Npn \spb_box_vmove:nn #1 { \str_case:nn {#1} { - { super } { \spb_boxa_move_up:n } - { sub } { \spb_boxa_move_down:n } + { super } { \spb_box_super_move_i_up:n } + { sub } { \spb_box_sub_move_i_down:n } } } -\cs_generate_variant:Nn \spb_boxa_move_up:n { V } -\cs_generate_variant:Nn \spb_boxb_move_down:n { V } +\cs_generate_variant:Nn \spb_box_super_move_ii_up:n { V } +\cs_generate_variant:Nn \spb_box_sub_move_ii_down:n { V } \dim_new:N \l__spb_supersub_half_vsep_tl \cs_new:Npn \spb_hbox_overlap_vmove:n #1 { \tl_set:Nn \l__spb_supersub_half_vsep_tl { \l__spb_supersub_vsep_tl/2 } \use:c { hbox_overlap_#1:n } - { \spb_boxa_move_up:V \l__spb_supersub_half_vsep_tl } + { \spb_box_super_move_ii_up:V \l__spb_supersub_half_vsep_tl } \use:c { hbox_overlap_#1:n } - { \spb_boxb_move_down:V \l__spb_supersub_half_vsep_tl } - } -\cs_new_protected:Npn \spb_box_ht_dp_assign:nn #1#2 - { - \tl_if_empty:nF {#1} { \box_set_ht:Nn \l_tmpa_box {#1} } - \tl_if_novalue:nF {#2} { \box_set_dp:Nn \l_tmpa_box {#2} } + { \spb_box_sub_move_ii_down:V \l__spb_supersub_half_vsep_tl } } \NewDocumentCommand{\spb@both@cmd@assign} {t+>{\SplitArgument{1}{,}}m} @@ -243,45 +266,45 @@ \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_global_value_init:n #1 +\cs_new_protected:Npn \spb_ht_dp_assign:nnn #1#2#3 { - \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} + \tl_if_empty:cF { l__#1_height_#3_tl } + { \box_set_ht:cv { l__#1_#3_box } { l__#1_height_#3_tl } } + \tl_if_empty:cF { l__#1_depth_i_tl } + { \box_set_dp:cv { l__#2_#3_box } { l__#2_depth_#3_tl } } } \cs_new_protected:Npn \spb_both_newcmd_map:n #1 { - \exp_args:Nc \NewDocumentCommand {#1} - {O{}>{\SplitArgument{1}{,}}O{}mO{}} + \exp_args:Nc \NewDocumentCommand {#1}{O{}mO{}} { \group_begin: - \spb_global_value_init:n {#1} - \keys_set:nn { ctex/style } {##1,##4} - \spb_mode_switch:nnn {#1} {##3} { i } + \tl_gset:Nn \g__spb_mark_case_init_tl {#1} + \keys_set:nn { ctex/style } {##1,##3} + \spb_mode_switch:nnn {#1} {##2} { i } \spb_content_hbox_set:n {#1} - \spb_box_ht_dp_assign:nn ##2 - \box_use:N \l_tmpa_box + \spb_ht_dp_assign:nnn {#1} {#1} { i } + \box_use:c { l__#1_i_box } \group_end: } } \cs_new_protected:Npn \spb_content_hbox_set:n #1 { - \hbox_set:Nn \l_tmpa_box + \hbox_set:cn { l__#1_i_box } { \dim_compare:nNnTF { \tl_use:c { l__spb_#1_hmove_tl } } < { 0pt } { \hbox_overlap_left:n { \hbox_overlap_right:n - { \spb_boxa_vmove:nn {#1} { \tl_use:c { l__spb_#1_vmove_tl } } } + { \spb_box_vmove:nn {#1} { \tl_use:c { l__spb_#1_vmove_tl } } } \skip_horizontal:n { -\tl_use:c { l__spb_#1_hmove_tl } } } } { \hbox_to_wd:nn - { \l__spb_boxa_wd_tl + \tl_use:c { l__spb_#1_hmove_tl } } - { \hss\spb_boxa_vmove:nn {#1} { \tl_use:c { l__spb_#1_vmove_tl } } } + { \tl_use:c { l__spb_box_#1_wd_i_tl } + \tl_use:c { l__spb_#1_hmove_tl } } + { \hss\spb_box_vmove:nn {#1} { \tl_use:c { l__spb_#1_vmove_tl } } } } } } @@ -292,9 +315,10 @@ \NewDocumentCommand{\supersub}{O{}mmO{}} { \group_begin: - \spb_global_value_init:n { supersub } + \tl_gset:Nn \g__spb_mark_case_init_tl { supersub } \keys_set:nn { ctex/style } {#1,#4} \spb_mode_switch:nnn {#2} {#3} { ii } + \spb_ht_dp_assign:nnn { super } { sub } { ii } \str_case:VnF \l__spb_supersub_halign_tl { { l } { \use_i:nnn } |