diff options
Diffstat (limited to 'macros/luatex/generic/minim-math')
-rw-r--r-- | macros/luatex/generic/minim-math/README | 6 | ||||
-rw-r--r-- | macros/luatex/generic/minim-math/minim-math.doc | 42 | ||||
-rw-r--r-- | macros/luatex/generic/minim-math/minim-math.lua | 10 | ||||
-rw-r--r-- | macros/luatex/generic/minim-math/minim-math.pdf | bin | 114067 -> 117893 bytes | |||
-rw-r--r-- | macros/luatex/generic/minim-math/minim-math.sty | 70 | ||||
-rw-r--r-- | macros/luatex/generic/minim-math/minim-math.tex | 19 |
6 files changed, 124 insertions, 23 deletions
diff --git a/macros/luatex/generic/minim-math/README b/macros/luatex/generic/minim-math/README index 24fe3397f1..8e3f841e41 100644 --- a/macros/luatex/generic/minim-math/README +++ b/macros/luatex/generic/minim-math/README @@ -1,4 +1,4 @@ -Version: 2024/1.4 +Version: 2025/1.5 SUMMARY @@ -18,6 +18,10 @@ In order to obtain the typeset manual of this package, simply say: HISTORY +2025/1.5 (12/2/2025) + + This version includes a new and experimental latex package. + 2024/1.4 (5/1/2024) * Add \floor and \ceil macros diff --git a/macros/luatex/generic/minim-math/minim-math.doc b/macros/luatex/generic/minim-math/minim-math.doc index 3648458b57..c46d288cb5 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 {2024-01-05} - version {2024/1.4} + date {2025-02-12} + version {2025/1.5} keywords {LuaTeX; Plain TeX; Unicode mathematics} stopmetadata \maketitle \fi @@ -26,6 +26,26 @@ It will not, however, select mathematical fonts for you. That you will have to do for yourself; see below for instructions. +\section Experimental LaTeX support + +As of version 1.5, an experimental latex package is available as a faster +alternative to unicode-math. +The unicode-math user interface is not replicated though: it adds nothing to +the plain tex version but the ⟦\setfontfam⟧ macro for loading a math font. +Use it like this: + +{\leftskip2em +⟦\usepackage {minim-mp} +% additional fonts can be loaded with \setfontfam +\textfam = 1 % for the \text command; see below +\setfontfam \textfam {Latin Modern Roman} +% the next line is also the default +\setfontfam 0 {Latin Modern Math} ⟧ +\par} + +Bugs are likely many at this point; reports are welcome. + + \section Styles and alphabets For some (mostly alphabetical) characters, multiple variants are available, @@ -167,18 +187,17 @@ Do note that various spacing constants are set according to the \emph{last} math family that is assigned to. Therefore, you should assign your main math font to a family after all others. - -\section Shorthands and additions - You can use ⟦*\text⟧ for adding nonmathematical text to your equations. It will behave well in sub- and superscripts: ⟦\text{word}^\text{word}⟧ gives $\smash{\text{word}^\text{word}}$. By default, the font used is the normal mathematical font. You can change this by setting the ⟦*\textfam⟧ parameter to some nonzero value and assigning -a different font to that family (see above). -You probably want to do this, since most commonly-used mathematical fonts do not +a different font to that family. +You probably want this, since most commonly-used mathematical fonts do not include a normal kerning table. +\section Shorthands and additions + All the usual arrows can be made extensible by prefacing them with an ⟦x⟧, including ⟦\xmapsto⟧ and ⟦\xmapsfrom⟧. Alternatively, you can use ⟦\→⟧ etc. as shorthands. Additionally, you can use the following: @@ -214,9 +233,9 @@ 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: +Finally, for plain tex only, 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 @@ -227,7 +246,8 @@ equations: 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⟧. +left-aligned by saying ⟦\leftdisplaystrue⟧. In that case, the displays are +offset from the margin by ⟦\leftdisplayindent⟧ (a muskip, default value~⟦0mu⟧). \section Best practices diff --git a/macros/luatex/generic/minim-math/minim-math.lua b/macros/luatex/generic/minim-math/minim-math.lua index 2598094fdd..f9bafa5ced 100644 --- a/macros/luatex/generic/minim-math/minim-math.lua +++ b/macros/luatex/generic/minim-math/minim-math.lua @@ -169,13 +169,13 @@ end local alphabets = alloc.saved_table('math:alphabets') local function add_to_alphabet(num, code) - alphabets[code] = (alphabets[code] or '') .. string.utfcharacter(num) + alphabets[code] = (alphabets[code] or '') .. utf8.char(num) end local function chars_iterator(input) local a = alphabets[input] if a then - return string.utfvalues(a) + return a:utfvalues() else local from, to = string.match(input, '^([0-9]+)@([0-9]+)$') if from then @@ -185,7 +185,7 @@ local function chars_iterator(input) if i <= n then return gaps[i] or i end end else - return string.utfvalues(input) + return input:utfvalues() end end end @@ -249,14 +249,14 @@ M.greek_variants = } function M.usevariant (char) - for num in string.utfvalues (char) do + for _, num in utf8.codes(char) do local class, fam, _ = tex.getmathcodes(num) tex.setmathcode (num, class, fam, M.greek_variants[num] or num) end end function M.usedefault (char) - for num in string.utfvalues (char) do + for _, num in utf8.codes(char) do local class, fam, _ = tex.getmathcodes(num) tex.setmathcode (num, class, fam, num) end diff --git a/macros/luatex/generic/minim-math/minim-math.pdf b/macros/luatex/generic/minim-math/minim-math.pdf Binary files differindex 9544068d92..9e6509a0ae 100644 --- a/macros/luatex/generic/minim-math/minim-math.pdf +++ b/macros/luatex/generic/minim-math/minim-math.pdf diff --git a/macros/luatex/generic/minim-math/minim-math.sty b/macros/luatex/generic/minim-math/minim-math.sty new file mode 100644 index 0000000000..ec4141f004 --- /dev/null +++ b/macros/luatex/generic/minim-math/minim-math.sty @@ -0,0 +1,70 @@ + +\ProvidesPackage{minim-math}[2025/02/12 Unicode mathematics] + +\RequirePackage[no-math]{fontspec} + +% load the plain package +\let\minimmathlatex=\relax +\input minim-math + +% do not reset math fonts in everymath +\let\check@mathfonts = \relax +\let\mathgroup = \fam + +% unicode-math compatibility +\let \symup = \mup +\let \symbfup = \mbf +\let \symbf = \mbf +\let \symit = \mit +\let \symbfit = \mbfit +\let \symbb = \mbb +\let \symscr = \scr +\let \symcal = \scr +\let \symbfscr = \bfscr +\let \symfrak = \frak +\let \symbffrak = \bffrak +\def \symsfup #1{{\mathstyle{sf}}} +\def \symbfsfup #1{{\mathstyle{sfbf}}} +\def \symsfit #1{{\mathstyle{sfit}}} +\def \symbfsfit #1{{\mathstyle{sfbfit}}} +\def \symtt #1{{\mathstyle{tt}}} + +% more compatibility +\let \mathup = \symup +\let \mathbfup = \symbfup +\let \mathbf = \symbf +\let \mathit = \symit +\let \mathbfit = \symbfit +\let \mathbb = \symbb +\let \mathscr = \symscr +\let \mathcal = \symcal +\let \mathbfscr = \symbfscr +\let \mathfrak = \symfrak +\let \mathbffrak = \symbffrak +\let \mathsfup = \symsfup +\let \mathbfsfup = \symbfsfup +\let \mathsfit = \symsfit +\let \mathbfsfit = \symbfsfit +\let \mathtt = \symtt + +% \setmathfam 0 [features] {font name or file} +\newcount\set@mathfamcount +\protected\def\setmathfam{\afterassignment\set@mathfam\set@mathfamcount= } +\newcommand\set@mathfam[2][]{% + \calculate@math@sizes \csname S@\f@size\endcsname + \expandafter\font\csname math main font \the\set@mathfamcount\endcsname + {#2:mode=base;script=math;ssty=0;#1} at \tf@size pt + \expandafter\font\csname math script font \the\set@mathfamcount\endcsname + {#2:mode=base;script=math;ssty=1;#1} at \sf@size pt + \expandafter\font\csname math sscript font \the\set@mathfamcount\endcsname + {#2:mode=base;script=math;ssty=2;#1} at \ssf@size pt + \textfont\the\set@mathfamcount + \expandafter\csname math main font \the\set@mathfamcount\endcsname + \scriptfont\the\set@mathfamcount + \expandafter\csname math script font \the\set@mathfamcount\endcsname + \scriptscriptfont\the\set@mathfamcount + \expandafter\csname math sscript font \the\set@mathfamcount\endcsname} + +% load a default font +\setmathfam 0 {Latin Modern Math} + diff --git a/macros/luatex/generic/minim-math/minim-math.tex b/macros/luatex/generic/minim-math/minim-math.tex index 7029952418..f39a26aea2 100644 --- a/macros/luatex/generic/minim-math/minim-math.tex +++ b/macros/luatex/generic/minim-math/minim-math.tex @@ -1,6 +1,6 @@ \ifdefined \minimmathloaded - \message{(skipped)} + \wlog{(skipped)} \expandafter\endinput \fi \chardef\minimmathloaded=\catcode`: \catcode`:=11 @@ -543,22 +543,25 @@ % 1 Displayed equations +% \leftdisplaystrue +\newif\ifleftdisplays +\newif\ifdisplay: +\newif\ifdisplay:nr + +\ifdefined\minimmathlatex\else % for the latex package + % \display \protected\def\display{\display:true} % \displaynr {nr} \protected\def\displaynr{\display:true\display:nrtrue \nextifcat\bgroup\display:specialnr\relax} -% \leftdisplaystrue -\newif\ifleftdisplays % \setdisplaynr {...} \newtoks\setdisplaynr % \equationnumber \newcount\equationnumber \equationnumber = 0 \setdisplaynr{\global\advance\equationnumber1(\the\equationnumber)} -\newif\ifdisplay: -\newif\ifdisplay:nr \newtoks\display:specialnr \display:specialnr{\the\setdisplaynr} @@ -572,6 +575,9 @@ \ifdefined \tagging:tagformula \else \let\tagging:tagformula=\ignore \fi +\newmuskip\leftdisplayindent +\leftdisplayindent = 0mu + \protected\def\startdisplay{% % if the display starts a paragraph, omit baselineskip % and ensure that the long \beforedisplayskip is used @@ -581,7 +587,7 @@ % compatibility with minim-pdf \csname tagging:indisplaytrue\endcsname % for left-aligned equations, force manual placement - \ifleftdisplays\muskip0mu\fi} + \ifleftdisplays\mskip\leftdisplayindent\relax\fi} \protected\def\stopdisplay{% \ifleftdisplays \hskip\displaywidth minus\displaywidth\fi @@ -592,6 +598,7 @@ \Ustopdisplaymath \ignorespaces} +\fi % standard mappings |