summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-12-16 03:01:13 +0000
committerNorbert Preining <norbert@preining.info>2021-12-16 03:01:13 +0000
commit16b22a983bc0f05cbbb201a6e0f5cbbfc3c8fffb (patch)
tree09f27480427360daa44bee043154b5d9580efa33 /macros
parent0efaa39c6d0b17b58df9a68ae1319ea20aaabc28 (diff)
CTAN sync 202112160301
Diffstat (limited to 'macros')
-rw-r--r--macros/latex/contrib/easybook/easybook.dtx25
-rw-r--r--macros/latex/contrib/easybook/easybook.pdfbin594610 -> 593159 bytes
-rw-r--r--macros/latex/contrib/easybook/easybook.tex78
-rw-r--r--macros/latex/contrib/ragged2e/README.md3
-rw-r--r--macros/latex/contrib/ragged2e/ragged2e.dtx29
-rw-r--r--macros/latex/contrib/ragged2e/ragged2e.pdfbin666241 -> 695933 bytes
-rw-r--r--macros/latex/contrib/spbmark/spbmark.pdfbin67031 -> 68252 bytes
-rw-r--r--macros/latex/contrib/spbmark/spbmark.sty289
-rw-r--r--macros/latex/contrib/spbmark/spbmark.tex103
-rw-r--r--macros/luatex/generic/lua-widow-control/README.md2
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.lua10
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.pdfbin313873 -> 314157 bytes
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.sty2
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.tex2
-rw-r--r--macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl12
-rw-r--r--macros/luatex/generic/lua-widow-control/lwc-documentation.tex2
-rw-r--r--macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl4
-rw-r--r--macros/luatex/generic/penlight/penlight.pdfbin29537 -> 29642 bytes
-rw-r--r--macros/luatex/generic/penlight/penlight.sty4
-rw-r--r--macros/luatex/generic/penlight/penlight.tex2
-rw-r--r--macros/luatex/generic/penlight/penlightextras.lua128
-rw-r--r--macros/luatex/latex/yamlvars/YAMLvars.lua75
-rw-r--r--macros/luatex/latex/yamlvars/YAMLvars.pdfbin46334 -> 46890 bytes
-rw-r--r--macros/luatex/latex/yamlvars/YAMLvars.sty10
-rw-r--r--macros/luatex/latex/yamlvars/YAMLvars.tex8
25 files changed, 464 insertions, 324 deletions
diff --git a/macros/latex/contrib/easybook/easybook.dtx b/macros/latex/contrib/easybook/easybook.dtx
index 701abb0ff0..0765fb3ecc 100644
--- a/macros/latex/contrib/easybook/easybook.dtx
+++ b/macros/latex/contrib/easybook/easybook.dtx
@@ -15,7 +15,7 @@
%<*class>
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{l3keys2e}
-\ProvidesExplClass{easybook}{2021/12/14}{1.41T}
+\ProvidesExplClass{easybook}{2021/12/15}{1.41U}
{Typeset Chinese theses or books}
\bool_set_false:N \l__eb_compile_draft_bool
@@ -308,12 +308,13 @@
%<*package>
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{l3keys2e,etoolbox}
-\ProvidesExplPackage{easybase}{2021/12/14}{1.41T}
+\ProvidesExplPackage{easybase}{2021/12/15}{1.41U}
{Typeset Chinese theses or books}
\cs_generate_variant:Nn \dim_set:Nn { NV }
\cs_generate_variant:Nn \dim_sign:n { V }
\cs_generate_variant:Nn \int_to_arabic:n { v }
+\cs_generate_variant:Nn \msg_warning:nnn { nnV }
\cs_generate_variant:Nn \prop_set_from_keyval:Nn { NV }
\cs_generate_variant:Nn \skip_set:Nn { NV }
\cs_generate_variant:Nn \seq_set_from_clist:Nn { No }
@@ -472,7 +473,7 @@
}
}
\cs_new:Npn \eb_msg_abandon_option:n #1
- { \msg_warning:nnx { easybase } { abandon-#1 } { \l_keys_key_str } }
+ { \msg_warning:nnV { easybase } { abandon-#1 } \l_keys_key_str }
\cs_if_exist:NF \chapter
{
\newcounter{chapter}
@@ -840,7 +841,7 @@
\str_if_eq:nnTF {#1} { match }
{
\tl_set:cv { l__eb_fn#2_#3shift_tl }
- { l__spb_super_script_#3shift_dim }
+ { l__spb_super_#3shift_dim }
}
{ \tl_set:cn { l__eb_fn#2_#3shift_tl } {#1} }
}
@@ -1079,16 +1080,18 @@
}
}
-\ProvideDocumentCommand{\super}{omo}{\textsuperscript{#2}}
+\ProvideDocumentCommand{\super}{mo}{\textsuperscript{#1}}
\providecommand{\spbset}{\use_none:n}
\NewDocumentCommand{\eb@fnmate@super}{sm}
{
\IfBooleanTF{#1}
- {\super[\l__eb_fntext_vshift_tl]{#2}[0pt]}
+ {\super{#2}[vshift = \l__eb_fntext_vshift_tl,nohshift]}
{
- \super[\l__eb_fnmark_vshift_tl]
- {\l__eb_fnmate_format_tl{#2}}
- [\l__eb_fnmark_hshift_tl]
+ \super{#2}[
+ cmd = \l__eb_fnmate_format_tl,
+ vshift = \l__eb_fnmark_vshift_tl,
+ hshift = \l__eb_fnmark_hshift_tl
+ ]
}
}
\cs_new_protected:Npn \eb_fnmate_format_initial:
@@ -2071,7 +2074,7 @@
{
\sisetup
{
- mode = match,
+ number-mode = match,
table-parse-only,
text-family-to-math,
text-series-to-math,
@@ -2429,7 +2432,7 @@
}
%</package>
%<*tcolorbox>
-\ProvidesExplFile{eb-tcolorbox.cfg}{2021/12/14}{1.41T}
+\ProvidesExplFile{eb-tcolorbox.cfg}{2021/12/15}{1.41U}
{Customization of tcolorbox for easybook}
\cs_set_protected:Npn \setexercise #1
diff --git a/macros/latex/contrib/easybook/easybook.pdf b/macros/latex/contrib/easybook/easybook.pdf
index 9eb1112942..8676768a4a 100644
--- a/macros/latex/contrib/easybook/easybook.pdf
+++ b/macros/latex/contrib/easybook/easybook.pdf
Binary files differ
diff --git a/macros/latex/contrib/easybook/easybook.tex b/macros/latex/contrib/easybook/easybook.tex
index 38d6cdfba5..f52cbce436 100644
--- a/macros/latex/contrib/easybook/easybook.tex
+++ b/macros/latex/contrib/easybook/easybook.tex
@@ -20,8 +20,8 @@
name = easybook,
color-scheme = blue,
title = EASYBOOK 使用手册,
- version = v1.41T,
- date = 2021/12/14,
+ version = v1.41U,
+ date = 2021/12/15,
authors = 瞿毅,
info = 排版简体中文学位论文和书籍,
email = q1jx@foxmail.com,
@@ -356,16 +356,28 @@
\end{commands}
\subsection{上标和下标}
-上标和下标的功能来自 \pkg*{spbmark} 宏包,下面三个命令可以用于输出上标和下标。它们根据当前处于文本还是数学模式来匹配相应的模式,或者可以使用它们的星号变体命令来强制使用数学模式。也可以使用键值列表对偏移量进行全局设置,详情见\ref{subsubsec:super-sub-script}。
+上标和下标的功能来自 \pkg*{spbmark} 宏包,下面三个命令可以用于输出上标和下标。可以使用键值列表的形式对上下标格式进行局部或全局设置,这些命令两个可选参数的键值列表是等效的。全局设置的详情见\ref{subsubsec:super-sub-script}。
\begin{commands}
- \command{super}[\sarg\oarg{垂直偏移}\splitoarg{高度,深度}\darg{格式代码}\marg{内容}\oarg{水平偏移}]
- 上标命令,与简短命令 \cs{sp} 等效。水平和垂直偏移进行距离微调,可以为带有长度单位的正值或负值,为正值时代表向上或向右移动,否则相反,默认均为 \code{0pt}。\meta{格式代码} 可以插入字体或颜色等命令,代码中的最后一个命令可以接受一个为上标或下标的参数。
- \command{sub}[\sarg\oarg{垂直偏移}\splitoarg{高度,深度}\darg{格式代码}\marg{内容}\oarg{水平偏移}]
- 下标命令,与简短命令 \cs{sp} 等效。水平和垂直偏移为正值时代表向下或向右移动,否则相反。其它用法和参数与上标命令 \cs{super} 类似。
- \command{supersub}[\sarg\oarg{间距}\darg{对齐方式}\marg{上标内容}\marg{下标内容}\oarg{水平偏移}\splitdarg{上标代码,下标代码}]
- 同时输出上标和下标的命令,与简短命令 \cs{spb} 等效。\meta{间距} 为上下标的垂直间距,\meta{对齐方式} 是下标的水平对齐方式,参数与 \option{supersubalign} 相同,\meta{水平偏移} 默认为 \code{0pt}。
+ \command{super}[\oarg{键值列表1}\splitoarg{高度,深度}\marg{内容}\oarg{键值列表2}]
+ 输出上标的命令,与简短命令 \cs{sp} 等效。
+ \command{sub}[\oarg{键值列表1}\splitoarg{高度,深度}\marg{内容}\oarg{键值列表2}]
+ 输出下标的命令,与简短命令 \cs{sp} 等效。用法和参数与上标命令 \cs{super} 类似。
+ \command{supersub}[\oarg{键值列表1}\marg{上标内容}\marg{下标内容}\oarg{键值列表2}]
+ 同时输出上标和下标的命令,与简短命令 \cs{spb} 等效。
\end{commands}
+关于这三个命令键值列表中共同的选项如下所示。如果 \option{vshift}、\option{hshift} 和 \option{cmd} 选项用于 \module*{style} 模块的全局设置,它们将根据前面最近一个命令的类型设定相应值。
+\begin{options}
+ \keyval-{vshift}{刚性长度}\Default{0pt}
+ 上标或下标的垂直偏移。如果是上下标命令使用则代表上标和上标间的垂直距离 \option{vsep}。
+ \keyval-{hshift}{刚性长度}\Default{0pt}
+ 上标或下标的水平偏移。如果是上下标命令使用则代表上标和上标的共同偏移。
+ \keyval-{cmd}{格式命令}\Default
+ 上标或下标的格式命令选项。最后一个命令可以带有一个参数,这个参数用于接受上标或下标。
+ \keychoice{mode}{text,math,match}\Default{match}
+ 上标或下标的输出格式。可以为文本 \code{text} 或数学 \code{math} 模式。当使用选项 \code{match} 时可以根据当前段落所处的模式自动匹配。
+\end{options}
+
\section{接口选项}
\label{sec:interface options}
\begin{commands}
@@ -447,30 +459,30 @@
\subsubsection{上下标全局设置}
\label{subsubsec:super-sub-script}
\begin{options}
- \keyval-{super-vshift}{刚性长度}\Default{0pt}
- 上标垂直偏移量,对应上标命令 \cs{super} 的参数 \meta{垂直偏移}。
- \keyval-{super-hshift}{刚性长度}\Default{0pt}
- 上标水平偏移量,对应上标命令 \cs{super} 的参数 \meta{水平偏移}。
- \keyval-{sub-vshift}{刚性长度}\Default{0pt}
- 下标垂直偏移量,对应下标命令 \cs{sub} 的参数 \meta{垂直偏移}。
- \keyval-{sub-hshift}{刚性长度}\Default{0pt}
- 下标水平偏移量,对应下标命令 \cs{sub} 的参数 \meta{水平偏移}。
+ \keyval-{spvshift}{刚性长度}\Default{0pt}
+ 上标命令 \cs{super} 对应的上标垂直偏移量。
+ \keyval-{sphshift}{刚性长度}\Default{0pt}
+ 上标命令 \cs{super} 对应的上标水平偏移量。
+ \keyval-{sbvshift}{刚性长度}\Default{0pt}
+ 下标命令 \cs{sub} 对应的下标垂直偏移量。
+ \keyval-{sbhshift}{刚性长度}\Default{0pt}
+ 下标命令 \cs{sub} 对应的下标水平偏移量。
\opt{nohshift}\Default!
- 同时取消上标和下标的 \meta{水平偏移},与 \keyis-{super-hshift}{0pt} 和 \keyis-{sub-hshift}{0pt} 等效。
+ 同时取消上标和下标的 \meta{水平偏移},与 \keyis-{sphshift}{0pt} 和 \keyis-{sbhshift}{0pt} 等效。
\opt{novshift}\Default!
- 同时取消上标和下标的 \meta{垂直偏移},与 \keyis-{super-vshift}{0pt} 和 \keyis-{sub-vshift}{0pt} 等效。
- \keyval-{super-format}{上标格式}\Default
- 上标的格式,对应上标命令 \cs{super} 的参数 \meta{格式代码}。
- \keyval-{sub-format}{下标格式}\Default
- 下标的格式,对应下标命令 \cs{sub} 的参数 \meta{格式代码}。
- \keyval-{supersub-hshift}{刚性长度}\Default{0pt}
- 上下标水平偏移量,对应上下标命令 \cs{supersub} 的参数 \meta{水平偏移}。
- \kvsplit{supersub-format}{上标格式,下标格式}\Default
- 上下标格式,对应上下标命令 \cs{supersub} 的参数 \splitmeta{上标格式,下标格式}。以英文逗号分隔为前后部分,也可以只有前部分,表示上标的格式。
- \keyval-{supersubsep}{刚性长度}\Default{0.3ex}
- 上下标垂直间距,对应上下标命令 \cs{supersub} 的参数 \meta{间距}。
- \keychoice{supersubalign}{l,c,r}\Default{l}
- 上下标的水平对齐方式,有左对齐、居中对齐和右对齐三种 \meta{对齐方式}。
+ 同时取消上标和下标的 \meta{垂直偏移},与 \keyis-{spvshift}{0pt} 和 \keyis-{sbvshift}{0pt} 等效。
+ \keyval-{spcmd}{格式命令}\Default
+ 上标命令 \cs{super} 对应的上标的格式命令。
+ \keyval-{sbcmd}{格式命令}\Default
+ 下标命令 \cs{sub} 对应的下标的格式命令。
+ \keyval-{spbhshift}{刚性长度}\Default{0pt}
+ 上下标命令 \cs{supersub} 对应的上下标共同水平偏移量。
+ \kvsplit{spbcmd}{上标格式,下标格式}\Default
+ 上下标命令 \cs{supersub} 对应的上下标格式命令。以英文逗号分隔为前后两个部分分别设置上下标格式,也可以只有前部分,表示上标的格式。
+ \keyval-{vsep}{刚性长度}\Default{0.3ex}
+ 上下标命令 \cs{supersub} 对应的上下标垂直距离。
+ \keychoice{halign}{l,c,r}\Default{l}
+ 上下标命令 \cs{supersub} 对应的上下标水平对齐方式,有左 \code{l}、居中 \code{c} 和右 \code{r} 三种对齐方式。
\end{options}
\subsection{超链接}
@@ -1213,9 +1225,9 @@
\keyval-{space}{符号间隙}\Default{0.25em}
符号间隙为引导符两侧与符号和说明文字间的距离。
\keychoice{item-align}{l,c,r}\Default{r}
- 符号的对齐方式,分为左(\code{l})、中(\code{c})和右(\code{r})三种对齐方式。
+ 符号的对齐方式,分为左 \code{l}、中 \code{c} 和右 \code{r} 三种对齐方式。
\keychoice{delim-align}{l,c,r}\Default{c}
- 引导符的对齐方式,分为左(\code{l})、中(\code{c})和右(\code{r})三种对齐方式。
+ 引导符的对齐方式,分为左 \code{l}、中 \code{c} 和右 \code{r} 三种对齐方式。
\keyval-{enumitem}{键值列表2}
可以使用选项 \option{enumitem} 或命令 \cs{seteqcomplist} 调整对照列表的水平和垂直间距。
\keyval-{intro}{首行文字}\Default
diff --git a/macros/latex/contrib/ragged2e/README.md b/macros/latex/contrib/ragged2e/README.md
index 3a7a51ddf8..03999a85a4 100644
--- a/macros/latex/contrib/ragged2e/README.md
+++ b/macros/latex/contrib/ragged2e/README.md
@@ -2,7 +2,7 @@
Copyright (C) Martin Schröder, 1996–2019, Marei Peischl (peiTeX) <marei@peitex.de>, 2021
- ragged2e 2021/02/05 v3.0
+ ragged2e 2021/12/15 v3.1
***************************************************************************
@@ -38,5 +38,6 @@ or want to report a suggestion for improvement, please visit
## Version History
* 3.0 Move from everysel package to lthooks
+ * 3.1 Robustify the user macros (Thanks for Markus Kohm for the hint)
diff --git a/macros/latex/contrib/ragged2e/ragged2e.dtx b/macros/latex/contrib/ragged2e/ragged2e.dtx
index 5c3408cf12..397b810b40 100644
--- a/macros/latex/contrib/ragged2e/ragged2e.dtx
+++ b/macros/latex/contrib/ragged2e/ragged2e.dtx
@@ -31,7 +31,7 @@
% \iffalse
\NeedsTeXFormat{LaTeX2e}[2017/03/29]
%<package>\ProvidesPackage{ragged2e}
-%<package> [2021/02/05 v3.0 ragged2e Package]
+%<package> [2021/12/15 v3.1 ragged2e Package]
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
@@ -209,14 +209,17 @@
% \subsection{\LaTeX}
% ^^A
% \LaTeX{} defines e.\,g.\ \cs{raggedright} as follows:
+% \changes{v3.1}{2021/12/15}{Use the updated definition of \cs{raggedright}}
% \begin{macrocode}
%<*latex>
-\def\raggedright{%
- \let\\=\@centercr
- \@rightskip\@flushglue
- \rightskip\@rightskip
- \leftskip\z@
- \parindent\z@}
+\DeclareRobustCommand
+ \raggedright{%
+ \let\\\@centercr
+ \@rightskip\@flushglue
+ \rightskip\@rightskip
+ \finalhyphendemerits=\z@
+ \leftskip\z@skip
+ \parindent\z@}
% \end{macrocode}
% Initially, \cs{@flushglue} is defined as
% \begin{macrocode}
@@ -1180,10 +1183,11 @@
% \end{Quote}
% Finally we signal the code inserted into \cs{selectfont} that
% we are active and call that code directly.
+% \changes{v3.1}{2021/12/15}{Robustify the user macros (Thanks to Markus Kohm for the hint)}
% \changes{v2.00}{2003/01/04}{Call \cs{@raggedtwoe@everyselectfont}
% and switch \cs{@gnewline}}
% \begin{macrocode}
-\newcommand{\Centering}{%
+\DeclareRobustCommand{\Centering}{%
\ifx\\\@raggedtwoe@savedcr
\let\\\@centercr
\fi
@@ -1202,10 +1206,11 @@
% \begin{macro}{\RaggedLeft}
% \cs{RaggedLeft} is like \cs{Centering}; it only uses other
% parameters.
+% \changes{v3.1}{2021/12/15}{Robustify the user macros}
% \changes{v2.00}{2003/01/04}{Call \cs{@raggedtwoe@everyselectfont}
% and switch \cs{@gnewline}}
% \begin{macrocode}
-\newcommand{\RaggedLeft}{%
+\DeclareRobustCommand{\RaggedLeft}{%
\ifx\\\@raggedtwoe@savedcr
\let\\\@centercr
\fi
@@ -1224,10 +1229,11 @@
% \begin{macro}{\RaggedRight}
% \cs{RaggedRight} is like \cs{Centering}; it only uses other
% parameters.
+% \changes{v3.1}{2021/12/15}{Robustify the user macros (Thanks to Markus Kohm for the hint)}
% \changes{v2.00}{2003/01/04}{Call \cs{@raggedtwoe@everyselectfont}
% and switch \cs{@gnewline}}
% \begin{macrocode}
-\newcommand{\RaggedRight}{%
+\DeclareRobustCommand{\RaggedRight}{%
\ifx\\\@raggedtwoe@savedcr
\let\\\@centercr
\fi
@@ -1246,9 +1252,10 @@
% \begin{macro}{\justifying}
% \cs{justifying} switches back to the defaults used by \LaTeX{} for
% typesetting justyfied text.
+% \changes{v3.1}{2021/12/15}{Robustify the user macros (Thanks to Markus Kohm for the hint)}
% \changes{v2.00}{2003/01/04}{New macro}
% \begin{macrocode}
-\newcommand{\justifying}{%
+\DeclareRobustCommand{\justifying}{%
\let\\\@raggedtwoe@savedcr
\let\@gnewline\@raggedtwoe@saved@gnewline
\leftskip\z@
diff --git a/macros/latex/contrib/ragged2e/ragged2e.pdf b/macros/latex/contrib/ragged2e/ragged2e.pdf
index 0a593dada1..f9999f907d 100644
--- a/macros/latex/contrib/ragged2e/ragged2e.pdf
+++ b/macros/latex/contrib/ragged2e/ragged2e.pdf
Binary files differ
diff --git a/macros/latex/contrib/spbmark/spbmark.pdf b/macros/latex/contrib/spbmark/spbmark.pdf
index c145a3b2c9..2bdd91a752 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 826d9a5b4b..099f871f20 100644
--- a/macros/latex/contrib/spbmark/spbmark.sty
+++ b/macros/latex/contrib/spbmark/spbmark.sty
@@ -9,9 +9,15 @@
% https://creativecommons.org/licenses/by/4.0/legalcode
\NeedsTeXFormat{LaTeX2e}[2018/12/31]
\RequirePackage{xparse,l3keys2e}
-\ProvidesExplPackage{spbmark}{2021/11/10}{1.1J}
+\ProvidesExplPackage{spbmark}{2021/12/15}{1.2}
{Customize superscripts and subscripts}
+\cs_generate_variant:Nn \dim_max:nn { VV }
+\cs_generate_variant:Nn \dim_compare:nNnTF { 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 }
+
\cs_new_protected:Npn \spb_define:n { \keys_define:nn { ctex/style } }
\cs_new_protected:Npn \spbset { \keys_set:nn { ctex/style } }
\keys_define:nn { spbmark/option }
@@ -32,35 +38,71 @@
\ProcessKeysOptions{spbmark/option}
-\tl_new:N \l__spb_super_script_formatii_tl
-\tl_new:N \l__spb_sub_script_formatii_tl
+\tl_new:N \l__spb_super_cmd_ii_tl
+\tl_new:N \l__spb_sub_cmd_ii_tl
+\tl_new:N \g__spb_hshift_init_tl
+\tl_new:N \g__spb_vshift_init_tl
+\tl_new:N \g__spb_cmd_init_tl
+
+\cs_new_protected:Npn \spb_local_case_init:nnnn #1#2#3#4
+ {
+ \str_case:xn { \tl_use:c { g__spb_#1_init_tl } }
+ {
+ { super } {#2}
+ { sub } {#3}
+ { supersub } {#4}
+ }
+ }
\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,
- supersub-hshift .dim_set:N = \l__spb_supersub_script_hshift_dim,
- supersub-hshift .initial:n = 0pt,
- nohshift .meta:n = { super-hshift = 0pt,sub-hshift = 0pt },
- novshift .meta:n = { super-vshift = 0pt,sub-vshift = 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
+ spvshift .dim_set:N = \l__spb_super_vshift_dim,
+ spvshift .initial:n = 0pt,
+ sphshift .dim_set:N = \l__spb_super_hshift_dim,
+ sphshift .initial:n = 0pt,
+ sbvshift .dim_set:N = \l__spb_sub_vshift_dim,
+ sbvshift .initial:n = 0pt,
+ sbhshift .dim_set:N = \l__spb_sub_hshift_dim,
+ sbhshift .initial:n = 0pt,
+ spbhshift .dim_set:N = \l__spb_supersub_hshift_dim,
+ spbhshift .initial:n = 0pt,
+ vshift .code:n =
+ {
+ \spb_local_case_init:nnnn { vshift }
+ { \dim_set:Nn \l__spb_super_vshift_dim {#1} }
+ { \dim_set:Nn \l__spb_sub_vshift_dim {#1} }
+ { \dim_set:Nn \l__spb_supersub_vsep_dim {#1} }
+ },
+ hshift .code:n =
+ {
+ \spb_local_case_init:nnnn { hshift }
+ { \dim_set:Nn \l__spb_super_hshift_dim {#1} }
+ { \dim_set:Nn \l__spb_sub_hshift_dim {#1} }
+ { \dim_set:Nn \l__spb_supersub_hshift_dim {#1} }
+ },
+ nohshift .meta:n = { sphshift = 0pt,sbhshift = 0pt },
+ novshift .meta:n = { spvshift = 0pt,sbvshift = 0pt },
+ spcmd .tl_set:N = \l__spb_super_cmd_i_tl,
+ sbcmd .tl_set:N = \l__spb_sub_cmd_i_tl,
+ spbcmd .code:n = \spb_both_cmd_assign:n {#1},
+ cmd .code:n =
+ {
+ \spb_local_case_init:nnnn { cmd }
+ { \tl_set:Nn \l__spb_super_cmd_i_tl {#1} }
+ { \tl_set:Nn \l__spb_sub_cmd_i_tl {#1} }
+ { \spb_both_cmd_assign:n {#1} }
+ },
+ vsep .dim_set:N = \l__spb_supersub_vsep_dim,
+ vsep .initial:n = 0.3ex,
+ halign .tl_set:N = \l__spb_supersub_align_tl,
+ halign .initial:n = l,
+ mode .tl_set:N = \l__spb_mode_value_tl,
+ mode .initial:n = match
}
\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 }
\tl_set:Nn \l__spb_box_max_wd_tl
- { \dim_max:nn { \l__spb_boxa_wd_tl } { \l__spb_boxb_wd_tl } }
+ { \dim_max:VV \l__spb_boxa_wd_tl \l__spb_boxb_wd_tl }
\providecommand{\hbox_overlap_center:n}[1]
{ \hbox_to_zero:n { \hss #1\hss } }
\cs_new:Npn \spb_boxa_move_up:n #1
@@ -77,32 +119,49 @@
{ sub } { \spb_boxa_move_down:n }
}
}
-\cs_new:Npn \spb_hbox_overlap_vshift:n #1#2
+\cs_generate_variant:Nn \spb_boxa_move_up:n { V }
+\cs_generate_variant:Nn \spb_boxb_move_down:n { V }
+\cs_new:Npn \spb_hbox_overlap_vshift:n #1
{
- \use:c { hbox_overlap_#2:n } { \spb_boxa_move_up:n {#1} }
- \use:c { hbox_overlap_#2:n } { \spb_boxb_move_down:n {#1} }
+ \use:c { hbox_overlap_#1:n }
+ { \spb_boxa_move_up:V \l__spb_supersub_vsep_dim }
+ \use:c { hbox_overlap_#1:n }
+ { \spb_boxb_move_down:V \l__spb_supersub_vsep_dim }
}
-\cs_new:Npn \spb_math_print_store:nnn #1#2#3
+\cs_new:Npn \spb_math_print_store_i:nn #1#2
{
\hbox_set:Nn \l_tmpa_box
- { \ensuremath{#1{\spb_math:nn {#2} {#3}}} }
+ { \ensuremath{\tl_use:c { l__spb_#1_cmd_i_tl }{\spb_math:nn {#1} {#2}}} }
}
-\cs_new:Npn \spb_text_print_store:nnn #1#2#3
+\cs_new:Npn \spb_text_print_store_i:nn #1#2
{
\hbox_set:Nn \l_tmpa_box
- { #1{\use:c { spb@text#2script@save }{#3}} }
+ { \tl_use:c { l__spb_#1_cmd_i_tl }{\use:c { spb@text#1script@save }{#2}} }
}
-\cs_new:Npn \spb_math_print_store:nnnn #1#2#3#4
+\cs_new:Npn \spb_math_print_store_ii:nn #1#2
{
- \hbox_set:Nn \l_tmpa_box { \ensuremath{#1{\spb@sp@save{#3}}} }
+ \hbox_set:Nn \l_tmpa_box
+ { \ensuremath{\l__spb_super_cmd_ii_tl{\spb@sp@save{#1}}} }
\hbox_set:Nn \l_tmpb_box
- { \ensuremath{\tl_if_novalue:nF {#2} {#2}{\spb@sb@save{#4}}} }
+ {
+ \ensuremath
+ {
+ \tl_if_novalue:VF \l__spb_sub_cmd_ii_tl
+ { \l__spb_sub_cmd_ii_tl }
+ { \spb@sb@save{#2} }
+ }
+ }
}
-\cs_new:Npn \spb_text_print_store:nnnn #1#2#3#4
+\cs_new:Npn \spb_text_print_store_ii:nn #1#2
{
- \hbox_set:Nn \l_tmpa_box { #1{\spb@textsuperscript@save{#3}} }
+ \hbox_set:Nn \l_tmpa_box
+ { \l__spb_super_cmd_ii_tl{\spb@textsuperscript@save{#1}} }
\hbox_set:Nn \l_tmpb_box
- { \tl_if_novalue:nF {#2} {#2}{\spb@textsubscript@save{#4}} }
+ {
+ \tl_if_novalue:VF \l__spb_sub_cmd_ii_tl
+ { \l__spb_sub_cmd_ii_tl }
+ { \spb@textsubscript@save{#2} }
+ }
}
\cs_set_eq:NN \spb@textsuperscript@save \textsuperscript
\cs_set_eq:NN \spb@textsubscript@save \textsubscript
@@ -121,74 +180,98 @@
\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}
+\NewDocumentCommand{\spb_both_cmd_assign:n}
{>{\SplitArgument{1}{,}}m}
- {\spb_supersub_script_both_format:nn #1}
-\cs_new_protected:Npn \spb_supersub_script_both_format:nn #1#2
+ {\spb_supersub_both_cmd:nn #1}
+\cs_new_protected:Npn \spb_supersub_both_cmd:nn #1#2
{
- \tl_set:Nn \l__spb_super_script_formatii_tl {#1}
+ \tl_set:Nn \l__spb_super_cmd_ii_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} }
+ { \tl_clear:N \l__spb_sub_cmd_ii_tl }
+ { \tl_set:Nn \l__spb_sub_cmd_ii_tl {#2} }
}
-
-\clist_map_inline:nn
- { super,sub }
+\cs_new_protected:Npn \spb_mode_switch:nnn #1#2#3
{
- \exp_args:Nc \NewDocumentCommand {#1}
+ \str_case:Vn \l__spb_mode_value_tl
{
- sO{\dim_use:c { l__spb_#1_script_vshift_dim }}
- >{\SplitArgument{1}{,}}O{}
- D(){\tl_use:c { l__spb_#1_script_formati_tl }}
- mO{\dim_use:c { l__spb_#1_script_hshift_dim }}
+ { math } {#1}
+ { text } {#2}
+ { match } {#3}
}
+ }
+\cs_new_protected:Npn \spb_local_value_init:n #1
+ {
+ \tl_gset:Nn \g__spb_hshift_init_tl {#1}
+ \tl_gset:Nn \g__spb_vshift_init_tl {#1}
+ \tl_gset:Nn \g__spb_cmd_init_tl {#1}
+ }
+
+\cs_new_protected:Npn \spb_both_newcmd_map:n #1
+ {
+ \exp_args:Nc \NewDocumentCommand {#1}
+ {O{}>{\SplitArgument{1}{,}}O{}mO{}}
{
- \IfBooleanTF{##1}
- {\spb_math_print_store:nnn {##4} {#1} {##5}}
+ \group_begin:
+ \spb_local_value_init:n {#1}
+ \keys_set:nn { ctex/style } {##1,##4}
+ \spb_mode_switch:nnn
+ { \spb_math_print_store_i:nn {#1} {##3} }
+ { \spb_text_print_store_i:nn {#1} {##3} }
{
\mode_if_math:TF
- { \spb_math_print_store:nnn {##4} {#1} {##5} }
- { \spb_text_print_store:nnn {##4} {#1} {##5} }
+ { \spb_math_print_store_i:nn {#1} {##3} }
+ { \spb_text_print_store_i:nn {#1} {##3} }
}
- \hbox_set:Nn \l_tmpa_box
- {
- \dim_compare:nNnTF {##6} < { 0pt }
- {
- \hbox_overlap_left:n
- {
- \hbox_to_wd:nn { \l__spb_boxa_wd_tl - ##6 }
- { \spb_boxa_vshift:nn {#1} {##2}\hss }
- }
- }
- {
- \hbox_to_wd:nn { \l__spb_boxa_wd_tl + ##6 }
- { \hss\spb_boxa_vshift:nn {#1} {##2} }
- }
- }
- \spb_box_ht_dp_assign:nn ##3
+ \spb_content_hbox_set:n {#1}
+ \spb_box_ht_dp_assign:nn ##2
\box_use:N \l_tmpa_box
+ \group_end:
}
}
-\NewDocumentCommand{\supersub}
- {
- sO{\l__spb_supersub_script_sep_dim}
- D(){\l__spb_supersub_script_align_tl}
- mmO{\l__spb_supersub_script_hshift_dim}
- >{\SplitArgument{1}{,}}D()
- {
- \l__spb_super_script_formatii_tl,
- \l__spb_sub_script_formatii_tl
- }
- }
+\cs_new_protected:Npn \spb_content_hbox_set:n #1
+ {
+ \hbox_set:Nn \l_tmpa_box
+ {
+ \dim_compare:nNnTF { \dim_use:c { l__spb_#1_hshift_dim } } < { 0pt }
+ {
+ \hbox_overlap_left:n
+ {
+ \hbox_to_wd:nn
+ { \l__spb_boxa_wd_tl - \dim_use:c { l__spb_#1_hshift_dim } }
+ {
+ \spb_boxa_vshift:nn {#1}
+ { \dim_use:c { l__spb_#1_vshift_dim } }\hss
+ }
+ }
+ }
+ {
+ \hbox_to_wd:nn
+ { \l__spb_boxa_wd_tl + \dim_use:c { l__spb_#1_hshift_dim } }
+ {
+ \hss\spb_boxa_vshift:nn {#1}
+ { \dim_use:c { l__spb_#1_vshift_dim } }
+ }
+ }
+ }
+ }
+\clist_map_inline:nn { super,sub } { \spb_both_newcmd_map:n {#1} }
+
+\cs_new:Npn \spb_supersub_hshift_if_negative:TF #1#2
+ { \dim_compare:VNnTF \l__spb_supersub_hshift_dim < { 0pt } {#1} {#2} }
+\NewDocumentCommand{\supersub}{O{}mmO{}}
{
- \IfBooleanTF{#1}
- {\spb_math_print_store:nnnn #7 {#4} {#5}}
+ \group_begin:
+ \spb_local_value_init:n { supersub }
+ \keys_set:nn { ctex/style } {#1,#4}
+ \spb_mode_switch:nnn
+ { \spb_math_print_store_ii:nn {#2} {#3} }
+ { \spb_text_print_store_ii:nnnn {#2} {#3} }
{
\mode_if_math:TF
- { \spb_math_print_store:nnnn #7 {#4} {#5} }
- { \spb_text_print_store:nnnn #7 {#4} {#5} }
+ { \spb_math_print_store_ii:nn {#2} {#3} }
+ { \spb_text_print_store_ii:nn {#2} {#3} }
}
- \str_case:onF {#3}
+ \str_case:VnF \l__spb_supersub_align_tl
{
{ l } { \use_i:nnn }
{ c } { \use_ii:nnn }
@@ -199,58 +282,62 @@
\use_i:nnn
}
{
- \dim_compare:nNnTF {#6} < { 0pt }
+ \spb_supersub_hshift_if_negative:TF
{
\hbox_overlap_left:n
{
- \spb_hbox_overlap_vshift:n {#2} { right }
- \skip_horizontal:n { -#6 }
+ \spb_hbox_overlap_vshift:n { right }
+ \skip_horizontal:n { -\l__spb_supersub_hshift_dim }
}
}
{
\hbox:n
{
- \skip_horizontal:n {#6}
- \spb_hbox_overlap_vshift:n {#2} { right }
+ \skip_horizontal:n { \l__spb_supersub_hshift_dim }
+ \spb_hbox_overlap_vshift:n { right }
\skip_horizontal:n { \l__spb_box_max_wd_tl }
}
}
}
{
- \dim_compare:nNnTF {#6} < { 0pt }
+ \spb_supersub_hshift_if_negative:TF
{
\hbox_overlap_left:n
{
- \spb_hbox_overlap_vshift:n {#2} { center }
- \skip_horizontal:n { \l__spb_box_max_wd_tl/2 - #6 }
+ \spb_hbox_overlap_vshift:n { center }
+ \skip_horizontal:n
+ { \l__spb_box_max_wd_tl/2 - \l__spb_supersub_hshift_dim }
}
}
{
\hbox:n
{
- \skip_horizontal:n { \l__spb_box_max_wd_tl/2 + #6 }
- \spb_hbox_overlap_vshift:n {#2} { center }
+ \skip_horizontal:n
+ { \l__spb_box_max_wd_tl/2 + \l__spb_supersub_hshift_dim }
+ \spb_hbox_overlap_vshift:n { center }
\skip_horizontal:n { \l__spb_box_max_wd_tl/2 }
}
}
}
{
- \dim_compare:nNnTF {#6} < { 0pt }
+ \spb_supersub_hshift_if_negative:TF
{
\hbox_overlap_left:n
{
- \spb_hbox_overlap_vshift:n {#2} { left }
- \skip_horizontal:n { -#6 }
+ \spb_hbox_overlap_vshift:n { left }
+ \skip_horizontal:n { -\l__spb_supersub_hshift_dim }
}
}
{
\hbox:n
{
- \skip_horizontal:n { \l__spb_box_max_wd_tl + #6 }
- \spb_hbox_overlap_vshift:n {#2} { left }
+ \skip_horizontal:n
+ { \l__spb_box_max_wd_tl + \l__spb_supersub_hshift_dim }
+ \spb_hbox_overlap_vshift:n { left }
}
}
}
+ \group_end:
}
\msg_new:nnn { spbmark } { unsupported-align }
{
diff --git a/macros/latex/contrib/spbmark/spbmark.tex b/macros/latex/contrib/spbmark/spbmark.tex
index 6ba38e5db1..9387433d0f 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.1J,
- date = 2021/11/10,
+ version = v1.2,
+ date = 2021/12/15,
authors = Qu Yi,
info = Customize superscript and subscript,
email = q1jx@foxmail.com,
@@ -61,90 +61,101 @@ The following macro package options will redefine the scripts commands of the \L
\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}[\sarg\oarg{vshift}\splitoarg{height}{depth}\darg{code}\marg{content}\oarg{hshift}]
- This is a superscript output command. If \meta{vshift} or \meta{hshift} is a positive value, the superscript moves up or to the right, if it's negative, the superscript moves down or to the left.
- \command{sub}[\sarg\oarg{vshift}\splitoarg{height}{depth}\darg{code}\marg{content}\oarg{hshift}]
- This is a subscript output command. If \meta{vshift} or \meta{hshift} is a positive value, the subscript moves down or to the right, if it's negative, the subscript moves up or to the left.
- \command{supersub}[\sarg\oarg{vsep}\darg{align}\marg{sup cont}\marg{sub cont}\oarg{hshift}\splitdarg{sup code}{sub code}]
- 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 \meta{vsep} represents the vertical spacing between superscript and subscript, same as option \option{supersubsep}. The parameters of \meta{align} are the same as the \option{supersubalign}.
+ \command{super}[\oarg{kv list}\splitoarg{height}{depth}\marg{content}\oarg{kv list}]
+ This is a superscript output command. The two \meta{kv list} are equivalent.
+ \command{sub}[\oarg{kv list}\splitoarg{height}{depth}\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.
\end{commands}
-These commands can 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 optional parameter \splitmeta{height}{depth} generally does not need to be used. The \meta{height} and \meta{depth} are separated by commas. Only the front part indicates the \meta{height} of the superscript or subscript, and only the back part indicates the \meta{depth}.
-The \meta{code} is used to format superscript and subscript, 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.
-
-If you need to use the original definitions of \cs{textsuperscript}, \cs{textsubscript}, \cs{sp} and \cs{sb} after using the \option{text} or \option{math} option, then you can use the following commands:
-\begin{commands}
- \command{spb@textsuperscript@save}[\marg{content}]
- Save the original definition of the \cs{textsuperscript} command, output superscript in the text.
- \command{spb@textsubscript@save}[\marg{content}]
- Save the original definition of the \cs{textsubscript} command, output subscript in the text.
- \command{spb@sp@save}[\marg{content}]
- Save the original definition of the \cs{sp} command, output superscript in the math mode.
- \command{spb@sb@save}[\marg{content}]
- Save the original definition of the \cs{sb} command, output subscript in the math mode.
-\end{commands}
+The options common to \meta{kv list} of the three commands are as follows. They can be used in \meta{key-value list} for the \cs{spbset} command. If \option{vshift}, \option{hshift} and \option{cmd} are used in the \cs{spbset} command, it is set according to the type of the previous nearest command.
+\begin{options}
+ \keyval{vshift}{fixed length}\Default{0pt}
+ Vertical shift of superscript or subscript. Represents the vertical distance \option{vsep} between superscript and subscript in the superscript and subscript commands.
+ \keyval{hshift}{fixed length}\Default{0pt}
+ Horizontal shift of superscript or subscript. Represents the common shift in the superscript and subscript commands.
+ \keyval{cmd}{format cmds}\Default
+ The format command of superscript or subscript. The last command can take a parameter, which accepts superscript or subscript. Represents the format of superscript and subscript in the superscript and subscript commands.
+ \keychoice{mode}{text,math,match}\Default{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.
+\end{options}
\section{Global control interface}
\label{sec:global control interface}
\begin{commands}
\command{spbset}[\marg{key-value list}]
- \pkg*{spbmark} uses the \cs{spbset} command to control the global default format of superscript and subscript. The values ​​set by it will be overwritten by the optional parameters of the superscript and other commands.
+ \pkg*{spbmark} uses the \cs{spbset} command to control the global default format of superscript and subscript. These options also apply to \meta{kv list} of the above commands. The values ​​set by it will be overwritten by the optional parameters of the superscript and other commands.
\end{commands}
-The following list of keys control the format both of superscript or subscript. They are equivalent to the optional parameters of the \cs{super} or \cs{sub} commands.
+The following list of keys control the format both of superscript or subscript.
\begin{options}
- \keyval{super-vshift}{fixed length}\Default{0pt}
- Extra vertical shift of the superscript.
- \keyval{super-hshift}{fixed length}\Default{0pt}
+ \keyval{spvshift}{fixed length}\Default{0pt}
+ Extra vertical shift of the superscript.
+ \keyval{sphshift}{fixed length}\Default{0pt}
Extra horizontal shift of the superscript.
- \keyval{sub-vshift}{fixed length}\Default{0pt}
+ \keyval{sbvshift}{fixed length}\Default{0pt}
Extra vertical shift of the subscript.
- \keyval{sub-hshift}{fixed length}\Default{0pt}
+ \keyval{sbhshift}{fixed length}\Default{0pt}
Extra horizontal shift of the subscript.
\opt{nohshift}\Default!
Cancel the horizontal offset of superscript and subscript at the same time.
\opt{novshift}\Default!
Cancel the vertical offset of superscript and subscript at the same time.
- \keyval{super-format}{format code}\Default
+ \keyval{spcmd}{format code}\Default
Control the format of superscript, the last command in the code can take an argument, which is a superscript.
- \keyval{sub-format}{format code}\Default
+ \keyval{sbcmd}{format code}\Default
Control the format of subscript, the last command in the code can take an argument, which is a subscript.
\end{options}
-The following list of keys control the format of superscript and subscript. They are equivalent to the optional parameters of the \cs{supersub} command.
+If \option{sphshift} is positive, the superscript or subscript moves to the right, and if it is negative, it moves to the left. However, for superscript, if \option{spvshift} is positive, the superscript moves up, and if spvshift is negative, it moves down. For subscripts, if \option{spvshift} is positive, the subscript moves down, and if spvshift is negative, it moves up.
+
+The following list of keys control the format of superscript and subscript.
\begin{options}
- \keyval{supersub-hshift}{fixed length}\Default{0pt}
+ \keyval{spbhshift}{fixed length}\Default{0pt}
Extra vertical shift of the superscript and the subscript.
- \kvsplit{supersub-format}{super code}{sub code}\Default{0pt}
+ \kvsplit{spbcmd}{super code}{sub code}\Default
Control the format of superscript or subscript. 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.
- \keyval{supersubsep}{fixed length}\Default{0.3ex}
+ \keyval{vsep}{fixed length}\Default{0.3ex}
The distance between superscript and subscript, its default value is \code{0.3ex}.
- \keychoice{supersubalign}{l,c,r}\Default{l}
+ \keychoice{halign}{l,c,r}\Default{l}
The alignment of superscript and subscript, which contains \code{l}, \code{c}, and \code{r} parameters respectively for left, center, and right alignment.
\end{options}
\section{Examples of use}
-Here is a list of the three commands, please pay attention to the delimiter and usage of optional parameters. Note when the horizontal offset is negative, the starting point is at the right end of the mark.
+Here is a list of the three commands, please pay attention to the usage of optional parameters. Note when the horizontal offset is negative, the starting point is at the right end of the mark.
\begin{example}
-\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[5pt]{c}[-1.5pt]B\sub[5pt]{d}[-1pt]AB
+\spbset{spbcmd={\ttfamily,\color{blue}}}
+A\super[vshift=0.2ex,hshift=0.2em,cmd=\textcolor{red}]{exam}B \\
+$A\sub[cmd=\mathsf,mode=math]{exam}B$ \\
+A\supersub[vsep=0.3ex,halign=c]{examsuper}{sub}B \\
+A\super{c}[vshift=5pt,hshift=-1.5pt]B\sub[vshift=5pt,hshift=-1pt]{d}AB
\end{example}
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*[-1pt]{2}} \\
-\qty[mode = text]{30}{A\supersub{b}{c}[1pt](\color{red})} \\
-\spbset{sub-hshift = 2pt}\unit[mode = text]{A\sub{b}}
+\unit[mode=math]{kg.m/s\super[vshift=-1pt]{2}} \\
+\qty[mode=text]{30}{A\supersub[hshift=1pt,cmd=\color{red}]{b}{c}} \\
+\spbset{sbhshift=2pt}\unit[mode=text]{A\sub{b}}
\end{example}
\pkg*{spbmark} also patches the footer markers for standard document class and \cls*{KOMA-Script}. You can format the footer markers by redefining the \cs{fnmarkfont} command. Note that extra horizontal shift does not work with footnote markers.
+\section{Developer commands}
+If you need to use the original definitions of \cs{textsuperscript}, \cs{textsubscript}, \cs{sp} and \cs{sb} after using the \option{text} or \option{math} option, then you can use the following commands:
+\begin{commands}
+ \command{spb@textsuperscript@save}[\marg{content}]
+ Save the original definition of the \cs{textsuperscript} command, output superscript in the text.
+ \command{spb@textsubscript@save}[\marg{content}]
+ Save the original definition of the \cs{textsubscript} command, output subscript in the text.
+ \command{spb@sp@save}[\marg{content}]
+ Save the original definition of the \cs{sp} command, output superscript in the math mode.
+ \command{spb@sb@save}[\marg{content}]
+ Save the original definition of the \cs{sb} command, output subscript in the math mode.
+\end{commands}
+
\section{Known issues}
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's converted to a space in the \cs*{unit} command, it's recommended to use \code{pt} as the unit of offset.
diff --git a/macros/luatex/generic/lua-widow-control/README.md b/macros/luatex/generic/lua-widow-control/README.md
index 71a4d67f46..6e467d96ff 100644
--- a/macros/luatex/generic/lua-widow-control/README.md
+++ b/macros/luatex/generic/lua-widow-control/README.md
@@ -42,4 +42,4 @@ Lua-widow-control is licensed under the [_Mozilla Public License_, version 2.0](
Please note that a compiled document is absolutely **not** considered to be an "Executable Form" as defined by the MPL. The use of lua-widow-control in a document does not place **any** obligations on the document's author or distributors. The MPL and CC-BY-SA licenses **only** apply to you if you distribute the lua-widow-control source code or documentation.
---
-_v1.1.1 (2021-11-26)_ <!--%%version %%date-->
+_v1.1.2 (2021-12-14)_ <!--%%version %%date-->
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.lua b/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
index 587288e1da..dd488f3bd2 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
@@ -60,12 +60,13 @@ assert(lwc.context or luatexbase, [[
if lwc.context then
lwc.warning = logs.reporter("module", lwc.name)
lwc.attribute = attributes.public(lwc.name)
- lwc.contrib_head = 'contribute_head' -- For \LuaMetaTeX{}
+ lwc.contrib_head = 'contributehead' -- For \LuaMetaTeX{}
+ lwc.stretch_order = "stretchorder"
elseif lwc.plain or lwc.latex then
luatexbase.provides_module {
name = lwc.name,
- date = "2021/11/26", --%%date
- version = "1.1.1", --%%version
+ date = "2021/12/14", --%%date
+ version = "1.1.2", --%%version
description = [[
This module provides a LuaTeX-based solution to prevent
@@ -77,6 +78,7 @@ elseif lwc.plain or lwc.latex then
lwc.warning = function(str) luatexbase.module_warning(lwc.name, str) end
lwc.attribute = luatexbase.new_attribute(lwc.name)
lwc.contrib_head = 'contrib_head' -- For \LuaTeX{}
+ lwc.stretch_order = "stretch_order"
else -- uh oh
error [[
Unsupported format.
@@ -167,7 +169,7 @@ function lwc.save_paragraphs(head)
-- Prevent ultra-short last lines (\TeX{}Book p. 104), except with narrow columns
local parfillskip = last(new_head)
if parfillskip.id == glue_id and tex.hsize > min_col_width then
- parfillskip.stretch_order = 0
+ parfillskip[lwc.stretch_order] = 0
parfillskip.stretch = 0.8 * tex.hsize -- Last line must be at least 20% long
end
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf b/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf
index c0107a6278..d8c7777e88 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf
Binary files differ
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.sty b/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
index ab6e6ffbc1..0b4826dc5e 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
@@ -5,7 +5,7 @@
\NeedsTeXFormat{LaTeX2e}[2015/01/01] % Formats built after 2015 include \LuaTeX{}Base
\ProvidesPackage{lua-widow-control}%
- [2021/11/26 v1.1.1] %%version %%date
+ [2021/12/14 v1.1.2] %%version %%date
\setlength{\clubpenalty}{1}
\setlength{\widowpenalty}{1}
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.tex b/macros/luatex/generic/lua-widow-control/lua-widow-control.tex
index cba8ecfe39..715652186e 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.tex
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.tex
@@ -3,7 +3,7 @@
% SPDX-License-Identifier: MPL-2.0+
% SPDX-FileCopyrightText: 2021 Max Chernoff
-\wlog{lua-widow-control v1.1.1} %%version
+\wlog{lua-widow-control v1.1.2} %%version
\input ltluatex % \LuaTeX{}Base
diff --git a/macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl b/macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl
index 05d9d930f9..a4489b2e70 100644
--- a/macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl
+++ b/macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl
@@ -28,6 +28,7 @@ fonts.handlers.otf.addfeature {
onum=yes,
script=latn,
emdash_kern=yes,
+ trep=yes,
]
\setupalign[hz, hanging]
@@ -171,6 +172,7 @@ setbounds currentpicture to boundingbox OverlayBox;
]
% TOC
+\def\secondleveltoc{subsection}
\starttexdefinition protected SectionTOCcommand #1#2#3
\startcurrentlistentrywrapper % Make the whole line a link
\midaligned{ % Have the title and page number "glued" to the middle
@@ -190,7 +192,7 @@ setbounds currentpicture to boundingbox OverlayBox;
toffset=-\lineheight,
]{
\global\firstsubsectiontrue
- \placelist[subsection][criterium=local]
+ \placelist[\secondleveltoc][criterium=local]
}}
\iffirstsubsection
\blank[quarterline] % No subsections here
@@ -289,8 +291,12 @@ interfaces.implement {
\blackrule[depth=-0.25\baselineskip, height=\dimexpr0.25\baselineskip + 0.4pt, width=8em]
\par
- \strippedurl{\documentvariable{ctan}}
- \strippedurl{\documentvariable{github}}
+ \doifdocumentvariable{ctan}{
+ \strippedurl{\documentvariable{ctan}}
+ }
+ \doifdocumentvariable{github}{
+ \strippedurl{\documentvariable{github}}
+ }
\blank[big]
\noindentation
diff --git a/macros/luatex/generic/lua-widow-control/lwc-documentation.tex b/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
index a49ab00a53..689fcda643 100644
--- a/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
+++ b/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
@@ -37,7 +37,7 @@
\startdocument[
title=lua-widow-control,
author=Max Chernoff,
- version=1.1.1, %%version
+ version=1.1.2, %%version
github=https://github.com/gucci-on-fleek/lua-widow-control,
ctan=https://www.ctan.org/pkg/lua-widow-control,
]
diff --git a/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl b/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl
index 78bdf1fc34..90ede02913 100644
--- a/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl
+++ b/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl
@@ -1,10 +1,10 @@
%D \module
%D [ file=t-lua-widow-control,
-%D version=1.1.1, %%version
+%D version=1.1.2, %%version
%D title=lua-widow-control,
%D subtitle=\ConTeXt module for lua-widow-control,
%D author=Max Chernoff,
-%D date=2021-11-26, %%date
+%D date=2021-12-14, %%date
%D copyright=Max Chernoff,
%D license=MPL-2.0+,
%D url=https://github.com/gucci-on-fleek/lua-widow-control]
diff --git a/macros/luatex/generic/penlight/penlight.pdf b/macros/luatex/generic/penlight/penlight.pdf
index 8d07293e47..1edb8bf2b5 100644
--- a/macros/luatex/generic/penlight/penlight.pdf
+++ b/macros/luatex/generic/penlight/penlight.pdf
Binary files differ
diff --git a/macros/luatex/generic/penlight/penlight.sty b/macros/luatex/generic/penlight/penlight.sty
index 1f1fccc042..9f0ead874f 100644
--- a/macros/luatex/generic/penlight/penlight.sty
+++ b/macros/luatex/generic/penlight/penlight.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-11-07
+% 2021-12-15
% Copyright (C) 2021 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -22,7 +22,7 @@
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
% OR OTHER DEALINGS IN THE SOFTWARE.
-\ProvidesPackage{penlight}[2021-11-07]
+\ProvidesPackage{penlight}[2021-12-15]
\RequirePackage{luacode}
diff --git a/macros/luatex/generic/penlight/penlight.tex b/macros/luatex/generic/penlight/penlight.tex
index 68b8f1bb40..79a5d08589 100644
--- a/macros/luatex/generic/penlight/penlight.tex
+++ b/macros/luatex/generic/penlight/penlight.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-11-07
+% 2021-12-15
% Copyright (C) 2021 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/macros/luatex/generic/penlight/penlightextras.lua b/macros/luatex/generic/penlight/penlightextras.lua
index 13d0ab5817..3479eb3fa0 100644
--- a/macros/luatex/generic/penlight/penlightextras.lua
+++ b/macros/luatex/generic/penlight/penlightextras.lua
@@ -20,7 +20,6 @@ function help_wrt(s1, s2) -- helpful printing, makes it easy to debug, s1 is obj
wrt('\n^^^^^\n')
end
-
function prt_array2d(t)
for _, r in ipairs(t) do
local s = ''
@@ -83,7 +82,7 @@ end
-- -- -- -- functions below extend the array2d module
-local function map_slice1(func, L, i1, i2) -- map a function to a slice of an array, can use PlcExpr
+function pl.array2d.map_slice1(func, L, i1, i2) -- map a function to a slice of an array, can use PlcExpr
i2 = i2 or i1
local len = #L
i1 = check_index(i1, len)
@@ -95,7 +94,7 @@ local function map_slice1(func, L, i1, i2) -- map a function to a slice of an ar
return L
end
-local function map_slice2(func, M, i1, j1, i2, j2) -- map a function to a slice of a Matrix
+function pl.array2d.map_slice2(func, M, i1, j1, i2, j2) -- map a function to a slice of a Matrix
i1, j1, i2, j2 = check_slice(M, i1, j1, i2, j2)
--for i,j in array2d.iter(M, true, i1, j1, i2, j2) do --todo this did not work, penlight may have fixed this
func = check_func(func)
@@ -107,12 +106,12 @@ local function map_slice2(func, M, i1, j1, i2, j2) -- map a function to a slice
return M
end
-local function map_columns(func, M, j1, j2) -- map function to columns of matrix
+function pl.array2d.map_columns(func, M, j1, j2) -- map function to columns of matrix
j2 = j2 or j1
return map_slice2(func, M, 1, j1, -1, j2)
end
-local function map_rows(func, M, i1, i2) -- map function to rows of matrix
+function pl.array2d.map_rows(func, M, i1, i2) -- map function to rows of matrix
i2 = i2 or i1
return map_slice2(func, M, i1, 1, i2, -1)
end
@@ -120,7 +119,7 @@ end
-- -- -- -- -- -- -- --
-function sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele is column, ie sort on which element
+function pl.array2d.sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele is column, ie sort on which element
M_new = {}
for row in pl.seq.sort(M, comp_2ele_func(op, ele)) do
M_new[#M_new+1] = row
@@ -128,13 +127,13 @@ function sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele i
return M_new
end
-local function like(M1, v)
+function pl.array2d.like(M1, v)
v = v or 0
r, c = pl.array2d.size(M1)
return pl.array2d.new(r,c,v)
end
-local function from_table(t) -- turns a labelled table to a 2d, label-free array
+function pl.array2d.from_table(t) -- turns a labelled table to a 2d, label-free array
t_new = {}
for k, v in pairs(t) do
if type(v) == 'table' then
@@ -150,7 +149,7 @@ local function from_table(t) -- turns a labelled table to a 2d, label-free array
return t_new
end
-local function toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line)
+function pl.array2d.toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line)
EL = EL or false
if EL then EL = '\\\\' else EL = '' end
return pl.array2d.reduce2(_1..EL.._2, _1..'&'.._2, M)..EL
@@ -158,31 +157,41 @@ end
-- -- -- -- -- -- --
--- add to array2d module
-pl.array2d['map_columns'] = map_columns
-pl.array2d['map_rows'] = map_rows
-pl.array2d['map_slice2'] = map_slice2
-pl.array2d['map_slice1'] = map_slice1
-pl.array2d['from_table'] = from_table
-pl.array2d['toTeX'] = toTeX
-pl.array2d['sortOP'] = sortOP
-pl.array2d['like'] = like
-- -- -- -- -- -- -- -- -- -- -- -- functions below extend the operator module
-local function strgt(a,b) return tostring(a) > tostring(b) end
-local function strlt(a,b) return tostring(a) < tostring(b) end
-pl.operator['strgt'] = strgt
-pl.operator['strlt'] = strlt
+function pl.operator.strgt(a,b) return tostring(a) > tostring(b) end
+function pl.operator.strlt(a,b) return tostring(a) < tostring(b) end
+
+
+-- -- -- -- string stuff
+local lpeg = require"lpeg"
+local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V
+local number = P{"number",
+ number = (V"int" * V"frac"^-1 * V"exp"^-1) / tonumber,
+ int = V"sign"^-1 * (R"19" * V"digits" + V"digit"),
+ digits = V"digit" * V"digits" + V"digit",
+ digit = R"09",
+ sign = S"+-",
+ frac = P"." * V"digits",
+ exp = S"eE" * V"sign"^-1 * V"digits",
+ }
-local function gextract(s, pat) --extract a pattern from string, returns both
+local mt = getmetatable("") -- register functions with str
+
+
+function mt.__index.gnum(s)
+ return number:match(s)
+end
+
+function mt.__index.gextract(s, pat) --extract a pattern from string, returns both
local s_extr = ''
local s_rem = s
for e in s:gmatch(pat) do
@@ -192,7 +201,7 @@ local function gextract(s, pat) --extract a pattern from string, returns both
return s_extr, s_rem
end
-local function gfirst(s, t) -- get the first pattern found from a table of pattern
+function mt.__index.gfirst(s, t) -- get the first pattern found from a table of pattern
for _, pat in pairs(t) do
if string.find(s, pat) then
return pat
@@ -200,7 +209,7 @@ local function gfirst(s, t) -- get the first pattern found from a table of patte
end
end
-local function appif(S, W, B, O) --append W ord to S tring if B oolean true, otherwise O ther
+function mt.__index.appif(S, W, B, O) --append W ord to S tring if B oolean true, otherwise O ther
--append Word to String
if B then --if b is true
S = S .. W
@@ -211,12 +220,10 @@ local function appif(S, W, B, O) --append W ord to S tring if B oolean true, oth
return S
end
-local mt = getmetatable("") -- register functions with str
-mt.__index["gextract"] = gextract
-mt.__index["gfirst"] = gfirst
-mt.__index["app_if"] = appif
+-- -- -- -- -- math stuffs
+
function mod(a, b) -- math modulo, return remainder only
return a - (math.floor(a/b)*b)
end
@@ -226,9 +233,11 @@ function mod2(a) -- math modulo 2
end
function hasval(x) -- if something has value
- if (x == nil) or (x == false) or (x == 0) or (x == '') then
+ if (type(x) == 'function') then
+ return true
+ elseif (x == nil) or (x == false) or (x == 0) or (x == '') then
return false
- elseif (type(x) ~= 'number') or (type(x) ~= 'string') then
+ elseif (type(x) ~= 'boolean') and (type(x) ~= 'number') and (type(x) ~= 'string') then
if #x == 0 then
return false
else
@@ -241,59 +250,6 @@ end
--- testing here
-____zzz__ = [[
-function hasStrKey(T)
- --checks if a Table contains a string-type key
- local hasaStrKey = false
- for k, v in pairs(T) do --look through table pairs
- if type(k) == "string" then --if any string found, return true
- hasaStrKey = true
- break
- end
- end
- return hasaStrKey
-end
-
-
-function any()
- --todo go through table or list of args and return true of anything is something
-end
-
-function all()
- --todo go through table or list of args and return true of anything is something
-end
-
-
- --elseif x == {} then
- -- return false
-
-n = nil
-b = false
-z = 0
-e = ''
-t = {}
-
---s = 'a'
---n = 1
-
-
-if is(nil) then
- print('TRUE')
-else
- print('FALSE')
-end
-
---print({}=={})
---print(0.0==0)
-
-
-]]
-
-
-
-
-
@@ -343,8 +299,10 @@ function reset_bkt_cnt(n)
end
function add_bkt_cnt(n)
+ -- add open bracket n times, returns brackets
n = n or 1
_NumBkts = _NumBkts + n
+ return ('{'):rep(n)
end
function close_bkt_cnt()
@@ -361,7 +319,7 @@ end
--definition helpers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--- todo add this
+-- todo add and improve this
local function defcmd_nest(cs) -- for option if you'd like your commands under a parent ex. \csparent{var}
tex.print('\\gdef\\'..cs..'#1{\\csname '..var..'--#1--\\endcsname}')
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.lua b/macros/luatex/latex/yamlvars/YAMLvars.lua
index e7baaf26f7..72e4d6ad1a 100644
--- a/macros/luatex/latex/yamlvars/YAMLvars.lua
+++ b/macros/luatex/latex/yamlvars/YAMLvars.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2021-11-07
+--% 2021-12-15
--% Copyright (C) 2021 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -51,6 +51,7 @@
YAMLvars = {} -- self table
YAMLvars.xfm = {}
YAMLvars.prc = {}
+YAMLvars.dec = {} -- table of declare function
YAMLvars.varsvals = {}
YAMLvars.varspecs = {}
@@ -66,8 +67,15 @@ YAMLvars.varTemp = ''
YAMLvars.tabmidrule = 'hline'
+YAMLvars.debug = false
+
YAMLvars.yaml = require('tinyyaml')
+function YAMLvars.debugtalk(s, ss)
+ if YAMLvars.debug then
+ help_wrt(s, ss)
+ end
+end
-- xfm functions (transforms) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
function YAMLvars.xfm.addxspace(var, val)
@@ -143,17 +151,56 @@ end
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+-- dec laration functions, -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+function YAMLvars.dec.gdef(var, dft)
+ YAMLvars.deccmd(var, dft)
+end
+
+function YAMLvars.dec.yvdef(var, dft)
+ YAMLvars.deccmd('yv--'..var, dft)
+end
+
+function YAMLvars.dec.toggle(var, dft)
+ tex.print('\\global\\newtoggle{'..var..'}')
+ YAMLvars.prc.toggle(var, dft)
+end
+
+function YAMLvars.dec.length(var, dft)
+ tex.print('\\global\\newlength{\\'..var..'}')
+ YAMLvars.prc.length(var, dft)
+end
+
-- prc functions (processing) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
function YAMLvars.prc.gdef(var, val)
token.set_macro(var, val, 'global')
+ YAMLvars.debugtalk(var..' = '..val, 'prc gdef')
end
function YAMLvars.prc.yvdef(var, val)
token.set_macro('yv--'..var, val, 'global')
+ YAMLvars.debugtalk('yv--'..var..' = '..val, 'prc yvdef')
+end
+
+function YAMLvars.prc.toggle(t, v) -- requires penlight extras
+ local s = ''
+ if hasval(v) then
+ s = '\\global\\toggletrue{'..t..'}'
+ else
+ s = '\\global\\togglefalse{'..t..'}'
+ end
+ tex.print(s)
+ YAMLvars.debugtalk(s, 'prc toggle')
+end
+
+function YAMLvars.prc.length(t, v)
+ v = v or '0pt'
+ local s = '\\global\\setlength{\\global\\'..t..'}{'..v..'}'
+ tex.print(s)
+ YAMLvars.debugtalk(s, 'prc length')
end
function YAMLvars.prc.PDFtitle(var, val)
@@ -211,13 +258,7 @@ function YAMLvars.prc.setdocvarOpts(var, val)
tex.print(s)
end
-function YAMLvars.prc.toggle(t, v) -- requires penlight extras
- if hasval(v) then
- tex.print('\\global\\toggletrue{'..t..'}')
- else
- tex.print('\\global\\togglefalse{'..t..'}')
- end
-end
+
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -257,7 +298,7 @@ end
function YAMLvars.declareYAMLvarsStr(y)
local t = YAMLvars.yaml.parse(y)
for var, specs in pairs(t) do
- YAMLvars.varspecs[var] = {xfm=YAMLvars.xfrmDefault,prc=YAMLvars.prcDefault,dft=YAMLvars.dftDefault}
+ YAMLvars.varspecs[var] = {xfm=YAMLvars.xfmDefault,prc=YAMLvars.prcDefault,dft=YAMLvars.dftDefault}
if type(specs) == 'string' then
specs = {xfm={specs}}
end
@@ -266,17 +307,17 @@ function YAMLvars.declareYAMLvarsStr(y)
if s == 'xfm' and type(p) ~= 'table' then p = {p} end
YAMLvars.varspecs[var][s] = p -- set property of var
end
- if YAMLvars.varspecs[var]['prc'] == 'gdef' then
- YAMLvars.deccmd(var, YAMLvars.varspecs[var]['dft'])
- elseif YAMLvars.varspecs[var]['prc'] == 'yvdef' then
- YAMLvars.deccmd('yv--'..var, YAMLvars.varspecs[var]['dft'])
- elseif YAMLvars.varspecs[var]['prc'] == 'toggle' then
- tex.print('\\global\\newtoggle{'..var..'}')
- YAMLvars.prc.toggle(var, YAMLvars.varspecs[var]['dft'])
+ if YAMLvars.dec[YAMLvars.varspecs[var].prc] ~= nil then
+ YAMLvars.dec[YAMLvars.varspecs[var].prc](var, YAMLvars.varspecs[var].dft)
+ --else -- actually don't a dec function for all
+ -- -- -- -- tex.print('\\PackageError{YAMLvars}{Declaration function for '..YAMLvarspecs[var].prc..'not found}{}')
end
end
+ YAMLvars.debugtalk(YAMLvars.varspecs, 'declared YAML vars, varspecs')
end
+
+
function YAMLvars.declareYAMLvarsFile(y)
YAMLvars.declareYAMLvarsStr(getYAMLfile(y))
end
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.pdf b/macros/luatex/latex/yamlvars/YAMLvars.pdf
index 18fa3a43e3..eeeab7ea6c 100644
--- a/macros/luatex/latex/yamlvars/YAMLvars.pdf
+++ b/macros/luatex/latex/yamlvars/YAMLvars.pdf
Binary files differ
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.sty b/macros/luatex/latex/yamlvars/YAMLvars.sty
index f7154389d7..2392800651 100644
--- a/macros/luatex/latex/yamlvars/YAMLvars.sty
+++ b/macros/luatex/latex/yamlvars/YAMLvars.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-11-07
+% 2021-12-15
% Copyright (C) 2021 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -24,9 +24,13 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{YAMLvars}[2021]
+\ProvidesPackage{YAMLvars}[2021-12-15]
\RequirePackage{luacode}
+\RequirePackage{xspace}
+\RequirePackage{etoolbox}
+\RequirePackage[pl,extras]{penlight}
+
\luadirect{YAMLvars = require('YAMLvars')}
@@ -39,6 +43,8 @@
}
\DeclareOption{allowundeclared}{
\luadirect{YAMLvars.allowUndeclared = true}
+}\DeclareOption{debug}{
+ \luadirect{YAMLvars.debug = true}
}
\DeclareOption*{\PackageWarning{YAMLvars}{Unknown option: '\CurrentOption'}{}}
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.tex b/macros/luatex/latex/yamlvars/YAMLvars.tex
index 38cc59dc48..5e32058dab 100644
--- a/macros/luatex/latex/yamlvars/YAMLvars.tex
+++ b/macros/luatex/latex/yamlvars/YAMLvars.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-11-07
+% 2021-12-15
% Copyright (C) 2021 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -145,6 +145,12 @@ Rhead:
\end{verbatim}
+To change how a variable is declared (initialize), you can modify or add functions in
+\texttt{YAMLvars.dec} table, where the index is the same as the \texttt{prc} name.
+This function accepts two variables, the var name, and the default value set by dft.
+For lengths and toggles (from etoolbox), these functions are used to initialize lengths
+with newlength and newtoggle.
+
\section{Parsing variables}
A YAML file to be parsed will contain the variables as the top level keys, similar to declaring.