summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/spbmark
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-12-21 03:00:53 +0000
committerNorbert Preining <norbert@preining.info>2021-12-21 03:00:53 +0000
commit3bffd8b7dfcee8333bb2841ea194a0daa26af8cd (patch)
treebcb2f36fb360e319a26e6a679e690112f744a28a /macros/latex/contrib/spbmark
parent95d5657ad19f20d47fa609a8539b36088be56ce2 (diff)
CTAN sync 202112210300
Diffstat (limited to 'macros/latex/contrib/spbmark')
-rw-r--r--macros/latex/contrib/spbmark/spbmark.pdfbin69960 -> 70115 bytes
-rw-r--r--macros/latex/contrib/spbmark/spbmark.sty165
-rw-r--r--macros/latex/contrib/spbmark/spbmark.tex14
3 files changed, 98 insertions, 81 deletions
diff --git a/macros/latex/contrib/spbmark/spbmark.pdf b/macros/latex/contrib/spbmark/spbmark.pdf
index 07b2e984d4..0dc97fd394 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 465a035066..10defa9e25 100644
--- a/macros/latex/contrib/spbmark/spbmark.sty
+++ b/macros/latex/contrib/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/18}{1.2C}
+\ProvidesExplPackage{spbmark}{2021/12/20}{1.2E}
{Customize superscripts and subscripts}
\cs_generate_variant:Nn \dim_max:nn { VV }
@@ -55,29 +55,29 @@
}
\spb_define:n
{
- spvmove .dim_set:N = \l__spb_super_vmove_dim,
+ spvmove .tl_set:N = \l__spb_super_vmove_tl,
spvmove .initial:n = 0pt,
- sphmove .dim_set:N = \l__spb_super_hmove_dim,
+ sphmove .tl_set:N = \l__spb_super_hmove_tl,
sphmove .initial:n = 0pt,
- sbvmove .dim_set:N = \l__spb_sub_vmove_dim,
+ sbvmove .tl_set:N = \l__spb_sub_vmove_tl,
sbvmove .initial:n = 0pt,
- sbhmove .dim_set:N = \l__spb_sub_hmove_dim,
+ sbhmove .tl_set:N = \l__spb_sub_hmove_tl,
sbhmove .initial:n = 0pt,
- spbhmove .dim_set:N = \l__spb_supersub_hmove_dim,
+ spbhmove .tl_set:N = \l__spb_supersub_hmove_tl,
spbhmove .initial:n = 0pt,
vmove .code:n =
{
\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} }
+ { \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 }
- { \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} }
+ { \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} }
},
nohmove .meta:n = { sphmove = 0pt,sbhmove = 0pt },
novmove .meta:n = { spvmove = 0pt,sbvmove = 0pt },
@@ -101,7 +101,7 @@
{ \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 .tl_set:N = \l__spb_supersub_vsep_tl,
vsep .initial:n = 0.6ex,
halign .tl_set:N = \l__spb_supersub_halign_tl,
halign .initial:n = l,
@@ -109,38 +109,6 @@
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: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
- { \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
- {
- \str_case:nn {#1}
- {
- { super } { \spb_boxa_move_up:n }
- { sub } { \spb_boxa_move_down:n }
- }
- }
-\cs_generate_variant:Nn \spb_boxa_move_up:n { V }
-\cs_generate_variant:Nn \spb_boxb_move_down:n { V }
-\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_half_vsep_dim }
- \use:c { hbox_overlap_#1:n }
- { \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
\cs_set_eq:NN \spb@math@super@save \sp
@@ -178,10 +146,73 @@
\hbox_set:Nn \l_tmpb_box
{ \spb@textsubscript@save{\l__spb_sub_cmd_ii_tl{#2}} }
}
+\cs_set_eq:NN \spbifmath \use_ii:nn
+\cs_new:Npn \spb@ifmathtrue { \cs_set_eq:NN \spbifmath \use_i:nn }
+\cs_new:Npn \spb@ifmathfalse { \cs_set_eq:NN \spbifmath \use_ii:nn }
+\cs_new_protected:Npn \spb_mode_switch:nnn #1#2#3
+ {
+ \str_case:Vn \l__spb_mode_value_tl
+ {
+ { math }
+ {
+ \spb@ifmathtrue
+ \use:c { spb_math_print_store_#3:nn } {#1} {#2}
+ }
+ { text }
+ {
+ \spb@ifmathfalse
+ \use:c { spb_text_print_store_#3:nn } {#1} {#2}
+ }
+ { match }
+ {
+ \mode_if_math:TF
+ {
+ \spb@ifmathtrue
+ \use:c { spb_math_print_store_#3:nn } {#1} {#2}
+ }
+ {
+ \spb@ifmathfalse
+ \use:c { spb_text_print_store_#3:nn } {#1} {#2}
+ }
+ }
+ }
+ }
+\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: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
+ { \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
+ {
+ \str_case:nn {#1}
+ {
+ { super } { \spb_boxa_move_up:n }
+ { sub } { \spb_boxa_move_down:n }
+ }
+ }
+\cs_generate_variant:Nn \spb_boxa_move_up:n { V }
+\cs_generate_variant:Nn \spb_boxb_move_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 }
+ \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_tmpb_box {#1} }
- \tl_if_novalue:nF {#2} { \box_set_dp:Nn \l_tmpb_box {#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} }
}
\NewDocumentCommand{\spb@both@cmd@assign}
{t+>{\SplitArgument{1}{,}}m}
@@ -202,22 +233,6 @@
\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 }
- { \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_hmove_init_tl {#1}
@@ -244,26 +259,26 @@
{
\hbox_set:Nn \l_tmpa_box
{
- \dim_compare:nNnTF { \dim_use:c { l__spb_#1_hmove_dim } } < { 0pt }
+ \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} { \dim_use:c { l__spb_#1_vmove_dim } } }
- \skip_horizontal:n { -\dim_use:c { l__spb_#1_hmove_dim } }
+ { \spb_boxa_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 + \dim_use:c { l__spb_#1_hmove_dim } }
- { \hss\spb_boxa_vmove:nn {#1} { \dim_use:c { l__spb_#1_vmove_dim } } }
+ { \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 } } }
}
}
}
\clist_map_inline:nn { super,sub } { \spb_both_newcmd_map:n {#1} }
\cs_new:Npn \spb_supersub_hmove_if_negative:TF #1#2
- { \dim_compare:VNnTF \l__spb_supersub_hmove_dim < { 0pt } {#1} {#2} }
+ { \dim_compare:VNnTF \l__spb_supersub_hmove_tl < { 0pt } {#1} {#2} }
\NewDocumentCommand{\supersub}{O{}mmO{}}
{
\group_begin:
@@ -286,13 +301,13 @@
\hbox_overlap_left:n
{
\spb_hbox_overlap_vmove:n { right }
- \skip_horizontal:n { -\l__spb_supersub_hmove_dim }
+ \skip_horizontal:n { -\l__spb_supersub_hmove_tl }
}
}
{
\hbox:n
{
- \skip_horizontal:n { \l__spb_supersub_hmove_dim }
+ \skip_horizontal:n { \l__spb_supersub_hmove_tl }
\spb_hbox_overlap_vmove:n { right }
\skip_horizontal:n { \l__spb_box_max_wd_tl }
}
@@ -304,13 +319,13 @@
\hbox_overlap_left:n
{
\spb_hbox_overlap_vmove:n { center }
- \skip_horizontal:n { \l__spb_box_max_wd_tl/2 - \l__spb_supersub_hmove_dim }
+ \skip_horizontal:n { -\l__spb_supersub_hmove_tl - \l__spb_box_max_wd_tl/2 }
}
}
{
\hbox:n
{
- \skip_horizontal:n { \l__spb_box_max_wd_tl/2 + \l__spb_supersub_hmove_dim }
+ \skip_horizontal:n { \l__spb_box_max_wd_tl/2 + \l__spb_supersub_hmove_tl }
\spb_hbox_overlap_vmove:n { center }
\skip_horizontal:n { \l__spb_box_max_wd_tl/2 }
}
@@ -322,13 +337,13 @@
\hbox_overlap_left:n
{
\spb_hbox_overlap_vmove:n { left }
- \skip_horizontal:n { -\l__spb_supersub_hmove_dim }
+ \skip_horizontal:n { -\l__spb_supersub_hmove_tl - \l__spb_box_max_wd_tl }
}
}
{
\hbox:n
{
- \skip_horizontal:n { \l__spb_box_max_wd_tl + \l__spb_supersub_hmove_dim }
+ \skip_horizontal:n { \l__spb_box_max_wd_tl + \l__spb_supersub_hmove_tl }
\spb_hbox_overlap_vmove:n { left }
}
}
diff --git a/macros/latex/contrib/spbmark/spbmark.tex b/macros/latex/contrib/spbmark/spbmark.tex
index 8f9ed7f08d..93620fd8a7 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.2C,
- date = 2021/12/18,
+ version = v1.2E,
+ date = 2021/12/20,
authors = Qu Yi,
info = Customize superscript and subscript,
email = q1jx@foxmail.com,
@@ -67,6 +67,8 @@ There are currently three commands to set superscript and subscript. Their forma
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.
+ \command{spbifmath}[\marg{math code}\marg{text code}]
+ 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}.
@@ -74,7 +76,7 @@ The optional parameter \splitmeta{height}{depth} generally does not need to be u
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.
\begin{options}
\keyval{vmove}{fixed length}\Default{0pt}
- Vertical move of superscript or subscript. Represents the vertical distance \option{vsep} between superscript and subscript in the superscript and subscript commands.
+ Vertical move of superscript or subscript. Represents the extra vertical distance \option{vsep} between superscript and subscript in the superscript and subscript commands.
\keyval{hmove}{fixed length}\Default{0pt}
Horizontal move of superscript or subscript. Represents the common move in the superscript and subscript commands.
\keyval{cmd}{format cmds}\Default
@@ -116,7 +118,7 @@ The following list of keys control the format both of superscript or subscript.
Add code to the previous global subcript format commands.
\end{options}
-If \option{sphmove} is positive, the superscript or subscript moves to the right, and if it is negative, it moves to the left. However, for superscript, if \option{spvmove} is positive, the superscript moves up, and if spvmove is negative, it moves down. For subscripts, if \option{spvmove} is positive, the subscript moves down, and if spvmove is negative, it moves up.
+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.
The following list of keys control the format of superscript and subscript.
\begin{options}
@@ -127,7 +129,7 @@ The following list of keys control the format of superscript and subscript.
\kvsplit{spbcmd+}{super cmds}{sub cmds}\Default
Add code to the previous global superscript and subscript format commands.
\keyval{vsep}{fixed length}\Default{0.6ex}
- The vertical distance between superscript and subscript.
+ The extra vertical distance between superscript and subscript.
\keychoice{halign}{l,c,r}\Default{l}
The alignment of superscript and subscript, which contains \code{l}, \code{c}, and \code{r} parameters respectively for left, center, and right alignment.
\end{options}
@@ -135,7 +137,7 @@ The following list of keys control the format of superscript and subscript.
\section{Examples of use}
Here is a list of the three commands, please pay attention to the usage of optional parameters. Note when the horizontal move is negative, the starting point is at the right end of the mark.
\begin{example}
-\spbset{spbcmd={\ttfamily,\color{blue}}}
+\spbset{spbcmd={\spbifmath{\mathtt}{\ttfamily},\color{blue}}}
A\super[vmove=0.2ex,hmove=0.2em,cmd=\textcolor{red}]{exam}B \\
$A\sub[cmd=\mathsf,mode=math]{exam}B$ \\
A\supersub[vsep=0.6ex,halign=c]{examsuper}{sub}B \\