summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/minim-math
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-03-07 03:02:56 +0000
committerNorbert Preining <norbert@preining.info>2023-03-07 03:02:56 +0000
commit4f55c9271affed648c1a939790a73083043752f5 (patch)
tree5de3491421bbf46cdb941a9a70158ca43e748919 /macros/luatex/generic/minim-math
parent75cd005305bd2c2a0ec383f30ee5b1749ed15183 (diff)
CTAN sync 202303070302
Diffstat (limited to 'macros/luatex/generic/minim-math')
-rw-r--r--macros/luatex/generic/minim-math/README9
-rw-r--r--macros/luatex/generic/minim-math/minim-math.doc20
-rw-r--r--macros/luatex/generic/minim-math/minim-math.lua8
-rw-r--r--macros/luatex/generic/minim-math/minim-math.pdfbin110408 -> 111554 bytes
-rw-r--r--macros/luatex/generic/minim-math/minim-math.tex79
5 files changed, 102 insertions, 14 deletions
diff --git a/macros/luatex/generic/minim-math/README b/macros/luatex/generic/minim-math/README
index 2463570ef8..e6f44401e2 100644
--- a/macros/luatex/generic/minim-math/README
+++ b/macros/luatex/generic/minim-math/README
@@ -1,4 +1,4 @@
-Version: 2022/1.1
+Version: 2023/1.2
SUMMARY
@@ -18,6 +18,13 @@ In order to obtain the typeset manual of this package, simply say:
HISTORY
+2023/1.2 (1/1/2023)
+
+ Minor additions:
+
+ * Add \unaryminus and \smartdecimalcomma
+ * Add convenience functions for numbering displayed equations.
+
2022/1.1 (1/1/2022)
Minor changes:
diff --git a/macros/luatex/generic/minim-math/minim-math.doc b/macros/luatex/generic/minim-math/minim-math.doc
index 79ff1dee71..d458876b41 100644
--- a/macros/luatex/generic/minim-math/minim-math.doc
+++ b/macros/luatex/generic/minim-math/minim-math.doc
@@ -8,8 +8,8 @@
\else \startmetadata
author {Esger Renkema}
title {minim-math}
- date {2022-03-03}
- version {2022/1.1}
+ date {2023-03-03}
+ version {2023/1.2}
keywords {LuaTeX; Plain TeX; Unicode mathematics}
stopmetadata
\maketitle \fi
@@ -117,6 +117,8 @@ sizes, too.
Say ⟦*\decimalcomma⟧ and have commas appear as $\decimalcomma1,2$ instead
of~$1,2$ (⟦*\nodecimalcomma⟧ restores the default).
+Say ⟦*\smartdecimalcomma⟧ for a comma that only acts as punctuation when not
+immediately followed by a digit.
The explicit ⟦*\comma⟧, like ⟦*\colon⟧, will always be punctuation.
The behaviour of limits on integral signs can be set by redefining
@@ -209,6 +211,20 @@ brackets:
⟦$$\underbrace[=1]{(x^2+∥penalty0y^2)}$$⟧ gives
$$\underbrace[=1]{(x^2 + y^2)}.$$
+Finally, the following (entirely optional) alternative to using dollar signs is
+provided, which also offers slight improvements in the spacing of displayed
+equations:
+\stopformulatagging\Ustartdisplaymath
+\halign{# \hfil&#\quad&#\hfil\cr
+&⟦\[ ... \]⟧&inline mathematics\cr
+⟦\display⟧&⟦\[ ... \]⟧&display mathematics\cr
+⟦\displaynr {nr}⟧&⟦\[ ... \]⟧&numbered display mathematics\cr
+⟦\displaynr⟧&⟦\[ ... \]⟧&automatically numbered display mathematics\cr
+}\Ustopdisplaymath\startformulatagging
+
+The automatic display numbering uses the count ⟦\equationnumber⟧ and the token
+list ⟦\setequationnumber⟧ internally. All displays created this way can be made
+left-aligned by saying ⟦\leftdisplaystrue⟧.
\section Best practices
diff --git a/macros/luatex/generic/minim-math/minim-math.lua b/macros/luatex/generic/minim-math/minim-math.lua
index 6373809e43..a4540a92b2 100644
--- a/macros/luatex/generic/minim-math/minim-math.lua
+++ b/macros/luatex/generic/minim-math/minim-math.lua
@@ -365,8 +365,9 @@ end
-- list of noads.
--]]
-local listmathfields = { 'head', 'nucleus', 'sub', 'sup', 'accent', 'bot_accent',
- 'display', 'text', 'script', 'scriptscript', 'num', 'denom', 'degree', 'next' }
+local listmathfields = { 'head', 'nucleus', 'sub', 'sup', 'accent',
+ 'bot_accent', 'display', 'text', 'script', 'scriptscript', 'num', 'denom',
+ 'degree', 'next' } -- note that ‘next’ should be last!
local function noad_iterator (head)
local nodelist = { link=nil, content=head }
@@ -385,7 +386,7 @@ end
local math_char = node.id ('math_char')
-local function inspect_noads (h,d,n)
+local function inspect_noads (h, _, _)
for nd in noad_iterator (h) do
if nd.id == math_char then
local sa = node.has_attribute(nd, style_attribute)
@@ -431,7 +432,6 @@ local is_delimiter =
}
local function tex_accent(class, num, char)
- kind = kind or ''
return '\\math:'..accents[class]..'{'..num..'}'..char
end
diff --git a/macros/luatex/generic/minim-math/minim-math.pdf b/macros/luatex/generic/minim-math/minim-math.pdf
index 33e9aec9f6..6a80c7a07e 100644
--- a/macros/luatex/generic/minim-math/minim-math.pdf
+++ b/macros/luatex/generic/minim-math/minim-math.pdf
Binary files differ
diff --git a/macros/luatex/generic/minim-math/minim-math.tex b/macros/luatex/generic/minim-math/minim-math.tex
index 06fb632a5c..d24a6693dc 100644
--- a/macros/luatex/generic/minim-math/minim-math.tex
+++ b/macros/luatex/generic/minim-math/minim-math.tex
@@ -77,7 +77,7 @@
\protected\def\mbb#1{{\mathstyle{bb}#1}}
\protected\def\frak#1{{\mathstyle{frak}#1}}
\protected\def\bffrak#1{{\mathstyle{bffrak}#1}}
-\protected\def\scr#1{{\mathstyle{scr}#1}} \let\mcal = \cal
+\protected\def\scr#1{{\mathstyle{scr}#1}} \let\mcal = \scr
\protected\def\bfscr#1{{\mathstyle{bfscr}#1}} \let\bfcal = \bfscr
% 1 Processing the character table
@@ -137,8 +137,26 @@
% decimal comma settings
\explicitmathchar \comma
+\Umathchardef \ordcomma "0"0"2C
+\protected\def\smartcomma{%
+ \futurelet\smartcomma:next\smartcomma:do}
+\def\smartcomma:do{\let\smartcomma:c\comma
+ \ifx0\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \ifx1\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \ifx2\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \ifx3\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \ifx4\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \ifx5\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \ifx6\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \ifx7\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \ifx8\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \ifx9\smartcomma:next\let\smartcomma:c\ordcomma\fi
+ \smartcomma:c}
+
\protected\def\decimalcomma {\Umathcode`\, = 0 \Umathcharfam`\, `\,}
\protected\def\nodecimalcomma{\Umathcode`\, = 6 \Umathcharfam`\, `\,}
+\protected\def\smartdecimalcomma{\mathlet,\smartcomma}
+
% set the colon to how it used to be
\Umathcode`\:="3"0"2236 % \ratio
@@ -439,13 +457,18 @@
\def\norm#1{\left\vert#1\right\vert} \let \abs=\norm
\def\Norm#1{\left\Vert#1\right\Vert}
-% a smaller inverse-function sign
-\protected\def\inv{^{\scriptscriptstyle
- \mathbin{\setbox0=\hbox{$\scriptscriptstyle-$}
- \kern.75\wd0 \pdfextension save
+% a slightly smaller unary minus
+\def\unaryminus{\mathord{\mathpalette\unaryminus:make{}}}
+\def\unaryminus:make#1#2{%
+ \setbox0 = \hbox{$#1-$}
+ \kern .75\wd0
+ \pdfextension save
\pdfextension setmatrix{.75 0 0 1}
- \kern-\wd0\box0 \pdfextension restore}
- \mkern-2mu 1}}
+ \kern -\wd0 \box0
+ \pdfextension restore}
+
+% a smaller inverse-function sign
+\protected\def\inv{^{\scriptscriptstyle\unaryminus1}}%
% upright multiletter symbols
\def\mord#1{\mathord{\mathstyle{up}#1}}
@@ -504,6 +527,48 @@
\newmathop {End} \newmathop {Aut}
\newmathop {Dom} \newmathop {Codom}
+% 1 Displayed equations
+
+\newif\ifdisplay:
+\newif\ifdisplay:nr
+\newif\ifleftdisplays
+\newtoks\setdisplaynr
+\newtoks\display:specialnr
+\display:specialnr{\the\setdisplaynr}
+
+% \display
+\protected\def\display{\display:true}
+% \displaynr {nr}
+\protected\def\displaynr{\display:true\display:nrtrue
+ \nextifcat\bgroup\display:specialnr\relax}
+
+% \[ ... \]
+\protected\def\[{\ifdisplay:\expandafter\startdisplay\else\Ustartmath\fi}
+\protected\def\]{\global\expandafter\display:false
+ \ifdisplay:\expandafter\stopdisplay\else\Ustopmath\fi}
+
+\protected\def\startdisplay{%
+ % if the display starts a paragraph, omit baselineskip
+ % and ensure that the long \beforedisplayskip is used
+ \ifvmode \nointerlineskip
+ \noindent \hbox to .5\hsize{\hss}\fi
+ \Ustartdisplaymath
+ % for left-aligned equations, force manual placement
+ \ifleftdisplays\muskip0mu\fi}
+\protected\def\stopdisplay{%
+ \ifleftdisplays
+ \hskip\displaywidth minus\displaywidth\fi
+ \global\expandafter\display:nrfalse
+ \ifdisplay:nr
+ \eqno\the\display:specialnr
+ \global\display:specialnr{\the\setdisplay:nr}\fi
+ \Ustopdisplaymath
+ \ignorespaces}
+
+% default equation numbering
+\newcount\equationnumber \equationnumber = 0
+\setdisplaynr{\global\advance\eqnr1(\the\equationnumber)}
+
%  standard mappings