summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/spbmark
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-03-06 03:01:07 +0000
committerNorbert Preining <norbert@preining.info>2022-03-06 03:01:07 +0000
commita2c331d17828388705046ea495e5fe5135bbcc83 (patch)
treebc7f9b50750ad2331f4495f511f6e71ac13bf680 /macros/latex/contrib/spbmark
parent19a90b19f6ec33aec1291be08fecfece45735a22 (diff)
CTAN sync 202203060301
Diffstat (limited to 'macros/latex/contrib/spbmark')
-rw-r--r--macros/latex/contrib/spbmark/README.md2
-rw-r--r--macros/latex/contrib/spbmark/spbmark.pdfbin81909 -> 85057 bytes
-rw-r--r--macros/latex/contrib/spbmark/spbmark.sty109
-rw-r--r--macros/latex/contrib/spbmark/spbmark.tex49
4 files changed, 97 insertions, 63 deletions
diff --git a/macros/latex/contrib/spbmark/README.md b/macros/latex/contrib/spbmark/README.md
index ed915ca1ca..93032ca368 100644
--- a/macros/latex/contrib/spbmark/README.md
+++ b/macros/latex/contrib/spbmark/README.md
@@ -1,6 +1,6 @@
# The spbmark package
-Spbmark provides three commands \super, \sub and \supersub to improve the layout of superscripts and subscripts which can be adjusted the relative position and format, and can be used in text and math mode.
+`spbmark` provides three commands `\super`, `\sub` and `\supersub` to improve the layout of superscripts and subscripts which can be adjusted the relative position and format, and can be used in text and math mode.
## License
diff --git a/macros/latex/contrib/spbmark/spbmark.pdf b/macros/latex/contrib/spbmark/spbmark.pdf
index 93f58f43bd..16a9936fff 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 e78f1db659..86ebb2a100 100644
--- a/macros/latex/contrib/spbmark/spbmark.sty
+++ b/macros/latex/contrib/spbmark/spbmark.sty
@@ -9,14 +9,15 @@
% https://creativecommons.org/licenses/by/4.0/legalcode
\NeedsTeXFormat{LaTeX2e}[2018/12/31]
\RequirePackage{xparse,l3keys2e}
-\ProvidesExplPackage{spbmark}{2022/03/04}{1.39}
+\ProvidesExplPackage{spbmark}{2022/03/05}{1.4}
{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_gset:Nn { Nv }
-\cs_generate_variant:Nn \dim_compare:nNnTF { V }
+\cs_generate_variant:Nn \dim_abs:n { V,v }
+\cs_generate_variant:Nn \dim_compare:nNnTF { V,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 }
@@ -120,9 +121,9 @@
novmove .meta:n = { spvmove = 0pt,sbvmove = 0pt }
}
\cs_new:Npn \spb_box_super_move_up_i:n #1
- { \box_move_up:nn {#1} { \box_use:N \l__super_i_box } }
+ { \box_move_up:nn {#1} { \box_use:N \l__super_i_inner_box } }
\cs_new:Npn \spb_box_sub_move_down_i:n #1
- { \box_move_down:nn {#1} { \box_use:N \l__sub_i_box } }
+ { \box_move_down:nn {#1} { \box_use:N \l__sub_i_inner_box } }
\cs_new:Npn \spb_box_super_move_up_ii:n #1
{ \box_move_up:nn {#1} { \box_use:N \l__super_ii_box } }
\cs_new:Npn \spb_box_sub_move_down_ii:n #1
@@ -216,30 +217,31 @@
{ \tl_set:Nn \l__sub_depth_ii_tl {#1} }
}
}
-\cs_new_protected:Npn \spb_ht_dp_assign:nnn #1#2#3
+\cs_new_protected:Npn \spb_ht_dp_assign:nnnn #1#2#3#4
{
\tl_if_blank:vF { l__#1_height_#3_tl }
- { \box_set_ht:cv { l__#1_#3_box } { l__#1_height_#3_tl } }
+ { \box_set_ht:cv { l__#1_#3#4_box } { l__#1_height_#3_tl } }
\tl_if_blank:vF { l__#1_depth_i_tl }
- { \box_set_dp:cv { l__#2_#3_box } { l__#2_depth_#3_tl } }
+ { \box_set_dp:cv { l__#2_#3#4_box } { l__#2_depth_#3_tl } }
}
-\box_new:N \l__super_i_box
-\box_new:N \l__sub_i_box
+\box_new:N \l__super_i_outer_box
+\box_new:N \l__super_i_inner_box
+\box_new:N \l__sub_i_outer_box
+\box_new:N \l__sub_i_inner_box
\box_new:N \l__super_ii_box
\box_new:N \l__sub_ii_box
\dim_new:N \llastwd
\dim_new:N \clastwd
\dim_new:N \rlastwd
-\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_box_super_wd_ii_tl \l__spb_box_sub_wd_ii_tl }
+\tl_set:Nn \superwd { \box_wd:N \l__super_ii_box }
+\tl_set:Nn \subwd { \box_wd:N \l__sub_ii_box }
+\tl_set:Nn \maxwd { \dim_max:VV \superwd \subwd }
+\tl_set:Nn \l__spb_box_super_wd_i_tl { \box_wd:N \l__super_i_inner_box }
+\tl_set:Nn \l__spb_box_sub_wd_i_tl { \box_wd:N \l__sub_i_inner_box }
\cs_new:Npn \spb_math_print_store_i:nn #1#2
{
- \hbox_set:cn { l__#1_i_box }
+ \hbox_gset:cn { l__#1_i_inner_box }
{
\ensuremath
{
@@ -251,7 +253,7 @@
}
\cs_new:Npn \spb_text_print_store_i:nn #1#2
{
- \hbox_set:cn { l__#1_i_box }
+ \hbox_gset:cn { l__#1_i_inner_box }
{
\use:c { spb@text#1script@save }
{ \tl_use:c { l__spb_#1_cmd_i_tl }{#2} }
@@ -260,16 +262,16 @@
}
\cs_new:Npn \spb_math_print_store_ii:nn #1#2
{
- \hbox_set:Nn \l__super_ii_box
+ \hbox_gset:Nn \l__super_ii_box
{ \ensuremath{\spb@math@super@save{\l__spb_super_cmd_ii_tl{#1}}} }
- \hbox_set:Nn \l__sub_ii_box
+ \hbox_gset: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__super_ii_box
+ \hbox_gset:Nn \l__super_ii_box
{ \spb@textsuperscript@save{\l__spb_super_cmd_ii_tl{#1}} }
- \hbox_set:Nn \l__sub_ii_box
+ \hbox_gset:Nn \l__sub_ii_box
{ \spb@textsubscript@save{\l__spb_sub_cmd_ii_tl{#2}} }
}
\cs_set_eq:NN \spbifmath \use_ii:nn
@@ -306,32 +308,38 @@
\cs_new_protected:Npn \spb_both_newcmd_map:n #1
{
- \exp_args:Nc \NewDocumentCommand {#1}{O{}mO{}}
+ \exp_args:Nc \NewDocumentCommand {#1}{sO{}mO{}}
{
\group_begin:
\mode_leave_vertical:
\tl_gset:Nn \g__spb_mark_case_init_tl {#1}
\spb_define:n { unknown .undefine: }
- \spb_set:n { ##1,##3 }
- \spb_mode_switch:nnn {#1} {##2} { i }
- \spb_content_hbox_set:n {#1}
- \spb_ht_dp_assign:nnn {#1} {#1} { i }
- \box_use:c { l__#1_i_box }
+ \spb_set:n { ##2,##4 }
+ \spb_mode_switch:nnn {#1} {##3} { i }
+ \spb_content_hbox_set:nn {#1} {##1}
+ \spb_ht_dp_assign:nnnn {#1} {#1} { i } { _outer }
+ \box_use:c { l__#1_i_outer_box }
\group_end:
}
}
-\cs_new_protected:Npn \spb_content_hbox_set:n #1
+\cs_new_protected:Npn \spb_content_hbox_set:nn #1#2
{
\dim_gset:Nn \clastwd { (\llastwd + \rlastwd)/2 }
- \hbox_set:cn { l__#1_i_box }
+ \tl_set:Nn \abs@hmove@i { \dim_abs:v { l__spb_#1_hmove_tl } }
+ \hbox_set:cn { l__#1_i_outer_box }
{
- \dim_compare:nNnTF { \tl_use:c { l__spb_#1_hmove_tl } } < { 0pt }
+ \dim_compare:vNnTF { l__spb_#1_hmove_tl } < { 0pt }
{
\hbox_overlap_left:n
{
\hbox_overlap_right:n
{ \spb_box_vmove_i:nn {#1} { \tl_use:c { l__spb_#1_vmove_tl } } }
- \skip_horizontal:n { \dim_abs:n { \tl_use:c { l__spb_#1_hmove_tl } } }
+ \skip_horizontal:n { \abs@hmove@i }
+ }
+ \IfBooleanT{#2}
+ {
+ \dim_compare:nNnT { \abs@hmove@i } < { \rlastwd }
+ { \skip_horizontal:n { \rlastwd - \abs@hmove@i } }
}
}
{
@@ -340,22 +348,30 @@
{ \hss\spb_box_vmove_i:nn {#1} { \tl_use:c { l__spb_#1_vmove_tl } } }
}
}
- \dim_gset:Nn \llastwd
- { \tl_use:c { l__spb_box_#1_wd_i_tl } - \tl_use:c { l__spb_#1_hmove_tl } }
+ \dim_gset:Nv \llastwd { l__spb_box_#1_wd_i_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_tl < { 0pt } {#1} {#2} }
-\NewDocumentCommand{\supersub}{O{}mmO{}}
+\tl_set:Nn \abs@hmove@ii { \dim_abs:V \l__spb_supersub_hmove_tl }
+\cs_new:Npn \spb_supersub_avoid_overlap:n #1
+ {
+ \IfBooleanT{#1}
+ {
+ \dim_compare:nNnT { \abs@hmove@ii } < { \maxwd }
+ { \skip_horizontal:n { \maxwd - \abs@hmove@ii } }
+ }
+ }
+\NewDocumentCommand{\supersub}{sO{}mmO{}}
{
\group_begin:
\mode_leave_vertical:
\tl_gset:Nn \g__spb_mark_case_init_tl { supersub }
\spb_define:n { unknown .undefine: }
- \spb_set:n {#1,#4}
- \spb_mode_switch:nnn {#2} {#3} { ii }
- \spb_ht_dp_assign:nnn { super } { sub } { ii }
+ \spb_set:n {#2,#5}
+ \spb_mode_switch:nnn {#3} {#4} { ii }
+ \spb_ht_dp_assign:nnnn { super } { sub } { ii } { }
\str_case:VnF \l__spb_supersub_halign_tl
{
{ l } { \use_i:nnn }
@@ -372,15 +388,16 @@
\hbox_overlap_left:n
{
\spb_hbox_overlap_vmove_ii:n { right }
- \skip_horizontal:n { \dim_abs:n { \l__spb_supersub_hmove_tl } }
+ \skip_horizontal:n { \abs@hmove@ii }
}
+ \spb_supersub_avoid_overlap:n {#1}
}
{
\hbox:n
{
\skip_horizontal:n { \l__spb_supersub_hmove_tl }
\spb_hbox_overlap_vmove_ii:n { right }
- \skip_horizontal:n { \l__spb_box_max_wd_tl }
+ \skip_horizontal:n { \maxwd }
}
}
}
@@ -390,16 +407,16 @@
\hbox_overlap_left:n
{
\spb_hbox_overlap_vmove_ii:n { center }
- \skip_horizontal:n
- { \dim_abs:n { \l__spb_supersub_hmove_tl + \l__spb_box_max_wd_tl/2 } }
+ \skip_horizontal:n { \abs@hmove@ii - \maxwd/2 }
}
+ \spb_supersub_avoid_overlap:n {#1}
}
{
\hbox:n
{
- \skip_horizontal:n { \l__spb_box_max_wd_tl/2 + \l__spb_supersub_hmove_tl }
+ \skip_horizontal:n { \maxwd/2 + \l__spb_supersub_hmove_tl }
\spb_hbox_overlap_vmove_ii:n { center }
- \skip_horizontal:n { \l__spb_box_max_wd_tl/2 }
+ \skip_horizontal:n { \maxwd/2 }
}
}
}
@@ -409,14 +426,14 @@
\hbox_overlap_left:n
{
\spb_hbox_overlap_vmove_ii:n { left }
- \skip_horizontal:n
- { \dim_abs:n { \l__spb_supersub_hmove_tl + \l__spb_box_max_wd_tl } }
+ \skip_horizontal:n { \abs@hmove@ii - \maxwd }
}
+ \spb_supersub_avoid_overlap:n {#1}
}
{
\hbox:n
{
- \skip_horizontal:n { \l__spb_box_max_wd_tl + \l__spb_supersub_hmove_tl }
+ \skip_horizontal:n { \maxwd + \l__spb_supersub_hmove_tl }
\spb_hbox_overlap_vmove_ii:n { left }
}
}
diff --git a/macros/latex/contrib/spbmark/spbmark.tex b/macros/latex/contrib/spbmark/spbmark.tex
index 7cdd0b2bfd..4405722a19 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.39,
- date = 2022/03/04,
+ version = v1.4,
+ date = 2022/03/05,
authors = Qu Yi,
info = Customize superscript and subscript,
email = q1jx@foxmail.com,
@@ -55,7 +55,7 @@ The following macro package options will redefine the script commands of the \La
\keybool{math}\Default{false}
\cs{sp} and \cs{sb} are equivalent to the \cs{super} and \cs{sub} commands.
\keybool{foot}\Default{false}
- The format of the footnote mark match the superscript move and format of the \cs{spbset} global setting.
+ The format of the footnote mark match the superscript global move and format settings.
\opt{both}
The values of \option{text} and \option{math} two options are \code{true} at the same time.
\opt{all}
@@ -69,26 +69,20 @@ The following macro package options will redefine the script commands of the \La
\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}\marg{content}\oarg{kv list}]
+ \command{super}[\sarg\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}\marg{content}\oarg{kv list}]
+ \command{sub}[\sarg\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.
- \command{defspbstyle}[\marg{style name}\marg{kv list}]
- Defines the style of the superscript or subscript used for the \option{style} option.
- \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.
When the horizontal movement distance of the marker is \emph{non-negative}, since the \cs{super} and \cs{sub} commands put the marker in a horizontal box, the horizontal position is staggered when using superscript and subscript \emph{consecutively}, which is a different mechanism than the sequential use of \code{\^{}} and \code{\_} symbols in math mode. The following three commands save the width of the previous marker, use it for negative move of the \option{hmove} option of the next marker, and provide the corresponding alignment.
It should be noted that the following commands should save the longer width of the marker, that is, the longer width of the marker in the front, the shorter width of the marker in the back. This is due to the fact that horizontal movement uses a negative distance to leave the marker in a zero-width box state.
\command{llastwd}\newtag%
- Save the width of the previous marker and provide left alignment.
+ Save the width of the previous marker and provide left alignment. This is actually the width of the previous marker, and is the same as the value of \cs{rlastwd} after the next command is used.
\command{clastwd}\newtag%
- Save the width of the previous marker and provide center alignment.
+ Save the width of the previous marker and provide center alignment.
\command{rlastwd}\newtag%
- Save the width of the previous marker and provide right alignment.
+ Save the width of the previous marker and provide right alignment. Actually this is the width of the next marker.
\begin{example}
A\super{bcd}\sub{e}B \\
A\super{bcd}\sub[hmove=-\llastwd]{e}B \\
@@ -96,6 +90,29 @@ There are currently three commands to set superscript and subscript. Their forma
A\super{bcd}\sub[hmove=-\clastwd]{e}B \\
A\super{bcd}\sub[hmove=-\rlastwd]{e}B \\
\end{example}
+ \command{supersub}[\sarg\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{superwd}
+ Save the width of the superscript in the previous super-subscript command.
+ \command{subwd}
+ Save the width of the subscript in the previous super-subscript command.
+ \command{maxwd}
+ Save the maximum width of superscript and subscript in the previous super-subscript command. That is, it is the larger of the \cs{superwd} and \cs{subwd} commands.
+
+ If horizontally move is negative and its absolute value is \emph{less} than the maximum width of the marker, then the marker overlaps the subsequent text. To avoid this use the command with the \emph{asterisk} parameter or adjust the horizontal distance with the marker length commands.
+ \begin{example}
+ \spbset{spvmove=5pt,vsep=1.8ex,spcmd=\color{blue}}
+ A\super[hmove=-8pt]{super}B \\
+ A\supersub[hmove=-8pt]{examsuper}{sub}B \\
+ A\super*[hmove=-8pt]{super}B \\
+ A\supersub*[hmove=-8pt]{examsuper}{sub}B \\
+ A\super[hmove=-8pt]{super}\hspace{\dimexpr(\llastwd-8pt)}B \\
+ A\supersub[hmove=-8pt]{examsuper}{sub}\hspace{\dimexpr(\maxwd-8pt)}B
+ \end{example}
+ \command{defspbstyle}[\marg{style name}\marg{kv list}]
+ Defines the style of the superscript or subscript used for the \option{style} option.
+ \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.
\command{spbshortkv}[\marg{short opt}\marg{key value}]\newtag%
Converts any existing key-value pair to a shorthand option. The value of key \code{\#1} indicates that the shorthand option needs to be assigned a value.
\begin{example}
@@ -110,9 +127,9 @@ There are currently three commands to set superscript and subscript. Their forma
The options common to \meta{kv list} of the three commands are as follows. They can also be used in \meta {key-value list} of the \cs{spbset} command. In this situation, in addition to \option{style} and \option{mode}, they will be 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.
+ Vertical move of superscript or subscript. Represents the extra vertical distance \option{vsep} between superscript and subscript in super-subscript command. The vertical movement starts at the marker horizontal baseline position.
\keyval{hmove}{fixed length}\Default{0pt}
- Horizontal move of superscript or subscript. Represents the common move in the superscript and subscript commands. Moved values can be expressed mathematically:
+ Horizontal move of superscript or subscript. Represents the \emph{common} move of superscript and subscript in super-subscript command. The starting point for horizontal movement is to the left of the marker. Moved values can be expressed mathematically:
\begin{example}
A\super{b}[vmove=0.4ex+4pt/2,hmove=2pt*3-11.5pt] \\
A\supersub[vsep={3pt,6pt-2bp}]{examsuper}{sub}