summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/spbmark
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-01-24 03:02:10 +0000
committerNorbert Preining <norbert@preining.info>2022-01-24 03:02:10 +0000
commit17f5b660e0ce0c5c1b1dc095df8213e078963809 (patch)
tree210a8643bac0dcb24683b9a8556e600ad3d1ba36 /macros/latex/contrib/spbmark
parent47551fbf494bf778f45c78692a0ff17d771b96d7 (diff)
CTAN sync 202201240302
Diffstat (limited to 'macros/latex/contrib/spbmark')
-rw-r--r--macros/latex/contrib/spbmark/spbmark.pdfbin70955 -> 71880 bytes
-rw-r--r--macros/latex/contrib/spbmark/spbmark.sty138
-rw-r--r--macros/latex/contrib/spbmark/spbmark.tex28
3 files changed, 102 insertions, 64 deletions
diff --git a/macros/latex/contrib/spbmark/spbmark.pdf b/macros/latex/contrib/spbmark/spbmark.pdf
index 756cb37d36..2c833724ea 100644
--- a/macros/latex/contrib/spbmark/spbmark.pdf
+++ b/macros/latex/contrib/spbmark/spbmark.pdf
Binary files differ
diff --git a/macros/latex/contrib/spbmark/spbmark.sty b/macros/latex/contrib/spbmark/spbmark.sty
index 16e168baa2..bc2aeab66f 100644
--- a/macros/latex/contrib/spbmark/spbmark.sty
+++ b/macros/latex/contrib/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 }
diff --git a/macros/latex/contrib/spbmark/spbmark.tex b/macros/latex/contrib/spbmark/spbmark.tex
index faa5c1a44c..08ed9bc04f 100644
--- a/macros/latex/contrib/spbmark/spbmark.tex
+++ b/macros/latex/contrib/spbmark/spbmark.tex
@@ -6,8 +6,8 @@
{
package = spbmark,
title = the spbmark package,
- version = v1.2H,
- date = 2021/12/22,
+ version = v1.3,
+ date = 2022/01/23,
authors = Qu Yi,
info = Customize superscript and subscript,
email = q1jx@foxmail.com,
@@ -61,9 +61,9 @@ The following macro package options will redefine the scripts commands of the \L
\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}[\oarg{kv list}\splitoarg{height}{depth}\marg{content}\oarg{kv list}]
+ \command{super}[\oarg{kv list}\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}]
+ \command{sub}[\oarg{kv list}\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.
@@ -73,9 +73,7 @@ There are currently three commands to set superscript and subscript. Their forma
In some cases, \code{math} or \code{text} output modes require different code for format or move. This command can be used when using the \code{match} option or changing the output mode locally, whitch should be used in the move or format options. It can switch the corresponding code according to different output modes.
\end{commands}
-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 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{vmove}, \option{hmove} and \option{cmd} are used in the \cs{spbset} command, it is set according to the type of the previous nearest command.
+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. When the following options are used in the \cs{spbset} command, in addition to \option{style} and \option{mode}, they are set according to the type of the previous most recent command.
\begin{options}
\keyval{vmove}{fixed length}\Default{0pt}
Vertical move of superscript or subscript. Represents the extra vertical distance \option{vsep} between superscript and subscript in the superscript and subscript commands.
@@ -85,6 +83,10 @@ The options common to \meta{kv list} of the three commands are as follows. They
The format commands 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.
\keyval{cmd+}{format cmds}\Default
Add code to the previous global superscript or subscript format commands.
+ \keyval{height}{fixed length}\Default
+ The distance between the superscript or subscript baseline and the previous line.
+ \keyval{depth}{fixed length}\Default
+ The distance between the superscript or subscript baseline and the next line.
\keyval{style}{style name}\Default
Use the \meta{style name} defined by the \cs{defspbstyle} command to make it work global or local.
\keychoice{mode}{text,math,match}\Default{match}
@@ -120,6 +122,14 @@ The following list of keys control the format both of superscript or subscript.
The format commands of subscript. The last command in the code can take an argument, which is a subscript.
\keyval{sbcmd+}{format cmds}\Default
Add code to the previous global subcript format commands.
+ \keyval{spheight}{fixed length}\Default
+ The distance between the superscript baseline and the previous line.
+ \keyval{spdepth}{fixed length}\Default
+ The distance between the superscript baseline and the next line.
+ \keyval{sbheight}{fixed length}\Default
+ The distance between the subscript baseline and the previous line.
+ \keyval{sbdepth}{fixed length}\Default
+ The distance between the subscript baseline and the next line.
\end{options}
If \option{sphmove} is positive, the superscript or subscript moves to the right, conversely it moves to the left. However, for superscript, if \option{spvmove} is positive, the superscript moves up, conversely it moves down. For subscript, if \option{spvmove} is positive, the subscript moves down, conversely it moves up.
@@ -132,6 +142,10 @@ The following list of keys control the format of superscript and subscript.
The format commands of superscript and subscript. The first part is in superscript format, and the latter part is in subscript format. They are separated by commas, or only the first part exists.
\kvsplit{spbcmd+}{super cmds}{sub cmds}\Default
Add code to the previous global superscript and subscript format commands.
+ \keyval{spbheight}{fixed length}\Default
+ The distance between the superscript baseline and the previous line.
+ \keyval{spbdepth}{fixed length}\Default
+ The distance between the subscript baseline and the next line.
\keyval{vsep}{fixed length}\Default{0.6ex}
The extra vertical distance between superscript and subscript.
\keychoice{halign}{l,c,r}\Default{l}