summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/spbmark
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-02-14 03:01:19 +0000
committerNorbert Preining <norbert@preining.info>2024-02-14 03:01:19 +0000
commita90336c3069c198b41b7b6eb76e3389610ad5eb7 (patch)
tree1d39210ab0b0caece02b2322e3fd773db8385982 /macros/latex/contrib/spbmark
parentff59efb1f42e705d74a6d50a1f8dbd7988ccf380 (diff)
CTAN sync 202402140301
Diffstat (limited to 'macros/latex/contrib/spbmark')
-rw-r--r--macros/latex/contrib/spbmark/spbmark.pdfbin89117 -> 93819 bytes
-rw-r--r--macros/latex/contrib/spbmark/spbmark.sty63
-rw-r--r--macros/latex/contrib/spbmark/spbmark.tex50
3 files changed, 99 insertions, 14 deletions
diff --git a/macros/latex/contrib/spbmark/spbmark.pdf b/macros/latex/contrib/spbmark/spbmark.pdf
index 90e46b31bf..2a9f56f6c2 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 e846f52fde..41fa6ea8b1 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}{2024/02/06}{1.46b}
+\ProvidesExplPackage{spbmark}{2024/02/13}{1.46d}
{Customize superscripts and subscripts}
\cs_generate_variant:Nn \box_set_ht:Nn { cv }
@@ -341,6 +341,61 @@
}
}
}
+\spb_define:n
+ {
+ thiswd .code:n =
+ {
+ \spb_local_case_init:nnn
+ { \tl_set:Nn \l__spb_super_thiswd_mode_tl {#1} }
+ { \tl_set:Nn \l__spb_sub_thiswd_mode_tl {#1} } { }
+ },
+ regex .code:n =
+ {
+ \spb_local_case_init:nnn
+ { \tl_set:Nn \l__spb_super_regex_next_tl {#1} }
+ { \tl_set:Nn \l__spb_sub_regex_next_tl {#1} } { }
+ },
+ spthiswd .tl_set:N = \l__spb_super_thiswd_mode_tl,
+ spthiswd .initial:n = keep,
+ sbthiswd .tl_set:N = \l__spb_sub_thiswd_mode_tl,
+ sbthiswd .initial:n = keep,
+ spregex .tl_set:N = \l__spb_super_regex_next_tl,
+ spregex .initial:n = \c{sub}|\c{textsubscript}|\c{sb}|\_,
+ sbregex .tl_set:N = \l__spb_sub_regex_next_tl,
+ sbregex .initial:n = \c{super}|\c{textsuperscript}|\c{sp}|\^
+ }
+\cs_new:Npn \spb_clear_thiswd:n #1
+ {
+ \str_case:nn {#1}
+ {
+ { super }
+ {
+ \peek_regex:nF
+ { \exp_not:o { \l__spb_super_regex_next_tl } }
+ {
+ \exp_not:n
+ {
+ \dim_zero:N \llastwd
+ \dim_zero:N \clastwd
+ \dim_zero:N \rlastwd
+ }
+ }
+ }
+ { sub }
+ {
+ \peek_regex:nF
+ { \exp_not:o { \l__spb_sub_regex_next_tl } }
+ {
+ \exp_not:n
+ {
+ \dim_zero:N \llastwd
+ \dim_zero:N \clastwd
+ \dim_zero:N \rlastwd
+ }
+ }
+ }
+ }
+ }
\cs_new_protected:Npn \spb_both_newcmd_map:n #1
{
@@ -354,7 +409,13 @@
\spb_content_hbox_set:nn {#1} {##1}
\spb_ht_dp_assign:nnnn {#1} {#1} { i } { _outer }
\box_use:c { l__#1_i_outer_box }
+ \exp_last_unbraced:Nx
\group_end:
+ {
+ \exp_args:Nv \str_if_eq:nnT
+ { l__spb_#1_thiswd_mode_tl } { auto }
+ { \spb_clear_thiswd:n {#1} }
+ }
}
}
\cs_new_protected:Npn \spb_content_hbox_set:nn #1#2
diff --git a/macros/latex/contrib/spbmark/spbmark.tex b/macros/latex/contrib/spbmark/spbmark.tex
index 2c9319118c..9fbf4962cf 100644
--- a/macros/latex/contrib/spbmark/spbmark.tex
+++ b/macros/latex/contrib/spbmark/spbmark.tex
@@ -7,8 +7,8 @@
{
package = spbmark,
title = the spbmark package,
- version = v1.46b,
- date = 2024/02/06,
+ version = v1.46d,
+ date = 2024/02/13,
authors = Qu Yi,
info = Customize superscript and subscript,
email = toquyi@163.com,
@@ -46,7 +46,6 @@
\begin{document}
\section{Macro package options}
-\label{sec:macro package options}
The following macro package options will redefine the script commands of the \LaTeX{} kernel. If you do not specify the values of boolean options, they default to \code{true}. These options can also be changed in the preamble area and main body using the global control command \cs{sbpset}.
\begin{options}
\keychoice{text}{true,\fbox{false}}\newtag[Changed]%
@@ -72,7 +71,8 @@ The following macro package options will redefine the script commands of the \La
\end{options}
\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}.
+\label{sec: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}[\sarg\oarg{kv list}\marg{content}\oarg{kv list}]
This is a superscript output command. The two \meta{kv list} are equivalent.
@@ -82,11 +82,11 @@ There are currently three commands to set superscript and subscript. Their forma
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%
+ \command{llastwd}
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%
+ \command{clastwd}
Save the width of the previous marker and provide center alignment.
- \command{rlastwd}\newtag%
+ \command{rlastwd}
Save the width of the previous marker and provide right alignment. Actually this is the width of the next marker.
\begin{example}
1A\super{bcd}\sub{e}B \\
@@ -118,7 +118,7 @@ There are currently three commands to set superscript and subscript. Their forma
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%
+ \command{spbshortkv}[\marg{short opt}\marg{key value}]
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}
\spbshortkv{x}{sphmove=#1}
@@ -151,6 +151,21 @@ The options common to \meta{kv list} of the three commands are as follows. They
Use the \meta{style name} defined by the \cs{defspbstyle} command to make it work global or local.
\keychoice{mode}{text,math,\fbox{match}}
The mode of superscript or subscript output can be \code{text} or \code{math} mode. The \code{match} option automatically matches output modes according to the current mode.
+ \keychoice{thiswd}{auto,\fbox{keep}}\newtag%
+ Sets how the length of the this marker is handled after this command is used. If it is \code{keep}, the width of the previous marker remains the same. If it is \code{auto}, if the next token is a marker command and the upper or lower position is the \textcolor{red}{opposite} of the this command, the width of the this marker is maintained, otherwise the width automatically returns to \textcolor{red}{zero}.
+ \begin{example}
+ \spbset{sbhmove=-\llastwd,sbthiswd=auto,sbcmd=\color{red}}
+ 1A\super{bcd}\sub[thiswd=keep]{e}Some texts\sub{e} \\
+ 3A\super{bcd}\sub{e}Some texts\sub{e} \\
+ 3A\sub{bcd}[thiswd=keep]\sub{e}Some texts\sub{e} \\
+ 4A\sub{bcd}\sub{e}Some texts\sub{e}
+ \end{example}
+ \keyval{regex}{regular expression}\newtag%
+ After using the superscript or subscript command, this option is used to determine whether the \textcolor{red}{following} tokens match the \meta{regular expression}. If it does \textcolor{red}{not}, the width of the this marker returns to zero.
+ \begin{example}[code-only]
+ \newcommand{\mysp}[2][]{\super[regex=\c{mysb},#2]{#1}}
+ \newcommand{\mysb}[2][]{\sub[regex=\c{mysp},#2]{#1}}
+ \end{example}
\end{options}
\section{Global control interface}
@@ -190,6 +205,14 @@ The following list of keys control the format both of superscript \emph{or} subs
The distance between the subscript baseline and the previous line.
\keyval{sbdepth}{fixed length}
The distance between the subscript baseline and the next line.
+ \keychoice{spthiswd}{auto,\fbox{keep}}\newtag%
+ Width processing mode after using this superscript. See Section \ref{sec:user commands} for the meaning of this option.
+ \keychoice{sbthiswd}{auto,\fbox{keep}}\newtag%
+ Width processing mode after using this subscript. See Section \ref{sec:user commands} for the meaning of this option.
+ \keyval{spregex}{regular expression}\newtag%
+ After the superscript command is used, the regular expression rules of the following tokens are matched. See Section \ref{sec:user commands} for the meaning of this option.
+ \keyval{sbregex}{regular expression}\newtag%
+ After the subscript command is used, the regular expression rules of the following tokens are matched. See Section \ref{sec:user commands} for the meaning of this option.
\end{options}
If \option{sphmove} is positive, the superscript or subscript moves to the right, conversely it moves to the left. The positive direction of vertical offset of subscript and superscript is opposite. 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.
@@ -206,7 +229,7 @@ The following list of keys control the format of superscript \emph{and} subscrip
The distance between the superscript baseline and the previous line.
\keyval{spbdepth}{fixed length}
The distance between the subscript baseline and the next line.
- \kvsplit{vsep}{super move}{sub move}\Default{0.6ex}\newtag[Changed]%
+ \kvsplit{vsep}{super move}{sub move}\Default{0.6ex}
The extra vertical distance between superscript and subscript. The front part is the movement amount of the superscript, and the latter part is the movement amount of the subscript. If only the front part means that both are vertically shifted by one-half of the current value.
\keychoice{halign}{\fbox{l},c,r}
The alignment of superscript and subscript, which contains \code{l}, \code{c}, and \code{r} parameters respectively for left, center, and right alignment.
@@ -220,7 +243,8 @@ Here is a list of the three commands, please pay attention to the usage of optio
1A\super[vmove=0.2ex,hmove=0.2em,cmd=\textcolor{red}]{exam}B \\
2$A\sub[style=fancy,cmd+=\mathsf,mode=math]{exam}B$ \\
3A\supersub[vsep=0.6ex,halign=c]{examsuper}{sub}B \\
- 4A\super{c}[vmove=5pt,hmove=-5.5pt]B\sub[vmove=5pt,hmove=-5pt]{d}AB
+ 4A\super{c}[vmove=5pt,hmove=-5.5pt]B\sub[vmove=5pt,hmove=-5pt]{d}AB \\
+ 5A\super{c\super{d}}B
\end{example}
\subsection{siunitx}
@@ -232,15 +256,15 @@ It can also be used with the \pkg*{siunitx} package to output superscript and su
\end{example}
\subsection{realscripts}
-If the OpenType text font you are using does not have optical sizes, the superscript and subscript may not appear correctly. Loading the \pkg*{realscripts} macro package before the \pkg*{spbmark} macro package fixes this behavior.
+If the OpenType text font you are using does not have optical sizes, the superscript and subscript may not appear correctly. Loading the \pkg*{realscripts} package before the \pkg*{spbmark} package fixes this behavior.
\begin{example}[code-only]
\usepackage{realscripts,spbmark}
\end{example}
\subsection{altsubsup}
-The \pkg*{altsubsup} package allows to write alternate superscript and subscript in math mode with \code{\^{}}\oarg{mark} and \code{\_{}}\oarg{mark} dimensions. When the macro package is loaded using the \code{spbmark} option, the superscript and subscript mechanism of \pkg*{spbmark} is used, you can use \cs{defspbstyle} to define its superscript style \code{altsup} and subscript style \code{altsub}.
+The \pkg*{altsubsup} package allows to write alternate superscript and subscript in math mode with \code{\^{}}\oarg{mark} and \code{\_{}}\oarg{mark} dimensions. When the package is loaded using the \code{spbmark} option, the superscript and subscript mechanism of \pkg*{spbmark} is used, you can use \cs{defspbstyle} to define its superscript style \code{altsup} and subscript style \code{altsub}.
\begin{example}
- \defspbstyle{altsup}{sphmove=-\llastwd,spvmove=1pt}
+ \defspbstyle{altsup}{sphmove=-\llastwd,spthiswd=auto,spvmove=1pt}
$A_[bcd]^[e]B$
\end{example}