summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/spbmark/spbmark.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/spbmark/spbmark.dtx')
-rw-r--r--macros/latex/contrib/spbmark/spbmark.dtx92
1 files changed, 66 insertions, 26 deletions
diff --git a/macros/latex/contrib/spbmark/spbmark.dtx b/macros/latex/contrib/spbmark/spbmark.dtx
index ba9cc49e69..b2666aab80 100644
--- a/macros/latex/contrib/spbmark/spbmark.dtx
+++ b/macros/latex/contrib/spbmark/spbmark.dtx
@@ -23,7 +23,7 @@
%
% \title{\pkg{spbmark} -- Customize superscripts and subscripts}
% \author{Qu Yi}
-% \date{2021/07/22\hskip 1em\relax v1.03\thanks{\url{https://github.com/texl3/spbmark}}}
+% \date{2021/07/23\hskip 1em\relax v1.04\thanks{\url{https://github.com/texl3/spbmark}}}
%
% \maketitle
% \begin{abstract}
@@ -53,7 +53,7 @@
% \tn{super} command is used to output superscripts, \tn{sub} command is used to output subscripts, \tn{supersub} command is used to output both superscripts and subscripts.
% \end{function}
%
-% They match the corresponding pattern depending on whether they are currently in text mode or mathematical mode, or they can use an asterisk variant to force the mathematical pattern. The \meta{vshift} and \meta{hshift} represent respectively vertical and horizontal offsets of superscript or subscript, their default value is 0 pt, and the parameters of \meta{script align} are the same as the \texttt{supersubalign}.
+% They match the corresponding pattern depending on whether they are currently in text mode or mathematical mode, or they can use an asterisk variant to force the mathematical pattern. The \meta{vshift} and \meta{hshift} represent respectively vertical and horizontal offsets of superscript or subscript, their default value is \texttt{0pt}, and the parameters of \meta{script align} are the same as the \texttt{supersubalign}.
%
% The second optional parameter generally does not need to be used. The \meta{height} and \meta{depth} are separated by commas. Only the front part indicates the height of the superscript or subscript, and only the back part indicates the depth.
%
@@ -66,22 +66,23 @@
% \end{function}
%
% \section{Global control interface}
-% \begin{function}[added = 2021-06-26]{\spbset}
+% \begin{function}[added = 2021-06-26,updated = 2021-07-23]{\spbset}
% \begin{syntax}
% \tn{spbset}\marg{key-value list}
% \end{syntax}
-% \pkg{spbmark} uses the \tn{spbset} command to control the global default format of superscripts and subscripts. The values ​​set by it will be overwritten by the optional parameters of the superscript and other commands. The list of key values it has is as follows:
+% \pkg{spbmark} uses the \tn{spbset} command to control the global default format of superscripts and subscripts. The values ​​set by it will be overwritten by the optional parameters of the superscript and other commands.
% \end{function}
%
-% \begin{function}{super-vshift,super-hshift,sub-vshift,sub-hshift,supersubsep,supersubalign}
+% \begin{function}{super-vshift,super-hshift,sub-vshift,sub-hshift,super-format,sub-format}
% \begin{syntax}
% super-vshift = <fixed length>
% super-hshift = <fixed length>
% sub-vshift = <fixed length>
% sub-hshift = <fixed length>
-% supersubsep = <fixed length>
-% supersubalign = <horizontal alignment>
+% super-format = <format code>
+% sub-format = <format code>
% \end{syntax}
+% These list of keys control the format of superscript or subscript. They are equivalent to the optional parameters of the \tn{super} or \tn{sub} commands.
% \end{function}
%
% \noindent
@@ -89,17 +90,35 @@
% \DescribeOption{super-hshift} Extra horizontal shift of the superscripts. \\
% \DescribeOption{sub-vshift} Extra vertical shift of the subscripts. \\
% \DescribeOption{sub-hshift} Extra horizontal shift of the subscripts. \\
-% \DescribeOption{supersubsep} The distance between superscript and subscript when using \tn{supersub}, its default value is 0.3 ex. \\
-% \DescribeOption{supersubalign} The alignment of superscript and subscript when using \tn{supersub}, which contains l, c, and r parameters respectively for left, center, and right alignment. \\
+% \DescribeOption{super-format} Control the format of superscripts, the last command in the code can take an argument, which is a superscript. \\
+% \DescribeOption{sub-format} Control the format of subscripts, the last command in the code can take an argument, which is a subscript.
+%
+% \begin{function}{supersub-hshift,supersub-format,supersubsep,supersubalign}
+% \begin{syntax}
+% supersub-hshift = <fixed length>
+% supersub-format = \{<super code>,<sub code>\}
+% supersubsep = <fixed length>
+% supersubalign = <horizontal alignment>
+% \end{syntax}
+% These list of keys control the format of superscripts and subscripts. They are equivalent to the optional parameters of the \tn{supersub} command.
+% \end{function}
+%
+% \noindent
+% \DescribeOption{supersub-hshift} Extra vertical shift of the superscripts and the subscripts. \\
+% \DescribeOption{supersub-format} Control the format of superscripts or subscripts. The first part is in superscript format, and the latter part is in subscript format. The two are separated by commas, or only the first part exists. \\
+% \DescribeOption{supersubsep} The distance between superscripts and subscripts, its default value is \texttt{0.3ex}. \\
+% \DescribeOption{supersubalign} The alignment of superscripts and subscripts, which contains \texttt{l}, \texttt{c}, and \texttt{r} parameters respectively for left, center, and right alignment.
%
% \section{Examples of use}
% Here is a list of the three commands, please pay attention to the delimiter and usage of optional parameters:
% \begin{quotation}
% \noindent
-% |A\super[0.2ex](\color{red}){exam}[0.2em]B| \\
+% |\spbset{supersub-format = {\ttfamily,\color{blue}}}| \\
+% |A\super[0.2ex](\textcolor{red}){exam}[0.2em]B| \\
% |$A\sub(\mathsf){exam}B$| \\
% |A\supersub[0.3ex][c]{examsuper}{sub}B| \\
-% A\super[0.2ex](\color{red}){exam}[0.2em]B \\
+% \spbset{supersub-format = {\ttfamily,\color{blue}}}
+% A\super[0.2ex](\textcolor{red}){exam}[0.2em]B \\
% $A\sub(\mathsf){exam}B$ \\
% A\supersub[0.3ex][c]{examsuper}{sub}B
% \end{quotation}
@@ -136,7 +155,7 @@
%<*package>
\NeedsTeXFormat{LaTeX2e}[2018/12/31]
\RequirePackage{xparse,l3keys2e}
-\ProvidesExplPackage{spbmark}{2021/07/22}{1.03}
+\ProvidesExplPackage{spbmark}{2021/07/23}{1.04}
{Customize superscripts and subscripts}
\cs_new_protected:Npn \spb_define:n { \keys_define:nn { spbmark } }
@@ -155,20 +174,27 @@
\ProcessKeysOptions{spbmark/option}
+\tl_new:N \l__spb_super_script_formatii_tl
+\tl_new:N \l__spb_sub_script_formatii_tl
\spb_define:n
{
- super-vshift .dim_set:N = \l__spb_super_script_vshift_dim,
- super-vshift .initial:n = 0pt,
- super-hshift .dim_set:N = \l__spb_super_script_hshift_dim,
- super-hshift .initial:n = 0pt,
- sub-vshift .dim_set:N = \l__spb_sub_script_vshift_dim,
- sub-vshift .initial:n = 0pt,
- sub-hshift .dim_set:N = \l__spb_sub_script_hshift_dim,
- sub-hshift .initial:n = 0pt,
- supersubsep .dim_set:N = \l__spb_supersub_script_sep_dim,
- supersubsep .initial:n = 0.3ex,
- supersubalign .tl_set:N = \l__spb_supersub_script_align_tl,
- supersubalign .initial:n = l
+ super-vshift .dim_set:N = \l__spb_super_script_vshift_dim,
+ super-vshift .initial:n = 0pt,
+ super-hshift .dim_set:N = \l__spb_super_script_hshift_dim,
+ super-hshift .initial:n = 0pt,
+ sub-vshift .dim_set:N = \l__spb_sub_script_vshift_dim,
+ sub-vshift .initial:n = 0pt,
+ sub-hshift .dim_set:N = \l__spb_sub_script_hshift_dim,
+ sub-hshift .initial:n = 0pt,
+ supersub-hshift .dim_set:N = \l__spb_supersub_script_hshift_dim,
+ supersub-hshift .initial:n = 0pt,
+ super-format .tl_set:N = \l__spb_super_script_formati_tl,
+ sub-format .tl_set:N = \l__spb_sub_script_formati_tl,
+ supersub-format .code:n = \spb_both_format_assign:n {#1},
+ supersubsep .dim_set:N = \l__spb_supersub_script_sep_dim,
+ supersubsep .initial:n = 0.3ex,
+ supersubalign .tl_set:N = \l__spb_supersub_script_align_tl,
+ supersubalign .initial:n = l
}
\tl_set:Nn \l__spb_boxa_wd_tl { \box_wd:N \l_tmpa_box }
@@ -229,6 +255,16 @@
\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} }
}
+\NewDocumentCommand{\spb_both_format_assign:n}
+ {>{\SplitArgument{1}{,}}m}
+ {\spb_supersub_script_both_format:nn #1}
+\cs_new_protected:Npn \spb_supersub_script_both_format:nn #1#2
+ {
+ \tl_set:Nn \l__spb_super_script_formatii_tl {#1}
+ \tl_if_novalue:nTF {#2}
+ { \tl_clear:N \l__spb_sub_script_formatii_tl }
+ { \tl_set:Nn \l__spb_sub_script_formatii_tl {#2} }
+ }
\clist_map_inline:nn
{ super,sub }
@@ -236,7 +272,8 @@
\exp_args:Nc \NewDocumentCommand {#1}
{
sO{\dim_use:c { l__spb_#1_script_vshift_dim }}
- >{\SplitArgument{1}{,}}O{}D(){}
+ >{\SplitArgument{1}{,}}O{}
+ D(){\tl_use:c { l__spb_#1_script_formati_tl }}
mO{\dim_use:c { l__spb_#1_script_hshift_dim }}
}
{
@@ -256,7 +293,10 @@
\NewDocumentCommand{\supersub}
{
sO{\l__spb_supersub_script_sep_dim}
- O{\l__spb_supersub_script_align_tl}D(){}mmO{0pt}D(){}
+ O{\l__spb_supersub_script_align_tl}
+ D(){\l__spb_super_script_formatii_tl}mm
+ O{\l__spb_supersub_script_hshift_dim}
+ D(){\l__spb_sub_script_formatii_tl}
}
{
\IfBooleanTF{#1}