diff options
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/spbmark/spbmark.dtx | 88 |
1 files changed, 60 insertions, 28 deletions
diff --git a/Master/texmf-dist/source/latex/spbmark/spbmark.dtx b/Master/texmf-dist/source/latex/spbmark/spbmark.dtx index 23e13e57b48..754bcfa0c46 100644 --- a/Master/texmf-dist/source/latex/spbmark/spbmark.dtx +++ b/Master/texmf-dist/source/latex/spbmark/spbmark.dtx @@ -11,7 +11,8 @@ % \iffalse %<*driver> \documentclass{l3doc} -\usepackage{spbmark} +\usepackage{spbmark,siunitx} +\usepackage[noto]{newtxmath} \OnlyDescription \begin{document} \DocInput{\jobname.dtx} @@ -22,7 +23,7 @@ % % \title{\pkg{spbmark} -- Superscript and subscript of text} % \author{Qu Yi} -% \date{2021/06/26\hskip 1em\relax v1.00\thanks{\url{https://github.com/texl3/spbmark}}} +% \date{2021/06/28\hskip 1em\relax v1.00a\thanks{\url{https://github.com/texl3/spbmark}}} % % \maketitle % \begin{abstract} @@ -36,10 +37,10 @@ % \end{function} % % \section{User commands} -% \begin{function}[added = 2021-06-26]{\super,\sub,\supersub,\textsuperscript,\textsubscript} +% \begin{function}[added = 2021-06-26,updated = 2021-06-28]{\super,\sub,\supersub,\textsuperscript,\textsubscript} % \begin{syntax} -% \tn{super*}\oarg{vertical shift}\parg{format code}\marg{content}\oarg{horizontal shift} -% \tn{sub*}\oarg{vertical shift}\parg{format code}\marg{content}\oarg{horizontal shift} +% \tn{super*}\oarg{vshift}[<height>,<depth>]\parg{code}\marg{content}\oarg{hshift} +% \tn{sub*}\oarg{vshift}[<height>,<depth>]\parg{code}\marg{content}\oarg{hshift} % \tn{supersub*}\oarg{script sep}\oarg{script align}\parg{super format code} % \ \marg{super content}\marg{sub content} % \ \oarg{horizontal shift}\parg{sub format code} @@ -47,9 +48,11 @@ % \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 vertical shift and horizontal shift are both 0pt, 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 0 pt, and the parameters of \meta{script align} are the same as the \texttt{supersubalign}. % -% The \meta{format code} is used to format superscripts and subscripts, and can insert commands such as fonts or colors. The last command in the code can take an argument, which is either a superscript or a subscript. +% 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. +% +% The \meta{code} is used to format superscripts and subscripts, and can insert commands such as fonts or colors. The last command in the code can take an argument, which is either a superscript or a subscript. % % The \tn{textsuperscript} and \tn{textsubscript} commands have been redefined to be equivalent to \tn{super} and \tn{sub} respectively, if you need to use their original definitions, then \tn{spb@textsuperscript@save} and \tn{spb@textsubscript@save} will be available. % @@ -77,7 +80,7 @@ % \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.3ex. \\ +% \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. \\ % % \section{Examples of use} @@ -86,16 +89,27 @@ % \noindent % |A\super[0.2ex](\color{red}){exam}[0.2em]B| \\ % |$A\sub(\mathsf){exam}B$| \\ -% |A\supersub[0.3ex][c]{examsuper}{examsub}B| \\ +% |A\supersub[0.3ex][c]{examsuper}{sub}B| \\ % A\super[0.2ex](\color{red}){exam}[0.2em]B \\ % $A\sub(\mathsf){exam}B$ \\ -% A\supersub[0.3ex][c]{examsuper}{examsub}B +% A\supersub[0.3ex][c]{examsuper}{sub}B +% \end{quotation} +% +% It can also be used with the \pkg{siunitx} package to output superscripts and subscripts in the unit: +% \begin{quotation} +% \noindent +% |\unit[mode = math]{kg.m/s\super*[-1pt]{2}}| \\ +% |\qty[mode = text]{30}{A\supersub(\color{red}){b}{c}[1pt]}| \\ +% |\spbset{sub-hshift = 2pt}\unit[mode = text]{A_b}| \\ +% \unit[mode = math]{kg.m/s\super*[-1pt]{2}} \\ +% \qty[mode = text]{30}{A\supersub(\color{red}){b}{c}[1pt]} \\ +% \spbset{sub-hshift = 2pt}\unit[mode = text]{A_b} % \end{quotation} % -% \pkg{spbmark} also patches the standard document class and the footer markers for \cls{KOMA-Script}. You can format the footer markers by redefining the \tn{fnmarkfont} command. Note that extra horizontal shift does not work with footnote markers. +% \pkg{spbmark} also patches the footer markers for standard document class and \cls{KOMA-Script}. You can format the footer markers by redefining the \tn{fnmarkfont} command. Note that extra horizontal shift does not work with footnote markers. % % \section{Known issues} -% At present, the vertical and horizontal offsets are effective for the unit commands in the text mode of the \pkg{siunitx} macro package. \tn{super} and \tn{sub} can also be used normally in its unit commands, but when the unit is output in the math mode, \tn{supersub} command cannot be used. +% At present, the vertical and horizontal offsets are effective for the unit commands in the \pkg{siunitx} macro package. However, due to the special mechanism that the decimal point is not recognized correctly because it is converted to a space in the \tn{unit} command, it is recommended to use \texttt{pt} as the unit of offset. % % \newcommand\urlprefix{\newline\hspace*{\fill}} % \let\OldUrl\url @@ -113,7 +127,7 @@ %<*package> \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{l3keys2e} -\ProvidesExplPackage{spbmark}{2021/06/26}{1.00}{beta} +\ProvidesExplPackage{spbmark}{2021/06/28}{1.00a}{beta} \cs_new_protected:Npn \spb_define:n { \keys_define:nn { spbmark } } \cs_new_protected:Npn \spbset { \keys_set:nn { spbmark } } @@ -143,10 +157,13 @@ 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 } \tl_set:Nn \l__spb_boxb_wd_tl { \box_wd:N \l_tmpb_box } \cs_new:Npn \spb_tmp_boxa_use: { \box_use:N \l_tmpa_box } \cs_new:Npn \spb_tmp_boxb_use: { \box_use:N \l_tmpb_box } +\cs_new:Npn \spb_tmp_hboxa_set:n #1 { \hbox_set:Nn \l_tmpa_box {#1} } +\cs_new:Npn \spb_tmp_hboxb_set:n #1 { \hbox_set:Nn \l_tmpb_box {#1} } \cs_new:Npn \spb_box_max_dim_horizontal: { \skip_horizontal:n @@ -174,27 +191,34 @@ { sub } { \sb } } } +\cs_new_protected:Npn \spb_box_dp_ht_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} } + } \clist_map_inline:nn { super,sub } { \exp_args:Nc \NewDocumentCommand {#1} { - sO{\dim_use:c { l__spb_#1_script_vshift_dim }}D(){}m - O{\dim_use:c { l__spb_#1_script_hshift_dim }} + sO{\dim_use:c { l__spb_#1_script_vshift_dim }} + >{\SplitArgument{1}{,}}O{}D(){} + mO{\dim_use:c { l__spb_#1_script_hshift_dim }} } { \IfBooleanTF{##1} - {\hbox_set:Nn \l_tmpa_box { $##3{\spb_math:nn {#1} {##4}}$ }} + {\spb_tmp_hboxa_set:n { $##4{\spb_math:nn {#1} {##5}}$ }} { \mode_if_math:TF - { \hbox_set:Nn \l_tmpa_box { $##3{\spb_math:nn {#1} {##4}}$ } } + { \spb_tmp_hboxa_set:n { $##4{\spb_math:nn {#1} {##5}}$ } } { - \hbox_set:Nn \l_tmpa_box - { ##3{\use:c { spb@text#1script@save }{##4}} } + \spb_tmp_hboxa_set:n + { ##4{\use:c { spb@text#1script@save }{##5}} } } } - \hbox_set_to_wd:Nnn \l_tmpb_box { \l__spb_boxa_wd_tl + ##5 } + \hbox_set_to_wd:Nnn \l_tmpb_box { \l__spb_boxa_wd_tl + ##6 } { \hss\box_move_up:nn {##2} { \spb_tmp_boxa_use: } } + \spb_box_dp_ht_assign:nn ##3 \spb_tmp_boxb_use: } } @@ -206,30 +230,33 @@ { \IfBooleanTF{#1} { - \hbox_set:Nn \l_tmpa_box { $#4{\sp{#5}}$ } - \hbox_set:Nn \l_tmpb_box { $#8{\sb{#6}}$ } + \spb_tmp_hboxa_set:n { $#4{\sp{#5}}$ } + \spb_tmp_hboxb_set:n { $#8{\sb{#6}}$ } }{ \mode_if_math:TF { - \hbox_set:Nn \l_tmpa_box { $#4{\sp{#5}}$ } - \hbox_set:Nn \l_tmpb_box { $#8{\sb{#6}}$ } + \spb_tmp_hboxa_set:n { $#4{\sp{#5}}$ } + \spb_tmp_hboxb_set:n { $#8{\sb{#6}}$ } } { - \hbox_set:Nn \l_tmpa_box { #4{\spb@textsuperscript@save{#5}} } - \hbox_set:Nn \l_tmpb_box { #8{\spb@textsubscript@save{#6}} } + \spb_tmp_hboxa_set:n { #4{\spb@textsuperscript@save{#5}} } + \spb_tmp_hboxb_set:n { #8{\spb@textsubscript@save{#6}} } } } \hbox_set_to_wd:Nnn \l_tmpa_box { \l__spb_boxa_wd_tl + #7 } { \hss\box_move_up:nn {#2} { \spb_tmp_boxa_use: } } \hbox_set_to_wd:Nnn \l_tmpb_box { \l__spb_boxb_wd_tl + #7 } { \hss\box_move_down:nn {#2} { \spb_tmp_boxb_use: } } - \str_case:nnF {#3} + \str_case:onF {#3} { { l } { \use_i:nnn } { c } { \use_ii:nnn } { r } { \use_iii:nnn } } - { \use_i:nnn } + { + \msg_warning:nn { spbmark } { unsupported-align } + \use_i:nnn + } { \hbox_overlap_right:n { \spb_tmp_boxa_use: } \hbox_overlap_right:n { \spb_tmp_boxb_use: } @@ -246,6 +273,11 @@ \hbox_overlap_left:n { \spb_tmp_boxb_use: } } } +\msg_new:nnn { spbmark } { unsupported-align } + { + Alignment~only~supports~l,~c,~and~r. \\ + The~l~parameter~will~be~used~by~default. + } \cs_set_eq:NN \textsuperscript \super \cs_set_eq:NN \textsubscript \sub \cs_set:Npn \@makefnmark |