diff options
author | Karl Berry <karl@freefriends.org> | 2024-05-19 20:35:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-05-19 20:35:57 +0000 |
commit | 51685e2bc214c9a15b4900b4d3e7478b2c1881fe (patch) | |
tree | b213a7e749e96d38c3403e43c51486d34b109c3f | |
parent | ad142b19e22601544b06b4cc495bc80f62bc1a17 (diff) |
spbmark (19may24)
git-svn-id: svn://tug.org/texlive/trunk@71304 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/spbmark/spbmark.pdf | bin | 91761 -> 91750 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/spbmark/spbmark.tex | 41 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/spbmark/spbmark.sty | 64 |
3 files changed, 72 insertions, 33 deletions
diff --git a/Master/texmf-dist/doc/latex/spbmark/spbmark.pdf b/Master/texmf-dist/doc/latex/spbmark/spbmark.pdf Binary files differindex 5ad9b3e360d..8242e5e3bf8 100644 --- a/Master/texmf-dist/doc/latex/spbmark/spbmark.pdf +++ b/Master/texmf-dist/doc/latex/spbmark/spbmark.pdf diff --git a/Master/texmf-dist/doc/latex/spbmark/spbmark.tex b/Master/texmf-dist/doc/latex/spbmark/spbmark.tex index e631b4c2100..9d04ea07f91 100644 --- a/Master/texmf-dist/doc/latex/spbmark/spbmark.tex +++ b/Master/texmf-dist/doc/latex/spbmark/spbmark.tex @@ -8,8 +8,8 @@ { package = spbmark, title = the spbmark package, - version = v1.46i, - date = 2024/05/13, + version = v1.46j, + date = 2024/05/19, authors = Qu Yi, info = Customize superscript and subscript, email = toquyi@163.com, @@ -40,7 +40,7 @@ \newsplitarg{\splitoarg}{[}{]} \newsplitarg{\splitmarg}{\{}{\}} \newsplitarg{\splitdarg}{(}{)} -\newnote{\newtag}[1][New]{\textcolor{red}{#1}} +\newnote{\newtag}[1]{\textcolor{red}{#1}} \renewcommand{\emph}[1]{\textcolor{red}{#1}} \renewcommand{\cnltx@write@lastname}{} \makeatother @@ -49,12 +49,14 @@ \section{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{spbset}. \begin{options} - \keychoice{text}{true,\fbox{false}}\newtag[Changed]% - \cs{textsuperscript} and \cs{textsubscript} are equivalent to the \cs{super} and \cs{sub} commands. You can also use the \cs{defspbstyle} command to define the style \code{textsp} and \code{textsb} to change the format of the text superscript and subscript. - \keychoice{math}{true,\fbox{false}}\newtag[Changed]% - \cs{sp} and \cs{sb} are equivalent to the \cs{super} and \cs{sub} commands. You can also use the \cs{defspbstyle} command to define the style \code{mathsp} and \code{mathsb} to change the format of the math superscript and subscript. - \keychoice{foot}{true,\fbox{false}}\newtag[Changed]% - The format of the footnote mark match the superscript global move and format settings. You can also use the \cs{defspbstyle} command to define the superscript style \code{fnmark} to change the format of the footnote mark. + \keychoice{text}{true,\fbox{false}} + \cs{textsuperscript} and \cs{textsubscript} are equivalent to the \cs{super} and \cs{sub} commands. The command \cs{defspbstyle} can be used to define the style \code{textsp} and \code{textsb} to change the format of the text superscript and subscript. + \keychoice{math}{true,\fbox{false}} + \cs{sp} and \cs{sb} are equivalent to the \cs{super} and \cs{sub} commands. The command \cs{defspbstyle} can be used to define the style \code{mathsp} and \code{mathsb} to change the format of the math superscript and subscript. + \keychoice{math*}{true,\fbox{false}}\newtag{Exp\\v1.46j}% + The \code{\^{}} and \code{\_{}} tokens in the math mode are equivalent to the \cs{super} and \cs{sub} commands. The command \cs{defspbstyle} can be used to define the style \code{mathsp*} and \code{mathsb*} to change the format of the math superscript and subscript. + \keychoice{foot}{true,\fbox{false}} + The format of the footnote mark match the superscript global move and format settings. \cs{defspbstyle} can be used to define the superscript style \code{fnmark} to change the format of the footnote mark. \begin{example}[code-only] \defspbstyle{textsp}{vmove=-1pt,cmd=\bfseries} \defspbstyle{mathsb}{hmove=0.5em} @@ -152,7 +154,7 @@ 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% + \keychoice{thiswd}{auto,\fbox{keep}} 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}} @@ -161,7 +163,7 @@ The options common to \meta{kv list} of the three commands are as follows. They 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% + \keyval{regex}{regular expression} 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},#1]{#2}} @@ -206,13 +208,13 @@ 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% + \keychoice{spthiswd}{auto,\fbox{keep}} 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% + \keychoice{sbthiswd}{auto,\fbox{keep}} Width processing mode after using this subscript. See Section \ref{sec:user commands} for the meaning of this option. - \keyval{spregex}{regular expression}\newtag% + \keyval{spregex}{regular expression} 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% + \keyval{sbregex}{regular expression} 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} @@ -251,9 +253,12 @@ Here is a list of the three commands, please pay attention to the usage of optio \subsection{siunitx} It can also be used with the \pkg*{siunitx} package to output superscript and subscript in the unit: \begin{example} - \unit[mode=math]{kg.m/s\super[vmove=-1pt]{2}} \\ - \qty[mode=text]{30}{A\supersub[hmove=1pt,cmd=\color{red}]{b}{c}} \\ - \spbset{sbhmove=2pt}\unit[mode=text]{A\sub{b}} + \spbset{spcmd=\spbifmath{}{\color{purple}}} + \sisetup{text-superscript-command=\super} + 1-\qty[mode=text]{10}{A^2} \\ + 2-\unit[mode=math]{kg.m/s\super[vmove=-1pt]{2}} \\ + 3-\qty[mode=text]{30}{A\supersub[hmove=1pt,cmd=\color{blue}]{b}{c}} \\ + 4-\spbset{sbhmove=2pt}\unit[mode=text]{A\sub{b}} \end{example} \subsection{realscripts} diff --git a/Master/texmf-dist/tex/latex/spbmark/spbmark.sty b/Master/texmf-dist/tex/latex/spbmark/spbmark.sty index 9646dc1e00e..c1ce4837a57 100644 --- a/Master/texmf-dist/tex/latex/spbmark/spbmark.sty +++ b/Master/texmf-dist/tex/latex/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/05/13}{1.46i} +\ProvidesExplPackage{spbmark}{2024/05/19}{1.46j} {Customize superscripts and subscripts} \cs_generate_variant:Nn \box_set_ht:Nn { cv } @@ -22,6 +22,8 @@ \cs_generate_variant:Nn \tl_if_novalue:nF { V } \cs_generate_variant:Nn \tl_if_blank:nF { v } +\providecommand{\AfterPreamble}{\AtBeginDocument} +\AtBeginDocument{\cs_set_eq:NN \AfterPreamble \use:n} \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 @@ -30,46 +32,78 @@ \cs_new_protected:Npn \spb_define:n { \keys_define:nn { ctex/tools } } \cs_new_protected:Npn \spb_set:n { \keys_set:nn { ctex/tools } } \cs_set_eq:NN \spbset \spb_set:n + \keys_define:nn { spbmark/option } { text .choice:, - text/true .code:n = + text/true .code:n = { \cs_set:Npn \textsuperscript { \super[textsp] } \cs_set:Npn \textsubscript { \sub[textsb] } }, - text/false .code:n = + text/false .code:n = { \cs_set:Npn \textsuperscript { \spb@textsuperscript@save } \cs_set:Npn \textsubscript { \spb@textsubscript@save } }, - text .default:n = true, + text .default:n = true, math .choice:, - math/true .code:n = + math/true .code:n = { \cs_set:Npn \sp { \super[mathsp] } \cs_set:Npn \sb { \sub[mathsb] } }, - math/false .code:n = + math/false .code:n = { \cs_set:Npn \sp { \spb@math@super@save } \cs_set:Npn \sb { \spb@math@sub@save } }, - math .default:n = true, + math .default:n = true, foot .choice:, - foot/true .code:n = + foot/true .code:n = { \cs_set:Npn \@makefnmark { \hbox:n { \fnmarkfont{\super[fnmark]{\@thefnmark}} } } }, - foot/false .code:n = + foot/false .code:n = { \cs_set:Npn \@makefnmark { \spb@@makefnmark@save } }, - foot .default:n = true, - both .meta:n = { text = #1,math = #1 }, - both .default:n = true, - all .meta:n = { text = #1,math = #1,foot = #1 }, - all .default:n = true + foot .default:n = true, + both .meta:n = { text = #1,math = #1 }, + both .default:n = true, + all .meta:n = { text = #1,math = #1,foot = #1 }, + all .default:n = true + } +\char_set_catcode_active:N \~ +\keys_define:nn { spbmark/option } + { + math* .choice:, + math*/true .code:n = + { + \AfterPreamble + { + \group_begin: + \char_set_lccode:nn { `\~ } { `\^ } + \lowercase{\group_end:\cs_set:Npn ~} { \super[mathsp*] } + \group_begin: + \char_set_lccode:nn { `\~ } { `\_ } + \lowercase{\group_end:\cs_set:Npn ~} { \sub[mathsb*] } + \char_set_mathcode:nn { `\^ } { "8000 } + \char_set_catcode_other:N \^ + \char_set_catcode_other:N \_ + } + }, + math*/false .code:n = + { + \AfterPreamble + { + \char_set_catcode_math_superscript:N \^ + \char_set_catcode_math_subscript:N \_ + \char_set_mathcode:nn { `\^ } { "005E } + } + }, + math* .default:n = true } +\char_set_catcode_space:N \~ \tl_if_exist:NTF \ftntm@font { \tl_set_eq:NN \fnmarkfont \ftntm@font } { \tl_set_eq:NN \fnmarkfont \normalfont } @@ -112,7 +146,7 @@ \cs_new_protected:Npn \spbshortkv #1#2 { \spb_define:n { #1 .meta:n = {#2} } } \clist_map_inline:nn - { textsp,textsb,mathsp,mathsb,fnmark } + { textsp,textsb,mathsp,mathsb,mathsp*,mathsb*,fnmark } { \defspbstyle{#1}{} \spbshortkv{#1}{style = #1} |