summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/spbmark
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-12-15 21:31:41 +0000
committerKarl Berry <karl@freefriends.org>2021-12-15 21:31:41 +0000
commitd17954c33edc93d453cd9b31a83baf282ad04e31 (patch)
tree7055c552d4a62a1404a395d0ca096e5270eb8970 /Master/texmf-dist/tex/latex/spbmark
parentc84aa59f3cdf68baf9351d9c543b6ae8a47cc3d1 (diff)
spbmark (15dec21)
git-svn-id: svn://tug.org/texlive/trunk@61314 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/spbmark')
-rw-r--r--Master/texmf-dist/tex/latex/spbmark/spbmark.sty289
1 files changed, 188 insertions, 101 deletions
diff --git a/Master/texmf-dist/tex/latex/spbmark/spbmark.sty b/Master/texmf-dist/tex/latex/spbmark/spbmark.sty
index 826d9a5b4be..099f871f20d 100644
--- a/Master/texmf-dist/tex/latex/spbmark/spbmark.sty
+++ b/Master/texmf-dist/tex/latex/spbmark/spbmark.sty
@@ -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@text#2script@save }{#3}} }
+ { \tl_use:c { l__spb_#1_cmd_i_tl }{\use:c { spb@text#1script@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@sp@save{#3}}} }
+ \hbox_set:Nn \l_tmpa_box
+ { \ensuremath{\l__spb_super_cmd_ii_tl{\spb@sp@save{#1}}} }
\hbox_set:Nn \l_tmpb_box
- { \ensuremath{\tl_if_novalue:nF {#2} {#2}{\spb@sb@save{#4}}} }
+ {
+ \ensuremath
+ {
+ \tl_if_novalue:VF \l__spb_sub_cmd_ii_tl
+ { \l__spb_sub_cmd_ii_tl }
+ { \spb@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@textsuperscript@save{#3}} }
+ \hbox_set:Nn \l_tmpa_box
+ { \l__spb_super_cmd_ii_tl{\spb@textsuperscript@save{#1}} }
\hbox_set:Nn \l_tmpb_box
- { \tl_if_novalue:nF {#2} {#2}{\spb@textsubscript@save{#4}} }
+ {
+ \tl_if_novalue:VF \l__spb_sub_cmd_ii_tl
+ { \l__spb_sub_cmd_ii_tl }
+ { \spb@textsubscript@save{#2} }
+ }
}
\cs_set_eq:NN \spb@textsuperscript@save \textsuperscript
\cs_set_eq:NN \spb@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} }
}
-
-\clist_map_inline:nn
- { super,sub }
+\cs_new_protected:Npn \spb_mode_switch:nnn #1#2#3
{
- \exp_args:Nc \NewDocumentCommand {#1}
+ \str_case:Vn \l__spb_mode_value_tl
{
- 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 }}
+ { 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}
+ }
+
+\cs_new_protected:Npn \spb_both_newcmd_map:n #1
+ {
+ \exp_args:Nc \NewDocumentCommand {#1}
+ {O{}>{\SplitArgument{1}{,}}O{}mO{}}
{
- \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}
- {
- 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
- }
- }
+\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{}}
{
- \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 }
{