diff options
Diffstat (limited to 'tex/context/base')
124 files changed, 6185 insertions, 2939 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 1844779fd..a02511e2c 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2022.05.11 11:34} +\newcontextversion{2022.07.06 21:34} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index a520470b2..385df8685 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2022.05.11 11:34} +\edef\contextversion{2022.07.06 21:34} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-cs.mkii b/tex/context/base/mkii/mult-cs.mkii index 5af147f70..e7987a2d6 100644 --- a/tex/context/base/mkii/mult-cs.mkii +++ b/tex/context/base/mkii/mult-cs.mkii @@ -641,6 +641,7 @@ % definitions for interface constants for language cs % \setinterfaceconstant{action}{akce} +\setinterfaceconstant{adaptive}{adaptive} \setinterfaceconstant{address}{adresa} \setinterfaceconstant{after}{po} \setinterfaceconstant{afterhead}{pohlavicce} @@ -1053,6 +1054,8 @@ \setinterfaceconstant{numberconversionset}{numberconversionset} \setinterfaceconstant{numberdistance}{numberdistance} \setinterfaceconstant{numbering}{cislovani} +\setinterfaceconstant{numberlocation}{numberlocation} +\setinterfaceconstant{numbermethod}{numbermethod} \setinterfaceconstant{numberorder}{numberorder} \setinterfaceconstant{numberprefix}{numberprefix} \setinterfaceconstant{numbersegments}{numbersegments} @@ -1063,6 +1066,7 @@ \setinterfaceconstant{numberstopper}{numberstopper} \setinterfaceconstant{numberstrut}{numberstrut} \setinterfaceconstant{numberstyle}{stylcisla} +\setinterfaceconstant{numberthreshold}{numberthreshold} \setinterfaceconstant{numberwidth}{numberwidth} \setinterfaceconstant{nx}{nx} \setinterfaceconstant{ny}{ny} @@ -1234,6 +1238,8 @@ \setinterfaceconstant{small}{male} \setinterfaceconstant{smallcapsfeatures}{smallcapsfeatures} \setinterfaceconstant{smallcapsfont}{smallcapsfont} +\setinterfaceconstant{snap}{snap} +\setinterfaceconstant{snapstep}{snapstep} \setinterfaceconstant{solution}{solution} \setinterfaceconstant{sort}{sort} \setinterfaceconstant{sorttype}{sorttype} diff --git a/tex/context/base/mkii/mult-en.mkii b/tex/context/base/mkii/mult-en.mkii index 2a00dba9b..cb26f8c65 100644 --- a/tex/context/base/mkii/mult-en.mkii +++ b/tex/context/base/mkii/mult-en.mkii @@ -870,6 +870,7 @@ \setinterfaceconstant{frameradius}{frameradius} \setinterfaceconstant{frames}{frames} \setinterfaceconstant{freeregion}{freeregion} +\setinterfaceconstant{freezespacing}{freezespacing} \setinterfaceconstant{from}{from} \setinterfaceconstant{functioncolor}{functioncolor} \setinterfaceconstant{functionstyle}{functionstyle} @@ -950,6 +951,7 @@ \setinterfaceconstant{lastpubsep}{lastpubsep} \setinterfaceconstant{layout}{layout} \setinterfaceconstant{left}{left} +\setinterfaceconstant{leftclass}{leftclass} \setinterfaceconstant{leftcolor}{leftcolor} \setinterfaceconstant{leftcompoundhyphen}{leftcompoundhyphen} \setinterfaceconstant{leftedge}{leftedge} @@ -1008,6 +1010,7 @@ \setinterfaceconstant{menu}{menu} \setinterfaceconstant{method}{method} \setinterfaceconstant{middle}{middle} +\setinterfaceconstant{middleclass}{middleclass} \setinterfaceconstant{middlecolor}{middlecolor} \setinterfaceconstant{middlecommand}{middlecommand} \setinterfaceconstant{middlesource}{middlesource} @@ -1054,6 +1057,8 @@ \setinterfaceconstant{numberconversionset}{numberconversionset} \setinterfaceconstant{numberdistance}{numberdistance} \setinterfaceconstant{numbering}{numbering} +\setinterfaceconstant{numberlocation}{numberlocation} +\setinterfaceconstant{numbermethod}{numbermethod} \setinterfaceconstant{numberorder}{numberorder} \setinterfaceconstant{numberprefix}{numberprefix} \setinterfaceconstant{numbersegments}{numbersegments} @@ -1064,6 +1069,7 @@ \setinterfaceconstant{numberstopper}{numberstopper} \setinterfaceconstant{numberstrut}{numberstrut} \setinterfaceconstant{numberstyle}{numberstyle} +\setinterfaceconstant{numberthreshold}{numberthreshold} \setinterfaceconstant{numberwidth}{numberwidth} \setinterfaceconstant{nx}{nx} \setinterfaceconstant{ny}{ny} @@ -1117,6 +1123,7 @@ \setinterfaceconstant{palet}{palet} \setinterfaceconstant{paper}{paper} \setinterfaceconstant{paragraph}{paragraph} +\setinterfaceconstant{penalties}{penalties} \setinterfaceconstant{period}{period} \setinterfaceconstant{place}{place} \setinterfaceconstant{placehead}{placehead} @@ -1170,6 +1177,7 @@ \setinterfaceconstant{reverse}{reverse} \setinterfaceconstant{right}{right} \setinterfaceconstant{rightchars}{rightchars} +\setinterfaceconstant{rightclass}{rightclass} \setinterfaceconstant{rightcolor}{rightcolor} \setinterfaceconstant{rightcompoundhyphen}{rightcompoundhyphen} \setinterfaceconstant{rightedge}{rightedge} diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii index 7823d3eef..08a2cbb62 100644 --- a/tex/context/base/mkii/mult-pe.mkii +++ b/tex/context/base/mkii/mult-pe.mkii @@ -870,6 +870,7 @@ \setinterfaceconstant{frameradius}{شعاعقالب} \setinterfaceconstant{frames}{قالبها} \setinterfaceconstant{freeregion}{freeregion} +\setinterfaceconstant{freezespacing}{freezespacing} \setinterfaceconstant{from}{از} \setinterfaceconstant{functioncolor}{functioncolor} \setinterfaceconstant{functionstyle}{functionstyle} @@ -950,6 +951,7 @@ \setinterfaceconstant{lastpubsep}{lastpubsep} \setinterfaceconstant{layout}{layout} \setinterfaceconstant{left}{چپ} +\setinterfaceconstant{leftclass}{leftclass} \setinterfaceconstant{leftcolor}{رنگچپ} \setinterfaceconstant{leftcompoundhyphen}{leftcompoundhyphen} \setinterfaceconstant{leftedge}{لبهچپ} @@ -1008,6 +1010,7 @@ \setinterfaceconstant{menu}{منو} \setinterfaceconstant{method}{روش} \setinterfaceconstant{middle}{میان} +\setinterfaceconstant{middleclass}{middleclass} \setinterfaceconstant{middlecolor}{middlecolor} \setinterfaceconstant{middlecommand}{middlecommand} \setinterfaceconstant{middlesource}{middlesource} @@ -1054,6 +1057,8 @@ \setinterfaceconstant{numberconversionset}{numberconversionset} \setinterfaceconstant{numberdistance}{فاصلهشماره} \setinterfaceconstant{numbering}{شمارهگذاری} +\setinterfaceconstant{numberlocation}{numberlocation} +\setinterfaceconstant{numbermethod}{numbermethod} \setinterfaceconstant{numberorder}{numberorder} \setinterfaceconstant{numberprefix}{numberprefix} \setinterfaceconstant{numbersegments}{numbersegments} @@ -1064,6 +1069,7 @@ \setinterfaceconstant{numberstopper}{numberstopper} \setinterfaceconstant{numberstrut}{numberstrut} \setinterfaceconstant{numberstyle}{سبکشماره} +\setinterfaceconstant{numberthreshold}{numberthreshold} \setinterfaceconstant{numberwidth}{عرضشماره} \setinterfaceconstant{nx}{nx} \setinterfaceconstant{ny}{ny} @@ -1117,6 +1123,7 @@ \setinterfaceconstant{palet}{لوح} \setinterfaceconstant{paper}{برگ} \setinterfaceconstant{paragraph}{پاراگراف} +\setinterfaceconstant{penalties}{penalties} \setinterfaceconstant{period}{period} \setinterfaceconstant{place}{بگذار} \setinterfaceconstant{placehead}{بگذارسر} @@ -1170,6 +1177,7 @@ \setinterfaceconstant{reverse}{برعکس} \setinterfaceconstant{right}{راست} \setinterfaceconstant{rightchars}{rightchars} +\setinterfaceconstant{rightclass}{rightclass} \setinterfaceconstant{rightcolor}{رنگراست} \setinterfaceconstant{rightcompoundhyphen}{rightcompoundhyphen} \setinterfaceconstant{rightedge}{لبهراست} diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index 661b94194..e52732b6b 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -1054,6 +1054,8 @@ \setinterfaceconstant{numberconversionset}{numberconversionset} \setinterfaceconstant{numberdistance}{numberdistance} \setinterfaceconstant{numbering}{numerotare} +\setinterfaceconstant{numberlocation}{numberlocation} +\setinterfaceconstant{numbermethod}{numbermethod} \setinterfaceconstant{numberorder}{numberorder} \setinterfaceconstant{numberprefix}{numberprefix} \setinterfaceconstant{numbersegments}{numbersegments} @@ -1064,6 +1066,7 @@ \setinterfaceconstant{numberstopper}{numberstopper} \setinterfaceconstant{numberstrut}{numberstrut} \setinterfaceconstant{numberstyle}{stilnumar} +\setinterfaceconstant{numberthreshold}{numberthreshold} \setinterfaceconstant{numberwidth}{numberwidth} \setinterfaceconstant{nx}{nx} \setinterfaceconstant{ny}{ny} diff --git a/tex/context/base/mkii/type-one.mkii b/tex/context/base/mkii/type-one.mkii index 4f6e43745..d5e281ff7 100644 --- a/tex/context/base/mkii/type-one.mkii +++ b/tex/context/base/mkii/type-one.mkii @@ -2858,7 +2858,7 @@ \definetypeface [dejavu] [rm] [serif] [dejavu] [default] [encoding=\typescripttwo] \definetypeface [dejavu] [ss] [sans] [dejavu] [default] [encoding=\typescripttwo] \definetypeface [dejavu] [tt] [mono] [dejavu] [default] [encoding=\typescripttwo] - \definetypeface [dejavu] [mm] [math] [xits] [default] [rscale=auto] + \definetypeface [dejavu] [mm] [math] [xits] [default] \loadmapfile [dejavu-truetype.map] \stoptypescript @@ -2866,7 +2866,7 @@ \definetypeface [dejavu-condensed] [rm] [serif] [dejavu-condensed] [default] [encoding=\typescripttwo] \definetypeface [dejavu-condensed] [ss] [sans] [dejavu-condensed] [default] [encoding=\typescripttwo] \definetypeface [dejavu-condensed] [tt] [mono] [dejavu-condensed] [default] [encoding=\typescripttwo] - \definetypeface [dejavu-condensed] [mm] [math] [xits] [default] [rscale=auto] + \definetypeface [dejavu-condensed] [mm] [math] [xits] [default] \loadmapfile [dejavu-truetype.map] \stoptypescript @@ -2874,26 +2874,15 @@ \starttypescriptcollection[gentium] - \starttypescript [serif] [gentium] [ec,texnansi,qx,t5,l7x] - \definefontsynonym [Gentium-Roman] [\typescriptthree-gentiumplus-regular] [encoding=\typescriptthree] - \definefontsynonym [Gentium-Italic] [\typescriptthree-gentiumplus-italic] [encoding=\typescriptthree] - \definefontsynonym [Gentium-Bold] [\typescriptthree-gentiumbasic-bold] [encoding=\typescriptthree] - \definefontsynonym [Gentium-BoldItalic] [\typescriptthree-gentiumbasic-bolditalic] [encoding=\typescriptthree] - \definefontsynonym [Gentium-RomanCaps] [\typescriptthree-gentiumplus-regular-sc] [encoding=\typescriptthree] - \definefontsynonym [Gentium-Slanted] [Gentium-Italic] - \definefontsynonym [Gentium-BoldSlanted] [Gentium-BoldItalic] - \loadmapfile[gentium-\typescriptthree.map] - \stoptypescript - - \starttypescript [serif] [gentium] [agr,t2a] + \starttypescript [serif] [gentium] [ec,texnansi,qx,t5,l7x,agr,t2a] \definefontsynonym [Gentium-Roman] [\typescriptthree-gentiumplus-regular] [encoding=\typescriptthree] \definefontsynonym [Gentium-Italic] [\typescriptthree-gentiumplus-italic] [encoding=\typescriptthree] + \definefontsynonym [Gentium-Bold] [\typescriptthree-gentiumplus-bold] [encoding=\typescriptthree] + \definefontsynonym [Gentium-BoldItalic] [\typescriptthree-gentiumplus-bolditalic] [encoding=\typescriptthree] \definefontsynonym [Gentium-RomanCaps] [\typescriptthree-gentiumplus-regular-sc] [encoding=\typescriptthree] - \definefontsynonym [Gentium-Bold] [Gentium-Roman] - \definefontsynonym [Gentium-BoldItalic] [Gentium-Italic] - \definefontsynonym [Gentium-Slanted] [Gentium-Italic] - \definefontsynonym [Gentium-BoldSlanted] [Gentium-Italic] - \loadmapfile[gentium-\typescriptthree.map] + \definefontsynonym [Gentium-Slanted] [\typescriptthree-gentiumplus-italic] [encoding=\typescriptthree] + \definefontsynonym [Gentium-BoldSlanted] [\typescriptthree-gentiumplus-bolditalic] [encoding=\typescriptthree] + \loadmapfile[gentiumplus-\typescriptthree.map] \stoptypescript \starttypescript [serif] [gentium] [name] @@ -2910,6 +2899,10 @@ \starttypescript [gentium] [ec,texnansi,qx,t5,t2a,agr,l7x] \definetypeface [gentium] [rm] [serif] [gentium] [default] [encoding=\typescripttwo] + \definetypeface [gentium] [ss] [sans] [dejavu] [default] [encoding=\typescripttwo] + \definetypeface [gentium] [tt] [mono] [dejavu] [default] [encoding=\typescripttwo] + \definetypeface [gentium] [mm] [math] [xits] [default] + \loadmapfile [dejavu-truetype.map] \stoptypescript \stoptypescriptcollection diff --git a/tex/context/base/mkiv/char-def.lua b/tex/context/base/mkiv/char-def.lua index b4f07a529..3b057b674 100644 --- a/tex/context/base/mkiv/char-def.lua +++ b/tex/context/base/mkiv/char-def.lua @@ -62534,11 +62534,11 @@ characters.data={ linebreak="in", mathspec={ { - class="inner", + class="ellipsis", name="ldots", }, { - class="inner", + class="ellipsis", name="dots", }, }, @@ -66828,6 +66828,8 @@ characters.data={ description="INCREMENT", direction="on", linebreak="al", + mathclass="differential", + mathname="laplace", synonyms={ "forward difference", "laplace operator" }, unicodeslot=0x2206, }, @@ -69460,7 +69462,7 @@ characters.data={ description="VERTICAL ELLIPSIS", direction="on", linebreak="al", - mathclass="inner", + mathclass="ellipsis", mathname="vdots", unicodeslot=0x22EE, }, @@ -69469,7 +69471,7 @@ characters.data={ description="MIDLINE HORIZONTAL ELLIPSIS", direction="on", linebreak="in", - mathclass="inner", + mathclass="ellipsis", mathname="cdots", unicodeslot=0x22EF, }, @@ -69478,7 +69480,7 @@ characters.data={ description="UP RIGHT DIAGONAL ELLIPSIS", direction="on", linebreak="al", - mathclass="inner", + mathclass="ellipsis", mathname="udots", mirror=0x22F1, unicodeslot=0x22F0, @@ -69488,7 +69490,7 @@ characters.data={ description="DOWN RIGHT DIAGONAL ELLIPSIS", direction="on", linebreak="al", - mathclass="inner", + mathclass="ellipsis", mathname="ddots", mirror=0x22F0, unicodeslot=0x22F1, @@ -137215,6 +137217,7 @@ characters.data={ description="PRESENTATION FORM FOR VERTICAL HORIZONTAL ELLIPSIS", direction="on", linebreak="in", + mathclass="ellipsis", specials={ "vertical", 0x2026 }, unicodeslot=0xFE19, }, @@ -227368,10 +227371,10 @@ characters.data={ linebreak="al", mathclass="ordinary", mathspec={ - { - name="Dd", - class="differential", - }, + { + class="differential", + name="Dd", + }, }, specials={ "font", 0x44 }, unicodeslot=0x1D437, @@ -227609,10 +227612,10 @@ characters.data={ linebreak="al", mathclass="ordinary", mathspec={ - { - name="dd", - class="differential", - }, + { + class="differential", + name="dd", + }, }, specials={ "font", 0x64 }, unicodeslot=0x1D451, @@ -227625,10 +227628,10 @@ characters.data={ linebreak="al", mathclass="ordinary", mathspec={ - { - name="ee", - class="exponential", - }, + { + class="exponential", + name="ee", + }, }, specials={ "font", 0x65 }, unicodeslot=0x1D452, @@ -227659,10 +227662,10 @@ characters.data={ linebreak="al", mathclass="ordinary", mathspec={ - { - name="ii", - class="imaginary", - }, + { + class="imaginary", + name="ii", + }, }, specials={ "font", 0x69 }, unicodeslot=0x1D456, @@ -227675,10 +227678,10 @@ characters.data={ linebreak="al", mathclass="ordinary", mathspec={ - { - name="ji", - class="imaginary", - }, + { + class="imaginary", + name="ji", + }, }, specials={ "font", 0x6A }, unicodeslot=0x1D457, diff --git a/tex/context/base/mkiv/char-ini.lua b/tex/context/base/mkiv/char-ini.lua index 3543b01ef..09c7994a9 100644 --- a/tex/context/base/mkiv/char-ini.lua +++ b/tex/context/base/mkiv/char-ini.lua @@ -285,9 +285,9 @@ local blocks = allocate { ["devanagariextended"] = { first = 0x0A8E0, last = 0x0A8FF, description = "Devanagari Extended" }, ["digitsarabicindic"] = { first = 0x00660, last = 0x00669, math = true }, -- ["digitsbengali"] = { first = 0x009E6, last = 0x009EF, math = true }, - ["digitsbold"] = { first = 0x1D7CE, last = 0x1D7D8, math = true }, + ["digitsbold"] = { first = 0x1D7CE, last = 0x1D7D7, math = true }, -- ["digitsdevanagari"] = { first = 0x00966, last = 0x0096F, math = true }, - ["digitsdoublestruck"] = { first = 0x1D7D8, last = 0x1D7E2, math = true }, + ["digitsdoublestruck"] = { first = 0x1D7D8, last = 0x1D7E1, math = true }, -- ["digitsethiopic"] = { first = 0x01369, last = 0x01371, math = true }, ["digitsextendedarabicindic"] = { first = 0x006F0, last = 0x006F9, math = true }, -- ["digitsgujarati"] = { first = 0x00AE6, last = 0x00AEF, math = true }, @@ -298,12 +298,12 @@ local blocks = allocate { ["digitslatin"] = { first = 0x00030, last = 0x00039, math = true }, -- ["digitsmalayalam"] = { first = 0x00D66, last = 0x00D6F, math = true }, -- ["digitsmongolian"] = { first = 0x01810, last = 0x01809, math = true }, - ["digitsmonospace"] = { first = 0x1D7F6, last = 0x1D80F, math = true }, + ["digitsmonospace"] = { first = 0x1D7F6, last = 0x1D7FF, math = true }, -- ["digitsmyanmar"] = { first = 0x01040, last = 0x01049, math = true }, ["digitsnormal"] = { first = 0x00030, last = 0x00039, math = true }, -- ["digitsoriya"] = { first = 0x00B66, last = 0x00B6F, math = true }, - ["digitssansserifbold"] = { first = 0x1D7EC, last = 0x1D805, math = true }, - ["digitssansserifnormal"] = { first = 0x1D7E2, last = 0x1D7EC, math = true }, + ["digitssansserifbold"] = { first = 0x1D7EC, last = 0x1D7F5, math = true }, + ["digitssansserifnormal"] = { first = 0x1D7E2, last = 0x1D7EB, math = true }, -- ["digitstamil"] = { first = 0x00030, last = 0x00039, math = true }, -- no zero -- ["digitstelugu"] = { first = 0x00C66, last = 0x00C6F, math = true }, -- ["digitsthai"] = { first = 0x00E50, last = 0x00E59, math = true }, @@ -407,7 +407,7 @@ local blocks = allocate { ["lowercasegreekbold"] = { first = 0x1D6C2, last = 0x1D6DB, math = true }, ["lowercasegreekbolditalic"] = { first = 0x1D736, last = 0x1D74F, math = true }, ["lowercasegreekitalic"] = { first = 0x1D6FC, last = 0x1D715, math = true }, - ["lowercasegreeknormal"] = { first = 0x003B1, last = 0x003CA, math = true }, + ["lowercasegreeknormal"] = { first = 0x003B1, last = 0x003C9, math = true }, ["lowercasegreeksansserifbold"] = { first = 0x1D770, last = 0x1D789, math = true }, ["lowercasegreeksansserifbolditalic"] = { first = 0x1D7AA, last = 0x1D7C3, math = true }, ["lowercaseitalic"] = { first = 0x1D44E, last = 0x1D467, math = true }, diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 19f0f51a2..34002f06d 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2022.05.11 11:34} +\newcontextversion{2022.07.06 21:34} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/cont-run.mkiv b/tex/context/base/mkiv/cont-run.mkiv index 12c12e0d9..764866a9e 100644 --- a/tex/context/base/mkiv/cont-run.mkiv +++ b/tex/context/base/mkiv/cont-run.mkiv @@ -53,7 +53,9 @@ \unexpanded\def\blocksynctexfile[#1]% {\processcommacommand{#1}\synctexblockfilename} -\def\continuewhenlmtxmode +\let\continuewhenmkivmode\relax + +\unexpanded\def\continuewhenlmtxmode {\starttext \startTEXpage[\c!offset=2ex,\c!foregroundstyle=\tttf]% This file needs \LuaMetaTeX\ and \ConTeXt\ \LMTX.% diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 6c37e0f35..40b49d386 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2022.05.11 11:34} +\edef\contextversion{2022.07.06 21:34} %D Kind of special: diff --git a/tex/context/base/mkiv/core-dat.lua b/tex/context/base/mkiv/core-dat.lua index b49750159..b58a801d9 100644 --- a/tex/context/base/mkiv/core-dat.lua +++ b/tex/context/base/mkiv/core-dat.lua @@ -156,8 +156,29 @@ local function setdataset(settings) end end -local function datasetvariable(name,tag,key) - local t = collected[name] +local cache = table.setmetatableindex(function(t,k) + local v = table.load(k..".tuc") + if v then + v = v.job + if v then + v = v.datasets + if v then + v = v.collected + end + end + end + if not v then + v = { } + if trace_datasets then + report_dataset("error: unknown dataset job %a",k) + end + end + t[k] = v + return v +end) + +local function datasetvariable(name,tag,key,cache) + local t = (cache or collected)[name] if t == nil then if trace_datasets then report_dataset("error: unknown dataset, name %a, tag %a, not passed to tex",name) -- no tag @@ -181,6 +202,10 @@ local function datasetvariable(name,tag,key) end end +local function datasetvariablefromjob(jobnname,name,tag,key) + datasetvariable(name,tag,key,cache[jobnname]) +end + implement { name = "setdataset", actions = setdataset, @@ -200,6 +225,12 @@ implement { arguments = "3 strings", } +implement { + name = "datasetvariablefromjob", + arguments = { "string", "string", "string", "string" }, + actions = datasetvariablefromjob +} + --[[ldx-- <p>We also provide an efficient variant for page states.</p> --ldx]]-- diff --git a/tex/context/base/mkiv/data-env.lua b/tex/context/base/mkiv/data-env.lua index 3b10d89b8..c9c11e49c 100644 --- a/tex/context/base/mkiv/data-env.lua +++ b/tex/context/base/mkiv/data-env.lua @@ -95,8 +95,8 @@ local relations = allocate { -- todo: handlers also here names = { "mp" }, variable = 'MPINPUTS', suffixes = CONTEXTLMTXMODE > 0 - and { 'mp', 'mpxl', 'mpvi', 'mpiv', 'mpii' } - or { 'mp', 'mpvi', 'mpiv', 'mpii' }, + and { 'mpxl', 'mpvi', 'mpiv', 'mpii', 'mp' } + or { 'mpvi', 'mpiv', 'mpii', 'mp' }, usertype = true, }, tex = { diff --git a/tex/context/base/mkiv/font-dsp.lua b/tex/context/base/mkiv/font-dsp.lua index 74a0a1f38..8f65ed9d9 100644 --- a/tex/context/base/mkiv/font-dsp.lua +++ b/tex/context/base/mkiv/font-dsp.lua @@ -2515,7 +2515,9 @@ do local scriptoffset = tableoffset + readushort(f) local featureoffset = tableoffset + readushort(f) local lookupoffset = tableoffset + readushort(f) - local variationsoffset = version > 0x00010000 and (tableoffset + readulong(f)) or 0 + -- MFK : Rubik-Regular.ttf : we need to delay adding the offset + -- local variationsoffset = version > 0x00010000 and (tableoffset + readulong(f)) or 0 + local variationsoffset = version > 0x00010000 and readulong(f) or 0 if not scriptoffset then return end @@ -2541,7 +2543,8 @@ do end -- if variationsoffset > 0 then - loadvariations(f,fontdata,variationsoffset,lookuptypes,featurehash,featureorder) + -- loadvariations(f,fontdata,variationsoffset,lookuptypes,featurehash,featureorder) + loadvariations(f,fontdata,tableoffset + variationsoffset,lookuptypes,featurehash,featureorder) end end end diff --git a/tex/context/base/mkiv/font-osd.lua b/tex/context/base/mkiv/font-osd.lua index d169faf64..ecf8009f9 100644 --- a/tex/context/base/mkiv/font-osd.lua +++ b/tex/context/base/mkiv/font-osd.lua @@ -6,15 +6,15 @@ if not modules then modules = { } end modules ['font-osd'] = { -- script devanag license = "see context related readme files" } -local experiment1 = false -local experiment2 = false -local experiment2b1 = false -local experiment2b2 = false - -experiments.register("fonts.indic.experiment1", function(v) experiment1 = v end) -experiments.register("fonts.indic.experiment2", function(v) experiment2 = v end) -experiments.register("fonts.indic.experiment2b1", function(v) experiment2b1 = v end) -experiments.register("fonts.indic.experiment2b2", function(v) experiment2b2 = v end) +-- local experiment1 = false +-- local experiment2 = false +-- local experiment2b1 = false +-- local experiment2b2 = false + +-- experiments.register("fonts.indic.experiment1", function(v) experiment1 = v end) +-- experiments.register("fonts.indic.experiment2", function(v) experiment2 = v end) +-- experiments.register("fonts.indic.experiment2b1", function(v) experiment2b1 = v end) +-- experiments.register("fonts.indic.experiment2b2", function(v) experiment2b2 = v end) -- we need to check nbsphash (context only) diff --git a/tex/context/base/mkiv/l-math.lua b/tex/context/base/mkiv/l-math.lua index 69f0a19e9..6105bc3c2 100644 --- a/tex/context/base/mkiv/l-math.lua +++ b/tex/context/base/mkiv/l-math.lua @@ -14,9 +14,19 @@ end if not math.round then - local floor = math.floor + if xmath then + + math.round = xmath.round + + else - function math.round(x) return floor(x + 0.5) end + local floor = math.floor + + function math.round(x) + return x < 0 and -floor(-x + 0.5) or floor(x + 0.5) + end + + end end diff --git a/tex/context/base/mkiv/lxml-aux.lua b/tex/context/base/mkiv/lxml-aux.lua index 126df4d82..fc17371e5 100644 --- a/tex/context/base/mkiv/lxml-aux.lua +++ b/tex/context/base/mkiv/lxml-aux.lua @@ -316,6 +316,37 @@ function xml.replace(root,pattern,whatever) end end +function xml.expand(root,pattern,whatever) + local collected = root and xmlapplylpath(root,pattern) + if collected then + for c=1,#collected do + local e = collected[c] + local p = e.__p__ + if p then + if trace_manipulations then + report('expanding',pattern,c,e) + end + local d = p.dt + local n = e.ni + local t = whatever(e,p) + if t then + if type(t) == "table" then + t = xmlcopy(t) + d[n] = t[1] + for i=2,#t do + n = n + 1 + insert(d,n,t[i]) + end + else + d[n] = t + end + redo_ni(d) -- probably not needed + end + end + end + end +end + local function wrap(e,wrapper) local t = { rn = e.rn, diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua index 1f0ec33b1..e18362bd8 100644 --- a/tex/context/base/mkiv/lxml-tab.lua +++ b/tex/context/base/mkiv/lxml-tab.lua @@ -1424,7 +1424,7 @@ can speed up things a bit. The second argument is not to be used!</p> -- end -- end -- --- We need to prevent __p__ recursio, so: +-- We need to prevent __p__ recursion, so: local function copy(old,p) if old then diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index dee5de585..56c7944f4 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -7346,6 +7346,9 @@ return { ["adaptive"]={ ["en"]="adaptive", }, + ["freezespacing"]={ + ["en"]="freezespacing", + }, ["address"]={ ["cs"]="adresa", ["de"]="adresse", @@ -10051,6 +10054,15 @@ return { ["en"]="mathclass", ["fr"]="classemath", }, + ["leftclass"]={ + ["en"]="leftclass", + }, + ["rightclass"]={ + ["en"]="rightclass", + }, + ["middleclass"]={ + ["en"]="middleclass", + }, ["mathlimits"]={ ["en"]="mathlimits", ["fr"]="limitesmath", @@ -10466,6 +10478,9 @@ return { ["pe"]="فاصلهشماره", ["ro"]="numberdistance", }, + ["numberthreshold"]={ + ["en"]="numberthreshold", + }, ["numbering"]={ ["cs"]="cislovani", ["de"]="nummerierung", @@ -10480,6 +10495,10 @@ return { ["en"]="numberorder", ["fr"]="ordrenumero", }, + ["numberlocation"]= + { + ["en"]="numberlocation", + }, ["numberprefix"]={ ["en"]="numberprefix", ["fr"]="prefixenumero", @@ -10890,6 +10909,9 @@ return { ["pe"]="پاراگراف", ["ro"]="paragraf", }, + ["penalties"]={ + ["en"]="penalties", + }, ["period"]={ ["en"]="period", ["fr"]="periode", @@ -12261,6 +12283,10 @@ return { ["pe"]="حاشیهمتن", ["ro"]="textmargin", }, + ["numbermethod"]={ + ["en"]="numbermethod", + ["nl"]="nummermethode", + }, ["textmethod"]={ ["cs"]="textmethod", ["de"]="textmethod", diff --git a/tex/context/base/mkiv/mult-fun.lua b/tex/context/base/mkiv/mult-fun.lua index 128e5b51e..5a3725b32 100644 --- a/tex/context/base/mkiv/mult-fun.lua +++ b/tex/context/base/mkiv/mult-fun.lua @@ -117,7 +117,8 @@ return { "grayscale", "greyscale", "withgray", "withgrey", "colorpart", "colorlike", "readfile", - "clearxy", "unitvector", "center", -- redefined + "clearxy", "unitvector", + "center", -- redefined "epsed", "anchored", "originpath", "infinite", "break", @@ -171,7 +172,7 @@ return { "passvariable", "passarrayvariable", "tostring", "topair", "format", "formatted", "quotation", "quote", "startpassingvariable", "stoppassingvariable", -- - "eofill", "eoclip", "nofill", "dofill", "fillup", "eofillup", "nodraw", "dodraw", + "eofill", "eoclip", "nofill", "dofill", "fillup", "eofillup", "nodraw", "dodraw", "enfill", "area", -- "addbackground", @@ -232,5 +233,9 @@ return { "processpath", "pencilled", "sortedintersectiontimes", "intersectionpath", "firstintersectionpath", "secondintersectionpath", "intersectionsfound", "cutbeforefirst", "cutafterfirst", "cutbeforelast", "cutafterlast", + -- + "xnormalized", "ynormalized", "xynormalized", + "phantom", + "scrutinized", }, } diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index 7fb7e3fa8..ae31c547e 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -17,7 +17,8 @@ return { "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "maxcardminusone", "zeropoint", "onepoint", "halfapoint", "onebasepoint", "maxcount", "maxdimen", "scaledpoint", "thousandpoint", "points", "halfpoint", - "zeroskip", + "zeroskip", "centeringskip", "stretchingskip", "shrinkingskip", + "centeringfillskip", "stretchingfillskip", "shrinkingfillskip", "zeromuskip", "onemuskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "normalpagebox", @@ -166,16 +167,14 @@ return { "mathfractioncode", "mathmiddlecode", "mathaccentcode", "mathfencedcode", "mathghostcode", "mathvariablecode", "mathactivecode", "mathvcentercode", "mathconstructcode", "mathwrappedcode", "mathbegincode", "mathendcode", "mathexplicitcode", "mathdivisioncode", "mathfactorialcode", - "mathdimensioncode", - -- - "mathimaginarycode", "mathdifferentialcode", "mathexponentialcode", "mathfunctioncode", "mathdigitcode", + "mathdimensioncode", "mathexperimentalcode", "mathtextpunctuationcode", + "mathimaginarycode", "mathdifferentialcode", "mathexponentialcode", "mathellipsiscode", "mathfunctioncode", "mathdigitcode", -- "mathtopaccentcode", "mathbottomaccentcode", "mathdelimitercode", "mathrootcode", "mathprintcode", -- "mathalphacode", "mathboxcode", "mathchoicecode", "mathnothingcode", "mathlimopcode", "mathnolopcode", + "mathunsetcode", "mathunspacedcode", "mathallcode", "mathfakecode", -- "constantnumber", "constantnumberargument", "constantdimen", "constantdimenargument", "constantemptyargument", -- - "continueifinputfile", - -- "luastringsep", "!!bs", "!!es", -- "lefttorightmark", "righttoleftmark", "lrm", "rlm", @@ -210,7 +209,9 @@ return { -- "nopreslackclassoptioncode", "nopostslackclassoptioncode", "lefttopkernclassoptioncode", "righttopkernclassoptioncode", "leftbottomkernclassoptioncode", "rightbottomkernclassoptioncode", - "lookaheadforendclassoptioncode", "defaultmathclassoptions", + "lookaheadforendclassoptioncode", "noitaliccorrectionclassoptioncode", "defaultmathclassoptions", + -- "openfenceclassoptioncode", "closefenceclassoptioncode", "middlefenceclassoptioncode", + "checkligatureclassoptioncode", "flattenclassoptioncode", "omitpenaltyclassoptioncode", -- "noligaturingglyphoptioncode", "nokerningglyphoptioncode", "noleftligatureglyphoptioncode", "noleftkernglyphoptioncode", "norightligatureglyphoptioncode", "norightkernglyphoptioncode", @@ -225,7 +226,7 @@ return { -- "normalworddiscoptioncode", "preworddiscoptioncode", "postworddiscoptioncode", -- - "continuewhenlmtxmode", + "continueifinputfile", "continuewhenlmtxmode", "continuewhenmkivmode", }, ["helpers"] = { -- @@ -338,7 +339,7 @@ return { -- "givenwidth", "givenheight", "givendepth", "scangivendimensions", -- - "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchtotal", + "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchtotal", "scratchitalic", "scratchhsize", "scratchvsize", "scratchxoffset", "scratchyoffset", "scratchhoffset", "scratchvoffset", "scratchxposition", "scratchyposition", diff --git a/tex/context/base/mkiv/mult-mps.lua b/tex/context/base/mkiv/mult-mps.lua index 9807902f8..008bcbb9f 100644 --- a/tex/context/base/mkiv/mult-mps.lua +++ b/tex/context/base/mkiv/mult-mps.lua @@ -3,7 +3,7 @@ return { "btex", "etex", "verbatimtex", }, shortcuts = { - "..", "...", "--", "---", "&", "\\", + "..", "...", "--", "---", "&", "&&", "\\", }, primitives = { -- to be checked "charcode", "day", "linecap", "linejoin", "miterlimit", "stacking", "month", "pausing", @@ -50,7 +50,7 @@ return { "message", "delimiters", "turningnumber", "errmessage", "scantokens", "end", "outer", "inner", "write", "to", "readfrom", "closefrom", "withprescript", "withpostscript", - "top", "bot", "lft", "rt", "ulft", "urt", "llft", "lrt", + -- "top", "bot", "lft", "rt", "ulft", "urt", "llft", "lrt", -- "redpart", "greenpart", "bluepart", "cyanpart", "magentapart", "yellowpart", @@ -70,6 +70,13 @@ return { "overloadmode", "setproperty", -- "intersectiontimeslist", "arcpoint", "arcpointlist", "subarclength", "maxknotpool", "nocycle", + "pathpoint", "pathprecontrol", "pathpostcontrol", "pathdirection", + "deltapoint", "deltaprecontrol", "deltapostcontrol", "deltadirection", + "corner", "xrange", "yrange", + "convexed", "uncontrolled", + "nep", "makenep", + "withmiterlimit", "withlinejoin", "withlinecap", + "centerof", "centerofmass", }, commands = { "on", "off", @@ -86,7 +93,8 @@ return { "pensquare", "penrazor", "penspec", "origin", "quartercircle", "right", "unitsquare", "up", "withdots", - "abs", "bbox", "ceiling", "center", "cutafter", "cutbefore", "dir", + "abs", "bbox", "ceiling", "cutafter", "cutbefore", "dir", + -- "center", "directionpoint", "div", "dotprod", "intersectionpoint", "inverse", "mod", "round", "unitvector", "whatever", "cutdraw", "draw", "drawarrow", "drawdblarrow", "fill", "filldraw", "drawdot", @@ -126,6 +134,8 @@ return { "primitive", "permanent", "immutable", "mutable", "frozen", -- "showproperty", "showhashentry", + -- + "top", "bot", "lft", "rt", "ulft", "urt", "llft", "lrt", }, internals = { -- we need to remove duplicates above -- diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index 2a6cd60cc..43e9515db 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -76,10 +76,16 @@ return { "Udelimiterunder", "Uhextensible", "Uleft", + "UmathDelimiterPercent", + "UmathDelimiterShortfall", "Umathaccent", "Umathaccentbasedepth", "Umathaccentbaseheight", + "Umathaccentbottomoverschoot", "Umathaccentbottomshiftdown", + "Umathaccentsuperscriptdrop", + "Umathaccentsuperscriptpercent", + "Umathaccenttopovershoot", "Umathaccenttopshiftup", "Umathaccentvariant", "Umathadapttoleft", @@ -262,10 +268,12 @@ return { "beginmathgroup", "beginsimplegroup", "boundary", + "boxadapt", "boxanchor", "boxanchors", "boxattribute", "boxdirection", + "boxfreeze", "boxgeometry", "boxorientation", "boxshift", @@ -303,6 +311,7 @@ return { "etoksapp", "etokspre", "everybeforepar", + "everymathatom", "everytab", "exceptionpenalty", "expand", @@ -317,6 +326,7 @@ return { "explicithyphenpenalty", "firstvalidlanguage", "flushmarks", + "fontcharta", "fontid", "fontmathcontrol", "fontspecdef", @@ -349,8 +359,10 @@ return { "glyphtextscale", "glyphxoffset", "glyphxscale", + "glyphxscaled", "glyphyoffset", "glyphyscale", + "glyphyscaled", "gtoksapp", "gtokspre", "hccode", @@ -431,6 +443,7 @@ return { "letmathspacing", "letprotected", "lettonothing", + "linebreakcriterium", "linedirection", "localbrokenpenalty", "localcontrol", @@ -462,7 +475,9 @@ return { "mathbeginclass", "mathdelimitersmode", "mathdirection", + "mathdisplaymode", "mathdisplayskipmode", + "mathdoublescriptmode", "mathendclass", "matheqnogapstep", "mathfenced", @@ -471,6 +486,8 @@ return { "mathforwardpenalties", "mathfrac", "mathghost", + "mathgluemode", + "mathgroupingmode", "mathleftclass", "mathlimitsmode", "mathmiddle", @@ -521,6 +538,7 @@ return { "parattribute", "pardirection", "permanent", + "pettymuskip", "postexhyphenchar", "posthyphenchar", "postinlinepenalty", @@ -568,7 +586,9 @@ return { "tabsize", "textdirection", "thewithoutunit", + "tinymuskip", "todimension", + "tohexadecimal", "tointeger", "tokenized", "toksapp", @@ -576,6 +596,8 @@ return { "tolerant", "tomathstyle", "toscaled", + "tosparsedimension", + "tosparsescaled", "tpack", "tracingadjusts", "tracingalignments", @@ -587,6 +609,7 @@ return { "tracingmarks", "tracingmath", "tracingnodes", + "tracingpenalties", "uleaders", "undent", "unexpandedloop", @@ -827,6 +850,7 @@ return { "hfilneg", "hfuzz", "holdinginserts", + "holdingmigrations", "hrule", "hsize", "hskip", @@ -1001,7 +1025,6 @@ return { "thickmuskip", "thinmuskip", "time", - "tinymuskip", "toks", "toksdef", "tolerance", diff --git a/tex/context/base/mkiv/page-pcl.mkiv b/tex/context/base/mkiv/page-pcl.mkiv index 43ba4feb3..262ee71ab 100644 --- a/tex/context/base/mkiv/page-pcl.mkiv +++ b/tex/context/base/mkiv/page-pcl.mkiv @@ -246,8 +246,8 @@ \page_marks_synchronize_column\plusone\c_page_col_n_of_columns\recurselevel\scratchbox % backgrounds \anch_mark_column_box\scratchbox\recurselevel - \mixedcolumnseparatorheight\ht\scratchbox - \mixedcolumnseparatordepth \dp\scratchbox + \pagecolumnseparatorheight\ht\scratchbox + \pagecolumnseparatordepth \dp\scratchbox \inheritedpagecolumnsframedbox\recurselevel\scratchbox} \def\page_col_routine_package diff --git a/tex/context/base/mkiv/publ-dat.lua b/tex/context/base/mkiv/publ-dat.lua index 382f70471..64aaaf460 100644 --- a/tex/context/base/mkiv/publ-dat.lua +++ b/tex/context/base/mkiv/publ-dat.lua @@ -379,6 +379,7 @@ function publications.new(name) suffixes = { }, xmldata = xmlconvert(xmlplaceholder), details = { }, + missing = { }, ordered = { }, nofbytes = 0, entries = nil, -- empty == all @@ -732,6 +733,7 @@ do end end end +-- inspect(luadata) statistics.stoptiming(publications) end @@ -1172,18 +1174,31 @@ do end end - function savers.lua(dataset,filename,tobesaved) - local list = { } - local n = 0 - for tag, data in next, tobesaved do + function savers.lua(dataset,filename,tobesaved,options) + local list = { } + local n = 0 + + local function totable(data,category) local t = { } for key, value in next, data do if not privates[key] then - d[key] = value + t[key] = value end end - list[tag] = t + t.category = category n = n + 1 + return t + end + + if options.category then + setmetatableindex(list,"table") + for tag, data in next, tobesaved do + list[data.category or "unknown"][tag] = totable(data) + end + else + for tag, data in next, tobesaved do + list[tag] = totable(data,data.category) + end end report("%s entries from dataset %a saved in %a",n,dataset,filename) table.save(filename,list) @@ -1200,6 +1215,7 @@ do local filename = specification.filename local filetype = specification.filetype local criterium = specification.criterium + local options = settings_to_hash(specification.options or "") statistics.starttiming(publications) if not filename or filename == "" then report("no filename for saving given") @@ -1229,7 +1245,7 @@ do end end end - saver(dataset,filename,tobesaved) + saver(dataset,filename,tobesaved,options) else report("unknown format %a for saving %a",filetype,dataset) end @@ -1250,6 +1266,7 @@ do { "filename" }, { "filetype" }, { "criterium" }, + { "options" }, } } } diff --git a/tex/context/base/mkiv/publ-imp-cite.mkvi b/tex/context/base/mkiv/publ-imp-cite.mkvi index 721985499..c9afdbf42 100644 --- a/tex/context/base/mkiv/publ-imp-cite.mkvi +++ b/tex/context/base/mkiv/publ-imp-cite.mkvi @@ -85,7 +85,8 @@ \startsetups btx:cite:invalid \btxcitereference - {\tt <\currentbtxreference>} + % {\tt <\currentbtxreference>} + {\tt <\currentbtxmissingreference>} \stopsetups \startsetups btx:cite:concat diff --git a/tex/context/base/mkiv/publ-ini.lua b/tex/context/base/mkiv/publ-ini.lua index 210a14deb..dac0ab441 100644 --- a/tex/context/base/mkiv/publ-ini.lua +++ b/tex/context/base/mkiv/publ-ini.lua @@ -22,7 +22,7 @@ if not modules then modules = { } end modules ['publ-ini'] = { -- gain is not that large anyway because not much publication stuff is flushed. local next, rawget, type, tostring, tonumber = next, rawget, type, tostring, tonumber -local match, find, gsub, lower = string.match, string.find, string.gsub, string.lower +local match, find, gsub = string.match, string.find, string.gsub local concat, sort, tohash = table.concat, table.sort, table.tohash local mod = math.mod local formatters = string.formatters @@ -32,7 +32,7 @@ local sortedkeys, sortedhash = table.sortedkeys, table.sortedhash local setmetatableindex = table.setmetatableindex local lpegmatch = lpeg.match local P, S, C, Ct, Cs, R, Carg = lpeg.P, lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.R, lpeg.Carg -local upper = characters.upper +local upper, lower = characters.upper, characters.lower local report = logs.reporter("publications") local report_cite = logs.reporter("publications","cite") @@ -693,6 +693,49 @@ local findallused do end } + implement { + name = "btxmissing", + arguments = "2 strings", + actions = function(dataset,tag) + local dataset = datasets[dataset] + if dataset then + local missing = dataset.missing + local message = missing[tag] + if message == nil then + local luadata = dataset.luadata + local entry = luadata[tag] + if not entry then + local t = lower(tag) + if luadata[t] then + message = t + else + t = upper(tag) + if luadata[t] then + message = t + else + for k, v in next, luadata do + if t == upper(k) then + message = k + break + end + end + end + end + end + if not message then + message = false + end + missing[tag] = message + end + if message then + context("%s vs %s",tag,message) + return + end + end + context(tag) + end + } + end local function unknowncite(reference) @@ -1316,12 +1359,6 @@ do local typesetters = { } publications.typesetters = typesetters - local lowered = setmetatableindex(function(t,k) - k = lower(k) - t[k] = k - return k - end) - local function defaulttypesetter(field,value,manipulator) if value and value ~= "" then value = tostring(value) @@ -1428,8 +1465,6 @@ do local function get(dataset,tag,field,what,check,catspec) -- somewhat more extensive local current = rawget(datasets,dataset) if current then - tag = lowered[tag] - field = lowered[field] local data = current.luadata[tag] if data then local category = data.category @@ -1479,8 +1514,6 @@ do local function btxflush(name,tag,field) local dataset = rawget(datasets,name) if dataset then - tag = lowered[tag] - field = lowered[field] local fields = dataset.luadata[tag] if fields then local manipulator, field = splitmanipulation(field) @@ -1507,8 +1540,6 @@ do local function btxfield(name,tag,field) local dataset = rawget(datasets,name) if dataset then - tag = lowered[tag] - field = lowered[field] local fields = dataset.luadata[tag] if fields then local category = fields.category @@ -1534,8 +1565,6 @@ do local function btxdetail(name,tag,field) local dataset = rawget(datasets,name) if dataset then - tag = lowered[tag] - field = lowered[field] local fields = dataset.luadata[tag] if fields then local details = dataset.details[tag] @@ -1566,11 +1595,8 @@ do local function btxdirect(name,tag,field) local dataset = rawget(datasets,name) if dataset then - tag = lowered[tag] - field = lowered[field] local fields = dataset.luadata[tag] if fields then - field = lowered[field] local manipulator, field = splitmanipulation(field) local value = fields[field] if value then @@ -1589,8 +1615,6 @@ do local function okay(name,tag,field) local dataset = rawget(datasets,name) if dataset then - tag = lowered[tag] - field = lowered[field] local fields = dataset.luadata[tag] if fields then local category = fields.category @@ -2675,6 +2699,8 @@ do -- a bit redundant access to datasets + local creported = setmetatableindex("table") + local function processcite(presets,specification) -- if specification then @@ -2701,9 +2727,15 @@ do -- if not found or #found == 0 then -- if not list or #list == 0 then - report("no entry %a found in dataset %a",reference,dataset) + if not creported[dataset][reference] then + report("no entry %a found in dataset %a",reference,dataset) + creported[dataset][reference] = true + end elseif not setup then - report("invalid reference for %a",reference) + if not creported[""][reference] then + report("invalid reference for %a",reference) + creported[""][reference] = true + end else if trace_cite then report("processing reference %a",reference) diff --git a/tex/context/base/mkiv/publ-sor.lua b/tex/context/base/mkiv/publ-sor.lua index 30a0d9bdd..ed944ed9d 100644 --- a/tex/context/base/mkiv/publ-sor.lua +++ b/tex/context/base/mkiv/publ-sor.lua @@ -370,9 +370,17 @@ table.setmetatableindex(sorters,function(t,k) return anything end) publications.lists.sorters = sorters --- publications.sortmethods.key = { --- sequence = { --- { field = "key", default = "", unknown = "" }, --- { field = "index", default = "", unknown = "" }, --- }, --- } +publications.sortmethods.key = { + sequence = { + { field = "key", default = "", unknown = "" }, + { field = "index", default = 0, unknown = 0 }, + }, +} + +publications.sortmethods.index = { + sequence = { + { field = "index", default = 0, unknown = 0 }, + }, +} + +publications.sortmethods.dataset = publications.sortmethods.index diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex e45d119cd..42bb6d94a 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 0015ece2b..983543d0f 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-lst.lua b/tex/context/base/mkiv/strc-lst.lua index 96ad7c8ed..2e8eb15d9 100644 --- a/tex/context/base/mkiv/strc-lst.lua +++ b/tex/context/base/mkiv/strc-lst.lua @@ -37,6 +37,8 @@ local conditionals = tex.conditionals local ctx_latelua = context.latelua +local cheat = true + local structures = structures local lists = structures.lists local sections = structures.sections @@ -193,8 +195,13 @@ local function finalizer() if r then local i = r.internal local f = flaginternals[i] + local v = usedviews[i] + if cheat and v then + -- this permits runs=2 with interactivity + r.view = v + end if f then - r.used = usedviews[i] or true + r.used = v or true end end end @@ -232,7 +239,7 @@ function lists.addto(t) -- maybe more more here (saves parsing at the tex end) if numberdata then local numbers = numberdata.numbers if type(numbers) == "string" then - numberdata.numbers = counters.compact(numbers,nil,true) + counters.compact(numberdata,numbers,numberdata.level) end end local group = numberdata and numberdata.group @@ -869,13 +876,23 @@ function lists.process(specification) local total = #result lists.result = result if total > 0 then + local usedinternals = references.usedinternals + local usedviews = references.usedviews local specials = settings_to_set(specification.extras or "") specials = next(specials) and specials or nil for i=1,total do - local r = result[i] - local m = r.metadata - local s = specials and r.numberdata and specials[zerostrippedconcat(r.numberdata.numbers,".")] or "" - context.strclistsentryprocess(m.name,m.kind,i,s) + local listentry = result[i] + local metadata = listentry.metadata + local numberdata = listentry.numberdata + local references = listentry.references + local special = specials and numberdata and specials[zerostrippedconcat(numberdata.numbers,".")] or "" + if cheat and references then + -- this permits runs=2 with interactivity + local internal = references.internal + usedinternals[internal] = true + usedviews [internal] = references.view + end + context.strclistsentryprocess(metadata.name,metadata.kind,i,special) end end end @@ -1098,6 +1115,7 @@ implement { } }, { "numberdata", { + { "level", "integer" }, { "numbers" }, { "groupsuffix" }, { "group" }, diff --git a/tex/context/base/mkiv/strc-num.lua b/tex/context/base/mkiv/strc-num.lua index 5d00fcca9..3339819a2 100644 --- a/tex/context/base/mkiv/strc-num.lua +++ b/tex/context/base/mkiv/strc-num.lua @@ -270,18 +270,36 @@ function counters.raw(name) return counterdata[name] end -function counters.compact(name,level,onlynumbers) +function counters.compact(target,name,level) local cd = counterdata[name] if cd then - local data = cd.data - local compact = { } - for i=1,level or #data do + local data = cd.data + local numbers = { } + local ownnumbers = { } + local depth = #data + if not level or level == 0 then + level = depth + elseif level > depth then + level = depth + end + + for i=1,level do local d = data[i] - if d.number ~= 0 then - compact[i] = (onlynumbers and d.number) or d + if d then + local n = d.number + local o = d.own + if n ~= 0 then + numbers[i] = n + end + if o ~= "" then + ownnumbers[i] = o + end end end - return compact + target.numbers = numbers + if next(ownnumbers) then + target.ownnumbers = ownnumbers + end end end diff --git a/tex/context/base/mkiv/strc-ref.lua b/tex/context/base/mkiv/strc-ref.lua index 2dee95b40..87fea6b68 100644 --- a/tex/context/base/mkiv/strc-ref.lua +++ b/tex/context/base/mkiv/strc-ref.lua @@ -2096,7 +2096,7 @@ function references.setandgetattribute(data) -- maybe do internal automatically if ndat then local numbers = ndat.numbers if type(numbers) == "string" then - ndat.numbers = counters.compact(numbers,nil,true) + counters.compact(ndat,numbers) end data.numberdata = helpers.simplify(ndat) end diff --git a/tex/context/base/mkiv/type-set.mkiv b/tex/context/base/mkiv/type-set.mkiv index 25186b290..3447c4e6e 100644 --- a/tex/context/base/mkiv/type-set.mkiv +++ b/tex/context/base/mkiv/type-set.mkiv @@ -142,4 +142,7 @@ \definefilesynonym [type-imp-kpfonts-bold.mkiv] [type-imp-kpfonts.mkiv] \definefilesynonym [type-imp-kpfonts-sans.mkiv] [type-imp-kpfonts.mkiv] +\definefilesynonym [type-imp-gentiumplus.mkiv] [type-imp-gentium.mkiv] +\definefilesynonym [type-imp-gentiumbook.mkiv] [type-imp-gentium.mkiv] + \protect \endinput diff --git a/tex/context/base/mkiv/typo-fkr.lua b/tex/context/base/mkiv/typo-fkr.lua index 628818b6a..faaa09891 100644 --- a/tex/context/base/mkiv/typo-fkr.lua +++ b/tex/context/base/mkiv/typo-fkr.lua @@ -56,7 +56,7 @@ function typesetters.fontkerns.handler(head) kern = (kern1 + kern2)/2 -- mixed end if kern ~= 0 then - head, current = insertbefore(head,current,new_kern(kern)) + head = insertbefore(head,current,new_kern(kern)) end lastdata = data else @@ -68,7 +68,7 @@ function typesetters.fontkerns.handler(head) end local kern = getkernpair(lastdata,lastchar,char) if kern ~= 0 then - head, current = insertbefore(head,current,new_kern(kern)) + head = insertbefore(head,current,new_kern(kern)) end end lastchar = char diff --git a/tex/context/base/mkiv/util-deb.lua b/tex/context/base/mkiv/util-deb.lua index bd94b6d01..10e5731b0 100644 --- a/tex/context/base/mkiv/util-deb.lua +++ b/tex/context/base/mkiv/util-deb.lua @@ -346,3 +346,25 @@ debugger.showtraceback = showtraceback -- debug.showtraceback = showtraceback -- showtraceback() + +-- For now also here because we want it in mtxrun (taken from lmt file): + +if luac then + + local show, dump = luac.print, string.dump + + function luac.inspect(v) + if type(v) == "function" then + local ok, str = xpcall(dump,function() end,v) + if ok then + v = str + end + end + if type(v) == "string" then + show(v,true) + else + print(v) + end + end + +end diff --git a/tex/context/base/mkiv/util-jsn.lua b/tex/context/base/mkiv/util-jsn.lua index c1048b00a..6d12c520a 100644 --- a/tex/context/base/mkiv/util-jsn.lua +++ b/tex/context/base/mkiv/util-jsn.lua @@ -269,6 +269,8 @@ do k = lpegmatch(escaper,k) or k v = lpegmatch(escaper,v) or v n = n + 1 t[n] = f_key_val_str(depth,k,v) + elseif i > 1 then + n = n - 1 end elseif tv == "table" then local l = #v @@ -284,6 +286,9 @@ do end elseif next(v) then tojsonpp(v,k,depth,level+1,0) + elseif i > 1 then + n = n - 1 + -- we don't know if we have a hash or string end elseif tv == "boolean" then if tk == "number" then @@ -301,6 +306,8 @@ do else t[n] = f_key_val_nop(depth,k) end + elseif i > 1 then + n = n - 1 end else if tk == "number" then @@ -310,6 +317,8 @@ do k = lpegmatch(escaper,k) or k n = n + 1 t[n] = f_key_val_null(depth,k) + elseif i > 1 then + n = n - 1 end end end diff --git a/tex/context/base/mkxl/back-res.lmt b/tex/context/base/mkxl/back-res.lmt index 8e5bf3095..031e56909 100644 --- a/tex/context/base/mkxl/back-res.lmt +++ b/tex/context/base/mkxl/back-res.lmt @@ -112,13 +112,13 @@ implement { do - local nuts = nodes.nuts - local tonut = nodes.tonut + local nuts = nodes.nuts + local tonut = nodes.tonut - local setwhd = nuts.setwhd - local setlist = nuts.setlist + local setwhd = nuts.setwhd + local setlist = nuts.setlist - local new_hlist = nuts.pool.hlist + local new_hlist = nuts.pool.hlist function codeinjections.restoreboxresource(index) local hbox = new_hlist() @@ -128,8 +128,12 @@ do return hbox -- so we return a nut ! end - function codeinjections.registerboxresource(n,offset) -- usecollected (arg 3) is a bit of a hack - local r = savebox(n,nil,true,true,0,offset or 0) -- direct, todo: accept functions as attr/resources + function codeinjections.registerboxresource(n,offset,delay,objnum) + local immediate = true + if delay == true or delay == 1 then + immediate = false + end + local r = savebox(n,nil,true,immediate,0,offset or 0,objnum) return r end diff --git a/tex/context/base/mkxl/colo-ini.mkxl b/tex/context/base/mkxl/colo-ini.mkxl index e9504e0eb..f7909e2a3 100644 --- a/tex/context/base/mkxl/colo-ini.mkxl +++ b/tex/context/base/mkxl/colo-ini.mkxl @@ -1378,6 +1378,7 @@ \definecolor[trace:9][g=.4,b=.8] \definecolor[trace:w][s=1] +\definecolor[trace:z][s=0,t=.5,a=1] \definecolor[trace:r][r=.75,t=.5,a=1] \definecolor[trace:g][g=.75,t=.5,a=1] \definecolor[trace:b][b=.75,t=.5,a=1] @@ -1392,6 +1393,7 @@ \definecolor[trace:o][r=1,g=.6,b=.1,t=.5,a=1] \definecolor[trace:dw][s=1] +\definecolor[trace:dz][s=0,t=.75,a=1] \definecolor[trace:dr][r=.75,t=.75,a=1] \definecolor[trace:dg][g=.75,t=.75,a=1] \definecolor[trace:db][b=.75,t=.75,a=1] diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 6e20f62a4..4af336828 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2022.05.11 11:34} +\newcontextversion{2022.07.06 21:34} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/cont-run.mkxl b/tex/context/base/mkxl/cont-run.mkxl index f3a946b28..edc038e45 100644 --- a/tex/context/base/mkxl/cont-run.mkxl +++ b/tex/context/base/mkxl/cont-run.mkxl @@ -56,4 +56,12 @@ \permanent\protected\lettonothing\continuewhenlmtxmode +\permanent\protected\def\continuewhenmkivmode + {\starttext + \startTEXpage[\c!offset=2ex,\c!foregroundstyle=\tttf]% + This file needs \LuaTeX\ and \ConTeXt\ \MKIV.% + \stopTEXpage + \stoptext + \endinput} + \protect \endinput diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 71c602887..db7781ea3 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2022.05.11 11:34} +\immutable\edef\contextversion{2022.07.06 21:34} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -133,6 +133,7 @@ \loadmkxlfile{mult-ini} \loadmkxlfile{mult-sys} \loadmkxlfile{mult-aux} +%doiffileelse{mult-aux-new.mkxl}{\loadmkxlfile{mult-aux-new}}{\loadmkxlfile{mult-aux}} \loadmkxlfile{mult-def} %loadmarkfile{mult-chk} \loadmklxfile{mult-dim} @@ -400,6 +401,7 @@ \loadmkxlfile{tabl-tab} % thrd-tab stripped and merged \loadmkxlfile{tabl-tbl} +%loadmkxlfile{tabl-ntb} \doiffileelse{tabl-ntb-new.mkxl}{\loadmkxlfile{tabl-ntb-new}}{\loadmkxlfile{tabl-ntb}} \loadmkxlfile{tabl-nte} \loadmkxlfile{tabl-ltb} @@ -486,6 +488,7 @@ \loadmkxlfile{math-mis} \loadmkxlfile{math-scr} \loadmkxlfile{math-int} +\loadmkxlfile{math-dif} \loadmkxlfile{math-del} \loadmkxlfile{math-fen} \loadmkxlfile{math-lop} @@ -515,6 +518,8 @@ \loadmkxlfile{strc-usr} \loadmkxlfile{pack-com} +\loadmkxlfile{math-com} + \loadmkxlfile{typo-del} \loadmkxlfile{grph-trf} @@ -531,6 +536,7 @@ \loadmkxlfile{meta-fig} \loadmkxlfile{page-ffl} +\loadmkxlfile{page-blk} \loadmkxlfile{lang-spa} % will become obsolete diff --git a/tex/context/base/mkxl/core-dat.mkxl b/tex/context/base/mkxl/core-dat.mkxl index 93d0bbb7a..540f5b747 100644 --- a/tex/context/base/mkxl/core-dat.mkxl +++ b/tex/context/base/mkxl/core-dat.mkxl @@ -30,6 +30,16 @@ %D \stoplines %D \stoptyping +%D \starttyping +%D \definedataset[nofpages] +%D +%D \dorecurse{16}{whatever\page} +%D +%D \setdataset [nofpages] [pagetotal=\lastpagenumber] +%D +%D \testfeatureonce{100}{test \datasetvariable[todo-datasets]{nofpages}{1}{pagetotal} } +%D \stoptyping + \unprotect \registerctxluafile{core-dat}{} @@ -58,8 +68,15 @@ \fi \endgroup} -\permanent\def\datasetvariable#1#2#3% - {\clf_datasetvariable{#1}{#2}{#3}} +% \permanent\def\datasetvariable#1#2#3% +% {\clf_datasetvariable{#1}{#2}{#3}} + +\permanent\tolerant\def\datasetvariable[#1]% + {\ifparameter#1\or + \expandafter\clf_datasetvariablefromjob{#1\expandafter}% + \else + \expandafter\clf_datasetvariable + \fi} \installcorenamespace{pagestate} \installcorenamespace{pagestatecounter} diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt index 6c4ca79cc..9a72d834d 100644 --- a/tex/context/base/mkxl/driv-shp.lmt +++ b/tex/context/base/mkxl/driv-shp.lmt @@ -229,13 +229,13 @@ local flush_character do end if csx then csx = csx * sx -else - csx = sx + else + csx = sx end if csy then csy = csy * sy -else - csy = sy + else + csy = sy end -- here no current! return flush_character(false,fnt,chr,factor,nest,pos_h,pos_v,pos_r,csx,csy) @@ -834,7 +834,8 @@ local hlist_out, vlist_out do -- cur_h = cur_h + wd - right -- hm, no left here? cur_h = cur_h + wd -- see new tabulate alignment code elseif id == glue_code then - local gluewidth = effectiveglue(current,this_box) +-- local gluewidth = effectiveglue(current,this_box) +local gluewidth = effectiveglue(current,this_box,true) if gluewidth ~= 0 then if subtype >= leaders_code then local leader = getleader(current) @@ -1170,7 +1171,8 @@ local hlist_out, vlist_out do -- if kern ~= 0 then -- cur_h = cur_h + kern -- else - cur_h = cur_h + effectiveglue(current,this_box) +-- cur_h = cur_h + effectiveglue(current,this_box) +cur_h = cur_h + effectiveglue(current,this_box,true) -- end elseif id == dir_code then -- We normally have proper begin-end pairs. A begin without end is (silently) handled @@ -1285,7 +1287,8 @@ local hlist_out, vlist_out do -- local id = getid(current) for current, id, subtype in nextnode, current do if id == glue_code then - local glueheight = effectiveglue(current,this_box) +-- local glueheight = effectiveglue(current,this_box) +local glueheight = effectiveglue(current,this_box,true) if glueheight ~= 0 then if subtype >= leaders_code then local leader = getleader(current) diff --git a/tex/context/base/mkxl/driv-usr.lmt b/tex/context/base/mkxl/driv-usr.lmt index 5ff601f2a..04e7da5e6 100644 --- a/tex/context/base/mkxl/driv-usr.lmt +++ b/tex/context/base/mkxl/driv-usr.lmt @@ -116,7 +116,8 @@ hlist_out = function(this_box,current) end end elseif id == glue_code then - cur_h = cur_h + effectiveglue(current,this_box) +-- cur_h = cur_h + effectiveglue(current,this_box) +cur_h = cur_h + effectiveglue(current,this_box,true) elseif id == hlist_code or id == vlist_code then local width, height, depth = getwhd(current) local list = getlist(current) @@ -264,7 +265,8 @@ hlist_out = function(this_box,current) elseif id == rule_code then cur_h = cur_h + getwidth(current) elseif id == math_code then - cur_h = cur_h + effectiveglue(current,this_box) +-- cur_h = cur_h + effectiveglue(current,this_box) +cur_h = cur_h + effectiveglue(current,this_box,true) elseif id == dir_code then local dir, cancel = getdirection(current) if cancel then @@ -348,7 +350,8 @@ vlist_out = function(this_box,current) for current, id, subtype in nextnode, current do if id == glue_code then - cur_v = cur_v + effectiveglue(current,this_box) +-- cur_v = cur_v + effectiveglue(current,this_box) +cur_v = cur_v + effectiveglue(current,this_box,true) elseif id == hlist_code or id == vlist_code then local width, height, depth = getwhd(current) local list = getlist(current) diff --git a/tex/context/base/mkxl/enco-ini.mkxl b/tex/context/base/mkxl/enco-ini.mkxl index c93ef7f61..5370035ed 100644 --- a/tex/context/base/mkxl/enco-ini.mkxl +++ b/tex/context/base/mkxl/enco-ini.mkxl @@ -208,10 +208,11 @@ \setbox0\hbox{#4}% \halign {##\crcr\hbox{#5}\crcr - \hidewidth + \hskip\hideskip % \hidewidth \hskip#2\wd0 \hskip-#3\slantperpoint % in plain 1ex * dimenless value - \vpack to .2\exheight{\box0\vss}\hidewidth + \vpack to .2\exheight{\box0\vss}% + \hskip\hideskip % \hidewidth \crcr}}} \permanent\protected\def\buildtextmacron {\bottomaccent{.25ex}{0}{15}{\textmacron}} diff --git a/tex/context/base/mkxl/font-con.lmt b/tex/context/base/mkxl/font-con.lmt index 83b97847d..5da757230 100644 --- a/tex/context/base/mkxl/font-con.lmt +++ b/tex/context/base/mkxl/font-con.lmt @@ -704,9 +704,9 @@ function constructors.scale(tfmdata,specification) end local va = character.accent if va then - chr.topaccent = vdelta*va + chr.topaccent = va*vdelta end - if stackmath then + if stackmath then -- not ok yet local mk = character.mathkerns if mk then local tr = mk.topright @@ -755,6 +755,10 @@ function constructors.scale(tfmdata,specification) if fa then chr.flataccent = fa end + local m = character.leftmargin if m and m ~= 0 then chr.leftmargin = m*hdelta end + local m = character.rightmargin if m and m ~= 0 then chr.rightmargin = m*hdelta end + local m = character.topmargin if m and m ~= 0 then chr.topmargin = m*hdelta end + local m = character.bottommargin if m and m ~= 0 then chr.bottommargin = m*hdelta end elseif autoitalicamount then -- itlc feature local vi = description.italic if not vi then diff --git a/tex/context/base/mkxl/font-imp-effects.lmt b/tex/context/base/mkxl/font-imp-effects.lmt index 1f9810f93..38d86498a 100644 --- a/tex/context/base/mkxl/font-imp-effects.lmt +++ b/tex/context/base/mkxl/font-imp-effects.lmt @@ -238,9 +238,11 @@ local function manipulateeffect(tfmdata) parameters.hshift = hshift parameters.vshift = vshift for unicode, character in next, characters do - local oldwidth = character.width - local oldheight = character.height - local olddepth = character.depth + local oldwidth = character.width + local oldheight = character.height + local olddepth = character.depth + local olditalic = character.italic + local oldtopaccent = character.topaccent if oldwidth and oldwidth > 0 then character.width = oldwidth + wdelta end @@ -250,6 +252,15 @@ local function manipulateeffect(tfmdata) if olddepth and olddepth > 0 then character.depth = olddepth + ddelta end + if olditalic or oldtopaccent then + local factor = character.width / oldwidth + if olditalic and olditalic > 0 then + character.italic = olditalic * factor + end + if oldtopaccent and oldtopaccent > 0 then + character.topaccent = oldtopaccent * factor + end + end end if mathparameters then setmathparameters(tfmdata,characters,mathparameters,dx,dy,squeeze,multiplier) diff --git a/tex/context/base/mkxl/font-imp-tracing.lmt b/tex/context/base/mkxl/font-imp-tracing.lmt index 3de48af6f..00e3aaa50 100644 --- a/tex/context/base/mkxl/font-imp-tracing.lmt +++ b/tex/context/base/mkxl/font-imp-tracing.lmt @@ -112,8 +112,8 @@ local function initialize(tfmdata,key,value) if value then local vfspecials = fonts.helpers.vfspecials local vfcommands = fonts.helpers.commands - local backgrounds = vfspecials.backgrounds - local outlines = vfspecials.outlines + -- local backgrounds = vfspecials.backgrounds + -- local outlines = vfspecials.outlines local characters = tfmdata.characters local rule = { "frame", true, true, true, false, false, false, false, "palegray" } local showchar = true @@ -178,7 +178,7 @@ local function initialize(tfmdata,key,value) local vfspecials = fonts.helpers.vfspecials local vfcommands = fonts.helpers.commands local backgrounds = vfspecials.backgrounds - local outlines = vfspecials.outlines + -- local outlines = vfspecials.outlines local characters = tfmdata.characters local rulecache = backgrounds local push = vfcommands.push @@ -192,6 +192,13 @@ local function initialize(tfmdata,key,value) for unicode, character in next, characters do local mathkerns = character.mathkerns local italic = character.vitalic or character.italic + +if italic ~= italic then + -- 8427 in pagella suddenly gets a "nan" assigned ... can this be a lua bug + -- test file : staircase-001.tex + italic = 0 +end + if mathkerns or (italic and italic ~= 0) then local width = character.width or 0 local height = character.height or 0 @@ -202,7 +209,7 @@ local function initialize(tfmdata,key,value) count = count + 1 list[count] = itcolor count = count + 1 list[count] = push count = count + 1 list[count] = { "offset", width + (italic < 0 and -italic or 0), 0 } - count = count + 1 list[count] = rulecache[height][depth][abs(-italic)] + count = count + 1 list[count] = rulecache[height][depth][italic < 0 and -italic or italic] count = count + 1 list[count] = pop count = count + 1 list[count] = black end @@ -227,7 +234,7 @@ local function initialize(tfmdata,key,value) end count = count + 1 list[count] = push count = count + 1 list[count] = { "offset", width + (k < 0 and k or 0), - depth } - count = count + 1 list[count] = rulecache[h][0][abs(k)] + count = count + 1 list[count] = rulecache[h][0][k < 0 and -k or k] count = count + 1 list[count] = pop end end @@ -251,7 +258,7 @@ local function initialize(tfmdata,key,value) end count = count + 1 list[count] = push count = count + 1 list[count] = { "offset", width + (k < 0 and k or 0), height - h } - count = count + 1 list[count] = rulecache[h][0][abs(k)] + count = count + 1 list[count] = rulecache[h][0][k < 0 and k or k] count = count + 1 list[count] = pop end end diff --git a/tex/context/base/mkxl/font-ini.lmt b/tex/context/base/mkxl/font-ini.lmt index 45e8f9e18..bc68fa83d 100644 --- a/tex/context/base/mkxl/font-ini.lmt +++ b/tex/context/base/mkxl/font-ini.lmt @@ -10,8 +10,8 @@ if not modules then modules = { } end modules ['font-ini'] = { <p>Not much is happening here.</p> --ldx]]-- -local allocate = utilities.storage.allocate -local sortedhash = table.sortedhash +local sortedhash, setmetatableindex = table.sortedhash, table.setmetatableindex +local allocate = utilities.storage.allocate fonts = fonts or { } local fonts = fonts @@ -37,4 +37,63 @@ fonts.privateoffsets = { keepnames = false, -- when set to true names are always kept (not for context) } +local effects = setmetatableindex( + function(t,slant) + local v = setmetatableindex( + function(t,squeeze) + local v = setmetatableindex( + function(t,extend) + local v = setmetatableindex( + function(t,mode) + local v = setmetatableindex( + function(t,line) + local v = { + slant = slant, + squeeze = squeeze, + extend = extend, + mode = mode, + line = line * 1000, + } + t[line] = v + return v + end) + t[mode] = v + return v + end) + t[extend] = v + return v + end) + t[squeeze] = v + return v + end) + t[slant] = v + return v + end) + +-- This is an experiment, part of math engine project (MS and HH) where we wondered +-- how to deal with bad or missing alphabets. One solution is a character specific +-- effect which is supported by the engine (in fact the backend). By using a table +-- cache we limit checking. We use tweaks in font goodies to achieve it. +-- +-- character.effect = fonts.effects[slant][squeeze][extend][mode][line] +-- character.effect = fonts.toeffect { slant = .2 } + +fonts.effects = effects + +fonts.effects[0][1][1][0][0] = false + +function fonts.toeffect(t) + local slant = t.slant or 0 + local squeeze = t.squeeze or 1 + local extend = t.extend or 1 + local mode = t.mode or 0 + local line = t.line or 0 + if slant or squeeze or extend or mode or line then + local effect = effects[slant][squeeze][extend][mode][line] + if effect then + return effect + end + end +end + -- Also here now: diff --git a/tex/context/base/mkxl/good-mth.lmt b/tex/context/base/mkxl/good-mth.lmt index 0c8311efe..6b0c320b2 100644 --- a/tex/context/base/mkxl/good-mth.lmt +++ b/tex/context/base/mkxl/good-mth.lmt @@ -21,7 +21,8 @@ local fontgoodies = fonts.goodies or { } local fontcharacters = fonts.hashes.characters -local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) +local trace_defining = false trackers.register ("math.defining", function(v) trace_defining = v end) +local use_math_goodies = true directives.register("math.nogoodies", function(v) use_math_goodies = not v end) local report_math = logs.reporter("mathematics","initializing") @@ -185,284 +186,3 @@ registerotffeature { node = initialize, } } - --- local helpers = fonts.helpers --- local upcommand = helpers.commands.up --- local rightcommand = helpers.commands.right --- local charcommand = helpers.commands.char --- local prependcommands = helpers.prependcommands --- --- -- experiment, we have to load the definitions immediately as they precede --- -- the definition so they need to be initialized in the typescript --- --- local function withscriptcode(tfmdata,unicode,data,action) --- if type(unicode) == "string" then --- local p, u = match(unicode,"^(.-):(.-)$") --- if u then --- u = tonumber(u) --- if u then --- local slots = helpers.mathscriptslots(tfmdata,u) --- if slots then --- if p == "*" then --- action(u,data) --- if type(slots) == "number" then --- action(slots,data) --- else --- for i=1,#slots do --- action(slots[i],data) --- end --- end --- else --- p = tonumber(p) --- if p then --- if type(slots) == "number" then --- action(slots,data) --- else --- action(slots[p],data) --- end --- end --- end --- end --- end --- end --- else --- action(unicode,data) --- end --- end --- --- local function finalize(tfmdata,feature,value,...) --- -- if tfmdata.mathparameters then -- funny, cambria text has this --- local goodies = tfmdata.goodies --- if goodies then --- local virtualized = mathematics.virtualized --- for i=1,#goodies do --- local goodie = goodies[i] --- local mathematics = goodie.mathematics --- local dimensions = mathematics and mathematics.dimensions --- if dimensions then --- if trace_defining then --- report_math("overloading dimensions in %a @ %p",tfmdata.properties.fullname,tfmdata.parameters.size) --- end --- local characters = tfmdata.characters --- local descriptions = tfmdata.descriptions --- local parameters = tfmdata.parameters --- local factor = parameters.factor --- local hfactor = parameters.hfactor --- local vfactor = parameters.vfactor --- -- --- tfmdata.type = "virtual" --- tfmdata.properties.virtualized = true --- -- --- local function overloadone(unicode,data) --- local character = characters[unicode] --- if not character then --- local c = virtualized[unicode] --- if c then --- character = characters[c] --- end --- end --- if character then --- local width = data.width --- local height = data.height --- local depth = data.depth --- if trace_defining and (width or height or depth) then --- report_math("overloading dimensions of %C, width %p, height %p, depth %p", --- unicode,width or 0,height or 0,depth or 0) --- end --- if width then character.width = width * hfactor end --- if height then character.height = height * vfactor end --- if depth then character.depth = depth * vfactor end --- -- --- local xoffset = data.xoffset --- local yoffset = data.yoffset --- if xoffset == "llx" then --- local d = descriptions[unicode] --- if d then --- xoffset = - d.boundingbox[1] --- character.width = character.width + xoffset * hfactor --- xoffset = rightcommand[xoffset] --- else --- xoffset = nil --- end --- elseif xoffset and xoffset ~= 0 then --- xoffset = rightcommand[xoffset * hfactor] --- else --- xoffset = nil --- end --- if yoffset and yoffset ~= 0 then --- yoffset = upcommand[yoffset * vfactor] --- else --- yoffset = nil --- end --- if xoffset or yoffset then --- local commands = character.commands --- if commands then --- prependcommands(commands,yoffset,xoffset) --- else --- -- character.commands = { { "offset", xoffset or 0, yoffset or 0, unicode } } --- local slot = charcommand[unicode] --- if xoffset and yoffset then --- character.commands = { xoffset, yoffset, slot } --- elseif xoffset then --- character.commands = { xoffset, slot } --- else --- character.commands = { yoffset, slot } --- end --- end --- end --- elseif trace_defining then --- report_math("no overloading dimensions of %C, not in font",unicode) --- end --- end --- local function overload(dimensions) --- for unicode, data in next, dimensions do --- withscriptcode(tfmdata,unicode,data,overloadone) --- end --- end --- if value == nil then --- value = { "default" } --- end --- if value == "all" or value == true then --- for name, value in next, dimensions do --- overload(value) --- end --- else --- if type(value) == "string" then --- value = utilities.parsers.settings_to_array(value) --- end --- if type(value) == "table" then --- for i=1,#value do --- local d = dimensions[value[i]] --- if d then --- overload(d) --- end --- end --- end --- end --- end --- end --- end --- end --- --- registerotffeature { --- name = "mathdimensions", --- description = "manipulate math dimensions", --- -- default = true, --- manipulators = { --- base = finalize, --- node = finalize, --- } --- } - --- local enabled = false directives.register("fontgoodies.mathkerning",function(v) enabled = v end) --- --- local function initialize(tfmdata) --- if tfmdata.mathparameters then -- funny, cambria text has this --- local goodies = tfmdata.goodies --- if goodies then --- local characters = tfmdata.characters --- if characters[0x1D44E] then -- 119886 --- -- we have at least an italic a --- for i=1,#goodies do --- local mathgoodies = goodies[i].mathematics --- if mathgoodies then --- local kerns = mathgoodies.kerns --- if kerns then --- local function kernone(unicode,data) --- local chardata = characters[unicode] --- if chardata and (not chardata.mathkerns or data.force) then --- chardata.mathkerns = data --- end --- end --- for unicode, data in next, kerns do --- withscriptcode(tfmdata,unicode,data,kernone) --- end --- return --- end --- end --- end --- else --- return -- no proper math font anyway --- end --- end --- end --- end --- --- registerotffeature { --- name = "mathkerns", --- description = "math kerns", --- -- default = true, --- initializers = { --- base = initialize, --- node = initialize, --- } --- } - --- -- math italics (not really needed) --- --- local function initialize(tfmdata) --- local goodies = tfmdata.goodies --- if goodies then --- local shared = tfmdata.shared --- for i=1,#goodies do --- local mathgoodies = goodies[i].mathematics --- if mathgoodies then --- local mathitalics = mathgoodies.italics --- if mathitalics then --- local properties = tfmdata.properties --- if properties.setitalics then --- mathitalics = mathitalics[file.nameonly(properties.name)] or mathitalics --- if mathitalics then --- if trace_goodies then --- report_goodies("loading mathitalics for font %a",properties.name) --- end --- local corrections = mathitalics.corrections --- local defaultfactor = mathitalics.defaultfactor --- -- properties.mathitalic_defaultfactor = defaultfactor -- we inherit outer one anyway (name will change) --- if corrections then --- fontgoodies.registerpostprocessor(tfmdata, function(tfmdata) -- this is another tfmdata (a copy) --- -- better make a helper so that we have less code being defined --- local properties = tfmdata.properties --- local parameters = tfmdata.parameters --- local characters = tfmdata.characters --- properties.mathitalic_defaultfactor = defaultfactor --- properties.mathitalic_defaultvalue = defaultfactor * parameters.quad --- if trace_goodies then --- report_goodies("assigning mathitalics for font %a",properties.name) --- end --- local quad = parameters.quad --- local hfactor = parameters.hfactor --- for k, v in next, corrections do --- local c = characters[k] --- if c then --- if v > -1 and v < 1 then --- c.italic = v * quad --- else --- c.italic = v * hfactor --- end --- else --- report_goodies("invalid mathitalics entry %U for font %a",k,properties.name) --- end --- end --- end) --- end --- return -- maybe not as these can accumulate --- end --- end --- end --- end --- end --- end --- end --- --- registerotffeature { --- name = "mathitalics", --- description = "additional math italic corrections", --- -- default = true, --- initializers = { --- base = initialize, --- node = initialize, --- } --- } --- --- -- fontgoodies.register("mathitalics", initialize) diff --git a/tex/context/base/mkxl/grph-inc.mkxl b/tex/context/base/mkxl/grph-inc.mkxl index a4b42e009..ffc9fdf5a 100644 --- a/tex/context/base/mkxl/grph-inc.mkxl +++ b/tex/context/base/mkxl/grph-inc.mkxl @@ -860,16 +860,16 @@ % Experimental (will become cleaner): \permanent\tolerant\protected\def\includesvgfile[#1]#*[#2]% - {\dontleavehmode\begingroup + {\hbox\bgroup % no \dontleavehmode \getdummyparameters[\c!offset=\zeropoint,#2]% \clf_includesvgfile{#1}\dimexpr\dummyparameter\c!offset\relax - \endgroup} + \egroup} \permanent\tolerant\protected\def\includesvgbuffer[#1]#*[#2]% - {\dontleavehmode\begingroup + {\hbox\bgroup % no \dontleavehmode \getdummyparameters[\c!offset=\zeropoint,#2]% \clf_includesvgbuffer{#1}\dimexpr\dummyparameter\c!offset\relax - \endgroup} + \egroup} % Bonus: diff --git a/tex/context/base/mkxl/lang-def.mkxl b/tex/context/base/mkxl/lang-def.mkxl index b7919a29b..2be05104f 100644 --- a/tex/context/base/mkxl/lang-def.mkxl +++ b/tex/context/base/mkxl/lang-def.mkxl @@ -269,12 +269,29 @@ \c!rightquotation=\leftguillemot, \c!date={\v!day,{.},\space,\v!month,\space,\v!year}] +\installlanguage % for now we copy from slovenian + [\s!sq] + [\c!command=\v!no, + \s!lefthyphenmin=2, + \s!righthyphenmin=2, + \c!spacing=\v!packed, + \c!leftsentence=\hbox{\endash\space}, + \c!rightsentence=\hbox{\space\endash}, + \c!leftsubsentence=\endash, + \c!rightsubsentence=\endash, + \c!leftquote=\guilsingleright, + \c!rightquote=\guilsingleleft, + \c!leftquotation=\rightguillemot, + \c!rightquotation=\leftguillemot, + \c!date={\v!day,{.},\space,\v!month,\space,\v!year}] + \installlanguage [\s!polish] [\s!pl] \installlanguage [\s!czech] [\s!cs] \installlanguage [\s!slovak] [\s!sk] \installlanguage [\s!croatian] [\s!hr] \installlanguage [\s!slovenian] [\s!sl] \installlanguage [slovene] [\s!sl] % both possible (mojca: still needed?) +\installlanguage [\s!albanian] [\s!sq] % Cyrillic Languages @@ -640,7 +657,7 @@ % Greek \installlanguage - [\s!gr] + [\s!gr] % grc el-monotonic-greek.tex [\c!spacing=\v!packed, \c!leftsentence=\emdash, \c!rightsentence=\emdash, @@ -651,7 +668,7 @@ \c!leftquotation=«, \c!rightquotation=», \c!date={\v!day\space\v!month\space\v!year}, - \s!patterns=\s!agr] % ok? + \s!patterns=\s!gr] \installlanguage [\s!greek] [\s!gr] diff --git a/tex/context/base/mkxl/lang-lab.lmt b/tex/context/base/mkxl/lang-lab.lmt new file mode 100644 index 000000000..b82721b76 --- /dev/null +++ b/tex/context/base/mkxl/lang-lab.lmt @@ -0,0 +1,195 @@ +if not modules then modules = { } end modules ['lang-lab'] = { + version = 1.001, + comment = "companion to lang-lab.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local format, find = string.format, string.find +local next, rawget, type = next, rawget, type +local lpegmatch = lpeg.match +local formatters = string.formatters + +local prtcatcodes = catcodes.numbers.prtcatcodes -- todo: use different method + +local trace_labels = false trackers.register("languages.labels", function(v) trace_labels = v end) +local report_labels = logs.reporter("languages","labels") + +languages.labels = languages.labels or { } +local labels = languages.labels + +local context = context +local implement = interfaces.implement + +local variables = interfaces.variables +local settings_to_array = utilities.parsers.settings_to_array + +local splitter = lpeg.splitat(":") + +local function split(tag) + return lpegmatch(splitter,tag) +end + +labels.split = split + +-- We don't store labels at the \LUA\ end because we want to obey grouping. Otherwise we +-- would need to start using tables that relate to the group level. + +local contextsprint = context.sprint + +local f_setlabeltextpair = formatters["\\setlabeltextpair{%s}{%s}{%s}{%s}{%s}"] +local f_key_key = formatters["\\v!%s:\\v!%s"] +local f_key_raw = formatters["\\v!%s:%s"] +local f_raw_key = formatters["%s:\\v!%s"] +local f_raw_raw = formatters["%s:%s"] +local f_key = formatters["\\v!%s"] +local f_raw = formatters["%s"] + +local function definelanguagelabels(data,class,tag,rawtag) + for language, text in next, data.labels do + if text == "" then + -- skip + elseif type(text) == "table" then + contextsprint(prtcatcodes,f_setlabeltextpair(class,language,tag,text[1],text[2])) + if trace_labels then + report_labels("language %a, defining label %a as %a and %a",language,rawtag,text[1],text[2]) + end + else + contextsprint(prtcatcodes,f_setlabeltextpair(class,language,tag,text,"")) + if trace_labels then + report_labels("language %a, defining label %a as %a",language,rawtag,text) + end + end + end +end + +-- local function definelanguagelabels(data,class,tag,rawtag) +-- local setlabeltextopair = context.setlabeltextpair +-- context.pushcatcodes("prt") +-- for language, text in next, data.labels do +-- if text == "" then +-- -- skip +-- elseif type(text) == "table" then +-- setlabeltextopair(class,language,tag,text[1],text[2]) +-- if trace_labels then +-- report_labels("language %a, defining label %a as %a and %a",language,rawtag,text[1],text[2]) +-- end +-- else +-- setlabeltextopair(class,language,tag,text,"") +-- if trace_labels then +-- report_labels("language %a, defining label %a as %a",language,rawtag,text) +-- end +-- end +-- end +-- context.popcatcodes() +-- end + +function labels.define(class,name,prefixed) + local list = languages.data.labels[name] + if list then + report_labels("defining label set %a",name) + for tag, data in next, list do + tag = variables[tag] or tag + if data.hidden then + -- skip + elseif prefixed then + local first, second = lpegmatch(splitter,tag) + if second then + if rawget(variables,first) then + if rawget(variables,second) then + definelanguagelabels(data,class,f_key_key(first,second),tag) + else + definelanguagelabels(data,class,f_key_raw(first,second),tag) + end + elseif rawget(variables,second) then + definelanguagelabels(data,class,f_raw_key(first,second),tag) + else + definelanguagelabels(data,class,f_raw_raw(first,second),tag) + end + elseif rawget(variables,rawtag) then + definelanguagelabels(data,class,f_key(tag),tag) + else + definelanguagelabels(data,class,tag,tag) + end + else + definelanguagelabels(data,class,tag,tag) + end + end + else + report_labels("unknown label set %a",name) + end +end + +-- function labels.check() +-- for category, list in next, languages.data.labels do +-- for tag, specification in next, list do +-- for language, text in next, specification.labels do +-- if type(text) == "string" and find(text,",") then +-- report_labels("warning: label with comma found, category %a, language %a, tag %a, text %a", +-- category, language, tag, text) +-- end +-- end +-- end +-- end +-- end +-- +-- labels.check() + +-- interface + +interfaces.implement { + name = "definelabels", + actions = labels.define, + arguments = { "string", "string", "boolean" } +} + +-- function commands.setstrippedtextprefix(str) +-- context(string.strip(str)) +-- end + +-- list : { "a", "b", "c" } +-- separator : ", " +-- last : " and " + +-- text : "a,b,c" +-- separators : "{, },{ and }" + +local function concatcommalist(settings) -- it's too easy to forget that this one is there + local list = settings.list or settings_to_array(settings.text or "") + local size = #list + local command = settings.command and context[settings.command] or context + if size > 1 then + local separator, last = " ", " " + if settings.separators then + local set = settings_to_array(settings.separators) + separator = set[1] or settings.separator or separator + last = set[2] or settings.last or last + else + separator = settings.separator or separator + last = settings.last or last + end + command(list[1]) + for i=2,size-1 do + context(separator) + command(list[i]) + end + context(last) + end + if size > 0 then + command(list[size]) + end +end + +implement { + name = "concatcommalist", + actions = concatcommalist, + arguments = { + { + { "text" }, + { "separators" }, + { "separator" }, + { "last" }, + } + } +} diff --git a/tex/context/base/mkxl/lang-lab.mkxl b/tex/context/base/mkxl/lang-lab.mkxl index 3ce9d027f..2a42861cd 100644 --- a/tex/context/base/mkxl/lang-lab.mkxl +++ b/tex/context/base/mkxl/lang-lab.mkxl @@ -13,7 +13,7 @@ \writestatus{loading}{ConTeXt Language Macros / Labels} -\registerctxluafile{lang-lab}{} +\registerctxluafile{lang-lab}{autosuffix} \registerctxluafile{lang-txt}{} \unprotect @@ -84,10 +84,10 @@ \mutable\let\currenttextprefixtag \s!unknown \protected\def\lang_labels_define_class_indeed#1#2#3#4#5#6#7#8#9% - {\permanent\instance\protected\defcsname setup#1text\endcsname{\protecttextprefixes#2\def\currenttextprefixclass{#1}\lang_labels_text_prefix_setup}% - \permanent\instance\protected\defcsname preset#1text\endcsname{\protecttextprefixes 1\def\currenttextprefixclass{#1}\lang_labels_text_prefix_setup}% - \permanent\instance\protected\defcsname copy#1text\endcsname{\protecttextprefixes 1\def\currenttextprefixclass{#1}\lang_labels_text_prefix_copy }% - \permanent\instance\protected\defcsname start#1text\endcsname{\protecttextprefixes 1\def\currenttextprefixclass{#1}\lang_labels_text_prefix_start[#1]}% + {\permanent\instance\protected\defcsname setup#1text\endcsname{\protecttextprefixes #2\def\currenttextprefixclass{#1}\lang_labels_text_prefix_setup}% + \permanent\instance\protected\defcsname preset#1text\endcsname{\protecttextprefixes\plusone\def\currenttextprefixclass{#1}\lang_labels_text_prefix_setup}% + \permanent\instance\protected\defcsname copy#1text\endcsname{\protecttextprefixes\plusone\def\currenttextprefixclass{#1}\lang_labels_text_prefix_copy }% + \permanent\instance\protected\defcsname start#1text\endcsname{\protecttextprefixes\plusone\def\currenttextprefixclass{#1}\lang_labels_text_prefix_start[#1]}% \permanent\instance \letcsname stop#1text\endcsname \relax \permanent\instance\def#4{\reallanguagetag{\defaultlanguage\currentmainlanguage}}% \ifnum#2=\plustwo % used for math and tags @@ -278,7 +278,7 @@ \definelabelclass [head] [0] % titles \definelabelclass [label] [0] % texts -\definelabelclass [mathlabel] [0] % functions +\definelabelclass [mathlabel] [2] % functions \definelabelclass [taglabel] [2] % tags \clf_definelabels{head}{titles}\s!true\relax @@ -365,10 +365,10 @@ last {\detokenize\expandafter{\normalexpanded{\labeltext{and-2}}}}% \relax} -\setuplabeltext [\s!nl] [and-1={{, }}, and-2={{ en }}] % 1, 2 en 3 -\setuplabeltext [\s!en] [and-1={{, }}, and-2={{, }}] % 1, 2, 3 -\setuplabeltext [\s!de] [and-1={{, }}, and-2={{ und }}] % 1, 2 und 3 -\setuplabeltext [\s!hr] [and-1={{, }}, and-2={{ i }}] % 1, 2 i 3 +\setuplabeltext [\s!nl] [and-1={{, }},and-2={{ en }}] % 1, 2 en 3 +\setuplabeltext [\s!en] [and-1={{, }},and-2={{, }}] % 1, 2, 3 +\setuplabeltext [\s!de] [and-1={{, }},and-2={{ und }}] % 1, 2 und 3 +\setuplabeltext [\s!hr] [and-1={{, }},and-2={{ i }}] % 1, 2 i 3 %D Goodie (handy at \LUA\ end): diff --git a/tex/context/base/mkxl/libs-imp-zint.lmt b/tex/context/base/mkxl/libs-imp-zint.lmt index d8d882924..0ae3b1296 100644 --- a/tex/context/base/mkxl/libs-imp-zint.lmt +++ b/tex/context/base/mkxl/libs-imp-zint.lmt @@ -91,29 +91,13 @@ end) local report = logs.reporter("zint") local context = context local shown = false +local sqrt = math.sqrt --- Same performance as just context(fmt,...): 113pps (On 2013 i7 laptop.) - ------ f_rectangle = formatters["%nofill unitsquare xysized (%N,%N) shifted (%N,%N);"] -local f_hexagon = formatters["%nofill (%N,-%N)--(%N,-%N)--(%N,-%N)--(%N,-%N)--(%N,-%N)--(%N,-%N)--cycle;"] -local f_circle = formatters["%nofill unitcircle scaled %N shifted (%N,-%N);"] - -local s_done = "dofill origin --cycle;" +local f_rectangle = formatters["( unitsquare xyscaled (%N,-%N) shifted (%N,-%N) )"] +local f_hexagon = formatters["( fullhexagon scaled %N shifted (%N,-%N) )"] +local f_circle = formatters["( fullcircle scaled %N shifted (%N,-%N) )"] local f_string = formatters['draw textext("%s") scaled (%N/10) shifted (%N,-%N);'] --- A bit faster: 130pps (When I see hexagons I'll do that too but MP takes way more time.) - --- local s_preamble = [[ --- save ns; def ns (expr a, b) = nofill unitsquare xyscaled a shifted b ; enddef; --- save ds; def ds (expr a, b) = dofill unitsquare xyscaled a shifted b ; enddef; --- ]] - -local s_preamble = [[ - save ns; def ns (expr a, b) = nofill unitsquare xyscaled a shifted b ; enddef; -]] - -local f_rectangle = formatters["ns((%i,-%i),(%i,-%i));"] - local aliases = { isbnx = "isbn", ISBNX = "ISBN", @@ -144,7 +128,6 @@ local function execute(specification) if result then -- not that fast but if needed we can speed it up context.startMPcode() - context(s_preamble) local rectangles = result.rectangles local hexagons = result.hexagons local circles = result.circles @@ -155,16 +138,16 @@ local function execute(specification) local r = rectangles[i] rectangles[i] = f_rectangle(r[3],r[4],r[1],r[2]) end - rectangles[n+1] = s_done - context("% t",rectangles) + context("fill % && t && cycle;",rectangles) end if hexagons then local n = #hexagons + local s = sqrt(2) / 2 -- can be finetuned if needed for i=1,n do - hexagons[i] = f_hexagon(unpack(hexagons[i])) + local h = hexagons[i] + hexagons[i] = f_hexagon(s*h[3],h[1],h[2]) end - hexagons[n+1] = s_done - context("% t",hexagons) + context("fill % && t && cycle;",hexagons) end if circles then local n = #circles @@ -172,15 +155,13 @@ local function execute(specification) local c = circles[i] circles[i] = f_circle(c[3],c[1],c[2]) end - circles[n+1] = s_done - context("% t",circles) + context("eofill % && t && cycle;",circles) end if strings then -- We set the font at the encapsulating level. local n = #strings for i=1,n do local s = strings[i] - -- context('draw textext("%s") scaled (%N/10) shifted (%N,%N);', strings[i] = f_string(s[4],s[3],s[1],s[2]) end context("% t",strings) diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 6b623b372..cb1b5c7a9 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -39,7 +39,7 @@ local concat, sortedhash = table.concat, table.sortedhash local setmetatableindex = table.setmetatableindex local loaddata = io.loaddata -local bpfactor = number.dimenfactors.bp +local bpfactor <const> = number.dimenfactors.bp local osuuid = os.uuid local zlibcompresssize = xzip.compresssize @@ -129,8 +129,10 @@ local usedfonts, usedxforms, usedximages, usedxgroups local getxformname, getximagename local boundingbox, shippingmode, objectnumber local tmrx, tmry, tmsx, tmsy, tmtx, tmty -local cmrx, cmry, cmsx, cmsy, cmtx, cmty +----- cmrx, cmry, cmsx, cmsy, cmtx, cmty +local cmrx, cmry, cmtx, cmty local tmef +local c_effect local function usefont(t,k) -- a bit redundant hash -- local v = pdfgetfontname(k) @@ -142,7 +144,7 @@ end local function reset_variables(specification) pdf_h, pdf_v = 0, 0 cmrx, cmry = 1.0, 1.0 - cmsx, cmsy = 0.0, 0.0 + -- cmsx, cmsy = 0.0, 0.0 cmtx, cmty = 0.0, 0.0 tmrx, tmry = 1.0, 1.0 tmsx, tmsy = 0.0, 0.0 @@ -169,6 +171,7 @@ local function reset_variables(specification) cur_factor = 0 tj_delta = 0.0 cw = 0.0 + c_effect = nil usedfonts = setmetatableindex(usefont) usedxforms = { } usedximages = { } @@ -264,6 +267,7 @@ end -- helpers (maybe in collapse mode we have to go %.9N) local f_cm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N cm"] +local f_cz = formatters["%.6N 0 0 %.6N %.6N %.6N cm"] local f_tm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N Tm"] local saved_text_pos_v = 0 @@ -277,6 +281,7 @@ local function begin_text() need_font = true need_width = 0 need_mode = 0 + c_effect = nil mode = "text" end @@ -295,28 +300,32 @@ local function end_text() mode = "page" end -local saved_chararray_pos_h -local saved_chararray_pos_v +local begin_chararray, end_chararray do -local saved_b = 0 + local saved_chararray_pos_h + local saved_chararray_pos_v -local function begin_chararray() - saved_chararray_pos_h = pdf_h - saved_chararray_pos_v = pdf_v - cw = horizontalmode and saved_chararray_pos_h or - saved_chararray_pos_v - tj_delta = 0 - saved_b = b - b = b + 1 ; buffer[b] = " [" - mode = "chararray" -end + local saved_b = 0 + + begin_chararray = function() + saved_chararray_pos_h = pdf_h + saved_chararray_pos_v = pdf_v + cw = horizontalmode and saved_chararray_pos_h or - saved_chararray_pos_v + tj_delta = 0 + saved_b = b + b = b + 1 ; buffer[b] = " [" + mode = "chararray" + end + + end_chararray = function() + b = b + 1 ; buffer[b] = "] TJ" + buffer[saved_b] = concat(buffer,"",saved_b,b) + b = saved_b + pdf_h = saved_chararray_pos_h + pdf_v = saved_chararray_pos_v + mode = "text" + end -local function end_chararray() - b = b + 1 ; buffer[b] = "] TJ" - buffer[saved_b] = concat(buffer,"",saved_b,b) - b = saved_b - pdf_h = saved_chararray_pos_h - pdf_v = saved_chararray_pos_v - mode = "text" end local function begin_charmode() @@ -353,7 +362,8 @@ end local function pdf_set_pos(h,v) local move = calc_pdfpos(h,v) if move then - b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor) + -- b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor) + b = b + 1 ; buffer[b] = f_cz(cmrx, cmry, cmtx*bpfactor, cmty*bpfactor) pdf_h = pdf_h + cmtx pdf_v = pdf_v + cmty end @@ -385,7 +395,8 @@ local function pdf_reset_pos() return end end - b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor) + -- b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor) + b = b + 1 ; buffer[b] = f_cz(cmrx, cmry, cmtx*bpfactor, cmty*bpfactor) pdf_h = pdf_h + cmtx pdf_v = pdf_v + cmty end @@ -393,7 +404,8 @@ end local function pdf_set_pos_temp(h,v) local move = calc_pdfpos(h,v) if move then - b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor) + -- b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor) + b = b + 1 ; buffer[b] = f_cz(cmrx, cmry, cmtx*bpfactor, cmty*bpfactor) end end @@ -522,18 +534,42 @@ do collapse = v end) - local function setup_fontparameters(font,factor,sx,sy) - local slant = fontparameters.slantfactor or 0 - local extend = fontparameters.extendfactor or 1 - local squeeze = fontparameters.squeezefactor or 1 - local expand = 1 + factor / 1000000 - local format = fontproperties.format - tmef = expand - tmrx = expand * extend - tmsy = slant - tmry = squeeze - need_width = fontparameters.width or 0 - need_mode = fontparameters.mode or 0 + local function setup_fontparameters(font,factor,sx,sy,effect) + local format = fontproperties.format + local expand = 1 + factor / 1000000 + tmef = expand + + -- local slant = fontparameters.slantfactor or 0 + -- local squeeze = fontparameters.squeezefactor or 1 + -- local extend = fontparameters.extendfactor or 1 + -- tmrx = extend * expand + -- tmry = squeeze + -- tmsy = slant + -- need_width = fontparameters.width or 0 + -- need_mode = fontparameters.mode or 0 + + if effect then + if effect ~= c_effect then + tmsy = effect.slant or fontparameters.slantfactor or 0 + tmry = effect.squeeze or fontparameters.squeezefactor or 1 + tmrx = effect.extend or fontparameters.extendfactor or 1 + need_mode = effect.mode or fontparameters.mode or 0 + need_width = effect.line or fontparameters.width or 0 + c_effect = effect + else + -- we could check if effects have changed but effects use unique tables; for + -- now they win over font effects (only used in math) + end + else + tmsy = fontparameters.slantfactor or 0 + tmry = fontparameters.squeezefactor or 1 + tmrx = fontparameters.extendfactor or 1 + need_mode = fontparameters.mode or 0 + need_width = fontparameters.width or 0 + end + + tmrx = expand * tmrx + f_cur = font f_pdf = usedfonts[font] -- cache cur_factor = factor @@ -665,7 +701,6 @@ do local s = data.scale local x = data.xoffset local y = data.yoffset - if s then sx = s * sx sy = s * sy @@ -679,16 +714,21 @@ do csy = 1 end + local effect = data.effect + -- if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur then - if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur or mode == "page" then + if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur + or mode == "page" + or effect ~= c_effect + then pdf_goto_textmode() - setup_fontparameters(font,factor,sx,sy) -- too often due to page + setup_fontparameters(font,factor,sx,sy,effect) -- too often due to page set_font() -- elseif mode == "page" then -- pdf_goto_textmode() -- set_font() elseif cur_tmrx ~= tmrx or cur_factor ~= factor then - setup_fontparameters(font,factor,sx,sy) + setup_fontparameters(font,factor,sx,sy,effect) need_tm = true end @@ -1120,11 +1160,11 @@ local flushimage do local pdfcollectedresources = lpdf.collectedresources - function codeinjections.saveboxresource(box,attributes,resources,immediate,kind,margin) + function codeinjections.saveboxresource(box,attributes,resources,immediate,kind,margin,onum) n = n + 1 local immediate = true local margin = margin or 0 -- or dimension - local objnum = pdfreserveobject() + local objnum = onum or pdfreserveobject() local list = tonut(type(box) == "number" and tex.takebox(box) or box) -- if resources == true then @@ -1146,6 +1186,10 @@ local flushimage do index = objnum, objnum = objnum, } + local r = boxresources[objnum] + if r then + flushlist(l.list) + end boxresources[objnum] = l if immediate then localconverter(list,"xform",objnum,l) @@ -1225,7 +1269,8 @@ local flushimage do tx = cmtx * bpfactor ty = cmty * bpfactor b = b + 1 ; buffer[b] = s_b - b = b + 1 ; buffer[b] = f_cm(rx,0,0,ry,tx,ty) + -- b = b + 1 ; buffer[b] = f_cm(rx,0,0,ry,tx,ty) + b = b + 1 ; buffer[b] = f_cz(rx, ry,tx,ty) b = b + 1 ; buffer[b] = f_fm(name) b = b + 1 ; buffer[b] = s_e end @@ -1452,8 +1497,6 @@ local flushimage do pdf_goto_pagemode() - -- local saved_b = b - b = b + 1 ; buffer[b] = s_b local dim_h = size_h * bpfactor @@ -1483,9 +1526,6 @@ local flushimage do b = b + 1 ; buffer[b] = rule b = b + 1 ; buffer[b] = s_e - -- buffer[saved_b] = concat(buffer," ",saved_b,b) - -- b = saved_b - end flushers.simplerule = function(pos_h,pos_v,pos_r,size_h,size_v) @@ -1581,11 +1621,12 @@ local wrapupdocument, registerpage do return list end - function lpdf.setpageorder(mapping) + function lpdf.setpageorder(mapping,p) -- mapping can be a hash so: local list = table.sortedkeys(mapping) local n = #list - if n == nofpages then + local nop = p or nofpages + if n == nop then local done = { } local hash = { } for i=1,n do @@ -1603,7 +1644,7 @@ local wrapupdocument, registerpage do end pages = done else - report("invalid page order, %i entries expected",nofpages) + report("invalid page order, %i entries expected",nop) end end @@ -2070,6 +2111,11 @@ end local flushdeferred -- defined later local level = 0 +local state = true + +function lpdf.setpagestate(s) + state = s +end local finalize do @@ -2157,6 +2203,10 @@ local finalize do -- resources can be indirect +if state == "ignore" or state == false then + +else + registerpage(pageattributes) lpdf.finalizepage(true) @@ -2171,6 +2221,8 @@ local finalize do if CropBox then pageattributes.CropBox = pdfsharedobject(CropBox ) end if BleedBox then pageattributes.BleedBox = pdfsharedobject(BleedBox) end +end + else local xformtype = specification.type or 0 @@ -2226,7 +2278,7 @@ local finalize do -- wrapper.Resources = pdfreference(pdfflushobject(boxresources)) if resources ~= "" then - boxresources = boxresources + resources + boxresources = boxresources + resources end if attributes ~= "" then wrapper = wrapper + attributes diff --git a/tex/context/base/mkxl/lpdf-rul.lmt b/tex/context/base/mkxl/lpdf-rul.lmt index 371549e19..d6a528034 100644 --- a/tex/context/base/mkxl/lpdf-rul.lmt +++ b/tex/context/base/mkxl/lpdf-rul.lmt @@ -78,28 +78,38 @@ do -- todo: RuleColor -> just string ? -- todo: fetch them instead fo push them - local predefined = { +-- local predefined = { +-- ["fake:word"] = replacer [[ +-- FakeWord(%width%,%height%,%depth%,%line%,%color%); +-- ]], +-- ["fake:rule"] = replacer[[ +-- %initializations% +-- FakeRule(%width%,%height%,%depth%,%line%,%color%); +-- ]], +-- ["fake:rest"] = replacer [[ +-- RuleDirection := "%direction%" ; +-- RuleOption := "%option%" ; +-- RuleWidth := %width% ; +-- RuleHeight := %height% ; +-- RuleDepth := %depth% ; +-- RuleH := %h% ; +-- RuleV := %v% ; +-- RuleThickness := %line% ; +-- RuleFactor := %factor% ; +-- RuleOffset := %offset% ; +-- def RuleColor = %color% enddef ; +-- %data%; +-- ]] +-- } + + local predefined = { ["fake:word"] = replacer [[ -FakeWord(%width%,%height%,%depth%,%line%,%color%); +FakeWord(RuleWidth,RuleHeight,RuleDepth,RuleThickness,RuleColor); ]], ["fake:rule"] = replacer[[ %initializations% -FakeRule(%width%,%height%,%depth%,%line%,%color%); +FakeRule(RuleWidth,RuleHeight,RuleDepth,RuleThickness,RuleColor); ]], --- ["fake:rest"] = replacer [[ ---RuleDirection := "%direction%" ; ---RuleOption := "%option%" ; ---RuleWidth := %width% ; ---RuleHeight := %height% ; ---RuleDepth := %depth% ; ---RuleH := %h% ; ---RuleV := %v% ; ---RuleThickness := %line% ; ---RuleFactor := %factor% ; ---RuleOffset := %offset% ; ---def RuleColor = %color% enddef ; ---%data%; --- ]] ["fake:rest"] = replacer [[ %data%; ]] @@ -141,7 +151,6 @@ FakeRule(%width%,%height%,%depth%,%line%,%color%); setmacro("m_rule_option", p.option or "") setmacro("m_rule_direction", p.direction or lefttoright_code) setmacro("m_rule_color", mpcolor(p.ma,p.ca,p.ta)) - print("!!!",mpcolor(p.ma,p.ca,p.ta)) -- if not initialized then initialized = true diff --git a/tex/context/base/mkxl/math-acc.mklx b/tex/context/base/mkxl/math-acc.mklx index 929a37ae6..baa24fcea 100644 --- a/tex/context/base/mkxl/math-acc.mklx +++ b/tex/context/base/mkxl/math-acc.mklx @@ -100,6 +100,7 @@ \edef\m_fixed{\ifcstok{\mathaccentparameter\c!stretch}\v!yes\else\s!fixed\fi}% \Umathaccent \usedcolorparameterattributes{\mathaccentparameter\c!color}% + % nooverflow % there is never na overflow anyway but we do accept thekey \ifcase#kind\or top \m_fixed \fam\zerocount#top diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt index 19464b522..d1a6b80e1 100644 --- a/tex/context/base/mkxl/math-act.lmt +++ b/tex/context/base/mkxl/math-act.lmt @@ -28,6 +28,9 @@ local mathematics = mathematics local texsetdimen = tex.setdimen local abs = math.abs +local blocks = characters.blocks +local stepper = utilities.parsers.stepper + local helpers = fonts.helpers local upcommand = helpers.commands.up local rightcommand = helpers.commands.right @@ -41,6 +44,10 @@ local appendaction = sequencers.appendaction local fontchars = fonts.hashes.characters local fontproperties = fonts.hashes.properties +local mathgaps = mathematics.gaps + +local use_math_goodies = true directives.register("math.nogoodies", function(v) use_math_goodies = not v end) + local mathfontparameteractions = sequencers.new { name = "mathparameters", arguments = "target,original", @@ -76,6 +83,12 @@ function mathematics.initializeparameters(target,original) if not mathparameters.FlattenedAccentBottomShiftDown then mathparameters.AccentBottomShiftDown = 0 end if not mathparameters.AccentBaseDepth then mathparameters.AccentBaseDepth = 0 end if not mathparameters.AccentFlattenedBaseDepth then mathparameters.AccentFlattenedBaseDepth = 0 end + if not mathparameters.AccentTopOvershoot then mathparameters.AccentTopOvershoot = 0 end + if not mathparameters.AccentBottomOvershoot then mathparameters.AccentBottomOvershoot = 0 end + if not mathparameters.AccentSuperscriptDrop then mathparameters.AccentSuperscriptDrop = 0 end + if not mathparameters.AccentSuperscriptPercent then mathparameters.AccentSuperscriptPercent = 0 end + if not mathparameters.DelimiterPercent then mathparameters.DelimiterPercent = 100 end + if not mathparameters.DelimiterShortfall then mathparameters.DelimiterShortfall = 0 end -- -- we don't want to reset that each time .. but then we also can't show what the value was -- @@ -97,6 +110,10 @@ local how = { NoLimitSubFactor = "unscaled", PrimeRaisePercent = "unscaled", PrimeWidthPercent = "unscaled", + AccentTopOvershoot = "unscaled", + AccentBottomOvershoot = "unscaled", + AccentSuperscriptPercent = "unscaled", + DelimiterPercent = "unscaled", } function mathematics.scaleparameters(target,original) @@ -157,62 +174,64 @@ end -- end function mathematics.overloadparameters(target,original) - local mathparameters = target.mathparameters - if mathparameters and next(mathparameters) then - local goodies = target.goodies - if goodies then - for i=1,#goodies do - local goodie = goodies[i] - local mathematics = goodie.mathematics - if mathematics then - local parameters = mathematics.parameters - local bigslots = mathematics.bigslots or mathematics.bigs - if parameters then - if trace_defining then - report_math("overloading math parameters in %a @ %p",target.properties.fullname,target.parameters.size) - end - for name, value in next, parameters do - local tvalue = type(value) - local oldvalue = mathparameters[name] - local newvalue = oldvalue - if tvalue == "number" then - newvalue = value - elseif tvalue == "string" then - -- delay till all set - elseif tvalue == "function" then - newvalue = value(oldvalue,target,original) - elseif not tvalue then - newvalue = nil + if use_math_goodies then + local mathparameters = target.mathparameters + if mathparameters and next(mathparameters) then + local goodies = target.goodies + if goodies then + for i=1,#goodies do + local goodie = goodies[i] + local mathematics = goodie.mathematics + if mathematics then + local parameters = mathematics.parameters + local bigslots = mathematics.bigslots or mathematics.bigs + if parameters then + if trace_defining then + report_math("overloading math parameters in %a @ %p",target.properties.fullname,target.parameters.size) end - if trace_defining and oldvalue ~= newvalue then - report_math("overloading math parameter %a: %S => %S",name,oldvalue or 0,newvalue) + for name, value in next, parameters do + local tvalue = type(value) + local oldvalue = mathparameters[name] + local newvalue = oldvalue + if tvalue == "number" then + newvalue = value + elseif tvalue == "string" then + -- delay till all set + elseif tvalue == "function" then + newvalue = value(oldvalue,target,original) + elseif not tvalue then + newvalue = nil + end + if trace_defining and oldvalue ~= newvalue then + report_math("overloading math parameter %a: %S => %S",name,oldvalue or 0,newvalue) + end + mathparameters[name] = newvalue end - mathparameters[name] = newvalue - end - for name, value in next, parameters do - local tvalue = type(value) - if tvalue == "string" then - local newvalue = mathparameters[value] - -- if not newvalue then - -- local code = loadstring("return " .. value,"","t",mathparameters) - -- if type(code) == "function" then - -- local okay, v = pcall(code) - -- if okay then - -- newvalue = v - -- end - -- end - -- end - if newvalue then - -- split in number and string - mathparameters[name] = newvalue - elseif trace_defining then - report_math("ignoring math parameter %a: %S",name,value) + for name, value in next, parameters do + local tvalue = type(value) + if tvalue == "string" then + local newvalue = mathparameters[value] + -- if not newvalue then + -- local code = loadstring("return " .. value,"","t",mathparameters) + -- if type(code) == "function" then + -- local okay, v = pcall(code) + -- if okay then + -- newvalue = v + -- end + -- end + -- end + if newvalue then + -- split in number and string + mathparameters[name] = newvalue + elseif trace_defining then + report_math("ignoring math parameter %a: %S",name,value) + end end end end - end - if bigslots then - target.bigslots = bigslots + if bigslots then + target.bigslots = bigslots + end end end end @@ -241,14 +260,31 @@ local function report_tweak(fmt,target,original,...) end end -do +-- { +-- tweak = "dimensions", +-- list = { +-- ["lowercasegreeksansserifbolditalic"] = { +-- -- delta = 0x003B1 - 0x1D7AA, +-- slant = -0.2, +-- line = 0.1, +-- mode = 1, +-- width = 0.675, +-- -- scale = 0.975, +-- squeeze = 0.975, +-- extend = .7, +-- }, +-- }, +-- }, - local stepper = utilities.parsers.stepper - local count = 0 +do + local stepper = utilities.parsers.stepper + local count = 0 local splitter = lpeg.tsplitat(".") + local toeffect = fonts.toeffect local function adapt(list,target,original,targetcharacters,originalcharacters,k,v,compact,n) + k = mathgaps[k] or k local character = targetcharacters[k] if character then if not character.tweaked then @@ -257,77 +293,81 @@ do v = list[v] t = type(v) end - if t == "table" then + if t == "table" and next(v) then + local original = v.original + if not original then + local delta = v.delta + if delta then + original = k + delta + end + end + if original then + original = mathgaps[original] or original + local data = targetcharacters[original] + if data then + data = table.copy(data) + data.unicode = original + targetcharacters[k] = data + character = data + else + report_mathtweak("no slot %U",original) + return + end + end + -- local width = character.width local height = character.height local depth = character.depth local italic = character.italic local topaccent = character.topaccent - if #v > 0 then - local offsetfactor = v[1] - local widthfactor = v[2] - local italicfactor = v[3] - local anchorfactor = v[4] - if width then - character.advance = width -- so advance is oldwidth - character.xoffset = offsetfactor * width - character.width = widthfactor * width - end - if italic then - character.italic = italicfactor * italic - elseif width and italicfactor ~= 1 then - character.italic = italicfactor * width - end - if topaccent and topaccent > 0 then - if anchorfactor then - character.topaccent = anchorfactor * topaccent - elseif width then - character.topaccent = topaccent + (character.width - character.advance) / 2 - end - end - else - local widthfactor = v.width - local heightfactor = v.height - local depthfactor = v.depth - local italicfactor = v.italic - local anchorfactor = v.anchor - local advancefactor = v.advance - local xoffsetfactor = v.xoffset - local yoffsetfactor = v.yoffset - local scalefactor = v.scale - local total = (height or 0) + (depth or 0) - if scalefactor ~= 1 then - character.scale = scalefactor - end - if width and width ~= 0 then - if advancefactor then - character.advance = advancefactor * width - end - if widthfactor then - character.width = widthfactor * width - end - if xoffsetfactor then - character.xoffset = xoffsetfactor * width - end + -- + local widthfactor = v.width + local heightfactor = v.height + local depthfactor = v.depth + local italicfactor = v.italic + local anchorfactor = v.anchor + local advancefactor = v.advance + local xoffsetfactor = v.xoffset + local yoffsetfactor = v.yoffset + local scalefactor = v.scale + local total = (height or 0) + (depth or 0) + if scalefactor ~= 1 then + character.scale = scalefactor + end + if width and width ~= 0 then + if advancefactor then + character.advance = advancefactor * width end - if height and height ~= 0 then - if heightfactor then - character.height = heightfactor * height - end + if widthfactor then + character.width = widthfactor * width end - if depth and depthfactor then - character.depth = depthfactor * depth + if xoffsetfactor then + character.xoffset = xoffsetfactor * width end - if yoffsetfactor then - character.yoffset = yoffsetfactor * total + end + if height and height ~= 0 then + if heightfactor then + character.height = heightfactor * height end - if italic and italic ~= 0 and italicfactor then + end + if depth and depthfactor then + character.depth = depthfactor * depth + end + if yoffsetfactor then + character.yoffset = yoffsetfactor * total + end + if italicfactor then + if italic then character.italic = italicfactor * italic + elseif width and italicfactor ~= 1 then + character.italic = italicfactor * width end - if anchorfactor then - character.topaccent = anchorfactor * (topaccent or width) - end end + if anchorfactor then + character.topaccent = anchorfactor * (topaccent or width) + end + -- todo: check once per tweak + character.effect = toeffect(v) if trace_tweaking then report_tweak("adapting dimensions of %U ",target,original,k) end @@ -359,30 +399,60 @@ do end end + -- ["0x7C.variants.*"] = { squeeze = 0.10, height = 0.10, depth = 0.10 }, + local function detail(characters,k) if type(k) == "string" then local t = lpeg.match(splitter,k) local n = #t if n > 0 then - local m = tonumber(t[1]) or tonumber(t[1],16) - if m then - local c = characters[m] + local base = tonumber(t[1]) or tonumber(t[1],16) + if base then + local c = characters[base] if c and n > 1 then - m = t[2] - if m == "parts" then + local list = t[2] + if list == "parts" then local nxt = c.next while nxt do c = characters[nxt] nxt = c.next end c = c.hparts or c.vparts - if c and n > 2 then - m = tonumber(t[3]) - if m then - c = c[m] - if c then - return c.glyph + if c then + local index = t[3] + if index == "*" then + return t + else + index = tonumber(index) + if index then + c = c[index] + if c then + return c.glyph + end + end + end + end + elseif list == "variants" then + local index = t[3] + if index == "*" then + local t = { } + local nxt = c.next + while nxt do + t[#t+1] = nxt + c = characters[nxt] + nxt = c.next + end + return t + else + index = tonumber(index) + if index then + local nxt = c.next + while nxt and index > 1 do + c = characters[nxt] + nxt = c.next + index = index - 1 end + return nxt end end end @@ -405,12 +475,27 @@ do adapt(list,target,original,targetcharacters,originalcharacters,k,v,compact,1) elseif t == "string" then local d = detail(targetcharacters,k) - if d then + local t = type(d) + if t == "table" then + for i=1,#d do + adapt(list,target,original,targetcharacters,originalcharacters,d[i],v,compact,1) + end + elseif t == "number" then adapt(list,target,original,targetcharacters,originalcharacters,d,v,compact,1) + elseif d then + -- some kind of error else - stepper(k,function(n) - adapt(list,target,original,targetcharacters,originalcharacters,n,v,compact,1) - end) + local r = blocks[k] + if r then + local done = false + for i=r.first,r.last do + adapt(list,target,original,targetcharacters,originalcharacters,i,v,compact,1) + end + else + stepper(k,function(n) + adapt(list,target,original,targetcharacters,originalcharacters,n,v,compact,1) + end) + end end -- elseif t == "table" then -- for i=1,#t do @@ -428,6 +513,53 @@ end do + function mathtweaks.wipevariants(target,original,parameters) + local list = parameters.list + if list then + local targetcharacters = target.characters + -- local originalcharacters = original.characters + local count = 0 + for k, v in sortedhash(list) do + local ori = targetcharacters[k] + local nxt = ori.next + local cnt = v + if nxt then + local hpt, vpt + local lst = { } + while nxt do + local chr = targetcharacters[nxt] + lst[#lst+1] = chr + nxt = chr.next + if not nxt then + hpt = chr.hparts + vpt = chr.vparts + break + end + end + if hpt or vpt then + count = count + 1 + if cnt ~= "*" then + if #lst < cnt then + cnt = #lst + end + ori = lst[cnt] + end + ori.hparts = hpt + ori.vparts = vpt + -- ori.next = nil -- so we keep the chain + end + end + end + if trace_tweaking and count > 0 then + report_mathtweak("%i variants wiped",count) + end + end + end + +end + +do + function mathtweaks.replacements(target,original,parameters) local list = parameters.list if list then @@ -441,7 +573,7 @@ do v = unicodes[v] end if type(v) == "number" then - targetcharacters[k] = targetcharacters[v] + targetcharacters[mathgaps[k] or k] = targetcharacters[mathgaps[v] or v] count = count + 1 end end @@ -462,7 +594,7 @@ do for k, v in sortedhash(list) do local sub = getsubstitution(original,k,v,true) if sub then - targetcharacters[k] = targetcharacters[sub] + targetcharacters[mathgaps[k] or k] = targetcharacters[mathgaps[sub] or sub] count = count + 1 end end @@ -669,9 +801,10 @@ end do function mathtweaks.fixanchors(target,original,parameters) - local factor = tonumber(parameters.factor) + local targetcharacters= target.characters + local factor = tonumber(parameters.factor) or 0 if factor ~= 0 then - for k, v in next, target.characters do + for k, v in next, targetcharacters do local a = v.topaccent if a and a > 0 then v.topaccent = a * factor @@ -680,6 +813,76 @@ do end end + -- local default = { + -- "digitsnormal", + -- "lowercasedoublestruck", + -- "uppercasedoublestruck", + -- } + + local function wipe(target,original,parameters,field) + local targetcharacters = target.characters + local function step(s,l) + local done = false + while s do + local c = targetcharacters[mathgaps[s] or s] + if c then + local v = c[field] + if v then + if trace_tweaking then + if l then + report_tweak("removing %a in range %a from %C",target,original,field,l,s) + else + report_tweak("removing %a from %C",target,original,field,s) + end + end + c[field] = nil + done = true + end + s = c.smaller + else + break + end + end + return done + end + local list = parameters.list -- todo: ranges + -- if list == "default" then + -- list = default + -- else + if type(list) == "string" then + list = { list } + end + for i=1,#list do + local l = list[i] + local r = blocks[l] + if r then + local done = false + for i=r.first,r.last do + if step(i,l) then + done = true + end + end + if not done and trace_tweaking then + report_mathtweak("there is no need to remove %a range %a",field,l) + end + else + stepper(l,step) + end + end + end + + function mathtweaks.wipeanchors(target,original,parameters) + wipe(target,original,parameters,"topaccent") + end + + function mathtweaks.wipeitalics(target,original,parameters) + wipe(target,original,parameters,"italic") + end + + -- function mathtweaks.fixdigits(target,original,parameters) + -- mathtweaks.fixanchors(target,original,{ list = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } }) + -- end + end do @@ -690,17 +893,97 @@ do local kerns = parameters.list if kerns then local characters = target.characters - local function kernone(unicode,data) - local chardata = characters[unicode] - local height = chardata.height or 0 - local depth = chardata.depth or 0 - local width = chardata.width or 0 + local function setone(unicode,data) + local chardata = characters[mathgaps[unicode] or unicode] + local width = chardata.width or 0 local k = data.topleft ; if k and k ~= 0 then chardata.topleft = k * width end local k = data.topright ; if k and k ~= 0 then chardata.topright = k * width end local k = data.bottomleft ; if k and k ~= 0 then chardata.bottomleft = k * width end local k = data.bottomright ; if k and k ~= 0 then chardata.bottomright = k * width end end for unicode, data in next, kerns do + setone(unicode,data) -- withscriptcode(tfmdata,unicode,data,kernone) + -- also smaller + end + end + end + +end + +do + + function mathtweaks.margins(target,original,parameters) + local margins = parameters.list + if margins then + local characters = target.characters + local function setone(unicode,data) + local chardata = characters[mathgaps[unicode] or unicode] + local width = chardata.width or 0 + local total = (chardata.height or 0) + (chardata.depth or 0) + local k = data.left ; if k and k ~= 0 then chardata.leftmargin = k * width end + local k = data.right ; if k and k ~= 0 then chardata.rightmargin = k * width end + local k = data.top ; if k and k ~= 0 then chardata.topmargin = k * total end + local k = data.bottom ; if k and k ~= 0 then chardata.bottommargin = k * total end + end + for unicode, data in next, margins do + setone(unicode,data) -- withscriptcode(tfmdata,unicode,data,kernone) + -- also smaller + end + end + end + +end + +do + + -- musical timestamp: June 2022, Porcupine Tree - Rats Return + + -- we can actually share these and flag them as being tweaked + + local function scale(t,width,total) + local r = { } + for i=1,#t do + local ti = t[i] + local kern = ti.kern + local height = ti.height + if kern then + kern = width * kern + end + if height then + height = total * height + end + r[i] = { + kern = kern or 0, + height = height or 0, + } + end + return r + end + + function mathtweaks.staircase(target,original,parameters) + local kerns = parameters.list + if kerns then + local characters = target.characters + local function kernone(unicode,data) + local chardata = characters[mathgaps[unicode] or unicode] + local total = (chardata.height or 0) + (chardata.depth or 0) + local width = chardata.width or 0 + if data then + local tl = data.topleft ; if tl then tl = scale(tl,width,total) end + local tr = data.topright ; if tr then tr = scale(tr,width,total) end + local bl = data.bottomleft ; if bl then bl = scale(bl,width,total) end + local br = data.bottomright ; if br then br = scale(br,width,total) end + chardata.mathkerns = { + topleft = tl, + ropright = tr, + bottomleft = bl, + bottomright = br, + } + else + chardata.mathkerns = nil + end + end + for unicode, data in next, kerns do kernone(unicode,data) -- withscriptcode(tfmdata,unicode,data,kernone) -- also smaller end @@ -773,16 +1056,14 @@ do yoffset = depth - d depth = d height = height - baseheight - else - if height > 0 then - local h = tonumber(factor) * height - yoffset = h - height - height = h - elseif depth > 0 then - local d = tonumber(factor) * depth - yoffset = depth - d - depth = d - end + elseif height > 0 then + local h = tonumber(factor) * height + yoffset = h - height + height = h + elseif depth > 0 then + local d = tonumber(factor) * depth + yoffset = depth - d + depth = d end c.yoffset = yoffset ~= 0 and yoffset or nil c.height = height > 0 and height or nil @@ -791,7 +1072,7 @@ do end end - local function process(characters,list,baseheight,basedepth) + local function process(target,original,characters,list,baseheight,basedepth) if list then for k, v in sortedhash(list) do -- sort for tracing local c = characters[k] @@ -826,7 +1107,7 @@ do end end if trace_tweaking then - report_tweak("adapting extensible (%i sizes, %i parts) %U",k,nv,ns) + report_tweak("adapting extensible (%i sizes, %i parts) %U",target,original,k,nv,ns) end end end @@ -847,7 +1128,7 @@ do t = type(v) end if t == "table" then - process(characters,v,baseheight,basedepth) + process(target,original,characters,v,baseheight,basedepth) end end end @@ -1075,7 +1356,7 @@ do unicode = unicode, } if trace_tweaking then - report_tweak("character %U has been wiped",unicode) + report_tweak("character %U has been wiped",target,original,unicode) end end end @@ -1134,41 +1415,6 @@ do end --- do --- --- local list = { --- { 0x00AF, 1 }, --- } --- --- local minint = -2147483647 - 1 --- --- local function fix(target,original,targetcharacters,unicode,factor) --- local chardata = targetcharacters[unicode] --- if chardata and factor then --- local accent = chardata.topaccent --- if not accent then --- local width = chardata.width or 0 --- local accent = (tonumber(factor) and factor * width) or (factor and minint) --- chardata.topaccent = accent --- if trace_tweaking then --- report_tweak("fixing accent %U",target,original,unicode) --- end --- end --- end --- end --- --- function mathtweaks.fixaccents(target,original,parameters) --- local targetcharacters = target.characters --- for i=1,#list do --- local entry = list[i] --- if entry then --- fix(target,original,targetcharacters,entry[1],entry[2]) --- end --- end --- end --- --- end - do local reported = { } @@ -1239,16 +1485,20 @@ local function applytweaks(when,target,original) end function mathematics.tweakbeforecopyingfont(target,original) - local mathparameters = target.mathparameters -- why not hasmath - if mathparameters then - applytweaks("beforecopying",target,original) + if use_math_goodies then + local mathparameters = target.mathparameters -- why not hasmath + if mathparameters then + applytweaks("beforecopying",target,original) + end end end function mathematics.tweakaftercopyingfont(target,original) - local mathparameters = target.mathparameters -- why not hasmath - if mathparameters then - applytweaks("aftercopying",target,original) + if use_math_goodies then + local mathparameters = target.mathparameters -- why not hasmath + if mathparameters then + applytweaks("aftercopying",target,original) + end end end @@ -1282,6 +1532,8 @@ local e_unknown = extensibles.unknown local unknown = { e_unknown, false, false } +-- top curly bracket: 23DE + local function extensiblecode(font,unicode) local characters = fontcharacters[font] local character = characters[unicode] diff --git a/tex/context/base/mkxl/math-ali.mkxl b/tex/context/base/mkxl/math-ali.mkxl index d58bd464f..e2d7d8d69 100644 --- a/tex/context/base/mkxl/math-ali.mkxl +++ b/tex/context/base/mkxl/math-ali.mkxl @@ -29,27 +29,65 @@ % matrix : ok % substack : +% Alignment overhaul timestamp: around watching GhostNote Live in Utrecht 2022 +% (energizing funky professionalism). + +%D The following macros are moved to this module because here we deal mostly with +%D alignment issues. In principle one should see strc-mat, math-ini and math-ali as +%D a close operation. The \type {\displaywidth} is only known inside a display +%D formula, so we need to catch it when still zero. + +\permanent\def\checkeddisplaywidth % hsize if zero + {\dimexpr + \ifzeropt\displaywidth + \hsize + \else + \displaywidth + \fi + \relax} + +\permanent\def\maximizeddisplaywidth % larger than zero but within hsize + {\dimexpr + \ifzeropt\displaywidth + \hsize + \orelse\ifdim\displaywidth>\hsize + \hsize + \else + \displaywidth + \fi + \relax} + %D \macros %D {definemathalignment, setupmathalignment, startmathalignment} %D %D Modules may provide additional alignment features. The following kind of plain %D mechanisms are provided by the core. -\newtoks\mathdisplayaligntweaks +% \startformula +% \startalign[m=3, n=2, align={1:right,2:left},distance=2em] +% \NC 1.1 \NC = 1.2 \NC 2.1 \NC = 2.2 \NC 3.1 \NC = 3.2 \NR +% \NC 1 \NC = 1 \NC 2 \NC = 2 \NC 3 \NC = 3 \NR +% \NC 1.1 \NC = 1.2 \NC 2.1 \NC = 2.2 \NC 3.1 \NC = 3.2 \NR +% \stopalign +% \stopformula -\newtoks\t_math_align_a -\newtoks\t_math_align_b -\newtoks\t_math_align_c +\newtoks\mathdisplayaligntweaks -\newskip\d_math_eqalign_distance -\newskip\d_math_eqalign_rulethickness +\newtoks \t_math_align_a +\newtoks \t_math_align_b +\newtoks \t_math_align_c +\newskip \d_math_eqalign_distance +\newskip \d_math_eqalign_rulethickness +\newdimen\d_math_eqalign_number_distance +\newcount\c_math_eqalign_repeat \protected\def\math_eqalign_distance {\relax \ifdim\d_math_eqalign_distance>\zeropoint - % \hskip\d_math_eqalign_distance \tabskip\d_math_eqalign_distance \fi + %global\expandafter\integerdef\csname\??mathbeginclass\the\c_math_eqalign_column\endcsname\mathbegincode + \global\expandafter\integerdef\csname\??mathendclass \the\c_math_eqalign_column\endcsname\mathendcode \mathalignmentparameter\c!separator \relax} @@ -58,20 +96,28 @@ \def\math_build_eqalign {\scratchtoks\emptytoks \d_math_eqalign_distance\mathalignmentparameter\c!distance\relax + \ifcstok{\mathalignmentparameter\c!align}\v!auto + \d_math_eqalign_number_distance\mathalignmentparameter\c!numberdistance\relax + \letmathalignmentparameter\c!align\v!middle + \else + \d_math_eqalign_number_distance\zeropoint + \fi \scratchcounterone\mathalignmentparameter\c!m \scratchcountertwo\mathalignmentparameter\c!n - \etoksapp\scratchtoks{\the\t_math_align_a}% + \toksapp\scratchtoks\t_math_align_a + \toksapp\scratchtoks{\global\c_math_eqalign_repeat\zerocount}% \scratchcounter\plusone \dorecurse{\numexpr\scratchcounterone*\scratchcountertwo-\plusone\relax} {\ifnum\scratchcounter=\scratchcountertwo \scratchcounter\plusone - \etoksapp\scratchtoks{\math_eqalign_distance}% - \etoksapp\scratchtoks{\global\c_math_eqalign_column\zerocount}% + \toksapp\scratchtoks{\math_eqalign_distance}% + \etoksapp\scratchtoks{\global\advance\c_math_eqalign_repeat\the\scratchcountertwo\relax}% \else \advance\scratchcounter\plusone \fi - \etoksapp\scratchtoks{\the\t_math_align_b}}% - \etoksapp\scratchtoks{\the\t_math_align_c}} + \toksapp\scratchtoks\t_math_align_b}% + \toksapp\scratchtoks\t_math_align_c + \toksapp\scratchtoks{\global\c_math_eqalign_repeat\zerocount}} \def\math_eqalign_set_defaults {\normalbaselines % hm, spacing ? @@ -79,16 +125,26 @@ \tabskip\zeropoint \everycr\emptytoks} -\def\math_math_in_eqalign#1% - {\mathbeginclass\mathordcode - \mathendclass \mathordcode +%installcorenamespace{mathbeginclass} % not needed currently +\installcorenamespace{mathendclass} + +%global\expandafter\integerdef\csname\??mathbeginclass\the\zerocount\endcsname\mathbegincode +\global\expandafter\integerdef\csname\??mathendclass \the\zerocount\endcsname\mathendcode + +\protected\def\math_math_in_eqalign#1% + {\mathbeginclass\csname\??mathendclass\the\numexpr\c_math_eqalign_column-\plusone\relax\endcsname \startforceddisplaymath \tabskip\zeropoint \everycr\emptytoks #1% - \stopforceddisplaymath} + \stopforceddisplaymath + \ifnum\lastrightclass<\mathunsetcode + %global\expandafter\integerdef\csname\??mathbeginclass\the\c_math_eqalign_column\endcsname\lastleftclass + \global\expandafter\integerdef\csname\??mathendclass \the\c_math_eqalign_column\endcsname\lastrightclass + \fi + } -\def\math_text_in_eqalign#1% +\noaligned\protected\def\math_text_in_eqalign#1% {\mathbeginclass\mathordcode \mathendclass \mathordcode \startimath @@ -97,40 +153,72 @@ #1% \stopimath} -\let\math_align_openup\relax % defined later on - -\permanent\protected\def\eqalign#1% rather plain, is this used at all ... - {\dontleavehmode - \mskip\thinmuskip\vcenter\bgroup % \vcenter \s!class \mathwrappercode \bgroup - \math_align_openup - \mathsurround\zeropoint % \math_eqalign_set_defaults - \ialign - {\strut - \hfil - \mathbeginclass\mathordcode - \mathendclass \mathordcode - \startforceddisplaymath\aligncontent\stopforceddisplaymath - \aligntab - \mathbeginclass\mathordcode - \mathendclass \mathordcode - \startforceddisplaymath\aligncontent\stopforceddisplaymath - \hfil - \crcr - #1% - \crcr}% - \egroup\mskip\thinmuskip} % \egroup - -% preamble is scanned for tabskips so we need the span to prevent an error message - -\setnewconstant\eqalignmode\plusone +% the preamble is scanned for tabskips so we need the span to prevent an error +% message but we can probably do without that hack now .. best not change this +% now .. what works now keeps working + +\setnewconstant\c_strc_formulas_check_width\plusone + +\newboundary\c_math_align_l_marker +\newboundary\c_math_align_r_marker + +% formula : numbermethod down : default +% formula : numberlocation overlay : option +% mathalign : align ..| auto : +% mathalign : adaptive yes : synchronize glue + +% \startplaceformula +% \startformula[numbermethod=down,numberlocation=normal] +% \medmuskip 4mu plus 2mu minus 2mu \showmakeup[mathglue]\showglyphs\showboxes +% \startalign[adaptive=yes,align=auto] +% \NC aaa+x+xxxxxxxx+x+xxxx \EQ x+xxx \NR[eq:two:zz] +% \NC x+x \EQ x+x+x+xxx+x+x+xxx+xx+xx \NR[eq:two:xx] +% \stopalign +% \stopformula +% \stopplaceformula +% +% \startplaceformula +% \startformula[numbermethod=normal,numberlocation=normal] +% \medmuskip 4mu plus 2mu minus 2mu \showmakeup[mathglue]\showglyphs\showboxes +% \startalign[adaptive=no,align=middle] +% \NC aaa+x+xxxxxxxx+x+xxxx \EQ x+xxx \NR[eq:two:zz] +% \NC x+x \EQ x+x+x+xxx+x+x+xxx+xx+xx \NR[eq:two:xx] +% \stopalign +% \stopformula +% \stopplaceformula + +\newconditional\c_math_align_overflow_mode \settrue\c_math_align_overflow_mode +\newconditional\c_math_align_reformat_mode \settrue\c_math_align_reformat_mode +\newconditional\c_strc_formulas_overlay_number \settrue\c_strc_formulas_overlay_number + +\protected\def\math_text_in_align + {\scratchcounter\numexpr\c_math_eqalign_row+\plusone\relax + \usemathalignmentstyleandcolor\c!textstyle\c!textcolor + \usemathalignmentstyleandcolor{\c!textstyle:\the\scratchcounter}{\c!textcolor:\the\scratchcounter}% + \mathalignmentparameter\c!text + \mathalignmentparameter{\c!text:\the\scratchcounter}} + +\def\math_align_initialize_class_states + {} -% use zeroskipplusfill +\def\math_align_reset_class_states + {\lastleftclass \mathbegincode + \lastrightclass\mathendcode} -\def\math_prepare_r_eqalign_no - {\t_math_align_a - {\strut - \tabskip\zeropoint +\def\math_prepare_l_eqalign_no % \checkeddisplaymath + {\math_align_initialize_class_states + \t_math_align_a + {\relax + \strut + \math_text_in_align \aligncontent % for picking up the number + \ifnum\c_strc_math_ragged_status=\plusthree + \tabskip\zeropoint\relax + \else + \tabskip\centeringskip + \fi + \boundary\c_math_align_l_marker + \math_align_reset_class_states \aligntab \math_first_in_eqalign \hfil @@ -147,39 +235,51 @@ \math_math_in_eqalign{\aligncontent}% \math_right_of_eqalign \tabskip\zeropoint}% - \ifnum\mathraggedstatus=\plusone + \ifnum\c_strc_math_ragged_status=\plusthree \t_math_align_c {\hfil + \tabskip\zeropoint \aligntab \span - \math_text_in_eqalign{\aligncontent}% + \boundary\c_math_align_r_marker + \math_alignment_rbox{\aligncontent}% \tabskip\zeropoint}% - \orelse\ifnum\mathraggedstatus=\plusthree + \orelse\ifnum\c_strc_math_ragged_status=\plusone \t_math_align_c {\hfil - \tabskip\zeropoint\s!plus 1\s!fill + \tabskip\stretchingfillskip \aligntab \span - \math_text_in_eqalign{\aligncontent}% + \boundary\c_math_align_r_marker + \math_alignment_rbox{\aligncontent}% \tabskip\zeropoint}% \else \t_math_align_c {\hfil - \tabskip\centering + \tabskip\centeringskip \aligntab \span - \llap{\math_text_in_eqalign{\aligncontent}}% + \boundary\c_math_align_r_marker + \math_alignment_rbox{\aligncontent}% \tabskip\zeropoint}% \fi \math_build_eqalign \the\mathdisplayaligntweaks - \tabskip\centering} + \tabskip\zeropoint + \ifnum\c_strc_math_ragged_status=\plusthree + \tabskip\stretchingfillskip + \fi} -\def\math_prepare_l_eqalign_no % \checkeddisplaymath - {\t_math_align_a - {\strut - \tabskip\zeropoint +\def\math_prepare_r_eqalign_no + {\math_align_initialize_class_states + \t_math_align_a + {\relax + \strut + \math_text_in_align + \tabskip\centeringskip \aligncontent % for picking up the number + \boundary\c_math_align_l_marker + \math_align_reset_class_states \aligntab \math_first_in_eqalign \hfil @@ -196,97 +296,88 @@ \math_math_in_eqalign{\aligncontent}% \math_right_of_eqalign \tabskip\zeropoint}% - \ifnum\mathraggedstatus=\plusone - \t_math_align_c - {\hfil - \aligntab - \kern-\displaywidth - \span - \rlap{\math_text_in_eqalign{\aligncontent}} - \tabskip\displaywidth}% - \orelse\ifnum\mathraggedstatus=\plusthree + \ifnum\c_strc_math_ragged_status=\plusthree \t_math_align_c {\hfil - \tabskip\zeropoint\s!plus 1\s!fill \aligntab - \kern-\displaywidth + \hfill % the only one ! \span - \math_rlap{\math_text_in_eqalign{\aligncontent}}% - \tabskip\displaywidth}% + \boundary\c_math_align_r_marker + \math_alignment_lbox{\aligncontent}% + \tabskip\zeropoint}% + \orelse\ifnum\c_strc_math_ragged_status=\plusone + \ifnum\c_strc_math_number_variant=\plusone + \t_math_align_c + {\hfil + \tabskip\stretchingfillskip + \aligntab + \span + \boundary\c_math_align_r_marker + \math_alignment_lbox{\aligncontent}% + \tabskip\zeropoint}% + \else + \t_math_align_c + {\hfil + \tabskip\zeropoint + \aligntab + \span + \boundary\c_math_align_r_marker + \math_alignment_lbox{\aligncontent}% + \tabskip\stretchingfillskip}% + \fi \else \t_math_align_c {\hfil - \tabskip\centering + \tabskip\centeringskip % fails in some cases \aligntab - \kern-\displaywidth \span - \rlap{\math_text_in_eqalign{\aligncontent}}% - \tabskip\displaywidth}% + \boundary\c_math_align_r_marker + \math_alignment_lbox{\aligncontent}% + \tabskip\zeropoint}% \fi \math_build_eqalign \the\mathdisplayaligntweaks - \tabskip\centering} + \tabskip\zeropoint} + +% \def\math_halign_checked_nop +% {\halign +% \ifconditional\c_math_align_overflow_mode +% callback +% attr +% \mathnumberlocationattribute +% \numexpr\ifconditional\c_math_align_reformat_mode\plusfour\else\plustwo\fi * \plussixteen\relax % just a signal +% \fi} +% +% \def\math_halign_checked_yes +% {\math_halign_checked_nop +% \ifcase\c_strc_formulas_check_width\else +% to \checkeddisplaywidth +% \fi} +% +% \def\math_halign_checked +% {\ifnum\c_strc_formulas_place_number_mode =\plusthree \math_halign_checked_yes \orelse +% \ifnum\c_strc_formulas_number_mode =\plusthree \math_halign_checked_yes \orelse +% \ifnum\c_strc_formulas_sub_number_mode =\plusthree \math_halign_checked_yes \orelse +% \ifnum\c_strc_formulas_nested_number_mode=\plusthree \math_halign_checked_yes \else +% \math_halign_checked_nop \fi} \def\math_halign_checked - {\halign \ifcase\eqalignmode \or to \checkeddisplaywidth \fi} - -\def\math_both_eqalign_no_normal#1#2% - {\ifmmode - \the\mathdisplayaligntweaks - \vcenter\bgroup - \enforced\let\math_finish_eqalign_no\egroup - \else - \enforced\let\math_finish_eqalign_no\relax - \fi - #1% - \math_halign_checked\expandafter\bgroup\the\scratchtoks\crcr#2\crcr\egroup - \math_finish_eqalign_no} - -\installcorenamespace {mathalignlocation} - -\defcsname\??mathalignlocation\v!top \endcsname{\let\math_alignment_halign_method\halign\tpack} -\defcsname\??mathalignlocation\v!bottom\endcsname{\let\math_alignment_halign_method\halign\vpack} -\defcsname\??mathalignlocation\v!center\endcsname{\let\math_alignment_halign_method\halign\vcenter} - -\let\math_alignment_halign_method\relax - -\def\math_both_eqalign_no_aligned#1% - {\let\math_alignment_halign_method\math_halign_checked - \ifmmode - \the\mathdisplayaligntweaks - \global\mathnumberstatus\plusone - \ifcase\mathraggedstatus - \def\math_finish_eqalign_no{\crcr\egroup}% - \else % we're in a mathbox - \ifcsname\??mathalignlocation\mathalignmentparameter\c!location\endcsname - \lastnamedcs % top|bottom|center as suggested by HM - \else - \vcenter - \fi - \bgroup - \def\math_finish_eqalign_no{\crcr\egroup\egroup}% + {\halign + \ifconditional\c_math_align_overflow_mode + callback + attr + \mathnumberlocationattribute + \numexpr\ifconditional\c_math_align_reformat_mode\plusfour\else\plustwo\fi * \plussixteen\relax % just a signal \fi - \fi - #1% - \math_alignment_halign_method\expandafter\bgroup\the\scratchtoks\crcr} - -\def\math_rlap#1% - {\setbox\scratchbox\hbox{#1}% - \ifdim\wd\scratchbox>\d_math_number_correction - \global\d_math_number_correction\wd\scratchbox - \fi - \box\scratchbox - \global\mathnumberstatus\plustwo} + \ifcase\c_strc_formulas_check_width\else + to \checkeddisplaywidth + \fi} -\def\math_handle_eqalign_no_r_normal {\math_both_eqalign_no_normal \math_prepare_r_eqalign_no} -\def\math_handle_eqalign_no_l_normal {\math_both_eqalign_no_normal \math_prepare_l_eqalign_no} -\def\math_handle_eqalign_no_r_aligned{\math_both_eqalign_no_aligned\math_prepare_r_eqalign_no} -\def\math_handle_eqalign_no_l_aligned{\math_both_eqalign_no_aligned\math_prepare_l_eqalign_no} -\def\math_finish_eqalign_no {\crcr\egroup} +\installcorenamespace {mathalignlocation} -\aliased\let\reqalignno\relax % just in case someone used that -\aliased\let\leqalignno\relax % just in case someone used that -\aliased\let\eqalignno \relax % just in case someone used that +\defcsname\??mathalignlocation\v!top \endcsname{\tpack } +\defcsname\??mathalignlocation\v!bottom\endcsname{\vpack } +\defcsname\??mathalignlocation\v!center\endcsname{\vcenter} %D Here we implement the user interface part. We start with basic math alignments: @@ -297,6 +388,37 @@ \newtoks \everymathalignment \newtoks \everymathalignmentdone +\newdimen\d_math_eqalign_number_threshold + +\definesystemattribute[mathnumberlocation] [public] +\definesystemattribute[mathnumberthreshold][public] + +\protected\def\math_alignment_lbox#1% + {\begingroup + \setbox\scratchbox\hbox{\letformulaparameter\c!location\empty#1}% + \ifzeropt\wd\scratchbox\else + \hpack + \s!attr \mathnumberlocationattribute \numexpr\c_strc_math_ragged_status * \plussixteen + \plusone\relax + \s!attr \mathnumberthresholdattribute \numexpr\d_math_eqalign_number_threshold\relax + {\strc_formulas_add_distance \plustwo\v!left\mathalignmentparameter + \box\scratchbox}% + \fi + \global\d_math_eqalign_number_threshold\zeropoint % move to begin of row + \endgroup} + +\protected\def\math_alignment_rbox#1% + {\begingroup + \setbox\scratchbox\hbox{\letformulaparameter\c!location\empty#1}% + \ifzeropt\wd\scratchbox\else + \hpack + \s!attr \mathnumberlocationattribute \numexpr\c_strc_math_ragged_status * \plussixteen + \plustwo\relax + \s!attr \mathnumberthresholdattribute \numexpr\d_math_eqalign_number_threshold\relax + {\box\scratchbox + \strc_formulas_add_distance \plustwo\v!right\mathalignmentparameter}% + \fi + \global\d_math_eqalign_number_threshold\zeropoint % move to begin of row + \endgroup} + \permanent\tolerant\protected\def\math_alignment_NN[#1]#*[#2]% {\aligntab \strc_formulas_place_number_nested{#1}{#2}} @@ -347,6 +469,7 @@ \enforced\let\NR\math_alignment_NR \enforced\let\TB\math_common_TB \global\settrue\c_math_eqalign_first + \global\s_strc_math_alignment_inbetween\zeroskip \to \everymathalignment \appendtoks @@ -355,6 +478,7 @@ \pop_macro_EQ \pop_macro_NN \pop_macro_NC + \global\s_strc_math_alignment_inbetween\zeroskip \to \everymathalignmentdone % % experimental: @@ -393,11 +517,30 @@ % % [align=2:right] % % [align={1:left,2:middle,3:right}] +\newskip\s_strc_math_alignment_inbetween + +\def\strc_math_setup_spacing_aligned#1% + {\begingroup + % here we abuse the whitespace setter + \edef\v_spac_whitespace_current{#1\c!spaceinbetween}% + \ifempty\v_spac_whitespace_current + \global\s_strc_math_alignment_inbetween\zeroskip + \else + \spac_whitespace_setup + \global\s_strc_math_alignment_inbetween\parskip + \fi + \endgroup} + \permanent\tolerant\protected\def\math_alignment_start[#1]#*[#2]% {\begingroup \edef\currentmathalignment{#1}% \ifarguments\or\or - \setupmathalignment[#1][#2]% bad! ungrouped + \setupmathalignment[#1][#2]% + \fi + \ifcstok{\mathalignmentparameter\c!adaptive}\v!yes + \settrue\c_math_align_reformat_mode + \else + \setfalse\c_math_align_reformat_mode \fi \math_alignment_snap_start \the\everymathalignment @@ -408,12 +551,29 @@ [\mathalignmentparameter\c!align]% {\advance\c_math_eqalign_column\plusone\math_eqalign_set_column}% takes argument \global\c_math_eqalign_column\plusone + \strc_math_setup_spacing_aligned\mathalignmentparameter \dostarttagged\t!math\empty \dostarttagged\t!mtable\currentmathalignment - \numberedeqalign} + % is this check still valid? + \ifmmode + % we're always in mathmode + \the\mathdisplayaligntweaks + \ifcsname\??mathalignlocation\mathalignmentparameter\c!location\endcsname + \lastnamedcs % top|bottom|center as suggested by HM + \else + \vcenter + \fi + \fi + \bgroup + \ifcstok{\formulaparameter\c!location}\v!left + \math_prepare_l_eqalign_no + \else + \math_prepare_r_eqalign_no + \fi + \math_halign_checked\expandafter\bgroup\the\scratchtoks\crcr} \def\math_alignment_stop % can be protected - {\math_finish_eqalign_no + {\crcr\egroup\egroup \dostoptagged \dostoptagged \the\everymathalignmentdone @@ -426,8 +586,8 @@ \installcommandhandler \??mathalignment {mathalignment} \??mathalignment \appendtoks - \frozen\protected\instance\edefcsname\e!start\currentmathalignment\endcsname{\math_alignment_start[\currentmathalignment]}% - \noaligned\frozen\protected\instance \defcsname\e!stop \currentmathalignment\endcsname{\math_alignment_stop}% can this be protected now? + \frozen\protected\instance\edefcsname\e!start\currentmathalignment\endcsname{\math_alignment_start[\currentmathalignment]}% + \noaligned\frozen\protected\instance \defcsname\e!stop \currentmathalignment\endcsname{\math_alignment_stop}% \to \everydefinemathalignment % to be tested @@ -441,31 +601,17 @@ [\c!n=2, \c!m=1, \c!distance=\emwidth, - \c!spaceinbetween=.25\bodyfontsize, + \c!spaceinbetween=\formulaparameter\c!spaceinbetween, + \c!numberthreshold=\zeropoint, \c!grid=\v!math] \definemathalignment[align] % default case (this is what amstex users expect) \definemathalignment[\v!mathalignment] % prefered case (this is cleaner, less clashing) -% this needs some consideration: - -\def\math_align_openup{\math_openup\mathalignmentparameter\c!spaceinbetween\relax} - -\let\math_display_align_hack_indeed\relax +% this needs some consideration, it might be obsolete now: -\protected\def\math_display_align_hack % I don't like the global, maybe we should push and pop - {\glet\math_display_align_hack_indeed\math_display_align_hack_remove_skip - \math_align_openup - \everycr{\noalign{\math_display_align_hack_indeed}}} - -\def\math_display_align_hack_remove_skip - {\ifdim\prevdepth>-\thousandpoint - \vskip\dimexpr-\lineskiplimit+\normallineskiplimit\relax - \fi - \glet\math_display_align_hack_indeed\math_display_align_hack_insert_penalty} - -\def\math_display_align_hack_insert_penalty - {\penalty\interdisplaylinepenalty} +\protected\def\math_display_align_hack + {\everycr{\noalign{\penalty\interdisplaylinepenalty}}} \appendtoks \math_display_align_hack @@ -517,11 +663,6 @@ % -\permanent\protected\def\numberedeqalign - {\doifelse{\formulaparameter\c!location}\v!left - \math_handle_eqalign_no_l_aligned - \math_handle_eqalign_no_r_aligned} - \def\math_first_in_eqalign {\global\c_math_eqalign_column\plusone \global\advance\c_math_eqalign_row\plusone @@ -538,6 +679,8 @@ \ifcase\lastnamedcs \or \relax \or \hfill \or \hfill \fi \orelse\ifcsname\??mathalignmentvariant\number\zerocount\endcsname \ifcase\lastnamedcs \or \relax \or \hfill \or \hfill \fi + \orelse\ifcsname\??mathalignmentvariant\number\numexpr\c_math_eqalign_column-\c_math_eqalign_repeat\relax\endcsname + \ifcase\lastnamedcs \or \relax \or \hfill \or \hfill \fi \fi} \def\math_right_of_eqalign @@ -545,6 +688,8 @@ \ifcase\lastnamedcs \or \hfill \or \relax \or \hfill \fi \orelse\ifcsname\??mathalignmentvariant\number\zerocount\endcsname \ifcase\lastnamedcs \or \hfill \or \relax \or \hfill \fi + \orelse\ifcsname\??mathalignmentvariant\number\numexpr\c_math_eqalign_column-\c_math_eqalign_repeat\relax\endcsname + \ifcase\lastnamedcs \or \hfill \or \relax \or \hfill \fi \fi} \newconditional\c_math_alignment_local_number % not used but when true puts in front (todo) @@ -597,9 +742,6 @@ \letcsname\??mathalignmentvariant\v!right \endcsname\plustwo \letcsname\??mathalignmentvariant\v!middle\endcsname\plusthree -\permanent\protected\def\math_align_NR_generic[#1][#2]% - {\strc_formulas_place_number_nested{#1}{#2}\crcr} - %D \starttyping %D \placeformula[eqn0]\startformula \startalign[n=1] a\NR \stopalign \stopformula See \in[eqn0] %D \placeformula[eqn1]\startformula \startalign[n=1] a\NR \stopalign \stopformula See \in[eqn1] @@ -608,17 +750,6 @@ %D \stoptyping %D \startbuffer -%D \placeformula \startformula \eqalignno { -%D a &= b & \formulanumber \cr -%D c &= d \cr -%D &= e \cr -%D &= f & \formulanumber -%D } \stopformula -%D \stopbuffer -%D -%D \typebuffer \getbuffer -%D -%D \startbuffer %D \placeformula \startformula \startalign %D \NC a \EQ b \NR[+] %D \NC c \EQ d \NR @@ -743,6 +874,7 @@ \setupmathcases [\c!distance=\emwidth, \c!strut=\v!yes, % new + \c!spaceinbetween=\mathalignmentparameter\c!spaceinbetween, %\c!numberdistance=2.5\emwidth, \c!numberdistance=\zeropoint] @@ -802,7 +934,7 @@ \ifmmode\stopimath\fi \aligntab \global\c_math_cases_nc\zerocount - \math_align_NR_generic[#1][#2]} + \strc_formulas_place_number_nested{#1}{#2}\crcr} \installglobalmacrostack\c_math_cases_nc @@ -835,7 +967,8 @@ \global\c_math_eqalign_column\plusone \global\c_math_eqalign_row\plusone \global\c_math_cases_nc\zerocount - \halign\bgroup + \strc_math_setup_spacing_aligned\mathcasesparameter + \halign callback \s!attr \mathnumberlocationattribute \zerocount \bgroup \ifmmode\else\startimath\fi \mathcasesparameter\c!style \aligncontent @@ -1007,7 +1140,7 @@ \def\math_matrix_anchor {\ifcase\c_math_matrix_anchor_mode\else - \markanchor{matrix}{\numexpr\c_math_eqalign_column+1\relax}\c_math_eqalign_row + \markanchor{matrix}{\numexpr\c_math_eqalign_column+\plusone\relax}\c_math_eqalign_row \fi} \protected\def\math_matrix_anchor_first @@ -1042,6 +1175,7 @@ \aligntab \aligntab \math_matrix_anchor + \hskip.5\d_math_eqalign_distance \aligncontent \aligntab \global\advance\c_math_eqalign_column\plusone @@ -1065,7 +1199,6 @@ \permanent\protected\def\math_matrix_pickup{\global\settrue \c_math_matrix_first} \permanent\protected\def\math_matrix_NC_yes{\global\setfalse\c_math_matrix_first} -%permanent\protected\def\math_matrix_NC_nop{\aligntab} % avoids lookahead \permanent\protected\def\math_matrix_NC_nop{\aligntab\aligntab} % avoids lookahead @@ -1119,12 +1252,11 @@ \dontleavehmode \fi \bgroup - \tabskip.5\d_math_eqalign_distance + %\tabskip.5\d_math_eqalign_distance + \tabskip\zeropoint \math_matrix_pickup \the\everymathmatrix % - % \enforced\let\endmath\relax - % \setbox\nextbox\vbox\bgroup \math_matrix_start_table \halign \bgroup @@ -1594,42 +1726,12 @@ {\defcsname\??mathinnerstart#1\endcsname{#2}% \defcsname\??mathinnerstop #1\endcsname{#3}} -\installtextracker - {formulas.boxes} - {\enforced\let\math_hbox\ruledhbox} - {\enforced\let\math_hbox\hbox} - -\let\math_hbox\hbox - -\newconstant\mathraggedstatus % normal left center right -\newconstant\mathnumberstatus % nothing normal shift_right - -\newdimen\d_math_number_correction - -\def\math_box_llapped_math_no - {\ifcase\mathraggedstatus\or - \box\b_strc_formulas_number - \or - \llap{\box\b_strc_formulas_number}% - \or - \llap{\box\b_strc_formulas_number}% - \fi} +\def\strc_math_flush_number_box{\box\b_strc_formulas_number} -\def\math_box_rlapped_math_no - {\ifcase\mathraggedstatus\or - \rlap{\box\b_strc_formulas_number}% - \or - \rlap{\box\b_strc_formulas_number}% - \or - \box\b_strc_formulas_number - \fi} - -\newconditional\c_strc_math_has_number \newconditional\c_strc_math_display_overflow \newconstant \c_strc_math_number_location -\newdimen \d_strc_math_number_width +\newconstant \c_strc_math_number_variant \newdimen \d_strc_math_display_width -\newbox \b_strc_math_display \newconstant \c_strc_formulas_frame_mode \newdimen \d_strc_math_indent \newconditional\c_strc_math_indent @@ -1646,31 +1748,132 @@ % mode: 0=no frame | 1=number inside frame | 2=number outside frame -\protected\def\strc_math_flush_aligned - {\ifcase\c_strc_math_vertical - \ifcase\mathraggedstatus\or\hfill\or\hfill\fi - \box\b_strc_math_display - \ifcase\mathraggedstatus\or\or\hfill\or\hfill\fi - \else - \begincsname\??mathtextalign\formulaparameter\c!textalign:\v!start\endcsname - \ifconditional\c_strc_math_indent - \ifzeropt\d_strc_math_indent\else - \hangafter\plusone - \hangindent\d_strc_math_indent +% it is a bit of a mess because we solve all kind of bordercases but at some +% point it will become clean + +\def\strc_math_flush_aligned_boxed_direct_yes + {\dontleavehmode + \box\b_strc_math_display + \llap{\box\b_strc_formulas_number}} + +\def\strc_math_flush_aligned_boxed_direct_nop + {\dontleavehmode + \box\b_strc_math_display} + +\protected\def\strc_math_flush_aligned_boxed + {\ifcase\c_strc_math_ragged_status + % align: error + \strc_math_flush_aligned_boxed_direct_yes + \or + % align: flushleft, number right + \strc_math_flush_aligned_boxed_direct_yes + \or + % align: middle + \ifnum\c_strc_math_split_mode=\c_strc_math_line_mode + \leftskip \zeropoint + \rightskip\zeropoint + \strc_math_flush_aligned_boxed_direct_yes + \else +% \dontleavehmode +% \ifnum\c_strc_math_split_mode=\c_strc_math_wrap_mode +% \vbox\bgroup % to be tested, maybe \vcenter +% \fi +% \ifvbox\b_strc_math_display\unvbox\else\box\fi\b_strc_math_display +% \setbox\b_strc_formulas_number\hbox to \displaywidth{\hss\hbox{\box\b_strc_formulas_number}}% +% \boxyoffset\b_strc_formulas_number\d_strc_math_last_depth % todo: use anchors instead +% \htdp\b_strc_formulas_number\zeropoint +% \box\b_strc_formulas_number +% \ifnum\c_strc_math_split_mode=\c_strc_math_wrap_mode +% \egroup +% \fi + \ifnum\c_strc_math_split_mode=\c_strc_math_wrap_mode + \dontleavehmode + \vbox\bgroup % to be tested, maybe \vcenter + \orelse\ifhmode + \dontleavehmode + \box\b_strc_math_display + \orelse\ifvbox\b_strc_math_display + \unvbox\b_strc_math_display + \else + \dontleavehmode + \box\b_strc_math_display + \fi + \setbox\b_strc_formulas_number\hbox to \displaywidth{\hss\hbox{\box\b_strc_formulas_number}}% + \boxyoffset\b_strc_formulas_number\d_strc_math_last_depth % todo: use anchors instead + \htdp\b_strc_formulas_number\zeropoint + \box\b_strc_formulas_number + \ifnum\c_strc_math_split_mode=\c_strc_math_wrap_mode + \egroup + \fi + \fi + \or + % align: flushright + % packaged, number (kind of ugly as we now stick in the margin) + \ifcase\c_strc_math_n_of_lines\or + \dontleavehmode + \kern-\wd\b_strc_formulas_number + \box\b_strc_math_display + \ifcase\c_strc_math_n_of_lines\or + \box\b_strc_formulas_number + \else + \llap{\box\b_strc_formulas_number}% + \fi + \orelse\iftrue % can become option + \ifdim\d_strc_math_last_width>\wd\b_strc_formulas_number + \ifdim\d_strc_math_max_width<\d_strc_math_last_width + \strc_math_flush_aligned_boxed_direct_yes + \else + \dontleavehmode + \kern-\wd\b_strc_formulas_number + \box\b_strc_math_display + \box\b_strc_formulas_number + \fi + \else + % delay number till later + \strc_math_flush_aligned_boxed_direct_nop \fi + \else + % delay number till later + \strc_math_flush_aligned_boxed_direct_nop \fi - \edef\p_interlinespace{\formulaparameter\c!interlinespace}% - \edef\p_spaceinbetween{\formulaparameter\c!spaceinbetween}% - \ifempty\p_interlinespace\else\baselineskip\p_interlinespace\fi - \ifempty\p_spaceinbetween\else\lineskip \p_spaceinbetween\lineskiplimit\baselineskip\fi - \global\d_strc_math_indent\zeropoint - \ifcase\mathraggedstatus\or\raggedleft\or\raggedcenter\or\raggedright\fi - \begincsname\??mathtextalign\formulaparameter\c!textalign:\v!stop\endcsname - \unhbox\b_strc_math_display + \fi + \ifvmode + \nointerlineskip + \fi} + +% \protected\def\strc_math_flush_aligned_unboxed +% {\begingroup +% \ifvbox\b_strc_math_display\unvbox\else\box\fi\b_strc_math_display +% \par +% \endgroup} + +\let\strc_math_flush_aligned_unboxed\strc_math_flush_aligned_boxed + +\protected\def\strc_math_flush_aligned_simple + {\ifcase\c_strc_math_ragged_status\or\or\hfill\or\hfill\fi + \box\b_strc_math_display + \ifcase\c_strc_math_ragged_status\or\hfill\or\hfill\or\fi} + +\protected\def\strc_math_flush_aligned + {\ifnum\c_strc_math_split_mode=\c_strc_math_line_mode + \strc_math_flush_aligned_simple + % \strc_math_flush_aligned_boxed + \orelse\ifconditional\c_strc_math_indent + % in this case the already set text align is overloaded + \strc_math_setup_align_auto + \strc_math_flush_aligned_unboxed + \else + % normally we don't end up here + \strc_math_setup_spacing_aligned\mathalignmentparameter + \begingroup + \forgetall + \unhbox\b_strc_math_display + \par + \endgroup \fi} \def\strc_math_flush_box_normal - {\ifcase\c_strc_math_vertical + {\ifnum\c_strc_math_split_mode=\c_strc_math_line_mode \hbox to \displaywidth\bgroup \strc_math_flush_aligned \egroup @@ -1683,9 +1886,9 @@ \setformulaframedparameter\c!align{\formulaparameter\c!align}% \letformulaframedparameter\c!strut\v!no \d_framed_formula\ht\b_strc_math_display - \ifcase\mathraggedstatus\or\hfill\or\hfill \fi + \ifcase\c_strc_math_ragged_status\or \or\hfill\or\hfill\fi \inheritedformulaframedframed{\box\b_strc_math_display}% - \ifcase\mathraggedstatus\or \or\hfill\or\hfill\fi} + \ifcase\c_strc_math_ragged_status\or\hfill\or\hfill \fi} \def\strc_math_flush_box_framed_display {\let\currentformulaframed\currentformula @@ -1707,6 +1910,9 @@ % combiners +\def\strc_math_flush_number_box_left {\ifconditional\c_strc_formulas_overlay_number\rlap\fi{\strc_math_flush_number_box}} +\def\strc_math_flush_number_box_right{\ifconditional\c_strc_formulas_overlay_number\llap\fi{\strc_math_flush_number_box}} + \def\strc_math_flush_box {\ifcase\c_strc_formulas_frame_mode \strc_math_flush_box_normal @@ -1717,10 +1923,10 @@ \def\strc_math_number_right_normal {\strc_math_flush_aligned \hss % hss makes room for number - \math_box_llapped_math_no} + \strc_math_flush_number_box_right} \def\strc_math_number_left_normal - {\math_box_rlapped_math_no + {\strc_math_flush_number_box_left \strc_math_flush_aligned \hss} % hss makes room for number @@ -1731,10 +1937,10 @@ \strc_math_flush_box_framed_display \fi \hss % hss makes room for number - \math_box_llapped_math_no} + \strc_math_flush_number_box} \def\strc_math_number_left_normal_outside - {\math_box_rlapped_math_no + {\strc_math_flush_number_box \hss % hss makes room for number \ifconditional\c_strc_formulas_tight \strc_math_flush_box_framed_fit_display @@ -1746,13 +1952,13 @@ {\setbox\b_strc_math_display\hpack to \dimexpr\displaywidth-\d_framed_locator_lo-\d_framed_locator_ro\relax\bgroup \strc_math_flush_aligned \hss - \math_box_llapped_math_no + \strc_math_flush_number_box \egroup \strc_math_flush_box_framed_fit_inline} \def\strc_math_number_left_normal_inside {\setbox\b_strc_math_display\hpack to \dimexpr\displaywidth-\d_framed_locator_lo-\d_framed_locator_ro\relax\bgroup - \math_box_rlapped_math_no + \strc_math_flush_number_box \hss \strc_math_flush_aligned \egroup @@ -1764,14 +1970,14 @@ \par \hpack to \displaywidth\bgroup \hss - \math_box_llapped_math_no + \strc_math_flush_number_box_right \egroup \egroup} \def\strc_math_number_left_overflow {\vpack\bgroup \hpack to \displaywidth\bgroup - \math_box_rlapped_math_no + \strc_math_flush_number_box_left \hss \egroup \strc_math_flush_box @@ -1783,14 +1989,14 @@ %\hskip\zeropoint % nicely breaks the line without introducing funny vertical spacing ... why o why \hpack to \displaywidth\bgroup \hss - \math_box_llapped_math_no + \strc_math_flush_number_box \egroup \egroup} \def\strc_math_number_left_overflow_outside {\vpack\bgroup \hpack to \dimexpr\displaywidth-\d_framed_locator_lo\relax\bgroup - \math_box_rlapped_math_no + \strc_math_flush_number_box \hss \egroup \hskip\zeropoint % nicely breaks the line without introducing funny vertical spacing ... why o why @@ -1802,7 +2008,7 @@ \box\b_strc_math_display \hpack to \displaywidth\bgroup \hss - \math_box_llapped_math_no + \strc_math_flush_number_box \hskip\d_framed_locator_ro \egroup \egroup @@ -1812,7 +2018,7 @@ {\setbox\b_strc_math_display\vpack\bgroup \hpack to \displaywidth\bgroup % \hskip\d_framed_locator_lo - \math_box_rlapped_math_no + \strc_math_flush_number_box \hss \egroup \box\b_strc_math_display @@ -1821,17 +2027,28 @@ % checkers +\setupmathalignment + [\c!numberdistance=\formulaparameter\c!numberdistance] + +\protected\def\d_strc_math_total_display_width + {\dimexpr + \d_strc_math_display_width+\wd\b_strc_formulas_number + \ifconditional\c_strc_formulas_overlay_number + \ifcase\c_strc_math_ragged_status\or\or+\wd\b_strc_formulas_number\or\fi + \fi + \relax} + \def\strc_math_number_check {\d_strc_math_display_width\wd\b_strc_math_display \ifconditional\c_strc_formulas_tight - \ifdim\d_strc_math_display_width>\displaywidth + \ifdim\d_strc_math_total_display_width>\displaywidth \settrue\c_strc_math_display_overflow \else - \displaywidth\d_strc_math_display_width + \displaywidth\d_strc_math_total_display_width \setfalse\c_strc_math_display_overflow \fi \else - \ifdim\d_strc_math_display_width>\displaywidth + \ifdim\dimexpr\d_strc_math_total_display_width+\formulaparameter\c!numberthreshold\relax>\displaywidth \settrue\c_strc_math_display_overflow \else \setfalse\c_strc_math_display_overflow @@ -1840,13 +2057,13 @@ \def\strc_math_number_check_outside {\d_strc_math_display_width\naturalwd\b_strc_math_display - \ifdim\dimexpr\d_strc_math_display_width+\d_framed_locator_lo+\d_framed_locator_ro\relax>\displaywidth + \ifdim\dimexpr\d_strc_math_total_display_width+\d_framed_locator_lo+\d_framed_locator_ro\relax>\displaywidth \settrue\c_strc_math_display_overflow \else \setfalse\c_strc_math_display_overflow \fi % still ok? - \ifnum\mathraggedstatus=\plustwo + \ifnum\c_strc_math_ragged_status=\plustwo \d_strc_math_framed_width\dimexpr\displaywidth-2\wd\b_strc_formulas_number\relax \else \d_strc_math_framed_width\dimexpr\displaywidth- \wd\b_strc_formulas_number\relax @@ -1867,7 +2084,7 @@ \def\strc_math_traced_state_yes {\llap{\setbox\scratchbox\hbox{\infofont - \ifcase\mathraggedstatus unset\or right\or middle\or left\fi + \ifcase\c_strc_math_ragged_status unset\or flushleft\or middle\or flushright\fi \space \ifcase\c_strc_formulas_frame_mode no\or out\or in\fi \space @@ -1883,24 +2100,85 @@ % packaging +\installcorenamespace{mathboxlocation} + +\defcsname\??mathboxlocation\v!left \endcsname + {\c_strc_math_number_location\plusone} + +\defcsname\??mathboxlocation\v!right\endcsname + {\c_strc_math_number_location\plustwo} + +\defcsname\??mathboxlocation\v!atrightmargin\endcsname + {\c_strc_math_number_location\plustwo + \c_strc_math_number_variant \plusone} + \protected\def\strc_math_box_start#1% - {\hsize\displaywidth % \checkeddisplaymath - \global\mathnumberstatus\plusone - \mathraggedstatus#1\relax - % - \global\d_math_number_correction\zeropoint - % - \edef\p_location{\formulaparameter\c!location}% + {\c_strc_math_ragged_status#1\relax % already set \useformulacolorparameter\c!color - \c_strc_math_number_location\ifx\p_location\v!left\plusone\orelse\ifx\p_location\v!right\plustwo\else\zerocount\fi + \c_strc_math_number_location\zerocount + \c_strc_math_number_variant \zerocount + \begincsname\??mathboxlocation\formulaparameter\c!location\endcsname + % + % We collect the math formula in an hbox. Dimensions don't really play + % a role yet but beware of nesting! % - %\strc_formulas_place_number % not here as we can have inner alignment numbers \dontcomplain - \setbox\b_strc_math_display\math_hbox\bgroup % \checkeddisplaymath + %\holdingmigrations\plusfour + \setbox\b_strc_math_display\hbox retain \plusfour\bgroup \startforceddisplaymath} +\protected\def\strc_math_box_stop + {\stopforceddisplaymath + \egroup + % preroll left and right offsets + \ifcase\c_strc_formulas_frame_mode + % no frame + \else + \strc_math_number_check_offsets + \fi + \ifcase\c_strc_formulas_frame_mode + \strc_math_number_check + \or + \strc_math_number_check_outside + \else + \strc_math_number_check_inside + \fi + \strc_math_traced_state + \ifnum\c_strc_math_split_mode=\c_strc_math_line_mode + \noindent % \noindentation % not \dontleavehmode + \hbox to \displaywidth \bgroup + \else + \bgroup + \strc_math_show_margins + \fi + \ifcase\c_strc_math_number_location + \strc_math_flush_box + \or % number left + \ifzeropt\wd\b_strc_formulas_number + \strc_math_flush_number_no + \else + \strc_math_flush_number_left + \fi + \else % number right + \ifzeropt\wd\b_strc_formulas_number + \strc_math_flush_number_no + \else + \strc_math_flush_number_right + \fi + \fi + \egroup} + +\defineinnermathhandler\v!left {\strc_math_box_start\plusthree}{\strc_math_box_stop} +\defineinnermathhandler\v!flushright{\strc_math_box_start\plusthree}{\strc_math_box_stop} +\defineinnermathhandler\v!right {\strc_math_box_start\plusone }{\strc_math_box_stop} +\defineinnermathhandler\v!flushleft {\strc_math_box_start\plusone }{\strc_math_box_stop} +\defineinnermathhandler\v!center {\strc_math_box_start\plustwo }{\strc_math_box_stop} +\defineinnermathhandler\v!middle {\strc_math_box_start\plustwo }{\strc_math_box_stop} +\defineinnermathhandler\v!normal {\strc_math_box_start\plustwo }{\strc_math_box_stop} +\defineinnermathhandler\v!atmargin {\strc_math_box_start\plusfour }{\strc_math_box_stop} + \def\strc_math_flush_number_no - {\ifcase\c_strc_math_vertical + {\ifnum\c_strc_math_split_mode=\c_strc_math_line_mode \ifconditional\c_strc_math_display_overflow \ifcase\c_strc_formulas_frame_mode \strc_math_flush_box_normal @@ -1927,7 +2205,7 @@ \fi} \def\strc_math_flush_number_left - {\ifcase\c_strc_math_vertical + {\ifnum\c_strc_math_split_mode=\c_strc_math_line_mode \ifconditional\c_strc_math_display_overflow \ifcase\c_strc_formulas_frame_mode \strc_math_number_left_overflow @@ -1952,7 +2230,7 @@ \fi} \def\strc_math_flush_number_right - {\ifcase\c_strc_math_vertical + {\ifnum\c_strc_math_split_mode=\c_strc_math_line_mode \ifconditional\c_strc_math_display_overflow \ifcase\c_strc_formulas_frame_mode \strc_math_number_right_overflow @@ -1976,86 +2254,6 @@ \box\b_strc_formulas_number \fi} -\protected\def\strc_math_box_stop - {\stopforceddisplaymath - \egroup - % check number - \d_strc_math_number_width\wd\b_strc_formulas_number - % - \ifcase\mathnumberstatus - \setfalse\c_strc_math_has_number - \or\ifzeropt\d_strc_math_number_width - \setfalse\c_strc_math_has_number - \else - \settrue\c_strc_math_has_number - \fi\fi - % preroll left and right offsets - \ifcase\c_strc_formulas_frame_mode - % no frame - \else - \strc_math_number_check_offsets - \fi - \ifcase\c_strc_formulas_frame_mode - \strc_math_number_check - \or - \strc_math_number_check_outside - \else - \strc_math_number_check_inside - \fi - \noindent % \noindentation % not \dontleavehmode - \hskip\d_strc_formulas_display_margin_left % was kern but that doesn't indent - \strc_math_traced_state - \ifcase\c_strc_math_vertical - \hbox to \displaywidth \bgroup - \or % yes - \vbox \bgroup \hsize\displaywidth - \or % page - \bgroup \hsize\displaywidth - \or % text - \bgroup \hsize\displaywidth - \fi - \ifcase\mathnumberstatus - \strc_math_flush_box - \or % status 1 - \ifcase\c_strc_math_number_location - \strc_math_flush_box - \or % number left - \ifzeropt\wd\b_strc_formulas_number - \strc_math_flush_number_no - \else - \strc_math_flush_number_left - \fi - \else % number right - \ifzeropt\wd\b_strc_formulas_number - \strc_math_flush_number_no - \else - \strc_math_flush_number_right - \fi - \fi - \or % status 2 - \hskip\d_math_number_correction % probably no longer used - \strc_math_flush_box - \hss - \else - \strc_math_flush_box - \fi - \ifcase\c_strc_math_vertical - \or - \or - \par - \or - \par - \fi - \egroup} - -\defineinnermathhandler\v!left {\strc_math_box_start\plusone }{\strc_math_box_stop} -\defineinnermathhandler\v!middle {\strc_math_box_start\plustwo }{\strc_math_box_stop} -\defineinnermathhandler\v!right {\strc_math_box_start\plusthree}{\strc_math_box_stop} -\defineinnermathhandler\v!flushleft {\strc_math_box_start\plusthree}{\strc_math_box_stop} -\defineinnermathhandler\v!center {\strc_math_box_start\plustwo }{\strc_math_box_stop} -\defineinnermathhandler\v!flushright{\strc_math_box_start\plusone }{\strc_math_box_stop} -\defineinnermathhandler\v!normal {\strc_math_box_start\plustwo }{\strc_math_box_stop} - %D Some inline math tweak. \appendtoks @@ -2121,7 +2319,7 @@ \appendtoks \edef\p_threshold{\mathematicsparameter\c!threshold}% \maththreshold\ifcsname\??maththreshold\p_threshold\endcsname\lastnamedcs\else\p_threshold\fi\relax -\to \everymath % \everyemathematics +\to \everymath % \everymathematics %D Here is simple alignment mechanism: @@ -2135,6 +2333,8 @@ \c!rightmargin=\zeropoint, \c!left=, \c!right=, + \c!strut=\v!yes, + \c!spaceinbetween=\mathalignmentparameter\c!spaceinbetween, \c!align=\v!all:\v!middle, \c!textdistance=.25\emwidth] @@ -2148,7 +2348,7 @@ \noaligned\tolerant\permanent\protected\def\math_simplealign_NR[#1]#*[#2]% {\unskip - \math_align_NR_generic[#1][#2]} + \strc_formulas_place_number_nested{#1}{#2}\crcr} \permanent\tolerant\protected\def\math_simplealign_start[#1]#*[#2]% {\begingroup @@ -2178,20 +2378,23 @@ \global\c_math_eqalign_column\zerocount \global\c_math_eqalign_row\plusone \edef\m_simplealign_distance{\mathsimplealignparameter\c!distance}% - \halign\bgroup + \strc_math_setup_spacing_aligned\mathcasesparameter + \halign callback \s!attr \mathnumberlocationattribute \zerocount \bgroup \global\c_math_eqalign_column\zerocount \global\advance\c_math_eqalign_row\zerocount \ignorespaces \aligncontent % dummy \removeunwantedspaces + \lastleftclass \mathbegincode + \lastrightclass\mathendcode \aligntab \global\advance\c_math_eqalign_column\plusone \math_left_of_eqalign % \hfil \ignorespaces \math_align_strut - \startimath + \startforceddisplaymath \aligncontent - \stopimath + \stopforceddisplaymath \removeunwantedspaces \math_right_of_eqalign % \hfil \aligntab @@ -2205,9 +2408,9 @@ \fi \ignorespaces \math_align_strut - \startimath + \startforceddisplaymath \aligncontent - \stopimath + \stopforceddisplaymath \removeunwantedspaces \math_right_of_eqalign % \hfil \crcr} @@ -2252,6 +2455,15 @@ %D \stopformula %D \stoptyping +%D Usage \type {\sum _ {\mstack {i \in V_{0}, i \neq j}}}, documented by Mikael: + +\permanent\protected\def\mstack#1% + {\begingroup + \scratchtoks\emptytoks \setcharstrut(\relax + \processcommalist[#1]{\iftok\scratchtoks\emptytoks\else\toksapp\scratchtoks{\strut\NR}\fi\toksapp\scratchtoks}% + \expandafter\startsubstack\the\scratchtoks\strut\stopsubstack + \endgroup} + \protect \endinput % \placeformula \startformula[-] \startmatrix diff --git a/tex/context/base/mkxl/math-com.mkxl b/tex/context/base/mkxl/math-com.mkxl new file mode 100644 index 000000000..27f014d44 --- /dev/null +++ b/tex/context/base/mkxl/math-com.mkxl @@ -0,0 +1,89 @@ +%D \module +%D [ file=math-com, +%D version=2022.07.17, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Combinations, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Initializations} + +%D This module might be extended. + +\unprotect + +% \startcombination[2*2] +% \startcontent +% \startplaceformula\startformula[width=\combinationwidth,title=a]1+x\stopformula\stopplaceformula +% \stopcontent +% \startcaption\stopcaption +% \startcontent +% \startplaceformula\startformula[width=\combinationwidth,title=b]2+x\stopformula\stopplaceformula +% \stopcontent +% \startcaption\stopcaption +% \startcontent +% \startplaceformula\startformula[width=\combinationwidth,xxxxx=c]3+x\stopformula\stopplaceformula +% \stopcontent +% \startcaption\stopcaption +% \startcontent +% \startplaceformula\startformula[width=\combinationwidth,title=d]4+x\stopformula\stopplaceformula +% \stopcontent +% \startcaption\stopcaption +% \stopcombination +% +% \startplaceformula[a] +% \startcombination[formula][nx=2,ny=2] +% \startformula[width=\combinationwidth,title=a]1+x\stopformula +% \startformula[width=\combinationwidth,title=b]2+x\stopformula +% \startformula[width=\combinationwidth,xxxxx=c]3+x\stopformula +% \startformula[width=\combinationwidth,title=d]4+x\stopformula +% \stopcombination +% \stopplaceformula +% +% \startplaceformula[a] +% \startformulacombination[nx=2,ny=2] +% \startformula[width=\combinationwidth,title=a]1+x\stopformula +% \startformula[width=\combinationwidth,title=b]2+x\stopformula +% \startformula[width=\combinationwidth,xxxxx=c]3+x\stopformula +% \startformula[width=\combinationwidth,title=d]4+x\stopformula +% \stopformulacombination +% \stopplaceformula + +\defcsname\??combinationmethod\v!formula\endcsname + {\vcenter} + +\defcsname\??combinationmethod\v!formula:\v!start\endcsname + {\startformula + \dostarttagged\t!formulaset\empty + \global\settrue\c_strc_formulas_inside_formulas + \bgroup + \setupformulas[\c!width=\combinationwidth]% + \enforced\tolerant\protected\def\startformula[##1]% + {\startcontent + \strc_formulas_nested_formula_start[\c!width=\combinationwidth,##1]}% + \enforced\protected\def\stopformula + {\normalexpanded + {\strc_formulas_nested_formula_stop + \stopcontent + \startcaption + \formulaparameter\c!title + \stopcaption}}} + +\defcsname\??combinationmethod\v!formula:\v!stop\endcsname + {\egroup + \global\setfalse\c_strc_formulas_inside_formulas + \dostoptagged + \stopformula + \the\everyresetformulas} + +\definecombination[\v!formula][method=formula,width=\hsize] + +\protected\def\startformulacombination{\startcombination[\v!formula]} +\protected\def\stopformulacombination {\stopcombination} + +\protect diff --git a/tex/context/base/mkxl/math-dif.mkxl b/tex/context/base/mkxl/math-dif.mkxl new file mode 100644 index 000000000..5cd65a80f --- /dev/null +++ b/tex/context/base/mkxl/math-dif.mkxl @@ -0,0 +1,39 @@ +%D \module +%D [ file=math-dif, +%D version=2022.05.31, % moved code +%D title=\CONTEXT\ Math Macros, +%D subtitle=Differentials, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Differentials} + +\unprotect + +\pushoverloadmode + + % For new times sake: + + \let\normal_math_dd\dd + + \def\c!differentiald{differentiald} % for now + + \def\upright_math_dd{\mathatom \s!unpack \mathdifferentialcode{\mathupright d}} + + \permanent\protected\def\dd + {\ifcstok{\mathematicsparameter\c!differentiald}\s!upright + \upright_math_dd + \else + \normal_math_dd + \fi} + + % \setupmathematics[differentiald=upright] + +\popoverloadmode + +\protect diff --git a/tex/context/base/mkxl/math-fen.mkxl b/tex/context/base/mkxl/math-fen.mkxl index e1a648ba4..5725c5ee1 100644 --- a/tex/context/base/mkxl/math-fen.mkxl +++ b/tex/context/base/mkxl/math-fen.mkxl @@ -58,6 +58,9 @@ \c!color=, \c!command=, \c!mathclass=, + \c!leftclass=\mathopencode, + \c!rightclass=\mathclosecode, + \c!middleclass=\mathmiddlecode, \c!leftsource=\zerocount, \c!middlesource=\zerocount, \c!rightsource=\mathfenceparameter\c!source, @@ -141,14 +144,17 @@ \s!axis \s!exact} +\newconstant \c_math_fenced_class + \def\math_fenced_common#1#2#3#4% \Uwhatever class symbol source - {\ifconditional\c_math_fenced_sized + {\c_math_fenced_class\mathfenceparameter#2\relax + \ifconditional\c_math_fenced_sized \orelse\ifconditional\c_math_fenced_level_mode - \ifnum#2=\mathopencode + \ifnum\c_math_fenced_class=\mathopencode % \hpack{\infofont<L:\number\c_math_fenced_level:\number\c_attr_mathsize>}% \integerdef\c_math_fenced_stack\c_attr_mathsize \push_macro_c_math_fenced_stack - \orelse\ifnum#2=\mathclosecode + \orelse\ifnum\c_math_fenced_class=\mathclosecode \pop_macro_c_math_fenced_stack \c_attr_mathsize\c_math_fenced_stack % \hpack{\infofont<R:\number\c_math_fenced_level:\number\c_attr_mathsize>}% @@ -156,7 +162,7 @@ \fi \edef\p_fence{#3}% \ifempty\p_fence - #1.\relax + \ifnum\c_math_fenced_class=\mathmiddlecode\else#1.\relax\fi \else \edef\p_factor {\mathfenceparameter\c!factor}% \edef\p_size {\mathfenceparameter\c!size}% @@ -170,6 +176,9 @@ \Uvextensible \else #1% \Uleft \Umiddle \Uleft + \ifx#1\Umiddle + nooverflow % + \fi \fi \orelse\ifx\p_factor\v!auto \ifconditional\c_math_fenced_level_mode @@ -190,8 +199,10 @@ \s!class \ifx\p_fence\v!none \mathghostcode + \orelse\ifempty\p_mathclass + \c_math_fenced_class \else - \ifempty\p_mathclass#2\else\p_mathclass\fi + \p_mathclass \fi \s!source \numexpr\namedboxanchor{\mathfenceparameter#4}\relax @@ -209,15 +220,27 @@ \def\math_fenced_left {\advance\c_math_fence_nesting\plusone - \math_fenced_common\Uleft\mathopencode\math_fenced_p_left\c!leftsource} - -\def\math_fenced_middle - {\math_fenced_common\Umiddle\mathmiddlecode\math_fenced_p_middle\c!middlesource} + \math_fenced_common\Uleft\c!leftclass\math_fenced_p_left\c!leftsource} \def\math_fenced_right - {\math_fenced_common\Uright\mathclosecode\math_fenced_p_right\c!rightsource + {\math_fenced_common\Uright\c!rightclass\math_fenced_p_right\c!rightsource \advance\c_math_fence_nesting\minusone} +\def\math_fenced_middle_normal + {\math_fenced_common\Umiddle\c!middleclass\math_fenced_p_middle\c!middlesource} + +\def\math_fenced_middle_sized + {\settrue\c_math_fenced_sized + \math_fenced_middle_normal + \setfalse\c_math_fenced_sized} + +\appendtoks + \let\math_fenced_middle\math_fenced_middle_normal + \enforced\let\fence\math_fenced_direct +\to \everymathatom + +\let\math_fenced_middle\math_fenced_middle_normal + \def\math_fenced_p_left {\ifconditional\c_math_fenced_mirror \ifconditional\c_math_right_to_left @@ -246,9 +269,12 @@ \aliased\let\fence \relax \aliased\let\fenced\relax +\protected\def\math_fenced_middle_common + {\math_fenced_middle} % redefined inside atom + \protected\def\math_fenced_fenced_common {\startusemathstyleparameter\mathfenceparameter\c!mathstyle - \enforced\let\fence\math_fenced_middle} + \enforced\let\fence\math_fenced_middle_common} \protected\def\math_fenced_fenced_start#1% {\begingroup @@ -299,6 +325,8 @@ \settrue\c_math_fenced_sized \math_fenced_left \setfalse\c_math_fenced_sized + \let\math_fenced_middle\math_fenced_middle_sized + % \enforced\let\middle\math_fenced_middle_sized #1% \settrue\c_math_fenced_sized \math_fenced_right @@ -343,6 +371,18 @@ \fi \endgroup} +% for torture testing mikael sundqvist: +% +% \setupmathfence[brace][middle=124] +% +% \im{\fenced[brace] {\vec{x}\in\reals^3\middle\vert \vec{x}\neq \vec{0}}} +% \im{\fenced[brace] {\vec{x}\in\reals^3\mid \vec{x}\neq \vec{0}}} +% \im{\fenced[brace][size=0]{\vec{x}\in\reals^3\fence \vec{x}\neq \vec{0}}} + +\aliased\let\normalmid\mid + +\protected\def\mid{\ifcase\c_math_fence_nesting\normalmid\else\middle\vert\fi} + % cases are defined in math-ali: \definemathfence [cases] [\c!left="007B,\c!right=\v!none] @@ -529,15 +569,15 @@ \definemathfence [leftopeninterval] [interval] [\c!left="2997,\c!right="2997] \definemathfence [rightopeninterval] [interval] [\c!left="2998,\c!right="2998] -\immutable\protected\def\Linterval {\math_fenced_fenced_start{interval}} -\immutable\protected\def\Lointerval {\math_fenced_fenced_start{openinterval}} -\immutable\protected\def\Llointerval {\math_fenced_fenced_start{leftopeninterval}} -\immutable\protected\def\Lrointerval {\math_fenced_fenced_start{rightopeninterval}} +\immutable\protected\def\Linterval {\math_fenced_fenced_start{interval}} +\immutable\protected\def\Lointerval {\math_fenced_fenced_start{openinterval}} +\immutable\protected\def\Llointerval {\math_fenced_fenced_start{leftopeninterval}} +\immutable\protected\def\Lrointerval {\math_fenced_fenced_start{rightopeninterval}} -\immutable\protected\def\Rinterval {\math_fenced_fenced_stop {interval}} -\immutable\protected\def\Rointerval {\math_fenced_fenced_stop {openinterval}} -\immutable\protected\def\Rlointerval {\math_fenced_fenced_stop {leftopeninterval}} -\immutable\protected\def\Rrointerval {\math_fenced_fenced_stop {rightopeninterval}} +\immutable\protected\def\Rinterval {\math_fenced_fenced_stop {interval}} +\immutable\protected\def\Rointerval {\math_fenced_fenced_stop {openinterval}} +\immutable\protected\def\Rlointerval {\math_fenced_fenced_stop {leftopeninterval}} +\immutable\protected\def\Rrointerval {\math_fenced_fenced_stop {rightopeninterval}} % \startformula % \left{ \frac{1}{a} \right} @@ -570,9 +610,9 @@ {\letcsname\??mathleft \normalmeaningless#1\endcsname#2% \letcsname\??mathright\normalmeaningless#3\endcsname#4} -\def\math_unknown_left {\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalleft \nexttoken\fi} -\def\math_unknown_right {\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalright \nexttoken\fi} -\def\math_unknown_middle{\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalmiddle\nexttoken\fi} +\def\math_unknown_left {\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\Uleft \nexttoken\fi} +\def\math_unknown_right {\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\Uright \nexttoken\fi} +\def\math_unknown_middle{\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\Umiddle nooverflow \nexttoken\fi} \letcsname\??mathleft \s!unknown\endcsname\math_unknown_left \letcsname\??mathright \s!unknown\endcsname\math_unknown_right @@ -805,7 +845,7 @@ \definemathcommand [Bigg] {\choosemathbig4} \definemathcommand [bigl] [\s!open] [one] {\big} -\definemathcommand [bigm] [\s!relation] [one] {\big} +\definemathcommand [bigm] [\s!relation] [one] {\big} % why not just middle \definemathcommand [bigr] [\s!close] [one] {\big} \definemathcommand [Bigl] [\s!open] [one] {\Big} \definemathcommand [Bigm] [\s!relation] [one] {\Big} @@ -847,7 +887,7 @@ \protected\def\math_fences_auto_left #1{\c_attr_mathautofence\plusone #1\c_attr_mathautofence\attributeunsetvalue} \protected\def\math_fences_auto_right #1{\c_attr_mathautofence\plustwo #1\c_attr_mathautofence\attributeunsetvalue} -\protected\def\math_fences_auto_middle#1{\c_attr_mathautofence\plusthree#1\c_attr_mathautofence\attributeunsetvalue} +\protected\def\math_fences_auto_middle#1{\c_attr_mathautofence\plusthree#1\c_attr_mathautofence\attributeunsetvalue nooverflow } \protected\def\math_fences_auto_both #1{\c_attr_mathautofence\plusfour #1\c_attr_mathautofence\attributeunsetvalue} \permanent\let\autofenceopen \math_fences_auto_left % for testing diff --git a/tex/context/base/mkxl/math-fnt.lmt b/tex/context/base/mkxl/math-fnt.lmt index e6978d6cd..0faa006c9 100644 --- a/tex/context/base/mkxl/math-fnt.lmt +++ b/tex/context/base/mkxl/math-fnt.lmt @@ -27,6 +27,7 @@ local getid = nuts.getid local chardata = fonts.hashes.characters -- not yet ok for compact fonts .. needs checking .. or just make this non-compact only +-- there's also an inaccuracy creeping in: \sqrt{\quad\blackrule[height=25pt,depth=25pt]} local function register_extensible(font,char,style,box) local bx = tonut(box) @@ -35,14 +36,14 @@ local function register_extensible(font,char,style,box) local al = getattrlst(bx) local wd, ht, dp = getwhd(bx) local private = fonts.helpers.setboxdirectly(font,chardata[font][char].unicode or char,box) - -- local g = new_glyph(font,private) - -- setattrlst(g,al) + -- we saved a scaled glyph stream so we now use an unscaled one ... local g = new_glyph(font,private,al) local n = new_hlist(g) + -- so the dimensions of the box don't match the glyph scale! setwhd(n,wd,ht,dp) setattrlst(n,al) if id == vlist_code then - h = new_vlist(n) + n = new_vlist(n) setwhd(n,wd,ht,dp) setattrlst(n,al) end diff --git a/tex/context/base/mkxl/math-frc.mkxl b/tex/context/base/mkxl/math-frc.mkxl index 2170c8fd1..2e16e061f 100644 --- a/tex/context/base/mkxl/math-frc.mkxl +++ b/tex/context/base/mkxl/math-frc.mkxl @@ -661,35 +661,6 @@ [\c!hfactor=20, \c!vfactor=10] -%D For Mikael Sundqvist who found out that most inline fractions look real bad: - -\pushoverloadmode - -%ifdefined\d \let\text_d\d \else \let\text_d\firstofoneargument \fi -\ifdefined\f \let\text_f\f \else \let\text_f\firstofoneargument \fi - -\definemathfraction - [f] - [\c!strut=\v!math] - -% \definemathfraction -% [d] -% [\c!method=\v!line, -% \c!strut=\v!math] - -\aliased\let\math_f\f -%aliased\let\math_d\d - -\permanent\protected\def\d{\mathortext\math_d\text_d} -%permanent\protected\def\f{\mathortext\math_f\text_f} - -% \setupmathfraction -% [%strut=math, -% \c!hfactor=100, -% \c!vfactor=100] - -\popoverloadmode - \protect \endinput % I have no clue what \mthfrac and \mthsqrt are supposed to do but diff --git a/tex/context/base/mkxl/math-ini.lmt b/tex/context/base/mkxl/math-ini.lmt index 306b6585a..184e56672 100644 --- a/tex/context/base/mkxl/math-ini.lmt +++ b/tex/context/base/mkxl/math-ini.lmt @@ -51,7 +51,7 @@ local setdelcode = tex.setdelcode -- These are different from mkiv with luatex. -local classes = allocate { } +local classes = allocate { unset = 64 } -- or -1 local classnames = allocate { } local maxengineclass = 63 local lastengineclass = 0 @@ -121,21 +121,29 @@ local function registerengineclass(name,short) return class end -registerengineclass("explicit", "expl") -registerengineclass("imaginary", "img") -registerengineclass("differential","dif") -registerengineclass("exponential", "exp") -registerengineclass("function", "fnc") -registerengineclass("digit", "dig") +registerengineclass("explicit", "xpl") +registerengineclass("imaginary", "img") +registerengineclass("differential", "dif") +registerengineclass("exponential", "exp") +registerengineclass("ellipsis", "ell") +registerengineclass("function", "fnc") +registerengineclass("digit", "dig") local division_class = -registerengineclass("division", "div") -registerengineclass("factorial", "fac") -registerengineclass("wrapped", "wra") -registerengineclass("construct", "con") -registerengineclass("dimension", "dim") - -classes["begin"] = 62 classnames[62] = "begin" -classes["end"] = 63 classnames[63] = "end" +registerengineclass("division", "div") +registerengineclass("factorial", "fac") +registerengineclass("wrapped", "wra") +registerengineclass("construct", "con") +registerengineclass("dimension", "dim") +registerengineclass("textpunctuation", "tpu") +registerengineclass("unspaced") +registerengineclass("experimental") +registerengineclass("fake") + +local specialclasses = tex.specialmathclasscodes + +classes["all"] = specialclasses["all"] classnames[specialclasses["all"] ] = "all" +classes["begin"] = specialclasses["begin"] classnames[specialclasses["begin"]] = "begin" +classes["end"] = specialclasses["end"] classnames[specialclasses["end"] ] = "end" callback.register("get_noad_class", function(n) return classnames[n] end) diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index f4358d5e7..19123ab8a 100644 --- a/tex/context/base/mkxl/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -13,40 +13,54 @@ \writestatus{loading}{ConTeXt Math Macros / Initializations} -%D This module provides namespaces for math fonts, thereby permitting mixed usage of -%D math fonts. Although not strictly needed, we also provide a family name mapping -%D mechanism as used in the (original) AMS math definition files, but here these -%D names can recursively be remapped and if needed, dynamically be changed. We've -%D tried to minimize the number of definition commands and use plain \TEX\ -%D definitions as fallback. We've tried to follow a couple of conventions from plain -%D and AMS math in order to achieve backward compatinility. We also kept an eye on -%D future usage of these modules in the perspective of MathML and unicode fonts. In -%D the meantime much has been dropped in favour of better alternatives. - -%D There is a subtle issue with grouping: the \type {\begingroup} method will not -%D restore a changed mathstyle so best avoid that one. However, there are cases where -%D we really need to use such grouping. We now have \type {\beginmathgroup} etc. +%D This is the \LMTX\ version of math support what evolved over decades. We started +%D out with native display math, battled for years with the heuristic spacing, +%D assumptions wrt number locations etc. Advanced alignments were implemented with +%D the help of Aditya. In \MKIV\ everything got upgraded, and we ended up with three +%D models for spacing and numbering: traditional (display), improved (using some +%D \LUATEX\ control options), and future (using emulated display) where we also +%D could handle multi|-|line formulas well. As \LUAMETATEX\ evolved it became clear +%D that we should drop the first two models completely and stick to the emulated +%D display mode combined with the ability to format multi|-|line formulas in greater +%D detail. +%D +%D One can wonder what this does with compatibility. Of course we try to be +%D interface compatible but better micro typography spacing has consequences. +%D However, in practice it looks like we get better results without too many side +%D effects. Also, we're not bound to for instance \AMS\ math because \CONTEXT\ is +%D not used by scientific publishers. In fact over the 15 plus years of development +%D (2022), no professional publisher (or large scale \TEX\ user) ever expressed +%D interest in \LUATEX\ and \LUAMETATEX, definitely not in relation to math, which +%D made it even more easy to upgrade the engine as well as \CONTEXT\ math and over +%D time users have demonstrated to appreciate improvements. We can do as we like, as +%D long as users like it too. It's with that mindset that Mikael Sundqvist and I +%D undertook this effort which took a year to mature. It started out with +%D implementing advanced spacing models based on inter|-|atom properties and control +%D but stepwise more got added and improved. We also settled on the fact that fonts +%D will never be perfect and that we need runtime fixing. That took some work but in +%D the end put less burden on the engine. +%D +%D After an extremely short discussion MS and HH decided that we will not support +%D \quote {BS ISO 80000-2:2009} because it doesn't comply to the CMS quality +%D standards and is BS anyway. %D Musical timestamp for the April 2022 math (inline) snapping sub activity: eNerd⁴ %D Time Capsule 2020 a.k.a. Farewell Party for Normalcy (DSD on the squeezebox with %D a proper DAC connected but it can hardly keep up which also counts for me with MS %D testing faster than I can provide variants (www.youtube.com/watch?v=xzQCqAJNOSM). -%D After an extremely short discussion MS and HH decided that we will not support -%D \quote { BS ISO 80000-2:2009} because it doesn't comply to the CMS quality -%D standards and is BS anyway. - \unprotect %D We move these definitions into the format: \registerctxluafile{math-ini}{autosuffix} \registerctxluafile{math-dim}{autosuffix} -\registerctxluafile{math-act}{autosuffix} +% \registerctxluafile{math-act}{autosuffix} \registerctxluafile{math-ext}{} \registerctxluafile{math-vfu}{autosuffix} \registerctxluafile{math-ttv}{} \registerctxluafile{math-map}{autosuffix} +\registerctxluafile{math-act}{autosuffix} \registerctxluafile{math-ren}{} \registerctxluafile{math-noa}{autosuffix} \registerctxluafile{math-tag}{autosuffix} @@ -60,6 +74,9 @@ \mathfencesmode \plusone % unpack +\delimiterfactor \plusthousand +\delimitershortfall \zeropoint + % These need to be set because otherwise the engine will not honor some font % properties. It also permits tracing. These might become engine defaults. As a % consequence we no longer check for traditional fonts but one can use font control @@ -91,19 +108,21 @@ % \mathpenaltiesmode\plusone -% These are frozen values because otherwise we need to sunc them when the predefined +% These are frozen values because otherwise we need to sync them when the predefined % muskip (internal) registers are changed. -\immutable\mugluespecdef\defaultthickermuskip 7mu plus 5.0mu -\immutable\mugluespecdef\defaultthickmuskip 5mu plus 5mu -\immutable\mugluespecdef\defaultmedmuskip 4mu plus 2mu minus 4mu +\immutable\mugluespecdef\defaultthickermuskip 7mu plus 5mu +\immutable\mugluespecdef\defaultthickmuskip 5mu plus 3mu minus 1mu +\immutable\mugluespecdef\defaultmedmuskip 4mu plus 2mu minus 2mu \immutable\mugluespecdef\defaultthinmuskip 3mu -\immutable\mugluespecdef\defaulttinymuskip 1mu +\immutable\mugluespecdef\defaulttinymuskip 2mu minus 1mu +\immutable\mugluespecdef\defaultpettymuskip 1mu minus 0.5mu -\immutable\mugluespecdef\halfthickmuskip 2.5mu plus 2.5mu -\immutable\mugluespecdef\halfmedmuskip 2.0mu plus 1.0mu minus 2.0mu +\immutable\mugluespecdef\halfthickmuskip 2.5mu plus 1.5mu minus 0.5mu +\immutable\mugluespecdef\halfmedmuskip 2mu plus 1mu minus 1mu \immutable\mugluespecdef\halfthinmuskip 1.5mu -\immutable\mugluespecdef\halftinymuskip 0.5mu +\immutable\mugluespecdef\halftinymuskip 1mu minus 0.5mu +\immutable\mugluespecdef\halfpettymuskip 0.5mu minus 0.25mu \immutable\mugluespecdef\hairmuskip .15mu @@ -114,41 +133,50 @@ \newmuskip\thickermuskip \thickermuskip \defaultthickermuskip -% more friendly in setups: - -\setnewconstant\mathordinarycode \mathclassvalue ordinary \aliased\let\mathordcode \mathordinarycode -\setnewconstant\mathoperatorcode \mathclassvalue operator \aliased\let\mathopcode \mathoperatorcode -\setnewconstant\mathbinarycode \mathclassvalue binary \aliased\let\mathbincode \mathbinarycode -\setnewconstant\mathrelationcode \mathclassvalue relation \aliased\let\mathrelcode \mathrelationcode -\setnewconstant\mathopencode \mathclassvalue open -\setnewconstant\mathclosecode \mathclassvalue close -\setnewconstant\mathpunctuationcode \mathclassvalue punctuation \aliased\let\mathpunctcode\mathpunctuationcode -\setnewconstant\mathinnercode \mathclassvalue inner -\setnewconstant\mathovercode \mathclassvalue over -\setnewconstant\mathundercode \mathclassvalue under -\setnewconstant\mathfractioncode \mathclassvalue fraction -\setnewconstant\mathradicalcode \mathclassvalue radical -\setnewconstant\mathmiddlecode \mathclassvalue middle -\setnewconstant\mathaccentcode \mathclassvalue accent -\setnewconstant\mathfencedcode \mathclassvalue fenced -\setnewconstant\mathghostcode \mathclassvalue ghost -\setnewconstant\mathvariablecode \mathclassvalue variable -\setnewconstant\mathactivecode \mathclassvalue active -\setnewconstant\mathvcentercode \mathclassvalue vcenter -\setnewconstant\mathimaginarycode \mathclassvalue imaginary -\setnewconstant\mathdifferentialcode \mathclassvalue differential -\setnewconstant\mathexponentialcode \mathclassvalue exponential -\setnewconstant\mathfunctioncode \mathclassvalue function -\setnewconstant\mathdigitcode \mathclassvalue digit -\setnewconstant\mathexplicitcode \mathclassvalue explicit -\setnewconstant\mathdivisioncode \mathclassvalue division -\setnewconstant\mathfactorialcode \mathclassvalue factorial -\setnewconstant\mathwrappedcode \mathclassvalue wrapped -\setnewconstant\mathconstructcode \mathclassvalue construct -\setnewconstant\mathdimensioncode \mathclassvalue dimension - -\setnewconstant\mathbegincode \mathclassvalue begin -\setnewconstant\mathendcode \mathclassvalue end +% Beware: we don't support mathinner any longer. We do have construct, wrapper, ellipsis etc +% as replacements and all inner spacing is basically unset. + +\setnewconstant\mathunsetcode \mathclassvalue unset + +\setnewconstant\mathordinarycode \mathclassvalue ordinary \aliased\let\mathordcode \mathordinarycode +\setnewconstant\mathoperatorcode \mathclassvalue operator \aliased\let\mathopcode \mathoperatorcode +\setnewconstant\mathbinarycode \mathclassvalue binary \aliased\let\mathbincode \mathbinarycode +\setnewconstant\mathrelationcode \mathclassvalue relation \aliased\let\mathrelcode \mathrelationcode +\setnewconstant\mathopencode \mathclassvalue open +\setnewconstant\mathclosecode \mathclassvalue close +\setnewconstant\mathpunctuationcode \mathclassvalue punctuation \aliased\let\mathpunctcode\mathpunctuationcode +\setnewconstant\mathinnercode \mathclassvalue inner +\setnewconstant\mathovercode \mathclassvalue over +\setnewconstant\mathundercode \mathclassvalue under +\setnewconstant\mathfractioncode \mathclassvalue fraction +\setnewconstant\mathradicalcode \mathclassvalue radical +\setnewconstant\mathmiddlecode \mathclassvalue middle +\setnewconstant\mathaccentcode \mathclassvalue accent +\setnewconstant\mathfencedcode \mathclassvalue fenced % unlikely to be seen but can be used +\setnewconstant\mathghostcode \mathclassvalue ghost % transparent for classes +\setnewconstant\mathvariablecode \mathclassvalue variable +\setnewconstant\mathactivecode \mathclassvalue active +\setnewconstant\mathvcentercode \mathclassvalue vcenter +\setnewconstant\mathimaginarycode \mathclassvalue imaginary +\setnewconstant\mathdifferentialcode \mathclassvalue differential +\setnewconstant\mathexponentialcode \mathclassvalue exponential +\setnewconstant\mathellipsiscode \mathclassvalue ellipsis % replacement for inner +\setnewconstant\mathfunctioncode \mathclassvalue function +\setnewconstant\mathdigitcode \mathclassvalue digit +\setnewconstant\mathexplicitcode \mathclassvalue explicit % only for for control +\setnewconstant\mathdivisioncode \mathclassvalue division +\setnewconstant\mathfactorialcode \mathclassvalue factorial +\setnewconstant\mathwrappedcode \mathclassvalue wrapped % replacement for inner +\setnewconstant\mathconstructcode \mathclassvalue construct % replacement for inner +\setnewconstant\mathdimensioncode \mathclassvalue dimension +\setnewconstant\mathtextpunctuationcode \mathclassvalue textpunctuation % for punctuation in text font followed by interword spacing +\setnewconstant\mathunspacedcode \mathclassvalue unspaced % for cases where we don't want spacing at all +\setnewconstant\mathexperimentalcode \mathclassvalue experimental % for MS and HH testing purposed only + +\setnewconstant\mathbegincode \mathclassvalue begin +\setnewconstant\mathendcode \mathclassvalue end +\setnewconstant\mathallcode \mathclassvalue all +\setnewconstant\mathfakecode \mathclassvalue fake %setnewconstant\mathtopaccentcode \mathclassvalue topaccent % these are private and above 31 %setnewconstant\mathbotaccentcode \mathclassvalue botaccent % these are private and above 31 @@ -168,22 +196,43 @@ \copymathspacing \mathexponentialcode \mathordinarycode \copymathspacing \mathdigitcode \mathordinarycode \copymathspacing \mathfunctioncode \mathoperatorcode -\copymathspacing \mathconstructcode \mathinnercode \copymathspacing \mathwrappedcode \mathfractioncode \setnewconstant\mathlimopcode \plusone \setnewconstant\mathnolopcode \plusone -% \m{m^2/x__3} - -\setmathoptions\mathdivisioncode\numexpr - \nopreslackclassoptioncode - +\nopostslackclassoptioncode - +\lefttopkernclassoptioncode - % +\righttopkernclassoptioncode - % +\leftbottomkernclassoptioncode - +\rightbottomkernclassoptioncode -\relax +%untraced\protected\def\mathordinary {\mathatom \s!class \mathordinarycode } % use \mathord +%untraced\protected\def\mathoperator {\mathatom \s!class \mathoperatorcode } % use \mathop +%untraced\protected\def\mathbinary {\mathatom \s!class \mathbinarycode } % use \mathbin +%untraced\protected\def\mathrelation {\mathatom \s!class \mathrelationcode } % use \mathrel +%untraced\protected\def\mathopen {\mathatom \s!class \mathopencode } % primitive +%untraced\protected\def\mathclose {\mathatom \s!class \mathclosecode } % primitive +%untraced\protected\def\mathpunctuation {\mathatom \s!class \mathpunctuationcode } % use \mathpunct +%untraced\protected\def\mathinner {\mathatom \s!class \mathinnercode } % primitive +%untraced\protected\def\mathover {\mathatom \s!class \mathovercode } % macro +%untraced\protected\def\mathunder {\mathatom \s!class \mathundercode } % macro +%untraced\protected\def\mathfraction {\mathatom \s!class \mathfractioncode } % use \mathfrac +%untraced\protected\def\mathradical {\mathatom \s!class \mathradicalcode } % use \mathrad +%untraced\protected\def\mathmiddle {\mathatom \s!class \mathmiddlecode } % primitive +%untraced\protected\def\mathaccent {\mathatom \s!class \mathaccentcode } % primitive +%untraced\protected\def\mathfenced {\mathatom \s!class \mathfencedcode } % primitive +%untraced\protected\def\mathghost {\mathatom \s!class \mathghostcode } % primitive +%untraced\protected\def\mathvariable {\mathatom \s!class \mathvariablecode } % useless +%untraced\protected\def\mathactive {\mathatom \s!class \mathactivecode } % useless +%untraced\protected\def\mathvcenter {\mathatom \s!class \mathvcentercode } % useless +\untraced\protected\def\mathimaginary {\mathatom \s!class \mathimaginarycode } +\untraced\protected\def\mathdifferential{\mathatom \s!class \mathdifferentialcode} +\untraced\protected\def\mathexponential {\mathatom \s!class \mathexponentialcode } +%untraced\protected\def\mathfunction {\mathatom \s!class \mathfunctioncode } % macro +\untraced\protected\def\mathdigit {\mathatom \s!class \mathdigitcode } +%untraced\protected\def\mathexplicit {\mathatom \s!class \mathexplicitcode } % dangerous +\untraced\protected\def\mathdivision {\mathatom \s!class \mathdivisioncode } +\untraced\protected\def\mathfactorial {\mathatom \s!class \mathfactorialcode } +\untraced\protected\def\mathwrapped {\mathatom \s!class \mathwrappedcode } +\untraced\protected\def\mathconstruct {\mathatom \s!class \mathconstructcode } +\untraced\protected\def\mathdimension {\mathatom \s!class \mathdimensioncode } +%untraced\protected\def\mathbegin {\mathatom \s!class \mathbegincode } % dangerous +%untraced\protected\def\mathend {\mathatom \s!class \mathendcode } % dangerous % obsolete @@ -212,11 +261,11 @@ \permanent\protected\def\ordopenspacing {\setmathspacing \mathordinarycode \mathopencode } \permanent\protected\def\ordclosespacing {\setmathspacing \mathordinarycode \mathclosecode } \permanent\protected\def\ordpunctspacing {\setmathspacing \mathordinarycode \mathpunctuationcode} -\permanent\protected\def\ordinnerspacing {\setmathspacing \mathordinarycode \mathinnercode } -\permanent\protected\def\ordfracspacing {\setmathspacing \mathordinarycode \mathfractioncode } -\permanent\protected\def\ordradspacing {\setmathspacing \mathordinarycode \mathradicalcode } +%permanent\protected\def\ordinnerspacing {\setmathspacing \mathordinarycode \mathinnercode } +%permanent\protected\def\ordfracspacing {\setmathspacing \mathordinarycode \mathfractioncode } +%permanent\protected\def\ordradspacing {\setmathspacing \mathordinarycode \mathradicalcode } \permanent\protected\def\ordmiddlespacing {\setmathspacing \mathordinarycode \mathmiddlecode } -\permanent\protected\def\ordaccentspacing {\setmathspacing \mathordinarycode \mathaccentcode } +%permanent\protected\def\ordaccentspacing {\setmathspacing \mathordinarycode \mathaccentcode } \permanent\protected\def\opordspacing {\setmathspacing \mathoperatorcode \mathordinarycode } \permanent\protected\def\opopspacing {\setmathspacing \mathoperatorcode \mathoperatorcode } @@ -225,11 +274,11 @@ \permanent\protected\def\opopenspacing {\setmathspacing \mathoperatorcode \mathopencode } \permanent\protected\def\opclosespacing {\setmathspacing \mathoperatorcode \mathclosecode } \permanent\protected\def\oppunctspacing {\setmathspacing \mathoperatorcode \mathpunctuationcode} -\permanent\protected\def\opinnerspacing {\setmathspacing \mathoperatorcode \mathinnercode } -\permanent\protected\def\opfracspacing {\setmathspacing \mathoperatorcode \mathfractioncode } -\permanent\protected\def\opradspacing {\setmathspacing \mathoperatorcode \mathradicalcode } +%permanent\protected\def\opinnerspacing {\setmathspacing \mathoperatorcode \mathinnercode } +%permanent\protected\def\opfracspacing {\setmathspacing \mathoperatorcode \mathfractioncode } +%permanent\protected\def\opradspacing {\setmathspacing \mathoperatorcode \mathradicalcode } \permanent\protected\def\opmiddlespacing {\setmathspacing \mathoperatorcode \mathmiddlecode } -\permanent\protected\def\opaccentspacing {\setmathspacing \mathoperatorcode \mathaccentcode } +%permanent\protected\def\opaccentspacing {\setmathspacing \mathoperatorcode \mathaccentcode } \permanent\protected\def\binordspacing {\setmathspacing \mathbinarycode \mathordinarycode } \permanent\protected\def\binopspacing {\setmathspacing \mathbinarycode \mathoperatorcode } @@ -238,11 +287,11 @@ \permanent\protected\def\binopenspacing {\setmathspacing \mathbinarycode \mathopencode } \permanent\protected\def\binclosespacing {\setmathspacing \mathbinarycode \mathclosecode } \permanent\protected\def\binpunctspacing {\setmathspacing \mathbinarycode \mathpunctuationcode} -\permanent\protected\def\bininnerspacing {\setmathspacing \mathbinarycode \mathinnercode } -\permanent\protected\def\binfracspacing {\setmathspacing \mathbinarycode \mathfractioncode } -\permanent\protected\def\binradspacing {\setmathspacing \mathbinarycode \mathradicalcode } +%permanent\protected\def\bininnerspacing {\setmathspacing \mathbinarycode \mathinnercode } +%permanent\protected\def\binfracspacing {\setmathspacing \mathbinarycode \mathfractioncode } +%permanent\protected\def\binradspacing {\setmathspacing \mathbinarycode \mathradicalcode } \permanent\protected\def\binmiddlespacing {\setmathspacing \mathbinarycode \mathmiddlecode } -\permanent\protected\def\binaccentspacing {\setmathspacing \mathbinarycode \mathaccentcode } +%permanent\protected\def\binaccentspacing {\setmathspacing \mathbinarycode \mathaccentcode } \permanent\protected\def\relordspacing {\setmathspacing \mathrelationcode \mathordinarycode } \permanent\protected\def\relopspacing {\setmathspacing \mathrelationcode \mathoperatorcode } @@ -251,11 +300,11 @@ \permanent\protected\def\relopenspacing {\setmathspacing \mathrelationcode \mathopencode } \permanent\protected\def\relclosespacing {\setmathspacing \mathrelationcode \mathclosecode } \permanent\protected\def\relpunctspacing {\setmathspacing \mathrelationcode \mathpunctuationcode} -\permanent\protected\def\relinnerspacing {\setmathspacing \mathrelationcode \mathinnercode } -\permanent\protected\def\relfracspacing {\setmathspacing \mathrelationcode \mathfractioncode } -\permanent\protected\def\relradspacing {\setmathspacing \mathrelationcode \mathradicalcode } +%permanent\protected\def\relinnerspacing {\setmathspacing \mathrelationcode \mathinnercode } +%permanent\protected\def\relfracspacing {\setmathspacing \mathrelationcode \mathfractioncode } +%permanent\protected\def\relradspacing {\setmathspacing \mathrelationcode \mathradicalcode } \permanent\protected\def\relmiddlespacing {\setmathspacing \mathrelationcode \mathmiddlecode } -\permanent\protected\def\relaccentspacing {\setmathspacing \mathrelationcode \mathaccentcode } +%permanent\protected\def\relaccentspacing {\setmathspacing \mathrelationcode \mathaccentcode } \permanent\protected\def\openordspacing {\setmathspacing \mathopencode \mathordinarycode } \permanent\protected\def\openopspacing {\setmathspacing \mathopencode \mathoperatorcode } @@ -264,11 +313,11 @@ \permanent\protected\def\openopenspacing {\setmathspacing \mathopencode \mathopencode } \permanent\protected\def\openclosespacing {\setmathspacing \mathopencode \mathclosecode } \permanent\protected\def\openpunctspacing {\setmathspacing \mathopencode \mathpunctuationcode} -\permanent\protected\def\openinnerspacing {\setmathspacing \mathopencode \mathinnercode } -\permanent\protected\def\openfracspacing {\setmathspacing \mathopencode \mathfractioncode } -\permanent\protected\def\openradspacing {\setmathspacing \mathopencode \mathradicalcode } +%permanent\protected\def\openinnerspacing {\setmathspacing \mathopencode \mathinnercode } +%permanent\protected\def\openfracspacing {\setmathspacing \mathopencode \mathfractioncode } +%permanent\protected\def\openradspacing {\setmathspacing \mathopencode \mathradicalcode } \permanent\protected\def\openmiddlespacing {\setmathspacing \mathopencode \mathmiddlecode } -\permanent\protected\def\openaccentspacing {\setmathspacing \mathopencode \mathaccentcode } +%permanent\protected\def\openaccentspacing {\setmathspacing \mathopencode \mathaccentcode } \permanent\protected\def\closeordspacing {\setmathspacing \mathclosecode \mathordinarycode } \permanent\protected\def\closeopspacing {\setmathspacing \mathclosecode \mathoperatorcode } @@ -277,11 +326,11 @@ \permanent\protected\def\closeopenspacing {\setmathspacing \mathclosecode \mathopencode } \permanent\protected\def\closeclosespacing {\setmathspacing \mathclosecode \mathclosecode } \permanent\protected\def\closepunctspacing {\setmathspacing \mathclosecode \mathpunctuationcode} -\permanent\protected\def\closeinnerspacing {\setmathspacing \mathclosecode \mathinnercode } -\permanent\protected\def\closefracspacing {\setmathspacing \mathclosecode \mathfractioncode } -\permanent\protected\def\closeradspacing {\setmathspacing \mathclosecode \mathradicalcode } +%permanent\protected\def\closeinnerspacing {\setmathspacing \mathclosecode \mathinnercode } +%permanent\protected\def\closefracspacing {\setmathspacing \mathclosecode \mathfractioncode } +%permanent\protected\def\closeradspacing {\setmathspacing \mathclosecode \mathradicalcode } \permanent\protected\def\closemiddlespacing {\setmathspacing \mathclosecode \mathmiddlecode } -\permanent\protected\def\closeaccentspacing {\setmathspacing \mathclosecode \mathaccentcode } +%permanent\protected\def\closeaccentspacing {\setmathspacing \mathclosecode \mathaccentcode } \permanent\protected\def\punctordspacing {\setmathspacing \mathpunctuationcode \mathordinarycode } \permanent\protected\def\punctopspacing {\setmathspacing \mathpunctuationcode \mathoperatorcode } @@ -290,24 +339,24 @@ \permanent\protected\def\punctopenspacing {\setmathspacing \mathpunctuationcode \mathopencode } \permanent\protected\def\punctclosespacing {\setmathspacing \mathpunctuationcode \mathclosecode } \permanent\protected\def\punctpunctspacing {\setmathspacing \mathpunctuationcode \mathpunctuationcode} -\permanent\protected\def\punctinnerspacing {\setmathspacing \mathpunctuationcode \mathinnercode } -\permanent\protected\def\punctfracspacing {\setmathspacing \mathpunctuationcode \mathfractioncode } -\permanent\protected\def\punctradspacing {\setmathspacing \mathpunctuationcode \mathradicalcode } +%permanent\protected\def\punctinnerspacing {\setmathspacing \mathpunctuationcode \mathinnercode } +%permanent\protected\def\punctfracspacing {\setmathspacing \mathpunctuationcode \mathfractioncode } +%permanent\protected\def\punctradspacing {\setmathspacing \mathpunctuationcode \mathradicalcode } \permanent\protected\def\punctmiddlespacing {\setmathspacing \mathpunctuationcode \mathmiddlecode } -\permanent\protected\def\punctaccentspacing {\setmathspacing \mathpunctuationcode \mathaccentcode } - -\permanent\protected\def\innerordspacing {\setmathspacing \mathinnercode \mathordinarycode } -\permanent\protected\def\inneropspacing {\setmathspacing \mathinnercode \mathoperatorcode } -\permanent\protected\def\innerbinspacing {\setmathspacing \mathinnercode \mathbinarycode } -\permanent\protected\def\innerrelspacing {\setmathspacing \mathinnercode \mathrelationcode } -\permanent\protected\def\inneropenspacing {\setmathspacing \mathinnercode \mathopencode } -\permanent\protected\def\innerclosespacing {\setmathspacing \mathinnercode \mathclosecode } -\permanent\protected\def\innerpunctspacing {\setmathspacing \mathinnercode \mathpunctuationcode} -\permanent\protected\def\innerinnerspacing {\setmathspacing \mathinnercode \mathinnercode } -\permanent\protected\def\innerfracspacing {\setmathspacing \mathinnercode \mathfractioncode } -\permanent\protected\def\innerradspacing {\setmathspacing \mathinnercode \mathradicalcode } -\permanent\protected\def\innermiddlespacing {\setmathspacing \mathinnercode \mathmiddlecode } -\permanent\protected\def\inneraccentspacing {\setmathspacing \mathinnercode \mathaccentcode } +%permanent\protected\def\punctaccentspacing {\setmathspacing \mathpunctuationcode \mathaccentcode } + +%permanent\protected\def\innerordspacing {\setmathspacing \mathinnercode \mathordinarycode } +%permanent\protected\def\inneropspacing {\setmathspacing \mathinnercode \mathoperatorcode } +%permanent\protected\def\innerbinspacing {\setmathspacing \mathinnercode \mathbinarycode } +%permanent\protected\def\innerrelspacing {\setmathspacing \mathinnercode \mathrelationcode } +%permanent\protected\def\inneropenspacing {\setmathspacing \mathinnercode \mathopencode } +%permanent\protected\def\innerclosespacing {\setmathspacing \mathinnercode \mathclosecode } +%permanent\protected\def\innerpunctspacing {\setmathspacing \mathinnercode \mathpunctuationcode} +%permanent\protected\def\innerinnerspacing {\setmathspacing \mathinnercode \mathinnercode } +%permanent\protected\def\innerfracspacing {\setmathspacing \mathinnercode \mathfractioncode } +%permanent\protected\def\innerradspacing {\setmathspacing \mathinnercode \mathradicalcode } +%permanent\protected\def\innermiddlespacing {\setmathspacing \mathinnercode \mathmiddlecode } +%permanent\protected\def\inneraccentspacing {\setmathspacing \mathinnercode \mathaccentcode } \permanent\protected\def\fracordspacing {\setmathspacing \mathfractioncode \mathordinarycode } \permanent\protected\def\fracopspacing {\setmathspacing \mathfractioncode \mathoperatorcode } @@ -316,11 +365,11 @@ \permanent\protected\def\fracopenspacing {\setmathspacing \mathfractioncode \mathopencode } \permanent\protected\def\fracclosespacing {\setmathspacing \mathfractioncode \mathclosecode } \permanent\protected\def\fracpunctspacing {\setmathspacing \mathfractioncode \mathpunctuationcode} -\permanent\protected\def\fracinnerspacing {\setmathspacing \mathfractioncode \mathinnercode } -\permanent\protected\def\fracfracspacing {\setmathspacing \mathfractioncode \mathfractioncode } -\permanent\protected\def\fracradspacing {\setmathspacing \mathfractioncode \mathradicalcode } +%permanent\protected\def\fracinnerspacing {\setmathspacing \mathfractioncode \mathinnercode } +%permanent\protected\def\fracfracspacing {\setmathspacing \mathfractioncode \mathfractioncode } +%permanent\protected\def\fracradspacing {\setmathspacing \mathfractioncode \mathradicalcode } \permanent\protected\def\fracmiddlespacing {\setmathspacing \mathfractioncode \mathmiddlecode } -\permanent\protected\def\fracaccentspacing {\setmathspacing \mathfractioncode \mathaccentcode } +%permanent\protected\def\fracaccentspacing {\setmathspacing \mathfractioncode \mathaccentcode } \permanent\protected\def\radordspacing {\setmathspacing \mathradicalcode \mathordinarycode } \permanent\protected\def\radopspacing {\setmathspacing \mathradicalcode \mathoperatorcode } @@ -329,11 +378,11 @@ \permanent\protected\def\radopenspacing {\setmathspacing \mathradicalcode \mathopencode } \permanent\protected\def\radclosespacing {\setmathspacing \mathradicalcode \mathclosecode } \permanent\protected\def\radpunctspacing {\setmathspacing \mathradicalcode \mathpunctuationcode} -\permanent\protected\def\radinnerspacing {\setmathspacing \mathradicalcode \mathinnercode } -\permanent\protected\def\radfracspacing {\setmathspacing \mathradicalcode \mathfractioncode } -\permanent\protected\def\radradspacing {\setmathspacing \mathradicalcode \mathradicalcode } +%permanent\protected\def\radinnerspacing {\setmathspacing \mathradicalcode \mathinnercode } +%permanent\protected\def\radfracspacing {\setmathspacing \mathradicalcode \mathfractioncode } +%permanent\protected\def\radradspacing {\setmathspacing \mathradicalcode \mathradicalcode } \permanent\protected\def\radmiddlespacing {\setmathspacing \mathradicalcode \mathmiddlecode } -\permanent\protected\def\radaccentspacing {\setmathspacing \mathradicalcode \mathaccentcode } +%permanent\protected\def\radaccentspacing {\setmathspacing \mathradicalcode \mathaccentcode } \permanent\protected\def\middleordspacing {\setmathspacing \mathmiddlecode \mathordinarycode } \permanent\protected\def\middleopspacing {\setmathspacing \mathmiddlecode \mathoperatorcode } @@ -342,11 +391,11 @@ \permanent\protected\def\middleopenspacing {\setmathspacing \mathmiddlecode \mathopencode } \permanent\protected\def\middleclosespacing {\setmathspacing \mathmiddlecode \mathclosecode } \permanent\protected\def\middlepunctspacing {\setmathspacing \mathmiddlecode \mathpunctuationcode} -\permanent\protected\def\middleinnerspacing {\setmathspacing \mathmiddlecode \mathinnercode } -\permanent\protected\def\middlefracspacing {\setmathspacing \mathmiddlecode \mathfractioncode } -\permanent\protected\def\middleradspacing {\setmathspacing \mathmiddlecode \mathradicalcode } +%permanent\protected\def\middleinnerspacing {\setmathspacing \mathmiddlecode \mathinnercode } +%permanent\protected\def\middlefracspacing {\setmathspacing \mathmiddlecode \mathfractioncode } +%permanent\protected\def\middleradspacing {\setmathspacing \mathmiddlecode \mathradicalcode } \permanent\protected\def\middlemiddlespacing{\setmathspacing \mathmiddlecode \mathmiddlecode } -\permanent\protected\def\middleaccentspacing{\setmathspacing \mathmiddlecode \mathaccentcode } +%permanent\protected\def\middleaccentspacing{\setmathspacing \mathmiddlecode \mathaccentcode } \permanent\protected\def\accentordspacing {\setmathspacing \mathaccentcode \mathordinarycode } \permanent\protected\def\accentopspacing {\setmathspacing \mathaccentcode \mathoperatorcode } @@ -355,11 +404,11 @@ \permanent\protected\def\accentopenspacing {\setmathspacing \mathaccentcode \mathopencode } \permanent\protected\def\accentclosespacing {\setmathspacing \mathaccentcode \mathclosecode } \permanent\protected\def\accentpunctspacing {\setmathspacing \mathaccentcode \mathpunctuationcode} -\permanent\protected\def\accentinnerspacing {\setmathspacing \mathaccentcode \mathinnercode } -\permanent\protected\def\accentfracspacing {\setmathspacing \mathaccentcode \mathfractioncode } -\permanent\protected\def\accentradspacing {\setmathspacing \mathaccentcode \mathradicalcode } +%permanent\protected\def\accentinnerspacing {\setmathspacing \mathaccentcode \mathinnercode } +%permanent\protected\def\accentfracspacing {\setmathspacing \mathaccentcode \mathfractioncode } +%permanent\protected\def\accentradspacing {\setmathspacing \mathaccentcode \mathradicalcode } \permanent\protected\def\accentmiddlespacing{\setmathspacing \mathaccentcode \mathmiddlecode } -\permanent\protected\def\accentaccentspacing{\setmathspacing \mathaccentcode \mathaccentcode } +%permanent\protected\def\accentaccentspacing{\setmathspacing \mathaccentcode \mathaccentcode } %D In the end Mikael and I prefer this but we need a high level interface: @@ -369,29 +418,124 @@ \setmathignore \Umathspacebeforescript\zerocount \setmathignore \Umathspaceafterscript \zerocount -\mathslackmode \plusone +\mathslackmode \plusone +\mathgroupingmode \plusone +%mathdoublescriptmode\zerocount % -1 will give an error (as usual) .. "LLRR (left class, right class) + +% $x ^^1__2 ^3_4 ^5_6 ^7_8 $ + +\mathdoublescriptmode + "\tohexadecimal\mathfakecode + \tohexadecimal\mathfakecode + \tohexadecimal\mathfakecode \integerdef\defaultmathclassoptions\numexpr \nopreslackclassoptioncode +\nopostslackclassoptioncode - % +\lefttopkernclassoptioncode - % +\righttopkernclassoptioncode - % +\leftbottomkernclassoptioncode - % +\rightbottomkernclassoptioncode - % +\lookaheadforendclassoptioncode + % +\lefttopkernclassoptioncode % applied in a late stage e.g. division + % +\righttopkernclassoptioncode % applied in a late stage e.g. division + % +\leftbottomkernclassoptioncode % applied in a late stage e.g. division + % +\rightbottomkernclassoptioncode % applied in a late stage e.g. division + % +\lookaheadforendclassoptioncode % signed whatevers + % +\noitaliccorrectionclassoptioncode + % +\openfenceclassoptioncode % the engine doesn't really used this property but maybe + % +\closefenceclassoptioncode % at some point we want to have to have access to it at + % +\middlefenceclassoptioncode % lua end ... so we keep it (also in the engine) commented + % +\checkligatureclassoptioncode % no font provides this so it is more a compatibility feature + % +\flattenclassoptioncode + % +\omitpenaltyclassoptioncode % old school check, we do pairwise instead +\relax + +\setmathoptions\mathordinarycode\numexpr + \noitaliccorrectionclassoptioncode + % +\checkligatureclassoptioncode + +\flattenclassoptioncode +\relax + +\setmathoptions\mathoperatorcode\numexpr + \defaultmathclassoptions + % +\checkligatureclassoptioncode \relax \setmathoptions\mathbinarycode\numexpr \defaultmathclassoptions +\lookaheadforendclassoptioncode + +\noitaliccorrectionclassoptioncode + % +\checkligatureclassoptioncode + +\flattenclassoptioncode \relax -\setmathoptions\mathoperatorcode \defaultmathclassoptions -\setmathoptions\mathrelationcode \defaultmathclassoptions -\setmathoptions\mathopencode \defaultmathclassoptions -\setmathoptions\mathclosecode \defaultmathclassoptions -\setmathoptions\mathpunctuationcode\defaultmathclassoptions -\setmathoptions\mathfractioncode \defaultmathclassoptions +\setmathoptions\mathrelationcode\numexpr + \defaultmathclassoptions + +\noitaliccorrectionclassoptioncode + % +\checkligatureclassoptioncode + +\flattenclassoptioncode + % +\omitpenaltyclassoptioncode +\relax + +\setmathoptions\mathopencode\numexpr + \defaultmathclassoptions + +\noitaliccorrectionclassoptioncode + % +\openfenceclassoptioncode + % +\checkligatureclassoptioncode +\relax + +\setmathoptions\mathclosecode\numexpr + \defaultmathclassoptions + +\noitaliccorrectionclassoptioncode + % +\closefenceclassoptioncode + % +\checkligatureclassoptioncode +\relax + +\setmathoptions\mathpunctuationcode\numexpr + \defaultmathclassoptions + +\noitaliccorrectionclassoptioncode + % +\checkligatureclassoptioncode + +\flattenclassoptioncode +\relax + +\setmathoptions\mathvariablecode\numexpr + \noitaliccorrectionclassoptioncode +\relax + +\setmathoptions\mathactivecode\numexpr + \noitaliccorrectionclassoptioncode +\relax + +%setmathoptions\mathinnercode\numexpr +% \noitaliccorrectionclassoptioncode +% +\flattenclassoptioncode +%relax + +\setmathoptions\mathmiddlecode\numexpr + \noitaliccorrectionclassoptioncode + % +\middlefenceclassoptioncode +\relax + +\setmathoptions\mathfractioncode\numexpr + \defaultmathclassoptions +\relax + +\setmathoptions\mathaccentcode\numexpr + \defaultmathclassoptions +\relax + +% \m{m^2/x__3} + +\setmathoptions\mathdivisioncode\numexpr + \nopreslackclassoptioncode + +\nopostslackclassoptioncode + +\lefttopkernclassoptioncode + % +\righttopkernclassoptioncode + % +\leftbottomkernclassoptioncode + +\rightbottomkernclassoptioncode +\relax + +\setmathoptions\mathbegincode + \nopostslackclassoptioncode + +\setmathoptions\mathendcode + \nopreslackclassoptioncode %D For now \unknown (todo: make it adapt to style but we're in text anyway) @@ -694,6 +838,7 @@ \medmuskip \defaultmedmuskip \thinmuskip \defaultthinmuskip \tinymuskip \defaulttinymuskip + \pettymuskip \defaultpettymuskip \relpenalty \defaultrelpenalty \binoppenalty \defaultbinoppenalty \prebinoppenalty\maxdimen @@ -705,6 +850,7 @@ \medmuskip \defaultmedmuskip \thinmuskip \defaultthinmuskip \tinymuskip \defaulttinymuskip + \pettymuskip \defaultpettymuskip \relpenalty \defaultrelpenalty \binoppenalty \defaultbinoppenalty \prebinoppenalty\defaultprebinoppenalty @@ -716,6 +862,7 @@ \medmuskip \halfmedmuskip \thinmuskip \halfthinmuskip \tinymuskip \halftinymuskip + \pettymuskip \halfpettymuskip \relpenalty \defaultrelpenalty \binoppenalty \defaultbinoppenalty \prebinoppenalty\maxdimen @@ -728,11 +875,13 @@ \medmuskip \halfmedmuskip \thinmuskip \halfthinmuskip \tinymuskip \halftinymuskip + \pettymuskip \halfpettymuskip \else \thickmuskip 1\halfthickmuskip \medmuskip 1\halfmedmuskip \thinmuskip 1\halfthinmuskip \tinymuskip 1\halftinymuskip + \pettymuskip 1\halfpettymuskip \fi \relpenalty \defaultrelpenalty \binoppenalty \maxdimen @@ -746,11 +895,13 @@ \medmuskip \halfmedmuskip \thinmuskip \halfthinmuskip \tinymuskip \halftinymuskip + \pettymuskip \halfpettymuskip \else \thickmuskip 1\halfthickmuskip \medmuskip 1\halfmedmuskip \thinmuskip 1\halfthinmuskip \tinymuskip 1\halftinymuskip + \pettymuskip 1\halfpettymuskip \fi \relpenalty \maxdimen \binoppenalty \maxdimen @@ -762,199 +913,44 @@ % \Umathspacingmode\allmathstyles\plusone % always pair driven -% \startsetups math:spacing:presets -% \resetmathspacing -% % \ordordspacing \allmathstyles \zeromuskip -% \inherited\ordopspacing \allmathstyles \thinmuskip -% \inherited\ordbinspacing \allsplitstyles \medmuskip -% \inherited\ordbinspacing \allscriptstyles\tinymuskip -% \inherited\ordrelspacing \allsplitstyles \thickmuskip -% \inherited\ordrelspacing \allscriptstyles\tinymuskip -% % \inherited\ordopenspacing \allmathstyles \zeromuskip -% \inherited\ordmiddlespacing \allsplitstyles \medmuskip -% \inherited\ordmiddlespacing \allscriptstyles\tinymuskip -% % \inherited\ordclosespacing \allmathstyles \zeromuskip -% % \inherited\ordpunctspacing \allmathstyles \zeromuskip -% \inherited\ordinnerspacing \allsplitstyles \thinmuskip -% \inherited\ordinnerspacing \allscriptstyles\tinymuskip -% \inherited\ordfracspacing \allmathstyles \tinymuskip -% \inherited\ordradspacing \allmathstyles \tinymuskip -% \inherited\opordspacing \allmathstyles \thinmuskip -% \inherited\opopspacing \allmathstyles \thinmuskip -% % \inherited \opbinspacing \allmathstyles \zeromuskip -% \inherited\oprelspacing \allsplitstyles \thickmuskip -% \inherited\oprelspacing \allscriptstyles\tinymuskip -% % \inherited\opopenspacing \allmathstyles \zeromuskip -% \inherited\opmiddlespacing \allsplitstyles \medmuskip -% \inherited\opmiddlespacing \allscriptstyles\tinymuskip -% % \inherited\opclosespacing \allmathstyles \zeromuskip -% % \inherited\oppunctspacing \allmathstyles \zeromuskip -% \inherited\opinnerspacing \allsplitstyles \thinmuskip -% \inherited\opinnerspacing \allscriptstyles\tinymuskip -% \inherited\opfracspacing \allmathstyles \thinmuskip -% \inherited\opradspacing \allmathstyles \thinmuskip -% \inherited\binordspacing \allsplitstyles \medmuskip -% \inherited\binordspacing \allscriptstyles\tinymuskip -% \inherited\binopspacing \allsplitstyles \medmuskip -% \inherited\binopspacing \allscriptstyles\tinymuskip -% % \inherited\binbinspacing \allmathstyles \zeromuskip -% % \inherited\binrelspacing \allmathstyles \zeromuskip -% \inherited\binopenspacing \allsplitstyles \medmuskip -% \inherited\binopenspacing \allscriptstyles\tinymuskip -% \inherited\binmiddlespacing \allsplitstyles \medmuskip -% \inherited\binmiddlespacing \allscriptstyles\tinymuskip -% % \inherited\binclosespacing \allmathstyles \zeromuskip -% % \inherited\binpunctspacing \allmathstyles \zeromuskip -% \inherited\bininnerspacing \allsplitstyles \medmuskip -% \inherited\bininnerspacing \allscriptstyles\tinymuskip -% \inherited\binfracspacing \allsplitstyles \medmuskip -% \inherited\binfracspacing \allscriptstyles\tinymuskip -% \inherited\binradspacing \allsplitstyles \medmuskip -% \inherited\binradspacing \allscriptstyles\tinymuskip -% \inherited\relordspacing \allsplitstyles \thickmuskip -% \inherited\relordspacing \allscriptstyles\tinymuskip -% \inherited\relopspacing \allsplitstyles \thickmuskip -% \inherited\relopspacing \allscriptstyles\tinymuskip -% % \inherited\relbinspacing \allmathstyles \zeromuskip -% % \inherited\relrelspacing \allmathstyles \zeromuskip -% \inherited\relopenspacing \allsplitstyles \thickmuskip -% \inherited\relopenspacing \allscriptstyles\tinymuskip -% \inherited\relmiddlespacing \allsplitstyles \thickmuskip -% \inherited\relmiddlespacing \allscriptstyles\thinmuskip -% % \inherited\relclosespacing \allmathstyles \zeromuskip -% % \inherited\relpunctspacing \allmathstyles \zeromuskip -% \inherited\relinnerspacing \allsplitstyles \thickmuskip -% \inherited\relinnerspacing \allscriptstyles\tinymuskip -% \inherited\relfracspacing \allsplitstyles \thickmuskip -% \inherited\relfracspacing \allscriptstyles\tinymuskip -% \inherited\relradspacing \allsplitstyles \thickmuskip -% \inherited\relradspacing \allscriptstyles\tinymuskip -% % \inherited\openordspacing \allmathstyles \zeromuskip -% % \inherited\openopspacing \allmathstyles \zeromuskip -% % \inherited\openbinspacing \allmathstyles \zeromuskip -% % \inherited\openrelspacing \allmathstyles \zeromuskip -% % \inherited\openopenspacing \allmathstyles \zeromuskip -% % \inherited\openmiddlespacing \allmathstyles \zeromuskip -% % \inherited\openclosespacing \allmathstyles \zeromuskip -% % \inherited\openpunctspacing \allmathstyles \zeromuskip -% % \inherited\openinnerspacing \allmathstyles \zeromuskip -% \inherited\openfracspacing \allmathstyles \tinymuskip -% % \inherited\openradspacing \allmathstyles \zeromuskip -% % \inherited\closeordspacing \allmathstyles \zeromuskip -% \inherited\closeopspacing \allmathstyles \thinmuskip -% \inherited\closebinspacing \allsplitstyles \medmuskip -% \inherited\closebinspacing \allscriptstyles\tinymuskip -% \inherited\closerelspacing \allsplitstyles \thickmuskip -% \inherited\closerelspacing \allscriptstyles\tinymuskip -% % \inherited\closeopenspacing \allmathstyles \zeromuskip -% % \inherited\closemiddlespacing \allmathstyles \zeromuskip -% % \inherited\closeclosespacing \allmathstyles \zeromuskip -% % \inherited\closepunctspacing \allmathstyles \zeromuskip -% \inherited\closeinnerspacing \allsplitstyles \thinmuskip -% \inherited\closeinnerspacing \allscriptstyles\tinymuskip -% \inherited\closefracspacing \allsplitstyles \thinmuskip -% \inherited\closefracspacing \allscriptstyles\tinymuskip -% % \inherited\closeradspacing \allmathstyles \zeromuskip -% \inherited\punctordspacing \allsplitstyles \thinmuskip -% \inherited\punctordspacing \allscriptstyles\tinymuskip -% \inherited\punctopspacing \allsplitstyles \thinmuskip -% \inherited\punctopspacing \allscriptstyles\tinymuskip -% % \inherited\punctbinspacing \allmathstyles \zeromuskip -% \inherited\punctrelspacing \allsplitstyles \thinmuskip -% \inherited\punctrelspacing \allscriptstyles\tinymuskip -% \inherited\punctopenspacing \allsplitstyles \thinmuskip -% \inherited\punctopenspacing \allscriptstyles\tinymuskip -% \inherited\punctmiddlespacing \allsplitstyles \thinmuskip -% \inherited\punctmiddlespacing \allscriptstyles\tinymuskip -% \inherited\punctclosespacing \allsplitstyles \thinmuskip -% \inherited\punctclosespacing \allscriptstyles\tinymuskip -% \inherited\punctpunctspacing \allsplitstyles \thinmuskip -% \inherited\punctpunctspacing \allscriptstyles\tinymuskip -% \inherited\punctinnerspacing \allsplitstyles \thinmuskip -% \inherited\punctinnerspacing \allscriptstyles\tinymuskip -% \inherited\punctfracspacing \allsplitstyles \thinmuskip -% \inherited\punctfracspacing \allscriptstyles\tinymuskip -% \inherited\punctradspacing \allsplitstyles \thinmuskip -% \inherited\punctradspacing \allscriptstyles\tinymuskip -% \inherited\innerordspacing \allsplitstyles \thinmuskip -% \inherited\innerordspacing \allscriptstyles\tinymuskip -% \inherited\inneropspacing \allmathstyles \thinmuskip -% \inherited\innerbinspacing \allsplitstyles \medmuskip -% \inherited\innerbinspacing \allscriptstyles\tinymuskip -% \inherited\innerrelspacing \allsplitstyles \thickmuskip -% \inherited\innerrelspacing \allscriptstyles\tinymuskip -% \inherited\inneropenspacing \allsplitstyles \thinmuskip -% \inherited\inneropenspacing \allscriptstyles\tinymuskip -% \inherited\innermiddlespacing \allsplitstyles \thinmuskip -% \inherited\innermiddlespacing \allscriptstyles\tinymuskip -% % \inherited\innerclosespacing \allmathstyles \zeromuskip -% \inherited\innerpunctspacing \allsplitstyles \thinmuskip -% \inherited\innerpunctspacing \allscriptstyles\tinymuskip -% \inherited\innerinnerspacing \allsplitstyles \thinmuskip -% \inherited\innerinnerspacing \allscriptstyles\tinymuskip -% \inherited\innerfracspacing \allsplitstyles \thinmuskip -% \inherited\innerfracspacing \allscriptstyles\tinymuskip -% \inherited\innerradspacing \allsplitstyles \thinmuskip -% \inherited\innerradspacing \allscriptstyles\tinymuskip -% \inherited\fracordspacing \allmathstyles \tinymuskip -% \inherited\fracopspacing \allmathstyles \thinmuskip -% \inherited\fracbinspacing \allsplitstyles \medmuskip -% \inherited\fracbinspacing \allscriptstyles\tinymuskip -% \inherited\fracrelspacing \allsplitstyles \thickmuskip -% \inherited\fracrelspacing \allscriptstyles\tinymuskip -% \inherited\fracopenspacing \allsplitstyles \thinmuskip -% \inherited\fracopenspacing \allscriptstyles\tinymuskip -% \inherited\fracmiddlespacing \allsplitstyles \medmuskip -% \inherited\fracmiddlespacing \allscriptstyles\tinymuskip -% \inherited\fracclosespacing \allmathstyles \tinymuskip -% % \inherited\fracpunctspacing \allmathstyles \zeromuskip -% \inherited\fracinnerspacing \allsplitstyles \thinmuskip -% \inherited\fracinnerspacing \allscriptstyles\tinymuskip -% \inherited\fracfracspacing \allsplitstyles \thinmuskip -% \inherited\fracfracspacing \allscriptstyles\tinymuskip -% \inherited\fracradspacing \allmathstyles \tinymuskip -% \inherited\radordspacing \allsplitstyles \tinymuskip -% \inherited\radopspacing \allmathstyles \thinmuskip -% \inherited\radbinspacing \allsplitstyles \medmuskip -% \inherited\radbinspacing \allscriptstyles\tinymuskip -% \inherited\radrelspacing \allsplitstyles \thickmuskip -% \inherited\radrelspacing \allscriptstyles\tinymuskip -% % \inherited\radopenspacing \allmathstyles \zeromuskip -% % \inherited\radmiddlespacing \allmathstyles \zeromuskip -% % \inherited\radclosespacing \allmathstyles \zeromuskip -% % \inherited\radpunctspacing \allmathstyles \zeromuskip -% \inherited\radinnerspacing \allsplitstyles \thinmuskip -% \inherited\radinnerspacing \allscriptstyles\tinymuskip -% \inherited\radfracspacing \allmathstyles \tinymuskip -% \inherited\radradspacing \allmathstyles \tinymuskip -% \inherited\middleordspacing \allsplitstyles \medmuskip -% \inherited\middleordspacing \allscriptstyles\tinymuskip -% \inherited\middleopspacing \allmathstyles \thinmuskip -% \inherited\middlebinspacing \allsplitstyles \medmuskip -% \inherited\middlebinspacing \allscriptstyles\tinymuskip -% \inherited\middlerelspacing \allsplitstyles \thickmuskip -% \inherited\middlerelspacing \allscriptstyles\tinymuskip -% % \inherited\middleopenspacing \allmathstyles \zeromuskip -% % \inherited\middlemiddlespacing \allmathstyles \zeromuskip -% % \inherited\middleclosespacing \allmathstyles \zeromuskip -% % \inherited\middlepunctspacing \allmathstyles \zeromuskip -% \inherited\middleinnerspacing \allsplitstyles \thinmuskip -% \inherited\middleinnerspacing \allscriptstyles\tinymuskip -% \inherited\middlefracspacing \allsplitstyles \medmuskip -% \inherited\middlefracspacing \allscriptstyles\tinymuskip -% % \inherited\middleradspacing \allmathstyles \zeromuskip -% % -% \inherited\setmathspacing \mathclosecode \mathdifferentialcode \allsplitstyles \thinmuskip -% \inherited\setmathspacing \mathclosecode \mathdifferentialcode \allscriptstyles \tinymuskip -% \inherited\setmathspacing \mathordinarycode \mathdifferentialcode \allsplitstyles \thinmuskip -% \inherited\setmathspacing \mathordinarycode \mathdifferentialcode \allscriptstyles \tinymuskip -% \inherited\setmathspacing \mathfactorialcode \mathordinarycode \allsplitstyles \thinmuskip -% \inherited\setmathspacing \mathfactorialcode \mathordinarycode \allscriptstyles \tinymuskip -% \inherited\setmathspacing \mathfactorialcode \mathfactorialcode \allmathstyles \zeromuskip -% % -% \inherited\setmathspacing \mathopencode \mathconstructcode \allmathstyles \thinmuskip -% \inherited\setmathspacing \mathconstructcode \mathclosecode \allmathstyles \thinmuskip -% \stopsetups +%D \starttyping +%D \startformula +%D f(x) = \sin x \mt{,} x +%D \stopformula +%D +%D $f(x) = \sin x \mt{,} x$ +%D \stoptyping + +% mu based: 18mu == quad, preferred + +\newmuskip\mathinterwordmuskip + +% Hans: +% +% \mathinterwordmuskip 9mu plus .45mu minus .225mu +% +% Lansburg, p. 296: "A quad---nothing less, but also nothing more---is set between all independent formulas, independent of their length, +% height or character. + +\mathinterwordmuskip 18mu + +\permanent\protected\def\mtp#1{\mathatom class \mathtextpunctuationcode {\hbox{#1}}} % only at the outer level (text, display) + +% granular, but more clutter +% +% \newskip\mathinterwordtextskip +% \newskip\mathinterwordscriptskip +% \newskip\mathinterwordscriptscriptskip +% +% \appendtoks +% \mathinterwordtextskip \fontinterwordspace\textfont \zerocount \fontinterwordstretch\textfont \zerocount \fontinterwordshrink\textfont \zerocount \relax +% \mathinterwordscriptskip \fontinterwordspace\scriptfont \zerocount \fontinterwordstretch\scriptfont \zerocount \fontinterwordshrink\scriptfont \zerocount \relax +% \mathinterwordscriptscriptskip \fontinterwordspace\scriptscriptfont\zerocount \fontinterwordstretch\scriptscriptfont\zerocount \fontinterwordshrink\scriptscriptfont\zerocount \relax +% \to \everymathematics +% +% \inherited\setmathspacing \mathtextpunctuationcode \mathordcode \allmathstyles \mathinterwordtextskip +% \inherited\setmathspacing \mathtextpunctuationcode \mathordcode \allscriptstyles \mathinterwordscriptskip +% \inherited\setmathspacing \mathtextpunctuationcode \mathordcode \allscriptscriptstyles \mathinterwordscriptscriptskip \startsetups math:spacing:presets \resetmathspacing @@ -962,71 +958,83 @@ % \inherited\setmathspacing \mathordinarycode \mathordinarycode \allmathstyles \zeromuskip \inherited\setmathspacing \mathordinarycode \mathoperatorcode \allmathstyles \thinmuskip \inherited\setmathspacing \mathordinarycode \mathbinarycode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathordinarycode \mathbinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathordinarycode \mathbinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathordinarycode \mathrelationcode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathordinarycode \mathrelationcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathordinarycode \mathrelationcode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathordinarycode \mathopencode \allmathstyles \zeromuskip \inherited\setmathspacing \mathordinarycode \mathmiddlecode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathordinarycode \mathmiddlecode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathordinarycode \mathmiddlecode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathordinarycode \mathclosecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathordinarycode \mathpunctuationcode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathordinarycode \mathinnercode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathordinarycode \mathinnercode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathordinarycode \mathfractioncode \allmathstyles \tinymuskip - \inherited\setmathspacing \mathordinarycode \mathradicalcode \allmathstyles \tinymuskip + \inherited\setmathspacing \mathordinarycode \mathconstructcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathordinarycode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathordinarycode \mathellipsiscode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathordinarycode \mathellipsiscode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathordinarycode \mathfractioncode \allsplitstyles \tinymuskip + \inherited\setmathspacing \mathordinarycode \mathfractioncode \allscriptstyles \pettymuskip + % \inherited\setmathspacing \mathordinarycode \mathradicalcode \allsplitstyles \tinymuskip % 220705 Results in an unwanted space + % \inherited\setmathspacing \mathordinarycode \mathradicalcode \allscriptstyles \pettymuskip % 220705 Results in an unwanted space % \inherited\setmathspacing \mathoperatorcode \mathordinarycode \allmathstyles \thinmuskip \inherited\setmathspacing \mathoperatorcode \mathoperatorcode \allmathstyles \thinmuskip % \inherited\setmathspacing \mathoperatorcode \mathbinarycode \allmathstyles \ zeromuskip \inherited\setmathspacing \mathoperatorcode \mathrelationcode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathoperatorcode \mathrelationcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathoperatorcode \mathrelationcode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathoperatorcode \mathopencode \allmathstyles \zeromuskip \inherited\setmathspacing \mathoperatorcode \mathmiddlecode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathoperatorcode \mathmiddlecode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathoperatorcode \mathmiddlecode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathoperatorcode \mathclosecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathoperatorcode \mathpunctuationcode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathoperatorcode \mathinnercode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathoperatorcode \mathinnercode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathoperatorcode \mathconstructcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathoperatorcode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathoperatorcode \mathellipsiscode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathoperatorcode \mathellipsiscode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathoperatorcode \mathfractioncode \allmathstyles \thinmuskip \inherited\setmathspacing \mathoperatorcode \mathradicalcode \allmathstyles \thinmuskip % \inherited\setmathspacing \mathbinarycode \mathordinarycode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathbinarycode \mathordinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathbinarycode \mathordinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathbinarycode \mathoperatorcode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathbinarycode \mathoperatorcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathbinarycode \mathoperatorcode \allscriptstyles \pettymuskip %% \inherited\setmathspacing \mathbinarycode \mathbinarycode \allmathstyles \zeromuskip %% \inherited\setmathspacing \mathbinarycode \mathrelationcode \allmathstyles \zeromuskip \inherited\setmathspacing \mathbinarycode \mathopencode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathbinarycode \mathopencode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathbinarycode \mathopencode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathbinarycode \mathmiddlecode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathbinarycode \mathmiddlecode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathbinarycode \mathmiddlecode \allscriptstyles \pettymuskip %% \inherited\setmathspacing \mathbinarycode \mathclosecode \allmathstyles \zeromuskip - %% \inherited\setmathspacing \mathbinarycode \mathpunctuationcode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathbinarycode \mathinnercode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathbinarycode \mathinnercode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathbinarycode \mathpunctuationcode \allsplitstyles \medmuskip + \inherited\setmathspacing \mathbinarycode \mathpunctuationcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathbinarycode \mathconstructcode \allsplitstyles \medmuskip + \inherited\setmathspacing \mathbinarycode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathbinarycode \mathellipsiscode \allsplitstyles \medmuskip + \inherited\setmathspacing \mathbinarycode \mathellipsiscode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathbinarycode \mathfractioncode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathbinarycode \mathfractioncode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathbinarycode \mathfractioncode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathbinarycode \mathradicalcode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathbinarycode \mathradicalcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathbinarycode \mathradicalcode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathrelationcode \mathordinarycode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathrelationcode \mathordinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathrelationcode \mathordinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathrelationcode \mathoperatorcode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathrelationcode \mathoperatorcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathrelationcode \mathoperatorcode \allscriptstyles \pettymuskip %% \inherited\setmathspacing \mathrelationcode \mathbinarycode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathrelationcode \mathrelationcode \allmathstyles \zeromuskip \inherited\setmathspacing \mathrelationcode \mathopencode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathrelationcode \mathopencode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathrelationcode \mathopencode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathrelationcode \mathmiddlecode \allsplitstyles \thickmuskip \inherited\setmathspacing \mathrelationcode \mathmiddlecode \allscriptstyles \thinmuskip % \inherited\setmathspacing \mathrelationcode \mathclosecode \allmathstyles \zeromuskip - % \inherited\setmathspacing \mathrelationcode \mathpunctuationcode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathrelationcode \mathinnercode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathrelationcode \mathinnercode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathrelationcode \mathpunctuationcode \allsplitstyles \thickmuskip + \inherited\setmathspacing \mathrelationcode \mathpunctuationcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathrelationcode \mathconstructcode \allsplitstyles \thickmuskip + \inherited\setmathspacing \mathrelationcode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathrelationcode \mathellipsiscode \allsplitstyles \thickmuskip + \inherited\setmathspacing \mathrelationcode \mathellipsiscode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathrelationcode \mathfractioncode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathrelationcode \mathfractioncode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathrelationcode \mathfractioncode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathrelationcode \mathradicalcode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathrelationcode \mathradicalcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathrelationcode \mathradicalcode \allscriptstyles \pettymuskip % % \inherited\setmathspacing \mathopencode \mathordinarycode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathopencode \mathoperatorcode \allmathstyles \zeromuskip @@ -1036,125 +1044,169 @@ % \inherited\setmathspacing \mathopencode \mathmiddlecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathopencode \mathclosecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathopencode \mathpunctuationcode \allmathstyles \zeromuskip - % \inherited\setmathspacing \mathopencode \mathinnercode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathopencode \mathfractioncode \allmathstyles \tinymuskip + % \inherited\setmathspacing \mathopencode \mathconstructcode \allmathstyles \zeromuskip + % \inherited\setmathspacing \mathopencode \mathellipsiscode \allmathstyles \zeromuskip + \inherited\setmathspacing \mathopencode \mathfractioncode \allmathstyles \pettymuskip % \inherited\setmathspacing \mathopencode \mathradicalcode \allmathstyles \zeromuskip % - % \inherited\setmathspacing \mathclosecode \mathordinarycode \allmathstyles \zeromuskip + \inherited\setmathspacing \mathclosecode \mathordinarycode \allmathstyles \tinymuskip \inherited\setmathspacing \mathclosecode \mathoperatorcode \allmathstyles \thinmuskip \inherited\setmathspacing \mathclosecode \mathbinarycode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathclosecode \mathbinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathclosecode \mathbinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathclosecode \mathrelationcode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathclosecode \mathrelationcode \allscriptstyles \tinymuskip - % \inherited\setmathspacing \mathclosecode \mathopencode \allmathstyles \zeromuskip + \inherited\setmathspacing \mathclosecode \mathrelationcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathclosecode \mathopencode \alltextstyles \tinymuskip + \inherited\setmathspacing \mathclosecode \mathopencode \alldisplaystyles\thinmuskip + \inherited\setmathspacing \mathclosecode \mathopencode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathclosecode \mathmiddlecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathclosecode \mathclosecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathclosecode \mathpunctuationcode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathclosecode \mathinnercode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathclosecode \mathinnercode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathclosecode \mathconstructcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathclosecode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathclosecode \mathfactorialcode \allmathstyles \zeromuskip + \inherited\setmathspacing \mathclosecode \mathellipsiscode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathclosecode \mathellipsiscode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathclosecode \mathfractioncode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathclosecode \mathfractioncode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathclosecode \mathfractioncode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathclosecode \mathradicalcode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathpunctuationcode \mathordinarycode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathordinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathpunctuationcode \mathordinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathpunctuationcode \mathoperatorcode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathoperatorcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathpunctuationcode \mathoperatorcode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathpunctuationcode \mathbinarycode \allmathstyles \zeromuskip \inherited\setmathspacing \mathpunctuationcode \mathrelationcode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathrelationcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathpunctuationcode \mathrelationcode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathpunctuationcode \mathopencode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathopencode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathpunctuationcode \mathopencode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathpunctuationcode \mathmiddlecode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathmiddlecode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathpunctuationcode \mathmiddlecode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathpunctuationcode \mathclosecode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathclosecode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathpunctuationcode \mathclosecode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathpunctuationcode \mathpunctuationcode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathpunctuationcode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathpunctuationcode \mathinnercode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathinnercode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathpunctuationcode \mathpunctuationcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathpunctuationcode \mathconstructcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathpunctuationcode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathpunctuationcode \mathellipsiscode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathpunctuationcode \mathellipsiscode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathpunctuationcode \mathfractioncode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathfractioncode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathpunctuationcode \mathfractioncode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathpunctuationcode \mathradicalcode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathpunctuationcode \mathradicalcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathpunctuationcode \mathradicalcode \allscriptstyles \pettymuskip % - \inherited\setmathspacing \mathinnercode \mathordinarycode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathinnercode \mathordinarycode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathinnercode \mathoperatorcode \allmathstyles \thinmuskip - \inherited\setmathspacing \mathinnercode \mathbinarycode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathinnercode \mathbinarycode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathinnercode \mathrelationcode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathinnercode \mathrelationcode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathinnercode \mathopencode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathinnercode \mathopencode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathinnercode \mathmiddlecode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathinnercode \mathmiddlecode \allscriptstyles \tinymuskip - % \inherited\setmathspacing \mathinnercode \mathclosecode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathinnercode \mathpunctuationcode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathinnercode \mathpunctuationcode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathinnercode \mathinnercode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathinnercode \mathinnercode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathinnercode \mathfractioncode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathinnercode \mathfractioncode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathinnercode \mathradicalcode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathinnercode \mathradicalcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathconstructcode \mathordinarycode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathconstructcode \mathordinarycode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathconstructcode \mathoperatorcode \allmathstyles \thinmuskip + \inherited\setmathspacing \mathconstructcode \mathbinarycode \allsplitstyles \medmuskip + \inherited\setmathspacing \mathconstructcode \mathbinarycode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathconstructcode \mathrelationcode \allsplitstyles \thickmuskip + \inherited\setmathspacing \mathconstructcode \mathrelationcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathconstructcode \mathopencode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathconstructcode \mathopencode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathconstructcode \mathmiddlecode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathconstructcode \mathmiddlecode \allscriptstyles \pettymuskip + % \inherited\setmathspacing \mathconstructcode \mathclosecode \allmathstyles \zeromuskip + \inherited\setmathspacing \mathconstructcode \mathpunctuationcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathconstructcode \mathpunctuationcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathconstructcode \mathconstructcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathconstructcode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathconstructcode \mathfractioncode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathconstructcode \mathfractioncode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathconstructcode \mathradicalcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathconstructcode \mathradicalcode \allscriptstyles \pettymuskip % - \inherited\setmathspacing \mathfractioncode \mathordinarycode \allmathstyles \tinymuskip - \inherited\setmathspacing \mathfractioncode \mathoperatorcode \allmathstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathordinarycode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathordinarycode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathellipsiscode \mathoperatorcode \allmathstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathbinarycode \allsplitstyles \medmuskip + \inherited\setmathspacing \mathellipsiscode \mathbinarycode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathellipsiscode \mathrelationcode \allsplitstyles \thickmuskip + \inherited\setmathspacing \mathellipsiscode \mathrelationcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathellipsiscode \mathopencode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathopencode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathellipsiscode \mathmiddlecode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathmiddlecode \allscriptstyles \pettymuskip + % \inherited\setmathspacing \mathellipsiscode \mathclosecode \allmathstyles \zeromuskip + \inherited\setmathspacing \mathellipsiscode \mathpunctuationcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathpunctuationcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathellipsiscode \mathconstructcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathellipsiscode \mathellipsiscode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathellipsiscode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathellipsiscode \mathfractioncode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathfractioncode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathellipsiscode \mathradicalcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathellipsiscode \mathradicalcode \allscriptstyles \pettymuskip + % + % + \inherited\setmathspacing \mathfractioncode \mathordinarycode \allsplitstyles \tinymuskip + \inherited\setmathspacing \mathfractioncode \mathordinarycode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathfractioncode \mathoperatorcode \allsplitstyles \medmuskip + \inherited\setmathspacing \mathfractioncode \mathoperatorcode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathfractioncode \mathbinarycode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathfractioncode \mathbinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathfractioncode \mathbinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathfractioncode \mathrelationcode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathfractioncode \mathrelationcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathfractioncode \mathrelationcode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathfractioncode \mathopencode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathfractioncode \mathopencode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathfractioncode \mathopencode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathfractioncode \mathmiddlecode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathfractioncode \mathmiddlecode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathfractioncode \mathclosecode \allmathstyles \tinymuskip + \inherited\setmathspacing \mathfractioncode \mathmiddlecode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathfractioncode \mathclosecode \allmathstyles \pettymuskip % \inherited\setmathspacing \mathfractioncode \mathpunctuationcode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathfractioncode \mathinnercode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathfractioncode \mathinnercode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathfractioncode \mathconstructcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathfractioncode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathfractioncode \mathellipsiscode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathfractioncode \mathellipsiscode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathfractioncode \mathfractioncode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathfractioncode \mathfractioncode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathfractioncode \mathradicalcode \allmathstyles \tinymuskip + \inherited\setmathspacing \mathfractioncode \mathfractioncode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathfractioncode \mathradicalcode \allsplitstyles \tinymuskip + \inherited\setmathspacing \mathfractioncode \mathradicalcode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathradicalcode \mathordinarycode \allsplitstyles \tinymuskip + \inherited\setmathspacing \mathradicalcode \mathordinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathradicalcode \mathoperatorcode \allmathstyles \thinmuskip \inherited\setmathspacing \mathradicalcode \mathbinarycode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathradicalcode \mathbinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathradicalcode \mathbinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathradicalcode \mathrelationcode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathradicalcode \mathrelationcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathradicalcode \mathrelationcode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathradicalcode \mathopencode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathradicalcode \mathmiddlecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathradicalcode \mathclosecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathradicalcode \mathpunctuationcode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathradicalcode \mathinnercode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathradicalcode \mathinnercode \allscriptstyles \tinymuskip - \inherited\setmathspacing \mathradicalcode \mathfractioncode \allmathstyles \tinymuskip - \inherited\setmathspacing \mathradicalcode \mathradicalcode \allmathstyles \tinymuskip + \inherited\setmathspacing \mathradicalcode \mathconstructcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathradicalcode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathradicalcode \mathellipsiscode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathradicalcode \mathellipsiscode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathradicalcode \mathfractioncode \allsplitstyles \tinymuskip + \inherited\setmathspacing \mathradicalcode \mathfractioncode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathradicalcode \mathradicalcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathradicalcode \mathradicalcode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathmiddlecode \mathordinarycode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathmiddlecode \mathordinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathmiddlecode \mathordinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathmiddlecode \mathoperatorcode \allmathstyles \thinmuskip \inherited\setmathspacing \mathmiddlecode \mathbinarycode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathmiddlecode \mathbinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathmiddlecode \mathbinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathmiddlecode \mathrelationcode \allsplitstyles \thickmuskip - \inherited\setmathspacing \mathmiddlecode \mathrelationcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathmiddlecode \mathrelationcode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathmiddlecode \mathopencode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathmiddlecode \mathmiddlecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathmiddlecode \mathclosecode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathmiddlecode \mathpunctuationcode \allmathstyles \zeromuskip - \inherited\setmathspacing \mathmiddlecode \mathinnercode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathmiddlecode \mathinnercode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathmiddlecode \mathconstructcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathmiddlecode \mathconstructcode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathmiddlecode \mathellipsiscode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathmiddlecode \mathellipsiscode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathmiddlecode \mathfractioncode \allsplitstyles \medmuskip - \inherited\setmathspacing \mathmiddlecode \mathfractioncode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathmiddlecode \mathfractioncode \allscriptstyles \pettymuskip % \inherited\setmathspacing \mathmiddlecode \mathradicalcode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathclosecode \mathdifferentialcode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathclosecode \mathdifferentialcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathclosecode \mathdifferentialcode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathordinarycode \mathdifferentialcode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathordinarycode \mathdifferentialcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathordinarycode \mathdifferentialcode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathfactorialcode \mathordinarycode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathfactorialcode \mathordinarycode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathfactorialcode \mathordinarycode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathfactorialcode \mathfactorialcode \allmathstyles \zeromuskip % \inherited\setmathspacing \mathopencode \mathconstructcode \allmathstyles \thinmuskip @@ -1162,12 +1214,31 @@ % \inherited\setmathspacing \mathdimensioncode \mathdimensioncode \allmathstyles \zeromuskip \inherited\setmathspacing \mathordinarycode \mathdimensioncode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathordinarycode \mathdimensioncode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathordinarycode \mathdimensioncode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathdigitcode \mathdimensioncode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathdigitcode \mathdimensioncode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathdigitcode \mathdimensioncode \allscriptstyles \pettymuskip \inherited\setmathspacing \mathclosecode \mathdimensioncode \allsplitstyles \thinmuskip - \inherited\setmathspacing \mathclosecode \mathdimensioncode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathclosecode \mathdimensioncode \allscriptstyles \pettymuskip + \inherited\setmathspacing \mathfunctioncode \mathbinarycode \allsplitstyles \medmuskip + \inherited\setmathspacing \mathfunctioncode \mathbinarycode \allscriptstyles \pettymuskip % + \inherited\setmathspacing \mathfakecode \mathallcode \allmathstyles \tinymuskip + \inherited\setmathspacing \mathallcode \mathfakecode \allmathstyles \tinymuskip + % + \inherited\setmathspacing \mathtextpunctuationcode \mathordinarycode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathoperatorcode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathbinarycode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathrelationcode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathopencode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathmiddlecode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathclosecode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathpunctuationcode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathconstructcode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathellipsiscode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathfractioncode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathradicalcode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathdifferentialcode \allmathstyles \mathinterwordmuskip + \inherited\setmathspacing \mathtextpunctuationcode \mathpunctuationcode \allmathstyles \mathinterwordmuskip \stopsetups \directsetup{math:spacing:default} @@ -1449,6 +1520,7 @@ % % \letcsname\??mathclasses \endcsname\normalmathord % \letcsname\??mathclasses inner\endcsname\normalmathinner +% \letcsname\??mathclasses ellipsis\endcsname\normalmathellipsis % \letcsname\??mathclasses open\endcsname\normalmathopen % \letcsname\??mathclasses close\endcsname\normalmathclose % \letcsname\??mathclasses ordinary\endcsname\normalmathord @@ -1699,7 +1771,8 @@ \protected\def\math_function_handle#1#2#3% {\begingroup - \getdummyparameters[\c!mathlimits=,#1]% + \letdummyparameter\c!mathlimits\empty + \getdummyparameters[#1]% \edef\p_limits{\dummyparameter\c!mathlimits}% \mathatom mathfont @@ -1731,7 +1804,7 @@ \permanent\tolerant\protected\def\mfunctionlabeltext[#1]{\math_function_handle{#1}\mathlabeltext} \permanent\tolerant\protected\def\definemathfunction[#1]#*[#2]% - {\frozen\protected\defcsname#1\endcsname{\math_function_handle{#2}\mathlabeltext{#1}}} + {\frozen\protected\defcsname#1\endcsname{\math_function_handle{#2}\mathlabeltext{#1}}} % \instance \let\math_tags_mfunctiontxt\gobbletwoarguments \let\math_tags_mfunctionlab\gobbletwoarguments @@ -1916,8 +1989,8 @@ \Umathchardef\prime "0 "0 "2032 \fi -%D We also dropped th eoption to let ampersands be alignment tabs. That has never -%D been a \CONTEXT\ option anyway. +%D We also dropped the option to let ampersands be alignment tabs. That has never +%D been a \CONTEXT\ feature|/|habit anyway. \bgroup @@ -2422,7 +2495,7 @@ \bgroup - % This can adn will be replaced by classes: + % This can and will be replaced by classes: \catcode\c_math_comma \activecatcode \catcode\c_math_period \activecatcode @@ -3457,29 +3530,6 @@ \permanent\protected\def\mathminus {\ifmmode –\orelse\iffontchar\font`−−\else –\fi} \permanent\protected\def\mathplusminus{±} -%D The \type {\displaywidth} is only known inside a display formula, so we need to catch -%D it when still zero. - -\permanent\def\checkeddisplaywidth % hsize if zero - {\dimexpr - \ifzeropt\displaywidth - \hsize - \else - \displaywidth - \fi - \relax} - -\permanent\def\maximizeddisplaywidth % larger than zero but within hsize - {\dimexpr - \ifzeropt\displaywidth - \hsize - \orelse\ifdim\displaywidth>\hsize - \hsize - \else - \displaywidth - \fi - \relax} - %D Experiment: (todo: same switch as italic, using \type {\everyswitchmathematics}). \newcount\c_math_domain_attribute @@ -3817,17 +3867,60 @@ % can become a lua call that globally defined it, then we can have % partials -%D For now we define this here: +%D We're done with the double dollars: +%D +%D \startbuffer +%D before $ i = 1 $ after\par +%D before $ i = 2 \Ustopmath{} after\par +%D before \Ustartmath i = 3 $ after\par +%D before \Ustartmath i = 4 \Ustopmath{} after\par +%D before $$ d = 1 $$ after\par +%D before $$ d = 2 \Ustopdisplaymath{} after\par +%D before \Ustartdisplaymath d = 3 $$ after\par +%D before \Ustartdisplaymath d = 4 \Ustopdisplaymath{} after\par +%D \stopbuffer +%D +%D \startpacked {\mathdisplaymode\zerocount \getbuffer} \stoppacked +%D \startpacked {\mathdisplaymode\plusone \getbuffer} \stoppacked +%D +%D So we do: + +\mathdisplaymode\plusone -\ifdefined\d \let\text_d\d \else \let\text_d\firstofoneargument \fi +%D Just to be sure: -\pushoverloadmode +\immutable\integerdef\c_math_glyph_options\numexpr + \noexpansionglyphoptioncode + +\noprotrusionglyphoptioncode +\relax + +\appendtoks + \glyphoptions\c_math_glyph_options +\to \everymathematics - \permanent\protected\def\math_d{\mathatom unpack \mathdifferentialcode{d}} +%D Bonus for testing: - \permanent\protected\def\d{\mathortext\math_d\text_d} +% styles : regular sansserif monospaced fraktur script blackboard +% alternatives : normal bold italic bolditalic +% sets : ucletters lcletters digits ucgreek lcgreek symbols -\popoverloadmode +% \def\CheckMathHat#1{\ruledhbox{\im{\widehat{\Uchar#1}_1^2__3^^4}}} +% +% \dontleavehmode \traversemath{regular}{bold}{digits}{\CheckMathHat{#1}\hskip1em} + +\aliased\let\mathtraversecommand\relax + +\permanent\protected\def\traversemath#1#2#3#4% + {\pushmacro\mathtraversecommand + \enforced\def\mathtraversecommand##1{#4}% + \clf_traversemath{#1}{#2}{#3}\mathtraversecommand + \popmacro\mathtraversecommand} + +\permanent\protected\def\traverseblock#1#2% + {\pushmacro\mathtraversecommand + \enforced\def\mathtraversecommand##1{#2}% + \clf_traverseblock{#1}\mathtraversecommand + \popmacro\mathtraversecommand} \protect \endinput diff --git a/tex/context/base/mkxl/math-int.mkxl b/tex/context/base/mkxl/math-int.mkxl index 30d9643cf..db7aec7e2 100644 --- a/tex/context/base/mkxl/math-int.mkxl +++ b/tex/context/base/mkxl/math-int.mkxl @@ -54,7 +54,6 @@ \to \everyswitchmathematics \setupmathematics -% [\c!integral=nolimits] - [\c!integral=autolimits] + [\c!integral=nolimits] \protect \endinput diff --git a/tex/context/base/mkxl/math-lop.mkxl b/tex/context/base/mkxl/math-lop.mkxl index c860b1318..044ca0634 100644 --- a/tex/context/base/mkxl/math-lop.mkxl +++ b/tex/context/base/mkxl/math-lop.mkxl @@ -51,6 +51,11 @@ \letcsname\??mathoperatormethod nolimits\expandafter\endcsname\csname\??mathoperatormethod\v!horizontal\endcsname \letcsname\??mathoperatormethod limits\expandafter\endcsname\csname\??mathoperatormethod\v!vertical \endcsname +%D With the auto option DisplayOperatorMinHeight will kick in unless we explicitly set the size or +%D use the start|-|stop variant (which will size automatically). The default of this font parameter +%D are a bit on the small size which doesn't work well with fonts other than Latin Modern that has +%D a large one. Keep in mind that we have e.g. integrals as operators and not fixed characters. + \installlocalcurrenthandler\??mathoperators {mathoperator} \protected\def\math_operator_operator#1#2% @@ -67,6 +72,7 @@ \s!auto \fi \s!class \mathoperatorcode + \s!attr \indexofregister \c_attr_mathsize \attributeunsetvalue % todo: find a way to pick up or pass sup/sub to here \Udelimiter \zerocount \fam \mathoperatorparameter\c!left {\edef\m_operator_text{\mathoperatorparameter\c!top}% diff --git a/tex/context/base/mkxl/math-map.lmt b/tex/context/base/mkxl/math-map.lmt index 8637667de..f411505f2 100644 --- a/tex/context/base/mkxl/math-map.lmt +++ b/tex/context/base/mkxl/math-map.lmt @@ -56,6 +56,7 @@ mathematics = mathematics or { } local mathematics = mathematics local implement = interfaces.implement +local context = context -- Unfortunately some alphabets have gaps (thereby troubling all applications that -- need to deal with math). Somewhat strange considering all those weird symbols that @@ -108,7 +109,7 @@ mathematics.charactersets = allocate { }, } -mathematics.gaps = allocate { +local gaps = allocate { [0x1D455] = 0x0210E, -- ℎ h [0x1D49D] = 0x0212C, -- ℬ script B [0x1D4A0] = 0x02130, -- ℰ script E @@ -136,6 +137,8 @@ mathematics.gaps = allocate { [0x1D551] = 0x02124, -- ℤ bb Z } +mathematics.gaps = gaps + local function fillinmathgaps(tfmdata,key,value) local mathgaps = mathematics.gaps local characters = tfmdata.characters @@ -391,7 +394,7 @@ local monospaced_bi = tovector(sansserif_bi) local monospaced = { tf = monospaced_tf, it = monospaced_tf, - bf = monospaced_tf, + bf = monospaced_bf, bi = monospaced_bf, } @@ -548,6 +551,16 @@ regular.italic = tovector(regular_it) regular.bold = tovector(regular_bf) regular.bolditalic = tovector(regular_bi) +blackboard.normal = tovector(blackboard_tf) +blackboard.italic = tovector(blackboard_tf) +blackboard.bold = tovector(blackboard_tf) +blackboard.bolditalic = tovector(blackboard_tf) + +fraktur.normal = tovector(fraktur_tf) +fraktur.italic = tovector(fraktur_bf) +fraktur.bold = tovector(fraktur_tf) +fraktur.bolditalic = tovector(fraktur_bf) + alphabets.serif = tovector(regular) alphabets.type = tovector(monospaced) alphabets.teletype = tovector(monospaced) @@ -562,6 +575,8 @@ mathematics.boldmap = boldmap -- all math (a bit of redundancy here) (sorted for tracing) +-- so we can do: mathematics.alphabets.blackboard.tf.digits + for alphabet, styles in sortedhash(alphabets) do -- per 9/6/2011 we also have attr for missing for style, data in sortedhash(styles) do -- let's keep the long names (for tracing) @@ -752,6 +767,12 @@ function mathematics.remapalphabets(char,mathalphabet,mathgreek) if not mathalphabet then return end + local g = gaps[char] + if g then + report_remapping("gap character %U changed into %C",char,g) + char = g + return + end if mathgreek and mathgreek > 0 then if not isgreek[char] then -- nothing needed @@ -822,3 +843,39 @@ function mathematics.addfallbacks(main) checkedcopy(characters,regular.bi.ucgreek,regular.it.ucgreek) checkedcopy(characters,regular.bi.lcgreek,regular.it.lcgreek) end + +implement { + name = "traversemath", + arguments = { "string", "string", "string", "csname" }, + actions = function(style,alternative,set,command) + local d = alphabets[style] + if d then + d = d[alternative] + if d then + d = d[set] + if d then + local c = context[command] + for k, v in sortedhash(d) do + c(v) + end + end + end + end + end +} + +local blocks = characters.blocks + +implement { + name = "traverseblock", + arguments = { "string", "csname" }, + actions = function(name,command) + local b = blocks[string.nospaces(name)] + if b then + local c = context[command] + for k = b.first, b.last do + c(gaps[k] or k) + end + end + end +} diff --git a/tex/context/base/mkxl/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt index d74e212da..f93201459 100644 --- a/tex/context/base/mkxl/math-noa.lmt +++ b/tex/context/base/mkxl/math-noa.lmt @@ -7,6 +7,8 @@ if not modules then modules = { } end modules ['math-noa'] = { license = "see context related readme files" } +-- TODO: SET CLASSES ! + -- if specials and (specials[1] == "char" or specials[1] == "font") then -- can we avoid this -- ... better create a reverse mapping from the already present vectors @@ -73,7 +75,8 @@ local trace_fences = false registertracker("math.fences", function(v local trace_unstacking = false registertracker("math.unstack", function(v) trace_unstacking = v end) local trace_snapping = false registertracker("math.snapping", function(v) trace_snapping = v end) -local check_coverage = true registerdirective("math.checkcoverage", function(v) check_coverage = v end) +local check_coverage = true registerdirective("math.checkcoverage", function(v) check_coverage = v end) +local use_math_goodies = true registerdirective("math.nogoodies", function(v) use_math_goodies = not v end) local report_processing = logreporter("mathematics","processing") local report_remapping = logreporter("mathematics","remapping") @@ -234,13 +237,6 @@ local leftfence_code = fencecodes.left local middlefence_code = fencecodes.middle local rightfence_code = fencecodes.right --- local mathclasses = mathematics.classes --- local fenceclasses = { --- [leftfence_code] = mathclasses.open, --- [middlefence_code] = mathclasses.middle, --- [rightfence_code] = mathclasses.close, --- } - -- this initial stuff is tricky as we can have removed and new nodes with the same address -- the only way out is a free-per-page list of nodes (not bad anyway) @@ -1361,68 +1357,71 @@ do } local function initializemathalternates(tfmdata) - local goodies = tfmdata.goodies - local autolist = defaults -- table.copy(defaults) + if use_math_goodies then - local function setthem(newalternates) - local resources = tfmdata.resources -- was tfmdata.shared - local mathalternates = resources.mathalternates - local alternates, attributes, registered, presets - if mathalternates then - alternates = mathalternates.alternates - attributes = mathalternates.attributes - registered = mathalternates.registered - else - alternates, attributes, registered = { }, { }, { } - mathalternates = { - attributes = attributes, - alternates = alternates, - registered = registered, - presets = { }, - resets = { }, - hashes = setmetatableindex("table") - } - resources.mathalternates = mathalternates - end - -- - for name, data in sortedhash(newalternates) do - if alternates[name] then - -- ignore + local goodies = tfmdata.goodies + local autolist = defaults -- table.copy(defaults) + + local function setthem(newalternates) + local resources = tfmdata.resources -- was tfmdata.shared + local mathalternates = resources.mathalternates + local alternates, attributes, registered, presets + if mathalternates then + alternates = mathalternates.alternates + attributes = mathalternates.attributes + registered = mathalternates.registered else - local attr = known[name] - attributes[attr] = data - alternates[name] = attr - registered[#registered+1] = attr + alternates, attributes, registered = { }, { }, { } + mathalternates = { + attributes = attributes, + alternates = alternates, + registered = registered, + presets = { }, + resets = { }, + hashes = setmetatableindex("table") + } + resources.mathalternates = mathalternates + end + -- + for name, data in sortedhash(newalternates) do + if alternates[name] then + -- ignore + else + local attr = known[name] + attributes[attr] = data + alternates[name] = attr + registered[#registered+1] = attr + end end end - end - if goodies then - local done = { } - for i=1,#goodies do - -- first one counts - -- we can consider sharing the attributes ... todo (only once scan) - local mathgoodies = goodies[i].mathematics - local alternates = mathgoodies and mathgoodies.alternates - if alternates then - if trace_goodies then - report_goodies("loading alternates for font %a",tfmdata.properties.name) - end - for k, v in next, autolist do - if not alternates[k] then - alternates[k] = v + if goodies then + local done = { } + for i=1,#goodies do + -- first one counts + -- we can consider sharing the attributes ... todo (only once scan) + local mathgoodies = goodies[i].mathematics + local alternates = mathgoodies and mathgoodies.alternates + if alternates then + if trace_goodies then + report_goodies("loading alternates for font %a",tfmdata.properties.name) end + for k, v in next, autolist do + if not alternates[k] then + alternates[k] = v + end + end + setthem(alternates) + return end - setthem(alternates) - return end end - end - if trace_goodies then - report_goodies("loading default alternates for font %a",tfmdata.properties.name) + if trace_goodies then + report_goodies("loading default alternates for font %a",tfmdata.properties.name) + end + setthem(autolist) end - setthem(autolist) end @@ -1818,7 +1817,9 @@ do end function handlers.kernpairs(head,style,penalties) - processnoads(head,kernpairs,"kernpairs") + if use_math_goodies then + processnoads(head,kernpairs,"kernpairs") + end return true -- not needed end diff --git a/tex/context/base/mkxl/math-pln.mkxl b/tex/context/base/mkxl/math-pln.mkxl index ec64b7e4d..fa44fda2c 100644 --- a/tex/context/base/mkxl/math-pln.mkxl +++ b/tex/context/base/mkxl/math-pln.mkxl @@ -17,120 +17,34 @@ \unprotect -% we need proper unicode: +% We need proper unicode: \def\relbar{\mathrel{\smash-}} % - has the same height as + .. no clue what this refers to -% might change +%D This might change: \permanent\protected\def\hrulefill{\leaders\hrule\hfill} -%protected\def\dotfill {\cleaders\hbox{\normalstartimath\mathsurround\zeropoint\mkern1.5mu.\mkern1.5mu\normalstopimath}\hfill} - -% will move .. not used anyway - -\permanent\def\oalign#1% - {\leavevmode % plain tex uses this - \vtop - {\baselineskip\zeroskip - \lineskip.25\exheight - \ialign{\alignmark\alignmark\crcr#1\crcr}}} - -\permanent\def\ooalign % chars over each other - {\lineskiplimit-\maxdimen - \oalign} - -% needs checking - -\permanent\protected\def\choose{\atopwithdelims()} % used in korean test file, has to go -%permanent\protected\def\brack {\atopwithdelims[]} -%permanent\protected\def\brace {\atopwithdelims\{\}} - -% needs checking - -\permanent\protected\def\buildrel#1\over#2% - {\mathrel{\mathop{\kern\zeropoint#2}\limits^{#1}}} - - \permanent\protected\def\bmod - {\nonscript - \mskip-\medmuskip - \mkern5mu - \mfunction{mod}% - \penalty900 - \mkern5mu - \nonscript - \mskip-\medmuskip} - - \permanent\protected\def\pmod#1% - {\allowbreak - \mkern18mu - (\mfunction{mod}\mskip\medmuskip#1)} - -\permanent\protected\def\cases#1% - {\left\{% - \mskip\thinmuskip - \vcenter - {\normalbaselines - \mathsurround\zeropoint - \ialign{% - \normalstartimath\alignmark\alignmark\hfil\normalstopimath - \aligntab - \quad\alignmark\alignmark\hfil - \crcr - #1% - \crcr}}% - \right.} - -\permanent\protected\def\matrix#1% - {\emptyhbox - \mskip\thinmuskip - \vcenter - {\normalbaselines - \mathsurround\zeropoint - \ialign{% - \hfil\normalstartimath\alignmark\alignmark\normalstopimath\hfil - \aligntab - \aligntab - \quad\hfil\normalstartimath\alignmark\alignmark\normalstopimath\hfil - \crcr - \mathstrut - \crcr - \noalign{\kern-\baselineskip} - #1\crcr - \mathstrut - \crcr - \noalign{\kern-\baselineskip}}}% - \mskip\thinmuskip} - -\permanent\protected\def\pmatrix#1% - {\left(\matrix{#1}\right)} - -\permanent\protected\def\math_openup - {\afterassignment\math_openup_indeed\scratchdimen} - -\aliased\let\math_closeup\relax - -\def\math_openup_indeed - {\enforced\permanent\protected\edef\math_closeup - {\lineskip \the\lineskip - \baselineskip \the\baselineskip - \lineskiplimit\the\lineskiplimit - \relax}% - \advance \lineskip \scratchdimen - \advance \baselineskip \scratchdimen - \advance \lineskiplimit \scratchdimen} - -\permanent\protected\def\openup {\math_openup } % the low level ones are used elsewhere -\permanent\protected\def\closeup{\math_closeup} % the low level ones are used elsewhere - -\permanent\protected\def\displaylines#1% - {\the\mathdisplayaligntweaks - \tabskip\zeroskip - \halign - {\hbox to \displaywidth{% - \normalstartimath\tabskip\zeroskip\everycr\emptytoks\hfil\displaystyle\alignmark\alignmark\hfil\normalstopimath}\crcr - #1\crcr}} - -%D This comes from plain but I gave it a \CONTEXT\ touch: +%permanent\protected\def\dotfill {\cleaders\hbox{\normalstartimath\mathsurround\zeropoint\mkern1.5mu.\mkern1.5mu\normalstopimath}\hfill} + +%D These need an update: + +\permanent\protected\def\bmod + {\nonscript + \mskip-\medmuskip + \mkern5mu + \mfunction{mod}% + \penalty900 + \mkern5mu + \nonscript + \mskip-\medmuskip} + +\permanent\protected\def\pmod#1% + {\allowbreak + \mkern18mu + (\mfunction{mod}\mskip\medmuskip#1)} + +%D This comes from plain but I gave it a \CONTEXT\ touch. When Mikael and I are in +%D the mood we will redo them in a more modern way. \permanent\def\math_border_NC_indeed {\enforced\global\def\math_border_NC{\aligntab}} diff --git a/tex/context/base/mkxl/math-rad.mklx b/tex/context/base/mkxl/math-rad.mklx index e527f23ca..2293c2a90 100644 --- a/tex/context/base/mkxl/math-rad.mklx +++ b/tex/context/base/mkxl/math-rad.mklx @@ -161,13 +161,17 @@ \integerdef\c_radical_unicode "221A -\protected\def\math_radical_common +% We use a strut in the degree because not all fonts have the right gaps set up but +% as struts are sort of predictable we can now fix all fonts in the lfg file. + +\protected\def\math_radical_common#degree% {\Uroot \s!height\dimexpr\mathradicalparameter\c!height\relax \s!depth \dimexpr\mathradicalparameter\c!depth\relax \s!source\numexpr\namedboxanchor{\mathradicalparameter\c!source}\relax \s!style \normalmathstyle - \zerocount \c_radical_unicode} + \zerocount \c_radical_unicode + {\mathstrut#degree}} \defcsname\??mathradicalalternative\v!default\endcsname % #body% {\math_radical_common{\currentmathradicaldegree}} % {#body}} diff --git a/tex/context/base/mkxl/math-spa.lmt b/tex/context/base/mkxl/math-spa.lmt index 32de6e417..487d9e4a4 100644 --- a/tex/context/base/mkxl/math-spa.lmt +++ b/tex/context/base/mkxl/math-spa.lmt @@ -8,79 +8,139 @@ if not modules then modules = { } end modules ['math-spa'] = { -- for the moment (when testing) we use a penalty 1 -local boundary_code = nodes.nodecodes.boundary -local glue_code = nodes.nodecodes.glue +local setmetatableindex = table.setmetatableindex -local nuts = nodes.nuts -local tonut = nodes.tonut -local tonode = nodes.tonode +local boundary_code = nodes.nodecodes.boundary +local hlist_code = nodes.nodecodes.hlist +local glue_code = nodes.nodecodes.glue +local line_code = nodes.listcodes.line +local ghost_code = nodes.listcodes.ghost -local getid = nuts.getid -local getnext = nuts.getnext -local getwidth = nuts.getwidth -local getdata = nuts.getdata -local setglue = nuts.setglue -local getdimensions = nuts.dimensions -local nextglue = nuts.traversers.glue +local nuts = nodes.nuts +local tonut = nodes.tonut +local tonode = nodes.tonode -local texsetdimen = tex.setdimen +local getid = nuts.getid +local getsubtype = nuts.getsubtype +local getnext = nuts.getnext +local getwidth = nuts.getwidth +local getdata = nuts.getdata +local getdepth = nuts.getdepth +local getlist = nuts.getlist +local setglue = nuts.setglue +local getdimensions = nuts.dimensions +local getnormalizedline = node.direct.getnormalizedline +local getbox = nuts.getbox +local setoffsets = nuts.setoffsets -local v_none = interfaces.variables.none -local v_auto = interfaces.variables.auto +local nextglue = nuts.traversers.glue +local nextlist = nuts.traversers.list +local nextboundary = nuts.traversers.boundary -local method = v_none -local distance = 0 -local boundary = tex.boundaries.system("mathalign") +local texgetdimen = tex.getdimen +local texsetdimen = tex.setdimen +local texsetcount = tex.setcount -function noads.handlers.align(h) - if method ~= v_none then - if method == v_auto then - --- can be a fast loop - local s = h - while s do - local id = getid(s) - local n = getnext(s) - if id == boundary_code and getdata(s) == boundary then - if n and getid(n) == glue_code then - s = n - n = getnext(s) - end - local w = getdimensions(h,n) + distance - texsetdimen("global","d_strc_math_indent",w) - break - end - s = n +local boundary = tex.boundaries.system("mathalign") +local stages = { } +local initial = { } + +stages[1] = function(specification,stage) + local box = getbox(specification.box) + local head = getlist(box) + local align = specification.alignstate + local distance = specification.distance + for s in nextboundary, head do + if getdata(s) == boundary then + -- todo: skip over ghost, maybe penalty, maybe glues all in one loop + local n = getnext(s) + while n and getid(n) == hlist_code and getsubtype(n) == ghost_code do + n = getnext(n) end - else - texsetdimen("global","d_strc_math_indent",distance) + -- while n and getid(n) == glue_code do + if n and getid(n) == glue_code then + n = getnext(n) + end + distance = distance + getdimensions(head,n) + break end - for n in nextglue, h do - setglue(n,getwidth(n),0,0) + end + texsetdimen("global","d_strc_math_indent",distance) + if align == 2 then + for n in nextglue, head do + setglue(n,getwidth(n),0,0,0,0) end - else - -- texsetdimen("global","d_strc_math_indent",0) end end +stages[2] = function(specification,stage) + local head = getlist(getbox(specification.box)) + local align = specification.alignstate + local max = false + local cnt = 0 + local width = 0 + local depth = 0 + for n, id, subtype, list in nextlist, head do + if subtype == line_code then + local t = getnormalizedline(n) + local m = t.rightskip + t.parfillrightskip + if not max then + max = m + elseif m < max then + max = m + end + cnt = cnt + 1 + width = m + depth = getdepth(n) + end + end + if stage == 2 and (align == 2 or align == 3) then + for n, id, subtype, list in nextlist, head do + if subtype == line_code then + if align == 1 then -- flushleft + elseif align == 2 then -- middle + setoffsets(n,max/2,0) + elseif align == 3 then -- flushright + setoffsets(n,max,0) + end + end + end + end + texsetcount("global","c_strc_math_n_of_lines",cnt) + texsetdimen("global","d_strc_math_max_width",max) + texsetdimen("global","d_strc_math_last_width",width) + texsetdimen("global","d_strc_math_last_depth",depth) +end + +stages[3] = stages[2] + +stages[4] = function(specification,stage) + nuts.openup(specification,getlist(getbox(specification.box))) +end + interfaces.implement { - name = "setmathhang", + name = "handlemathhang", arguments = { { - { "method", "string" }, + { "stage", "integer" }, + -- { "method" }, + { "alignstate", "integer" }, + { "box", "integer" }, { "distance", "dimension" }, + { "inbetween", "dimension" }, + { "height", "dimension" }, + { "depth", "dimension" }, } }, - actions = function(t) - method = t.method or v_none - distance = t.distance or 0 - end -} - -interfaces.implement { - name = "resetmathhang", - actions = function(t) - method = v_none - distance = 0 + actions = function(specification) + local stage = specification.stage + if stage == 1 then + initial = specification + else + setmetatableindex(specification,initial) + end + if stage > 0 and stage <= #stages then + stages[stage](specification,stage) + end end } - diff --git a/tex/context/base/mkxl/math-stc.mklx b/tex/context/base/mkxl/math-stc.mklx index 86c6b6499..bed61bb62 100644 --- a/tex/context/base/mkxl/math-stc.mklx +++ b/tex/context/base/mkxl/math-stc.mklx @@ -185,7 +185,8 @@ \c!distance=\mathstackersparameter\c!voffset, % distance between symbol and base (can be different from voffset) \c!minheight=\mathexheight, \c!mindepth=\zeropoint, - \c!minwidth=.5\mathemwidth, + % \c!minwidth=.5\mathemwidth, + \c!minwidth=.25\mathemwidth, % \iota \c!order=\v!normal, \c!strut=, \c!color=, % todo: when I need it @@ -532,7 +533,8 @@ \edef\p_limits{\mathstackersparameter\c!mathlimits}% \ifx\p_limits\v!yes \def\math_stackers_stop_group{\egroup\endgroup\ordlimits}% - \mathop\bgroup + % \mathop\bgroup + \mathaccent\bgroup \else \let\math_stackers_stop_group\endgroup \fi} @@ -1252,6 +1254,8 @@ \thickmuskip \zeromuskip \medmuskip \zeromuskip \thinmuskip \zeromuskip + \tinymuskip \zeromuskip + \pettymuskip \zeromuskip #1% \mkern-7\onemuskip \cleaders\mathstylehbox{\mkern-2\onemuskip#2\mkern-2\onemuskip}\hfill diff --git a/tex/context/base/mkxl/meta-imp-functions.lmt b/tex/context/base/mkxl/meta-imp-functions.lmt new file mode 100644 index 000000000..195669d08 --- /dev/null +++ b/tex/context/base/mkxl/meta-imp-functions.lmt @@ -0,0 +1,260 @@ +if not modules then modules = { } end modules ['meta-imp-functions'] = { + version = 1.001, + comment = "companion to meta-imp-functions.mkxl", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +local formatters = string.formatters +local sequenced = table.sequenced + +local noffunctions = 0 +local version = 1 + +local function preparecache(p) + noffunctions = noffunctions + 1 +local action = p.action +p.action = nil + local hash = md5.HEX(sequenced(p)) + local name = formatters["mkiv-%s-m-f-%03i.lua"](tex.jobname,noffunctions) +p.action = action + return name, hash +end + +local function getcache(p) + local cache = p.cache + if cache then + local name, hash = preparecache(p) + local data = table.load(name) + if data and data.hash == hash and data.version == version and data.data then + return hash, name, data.data + else + return hash, name, false + end + else + return false, false, false + end +end + +local function setcache(hash,name,data) + local result = { + version = version, + hash = hash, + data = data, + } + table.save(name,result) +end + +local injectpath = mp.inject.path +local getparameterset = metapost.getparameterset + +local report = logs.reporter("metapost","functions") + +local functions = { } +local actions = { } + +function mp.registerfunction(specification) + local name = specification.name + functions[name] = specification +end + +function mp.registeraction(specification) + local name = specification.name + actions[name] = specification +end + +metapost.registerscript("processfunction", function() + local specification = getparameterset("function") + local name = specification.name + local lua = specification.lua + local fnction = functions[name] + local action = lua and actions[lua] + if fnction then + if action then + specification.action = action.action + end + -- statistics.starttiming(functions) + fnction.action(specification) + -- statistics.stoptiming(functions) + end +end) + +-- statistics.register("mp function time", function() +-- return statistics.elapsedseconds(functions,"including feedback to metapost") +-- end) + +-- Here comes the fancy stuff: + +local math = math +local sqrt = math.sqrt + +local mathfunctions = math.functions or { } +math.functions = mathfunctions + +-- Todo : reference where we got the factors from because those from +-- +-- This is Runge-Kutta-Merson 4("5") +-- See Table 4.1. Merson 4("5") of Hairer, Nørsett, Wanner - Solving Ordinary Differential Equations I (Springer, 2008) +-- +-- function mathfunctions.rungekutta(specification) +-- local f = specification.action or function(t,x,y) return x, y end +-- local x = specification.x or 0 +-- local y = specification.y or 0 +-- local t = 0 +-- local tmax = specification.tmax or 1 +-- local dt = specification.dt or tmax/10 +-- local eps = specification.eps or dt/10 +-- local r = 1 +-- -- local result = { { x, y, x, y, x, y } } +-- local result = { { x, y } } +-- while t < tmax do +-- local k1x, k1y = f(t, x, +-- y) +-- k1x = dt * k1x +-- k1y = dt * k1y +-- local k2x, k2y = f(t + (1/3) * dt, x + (1/3) * k1x, +-- y + (1/3) * k1y) +-- k2x = dt * k2x +-- k2y = dt * k2y +-- local k3x, k3y = f(t + (1/3) * dt, x + (1/6) * k1x + (1/6) * k2x, +-- y + (1/6) * k1y + (1/6) * k2y) +-- k3x = dt * k3x +-- k3y = dt * k3y +-- local k4x, k4y = f(t + (1/2) * dt, x + (1/8) * k1x + (3/8) * k3x, +-- y + (1/8) * k1y + (3/8) * k3y) +-- k4x = dt * k4x +-- k4y = dt * k4y +-- local k5x, k5y = f(t + dt, x + (1/2) * k1x - (3/2) * k3x - (2) * k4x, +-- y + (1/2) * k1y - (3/2) * k3y - (2) * k4y) +-- k5x = dt * k5x +-- k5y = dt * k5y +-- -- +-- local teps = sqrt(((1/10-1/6) * k1x + (3/10) * k3x + (2/5-2/3) * k4x + (1/5 -1/6) * k5x)^2 + +-- ((1/10-1/6) * k1y + (3/10) * k3y + (2/5-2/3) * k4y + (1/5 -1/6) * k5y)^2 ) +-- if teps < eps then +-- dt = 0.9 * dt * (eps/teps)^(1/4) +-- x = x + (1/10) * k1x + (3/10) * k3x + (2/5) * k4x + (1/5) * k5x +-- y = y + (1/10) * k1y + (3/10) * k3y + (2/5) * k4y + (1/5) * k5y +-- r = r + 1 +-- -- result[r] = { x, y, x, y, x, y } +-- result[r] = { x, y } +-- t = t + dt +-- else +-- dt = 0.9 * dt * (eps/teps)^(1/3) +-- end +-- end +-- return result +-- end + +local function rungekutta(specification) + local f = specification.action or function(t,x,y) return x, y end + local x = specification.x or 0 + local y = specification.y or 0 + local tmin = specification.tmin or 0 + local tmax = specification.tmax or 1 + local t = tmin + local rmax = specification.maxpath or 0 + local stepsize = specification.stepsize or "adaptive" + local dt = specification.dt or (tmax-tmin)/10 + local eps = specification.eps or dt/10 + local kind = specification.kind or specification.type -- xy x y + local adaptive = stepsize == "adaptive" + local r = 1 + local result + if kind ~= "tx" and kind ~= "ty" then + kind = "xy" + end + if kind == "xy" then + -- result = { { x, y, x, y, x, y } } + result = { { x, y } } + elseif kind == "tx" then + -- result = { { x, x, t, x, t, x } } + result = { { t, x } } + else + -- result = { { x, y, t, y, t, y } } + result = { { t, y } } + end + local hash, name, data = getcache(specification) + if data then + -- print(hash,name,"REUSING") + return data + else + -- print(hash,name,"GENERATING") + end + if rmax == 0 then + rmax = 0xFFFF + end + + while t < tmax do + local k1x, k1y = f(t, x, + y) + k1x = dt * k1x + k1y = dt * k1y + local k2x, k2y = f(t + (1/3) * dt, x + (1/3) * k1x, + y + (1/3) * k1y) + k2x = dt * k2x + k2y = dt * k2y + local k3x, k3y = f(t + (1/3) * dt, x + (1/6) * k1x + (1/6) * k2x, + y + (1/6) * k1y + (1/6) * k2y) + k3x = dt * k3x + k3y = dt * k3y + local k4x, k4y = f(t + (1/2) * dt, x + (1/8) * k1x + (3/8) * k3x, + y + (1/8) * k1y + (3/8) * k3y) + k4x = dt * k4x + k4y = dt * k4y + local k5x, k5y = f(t + dt, x + (1/2) * k1x - (3/2) * k3x - (2) * k4x, + y + (1/2) * k1y - (3/2) * k3y - (2) * k4y) + k5x = dt * k5x + k5y = dt * k5y + -- + if adaptive then + local teps = sqrt(((1/10-1/6) * k1x + (3/10) * k3x + (2/5-2/3) * k4x + (1/5 -1/6) * k5x)^2 + + ((1/10-1/6) * k1y + (3/10) * k3y + (2/5-2/3) * k4y + (1/5 -1/6) * k5y)^2 ) + local step = eps/teps + if teps < eps then + step = step^(1/4) + dt = 0.9 * dt * step + else + step = step^(1/3) + dt = 0.9 * dt * step + goto again + end + end + ::append:: + t = t + dt + x = x + (1/10) * k1x + (3/10) * k3x + (2/5) * k4x + (1/5) * k5x + y = y + (1/10) * k1y + (3/10) * k3y + (2/5) * k4y + (1/5) * k5y + r = r + 1 + if kind == "xy" then + result[r] = { x, y } + elseif kind == "tx" then + result[r] = { t, x } + else + result[r] = { t, y } + end + if r >= rmax then + -- report("pathmax is set to %i, quiting",rmax) + break + end + ::again:: + end + if name and hash then + setcache(hash,name,result) + end + return result +end + +mathfunctions.rungekutta = rungekutta + +mp.registerfunction { + name = "rungekutta", + action = function(specification) + local result = rungekutta(specification) + if result then + injectpath(result) + else + injectpath { { 0, 0 } } + end + end +} diff --git a/tex/context/base/mkxl/meta-imp-functions.mkxl b/tex/context/base/mkxl/meta-imp-functions.mkxl new file mode 100644 index 000000000..dd20ea8b8 --- /dev/null +++ b/tex/context/base/mkxl/meta-imp-functions.mkxl @@ -0,0 +1,342 @@ +%D \module +%D [ file=meta-imp-functions, +%D version=2022.05.17, +%D title=\METAPOST\ Graphics, +%D subtitle=All kind of functions, +%D author=Mikael Sundqvist & Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% \useMPlibrary[functions] + +% todo: as with contours, cache + +\registerctxluafile{meta-imp-functions}{autosuffix} + +\startMPextensions + newscriptindex mfid_processfunction ; mfid_processfunction := scriptindex("processfunction") ; + + presetparameters "function" [ name = "unknown", smoothen = false, maxpath = 65536 ] ; + + def lmt_processfunction = applyparameters "function" "lmt_do_processfunction" enddef ; + + vardef lmt_do_processfunction = + if getparameter "function" "smoothen" : + for k within (runscript mfid_processfunction) : pathpoint .. endfor nocycle + else : + (runscript mfid_processfunction) + fi + enddef ; +\stopMPextensions + +\continueifinputfile{meta-imp-functions.mkxl} + +\starttext + +\startluacode + mp.registeraction { + name = "ms2", + action = function(t, x, y) + return -y, x + end + } +\stopluacode + +\startMPpage + path p ; p := lmt_processfunction [ + name = "rungekutta" + lua = "ms2", + x = 1, + y = 0, + tmax = 6pi, + dt = 0.001, + eps = 0.00001, + ] xysized (5cm,5cm) ; + draw p withcolor red withpen pencircle scaled 1 ; + path q ; q := for i within p : pathpoint .. endfor nocycle ; + draw q withcolor green withpen pencircle scaled 1/2 ; +\stopMPpage + +% + +\startluacode + mp.registeraction { + name = "ms3", + action = function(t, x, y) + return 1, -t*y*y + end + } +\stopluacode + +\startMPpage + path p ; p := lmt_processfunction [ + name = "rungekutta" + lua = "ms3", + x = 0, + y = 2, + tmax = 10, + dt = 0.001, + eps = 0.00001, + ] xysized (5cm,5cm) ; + draw p withcolor red withpen pencircle scaled 6 ; +\stopMPpage + +% + +\startluacode + mp.registeraction { + name = "ms4", + action = function(t, x, y) + return 1, -y + end + } +\stopluacode + +\startMPpage + path p ; p := lmt_processfunction [ + name = "rungekutta" + lua = "ms4", + x = 0, + y = 1, + tmax = 10, + dt = 0.001, + eps = 0.00001, + ] scaled 5cm ; + draw p withcolor red withpen pencircle scaled 6 ; +\stopMPpage + +% + +\startluacode + mp.registeraction { + name = "ms5", + action = function(t, x, y) + return x + y + x*x + y*y, x - y - x*x + y*y + end + } +\stopluacode + +\startMPpage + path b ; numeric s; + + s := 1cm ; + b := ((-2.5,-2.5) -- (1.5,-2.5) -- (1.5,1.5) -- (-2.5,1.5) -- cycle) scaled s ; + + for i = -3.05 step 0.1 until 2.5 : + for j = -3.05 step 0.1 until 2.5 : + draw lmt_processfunction [ + name = "rungekutta", + lua = "ms5", + x = i, + y = j, + tmax = 10, + dt = 0.1, + eps = 0.001, + smoothen = true, + maxpath = 500, % crazy large paths .. so kind of bad spec here + ] + scaled s + withpen pencircle scaled 0.1 + withcolor (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1)) + ; + endfor ; + endfor ; + + % so how much slack ? + + draw b withpen pencircle scaled 2 ; + clip currentpicture to b ; + +\stopMPpage + +% https://wolfram.com/xid/0dekz2-wla + +\startluacode + mp.registeraction { + name = "mma1", + action = function(t, x, y) + return 1, y*math.cos(x+y) + end + } +\stopluacode + +\startMPpage + path p ; p := lmt_processfunction [ + name = "rungekutta" + lua = "mma1", + x = 0, + y = 1, + tmax = 30, + dt = 0.001, + eps = 0.00001, + ] xysized(10cm,5cm) ; + draw p withcolor red withpen pencircle scaled 2 ; + drawpoints p withcolor blue withpen pencircle scaled 2 ; +\stopMPpage + +% https://wolfram.com/xid/0dekz2-gpx + +\startluacode + mp.registeraction { + name = "mma2", + action = function(t, x, y) + return -y-x*x, 2*x-y*y*y + end + } +\stopluacode + +\startMPpage + path p ; p := lmt_processfunction [ + name = "rungekutta" + lua = "mma2", + x = 1, + y = 1, + tmax = 20, + dt = 0.001, + eps = 0.00001, + ] xysized(10cm,10cm) ; + draw p withcolor red withpen pencircle scaled 2 ; + drawpoints p withcolor blue withpen pencircle scaled 2 ; +\stopMPpage + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% https://wolfram.com/xid/0dekz2-xixft + +\startluacode + mp.registeraction { + name = "mma3", + action = function(t, x, y) + return y, -0.1 * y - math.sin(x) + 0.5 * math.cos(t) + end + } +\stopluacode + +\startMPpage + path p ; p := lmt_processfunction [ + name = "rungekutta" + lua = "mma3", + x = 0, + y = 0, + tmax = 100, + dt = 0.001, + eps = 0.00001, + ] xysized(10cm,10cm) ; + draw p withcolor red withpen pencircle scaled 2 ; + drawpoints p withcolor blue withpen pencircle scaled 2 ; +\stopMPpage + +% https://wolfram.com/xid/0dekz2-dmilmp +% Stiff! Not working! + +% \startluacode +% mp.registeraction { +% name = "mma4", +% action = function(t, x, y) +% return y, - x + 1000 * (1 - x * x) * y +% end +% } +% \stopluacode + +% \startMPpage % [instance=decimalfun] +% path p ; p := lmt_processfunction [ +% name = "rungekutta" +% lua = "mma4", +% x = 2, +% y = 0, +% tmax = 2000, +% dt = 0.01, +% eps = 0.0001 +% ] xynormalized(10cm,10cm) ; +% draw p +% withpen pencircle scaled 2 +% withcolor red +% ; +% % drawpoints p withcolor blue withpen pencircle scaled 2 ; +% \stopMPpage + +% https://wolfram.com/xid/0dekz2-d1orb +% Discontinuous right-hand side + +\startluacode + mp.registeraction { + name = "mma5", + action = function(t, x, y) + return 1, - math.cos(y) + math.floor(t) + end + } +\stopluacode + +\startMPpage + save n ; n := 0 ; + for i = "xy", "tx", "ty" : + path p ; p := lmt_processfunction [ + name = "rungekutta", + type = i, + lua = "mma5", + x = 0, + y = 1, + tmax = 3, + dt = 0.001, + eps = 0.0001, + ] xysized(10cm,10cm) shifted (n*11cm,0) ; + draw p withcolor red withpen pencircle scaled 2 ; + drawpoints p withcolor blue withpen pencircle scaled 2 ; + n := n + 1 ; + endfor ; +\stopMPpage + +\startluacode + mp.registeraction { + name = "mma6", + action = function(t, x, y) + return y, -x + end + } +\stopluacode + +\startMPpage + save n ; n := 0 ; + for i = "xy", "tx", "ty" : + path p ; p := lmt_processfunction [ + name = "rungekutta", + kind = i, + lua = "mma6", + x = 1, + y = 0, + tmin = 0, + tmax = 6.28, + dt = 0.001, + eps = 0.0000001, + ] xysized(10cm,10cm) shifted (n*11cm,0) ; + draw p withcolor red withpen pencircle scaled 2 ; + drawpoints p withcolor blue withpen pencircle scaled 2 ; + n := n + 1 ; + endfor ; +\stopMPpage + +\startMPpage + save n ; n := 0 ; + for i = "xy", "tx", "ty" : + path p ; p := lmt_processfunction [ + name = "rungekutta", + kind = i, + lua = "mma6", + x = 1, + y = 0, + tmin = 0, + tmax = 6, + stepsize = "fixed", + dt = 0.5, + maxpath = 3, + ] xysized(10cm,10cm) shifted (n*11cm,0) ; + draw p withcolor red withpen pencircle scaled 2 ; + drawpoints p withcolor blue withpen pencircle scaled 2 ; + n := n + 1 ; + endfor ; +\stopMPpage + +\stoptext diff --git a/tex/context/base/mkxl/mlib-cnt.lmt b/tex/context/base/mkxl/mlib-cnt.lmt index 9d8a483ba..35ea4067a 100644 --- a/tex/context/base/mkxl/mlib-cnt.lmt +++ b/tex/context/base/mkxl/mlib-cnt.lmt @@ -194,7 +194,7 @@ local n_box = 0 local nofcontours = 0 --- We don't want cosmetics like axis and labels to trigger a calculation, +-- We don't want cosmetics like axis and labels to trigger a calculation, -- especially a slow one. local hashfields = { @@ -1837,12 +1837,41 @@ local f_function_y = formatters [ [[ end ]] ] +-- local f_color = formatters [ [[ +-- local math = math +-- return function(f) +-- return %s +-- end +-- ]] ] + local f_color = formatters [ [[ - local math = math - return function(f) - return %s - end -]] ] + local math = math + local min = math.min + local max = math.max + local abs = math.abs + local minz = %s + local maxz = %s + -- + local color_value = 0 + local color_step = mp.lmt_color_functions.step + local color_shade = mp.lmt_color_functions.shade + + local function step(...) + return color_step(color_value,n,...) + end + local function shade(...) + return color_shade(color_value,n,...) + end + -- local function lin(l) + -- return l/n + -- end + %s + return function(f,z) + brightness_factor = f + function_value = z + return %s + end + ]] ] function mp.lmt_surface_do(specification) -- @@ -1898,7 +1927,7 @@ function mp.lmt_surface_do(specification) local dy = (ymax - ymin) / ny local xt = xmin -- - local minf, maxf + local minf, maxf, minz, maxz -- -- similar as contours but no data loop here -- @@ -1908,12 +1937,6 @@ function mp.lmt_surface_do(specification) return false -- fatal error end -- - local ccode = load(f_color(colorcode)) - local color = type(ccode) == "function" and ccode() - if type(color) ~= "function" then - return false -- fatal error - end - -- for i=0,nx do local yt = ymin for j=0,ny do @@ -1946,8 +1969,16 @@ function mp.lmt_surface_do(specification) maxf = fac end -- - data[i][j] = { x, y, fac } - -- + if not minz then + minz = z + maxz = z + elseif z < minz then + minz = z + elseif z > maxz then + maxz = z + end + data[i][j] = { x, y, fac, z } + -- yt = yt + dy end xt = xt + dx @@ -1957,6 +1988,11 @@ function mp.lmt_surface_do(specification) local range = maxf - minf local cl = linecolor or 1 local enforce = attributes.colors.model == "cmyk" + local ccode = load(f_color(minz,maxz,preamble,colorcode)) + local color = type(ccode) == "function" and ccode() + if type(color) ~= "function" then + return false -- fatal error + end for i=0,nx-1 do for j=0,ny-1 do -- points @@ -1990,7 +2026,7 @@ function mp.lmt_surface_do(specification) -- else -- -- fill and draw in one go to prevent artifacts -- end - local cr, cg, cb = color(cf) + local cr, cg, cb = color(cf,z1[4]) -- cf, zout if not cr then cr = 0 end if not cg then cg = 0 end if not cb then cb = 0 end diff --git a/tex/context/base/mkxl/mlib-fio.lmt b/tex/context/base/mkxl/mlib-fio.lmt index d0917392a..7bb6c0e9b 100644 --- a/tex/context/base/mkxl/mlib-fio.lmt +++ b/tex/context/base/mkxl/mlib-fio.lmt @@ -275,7 +275,8 @@ function mplib.new(specification) local instance instance = mplibnew { -- used - tolerance = specification.tolerance, + bend_tolerance = specification.bendtolerance, + move_tolerance = specification.movetolerance, math_mode = specification.mathmode, run_script = specification.runscript, run_internal = specification.runinternal, diff --git a/tex/context/base/mkxl/mlib-pdf.lmt b/tex/context/base/mkxl/mlib-pdf.lmt index f537743aa..3fe09eb93 100644 --- a/tex/context/base/mkxl/mlib-pdf.lmt +++ b/tex/context/base/mkxl/mlib-pdf.lmt @@ -165,7 +165,7 @@ local function flushnormalpath(path, t, open, tolerance) for i=1,length do nt = nt + 1 pth = path[i] - if not ith then + if not ith or pth.state == 1 then t[nt] = f_m(pth.x_coord,pth.y_coord) elseif curved(ith,pth,tolerance) then -- elseif pth.curved then @@ -178,7 +178,9 @@ local function flushnormalpath(path, t, open, tolerance) if not open then nt = nt + 1 local one = path[1] - if curved(pth,one,tolerance) then + if one.state == 1 then + t[nt] = f_m(one.x_coord,one.y_coord) + elseif curved(pth,one,tolerance) then -- if one.curved then t[nt] = f_c(pth.right_x,pth.right_y,one.left_x,one.left_y,one.x_coord,one.y_coord) else @@ -209,7 +211,7 @@ local function flushconcatpath(path, t, open, tolerance, transform) for i=1,length do nt = nt + 1 pth = path[i] - if not ith then + if not ith or pth.state == 1 then t[nt] = f_m(mpconcat(pth.x_coord,pth.y_coord)) elseif curved(ith,pth,tolerance) then -- elseif pth.curved then @@ -224,7 +226,9 @@ local function flushconcatpath(path, t, open, tolerance, transform) if not open then nt = nt + 1 local one = path[1] - if curved(pth,one,tolerance) then + if one.state == 1 then + t[nt] = f_m(one.x_coord,one.y_coord) + elseif curved(pth,one,tolerance) then -- if one.curved then local a, b = mpconcat(pth.right_x,pth.right_y) local c, d = mpconcat(one.left_x,one.left_y) @@ -476,6 +480,8 @@ function metapost.flush(specification,result) local collect = false local both = false local flush = false + local outline = force_outline + local envelope = false local postscript = object.postscript local tolerance = options and tonumber(options.tolerance) or tolerance -- if not object.istext then @@ -490,6 +496,8 @@ function metapost.flush(specification,result) elseif postscript == "eoboth" then evenodd = true both = true + elseif postscript == "envelope" then + envelope = true end -- end -- @@ -505,6 +513,9 @@ function metapost.flush(specification,result) end else local objecttype = object.type -- can have changed + if envelope then + dashed, linewidth = "", 1 -- to be sure + end if before then result = pluginactions(before,result,flushfigure) end @@ -547,7 +558,7 @@ function metapost.flush(specification,result) local open = path and path[1].left_type and path[#path].right_type -- at this moment only "end_point" local pen = object.pen if pen then - if pen.type == "elliptical" then + if pen.type == "elliptical" or outline then transformed, penwidth = pen_characteristics(original) -- boolean, value if penwidth ~= linewidth then result[#result+1] = f_w(penwidth) @@ -567,6 +578,7 @@ function metapost.flush(specification,result) if savedpath then for i=1,#savedpath do local path = savedpath[i] + local open = not path.cycle if transformed then flushconcatpath(path,result,open,tolerance,i==1) else @@ -582,7 +594,7 @@ function metapost.flush(specification,result) else flushnormalpath(path,result,open,tolerance) end - if force_stroke then + if outline or envelope then result[#result+1] = open and "S" or "h S" elseif objecttype == "fill" then result[#result+1] = evenodd and "h f*" or "h f" -- f* = eo @@ -607,6 +619,7 @@ function metapost.flush(specification,result) if savedhtap then for i=1,#savedhtap do local path = savedhtap[i] + local open = not path.cycle if transformed then flushconcatpath(path,result,open,tolerance,i==1) else @@ -621,7 +634,7 @@ function metapost.flush(specification,result) else flushnormalpath(path,result,open,tolerance) end - if force_stroke then + if outline or envelope then result[#result+1] = open and "S" or "h S" elseif objecttype == "fill" then result[#result+1] = evenodd and "h f*" or "h f" -- f* = eo diff --git a/tex/context/base/mkxl/mlib-pps.lmt b/tex/context/base/mkxl/mlib-pps.lmt index 5d91f0799..3cb26d044 100644 --- a/tex/context/base/mkxl/mlib-pps.lmt +++ b/tex/context/base/mkxl/mlib-pps.lmt @@ -759,7 +759,7 @@ local function cm(object) local ry = fourth.x_coord - tx if sx == 0 then sx = 0.00001 end if sy == 0 then sy = 0.00001 end - return sx, rx, ry, sy, tx, ty + return sx, rx, ry, sy, tx, ty -- different order elsewhere ! end end return 1, 0, 0, 1, 0, 0 -- weird case @@ -1620,6 +1620,8 @@ local function pt_process(object,prescript,before,after) local llx, lly, urx, ury = getcorners(object.path) if abs(llx) < 0.0001 then llx = 0 end if abs(lly) < 0.0001 then lly = 0 end + if abs(urx) < 0.0001 then urx = 0 end + if abs(ury) < 0.0001 then ury = 0 end before[#before+1] = function() if pt_action == "set" then pattern_index = pattern_index + 1 diff --git a/tex/context/base/mkxl/mlib-run.lmt b/tex/context/base/mkxl/mlib-run.lmt index bf3d5434a..0e955818e 100644 --- a/tex/context/base/mkxl/mlib-run.lmt +++ b/tex/context/base/mkxl/mlib-run.lmt @@ -181,16 +181,31 @@ local seed = nil local default_tolerance = 131/65536.0 -- a little below 0.001 * 0x7FFF/0x4000 local bend_tolerance = default_tolerance +local move_tolerance = default_tolerance ----- bend_tolerance = 10/2000 +----- move_tolerance = bend_tolerance function metapost.setbendtolerance(t) bend_tolerance = t or default_tolerance end +function metapost.setmovetolerance(t) + move_tolerance = t or default_tolerance +end +function metapost.settolerance(t) + bend_tolerance = t or default_tolerance + move_tolerance = t or default_tolerance +end function metapost.getbendtolerance() return bend_tolerance end +function metapost.getmovetolerance() + return move_tolerance +end +function metapost.gettolerance(t) + return bend_tolerance, move_tolerance +end function metapost.load(name,method) starttiming(mplib) @@ -202,19 +217,19 @@ function metapost.load(name,method) seed = seed % 4096 end end --- local loghandler = method = method and methods[method] or "scaled" local mpx, terminal = new_instance { - tolerance = bend_tolerance, - mathmode = method, - runscript = metapost.runscript, - runinternal = metapost.runinternal, - scripterror = metapost.scripterror, - maketext = metapost.maketext, - handlers = { - log = metapost.newlogger(), - -- warning = function(...) end, - -- error = function(...) end, + bendtolerance = bend_tolerance, + movetolerance = move_tolerance, + mathmode = method, + runscript = metapost.runscript, + runinternal = metapost.runinternal, + scripterror = metapost.scripterror, + maketext = metapost.maketext, + handlers = { + log = metapost.newlogger(), + -- warning = function(...) end, + -- error = function(...) end, }, } report_metapost("initializing number mode %a",method) diff --git a/tex/context/base/mkxl/mult-aux.mkxl b/tex/context/base/mkxl/mult-aux.mkxl index e5850668b..4bbebf2d1 100644 --- a/tex/context/base/mkxl/mult-aux.mkxl +++ b/tex/context/base/mkxl/mult-aux.mkxl @@ -814,15 +814,18 @@ \newcount\c_mult_interfaces_n_of_namespaces +% \def\v_interfaces_prefix_template +% {\number\c_mult_interfaces_n_of_namespaces>} + \def\v_interfaces_prefix_template - {\number\c_mult_interfaces_n_of_namespaces>} + {\tohexadecimal\c_mult_interfaces_n_of_namespaces>} \permanent\protected\def\installnamespace#1% for modules and users {\ifcsname ????#1\endcsname \writestatus\m!system{duplicate user namespace '#1'}\wait \else \global\advance\c_mult_interfaces_n_of_namespaces\plusone - \immutable\edefcsname ????#1\endcsname{\v_interfaces_prefix_template}% + \immutable\xdefcsname ????#1\endcsname{\v_interfaces_prefix_template}% \fi} \permanent\protected\def\installcorenamespace#1% @@ -830,7 +833,7 @@ \writestatus\m!system{duplicate core namespace '#1'}\wait \else \global\advance\c_mult_interfaces_n_of_namespaces\plusone - \immutable\edefcsname ??#1\endcsname{\v_interfaces_prefix_template}% + \immutable\xdefcsname ??#1\endcsname{\v_interfaces_prefix_template}% \clf_registernamespace\c_mult_interfaces_n_of_namespaces{#1}% \fi} diff --git a/tex/context/base/mkxl/mult-sys.mkxl b/tex/context/base/mkxl/mult-sys.mkxl index 26abaf20f..38d2c0633 100644 --- a/tex/context/base/mkxl/mult-sys.mkxl +++ b/tex/context/base/mkxl/mult-sys.mkxl @@ -44,6 +44,7 @@ % definesystemconstant {vn} \definesystemconstant {afrikaans} \definesystemconstant {af} +\definesystemconstant {albanian} \definesystemconstant {sq} \definesystemconstant {ancientgreek} \definesystemconstant {agr} \definesystemconstant {ancientlatin} \definesystemconstant {ala} \definesystemconstant {arabic} \definesystemconstant {ar} @@ -414,6 +415,7 @@ \definesystemconstant {unpack} \definesystemconstant {unknown} \definesystemconstant {Unicode} +\definesystemconstant {upright} \definesystemconstant {userdata} \definesystemconstant {userpage} \definesystemconstant {user} @@ -450,6 +452,7 @@ \definemessageconstant {languages} \definemessageconstant {layouts} \definemessageconstant {lua} +\definemessageconstant {math} \definemessageconstant {metapost} \definemessageconstant {publications} \definemessageconstant {references} diff --git a/tex/context/base/mkxl/node-ali.lmt b/tex/context/base/mkxl/node-ali.lmt index 0a7cf30ce..ca3c97536 100644 --- a/tex/context/base/mkxl/node-ali.lmt +++ b/tex/context/base/mkxl/node-ali.lmt @@ -6,50 +6,75 @@ if not modules then modules = { } end modules ['node-ali'] = { license = "see context related readme files" } -local a_alignchar = attributes.private("aligncharacter") - -local nuts = nodes.nuts -local tonut = nuts.tonut -local tonode = nuts.tonode -local getwidth = nuts.getwidth -local setwidth = nuts.setwidth -local getid = nuts.getid -local getattr = nuts.getattr -local setnext = nuts.setnext -local getnext = nuts.getnext -local getprev = nuts.getprev -local setglue = nuts.setglue -local getglue = nuts.getglue -local getlist = nuts.getlist -local setlist = nuts.setlist -local setattrlist = nuts.setattrlist -local getchar = nuts.getchar -local addmargins = nuts.addmargins -local findtail = nuts.tail -local hasglyph = nuts.hasglyph -local getwordrange = nuts.getwordrange -local dimensions = nuts.rangedimensions -local nextrecord = nuts.traversers.alignrecord -local nextunset = nuts.traversers.unset -local nextglyph = nuts.traversers.glyph -local nextglue = nuts.traversers.glue -local nextnode = nuts.traversers.node -local prevnode = nuts.treversers.node -local flushnode = nuts.flush -local hpack = nuts.hpack - -local glyph_code = nodes.nodecodes.glyph -local glue_code = nodes.nodecodes.glue -local kern_code = nodes.nodecodes.kern -local disc_code = nodes.nodecodes.disc - -local spaceskip_code = nodes.gluecodes.spaceskip -local xspaceskip_code = nodes.gluecodes.xspaceskip -local fontkern_code = nodes.kerncodes.fontkern - -local newkern = nuts.pool.kern -local insertbefore = nuts.insertbefore -local insertafter = nuts.insertafter +local setmetatableindex = table.setmetatableindex + +local a_alignchar = attributes.private("aligncharacter") + +local nuts = nodes.nuts +local tonut = nuts.tonut +local tonode = nuts.tonode +local getwidth = nuts.getwidth +local setwidth = nuts.setwidth +local getid = nuts.getid +local getattr = nuts.getattr +local setnext = nuts.setnext +local getnext = nuts.getnext +local getprev = nuts.getprev +local setglue = nuts.setglue +local getglue = nuts.getglue +local setglue = nuts.setglue +local getwhd = nuts.getwhd +local setwhd = nuts.setwhd +local getlist = nuts.getlist +local setlist = nuts.setlist +local setattrlist = nuts.setattrlist +local setprop = nuts.setprop +local getfont = nuts.getfont +local getchar = nuts.getchar +local addmargins = nuts.addmargins +local findtail = nuts.tail +local hasglyph = nuts.hasglyph +local getwordrange = nuts.getwordrange +local dimensions = nuts.rangedimensions +local flushnode = nuts.flush +local hpack = nuts.hpack +local repack = nuts.repack +local insertbefore = nuts.insertbefore +local insertafter = nuts.insertafter +local effectiveglue = nuts.effectiveglue + +local newkern = nuts.pool.kern +local newrule = nuts.pool.rule +local newglue = nuts.pool.glue + +local traversers = nuts.traversers +local nextrecord = traversers.alignrecord +local nextunset = traversers.unset +local nextglyph = traversers.glyph +local nextglue = traversers.glue +local nextboundary = traversers.boundary +local nextnode = traversers.node +local nextlist = traversers.list + +local nodecodes = nodes.nodecodes +local glyph_code = nodecodes.glyph +local glue_code = nodecodes.glue +local kern_code = nodecodes.kern +local disc_code = nodecodes.disc +local unset_code = nodecodes.unset +local alignrecord_code = nodecodes.alignrecord + +local spaceskip_code = nodes.gluecodes.spaceskip +local xspaceskip_code = nodes.gluecodes.xspaceskip +local intermathskip_code = nodes.gluecodes.intermathskip +local fontkern_code = nodes.kerncodes.fontkern +local row_code = nodes.listcodes.alignment -- should be row +local cell_code = nodes.listcodes.cell +local line_code = nodes.listcodes.line + +-- local preamble_pass <const> = tex.alignmentcontextcodes.preamble +-- local preroll_pass <const> = tex.alignmentcontextcodes.preroll +-- local wrapup_pass <const> = tex.alignmentcontextcodes.wrapup -- todo statistics and tracing @@ -57,211 +82,213 @@ local method = 2 local unislots = fonts.hashes.unislots -- todo local chardata = fonts.hashes.characters -function nodes.handlers.aligncharacter(head,attr,preamble) - local attr = getattr(attr,a_alignchar) -- 1 : value doesn't matter (for now) - if attr then - local widths = { } - local data = { } - local rows = 0 - local cols = 0 - for col in nextrecord, preamble do - cols = cols + 1 - local w, s = getwidth(col,true) - widths[cols] = { col, w, s } - end - -- - for row in nextunset, head do - rows = rows + 1 - local c = 0 - local d = { } - data[rows] = d - for col in nextunset, getlist(row) do - c = c + 1 - if widths[c][2] then - local list = getlist(col) - -- if method == 1 then - -- local left = nil - -- local right = nil - -- local middle = nil - -- for g, char in nextglyph, list do - -- if not left then - -- left = g - -- end - -- if char == getattr(g,a_alignchar) then - -- middle = g - -- end - -- right = g - -- end - -- d[c] = middle and { col, left, middle, right, 0, 0, getwidth(middle) } or false - -- elseif method == 2 then - local middle = nil - -- we can either cache unislots or we can cache for this font - for g, char, font in nextglyph, list do - local unicode = getattr(g,a_alignchar) - if unicode then - if char == unicode then - middle = g - elseif unislots[font][char] == unicode then - middle = g +function nodes.handlers.aligncharacter(head,where,attr,preamble) + if where == "preroll" then + local attr = getattr(attr,a_alignchar) -- 1 : value doesn't matter (for now) + if attr then + local widths = { } + local data = { } + local rows = 0 + local cols = 0 + for col in nextrecord, preamble do + cols = cols + 1 + local w, s = getwidth(col,true) + widths[cols] = { col, w, s } + end + -- + for row in nextunset, head do + rows = rows + 1 + local c = 0 + local d = { } + data[rows] = d + for col in nextunset, getlist(row) do + c = c + 1 + if widths[c][2] then + local list = getlist(col) + -- if method == 1 then + -- local left = nil + -- local right = nil + -- local middle = nil + -- for g, char in nextglyph, list do + -- if not left then + -- left = g + -- end + -- if char == getattr(g,a_alignchar) then + -- middle = g + -- end + -- right = g + -- end + -- d[c] = middle and { col, left, middle, right, 0, 0, getwidth(middle) } or false + -- elseif method == 2 then + local middle = nil + -- we can either cache unislots or we can cache for this font + for g, char, font in nextglyph, list do + local unicode = getattr(g,a_alignchar) + if unicode then + if char == unicode then + middle = g + elseif unislots[font][char] == unicode then + middle = g + end end end - end - if middle then - local left, right = getwordrange(middle) -- not real gain but handy anyway (less code too) - -- local left = middle - -- local right = middle - -- for g, id, subtype in nextnode, middle do - -- if id == glyph_code or id == disc_code then - -- right = g - -- elseif id == kern_code and subtype == fontkern_code then - -- right = g - -- else - -- break - -- end - -- end - -- for g, id, subtype in prevnode, middle do - -- if id == glyph_code or id == disc_code then - -- left = g - -- elseif id == kern_code and subtype == fontkern_code then - -- left = g - -- else - -- break - -- end - -- end - d[c] = { col, left, middle, right, 0, 0, getwidth(middle) } - else - d[c] = false - end - -- else - -- local middle = nil - -- for g, char in nextglyph, list do - -- if char == getattr(g,a_alignchar) then - -- middle = g - -- end - -- end - -- if middle then - -- local left = list - -- local right = findtail(list) - -- if getid(left) == glue_code then - -- left = getnext(left) - -- end - -- if getid(right) == glue_code then - -- right = getprev(right) - -- end - -- d[c] = { col, left, middle, right, 0, 0, getwidth(middle) } - -- else - -- d[c] = false - -- end - -- end - else - d[c] = false + if middle then + local left, right = getwordrange(middle) -- not real gain but handy anyway (less code too) + -- local left = middle + -- local right = middle + -- for g, id, subtype in nextnode, middle do + -- if id == glyph_code or id == disc_code then + -- right = g + -- elseif id == kern_code and subtype == fontkern_code then + -- right = g + -- else + -- break + -- end + -- end + -- for g, id, subtype in prevnode, middle do + -- if id == glyph_code or id == disc_code then + -- left = g + -- elseif id == kern_code and subtype == fontkern_code then + -- left = g + -- else + -- break + -- end + -- end + d[c] = { col, left, middle, right, 0, 0, getwidth(middle) } + else + d[c] = false + end + -- else + -- local middle = nil + -- for g, char in nextglyph, list do + -- if char == getattr(g,a_alignchar) then + -- middle = g + -- end + -- end + -- if middle then + -- local left = list + -- local right = findtail(list) + -- if getid(left) == glue_code then + -- left = getnext(left) + -- end + -- if getid(right) == glue_code then + -- right = getprev(right) + -- end + -- d[c] = { col, left, middle, right, 0, 0, getwidth(middle) } + -- else + -- d[c] = false + -- end + -- end + else + d[c] = false + end end end - end - -- - for col=1,cols do - local maxl = 0 - local maxr = 0 - local minm = 0 - local maxm = 0 - local colw = widths[col] - for row=1,rows do - local d = data[row][col] - if d then - local p = d[1] - local l = d[2] - local m = d[3] - local r = d[4] - if m then - local lw = l == m and 0 or dimensions(p,l,m) - local rw = m == r and 0 or dimensions(p,getnext(m),getnext(r)) - d[5] = lw - d[6] = rw - if lw > maxl then - maxl = lw - end - if rw > maxr then - maxr = rw - end - local mw = d[7] - if maxm == 0 then - minm = mw - maxm = mw - else - if mw > maxm then - maxm = mw + -- + for col=1,cols do + local maxl = 0 + local maxr = 0 + local minm = 0 + local maxm = 0 + local colw = widths[col] + for row=1,rows do + local d = data[row][col] + if d then + local p = d[1] + local l = d[2] + local m = d[3] + local r = d[4] + if m then + local lw = l == m and 0 or dimensions(p,l,m) + local rw = m == r and 0 or dimensions(p,getnext(m),getnext(r)) + d[5] = lw + d[6] = rw + if lw > maxl then + maxl = lw end - if mw < minm then + if rw > maxr then + maxr = rw + end + local mw = d[7] + if maxm == 0 then minm = mw + maxm = mw + else + if mw > maxm then + maxm = mw + end + if mw < minm then + minm = mw + end end end end end - end - -- - local fixedwidth = colw[3] ~= 0 - -- - local old = colw[2] - local new = old - for row=1,rows do - local d = data[row][col] - if d then - local p = d[1] - local l = d[2] - local m = d[3] - local r = d[4] - if l and m and r then - local lw = d[5] - local rw = d[6] - local mw = d[7] - dl = maxl - lw - dr = maxr - rw - if dl ~= 0 or dr ~= 0 or mw ~= maxm then - local lst = getlist(p) - local wid = getwidth(p) - if dl ~= 0 then - local k = newkern(dl) - lst = insertbefore(lst,l,k) - setattrlist(k,m) + -- + local fixedwidth = colw[3] ~= 0 + -- + local old = colw[2] + local new = old + for row=1,rows do + local d = data[row][col] + if d then + local p = d[1] + local l = d[2] + local m = d[3] + local r = d[4] + if l and m and r then + local lw = d[5] + local rw = d[6] + local mw = d[7] + dl = maxl - lw + dr = maxr - rw + if dl ~= 0 or dr ~= 0 or mw ~= maxm then + local lst = getlist(p) + local wid = getwidth(p) + if dl ~= 0 then + local k = newkern(dl) + lst = insertbefore(lst,l,k) + setattrlist(k,m) + setlist(p,lst) + wid = wid + dl + end + if dr ~= 0 then + local k = newkern(dr) + insertafter(lst,r,k) + setattrlist(k,m) + wid = wid + dr + end + if mw ~= maxm then + local dw = (maxm - mw) + local dx = dw / 2 + addmargins(m,-dx,-dx) + wid = wid + dw + end + setwidth(p,wid) + if wid > new then + new = wid + end setlist(p,lst) - wid = wid + dl - end - if dr ~= 0 then - local k = newkern(dr) - insertafter(lst,r,k) - setattrlist(k,m) - wid = wid + dr - end - if mw ~= maxm then - local dw = (maxm - mw) - local dx = dw / 2 - addmargins(m,-dx,-dx) - wid = wid + dw - end - setwidth(p,wid) - if wid > new then - new = wid - end - setlist(p,lst) - -- somewhat fuzzy: - if fixedwidth then - local l = hpack(h,getwidth(p),"exactly") - setglue(p,getglue(l)) - setlist(l) - flushnode(l) - else - setglue(p) + -- somewhat fuzzy: + if fixedwidth then + local l = hpack(h,getwidth(p),"exactly") + setglue(p,getglue(l)) + setlist(l) + flushnode(l) + else + setglue(p) + end + -- end - -- end end end - end - if new > old then - if fixedwidth then - -- issue overflow warning - else - setwidth(colw[1],new) + if new > old then + if fixedwidth then + -- issue overflow warning + else + setwidth(colw[1],new) + end end end end @@ -283,3 +310,326 @@ interfaces.implement { end, } +-- Let's put it here (for now): + +do + + local getdata = nuts.getdata + local removenode = nuts.remove + local getwhd = nuts.getwhd + local getheight = nuts.getheight + local getdepth = nuts.getdepth + local setheight = nuts.setheight + local setdepth = nuts.setdepth + local getglue = nuts.getglue + local setoffsets = nuts.setoffsets + local setsubtype = nuts.setsubtype + + local baselineskip_code = nodes.gluecodes.baselineskip + local lineskip_code = nodes.gluecodes.lineskip + + local alignrecord_code = nodecodes.alignrecord + local hlist_code = nodecodes.hlist + local unset_code = nodecodes.unset + + local nextnode = nuts.traversers.node + + local texgetdimen = tex.getdimen + local texgetglue = tex.getglue + local texget = tex.get + + local leftmarker = tex.boundaries.system("c_math_align_l_marker") + local rightmarker = tex.boundaries.system("c_math_align_r_marker") + + local a_location = attributes.system("mathnumberlocation") + local a_threshold = attributes.system("mathnumberthreshold") + + -- Here: + + local function openup(specification,head) + local inbetween = specification.inbetween or 0 + local height = specification.height or 0 + local depth = specification.depth or 0 + local lines = { } + for n, id, subtype, list in nextlist, head do + lines[#lines+1] = { n, subtype, getwhd(n) } + end + local t = #lines + if t > 0 then + local l = 1 + for n, subtype in nextglue, head do + -- one day we can decide what to do with intertext stuff based on the + -- subtype but not now ... on our agenda (intertext etc) + if subtype == baselineskip_code or subtype == lineskip_code then + local amount, stretch, shrink = getglue(n) + local prevdp = lines[l] [5] + local nextht = lines[l+1][4] + local delta = 0 + if prevdp < depth then + setdepth(lines[l][1],depth) + delta = delta + (depth - prevdp) + end + if nextht < height then + setheight(lines[l+1][1],height) + delta = delta + (height - nextht) + end + if subtype == lineskip_code then + setglue(n,inbetween,stretch,shrink) + setsubtype(n,baselineskip_code) + else + setglue(n,amount+inbetween-delta,stretch,shrink) + end + l = l + 1 +-- if l > t then +-- break +-- end + end + end + local firstht = lines[1][4] + local lastdp = lines[t][5] + if firstht < height then + setheight(lines[1],height) + end + if lastdp < depth then + setdepth(lines[t],depth) + end + end + end + + nuts.openup = openup + + -- When present, the number is after the right marker. We need to move the + -- number when we want it at the left. + -- + -- Todo: set a flag in mathalignment and support atttibutes on it so that + -- we can check if this is needed. + + -- [dummy] [left -2] [second -1] [number 0] + + -- In the end it makes more sense to just calculate the alignment in lua + -- but it is kind of fun to see how we can control alignments. + + local totals = { } + local widths = { } + local records = { } + local deltas = { } + local cellwidths = { } + + local a_flushleft <const> = 1 + local a_centered <const> = 2 + local a_flushright <const> = 3 + + local function first_pass(head,attr,preamble) + -- + local width = 0 + local hsize = texget("hsize") + local count = 0 + local overflow = false +totals = { } -- maybe use one table +widths = { } +records = { } +deltas = { } + for n in nextrecord, preamble do + local wd = getwidth(n) + count = count + 1 + width = width + wd + totals [count] = width + widths [count] = wd + records[count] = n + deltas [count] = 0 + end + -- + local lindex = 0 + local rindex = 0 + local lwidth = 0 + local rwidth = 0 + local centered = false + for row in nextunset, head do + local count = 0 + local anchor = nil + local rochan = nil + -- local cellwidths = { } + for cell in nextunset, getlist(row) do + local list = getlist(cell) + count = count + 1 + cellwidths[count] = getwidth(cell) + for bound in nextboundary, list do + local marker = getdata(bound) + if marker == leftmarker then + lindex = count + anchor = bound + rochan = list + elseif marker == rightmarker then + local n = getnext(bound) + if n and getid(n) == hlist_code then + local wd, ht, dp = getwhd(n) + local lc = getattr(n,a_location) + if lc then + -- todo: just store align in the outer attribute so once ... + local align = lc // 0x10 + local location = lc % 0x10 + local threshold = getattr(n,a_threshold) + if location == 1 then + -- number right + local m = 1 + local s = align == a_centered and 2 or 1 +-- if align == 1 then + if align == a_flushleft then + -- flushleft + rwidth = wd +-- elseif align == 3 then + elseif align == a_flushright then + -- flushright + rwidth = wd + elseif wd > lwidth then + lwidth = wd + rwidth = wd + centered = true + end + if totals[count-2] + cellwidths[count-1] + s*wd - s*threshold > hsize then + local total = ht + dp + setdepth(row,getdepth(row) + total) + setoffsets(n,0,-total) + local pr = records[count-1] + local cw = getwidth(pr) + if cw - wd > deltas[count-1] then + deltas[count-1] = cw - wd + end + overflow = true + end + elseif location == 2 then + -- number left +-- if align == 1 then + if align == a_flushleft then + -- flushleft + lwidth = wd +-- elseif align == 3 then + elseif align == a_flushright then + -- flushright + lwidth = wd + end + end + if location == 2 and anchor then + local l, l, n = removenode(list,n) + if l ~= list then + setlist(cell,l) + -- setwidth(cell,0) + end + insertafter(rochan,anchor,n) + end + end + end + rindex = count + end + end + end + end + -- + if overflow then + if deltas[rindex-1] ~= 0 then + setwidth(records[rindex-1],deltas[rindex-1]) + end + end + for count=1,#records do + if count == lindex then + if centered and overflow then + lwidth = lwidth - tex.getdimen("d_math_eqalign_number_distance") + end + setwidth(records[count],lwidth) + elseif count == rindex then + setwidth(records[count],rwidth) + end + end + end + + local function second_pass(head,attr,preamble) + local done = setmetatableindex("table") + local glues = { } + local okay = false + for row, id, subtype in nextlist, head do + if id == hlist_code and subtype == row_code then + for cell, id, subtype in nextlist, getlist(row) do + if id == hlist_code and subtype == cell_code then + for n, s in nextglue, getlist(cell) do + if s == intermathskip_code then + local e = effectiveglue(n,cell) + local g = getglue(n) + local f = getfont(n) + local a = done[f] + local d = a[g] + glues[n] = g + if not d then + a[g] = e + elseif d > e then + a[g] = e + okay = true + end + end + end + end + end + end + end + if okay then + for k, v in next, glues do + local g = done[getfont(k)][v] + if g then + setglue(k,g) + setprop(k,"fixedmathalign",true) + end + end + for row, id, subtype in nextlist, head do + if id == hlist_code and subtype == row_code then + for cell, id, subtype, list in nextlist, getlist(row) do + if list and id == hlist_code and subtype == cell_code then + local wd = getwidth(cell) + repack(cell,wd,"exactly") + end + end + end + end + end + end + + local function third_pass(head,attr,preamble) + local inbetween, stretch, shrink = texgetglue("s_strc_math_alignment_inbetween") + openup({ inbetween = inbetween }, head) + end + + -- maybe zero pass: preamble pass + + function nodes.handlers.fixmathalign(head,where,attr,preamble) + if where == "preroll" then + local signal = getattr(attr,a_location) + if signal == 0x20 or signal == 0x40 then + first_pass(head,attr,preamble) + end + elseif where == "wrapup" then + local signal = getattr(attr,a_location) + if signal == 0x40 then + second_pass(head,attr,preamble) + end + -- maybe also signal + third_pass(head,attr,preamble) + end + end +end + +local report = logs.reporter("alignment","preamble") +local trace trackers.register("alignments.showstates",function(v) trace = v end) + +function nodes.handlers.showpreamble(head,where,attr,preamble) + if trace then + local c = 0 + for n, id in nextnode, preamble do + if id == unset_code or id == alignrecord_code then + c = c + 1 + report("stage %a, cell %i, width %p",where,c,getwidth(n)) + elseif id == glue_code then + report("stage %a, tabskip %s",where,node.direct.gluetostring(n)) + else + report("stage %a, node %a",where,nodecodes[id]) + end + end + end +end diff --git a/tex/context/base/mkxl/node-nut.lmt b/tex/context/base/mkxl/node-nut.lmt index dbc4696cc..92e8f0990 100644 --- a/tex/context/base/mkxl/node-nut.lmt +++ b/tex/context/base/mkxl/node-nut.lmt @@ -182,6 +182,8 @@ local nuts = { protrusionskippable = direct.protrusionskippable, rangedimensions = direct.rangedimensions, remove = d_remove_node, + repack = direct.repack, + freeze = direct.freeze, reverse = direct.reverse, setattr = direct.setattribute, setattribute = direct.setattribute, @@ -275,6 +277,7 @@ local nuts = { getspeciallist = direct.getspeciallist, setspeciallist = direct.setspeciallist, getusedattributes = direct.getusedattributes, + gluetostring = direct.gluetostring, } nodes.nuts = nuts diff --git a/tex/context/base/mkxl/node-pro.lmt b/tex/context/base/mkxl/node-pro.lmt index ab40dc0c1..9ad78bb20 100644 --- a/tex/context/base/mkxl/node-pro.lmt +++ b/tex/context/base/mkxl/node-pro.lmt @@ -143,8 +143,9 @@ do local actions = tasks.actions("alignments") - function processors.alignment_filter(head,attr,preamble) - actions(head,attr,preamble) + function processors.alignment_filter(head,where,attr,preamble) + -- todo: add timing + actions(head,where,attr,preamble) end callbacks.register("alignment_filter", processors.alignment_filter, "things done with alignments") diff --git a/tex/context/base/mkxl/node-tsk.lmt b/tex/context/base/mkxl/node-tsk.lmt index 01b485a55..c4871b568 100644 --- a/tex/context/base/mkxl/node-tsk.lmt +++ b/tex/context/base/mkxl/node-tsk.lmt @@ -347,7 +347,7 @@ tasks.new { templates = templates, } --- -- alignment -- -- +-- -- alignment -- -- gets temp node ! (currently as that might change) tasks.new { name = "alignments", @@ -370,7 +370,7 @@ local tonode = nodes.nuts.tonode %localize% -return function(head,attr,preamble) +return function(head,where,attr,preamble) local nuthead = tonut(head) local nutattr = tonut(attr) local nutpreamble = tonut(preamble) @@ -380,19 +380,19 @@ end ]], step = [[ - %action%(head,attr,preamble) + %action%(head,where,attr,preamble) ]], nut = [[ - %action%(nuthead,nutattr,nutpreamble) + %action%(nuthead,where,nutattr,nutpreamble) ]], nohead = [[ - %action%(head,attr,preamble) + %action%(head,where,attr,preamble) ]], nonut = [[ - %action%(nuthead,nutattr,nutpreamble) + %action%(nuthead,where,nutattr,nutpreamble) ]], } diff --git a/tex/context/base/mkxl/pack-box.mkxl b/tex/context/base/mkxl/pack-box.mkxl index 8c83f8308..43f6bfbc7 100644 --- a/tex/context/base/mkxl/pack-box.mkxl +++ b/tex/context/base/mkxl/pack-box.mkxl @@ -54,7 +54,7 @@ \mutable\let\currentanchor\empty \permanent\tolerant\protected\def\defineanchor[#1]#*[#2]#*[#3]#*[#4]% name targetlayer layersetting framedsetting - {\setvalue{\??anchor#1}{\pack_anchors_process_defined{#2}{#3}{#4}}} + {\defcsname\??anchor#1\endcsname{\pack_anchors_process_defined{#2}{#3}{#4}}} \let\pack_anchors_process_defined_indeed\gobbletwooptionals @@ -228,7 +228,7 @@ \installcorenamespace{collectorcorners} -\setvalue{\??collectorcorners\v!middle}% +\defcsname\??collectorcorners\v!middle\endcsname {\ifdim\d_pack_layers_x_size>\zeropoint \advance\d_pack_layers_x_position.5\d_pack_layers_x_size \fi @@ -236,13 +236,13 @@ \advance\d_pack_layers_y_position.5\d_pack_layers_y_size \fi} -\setvalue{\??collectorcorners\v!bottom}% +\defcsname\??collectorcorners\v!bottom\endcsname {\ifdim\d_pack_layers_y_size>\zeropoint \advance\d_pack_layers_y_position-\d_pack_layers_y_size \d_pack_layers_y_position-\d_pack_layers_y_position \fi} -\setvalue{\??collectorcorners\v!right}% +\defcsname\??collectorcorners\v!right\endcsname {\ifdim\d_pack_layers_x_size>\zeropoint \advance\d_pack_layers_x_position-\d_pack_layers_x_size \d_pack_layers_x_position-\d_pack_layers_x_position @@ -535,18 +535,18 @@ \installcorenamespace{bleedinglocation} -\setvalue{\??bleedinglocation t}{\settrue\c_pack_boxes_t\scratchhoffset\zeropoint} -\setvalue{\??bleedinglocation b}{\settrue\c_pack_boxes_b\scratchhoffset\zeropoint} -\setvalue{\??bleedinglocation l}{\settrue\c_pack_boxes_l\scratchvoffset\zeropoint} -\setvalue{\??bleedinglocation r}{\settrue\c_pack_boxes_r\scratchvoffset\zeropoint} -\setvalue{\??bleedinglocation bl}{\settrue\c_pack_boxes_l\settrue\c_pack_boxes_b} -\setvalue{\??bleedinglocation lb}{\settrue\c_pack_boxes_l\settrue\c_pack_boxes_b} -\setvalue{\??bleedinglocation br}{\settrue\c_pack_boxes_r\settrue\c_pack_boxes_b} -\setvalue{\??bleedinglocation rb}{\settrue\c_pack_boxes_r\settrue\c_pack_boxes_b} -\setvalue{\??bleedinglocation tl}{\settrue\c_pack_boxes_l\settrue\c_pack_boxes_t} -\setvalue{\??bleedinglocation lt}{\settrue\c_pack_boxes_l\settrue\c_pack_boxes_t} -\setvalue{\??bleedinglocation tr}{\settrue\c_pack_boxes_r\settrue\c_pack_boxes_t} -\setvalue{\??bleedinglocation rt}{\settrue\c_pack_boxes_r\settrue\c_pack_boxes_t} +\defcsname\??bleedinglocation t\endcsname{\settrue\c_pack_boxes_t\scratchhoffset\zeropoint} +\defcsname\??bleedinglocation b\endcsname{\settrue\c_pack_boxes_b\scratchhoffset\zeropoint} +\defcsname\??bleedinglocation l\endcsname{\settrue\c_pack_boxes_l\scratchvoffset\zeropoint} +\defcsname\??bleedinglocation r\endcsname{\settrue\c_pack_boxes_r\scratchvoffset\zeropoint} +\defcsname\??bleedinglocation bl\endcsname{\settrue\c_pack_boxes_l\settrue\c_pack_boxes_b} +\defcsname\??bleedinglocation lb\endcsname{\settrue\c_pack_boxes_l\settrue\c_pack_boxes_b} +\defcsname\??bleedinglocation br\endcsname{\settrue\c_pack_boxes_r\settrue\c_pack_boxes_b} +\defcsname\??bleedinglocation rb\endcsname{\settrue\c_pack_boxes_r\settrue\c_pack_boxes_b} +\defcsname\??bleedinglocation tl\endcsname{\settrue\c_pack_boxes_l\settrue\c_pack_boxes_t} +\defcsname\??bleedinglocation lt\endcsname{\settrue\c_pack_boxes_l\settrue\c_pack_boxes_t} +\defcsname\??bleedinglocation tr\endcsname{\settrue\c_pack_boxes_r\settrue\c_pack_boxes_t} +\defcsname\??bleedinglocation rt\endcsname{\settrue\c_pack_boxes_r\settrue\c_pack_boxes_t} \mutable\let\currentbleedposition\empty \mutable\let\currentpageposition \empty diff --git a/tex/context/base/mkxl/pack-com.mkxl b/tex/context/base/mkxl/pack-com.mkxl index ebae2fd4a..2b751e08b 100644 --- a/tex/context/base/mkxl/pack-com.mkxl +++ b/tex/context/base/mkxl/pack-com.mkxl @@ -232,12 +232,97 @@ \let\p_nx_ny\empty -\permanent\protected\def\stopcombination - {\bgroup\normalexpanded{\egroup{}\ntimes{{}{}}\c_pack_combinations_y}% brr - \dostoptagged - \egroup - \pack_combinations_pop - \egroup} +% \permanent\tolerant\protected\def\startcombination[#1]#*[#2]% can be simplified +% {\bgroup % so we can grab a group +% \pack_combinations_push +% \edef\currentcombination{#1}% +% \edef\p_nx_ny{#2}% +% % +% \ifempty\p_nx_ny +% \ifcondition\validassignment{#1}% +% \let\currentcombination\empty +% \setupcurrentcombination[#1]% +% \edef\p_nx_ny{\combinationparameter\c!nx*\combinationparameter\c!ny*}% +% \else +% \doifelseinstring{*}\currentcombination +% {\edef\p_nx_ny{\currentcombination*\plusone*}% +% \let\currentcombination\empty} +% {\doifelsenumber\currentcombination +% {\edef\p_nx_ny{\currentcombination*\plusone*}% +% \let\currentcombination\empty} +% {\edef\p_nx_ny{\combinationparameter\c!nx*\combinationparameter\c!ny*}}}% +% \fi +% \else +% \ifcondition\validassignment{#2}% +% \setupcurrentcombination[#2]% +% \edef\p_nx_ny{\combinationparameter\c!nx*\combinationparameter\c!ny*}% +% \else +% \edef\p_nx_ny{\p_nx_ny*\plusone*}% +% \fi +% \fi +% % +% % test first: +% % +% % \ifempty\p_nx_ny +% % \ifhastok={#1}% +% % \let\currentcombination\empty +% % \setupcurrentcombination[#1]% +% % \edef\p_nx_ny{\combinationparameter\c!nx*\combinationparameter\c!ny*}% +% % \orelse\ifhastok*{\currentcombination}% +% % \edef\p_nx_ny{\currentcombination*\plusone*}% +% % \let\currentcombination\empty +% % \orelse\ifchknum\currentcombination\or +% % \edef\p_nx_ny{\currentcombination*\plusone*}% +% % \let\currentcombination\empty +% % \else +% % \edef\p_nx_ny{\combinationparameter\c!nx*\combinationparameter\c!ny*}% +% % \fi +% % \orelse\ifhastok={#2}% +% % \setupcurrentcombination[#2]% +% % \edef\p_nx_ny{\combinationparameter\c!nx*\combinationparameter\c!ny*}% +% % \else +% % \edef\p_nx_ny{\p_nx_ny*\plusone*}% +% % \fi +% % +% \forgetall +% % +% \the\everycombination +% % +% \enforced\let\startcontent\pack_common_content_start +% \enforced\let\stopcontent \pack_common_content_stop +% \enforced\let\startcaption\pack_common_caption_start +% \enforced\let\stopcaption \pack_common_caption_stop +% % +% \edef\p_height {\combinationparameter\c!height}% +% \edef\p_width {\combinationparameter\c!width}% +% \edef\p_location{\combinationparameter\c!location}% +% \edef\p_distance{\combinationparameter\c!distance}% +% % +% \pack_combinations_location_reset +% \rawprocesscommacommand[\p_location]\pack_combinations_location_step +% % +% \dostarttaggedchained\t!combination\currentcombination\??combination +% \vbox \ifx\p_height\v!fit\else to \p_height \fi \bgroup +% \enforced\let\combination\empty % permits \combination{}{} handy for cld +% \normalexpanded{\pack_combinations_start_indeed[\p_nx_ny]}} +% +% \permanent\protected\def\stopcombination +% {\bgroup\normalexpanded{\egroup{}\ntimes{{}{}}\c_pack_combinations_y}% brr +% \dostoptagged +% \egroup +% \pack_combinations_pop +% \egroup} + +\installcorenamespace{combinationmethod} + +% \defcsname\??combinationmethod:\v!start\endcsname +% {} +% +% \defcsname\??combinationmethod\endcsname +% {\vbox} +% +% \defcsname\??combinationmethod:\v!stop\endcsname +% {} \permanent\tolerant\protected\def\startcombination[#1]#*[#2]% can be simplified {\bgroup % so we can grab a group @@ -267,6 +352,7 @@ \edef\p_nx_ny{\p_nx_ny*\plusone*}% \fi \fi + \begincsname\??combinationmethod\combinationparameter\c!method:\v!start\endcsname % % test first: % @@ -309,12 +395,25 @@ \rawprocesscommacommand[\p_location]\pack_combinations_location_step % \dostarttaggedchained\t!combination\currentcombination\??combination - \vbox \ifx\p_height\v!fit\else to \p_height \fi \bgroup +% \vbox \ifx\p_height\v!fit\else to \p_height \fi \bgroup + \ifcsname\??combinationmethod\combinationparameter\c!method\endcsname + \lastnamedcs\else\vbox + \fi\ifx\p_height\v!fit\else to \p_height \fi \bgroup \enforced\let\combination\empty % permits \combination{}{} handy for cld \normalexpanded{\pack_combinations_start_indeed[\p_nx_ny]}} +\permanent\protected\def\stopcombination + {\bgroup\normalexpanded{\egroup{}\ntimes{{}{}}\c_pack_combinations_y}% brr + \dostoptagged + \egroup + \begincsname\??combinationmethod\combinationparameter\c!method:\v!stop\endcsname + \pack_combinations_pop + \egroup} + \let\pack_combinations_check_x_y\relax +\aliased\let\combinationwidth\!!zeropoint + \protected\def\pack_combinations_start_indeed[#1*#2*#3]% {\global\c_pack_combinations_x#1\relax \global\c_pack_combinations_y#2\relax @@ -326,6 +425,10 @@ \global\c_pack_combinations_max\c_pack_combinations_x \multiply\c_pack_combinations_y\c_pack_combinations_x \tabskip\zeropoint + \enforced\permanent\protected\edef\combinationwidth % \immutable + {\the\dimexpr + (\hsize-\numexpr\c_pack_combinations_x-\plusone\relax\dimexpr\combinationparameter\c!distance\relax)/\c_pack_combinations_x + \relax}% \halign \ifx\p_width\v!fit\else to \p_width \fi \bgroup % repetitive preamble % \halign noskips \ifx\p_width\v!fit\else to \p_width \fi \bgroup % repetitive preamble \aligntab diff --git a/tex/context/base/mkxl/pack-mat.mkxl b/tex/context/base/mkxl/pack-mat.mkxl index 0c62638cb..66be25a9d 100644 --- a/tex/context/base/mkxl/pack-mat.mkxl +++ b/tex/context/base/mkxl/pack-mat.mkxl @@ -81,4 +81,146 @@ %D \stopTEXpage %D \stoptyping +%D From the list: + +%D \starttyping +%D \startformula[spaceinbetween=.5\lineheight] +%D \left\{ +%D \mparagraph{Quaternion algebras\par over $\blackboard{Q}$ up to isomorphism} +%D \right\} +%D \alignhere \leftrightarrow +%D \left\{ +%D \mparagraph +%D [foregroundcolor=darkred,offset=.1ex,frame=on] +%D {Finite subset of places of $\blackboard{Q}$\par of even cardinality} +%D \right\} +%D \breakhere \leftrightarrow +%D \left\{ +%D \mparagraph{more text} +%D \right\} +%D \breakhere \leftrightarrow +%D \left\{ +%D \mparagraph[foregroundcolor=darkblue]{and more text} +%D \right\} +%D \stopformula +%D \stoptyping + +\permanent\tolerant\protected\def\mparagraph[#1]#*#:#2% + {\vcenter class \mathconstructcode \bgroup % \mathwrappedcode would be like fraction + \framed[\c!offset=\v!overlay,\c!frame=\v!overlay,\c!align=\v!middle,#1]{#2}% + \egroup} + +%D Moved from pack-rul.mkxl to here: + +%D \macros +%D {mframed, minframed} +%D +%D See mkii and mkiv files for some history on this already rather old mechanism; it +%D dates from the real beginning. In the meantime we used anchoring, and now we're +%D doing it more \LMTX ish. + +% mframed xx\mframed {x^2 + \frac{2}{x} + \sqrt{\frac{2}{\sqrt{\frac{2}{x}}}}} \input tufte +% inmframed xx\inmframed{x^2 + \frac{2}{x} + \sqrt{\frac{2}{\sqrt{\frac{2}{x}}}}} \input tufte +% mcframed xx\mcframed {x^2 + \frac{2}{x} + \sqrt{\frac{2}{\sqrt{\frac{2}{x}}}}} \input tufte +% mtframed xx\mtframed {x^2 + \frac{2}{x} + \sqrt{\frac{2}{\sqrt{\frac{2}{x}}}}} \input tufte + +\newcount\c_framed_mstyle + +\installcorenamespace{mathframed} + +\installframedcommandhandler \??mathframed {mathframed} \??mathframed + +\newtoks \t_pack_framed_mathframed +\newdimen\d_pack_framed_mathframed + +\appendtoks + \frozen\protected\instance\edefcsname\currentmathframed\endcsname{\pack_framed_mathframed[\currentmathframed]}% +\to \everydefinemathframed + +\tolerant\protected\def\pack_framed_mathframed[#1]#*[#2]#:#3% needs testing ! + {\begingroup + \edef\currentmathframed{#1}% + \setupcurrentmathframed[#2]% + \c_framed_mstyle\normalmathstyle + \edef\m_framed_location{\mathframedparameter\c!location}% + \ifx\m_framed_location\v!mathematics + \inheritedmathframedframed\bgroup + \setbox\scratchbox\hbox\bgroup + \Ustartmath + \triggermathstyle\c_framed_mstyle + \the\t_pack_framed_mathframed + \mathatom \mathunspacedcode\bgroup + #3% + \egroup + \Ustopmath + \egroup + \global\d_pack_framed_mathframed\dp\scratchbox + \dontleavehmode\box\scratchbox + \egroup + \else + \inheritedmathframedframed\bgroup + \hbox\bgroup + \Ustartmath + \triggermathstyle\c_framed_mstyle + #3% + \Ustopmath + \egroup + \egroup + \fi + \endgroup} + +\appendtoks + \c_strc_math_ragged_status \plustwo + \c_strc_formulas_check_width\zerocount +\to \t_pack_framed_mathframed + +\installframedlocator \v!mathematics + {} + {\pack_framed_locator_set_lo + \ifzeropt\d_framed_locator_lo\else + \lower\dimexpr\d_framed_locator_lo+\d_pack_framed_mathframed\relax + \fi + \box\b_framed_normal} + +\definemathframed[mframed] +\definemathframed[inmframed][\c!location=\v!low] +\definemathframed[mcframed] [\c!location=\v!mathematics] % centered +\definemathframed[mtframed] [\c!location=\v!mathematics,\c!offset=\v!overlay,\c!frame=\v!overlay] % tight + +%D So instead of the rather versatile \type {\framed}, we use \type {\mframed}: +%D +%D \startbuffer +%D \startformula +%D x \times \mframed{y} \times y^{z_z} +%D x \times \inmframed{y} \times y^{z_z} +%D \stopformula +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D And: +%D +%D \startbuffer +%D \startformula +%D x \times \mframed{y} \times y^{\mframed{z}_{\mframed{z}}} +%D \stopformula +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D As usual, one can specify in what way the text should be framed. One should be +%D aware of the fact that, inorder to preserve the proper spacing, the \type +%D {offset} is set to \type {overlay} and \type {frameoffset} is used used instead. +%D +%D \startbuffer +%D \startformula +%D x \times y^{\mframed[framecolor=red]{z}_{z}} +%D \stopformula +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D For inline use, we also provide the \type {\inmframed} alternative: we want $x +%D \times \inmframed{y}$ in inline math, right? + \protect diff --git a/tex/context/base/mkxl/pack-obj.lmt b/tex/context/base/mkxl/pack-obj.lmt index 894d9e8b2..5f784b32a 100644 --- a/tex/context/base/mkxl/pack-obj.lmt +++ b/tex/context/base/mkxl/pack-obj.lmt @@ -99,14 +99,23 @@ objects = { local objects = objects -function objects.register(ns,id,b,referenced,offset,mode) - local n = objects.n + 1 - objects.n = n - nodes.handlers.finalizebox(b) - if mode == 0 then +function objects.register(ns,id,b,referenced,offset,mode,delay) + -- The delay feature is just an experiment: a value of 1 delays the + -- flushing and 2 overloads the content. It might disappear again. + local found = data[ns][id] + if found and delay == 2 then + nodes.handlers.finalizebox(b) + data[ns][id] = { + codeinjections.registerboxresource(b,nil,nil,found[1]), -- hardcoded [1] + offset, + referenced or false, + mode, + } + return + elseif mode == 0 then -- tex data[ns][id] = { - codeinjections.registerboxresource(b), -- a box number + codeinjections.registerboxresource(b,nil,delay), -- a box number offset, referenced or false, mode, @@ -114,7 +123,7 @@ function objects.register(ns,id,b,referenced,offset,mode) else -- box (backend) data[ns][id] = { - codeinjections.registerboxresource(b,offset), -- a box number + codeinjections.registerboxresource(b,offset,delay), -- a box number false, referenced, mode, @@ -183,13 +192,13 @@ end implement { name = "registerreferencedobject", - arguments = { "string", "string", "integer", true, "dimension", "integer" }, + arguments = { "string", "string", "integer", true, "dimension", "integer", "integer" }, actions = objects.register, } implement { name = "registerobject", - arguments = { "string", "string", "integer", false, "dimension", "integer" }, + arguments = { "string", "string", "integer", false, "dimension", "integer", "integer" }, actions = objects.register, } diff --git a/tex/context/base/mkxl/pack-obj.mkxl b/tex/context/base/mkxl/pack-obj.mkxl index ab42d163f..3dad2644a 100644 --- a/tex/context/base/mkxl/pack-obj.mkxl +++ b/tex/context/base/mkxl/pack-obj.mkxl @@ -62,7 +62,28 @@ %D We can get subtle differences in boundingboxes but both methods work ok. +% How useful is this ... delayed but refered objects .. messy concept. +% +% \def\InitIt{% +% \c_pack_objects_delay\plusone +% \setobject{test}{1}\hbox{test me 1} +% \c_pack_objects_delay\zerocount +% } +% +% \def\GetIt{% +% \c_pack_objects_delay\plusone +% \getobject{test}{1} +% \c_pack_objects_delay\zerocount +% } +% +% \def\SetIt{% +% \c_pack_objects_delay\plustwo +% \setobject{test}{1}\hbox{\bf HERE}% we cannot have interactivity in xforms +% \c_pack_objects_delay\zerocount +% } + \newconstant\c_pack_objects_offset_mode % 0=tex 1=box +\newconstant\c_pack_objects_delay % 0=immediate 1=delay \protected\def\pack_objects_set_yes#1#2% {\ifcase\c_pack_objects_offset_mode @@ -74,7 +95,12 @@ \else \pack_objects_package_nop\nextbox \fi - \clf_registerreferencedobject{#1}{#2}\b_pack_objects\d_pack_objects_offset\c_pack_objects_offset_mode + \clf_registerreferencedobject + {#1}{#2}% + \b_pack_objects + \d_pack_objects_offset + \c_pack_objects_offset_mode + \c_pack_objects_delay \synctexresume \endgroup} @@ -88,7 +114,12 @@ \else \pack_objects_package_nop\nextbox \fi - \clf_registerobject{#1}{#2}\b_pack_objects\d_pack_objects_offset\c_pack_objects_offset_mode + \clf_registerobject + {#1}{#2}% + \b_pack_objects + \d_pack_objects_offset + \c_pack_objects_offset_mode + \c_pack_objects_delay \synctexresume \endgroup} diff --git a/tex/context/base/mkxl/pack-rul.mkxl b/tex/context/base/mkxl/pack-rul.mkxl index 2ae83cb98..803d83bf3 100644 --- a/tex/context/base/mkxl/pack-rul.mkxl +++ b/tex/context/base/mkxl/pack-rul.mkxl @@ -946,6 +946,7 @@ \edef\p_framed_background{\framedparameter\c!background}% % not here, in calling macro: setups \pack_framed_remove_depth + % beware, depth goes away when we have a frame, otherwise it's retained \ifx\p_framed_frame\v!overlay \orelse \ifx\p_framed_frame\v!none \else \ifempty\p_framed_rulethickness\else \d_framed_linewidth\p_framed_rulethickness\relax @@ -1349,6 +1350,10 @@ \installcorenamespace{framedoffsetalternative} % widths +% +% \inframed[adaptive=0500]{Just some words} +% \inframed[adaptive=0] {Just some words} +% \inframed[adaptive=-500]{Just some words} \defcsname\??framedwidthalternative\empty\endcsname {\ifconditional\c_framed_has_format @@ -1597,8 +1602,19 @@ \pack_framed_reshape_reset \fi} +% Musical timestamp for the adding the "freezespacing" feature: Porcupine Tree - +% Herd Culling (Single Edit - Official Visualiser : some old sql code scrolling by +% on some paper terminal font); scalefactors are in the range -1000..1000. + \protected\def\pack_framed_finish - {\pack_framed_locator_before\p_framed_location + {\edef\p_freeze{\framedparameter\c!freezespacing}% + \ifempty\p_freeze + % \orelse\ifx\p_freeze\v!yes + % \boxfreeze\b_framed_normal\zerocount + \else + \boxadapt\b_framed_normal\p_freeze\relax + \fi + \pack_framed_locator_before\p_framed_location \ifconditional\c_framed_has_format \ifempty\p_framed_anchoring\else \pack_framed_reverse_box @@ -1958,143 +1974,6 @@ %D When we set \type{empty} to \type{yes}, we get ourselves a frame and/or background, %D but no content, so actually we have a sort of phantom framed box. -%D \macros -%D {mframed, minframed} -%D -%D When Tobias asked how to frame mathematical elements in formulas, Taco's posted the -%D next macro: -%D -%D \starttyping -%D \def\mframed#1% -%D {\relax -%D \ifmmode -%D \vcenter{\hbox{\framed{$\ifinner\else\displaystyle\fi#1$}}}% -%D \else -%D \framed{$#1$}% -%D \fi} -%D \stoptyping -%D -%D Because \type {\ifinner} does not (always) reports what one would expect, we move the -%D test to the outer level. We also want to pass arguments, -%D -%D \starttyping -%D \def\mframed% -%D {\dosingleempty\domframed} -%D -%D \def\domframed[#1]#2% % tzt \dowithnextmathbox ? -%D {\relax -%D \ifmmode -%D \ifinner -%D \inframed[#1]{$#2$}% -%D \else -%D \vcenter{\hbox{\framed[#1]{$\displaystyle#2$}}}% -%D \fi -%D \else -%D \inframed[#1]{$#2$}% -%D \fi} -%D \stoptyping -%D -%D Still better is the next alternative, if only because it takes care of setting the super- -%D and subscripts styles - -\newcount\c_framed_mstyle - -\protected\def\pack_framed_math_strut - {\Ustartmath - \triggermathstyle\c_framed_mstyle - \vphantom{(}% - \Ustopmath} - -\installcorenamespace{mathframed} - -\installframedcommandhandler \??mathframed {mathframed} \??mathframed - -\newcount\c_pack_framed_mathframed -\newtoks \t_pack_framed_mathframed - -\appendtoks - \frozen\protected\instance\edefcsname\currentmathframed\endcsname{\pack_framed_mathframed[\currentmathframed]}% -\to \everydefinemathframed - -\let\pack_framed_mc_one\relax -\let\pack_framed_mc_two\relax - -\tolerant\protected\def\pack_framed_mathframed[#1]#*[#2]#:#3% needs testing ! - {\begingroup - \edef\currentmathframed{#1}% - \setupcurrentmathframed[#2]% - \c_framed_mstyle\normalmathstyle - \edef\m_framed_location{\mathframedparameter\c!location}% - \ifx\m_framed_location\v!mathematics - \enforced\let\normalstrut\pack_framed_math_pos % I don't like this overload! - \orelse\ifx\m_framed_location\v!low\else - \enforced\let\normalstrut\pack_framed_math_strut - \fi - \inheritedmathframedframed\bgroup - \Ustartmath - \triggermathstyle\c_framed_mstyle - \the\t_pack_framed_mathframed - #3% - \Ustopmath - \egroup - \endgroup} - -\def\pack_framed_math_pos - {\global\advance\c_pack_framed_mathframed\plusone - \xdef\pack_framed_mc_one{mcf:1:\number\c_pack_framed_mathframed}% - \xdef\pack_framed_mc_two{mcf:2:\number\c_pack_framed_mathframed}% - \xypos\pack_framed_mc_two} - -\appendtoks - \mathraggedstatus\plustwo % makes \startalign work - \eqalignmode \zerocount % makes \startalign fit -\to \t_pack_framed_mathframed - -\installframedlocator \v!mathematics - {} - {\lower\dimexpr\MPy\pack_framed_mc_two-\MPy\pack_framed_mc_one\relax - \hpack{\xypos\pack_framed_mc_one\box\b_framed_normal}} - -\definemathframed[mframed] -\definemathframed[inmframed][\c!location=\v!low] -\definemathframed[mcframed] [\c!location=\v!mathematics] - -%D So instead of the rather versatile \type {\framed}, we use \type {\mframed}: -%D -%D \startbuffer -%D \startformula -%D x \times \mframed{y} \times y^{z_z} -%D x \times \inmframed{y} \times y^{z_z} -%D \stopformula -%D \stopbuffer -%D -%D \typebuffer \getbuffer -%D -%D And: -%D -%D \startbuffer -%D \startformula -%D x \times \mframed{y} \times y^{\mframed{z}_{\mframed{z}}} -%D \stopformula -%D \stopbuffer -%D -%D \typebuffer \getbuffer -%D -%D As usual, one can specify in what way the text should be framed. One should be -%D aware of the fact that, inorder to preserve the proper spacing, the \type -%D {offset} is set to \type {overlay} and \type {frameoffset} is used used instead. -%D -%D \startbuffer -%D \startformula -%D x \times y^{\mframed[framecolor=red]{z}_{z}} -%D \stopformula -%D \stopbuffer -%D -%D \typebuffer \getbuffer -%D -%D For inline use, we also provide the \type {\inmframed} alternative: we want $x -%D \times \inmframed{y}$ in inline math, right? - %D This previous framing macros needs a lot of alternatives for putting rules around %D boxes, inserting offsets and aligning text. Each step is handled by separate macros. diff --git a/tex/context/base/mkxl/page-blk.lmt b/tex/context/base/mkxl/page-blk.lmt new file mode 100644 index 000000000..2078245e4 --- /dev/null +++ b/tex/context/base/mkxl/page-blk.lmt @@ -0,0 +1,98 @@ +if not modules then modules = { } end modules ['page-blk'] = { + version = 1.001, + comment = "companion to page-blk.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local context = context +local implement = interfaces.implement +local texgetcount = tex.getcount + +local blocks = { } +local block = false + +implement { + name = "startpageblock", + arguments = "string", + actions = function(s) + local p = texgetcount("realpageno") + block = { p, p } + blocks[s] = block + end, +} + +implement { + name = "stoppageblock", + actions = function() + local p = texgetcount("realpageno") - 1 + block[2] = p + end, +} + +implement { + name = "pageblockrealpage", + arguments = "string", + actions = function(name) + local b = blocks[name] + context(b and b[1] or 0) + end, +} + +implement { + name = "flushpageblocks", + arguments = "string", + actions = function(list) + local count = 0 + local order = utilities.parsers.settings_to_array(list) + local pages = { } + for i=1,#order do + local name = order[i] + local block = blocks[name] + if block then + for i=block[1],block[2] do + count = count + 1 + pages[count] = i + end + end + end + -- if count ~= nofpages then + -- end + -- inspect(blocks) + -- inspect(pages) + if lpdf.setpageorder then + lpdf.setpageorder(pages) -- ,count) + end + end +} + +-- maybe intercept nesting with error + +local currentpreroll = false +local prerolled = { } + +implement { + name = "startprerollpageblock", + arguments = "string", + actions = function(name) + currentrealpage = texgetcount("realpageno") + currentpreroll = name + end +} + +implement { + name = "stopprerollpageblock", + actions = function() + prerolled[currentpreroll] = texgetcount("realpageno") - currentrealpage + currentpreroll = false + end +} + +implement { + name = "prerolledpages", + arguments = "string", + actions = function(name) + context(prerolled[name] or 0) + end +} diff --git a/tex/context/base/mkxl/page-blk.mkxl b/tex/context/base/mkxl/page-blk.mkxl new file mode 100644 index 000000000..5ce6dff53 --- /dev/null +++ b/tex/context/base/mkxl/page-blk.mkxl @@ -0,0 +1,192 @@ +%D \module +%D [ file=page-blk, +%D version=2022.06.04, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Shuffling Pages, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Shuffling pages} + +%D This is a somewhat tricky module and although we have a somewhat abstract +%D interface we are pretty much bound to \PDF\ output here. When large amounts of +%D documents are to be generated and|/|or when saving a run makes sense the table +%D of contents can be typeset at the end and moved to the beginning. However, it +%D assumes a rather stable and predictable rendering. Don't use this without +%D checking it really works out well. +%D +%D The low level backend code has been around for quite a while but we never had +%D a real (need and therefore) interface for it. There actually is not that much +%D code involved anyway. There is no need to backport it to \MKIV. + +\registerctxluafile{page-blk}{autosuffix} + +% Musical timestamp: end May 2022 xpropaganda (in loop mode to keep the pace). + +% pitfalls: we need to keep the toc in order (or generate it 'manually' based on +% deltas but even then we get the numbers wrong) + +\unprotect + +\newcount\c_pages_prerolled + +\permanent\protected\def\startpageblock[#1]% + {\page + \clf_startpageblock{#1}} + +\permanent\protected\def\stoppageblock + {\page + \clf_stoppageblock} + +\permanent\protected\def\flushpageblocks[#1]% + {\page + \clf_flushpageblocks{#1}} + +\permanent\def\pageblockrealpage#1% + {\clf_pageblockrealpage{#1}} + +\tolerant\permanent\protected\def\startprerollpageblock[#1]% + {\page + \clf_startprerollpageblock{#1}% + \global\c_pages_prerolled\realpageno % hack + \setuppaper[\c!method=\v!none]} + +\permanent\protected\def\stopprerollpageblock + {\page + \clf_stopprerollpageblock + \setcounter[realpage][\c_pages_prerolled]% hack + \setuppaper[\c!method=\v!normal]} + +\permanent\def\prerolledpages#1% + {\clf_prerolledpages{#1}} + +\protect \endinput + +\usemodule[article-basic] + +\setupinteraction[state=start] + +% \enabletrackers[*reference*] +% \enabletrackers[*destination*] + +\useMPlibrary[dum] + +\starttext + +\def\AlphaOffset{0} +\def\BetaOffset {0} + +% the flexible ones (can come from files) + +\startbuffer[alpha] + \startchapter[title=Alpha] + \dorecurse{20}{\samplefile{tufte}\par} + \stopchapter +\stopbuffer + +\startbuffer[beta] + \startchapter[title=Beta] + \dorecurse{6}{\samplefile{tufte}\par} + \stopchapter +\stopbuffer + +% the fixed ones + +\startbuffer[gamma] + \startchapter[title=Gamma] + \externalfigure[whatever-dummy-3][width=\textwidth] + \stopchapter +\stopbuffer + +\startbuffer[rest] + \startchapter[title=Rest A] + \samplefile{tufte} + \stopchapter + \startchapter[title=Rest B] + \samplefile{tufte} + \blank + Alpha : \goto{page \AlphaPages}[realpage(\AlphaPages)]\par + Beta : \goto{page \BetaPages }[realpage(\BetaPages )] + \stopchapter +\stopbuffer + +\startbuffer[contents] + \starttitle[title=Contents] + \placelist[chapter][criterium=text] + \stoptitle +\stopbuffer + +% Preroll. + +\startprerollpageblock[alpha] + \start + \setuphead[chapter][incrementnumber=no] + \getbuffer[alpha] + \stop +\stopprerollpageblock + +% \writestatus{!!!!!}{nofalphapages: \prerolledpages{alpha}} + +\startprerollpageblock[beta] + \start + \setuphead[chapter][incrementnumber=no] + \getbuffer[beta] + \stop +\stopprerollpageblock + +% \writestatus{!!!!!}{nofbetapages: \prerolledpages{beta}} + +% Some titling. + +\startpageblock[titlepage] + \startstandardmakeup + \externalfigure[whatever-dummy-1][height=\textheight,width=\textwidth] + \stopstandardmakeup +\stoppageblock + +\startpageblock[boguspage] + \startstandardmakeup + \externalfigure[whatever-dummy-2][height=\textheight,width=\textwidth] + \stopstandardmakeup +\stoppageblock + +% The contents will end up here. + +% page 1 + +% The main document. + +\setuppagenumber[number=2] + +\startpageblock[chapters] + % we have a predictable rest: + + \edef\AlphaPages{\the\numexpr 4 \relax} + \edef\BetaPages {\the\numexpr 4 + \prerolledpages{alpha} \relax} + + \getbuffer[rest] + \getbuffer[alpha] + \getbuffer[beta] + \getbuffer[gamma] +\stoppageblock + +% This one will move: + +\setuppagenumber[number=1] + +\startpageblock[contents] + \getbuffer[contents] +\stoppageblock + +\flushpageblocks + [titlepage, + boguspage, + contents, + chapters] + +\stoptext diff --git a/tex/context/base/mkxl/page-ini.mkxl b/tex/context/base/mkxl/page-ini.mkxl index e179b6d03..92bb8167f 100644 --- a/tex/context/base/mkxl/page-ini.mkxl +++ b/tex/context/base/mkxl/page-ini.mkxl @@ -292,6 +292,7 @@ \appendtoks \restoreglobalbodyfont + \restoreglobalinterlinespace \pickupattributes \to \everybeforepagebody diff --git a/tex/context/base/mkxl/page-lay.mkxl b/tex/context/base/mkxl/page-lay.mkxl index 4c28b4656..9dbe9aef0 100644 --- a/tex/context/base/mkxl/page-lay.mkxl +++ b/tex/context/base/mkxl/page-lay.mkxl @@ -171,6 +171,20 @@ \permanent\def\layoutdistance#1#2{\ifdim\zeropoint<#1#2\else\zeropoint\fi} +\appendtoks + \global\pageextragoal\zeropoint +\to \everysetuplayout + +\appendtoks + \global\pageextragoal \zeropoint +\to \everysetupoutputroutine + +\immutable\integerdef\lasttextadaptive\zerocount + +\prependtoks + \enforced\integerdef\lasttextadaptive\plusone +\to \everybeforeoutput + % \newconditional\reverselayout \def\page_layouts_set_dimensions @@ -1354,12 +1368,13 @@ %D %showsetup{showgrid} %D %showsetup{showusage} -\fetchmodulecommand \showprint \f!page_run -\fetchmodulecommand \showframe \f!page_run -\fetchmodulecommand \showlayout \f!page_run -\fetchmodulecommand \showsetups \f!page_run -\fetchmodulecommand \showmargins \f!page_run -\fetchmodulecommand \showgrid \f!page_run +\fetchmodulecommand \showprint \f!page_run +\fetchmodulecommand \showframe \f!page_run +\fetchmodulecommand \showlayout \f!page_run +\fetchmodulecommand \showsetups \f!page_run +\fetchmodulecommand \showmargins \f!page_run +\fetchmodulecommand \showgrid \f!page_run +\fetchmodulecommand \showcentering\f!page_run \glet\page_grids_add_to_box\gobbleoneargument \glet\page_grids_add_to_one\gobbleoneargument @@ -1435,8 +1450,8 @@ \c!setups=\systemsetupsprefix\s!default, \c!clipoffset=\zeropoint, \c!lines=0, - \c!paper=, % for foxet - \c!page=, % for foxet + \c!paper=, + \c!page=, \c!adaptive=\zeropoint, % new: experiment \c!columns=\plusone, \c!columndistance=\zeropoint] diff --git a/tex/context/base/mkxl/page-pcl.mkxl b/tex/context/base/mkxl/page-pcl.mkxl index 4585f1fd5..02f98a543 100644 --- a/tex/context/base/mkxl/page-pcl.mkxl +++ b/tex/context/base/mkxl/page-pcl.mkxl @@ -235,8 +235,8 @@ \page_marks_synchronize_column\plusone\c_page_col_n_of_columns\recurselevel\scratchbox % backgrounds \anch_mark_column_box\scratchbox\recurselevel - \mixedcolumnseparatorheight\ht\scratchbox - \mixedcolumnseparatordepth \dp\scratchbox + \pagecolumnseparatorheight\ht\scratchbox + \pagecolumnseparatordepth \dp\scratchbox \inheritedpagecolumnsframedbox\recurselevel\scratchbox} \def\page_col_routine_package diff --git a/tex/context/base/mkxl/phys-dim.mkxl b/tex/context/base/mkxl/phys-dim.mkxl index c84e7fffa..44aff6411 100644 --- a/tex/context/base/mkxl/phys-dim.mkxl +++ b/tex/context/base/mkxl/phys-dim.mkxl @@ -170,16 +170,11 @@ \permanent\protected\def\digitstextbinop#1% assumes preceding {\ifmmode#1\else\fourperemspace\nobreak#1\fourperemspace\fi} -%frozen\def\digitstimessymbol{\ifmmode\cdot\else\digitstextbinop\cdot\fi} \frozen\def\digitstimessymbol{\digitstextbinop\times} \frozen\protected\def\digitszeropadding {\hphantom{0}} -%frozen\protected\def\digitsnegative {\phys_digits_normalized{0}{\phys_digits_raised{\textminus}}} -%frozen\protected\def\digitspositive {\phys_digits_normalized{0}{\phys_digits_raised{\textplus}}} \frozen\protected\def\digitsnegative {\phys_digits_normalized{0}{\mathematics{\negative}}} \frozen\protected\def\digitspositive {\phys_digits_normalized{0}{\mathematics{\positive}}} -%frozen\protected\def\digitsminus {\phys_digits_normalized{0}{\mathematics{-}}} -%frozen\protected\def\digitsplus {\phys_digits_normalized{0}{\mathematics{+}}} \frozen\protected\def\digitsminus {\phys_digits_normalized{0}{\mathminus}} \frozen\protected\def\digitsplus {\phys_digits_normalized{0}{\mathplus}} \frozen\protected\def\digitsplusminus {\phys_digits_normalized{0}{\mathplusminus}} @@ -444,15 +439,14 @@ % \the\everyunits %\removeunwantedspaces % not ok yet \useunitstyleandcolor\c!style\c!color - \edef\scratchstringone{\unitparameter\c!alternative}% \ifmmode - \ifx\scratchstringone\v!text + \ifcstok{\unitparameter\c!alternative}\v!text \expandafter\expandafter\expandafter\phys_units_direct_text_in_math \else \expandafter\expandafter\expandafter\phys_units_direct_math \fi \else - \ifx\scratchstringone\v!mathematics + \ifcstok{\unitparameter\c!alternative}\v!mathematics \expandafter\expandafter\expandafter\phys_units_direct_math_in_text \else \expandafter\expandafter\expandafter\phys_units_direct_text @@ -609,30 +603,6 @@ \permanent\protected\def\unitsN#1% {\unitsNstart#1\unitsNstop} -% \def\phys_units_start -% {\ifmmode -% \dostarttagged\t!maction\t!unit -% \bgroup % make an mrow -% \else -% \dostarttagged\t!unit\empty -% \fi -% \let\phys_units_finish\phys_units_stop -% \let\phys_units_start\relax} -% -% \def\phys_units_stop -% {\ifconditional\c_phys_units_number -% \setfalse\c_phys_units_number -% \dostoptagged -% \fi -% \ifconditional\c_phys_units_quantity -% \setfalse\c_phys_units_quantity -% \dostoptagged -% \fi -% \dostoptagged -% \ifmmode -% \egroup -% \fi} - \def\phys_units_start {\ifmmode \dostarttagged\t!maction\t!unit diff --git a/tex/context/base/mkxl/publ-ini.mkxl b/tex/context/base/mkxl/publ-ini.mkxl index f1e60ca43..a9597d854 100644 --- a/tex/context/base/mkxl/publ-ini.mkxl +++ b/tex/context/base/mkxl/publ-ini.mkxl @@ -81,7 +81,7 @@ \defineinterfacevariable {btxlist} {btxlist} \defineinterfacevariable {btxrendering} {btxrendering} -\definelabelclass[btxlabel][2] +\definelabelclass [btxlabel] [2] \clf_definelabels{btxlabel}{btx}\s!false\relax @@ -877,6 +877,7 @@ filter {\btxrenderingparameter\c!filter}% \relax \ifnum\nofbtxlistentries>\zerocount + \clf_btxpreparelistentries{\currentbtxdataset}% could be put in collect \forgetall \btxrenderingparameter\c!before \ifconditional#2\relax @@ -895,7 +896,6 @@ \dostarttagged\t!list{btx}% \startpacked[\v!blank]% % sorting and so - \clf_btxpreparelistentries{\currentbtxdataset}% could be put in collect % next we analyze the width \ifempty\currentbtxnumbering \else \edef\p_width{\listparameter\c!width}% @@ -926,9 +926,9 @@ \global\advance\btxblock\plusone \endgroup} -\permanent\protected\def\placebtxrendering {\publ_place_list_indeed\conditionalfalse\conditionalfalse} -\permanent\protected\def\completebtxrendering{\publ_place_list_indeed\conditionaltrue \conditionalfalse} -\permanent\protected\def\flushbtxrendering {\publ_place_list_indeed\conditionalfalse\conditionaltrue } +\permanent\protected\def\placebtxrendering {\publ_place_list_indeed\conditionalfalse\conditionalfalse} +\permanent\protected\def\completebtxrendering {\publ_place_list_indeed\conditionaltrue \conditionalfalse} +\permanent\protected\def\flushbtxrendering {\publ_place_list_indeed\conditionalfalse\conditionaltrue } \aliased\let\completelistofpublications\completebtxrendering % for old times sake \aliased\let\placelistofpublications \placebtxrendering % for old times sake @@ -1530,8 +1530,14 @@ \endgroup \fi} +% \permanent\protected\def\btxmissing#1% +% {\dontleavehmode{\tttf<#1>}} + +\permanent\protected\def\currentbtxmissingreference + {\clf_btxmissing{\currentbtxdataset}{\currentbtxreference}} + \permanent\protected\def\btxmissing#1% - {\dontleavehmode{\tttf<#1>}} + {\dontleavehmode{\tttf<\clf_btxmissing{\currentbtxdataset}{#1}>}} %D Compatibility: @@ -1796,6 +1802,7 @@ filename {\dummyparameter\c!file}% filetype {\dummyparameter\c!type}% criterium {\dummyparameter\c!criterium}% + options {\dummyparameter\c!option}% \relax \endgroup} diff --git a/tex/context/base/mkxl/spac-ali.mkxl b/tex/context/base/mkxl/spac-ali.mkxl index 085ed143a..a74136c21 100644 --- a/tex/context/base/mkxl/spac-ali.mkxl +++ b/tex/context/base/mkxl/spac-ali.mkxl @@ -309,6 +309,8 @@ \rightskip \plusone\rightskip \spaceskip \zeropoint \xspaceskip \zeropoint + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \s_zero_plus_one_fil % new \setfalse \raggedonelinerstate % now here @@ -322,6 +324,8 @@ \rightskip \plusone\rightskip\s!plus\zeropoint \spaceskip \v_spac_align_space_amount \xspaceskip \v_spac_align_space_amount_x + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \s_zero_plus_zero \parindent \zeropoint @@ -335,6 +339,8 @@ \rightskip \plusone\rightskip\s!plus\spac_align_set_raggedness_middle \spaceskip \v_spac_align_space_amount \xspaceskip \v_spac_align_space_amount_x + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \s_zero_plus_zero \parindent \zeropoint @@ -348,6 +354,8 @@ \rightskip \plusone\rightskip\s!plus\spac_align_set_raggedness_right \spaceskip \v_spac_align_space_amount \xspaceskip \v_spac_align_space_amount_x + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \s_zero_plus_one_fil %\parindent \parindent @@ -360,6 +368,8 @@ \rightskip \plusone\rightskip\s!plus\zeropoint \spaceskip \v_spac_align_space_amount \xspaceskip \v_spac_align_space_amount_x + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \s_zero_plus_zero \parindent \zeropoint @@ -372,6 +382,8 @@ \rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount \spaceskip \v_spac_align_space_amount \xspaceskip \v_spac_align_space_amount_x + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \s_zero_plus_zero \parindent \zeropoint @@ -384,6 +396,8 @@ \rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount \spaceskip \v_spac_align_space_amount \xspaceskip \v_spac_align_space_amount_x + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \s_zero_plus_zero %\parindent \parindent @@ -397,6 +411,8 @@ \rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount_half \spaceskip \v_spac_align_space_amount \xspaceskip \v_spac_align_space_amount_x + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \s_zero_plus_zero \parindent \zeropoint @@ -407,8 +423,10 @@ \c_attr_alignstate\attributeunsetvalue \leftskip \plusone\leftskip \s!plus\v_spac_align_fill_amount\relax \rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount_negative\relax - \spaceskip \zeropoint\relax - \xspaceskip \zeropoint\relax + \spaceskip \zeropoint + \xspaceskip \zeropoint + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \zeropoint\s!plus\v_spac_align_fill_amount_double\relax \parindent \zeropoint @@ -419,8 +437,10 @@ \c_attr_alignstate\attributeunsetvalue \leftskip \plusone\leftskip \s!plus\v_spac_align_fill_amount\relax \rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount_negative\relax - \spaceskip \zeropoint\relax - \xspaceskip \zeropoint\relax + \spaceskip \zeropoint + \xspaceskip \zeropoint + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillskip \zeropoint \parfillleftskip \zeropoint\s!plus\v_spac_align_fill_amount_extreme\relax \parindent \zeropoint @@ -432,13 +452,30 @@ \c_attr_alignstate\plusthree \leftskip \plusone\leftskip \s!plus\zeropoint\relax \rightskip \plusone\rightskip\s!plus\spac_align_set_raggedness_right\relax - \spaceskip \zeropoint\relax - \xspaceskip \zeropoint\relax + \spaceskip \zeropoint + \xspaceskip \zeropoint + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint \parfillleftskip \zeropoint \parfillskip \s_zero_plus_zero %\parindent \parindent \relax} +\permanent\protected\def\spac_align_set_horizontal_slanted + {\raggedstatus \zerocount + %\c_attr_alignstate\attributeunsetvalue + \c_attr_alignstate\plustwo + \leftskip \plusone\leftskip \s!plus\spac_align_set_raggedness_middle + \rightskip \plusone\rightskip\s!plus\spac_align_set_raggedness_middle + \spaceskip \zeropoint + \xspaceskip \zeropoint + \parinitleftskip \zeropoint + \parinitrightskip \zeropoint\s!plus\v_spac_align_fill_amount_extreme\relax + \parfillleftskip \zeropoint\s!plus\v_spac_align_fill_amount_extreme\relax + \parfillskip \zeropoint + \parindent \zeropoint + \relax} + \permanent\protected\def\spac_align_set_horizontal_extra {\xspaceskip\zeropoint\s!plus\v_spac_align_fill_amount_space\relax} @@ -498,6 +535,9 @@ \or % 9 paragraph \parfillskip\zeropoint + \or + % 10 slanted + \spac_align_set_horizontal_slanted \fi \relax} @@ -732,6 +772,11 @@ \defcsname\??aligncommand l2r\endcsname{\c_spac_align_state_direction \plusone } \defcsname\??aligncommand r2l\endcsname{\c_spac_align_state_direction \plustwo } + +\defcsname\??aligncommand\v!slanted \endcsname{\c_spac_align_state_horizontal\plusten + \c_spac_align_state_broad \plustwo } + + \defcsname\??aligncommand\v!table \endcsname{\c_spac_align_state_vertical \plusthree \c_spac_align_state_broad \plusone \c_spac_align_state_horizontal\plustwo } @@ -823,6 +868,7 @@ \aliased\let\flushedrightlastline\spac_align_set_horizontal_flushedright_last_line \aliased\let\ttraggedright \spac_align_set_horizontal_right_tt % a plain command \aliased\let\forgetragged \spac_align_set_horizontal_none +\aliased\let\raggedslanted \spac_align_set_horizontal_slanted \appendtoks \spac_align_set_horizontal_none diff --git a/tex/context/base/mkxl/spac-hor.mkxl b/tex/context/base/mkxl/spac-hor.mkxl index 0773b042a..897cac3e2 100644 --- a/tex/context/base/mkxl/spac-hor.mkxl +++ b/tex/context/base/mkxl/spac-hor.mkxl @@ -1034,8 +1034,8 @@ \definehspace [\v!default] [\spaceamount] \definehspace [\v!none] [\zeropoint] -%D Taken from Taco's math module (cq. \AMS\ macros), but -%D adapted to \type {\hspace}: +%D Taken from Taco's math module (cq. \AMS\ macros), but %D adapted to \type +%D {\hspace}: \permanent\protected\def\textormathspace #1#2#3{\ifmmode\mskip#1#2\else\kern #1\hspaceamount\empty{#3}\fi\relax} \permanent\protected\def\textormathspacecommand #1#2#3{\ifmmode\mskip#1#2\else#3\fi\relax} diff --git a/tex/context/base/mkxl/spac-ver.mkxl b/tex/context/base/mkxl/spac-ver.mkxl index 2aff966bc..28a1151fb 100644 --- a/tex/context/base/mkxl/spac-ver.mkxl +++ b/tex/context/base/mkxl/spac-ver.mkxl @@ -420,8 +420,8 @@ {\ifcsname\??whitespacemethod#1\endcsname \lastnamedcs \else - \s_spac_whitespace_parskip#1\fi - \relax} + \s_spac_whitespace_parskip#1% + \fi\relax} \permanent\protected\def\forgetparskip {\s_spac_whitespace_parskip\zeropoint @@ -726,7 +726,7 @@ {\maxdepth\systemmaxdepthfactor\globalbodyfontsize} \newskip \usedbaselineskip % These used to be \normal... but that isn't pretty -\newskip \usedlineskip % in the token interface, so thes few now have new +\newskip \usedlineskip % in the token interface, so these few now have new \newdimen\usedlineskiplimit % names. They are public but not really user commands. \permanent\protected\def\normalbaselines @@ -796,6 +796,8 @@ %D \starttyping %D \rm \saveinterlinespace .... {\ss \restoreinterlinespace .... \endgraf} %D \stoptyping +%D +%D This is no longer needed. \aliased\let\restoreinterlinespace\relax @@ -1554,6 +1556,18 @@ \synchronizelocallinespecs \to \everysetuplocalinterlinespace +%D More might be added here: + +\def\restoreglobalinterlinespace + {\mutable\let\normallineheight\globalbodyfontlineheight + \bodyfontlineheight \globalbodyfontlineheight + \bodyfontstrutheight\globalbodyfontstrutheight + \bodyfontstrutdepth \globalbodyfontstrutdepth} + +% \appendtoks +% \restoreglobalinterlinespace % done elsewhere +% \to \everybeforepagebody + %D We still have to synchronize these: \permanent\protected\def\synchronizeskipamounts diff --git a/tex/context/base/mkxl/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl index 98c64205b..7e03624dc 100644 --- a/tex/context/base/mkxl/strc-mat.mkxl +++ b/tex/context/base/mkxl/strc-mat.mkxl @@ -41,6 +41,7 @@ \c!expansion=\v!yes, % maybe automatically \c!spacebefore=\v!big, \c!spaceafter=\formulaparameter\c!spacebefore, + \c!spaceinbetween=\v!quarterline, \c!width=\hsize, \c!leftmargin=\zeropoint, \c!rightmargin=\zeropoint, @@ -48,7 +49,8 @@ \c!alternative=\s!default, \c!strut=\v!yes, % per 2022-04, was \v!no \c!numberstrut=\v!yes, % \v!no \v!yes \v!always - \c!distance=2\emwidth] + \c!numberthreshold=\emwidth, + \c!numberdistance=2\emwidth] \setupformulaframed [%c!location=<auto set>, @@ -56,18 +58,7 @@ %c!align=<auto set>, \c!offset=.5\exheight] -\ifdefined\matheqnogapstep - % we're ok, now we have that quad in the distance which is - % more consistent and not depending on the text font in math - \matheqnogapstep\zerocount -\else - % we will keep this for a while - \setupformulas[\c!distance=\emwidth] -\fi - -% \ifdefined\mathdisplayskipmode -% \mathdisplayskipmode\plustwo % only when not zero / needs adapted space handler -% \fi +\matheqnogapstep\zerocount % we no longer need this as we don't use displaymode % \mathdisplayskipmode\plusthree % @@ -156,8 +147,8 @@ {\frozen\instance\protected\defcsname\e!start#1\v!formula\endcsname{#2}% \frozen\instance\protected\defcsname\e!stop #1\v!formula\endcsname{#3}} -% sp = single line paragraph sd = single line display -% mp = multi line paragraph md = multy line display +% sp = single line paragraph sd = single line display +% mp = multi line paragraph md = multi line display \defineformulaalternative[\s!default][\startdisplaymath][\stopdisplaymath] \defineformulaalternative[\s!single] [\startdisplaymath][\stopdisplaymath] @@ -195,14 +186,14 @@ % implementation -\protected\def\strc_formulas_store_number#1#2#3#4#5% ref, todo:str, \sync % todo: title etc (like float) +\protected\def\strc_formulas_store_number#1#2#3#4#5#6% ref, todo:str, \sync % todo: title etc (like float) {\settrue\c_strc_formulas_handle_number \strc_counters_register_component {formula}% \setupcurrentformula \formulaparameter \detokenizedformulaparameter \relax \relax \relax [\c!name=\v!formula,\s!counter=\v!formula,% - \s!hascaption=\v!yes,\s!hastitle=\v!yes,\s!hasnumber=\v!yes,%\s!haslevel=#6,% + \s!hascaption=\v!yes,\s!hastitle=\v!yes,\s!hasnumber=\v!yes,\s!haslevel=#6,% \c!reference=#1,% \c!title=\namedformulaentry, \c!list=\currentplaceformulalist, @@ -220,6 +211,66 @@ \newconstant\c_strc_formulas_sub_number_mode \newconstant\c_strc_formulas_nested_number_mode +\let\strc_formulas_show_modes \relax +\let\strc_formulas_show_references\relax + +\installtextracker + {math.numbering} + {\let\strc_formulas_show_modes \strc_formulas_show_modes_indeed + \let\strc_formulas_show_references\strc_formulas_show_references_indeed} + {\let\strc_formulas_show_modes \relax + \let\strc_formulas_show_references\relax} + +\def\strc_formulas_mode_row#1#2#3#4% + {\NC #1% + \NC \ifcase#2\relax unset\or forced\or none\or reference\fi + \NC #3% + \NC #4% + \NC \NR} + +\protected\def\strc_formulas_show_modes_indeed + {\rlap{\enspace\vcenter to \zeropoint{\vss\ruledvcenter{% + \forgetall\smallinfofont\setupinterlinespace + \starttabulate[|l|l|l|l|] + \strc_formulas_mode_row{place} \c_strc_formulas_place_number_mode \currentplaceformulareference \currentplaceformulasuffix + \strc_formulas_mode_row{main} \c_strc_formulas_number_mode \currentformulareference \currentformulasuffix + \strc_formulas_mode_row{sub} \c_strc_formulas_sub_number_mode \currentsubformulareference \currentsubformulasuffix + \strc_formulas_mode_row{nested} \c_strc_formulas_nested_number_mode \currentnestedformulareference \currentnestedformulasuffix + \stoptabulate + \vss}}}} + +\protected\def\strc_formulas_show_references_indeed + {\llap{\vcenter to \zeropoint{\vss\ruledvcenter{% + \forgetall\smallinfofont\setupinterlinespace + \starttabulate[|l|l|l|l|] + \NC place\NC + \ifnum\c_strc_formulas_place_number_mode=\plusthree + \ifconditional\c_strc_formulas_referenced + \textminus + \else + \textplus + \fi + \else + \textminus + \fi + \NC \NR + \NC formulas\NC + \ifnum\c_strc_formulas_number_mode=\plusthree + \textplus + \else + \textminus + \fi + \NC \NR + \NC nested\NC + \ifnum\c_strc_formulas_nested_number_mode=\plusthree + \textplus + \else + \textminus + \fi + \NC \NR + \stoptabulate + \vss}}}\enspace} + \appendtoks \c_strc_formulas_place_number_mode \zerocount \c_strc_formulas_number_mode \zerocount @@ -232,6 +283,8 @@ \newconditional\c_strc_formulas_inside_place_sub \newconditional\c_strc_formulas_inside_formulas \newconditional\c_strc_formulas_inside_formulas_sub +\newconditional\c_strc_formulas_incremented +\newconditional\c_strc_formulas_referenced \appendtoks \global\setfalse\c_strc_formulas_inside_place @@ -262,7 +315,8 @@ \empty \currentsubformulasnumber \currentsubformulassynchronize - \currentsubformulasattribute} + \currentsubformulasattribute + \plustwo} \def\strc_formulas_handle_sub_number % sub formulas {\iftrialtypesetting @@ -280,8 +334,9 @@ {\begingroup \rm % determines the distance and main font \edef\p_location{\formulaparameter\c!location}% + \strc_formulas_show_references \ifx\p_location\v!right - \hskip\formulaparameter\c!distance + \strc_formulas_add_distance\plusone\v!left\formulaparameter \fi \begingroup \useformulastyleandcolor\c!numberstyle\c!numbercolor @@ -300,14 +355,15 @@ \formulaparameter\c!right}% \endgroup \ifx\p_location\v!left - \hskip\formulaparameter\c!distance + \strc_formulas_add_distance\plusone\v!right\formulaparameter \fi + \strc_formulas_show_modes \endgroup} \protected\def\strc_formulas_place_current_number {\ifempty\namedformulaentry - \strc_formulas_handle_current_references \labeltexts\currentformula{\convertedcounter[\v!formula][]}% + \strc_formulas_handle_current_references \else \expandafter % hm, the next one reset \namedformulaentry \strc_formulas_handle_current_references @@ -373,20 +429,23 @@ \mutable\let\currentsubformulasreference \empty \mutable\let\currentsubformulassynchronize\empty -% currently we do the number, some day we will do the (sub) formula - \def\strc_formulas_handle_current_references {\strc_formulas_reference_show \ifnum\c_strc_formulas_place_number_mode=\plusthree - \strc_formulas_store_number - \currentplaceformulareference - \empty - \currentplaceformulanumber + \ifconditional\c_strc_formulas_referenced + \else + \strc_formulas_store_number + \currentplaceformulareference + \empty + \currentplaceformulanumber + \currentplaceformulasynchronize + \currentplaceformulaattribute + \plusone \currentplaceformulasynchronize - \currentplaceformulaattribute - \currentplaceformulasynchronize - \glet\currentplaceformulasynchronize\relax - \theformuladestinationattribute\currentplaceformulaattribute + \glet\currentplaceformulasynchronize\relax + \theformuladestinationattribute\currentplaceformulaattribute + \global\settrue\c_strc_formulas_referenced + \fi \fi \ifnum\c_strc_formulas_number_mode=\plusthree \strc_formulas_store_number @@ -395,6 +454,7 @@ \currentformulasnumber \currentformulassynchronize \currentformulasattribute + \plustwo \currentformulassynchronize \glet\currentformulassynchronize\relax \theformuladestinationattribute\currentformulasattribute @@ -410,18 +470,53 @@ \currentnestedformulanumber \currentnestedformulasynchronize \currentnestedformulaattribute + \plustwo \currentnestedformulasynchronize \glet\currentnestedformulasynchronize\relax \theformuladestinationattribute\currentnestedformulaattribute \fi} -% needs checking ... too many: +% \def\strc_formulas_handle_numbering_indeed +% {\ifempty\namedformulaentry +% \doifelsetext\currentnestedformulasuffix +% {\strc_counters_increment\v!formula +% \ifcstok{+}\currentnestedformulasuffix +% \strc_counters_increment_sub\v!formula\plustwo +% \else +% \strc_counters_setown_sub\v!formula\plustwo\currentnestedformulasuffix +% \fi}% +% {\ifempty\currentplaceformulasuffix\else +% \let\currentnestedformulasuffix \currentplaceformulasuffix +% \let\currentnestedformulareference\currentplaceformulareference +% \strc_formulas_place_number_nested_check +% \fi +% \strc_counters_increment\v!formula}% +% \fi +% \glet\currentplaceformulasuffix\empty +% \glet\currentnestedformulasuffix\empty +% \placecurrentformulanumber} \def\strc_formulas_handle_numbering_indeed {\ifempty\namedformulaentry - \strc_counters_increment\v!formula - \doiftext\currentplaceformulasuffix{\strc_counters_setown_sub\v!formula\plustwo\currentplaceformulasuffix}% + \doifelsetext\currentnestedformulasuffix + {\ifconditional\c_strc_formulas_incremented\else + \strc_counters_increment\v!formula + \fi + \global\settrue\c_strc_formulas_incremented + \ifcstok{+}\currentnestedformulasuffix + \strc_counters_increment_sub\v!formula\plustwo + \else + \strc_counters_setown_sub\v!formula\plustwo\currentnestedformulasuffix + \fi}% + {\ifempty\currentplaceformulasuffix\else + \let\currentnestedformulasuffix \currentplaceformulasuffix + \let\currentnestedformulareference\currentplaceformulareference + \strc_formulas_place_number_nested_check + \fi + \strc_counters_increment\v!formula}% \fi + \glet\currentplaceformulasuffix\empty + \glet\currentnestedformulasuffix\empty \placecurrentformulanumber} \def\strc_formulas_handle_numbering @@ -435,9 +530,11 @@ \def\strc_formulas_handle_sub_numbering_indeed {\let\strc_formulas_handle_sub_numbering\relax % else error: see math/numbering-001.tex - \doifelsetext\currentsubformulasuffix - {\strc_counters_setown_sub\v!formula\plustwo\currentsubformulasuffix} + \doifelsetext\currentnestedformulasuffix + {\strc_counters_setown_sub\v!formula\plustwo\currentnestedformulasuffix}% {\strc_counters_increment_sub\v!formula\plustwo}% + \glet\currentplaceformulasuffix\empty + \glet\currentnestedformulasuffix\empty \placecurrentformulanumber} \def\strc_formulas_handle_sub_numbering @@ -502,27 +599,21 @@ %D %D \starttyping %D \displaylines -%D \eqalignno -%D \eqalignno %D \stoptyping %D %D Otherwise we get a missing \type {$$} error reported. \pushoverloadmode -\aliased\let\reqno\eqno % no longer valid as we just nil it - -\aliased\let\math_native_leqno\leqno -\aliased\let\math_native_reqno\reqno + \permanent\protected\def\normaleqno#1{\writestatus\m!system{no native (l/r)eqno equation number support}} -\permanent\protected\def\normaleqno#1{\writestatus\m!system{no native (l)eqno equation number support}} + \aliased\let\normalleqno\normaleqno + \aliased\let\normalreqno\normaleqno + \aliased\let\normaleqno \normaleqno -\aliased\let\normalleqno\normaleqno -\aliased\let\normalreqno\normaleqno - -\aliased\let\leqno\normaleqno -\aliased\let\reqno\normaleqno -\aliased\let\eqno \normaleqno + \aliased\let\leqno \normaleqno + \aliased\let\reqno \normaleqno + \aliased\let\eqno \normaleqno \popoverloadmode @@ -558,100 +649,52 @@ % \predisplaygapfactor \zerocount % default is 2000 -\protected\def\strc_formulas_forget_display_skips - {\mathdisplayskipmode \plusthree - \abovedisplayskip \zeropoint - \belowdisplayskip \zeropoint - \abovedisplayshortskip\zeropoint - \belowdisplayshortskip\zeropoint} - -\newdimen\d_strc_formulas_display_skip_left -\newdimen\d_strc_formulas_display_skip_right -\newdimen\d_strc_formulas_display_margin_left -\newdimen\d_strc_formulas_display_margin_right -\newdimen\d_strc_formulas_display_pre_threshold -\newdimen\d_strc_formulas_display_width +%D We no longer need to do this every time as we don't use display mode +%D at all, so: -\newconstant\c_strc_formulas_mode % this will go away -\newconstant\c_strc_formulas_space_model +% \protected\def\strc_formulas_forget_display_skips +% {\mathdisplayskipmode \plusthree +% \abovedisplayskip \zeropoint +% \belowdisplayskip \zeropoint +% \abovedisplayshortskip\zeropoint +% \belowdisplayshortskip\zeropoint} -\newconstant\c_strc_math_vertical % experiment +%D Became this, where setting the mode is now also irrelevant but the engine still +%D has it, so: -\c_strc_formulas_mode \plustwo % 0=native 1=simple (old) 2=align (new) -\c_strc_formulas_space_model\plusthree % replaces \plusone, we might use \plusfour in the future +\mathdisplayskipmode \plusthree +\abovedisplayskip \zeropoint +\belowdisplayskip \zeropoint +\abovedisplayshortskip\zeropoint +\belowdisplayshortskip\zeropoint -\newconditional\c_strc_formulas_tight +\newdimen\d_strc_formulas_display_width -\newbox\b_strc_formulas_number -\newbox\b_strc_formulas_content - -\def\strc_formulas_flush_content_and_number - {\noindentation - % \dontleavehmode - \kern\d_strc_formulas_display_margin_left - \ifcase\wd\b_strc_formulas_number - \hbox to \displaywidth \bgroup - \hfill - \box\b_strc_formulas_content - \hfill - \egroup - \orelse\ifdim\dimexpr\wd\b_strc_formulas_content+\wd\b_strc_formulas_number\relax>\displaywidth - \vbox \bgroup - \hsize\displaywidth - \box\b_strc_formulas_content - \par - \ifx\p_location\v!left - \box\b_strc_formulas_number\hfill - \else - \hfill\box\b_strc_formulas_number - \fi - \egroup - \else - \hbox to \displaywidth \bgroup - \ifx\p_location\v!left - \rlap{\box\b_strc_formulas_number}% - \hfill\box\b_strc_formulas_content\hfill - \else - \hfill\box\b_strc_formulas_content\hfill - \llap{\box\b_strc_formulas_number}% - \fi - \egroup - \fi} +%D In \LMTX\ we have three ways of rendering formulas: +%D +%D \startitemize +%D \startitem line: a single boxed line \stopitem +%D \startitem text: multiple boxed lines \stopitem +%D \startitem page: multiple unboxed lines \stopitem +%D \stopitemize +%D +%D So, yes has become text -\installcorenamespace{mathdisplayspacemodel} +\newconstant\c_strc_math_split_mode -\defcsname\??mathdisplayspacemodel\v!before:1\endcsname % old - {\ifx\p_spacebefore\v!none - % nothing - \else - \directvspacing\p_spacebefore - \fi} +\mutable\let\m_strc_math_split\empty -\defcsname\??mathdisplayspacemodel\v!after:1\endcsname % old - {\prevdepth .5\strutdp - \ifx\p_spaceafter\v!none - % nothing - \else - \directvspacing\p_spaceafter - \fi} +\aliased\let\c_strc_math_line_mode\zerocount +\aliased\let\c_strc_math_flow_mode\plusone +\aliased\let\c_strc_math_wrap_mode\plusthree -\defcsname\??mathdisplayspacemodel\v!before:2\endcsname % old - {\ifx\p_spacebefore\v!none - % nothing - \else - \directvspacing\p_spacebefore - \fi - \prevdepth-\maxdimen} % texbook pagina 79-80 +\newconditional\c_strc_formulas_tight +\newconditional\c_strc_formulas_packed +\newconditional\c_strc_formulas_depth -\defcsname\??mathdisplayspacemodel\v!after:2\endcsname % old - {\prevdepth\lineheight - \ifx\p_spaceafter\v!none - % nothing - \else - \directvspacing\p_spaceafter - \fi} +\newbox\b_strc_formulas_number -\defcsname\??mathdisplayspacemodel\v!before:3\endcsname +\def\strc_formulas_display_space_before_normal {% not ok, try \stopformula\par\startformula vs \stopformula\startformula \let\m_spacebefore\empty \ifvmode @@ -675,7 +718,6 @@ \orelse\ifempty\p_spacebefore \directvspacing\currentvspacing \else -% \directvspacing{\p_spacebefore,\the\scratchdimen}% \directvspacing\p_spacebefore \fi \else @@ -688,9 +730,8 @@ \fi \fi} -\defcsname\??mathdisplayspacemodel\v!after:3\endcsname - {\prevdepth\strutdp % \directvspacing\v!depth - \ifx\p_spaceafter\v!none +\def\strc_formulas_display_space_after_common + {\ifx\p_spaceafter\v!none % nothing \orelse\ifempty\p_spaceafter \directvspacing\currentvspacing @@ -698,15 +739,17 @@ \directvspacing\p_spaceafter \fi} -\newconditional\c_math_model_four_indeed +\def\strc_formulas_display_space_after_normal + {\prevdepth\strutdp % \directvspacing\v!depth + \strc_formulas_display_space_after_common} -\defcsname\??mathdisplayspacemodel\v!before:4\endcsname +\def\strc_formulas_display_space_before_depth {% not ok, try \stopformula\par\startformula vs \stopformula\startformula \ifvmode \ifinner - \csname\??mathdisplayspacemodel\v!before:3\endcsname + \strc_formulas_display_space_before_normal + \setfalse\c_strc_formulas_depth \else - \settrue\c_math_model_four_indeed \forcestrutdepth \nointerlineskip \ifx\p_spacebefore\v!none @@ -714,32 +757,33 @@ \orelse\ifempty\p_spacebefore \directvspacing\currentvspacing \else -% \directvspacing{\p_spacebefore,\the\scratchdimen}% \directvspacing\p_spacebefore \fi \fi - \else - \csname\??mathdisplayspacemodel\v!before:3\endcsname - \fi} + \else + \strc_formulas_display_space_before_normal + \fi} -\defcsname\??mathdisplayspacemodel\v!after:4\endcsname - {\ifconditional\c_math_model_four_indeed - \setfalse\c_math_model_four_indeed +\def\strc_formulas_display_space_after_depth + {\ifconditional\c_strc_formulas_depth \forcestrutdepth + \strc_formulas_display_space_after_common \else - \prevdepth\strutdp % \directvspacing\v!depth - \fi - \ifx\p_spaceafter\v!none - % nothing - \orelse\ifempty\p_spaceafter - \directvspacing\currentvspacing + \strc_formulas_display_space_after_depth_normal + \fi} + +\def\strc_formulas_display_space_before + {\ifconditional\c_strc_formulas_depth + \strc_formulas_display_space_before_depth \else - \directvspacing\p_spaceafter + \strc_formulas_display_space_before_normal \fi} -\permanent\protected\def\setdisplaymathspacemodel[#1]% - {\ifcsname\??mathdisplayspacemodel\v!before:\number#1\endcsname - \c_strc_formulas_space_model#1\relax +\def\strc_formulas_display_space_after + {\ifconditional\c_strc_formulas_depth + \strc_formulas_display_space_after_depth + \else + \strc_formulas_display_space_after_normal \fi} % \newtoks\everybeforedisplay @@ -750,8 +794,13 @@ \par \fi \ifvmode - \edef\p_spacebefore{\formulaparameter\c!spacebefore}% - \begincsname\??mathdisplayspacemodel\v!before:\number\c_strc_formulas_space_model\endcsname + \ifconditional\c_strc_formulas_packed + \let\p_spacebefore\empty + \else + \edef\p_spacebefore{\formulaparameter\c!spacebefore}% + \fi + % \begincsname\??mathdisplayspacemodel\v!before:\number\c_strc_formulas_space_model\endcsname + \strc_formulas_display_space_before \fi \ifhmode \par @@ -763,32 +812,21 @@ \par \fi \ifvmode - \edef\p_spaceafter{\formulaparameter\c!spaceafter}% - \begincsname\??mathdisplayspacemodel\v!after:\number\c_strc_formulas_space_model\endcsname + \ifconditional\c_strc_formulas_packed + \let\p_spaceafter\empty + \else + \edef\p_spaceafter{\formulaparameter\c!spaceafter}% + \fi + % \begincsname\??mathdisplayspacemodel\v!after:\number\c_strc_formulas_space_model\endcsname + \strc_formulas_display_space_after \fi \ifhmode \par \fi} -\permanent\protected\def\setdisplaydimensions - {\displayindent\dimexpr - \d_strc_formulas_display_skip_left - +\d_strc_formulas_display_margin_left - \relax - \displaywidth\d_strc_formulas_display_width - %\setlocalhsize - %\displaywidth\localhsize - \ifdim\hangindent>\zeropoint - \advance\displayindent\hangindent - \else - \advance\displaywidth\hangindent - \fi - \advance\displaywidth\dimexpr - -\displayindent - -\d_strc_formulas_display_skip_right - -\d_strc_formulas_display_margin_right - \relax - \hsize\displaywidth} % new, else overfull in itemize +\ifdefined\setdisplaydimensions \else + \let\setdisplaydimensions\relax % this one will be defined in math-ali +\fi % \newskip\formulastrutht % \newskip\formulastrutdp @@ -800,18 +838,59 @@ %D %D \typebuffer \getbuffer +%D Some tracing of distances and thresholds: + +\def\strc_formulas_add_distance_normal#1#2#3% maybe a skip with stretch/shrink + {\kern#3\c!numberdistance\relax} + +\def\strc_formulas_add_distance_traced#1#2#3% + {\begingroup + \scratchdimenone #3\c!numberdistance\relax + \scratchdimentwo \ifconditional\c_strc_formulas_tight\formulaparameter\c!numberthreshold\else\zeropoint\fi\relax + \scratchdimenthree.5\exheight + \ifcase\scratchdimentwo\else\ifx#2\v!left + \middlered + \kern-\scratchdimentwo + \vrule + \s!height\scratchdimenthree + \s!depth \scratchdimenthree + \s!width \scratchdimentwo + \fi\fi + \ifcase\scratchdimenone\else + \ifcase#1\or\middlegreen\else\middleblue\fi + \vrule + \s!height\scratchdimenthree + \s!depth \scratchdimenthree + \s!width \scratchdimenone + \fi + \ifcase\scratchdimentwo\else\ifx#2\v!right + \middlered + \vrule + \s!height\scratchdimenthree + \s!depth \scratchdimenthree + \s!width \scratchdimentwo + \kern-\scratchdimentwo + \fi\fi + \endgroup} + +\installtextracker + {math.numberdistance} + {\let\strc_formulas_add_distance\strc_formulas_add_distance_traced} + {\let\strc_formulas_add_distance\strc_formulas_add_distance_normal} + +\let\strc_formulas_add_distance \strc_formulas_add_distance_normal + \defcsname\??formulaoption\v!packed\endcsname - {\c_strc_formulas_space_model\zerocount} + {\settrue\c_strc_formulas_packed} \defcsname\??formulaoption\v!tight\endcsname {\settrue\c_strc_formulas_tight} \defcsname\??formulaoption\v!middle\endcsname - {\d_strc_formulas_display_skip_left \zeropoint - \d_strc_formulas_display_skip_right\zeropoint} + {} \defcsname\??formulaoption\v!depth\endcsname - {\c_strc_formulas_space_model\plusfour} + {\settrue\c_strc_formulas_depth} \defcsname\??formulaoption\v!line\endcsname {\ifgridsnapping @@ -838,51 +917,85 @@ % \prebinoppenalty -100 % \prerelpenalty -100 -\def\strc_math_set_split_yes - {% \clf_setmathpenalties\plusone - \mathpenaltiesmode \plusone - \edef\p_hang{\formulaparameter\c!hang}% - \ifx\p_hang\v!none +% \placeformula[eq:a] +% \startformula[split=text] +% m(b-a)\leq\int_a^b f(x)\dd x\leq M(b-a). +% \stopformula +% +% \placeformula[eq:b] +% \startformula[split=line] +% m(b-a)\leq\int_a^b f(x)\dd x\leq M(b-a). +% \stopformula +% +% \placeformula[eq:c] +% \startformula[split=line,numberlocation=overlay] +% m(b-a)\leq\int_a^b f(x)\dd x\leq M(b-a). +% \stopformula + +\def\strc_math_set_split + {\edef\m_strc_math_split{\formulaparameter\c!split}% + \ifx\m_strc_math_split\v!line + \global\c_strc_math_split_mode\c_strc_math_line_mode + \orelse\ifx\m_strc_math_split\v!no + \global\c_strc_math_split_mode\c_strc_math_line_mode + \orelse\ifx\m_strc_math_split\v!box + \global\c_strc_math_split_mode\c_strc_math_wrap_mode + % \orelse\ifx\m_strc_math_split\v!page + % \global\c_strc_math_split_mode\c_strc_math_flow_mode + % \orelse\ifx\m_strc_math_split\v!text + % \global\c_strc_math_split_mode\c_strc_math_flow_mode + % \orelse\ifx\m_strc_math_split\v!yes + % \global\c_strc_math_split_mode\c_strc_math_flow_mode + % \orelse\ifx\m_strc_math_split\v!paragraph + % \global\c_strc_math_split_mode\c_strc_math_flow_mode + \else + \global\c_strc_math_split_mode\c_strc_math_flow_mode + \fi + \mathpenaltiesmode\plusone + \ifnum\c_strc_math_split_mode=\c_strc_math_line_mode \global\setfalse\c_strc_math_indent - \clf_resetmathhang \else - \global\settrue\c_strc_math_indent - \clf_setmathhang {% - method {\p_hang}% - distance \formulaparameter\c!distance - }% - \fi} - -\def\strc_math_set_split_nop - {\mathpenaltiesmode \zerocount - \clf_resetmathhang} + \global\settrue\c_strc_math_indent % otherwise no breaks + \fi + \global\d_strc_math_indent\zeropoint} -\def\strc_math_set_split - {\edef\p_split{\formulaparameter\c!split}% - \ifx\p_split\v!yes - \global\c_strc_math_vertical\plusone - \strc_math_set_split_yes - \orelse\ifx\p_split\v!page - \global\c_strc_math_vertical\plustwo - \strc_math_set_split_yes - \orelse\ifx\p_split\v!text - \global\c_strc_math_vertical\plusthree - \strc_math_set_split_nop +\def\strc_math_set_number_location + {\ifcstok{\formulaparameter\c!numberlocation}\v!overlay + \settrue\c_strc_formulas_overlay_number \else - \global\c_strc_math_vertical\zerocount - \strc_math_set_split_nop + \setfalse\c_strc_formulas_overlay_number + \fi + \ifcstok{\formulaparameter\c!numbermethod}\v!down + \settrue\c_math_align_overflow_mode + \else + \setfalse\c_math_align_overflow_mode \fi} \setupformula - [\c!split=\v!no, - \c!distance=\zeropoint, +% [\c!split=\v!no, + [\c!split=\v!text, % multi line no page breaks + \c!numberlocation=, + \c!textdistance=\zeropoint, %\c!interlinespace=1.5\lineheight, \c!textmargin=2\emwidth, - \c!interlinespace=, - \c!hang=\v!none] + \c!numbermethod=\v!down, + \c!interlinespace=] % for the moment (when testing) we use a penalty 1 +%D Alignment in vertically rendered formulas using \type {\alignhere} and friends +%D has been an experimental \MKIV\ features for quite a while but probably very few +%D users were aware of it. It works quite well and little code is needed. With +%D \LMTX\ defaulting to multiline display math it was time to add a couple of +%D features and tracing. It can actually often replace math alignments and thereby +%D not only save coding but also keep formulas as formulas instead of snippets. +%D +%D There can of course be more tricks applied but most already were rejected when I +%D wrote the original version which is actually not that far from what we do now +%D (like deeply burried align points). The main difference between the following +%D variant and the \MKIV\ one is that we try to honour the new inter|-|atom spacing +%D and adapt to the general alignment settings. + \def\strc_math_pickup_again % {\mathatom \s!leftclass \mathendcode \s!rightclass \mathbegincode{}\noatomruling} {\mathatom \s!class \mathbegincode{}\noatomruling} @@ -891,131 +1004,408 @@ \defineboundary[mathalign] % this one is also used at the lua end +\newconditional\c_strc_math_trace_hang +\newdimen \d_strc_math_hang_state + +\installtextracker + {math.autohang} + {\settrue\c_strc_math_trace_hang} + {\setfalse\c_strc_math_trace_hang} + +\newconditional\c_strc_math_aligned_here + +\def\strc_math_trace_okay#1#2% + {\mathghost{\llap{\backgroundline[#1]{\white\tttf#2}}}} + \protected\def\strc_math_align_here {\ifmmode + \global\settrue\c_strc_math_aligned_here % we can have a more dedicated value, and also maybe store the class so that we can % pick it up at the engine end (second pass) + \ifconditional\c_strc_math_trace_hang + \strc_math_trace_okay{darkred}{A}% + \fi \boundary\c_bndr_mathalign \fi} -\protected\def\strc_math_break_here +\tolerant\protected\def\strc_math_skip_here[#1]% + {% no strut as it will influence fences + \ifconditional\c_strc_math_trace_hang + \strc_math_trace_okay{darkblue}{S #1}% + \fi + \scratchdimen\dimexpr\formulaparameter\c!textmargin\relax + \ifchkdim#1\or + \d_strc_math_hang_state#1% + \orelse\ifchknum#1\or + \d_strc_math_hang_state#1\scratchdimen + \orelse\iftok{#1}{+}% + \advance\d_strc_math_hang_state\scratchdimen + \orelse\iftok{#1}{-}% + \advance\d_strc_math_hang_state-\scratchdimen + \else + \d_strc_math_hang_state\scratchdimen + \fi + \kern\d_strc_math_hang_state + \strc_math_pickup_again} + +% \blank[line] \ruledhbox{zzzz} \blank[line] +% +% xxxx \vadjust +% depth check +% depth after -\thousandpoint +% {\blue xxxx +} +% xxxx \vadjust +% pre +% {\red xxxx -} +% xxxx +% +% \blank[line] \ruledhbox{zzzz} \blank[line] + +\tolerant\protected\def\strc_math_text_here[#1]#:#*#=% + {\ifparameter#2\or + \ifnum\lastboundary=\c_math_begin_boundary\else + \ifcstok{#1}\v!right\else + \strc_math_break_here + \fi + \fi + \vadjust + \ifcstok{#1}\v!before + pre + \orelse\ifcstok{#1}\v!left + pre + baseline + depth before -\thousandpoint + \orelse\ifcstok{#1}\v!right + post + baseline + \fi + \bgroup + \hbox to \displaywidth \bgroup + \strut + \ifcstok{#1}\v!right + \hfill#2% + \else + #2\hss + \fi + \strut + \egroup + \egroup + \ifcstok{#1}\v!right + \strc_math_break_here + \else + % \mathatom class \mathexplicitcode{}% + \strc_math_pickup_again + \fi + \orelse\ifcstok{#1}\v!page + \strc_math_page_here + \orelse\ifcstok{#1}\v!samepage + \strc_math_same_here + \else + \strc_math_break_here + \fi} + +\protected\def\strc_math_page_here {\ifmmode - \hfill + \ifconditional\c_strc_math_trace_hang + \strc_math_trace_okay{darkyellow}{B P}% + \fi \break + \vadjust pre {\vfill\penalty-100000}% \strc_math_pickup_again \fi} -\tolerant\protected\def\strc_math_skip_here[#1]% - {% no strut as it will influence fences - \kern - \ifchkdim#1\or - #1% - \orelse\ifchknum#1\or - #1\dimexpr\formulaparameter\c!textmargin\relax - \else - \formulaparameter\c!textmargin +\protected\def\strc_math_same_here + {\ifmmode + \ifconditional\c_strc_math_trace_hang + \strc_math_trace_okay{darkyellow}{B S}% \fi - \relax - \strc_math_pickup_again} + \break + \vadjust pre {\penalty\plustenthousand}% + \strc_math_pickup_again + \fi} + +\protected\def\strc_math_break_here + {\ifmmode + \ifconditional\c_strc_math_trace_hang + \strc_math_trace_okay{darkgreen}{B}% + \fi + \break + \strc_math_pickup_again + \fi} \ifdefined\alignhere \else \aliased\let\alignhere\relax \fi -\ifdefined\breakhere \else \aliased\let\breakhere\relax \fi +%ifdefined\texthere \else \aliased\let\texthere \relax \fi \ifdefined\skiphere \else \aliased\let\skiphere \relax \fi +\ifdefined\breakhere \else \aliased\let\breakhere\relax \fi -\appendtoks +\appendtoks % must move to alignment \enforced\let\alignhere\strc_math_align_here - \enforced\let\breakhere\strc_math_break_here + \enforced\let\breakhere\strc_math_text_here \enforced\let\skiphere \strc_math_skip_here + %enforced\let\texthere \strc_math_text_here +% \global\setfalse\c_strc_math_aligned_here \to \everymathematics -% \protected\def\strc_formulas_start_formula#1% -% {\strc_formulas_start_formula_indeed[#1]} -% -% \tolerant\protected\def\strc_formulas_start_formula[#1]#*[#2]% setting leftskip adaption is slow ! - \installcorenamespace{mathtextalign} -\defcsname\??mathtextalign\v!slanted\endcsname - {\raggedcenter - \parinitleftskip \zeropoint - \parinitrightskip\s_spac_filll - \parfillleftskip \s_spac_filll - \parfillrightskip\zeropoint - \updateparagraphproperties} +\newconstant\c_strc_math_ragged_status +\newconstant\c_strc_math_split_status + +\prependtoks + \c_strc_math_ragged_status\plustwo + \c_strc_math_split_status \zerocount +\to \everymathematics + +% \defcsname\??mathtextalign\v!flushleft\endcsname {\raggedright + \mathgluemode\plustwo + \c_strc_math_ragged_status\plusone + \updateparagraphproperties} % not needed + +\defcsname\??mathtextalign\v!middle\endcsname + {\raggedcenter + \mathgluemode\plustwo + \c_strc_math_ragged_status\plustwo \updateparagraphproperties} % not needed \defcsname\??mathtextalign\v!flushright\endcsname {\raggedleft + \mathgluemode\plustwo + \c_strc_math_ragged_status\plusthree \updateparagraphproperties} % not needed -\defcsname\??mathtextalign\v!middle\endcsname - {\raggedcenter +\defcsname\??mathtextalign\v!slanted\endcsname + {\raggedslanted + %\mathgluemode\plustwo + \c_strc_math_ragged_status\plustwo + \parfillrightskip\wd\b_strc_formulas_number % should normally fit \updateparagraphproperties} % not needed -\defcsname\??mathtextalign\v!middle:\v!start\endcsname - {\raggedcenter - \setbox\scratchbox\vbox{\unhcopy\b_strc_math_display}% - \scratchdimen\dimexpr\textwidth-\d_strc_math_indent-\themaxboxwidth\scratchbox\relax} +\def\strc_math_setup_align + {\ifcsname\??mathtextalign\formulaparameter\c!align\endcsname + \lastnamedcs\else\begincsname\??mathtextalign\v!middle\endcsname + \fi} + +\defcsname\??mathtextalign\v!flushleft:\v!auto\endcsname + {\raggedright + \mathgluemode\plustwo + \c_strc_math_ragged_status\plusone + \strc_math_analyze_box} + +\defcsname\??mathtextalign\v!middle:\v!auto\endcsname + {\raggedright + \mathgluemode\plustwo + \c_strc_math_ragged_status\plustwo + \strc_math_analyze_box} -\defcsname\??mathtextalign\v!middle:\v!stop\endcsname - {\leftskip.5\scratchdimen - \rightskip\leftskip} +\defcsname\??mathtextalign\v!flushright:\v!auto\endcsname + {\raggedright + \mathgluemode\plustwo + \c_strc_math_ragged_status\plusthree + \strc_math_analyze_box} + +\defcsname\??mathtextalign\v!slanted:\v!auto\endcsname + {\raggedright + \mathgluemode\plustwo + \c_strc_math_ragged_status\plustwo + \strc_math_analyze_box}\stopformula -\defcsname\??mathtextalign\v!flushleft:\v!start\endcsname - {\csname\??mathtextalign\v!middle:\v!start\endcsname} +\def\strc_math_setup_align_auto + {\ifcsname\??mathtextalign\formulaparameter\c!align:\v!auto\endcsname + \lastnamedcs\else\begincsname\??mathtextalign\v!middle:\v!auto\endcsname + \fi} -\defcsname\??mathtextalign\v!flushleft:\v!stop\endcsname - {\leftskip\zeropoint - \rightskip\leftskip} +\startsetups[math:penalties:\v!text] + \interlinepenalty \plustenthousand + \shapingpenalty \plustenthousand +\stopsetups -\defcsname\??mathtextalign\v!flushright:\v!start\endcsname - {\csname\??mathtextalign\v!middle:\v!start\endcsname} +% or (test): +% +% \startsetups[math:penalties:\v!text] +% \shapingpenaltiesmode \zerocount +% \interlinepenalty \plustenthousand +% \stopsetups -\defcsname\??mathtextalign\v!flushright:\v!stop\endcsname - {\leftskip\scratchdimen - \rightskip\leftskip} +\startsetups[math:penalties:\v!page] + \shapingpenaltiesmode \zerocount + \widowpenalties \plusthree \plustenthousand \plustenthousand \zerocount + \clubpenalties \plusthree \plustenthousand \plustenthousand \zerocount +\stopsetups -\tolerant\protected\def\strc_formulas_start_formula#1#:#*[#2]% setting leftskip adaption is slow ! - {\ifhmode - \par +\setupformula + [\c!penalties=math:penalties:\formulaparameter\c!split] % math:penalties:\m_strc_math_split + +\def\strc_math_setup_penalties + {\directsetup{\formulaparameter\c!penalties}} + +% a limitation is that this only works in a regular setting, so no shapes + +\newcount\c_strc_math_n_of_lines +\newdimen\d_strc_math_max_width +\newdimen\d_strc_math_last_width +\newdimen\d_strc_math_last_depth + +\appendtoks + \global\d_strc_math_indent \zeropoint + \global\c_strc_math_n_of_lines\zerocount + \global\d_strc_math_max_width \zeropoint + \global\d_strc_math_last_width\zeropoint + \global\d_strc_math_last_depth\zeropoint +\to \everyresetformulas + +\newbox\b_strc_math_display % most code is in math-ali (for historical reasons) + +\newskip\s_strc_formulas_margin_left +\newskip\s_strc_formulas_margin_right + +\def\strc_formulas_set_paragraph + {%\setlocalhsize + %\hsize\localhsize + % + \d_strc_formulas_display_width\formulaparameter\c!width\relax + \s_strc_formulas_margin_left \leftskip + \s_strc_formulas_margin_right\rightskip + \edef\p_margin{\formulaparameter\c!leftmargin}% + \ifempty\p_margin \else + \doadaptleftskip\p_margin \fi - \bgroup % HERE - \iftrialtypesetting\else - \global\advance\c_strc_formulas_n\plusone + \edef\p_margin{\formulaparameter\c!rightmargin}% + \ifempty\p_margin \else + \doadaptrightskip\p_margin \fi - \def\currentformula{#1}% - \strc_math_set_split - \dostarttaggedchained\t!formula\currentformula\??formula - \setfalse\c_strc_formulas_tight - \d_strc_formulas_display_skip_left \leftskip - \d_strc_formulas_display_skip_right \rightskip - \d_strc_formulas_display_width \formulaparameter\c!width\relax - \d_strc_formulas_display_margin_left \formulaparameter\c!leftmargin\relax - \d_strc_formulas_display_margin_right\formulaparameter\c!rightmargin\relax - \iftok{#2}\emptytoks + \edef\p_margin{\formulaparameter\c!margin}% + \ifempty\p_margin \else + \doadaptleftskip\p_margin + \doadaptrightskip\p_margin + \fi + % + \global\setfalse\c_strc_math_aligned_here + \hsize\d_strc_formulas_display_width + \displaywidth\hsize + \displayindent\zeropoint} + +\def\strc_math_analyze_box + {\clf_handlemathhang + stage \plusone + alignstate \c_strc_math_ragged_status + box \b_strc_math_display + distance \formulaparameter\c!textdistance + \relax + %\holdingmigrations\zerocount + \setbox\b_strc_math_display\vbox\bgroup % \vtop + \ifnum\c_strc_math_split_mode=\c_strc_math_line_mode + % we can't end up here + \orelse\ifconditional\c_strc_math_aligned_here + \ifzeropt\d_strc_math_indent\else + \hangafter\plusone + \hangindent\d_strc_math_indent + \fi + % \strc_math_setup_align % _inner + \else + \strc_math_setup_align + \fi +% \strc_math_setup_spacing\formulaparameter + \strc_math_setup_penalties + \unhbox\b_strc_math_display + \egroup + \clf_handlemathhang + stage \ifconditional\c_strc_math_aligned_here \plustwo \else \plusthree \fi + % alignstate \c_strc_math_ragged_status + % box \b_strc_math_display + % distance \formulaparameter\c!textdistance + \relax + % + \begingroup + \edef\v_spac_whitespace_current{\formulaparameter\c!spaceinbetween}% + \spac_whitespace_setup + \clf_handlemathhang + stage \plusfour + inbetween 1\parskip + height \strutht + depth \strutdp + \relax + \endgroup} + +\def\strc_math_show_margins_there + {\vadjust pre \bgroup + \c_attr_visual\attributeunsetvalue + \hbox to \hsize \bgroup + \setbox\scratchbox\hbox to \hsize\bgroup + \bgroup\darkred \vrule \s!width\leftskip \egroup\hss + \bgroup\darkgray\leaders\vrule\hfill \egroup\hss + \bgroup\white \vrule \s!width\emwidth \egroup\hss + \bgroup\darkgray\leaders\vrule\hfill \egroup\hss + \bgroup\darkblue\vrule \s!width\rightskip\egroup + \egroup + \ht\scratchbox1.2\exheight + \dp\scratchbox0.4\exheight + \strut + \box\scratchbox + \hskip-\hsize + \hbox to \hsize \bgroup + \white + \infofont + \hskip1\leftskip + \quad + \formulaparameter\c!split + \quad + \formulaparameter\c!align + \egroup + \egroup + \egroup} + +\let\strc_math_inject_show_margins_here\relax + +\def\strc_math_show_margins_indeed + {\gdef\strc_math_inject_show_margins_here + {\strc_math_show_margins_there + \glet\strc_math_inject_show_margins_here\relax}% + \appendtoks\strc_math_inject_show_margins_here\to\everypar} + +\installtextracker + {math.showmargins} + {\let\strc_math_show_margins\strc_math_show_margins_indeed} + {\let\strc_math_show_margins\relax} + +\let\strc_math_show_margins\relax + +\def\strc_math_set_options#1% + {\setfalse\c_strc_formulas_tight + \setfalse\c_strc_formulas_packed + \setfalse\c_strc_formulas_depth + \iftok{#1}\emptytoks \edef\p_option{\formulaparameter\c!option}% - \orelse\ifhastok={#2}% this is new, so that we can also set the grid - \setupcurrentformula[#2]% + \orelse\ifhastok={#1}% this is new, so that we can also set the grid + \setupcurrentformula[#1]% \edef\p_option{\formulaparameter\c!option}% \else \edef\p_option{\formulaparameter\c!option}% - \edef\p_option{\ifempty\p_option\else\p_option,\fi#2}% + \edef\p_option{\ifempty\p_option\else\p_option,\fi#1}% \fi \ifempty\p_option \else \rawprocesscommacommand[\p_option]\strc_formulas_option + \fi} + +\tolerant\protected\def\strc_formulas_start_formula#1#:#*[#2]% setting leftskip adaption is slow ! + {\ifhmode + \par \fi - \edef\p_margin{\formulaparameter\c!margin}% - \ifempty\p_margin \else - \dosetleftskipadaption\p_margin - \d_strc_formulas_display_margin_left\leftskipadaption + \bgroup % HERE + \iftrialtypesetting\else + \global\advance\c_strc_formulas_n\plusone \fi + \def\currentformula{#1}% + \dostarttaggedchained\t!formula\currentformula\??formula + \strc_math_set_options{#2}% + \strc_math_set_split + \strc_math_set_number_location + \strc_formulas_set_paragraph \let\strc_formulas_start_formula\strc_formulas_start_formula_nested - \strc_formulas_forget_display_skips \the\everybeforedisplayformula - \begincsname\??mathtextalign\formulaparameter\c!textalign\endcsname + \strc_math_setup_align \ifcstok{\formulaparameter\c!strut}\v!yes \let\strc_formulas_begstrut\begstrut \let\strc_formulas_endstrut\endstrut @@ -1034,6 +1424,8 @@ {\dostoptagged \egroup} +% the application of the above is in math-ali.mkxl: \strc_math_flush_aligned + % tagging of formulanumbers is not ok (we get two display maths blobs) \newcount\c_strc_formulas_n @@ -1071,9 +1463,6 @@ \fi \to \everybeforedisplayformula -% \protected\def\switchtoformulabodyfont -% {\switchtobodyfont} - \tolerant\permanent\protected\def\formula[#1]#;#2% todo: tagged {\begingroup \ifparameters#1\else @@ -1095,6 +1484,8 @@ \let\strc_formulas_begstrut\relax \let\strc_formulas_endstrut\relax +\newboundary\c_math_begin_boundary + \permanent\protected\def\startdisplaymath {\ifhmode \par @@ -1102,20 +1493,11 @@ \bgroup \informulatrue \beforedisplayspace - \setdisplaydimensions - \ifcase\c_strc_formulas_mode - \noindent % prevents that tex injects empty line (when using native display mechanism) - \Ucheckedstartdisplaymath - \the\everydisplay % new (probably too much) - \or - \setbox\b_strc_formulas_content\hbox\bgroup - \normalUstartmath - \displaystyle - \the\everydisplay % new (probably too much) - \else - \expandafter\startinnermath + \startinnermath + \ifrelax\strc_formulas_begstrut\else + \strc_formulas_begstrut + \boundary\c_math_begin_boundary \fi - \strc_formulas_begstrut \begingroup} % less interference with upcoming a \over b \permanent\protected\def\stopdisplaymath @@ -1123,15 +1505,7 @@ \ifhmode \strc_formulas_endstrut \fi - \ifcase\c_strc_formulas_mode - \Ucheckedstopdisplaymath - \or - \normalUstopmath - \egroup - \strc_formulas_flush_content_and_number - \else - \expandafter\stopinnermath - \fi + \stopinnermath \afterdisplayspace \egroup} @@ -1161,10 +1535,7 @@ % \placeformula {f} \startspformule \fakespacingformula \stopspformule % \fakewords{20}{40} -\permanent\protected\def\startsubformulas - {\dosingleempty\strc_formulas_start_sub_formulas} - -\def\strc_formulas_start_sub_formulas[#1]% +\tolerant\permanent\protected\def\startsubformulas[#1]% {\edef\currentsubformulasreference{#1}% \global\settrue\c_strc_formulas_inside_formulas_sub \strc_formulas_handle_sub_number} @@ -1178,10 +1549,7 @@ %D Named subformulas (to be redone) -\permanent\protected\def\startnamedsubformulas - {\dosingleempty\strc_formulas_start_named_sub_formulas} - -\def\strc_formulas_start_named_sub_formulas[#1]#2% +\tolerant\permanent\protected\def\startnamedsubformulas[#1]#2% {\setformulalistentry{#2}% \startsubformulas[#1]} @@ -1203,21 +1571,25 @@ \permanent\letcsname\e!stop\v!formulas\endcsname\relax -\protected\def\strc_formulas_nested_formula_start - {\hbox to \displaywidth \bgroup - \hsize\displaywidth - \hss - %\Ustartmath +\tolerant\protected\def\strc_formulas_nested_formula_start[#1]% + {\begingroup + \ifparameter#1\or + \setupformula[\c!width=\d_strc_formulas_display_width,#1]% + \d_strc_formulas_display_width\formulaparameter\c!width\relax + \fi + \vcenter \bgroup + \hsize \d_strc_formulas_display_width + \displaywidth\d_strc_formulas_display_width + \raggedcenter \dostarttagged\t!formulacontent\empty \csname\e!start\formulaparameter\c!alternative\v!formula\endcsname} \protected\def\strc_formulas_nested_formula_stop {\csname\e!stop\formulaparameter\c!alternative\v!formula\endcsname \dostoptagged - %\Ustopmath - \hss \egroup - \hss} + \hss + \endgroup} \normalexpanded{\tolerant\def\noexpand\strc_formulas_start_formulas[#1]#:#2\csname\e!stop\v!formulas\endcsname}% {\startformula @@ -1226,15 +1598,15 @@ \edef\currentformulasreference{#1}% \strc_formulas_handle_number \let\currentformula\empty - \strc_formulas_forget_display_skips + % \strc_formulas_forget_display_skips \enforced\protected\def\startformula {\advance\scratchcounter\plusone \expandafter\gobbleuntil\csname\e!stop\v!formula\endcsname}% \scratchcounter\zerocount #2% preroll - \hbox to \displaywidth \bgroup + \hbox to \d_strc_formulas_display_width \bgroup \ifcase\scratchcounter\else - \divide\displaywidth\scratchcounter + \divide\d_strc_formulas_display_width\scratchcounter \fi \hss \enforced\let\startformula\strc_formulas_nested_formula_start @@ -1266,10 +1638,7 @@ \plusthree \fi} -\permanent\protected\def\formulanumber - {\strc_formulas_number} % for the moment - -\tolerant\protected\def\strc_formulas_number[#1]% +\tolerant\permanent\protected\def\formulanumber[#1]% {\def\currentformulareference{#1}% \strc_formulas_place_number_in_box} @@ -1277,12 +1646,16 @@ \permanent\protected\def\placesubformula{\global\settrue\c_strc_formulas_inside_place_sub\strc_formulas_place} \tolerant\protected\def\strc_formulas_place[#1]% - {\def\currentplaceformulareference{#1}% - \let\currentplaceformulasuffix\empty + {\xdef\currentplaceformulareference{#1}% + \glet\currentplaceformulasuffix\empty + \glet\currentnestedformulasuffix\empty + \global\setfalse\c_strc_formulas_incremented + \global\setfalse\c_strc_formulas_referenced + \global\settrue\c_strc_formulas_inside_place \doifelsenextbgroup\strc_formulas_place_yes\strc_formulas_place_nop} % [ref]{} \protected\def\strc_formulas_place_yes#1% - {\def\currentplaceformulasuffix{#1}% + {\xdef\currentplaceformulasuffix{#1}% \strc_formulas_place_nop} \protected\def\strc_formulas_place_nop @@ -1311,6 +1684,8 @@ \permanent\tolerant\protected\def\startplaceformula[#1]% {\begingroup + \global\setfalse\c_strc_formulas_incremented + \global\setfalse\c_strc_formulas_referenced \global\settrue\c_strc_formulas_inside_place \ifparameter#1\or \expandafter\strc_formulas_start_place_yes @@ -1322,13 +1697,13 @@ {\doifassignmentelse{#1}\strc_formulas_start_place_parameters\strc_formulas_start_place_reference[#1]} \def\strc_formulas_start_place_nop[#1]% - {\let\currentplaceformulareference\empty - \let\currentplaceformulasuffix \empty + {\glet\currentplaceformulareference\empty + \glet\currentplaceformulasuffix \empty \strc_formulas_place_nop} \def\strc_formulas_start_place_reference[#1]% - {\edef\currentplaceformulareference{#1}% - \let\currentplaceformulasuffix\empty + {\xdef\currentplaceformulareference{#1}% + \glet\currentplaceformulasuffix\empty %\doifelsenextbgroup\strc_formulas_place_yes\strc_formulas_place_nop} % [ref]{} \strc_formulas_place_nop} @@ -1362,50 +1737,70 @@ \let\strc_formulas_place_number_nested\gobbletwoarguments \def\strc_formulas_place_number_nested_indeed#1#2% - {\def\currentnestedformulareference{#1}% - \def\currentnestedformulasuffix{#2}% - \strc_formulas_check_reference\c_strc_formulas_nested_number_mode\currentnestedformulareference + {\ifhastok={#1}% + \setupcurrentmathalignment[#1]% + \xdef\currentnestedformulareference{\mathalignmentparameter\c!reference}% + \xdef\currentnestedformulasuffix {\mathalignmentparameter\c!suffix}% + \global\d_math_eqalign_number_threshold\mathalignmentparameter\c!numberthreshold\relax + \orelse\ifhastok+{#1}% + \glet\currentnestedformulareference\empty + \xdef\currentnestedformulasuffix {+}% + \orelse\ifempty\currentplaceformulareference + \xdef\currentnestedformulareference{#1}% + \xdef\currentnestedformulasuffix {#2}% + \else + \glet\currentnestedformulareference\empty + \xdef\currentnestedformulasuffix {#1}% + \fi + \strc_formulas_place_number_nested_check} + +\def\strc_formulas_place_number_nested_check + {\ifempty\currentnestedformulareference + \ifempty\currentnestedformulasuffix \else + \c_strc_formulas_nested_number_mode\plusthree + \fi + \else + \strc_formulas_check_reference\c_strc_formulas_nested_number_mode\currentnestedformulareference + \fi \ifcase\c_strc_formulas_nested_number_mode % nothing \or \glet\strc_formulas_place_number\relax - \expandafter\strc_formulas_number % hm, looks ahead for [] + \strc_formulas_place_number_in_box \or % nothing \or \glet\strc_formulas_place_number\relax - \expandafter\strc_formulas_number % hm, looks ahead for [] + \strc_formulas_place_number_in_box \fi} \def\strc_formulas_place_number_indeed {\strc_formulas_place_number_in_box} -% \def\strc_formulas_place_number_in_box -% {\dostarttagged\t!formulacaption\empty -% \global\setbox\b_strc_formulas_number\naturalhbox{\strc_formulas_number_indeed}% -% \dostoptagged} +% \startplaceformula +% \startformula +% \startalign +% \NC a \NC = p \NR[eq:one] +% \NC b \NC = q \NR +% \NC c \NC = r \NR[eq:two] +% \NC d \NC = s \NR[eq:three] +% \stopalign +% \stopformula +% \stopplaceformula +% \stoptext \def\strc_formulas_place_number_in_box {\dostarttagged\t!formulacaption\empty - % this is really needed, otherwise we get spurious numbers probbaly due to some + % this is really needed, otherwise we get spurious numbers probably due to some % interference with other local variables .. also keep an eye on eqtest in the % MS tests - \glet\strc_formulas_place_number \relax - \glet\strc_formulas_place_number_nested\gobbletwoarguments + \glet\strc_formulas_place_number \relax + %\glet\strc_formulas_place_number_nested\gobbletwoarguments % \global\setbox\b_strc_formulas_number\naturalhbox{\strc_formulas_number_indeed}% \dostoptagged} -\def\strc_formulas_flush_number - {\ifcase\c_strc_formulas_mode - \ifzeropt\wd\b_strc_formulas_number - % nothing to be done - \orelse\ifx\p_location\v!left - \math_native_leqno{\box\b_strc_formulas_number}% - \else - \math_native_reqno{\box\b_strc_formulas_number}% - \fi - \fi} +\let\strc_formulas_flush_number\relax % todo @@ -1424,10 +1819,21 @@ {\setformulalistentry{#2}% \placeformula} +\def\strc_math_flush_aligned_boxed_direct_yes + {\dontleavehmode % NO! + \hskip-\leftskip % bah + \box\b_strc_math_display + \llap{\box\b_strc_formulas_number}} + +\def\strc_math_flush_aligned_boxed_direct_nop + {\dontleavehmode % NO! + \hskip-\leftskip % bah + \box\b_strc_math_display} + \mutable\let\namedformulaentry\empty % \relax % this will become a key/value so that we can do bookmarks \permanent\protected\def\setformulalistentry#1% - {\gdef\namedformulaentry{#1}} + {\xdef\namedformulaentry{#1}} %D New: %D diff --git a/tex/context/base/mkxl/strc-not.mklx b/tex/context/base/mkxl/strc-not.mklx index f6de80efe..fbe45b2e8 100644 --- a/tex/context/base/mkxl/strc-not.mklx +++ b/tex/context/base/mkxl/strc-not.mklx @@ -1387,22 +1387,33 @@ \setupnotes [\c!width=\v!auto] +% \permanent\protected\def\setnotehsize +% {\ifinsidemulticolumns +% \setnoteparameter\c!width{\makeupwidth}% +% \else +% \edef\p_width{\noteparameter\c!width}% +% \ifx\p_width\v!auto +% % \ifinsidecolumns +% \setnoteparameter\c!width{\ifdim\hsize<\makeupwidth\hsize\else\makeupwidth\fi}% +% % \else +% % \setnoteparameter\c!width{\makeupwidth}% +% % \fi +% \orelse\ifempty\p_width +% \setnoteparameter\c!width{\hsize}% +% \fi +% \fi +% \hsize\noteparameter\c!width\relax} +% +% We construct immediately and migrate so: + \permanent\protected\def\setnotehsize - {\ifinsidemulticolumns + {\edef\p_width{\noteparameter\c!width}% + \ifx\p_width\v!auto + % intercept old value + \let\p_width\makeupwidth \setnoteparameter\c!width{\makeupwidth}% - \else - \edef\p_width{\noteparameter\c!width}% - \ifx\p_width\v!auto - % \ifinsidecolumns - \setnoteparameter\c!width{\ifdim\hsize<\makeupwidth\hsize\else\makeupwidth\fi}% - % \else - % \setnoteparameter\c!width{\makeupwidth}% - % \fi - \orelse\ifempty\p_width - \setnoteparameter\c!width{\hsize}% - \fi - \fi - \hsize\noteparameter\c!width\relax} + \fi + \hsize\p_width\relax} \appendtoks % only needed when columns (could be three \set...) diff --git a/tex/context/base/mkxl/strc-num.mkxl b/tex/context/base/mkxl/strc-num.mkxl index 02674bce2..f0735b0e5 100644 --- a/tex/context/base/mkxl/strc-num.mkxl +++ b/tex/context/base/mkxl/strc-num.mkxl @@ -454,13 +454,17 @@ \def\strc_counters_register_component_list#1#2#3#4% {\xdef\currentstructurecomponentname {#2\s!name}% - \xdef\currentstructurecomponentlevel {#2\c!level}% + \xdef\currentstructurecomponentcounter {#2\s!counter}% + \xdef\currentstructurecomponentlevel {#2\s!haslevel}% \edef\currentstructurecomponentexpansion {#2\c!expansion}% \xdef\currentstructurecomponentxmlsetup {#2\c!xmlsetup}% \xdef\currentstructurecomponentcatcodes {#2\s!catcodes}% \xdef\currentstructurecomponentlabel {#2\c!label}% \xdef\currentstructurecomponentreference {#2\c!reference}% \xdef\currentstructurecomponentreferenceprefix{#2\c!referenceprefix}% + \ifempty\currentstructurecomponentcounter + \glet\currentstructurecomponentcounter\currentcounter + \fi \strc_counters_register_component_check_prefix \ifx\currentstructurecomponentexpansion\s!xml \xmlstartraw @@ -533,7 +537,7 @@ list {\detokenize\expandafter{\currentstructurecomponentlist}} \fi } - \ifx\p_hasnumber\v!yes + \ifx\p_hasnumber\v!yes\ifempty\currentstructurecomponentcounter\else prefixdata { prefix {#2\c!prefix} separatorset {#2\c!prefixseparatorset} @@ -545,10 +549,13 @@ connector {#2\c!prefixconnector} } numberdata { % more helpers here, like compact elsewhere - numbers {\currentcounter} + \ifempty\currentstructurecomponentlevel\else + level \currentstructurecomponentlevel + \fi + numbers {\currentstructurecomponentcounter} group {#2\c!group} groupsuffix {#2\c!groupsuffix} - counter {\currentcounter} + counter {\currentstructurecomponentcounter} separatorset {#2\c!numberseparatorset} conversion {#2\c!numberconversion} conversionset {#2\c!numberconversionset} @@ -556,7 +563,7 @@ stopper {#2\c!numberstopper} segments {#2\c!numbersegments} } - \fi + \fi\fi userdata {\detokenize{#4}} %} \relax diff --git a/tex/context/base/mkxl/strc-ref.lmt b/tex/context/base/mkxl/strc-ref.lmt index ddbb160ff..7ad20fa34 100644 --- a/tex/context/base/mkxl/strc-ref.lmt +++ b/tex/context/base/mkxl/strc-ref.lmt @@ -195,7 +195,7 @@ local nofreferred = 0 local function initializer() -- can we use a tobesaved as metatable for collected? tobereferred = references.tobereferred referred = references.referred - nofreferred = #referred + nofreferred = #referred end -- no longer done this way @@ -1854,7 +1854,7 @@ references.identify = identify local unknowns, nofunknowns, f_valid = { }, 0, formatters["[%s][%s]"] -function references.valid(prefix,reference,specification) +function references.valid(prefix,reference,specification,silent) local set, bug = identify(prefix,reference) local unknown = bug or #set == 0 if unknown then @@ -1862,7 +1862,7 @@ function references.valid(prefix,reference,specification) local str = f_valid(prefix,reference) local u = unknowns[str] if not u then - if somefound then + if somefound and not silent then interfaces.showmessage("references",1,str) -- 1 = unknown, 4 = illegal end unknowns[str] = 1 @@ -1880,6 +1880,10 @@ function references.valid(prefix,reference,specification) return not unknown end +function references.checked(prefix,reference,specification) + return references.valid(prefix,reference,specification,true) +end + implement { name = "doifelsereference", actions = { references.valid, commands.doifelse }, @@ -1894,6 +1898,20 @@ implement { } } +implement { + name = "doifelsereferencechecked", + actions = { references.checked, commands.doifelse }, + arguments = { + "string", + "string", + { + { "highlight", "boolean" }, + { "newwindow", "boolean" }, + { "layer" }, + } + } +} + logs.registerfinalactions(function() if nofunknowns > 0 then statistics.register("cross referencing", function() @@ -2064,7 +2082,7 @@ function references.setandgetattribute(data) -- maybe do internal automatically if ndat then local numbers = ndat.numbers if type(numbers) == "string" then - ndat.numbers = counters.compact(numbers,nil,true) + counters.compact(ndat,numbers) end data.numberdata = helpers.simplify(ndat) end diff --git a/tex/context/base/mkxl/strc-ref.mklx b/tex/context/base/mkxl/strc-ref.mklx index 61c1085f1..07c8c2c1b 100644 --- a/tex/context/base/mkxl/strc-ref.mklx +++ b/tex/context/base/mkxl/strc-ref.mklx @@ -693,6 +693,11 @@ \aliased\let\doifreferencefoundelse\doifelsereferencefound +\permanent\def\doifelsereferencechecked#label% + {\clf_doifelsereferencechecked{\referenceprefix}{#label}{\extrareferencearguments}} + +\aliased\let\doifcheckedreferencefoundelse\doifelsereferencechecked + %D The tester only splits the reference in components but does not look into them. %D The following macro does a preroll and determines for instance the current real %D reference pagenumber. The \type {\currentrealreference} macro does the same so diff --git a/tex/context/base/mkxl/strc-sec.mkxl b/tex/context/base/mkxl/strc-sec.mkxl index cb897d906..3973d0834 100644 --- a/tex/context/base/mkxl/strc-sec.mkxl +++ b/tex/context/base/mkxl/strc-sec.mkxl @@ -64,8 +64,12 @@ {\ifempty\currentstructurereferenceprefix % nothing \orelse\ifx\currentstructurereferenceprefix\m_strc_references_prefix_yes - \global\advance\prefixcounter \plusone % temp here - \setupglobalreferenceprefix[\the\prefixcounter]% + \ifempty\currentstructurereference + \global\advance\prefixcounter \plusone % temp here + \setupglobalreferenceprefix[\the\prefixcounter]% + \else + \setupglobalreferenceprefix[\currentstructurereference]% + \fi \orelse\ifx\currentstructurereferenceprefix\m_strc_references_prefix_nop \setupglobalreferenceprefix[]% \else diff --git a/tex/context/base/mkxl/supp-mat.mkxl b/tex/context/base/mkxl/supp-mat.mkxl index ef72e0e9a..c3c69593a 100644 --- a/tex/context/base/mkxl/supp-mat.mkxl +++ b/tex/context/base/mkxl/supp-mat.mkxl @@ -44,21 +44,21 @@ %D %D Which is implemented (in \type{syst-ini.mkiv}) as: -\permanent\protected\def\Ucheckedstartdisplaymath - {\ifinner - \ifhmode - \normalUstartmath - \let\Ucheckedstopdisplaymath\normalUstopmath - \else - \normalUstartdisplaymath - \let\Ucheckedstopdisplaymath\normalUstopdisplaymath - \fi - \else - \normalUstartdisplaymath - \let\Ucheckedstopdisplaymath\normalUstopdisplaymath - \fi} - -\aliased\let\Ucheckedstopdisplaymath\relax +% \permanent\protected\def\Ucheckedstartdisplaymath +% {\ifinner +% \ifhmode +% \normalUstartmath +% \let\Ucheckedstopdisplaymath\normalUstopmath +% \else +% \normalUstartdisplaymath +% \let\Ucheckedstopdisplaymath\normalUstopdisplaymath +% \fi +% \else +% \normalUstartdisplaymath +% \let\Ucheckedstopdisplaymath\normalUstopdisplaymath +% \fi} +% +% \aliased\let\Ucheckedstopdisplaymath\relax % \let\normalsuper\Usuperscript % obsolete % \let\normalsuber\Usubscript % obsolete @@ -69,8 +69,8 @@ \aliased\let\stopdmath \Ustopdisplaymath % \Ucheckedstopdisplaymath \permanent\protected\def\mathematics#1{\relax \ifmmode#1\else\normalstartimath#1\normalstopimath\fi} -\permanent\protected\def\displaymath#1{\noindent \ifmmode#1\else\normalstartdmath#1\normalstopdmath\fi} -\permanent\protected\def\inlinemath #1{\dontleavehmode\ifmmode#1\else\normalstartimath#1\normalstopimath\fi} +%permanent\protected\def\displaymath#1{\noindent \ifmmode#1\else\normalstartdmath#1\normalstopdmath\fi} +%permanent\protected\def\inlinemath #1{\dontleavehmode\ifmmode#1\else\normalstartimath#1\normalstopimath\fi} \permanent\protected\def\textmath #1{\dontleavehmode\ifmmode#1\else\begingroup\everymath\emptytoks\normalstartimath#1\normalstopimath\endgroup\fi} % \mathsurround\zeropoint \aliased\let\stopmathmode\relax @@ -93,17 +93,23 @@ %D \macros %D {displaymathematics,inlinemathematics,automathematics} %D -%D An example of usage of the following can be found in the MathML module: +%D We no longer support native displaymath, which is no big deal because already +%D for many years we abandoned it. We therefore also default differently now. We +%D signal \LUAMETATEX\ that the double dollar mode actually has to be inline +%D display math anyway. \ifdefined\strc_formulas_start_formula \else - \def\strc_formulas_start_formula{\normalstartdmath} - \def\strc_formulas_stop_formula {\normalstopdmath } + \def\strc_formulas_start_formula{\normalstartdmath} + \def\strc_formulas_stop_formula {\normalstopdmath } \fi \permanent\protected\def\displaymathematics#1{\relax\ifmmode#1\else\strc_formulas_start_formula{}#1\strc_formulas_stop_formula\fi} \permanent\protected\def\inlinemathematics {\dontleavehmode\mathematics} %permanent\protected\def\automathematics {\relax\ifhmode\expandafter\inlinemathematics\else\expandafter\displaymathematics\fi} +\aliased\let\displaymath\displaymathematics % we no longer support native displaymath +\aliased\let\inlinemath \inlinemathematics % we no longer support native displaymath + % better, esp when used in bTABLE ... eTABLE \permanent\protected\def\automathematics diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index 3c327c047..d94579548 100644 --- a/tex/context/base/mkxl/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -508,6 +508,7 @@ \newdimen\scratchwidth \newdimen\scratchheight \newdimen\scratchdepth +\newdimen\scratchitalic \newdimen\scratchtotal \newdimen\scratchoffset @@ -567,7 +568,13 @@ \immutable\dimensiondef \scaledpoint 1sp \immutable\dimensiondef \thousandpoint 1000pt -\immutable\gluespecdef \zeroskip 0pt plus 0pt minus 0pt +\immutable\gluespecdef \zeroskip \zeropoint plus \zeropoint minus \zeropoint +\immutable\gluespecdef \centeringskip \zeropoint plus \thousandpoint minus \thousandpoint +\immutable\gluespecdef \stretchingskip \zeropoint plus \thousandpoint +\immutable\gluespecdef \shrinkingskip \zeropoint minus \thousandpoint +\immutable\gluespecdef \centeringfillskip \zeropoint plus 1fill minus 1fill +\immutable\gluespecdef \stretchingfillskip \zeropoint plus 1fill +\immutable\gluespecdef \shrinkingfillskip \zeropoint minus 1fill \immutable\mugluespecdef \zeromuskip 0mu \immutable\mugluespecdef \onemuskip 1mu @@ -1147,16 +1154,16 @@ %D Again a few kind-of-extensions the core. These come from plain \TEX\ but are %D probably not used in \CONTEXT. -\newskip \hideskip \hideskip = -1000pt plus 1fill -\newskip \centering \centering = 0pt plus 1000pt minus 1000pt +\newskip \hideskip \hideskip = -1000pt plus 1fill % obsolete +\newskip \centering \centering = 0pt plus 1000pt minus 1000pt % obsolete -\permanent\def\hidewidth % for alignment entries that can stick out - {\hskip\hideskip} - -\permanent\def\ialign % initialized \halign, to be used grouped! - {\everycr\emptytoks - \tabskip\zeroskip - \halign} +% \permanent\def\hidewidth % for alignment entries that can stick out +% {\hskip\hideskip} +% +% \permanent\def\ialign % initialized \halign, to be used grouped! +% {\everycr\emptytoks +% \tabskip\zeroskip +% \halign} \newcount \mscount @@ -1249,10 +1256,6 @@ \immutable\integerdef\eTeXversion 2 \immutable\def \eTeXrevision {2} -%D Experiment: - -\glyphoptions"80 % replaces \glyphdimensionsmode=1 - %D Just in case users use this (or some styles still have it): \aliased\let\immediateassignment\immediate diff --git a/tex/context/base/mkxl/tabl-ntb.mkxl b/tex/context/base/mkxl/tabl-ntb.mkxl index 644d156e6..33e68a4cb 100644 --- a/tex/context/base/mkxl/tabl-ntb.mkxl +++ b/tex/context/base/mkxl/tabl-ntb.mkxl @@ -372,6 +372,8 @@ \def\tabl_ntb_get_dis#1{\ifcsname\??naturaltabledis\m_tabl_tbl_level:\number#1\endcsname\lastnamedcs\else\zeropoint\fi} \def\tabl_ntb_get_aut#1{\csname \??naturaltableaut\m_tabl_tbl_level:\number#1\endcsname} +% \i ntegerdef + \def\tabl_ntb_let_bck#1#2{\global\expandafter\chardef\csname\??naturaltablebck\m_tabl_tbl_level:\number#1:\number#2\endcsname} \def\tabl_ntb_get_bck#1#2{\csname\??naturaltablebck\m_tabl_tbl_level:\number#1:\number#2\endcsname} diff --git a/tex/context/base/mkxl/tabl-tab.mkxl b/tex/context/base/mkxl/tabl-tab.mkxl index 01e665d02..d8a71943c 100644 --- a/tex/context/base/mkxl/tabl-tab.mkxl +++ b/tex/context/base/mkxl/tabl-tab.mkxl @@ -259,9 +259,9 @@ \def\!tfComputeMinColWidth {\setbox\scratchbox\vbox - {\ialign{% Plain's initialized \halign; \tabskip=0pt \everycr={} - \span\the\!taDataColumnTemplate\cr - \!tfWidthText\cr}}% + {\everycr\emptytoks + \tabskip\zeroskip + \halign{\span\the\!taDataColumnTemplate\cr\!tfWidthText\cr}}% \!taMinimumColumnWidth\wd\scratchbox} \def\!tfFinishFormat @@ -298,7 +298,11 @@ \def\!tfReFormat#1% {\the \!taLeftGlue - \vbox{\forgetall\ialign{\span\the\!taDataColumnTemplate\cr#1\cr}}% + \vbox + {\forgetall + \everycr\emptytoks + \tabskip\zeroskip + \halign{\span\the\!taDataColumnTemplate\cr#1\cr}}% \the \!taRightGlue \kern\zeropoint} % prevents \unskip / really needed diff --git a/tex/context/base/mkxl/tabl-tbl.mkxl b/tex/context/base/mkxl/tabl-tbl.mkxl index cd3d3d02d..ac2eae49f 100644 --- a/tex/context/base/mkxl/tabl-tbl.mkxl +++ b/tex/context/base/mkxl/tabl-tbl.mkxl @@ -1968,7 +1968,7 @@ % % can we omit the next one in the first run? probably % \noalign{\the\t_tabl_tabulate_every_after_row#2}} -\permanent\protected\def\tabl_tabulate_NR_common#1#2#.#3% #. gobbles pars and spaces +\permanent\tolerant\protected\def\tabl_tabulate_NR_common#1#2#.#3% #. gobbles pars and spaces {\global\advance\c_tabl_tabulate_noflines\plusone \global\setfalse\c_tabl_tabulate_firstflushed \global\setfalse\c_tabl_tabulate_equal diff --git a/tex/context/base/mkxl/tabl-xtb.lmt b/tex/context/base/mkxl/tabl-xtb.lmt index 32770141b..3d91ccb85 100644 --- a/tex/context/base/mkxl/tabl-xtb.lmt +++ b/tex/context/base/mkxl/tabl-xtb.lmt @@ -1266,7 +1266,7 @@ implement { } } -implement { name = "x_table_reflow_width", actions = xtables.reflow_width } +implement { name = "x_table_reflow_width", actions = xtables.reflow_width } implement { name = "x_table_reflow_height", actions = xtables.reflow_height } implement { name = "x_table_construct", actions = xtables.construct } implement { name = "x_table_cleanup", actions = xtables.cleanup } diff --git a/tex/context/base/mkxl/task-ini.lmt b/tex/context/base/mkxl/task-ini.lmt index 8a4d492e0..fcaad17e3 100644 --- a/tex/context/base/mkxl/task-ini.lmt +++ b/tex/context/base/mkxl/task-ini.lmt @@ -119,7 +119,7 @@ appendaction("math", "normalizers", "noads.handlers.classes", appendaction("math", "builders", "builders.kernel.mlisttohlist", nil, "nut", "enabled" ) -- mandate appendaction("math", "builders", "typesetters.directions.processmath", nil, "nut", "disabled" ) appendaction("math", "builders", "noads.handlers.makeup", nil, "nonut", "disabled" ) -appendaction("math", "builders", "noads.handlers.align", nil, "nonut", "enabled" ) +------------("math", "builders", "noads.handlers.align", nil, "nonut", "enabled" ) appendaction("math", "finalizers", "noads.handlers.normalize", nil, "nonut", "enabled" ) appendaction("math", "finalizers", "noads.handlers.snap", nil, "nonut", "disabled" ) @@ -159,7 +159,9 @@ appendaction("vboxhandlers", "normalizers", "nodes.adaptive.handlevertical", appendaction("everypar", "normalizers", "nodes.handlers.checkparcounter", nil, "nut", "disabled" ) +appendaction("alignments", "normalizers", "nodes.handlers.showpreamble", nil, "nut", "enabled" ) appendaction("alignments", "normalizers", "nodes.handlers.aligncharacter", nil, "nut", "disabled" ) +appendaction("alignments", "normalizers", "nodes.handlers.fixmathalign", nil, "nut", "enabled" ) -- maybe delay appendaction("localboxes", "lists", "typesetters.localboxes.handler", nil, "nut", "enabled" ) diff --git a/tex/context/base/mkxl/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt index 9377bad42..c152afb36 100644 --- a/tex/context/base/mkxl/toks-aux.lmt +++ b/tex/context/base/mkxl/toks-aux.lmt @@ -157,7 +157,7 @@ local function getthem(getter,post) for k, v in next, getter() do codes[k] = gsub(v,"[_ ]","") end - if post ~= "" then + if post and post ~= "" then if environment.initex then for k, v in next, codes do texintegerdef(v .. post,k,"immutable") @@ -176,23 +176,25 @@ local function getthem(getter,post) return utilities.storage.allocate(table.swapped(codes,codes)) end -tex.discoptioncodes = getthem(tex.getdiscoptionvalues, "discoptioncode") -tex.flagcodes = getthem(tex.getflagvalues, "flagcode" ) -tex.frozenparcodes = getthem(tex.getfrozenparvalues, "frozenparcode") -tex.glyphoptioncodes = getthem(tex.getglyphoptionvalues, "glyphoptioncode") -tex.groupcodes = getthem(tex.getgroupvalues, "groupcode") -tex.hyphenationcodes = getthem(tex.gethyphenationvalues, "hyphenationcode") -tex.mathcontrolcodes = getthem(tex.getmathcontrolvalues, "mathcontrolcode") ----.mathflattencodes = getthem(tex.getmathflattenvalues, "mathflattencode") -tex.noadoptioncodes = getthem(tex.getnoadoptionvalues, "") -- only at lua end -tex.normalizelinecodes = getthem(tex.getnormalizelinevalues, "normalizecode") -- we keep the short name -tex.normalizeparcodes = getthem(tex.getnormalizeparvalues, "normalizeparcode") -tex.automigrationcodes = getthem(tex.getautomigrationvalues, "automigrationcode") -- only at lua end -tex.parcontextcodes = getthem(tex.getparcontextvalues, "parcontextcode") -tex.textcontrolcodes = getthem(tex.gettextcontrolvalues, "") -- only at lua end -tex.listanchorcodes = getthem(tex.getlistanchorvalues, "listanchorcode") -tex.listsigncodes = getthem(tex.getlistsignvalues, "listsigncode") -tex.classoptioncodes = getthem(tex.getmathclassoptionvalues, "classoptioncode") +tex.discoptioncodes = getthem(tex.getdiscoptionvalues, "discoptioncode") +tex.flagcodes = getthem(tex.getflagvalues, "flagcode" ) +tex.frozenparcodes = getthem(tex.getfrozenparvalues, "frozenparcode") +tex.glyphoptioncodes = getthem(tex.getglyphoptionvalues, "glyphoptioncode") +tex.groupcodes = getthem(tex.getgroupvalues, "groupcode") +tex.hyphenationcodes = getthem(tex.gethyphenationvalues, "hyphenationcode") +tex.mathcontrolcodes = getthem(tex.getmathcontrolvalues, "mathcontrolcode") +---.mathflattencodes = getthem(tex.getmathflattenvalues, "mathflattencode") +tex.noadoptioncodes = getthem(tex.getnoadoptionvalues ) -- only at lua end +tex.normalizelinecodes = getthem(tex.getnormalizelinevalues, "normalizecode") -- we keep the short name +tex.normalizeparcodes = getthem(tex.getnormalizeparvalues, "normalizeparcode") +tex.automigrationcodes = getthem(tex.getautomigrationvalues, "automigrationcode") +tex.parcontextcodes = getthem(tex.getparcontextvalues, "parcontextcode") +tex.textcontrolcodes = getthem(tex.gettextcontrolvalues ) -- only at lua end +tex.listanchorcodes = getthem(tex.getlistanchorvalues, "listanchorcode") +tex.listsigncodes = getthem(tex.getlistsignvalues, "listsigncode") +tex.classoptioncodes = getthem(tex.getmathclassoptionvalues, "classoptioncode") +---.alignmentcontextcodes = getthem(tex.getalignmentcontextvalues ) -- only at lua end +tex.specialmathclasscodes = getthem(tex.getspecialmathclassvalues ) -- only at lua end function tex.stringtocodesbitmap(str,codes) local bitmap = 0 diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index d277095a3..ca6b98fc1 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -58,6 +58,7 @@ local getexpansion = nuts.getexpansion local getstate = nuts.getstate local getoffsets = nuts.getoffsets local getindex = nuts.getindex +local getprop = nuts.getprop local isglyph = nuts.isglyph @@ -137,10 +138,10 @@ local modes = { space = 0x0040000, depth = 0x0080000, marginkern = 0x0100000, - mathkern = 0x0200000, + mathkern = 0x0200000, -- dir = 0x0400000, par = 0x0800000, - mathglue = 0x1000000, + mathglue = 0x1000000, -- mark = 0x2000000, insert = 0x4000000, boundary = 0x8000000, @@ -375,7 +376,6 @@ for mode, value in next, modes do end local fraction = 10 -local normalize = true trackers .register("visualizers.reset", function(v) set("reset", v) end) trackers .register("visualizers.all", function(v) set("all", v) end) @@ -1026,6 +1026,8 @@ local ruledglue, ruledmathglue do local righthangskip_code = gluecodes.righthangskip local parfillleftskip_code = gluecodes.parfillleftskip or parfillskip_code local parfillrightskip_code = gluecodes.parfillrightskip or parfillskip_code + local parinitleftskip_code = gluecodes.parinitleftskip + local parinitrightskip_code = gluecodes.parinitrightskip local indentskip_code = gluecodes.indentskip local intermathskip_code = gluecodes.intermathskip local correctionskip_code = gluecodes.correctionskip @@ -1033,16 +1035,10 @@ local ruledglue, ruledmathglue do local g_cache_v = caches["vglue"] local g_cache_h = caches["hglue"] - local g_cache_ls = caches["leftskip"] - local g_cache_rs = caches["rightskip"] - local g_cache_lh = caches["lefthang"] - local g_cache_rh = caches["righthang"] - local g_cache_lp = caches["parfillleftskip"] - local g_cache_rp = caches["parfillrightskip"] - local g_cache_is = caches["indentskip"] - local g_cache_cs = caches["correctionskip"] + local g_cache_gn = caches["gluename"] local g_cache_gz = caches["gluezero"] + local g_cache_gf = caches["gluefixed"] local tags = { -- [userskip_code] = "US", @@ -1077,8 +1073,8 @@ local ruledglue, ruledmathglue do [zerospaceskip_code] = "ZS", [parfillleftskip_code] = "PL", [parfillrightskip_code] = "PR", - [gluecodes.parinitleftskip] = "IL", - [gluecodes.parinitrightskip] = "IR", + [parinitleftskip_code] = "IL", + [parinitrightskip_code] = "IR", [indentskip_code] = "IN", [correctionskip_code] = "CS", } @@ -1088,72 +1084,84 @@ local ruledglue, ruledmathglue do [righthangskip_code] = 0.5, [leftskip_code] = -2, [rightskip_code] = -2, + [parinitleftskip_code] = -1.3775, + [parinitrightskip_code] = -1.3775, [parfillleftskip_code] = -0.75, [parfillrightskip_code] = -0.75, } - -- we sometimes pass previous as we can have issues in math (not watertight for all) - - local f_amount = formatters["%s:%0.3f"] - local mathvalues = nodes.mathvalues - - mathvalues[-1] = "left" - mathvalues[-2] = "right" - - local morehack = setmetatableindex(function(t,k) - local v = mathematics.classnames[k] -- yet unknown --- v = v and string.sub(v,1,4) or string.formatters["x%02x"](k) - v = v and string.sub(v,1,3) or string.formatters["x%02x"](k) - t[k] = v - return v - end) - - local temphack = setmetatableindex(function(t,k) - local v = mathvalues[k] - if v then - v = gsub(v,"spacing","") -- old - else - v = k - 256 - v = morehack[v//64] ..morehack[v%64] - end - t[k] = v - return v - end) - - local function gluename(current,layer,color) - local name = getfont(current) - local zero = iszeroglue(current) - local info = zero and g_cache_gz[name] or g_cache_gn[name] - if not info then - local text = hpack_string(temphack[name],usedfont) - local rule = new_rule(emwidth/fraction,2*exheight,(zero and 4.25 or 2.75)*exheight) - local list = getlist(text) - setlisttransparency(list,color) - settransparency(rule,color) - setshift(text,(zero and 3.5 or 2)*exheight) - info = new_hlist(setlink(rule,text)) - setattr(info,a_layer,layer) - g_cache_gn[name] = info - end - return copylist(info) - end - - ruledmathglue = function(head,current) - return insertnodebefore(head,current,gluename(current,l_glue,"trace:m")) - end + local f_amount = formatters["%s:%0.3f"] + +-- ruledglue = function(head,current,vertical,parent) +-- local subtype = getsubtype(current) +-- local width = effectiveglue(current,parent) +-- local stag = stags[subtype] +-- local amount = f_amount(tags[subtype] or (vertical and "VS") or "HS",width*pt_factor) -- can be sped up +-- local info = (vertical and g_cache_v or g_cache_h)[amount] +-- if subtype == intermathskip_code then +-- head = ruledmathglue(head, current) +-- end +-- if info then +-- -- print("glue hit") +-- else +-- if subtype == spaceskip_code or subtype == xspaceskip_code or subtype == zerospaceskip_code then +-- info = sometext(amount,l_glue,"trace:y") +-- elseif subtype == userskip_code then +-- if width > 0 then +-- info = sometext(amount,l_glue,"trace:b") +-- elseif width < 0 then +-- info = sometext(amount,l_glue,"trace:r") +-- else +-- info = sometext(amount,l_glue,"trace:g") +-- end +-- elseif subtype == tabskip_code then +-- info = sometext(amount,l_glue,"trace:s") +-- elseif subtype == indentskip_code or subtype == correctionskip_code then +-- info = sometext(amount,l_glue,"trace:s") +-- elseif subtype == leftskip_code then +-- info = sometext(amount,l_glue,"trace:y",false,true,stag) +-- elseif subtype == rightskip_code then +-- info = sometext(amount,l_glue,"trace:y",false,false,stag) +-- elseif subtype == lefthangskip_code then +-- info = sometext(amount,l_glue,"trace:y",false,true,stag) +-- elseif subtype == righthangskip_code then +-- info = sometext(amount,l_glue,"trace:y",false,false,stag) +-- elseif subtype == parfillleftskip_code then +-- info = sometext(amount,l_glue,"trace:s",false,true,stag) +-- elseif subtype == parfillrightskip_code then +-- info = sometext(amount,l_glue,"trace:s",false,false,stag) +-- elseif subtype == parinitleftskip_code then +-- info = sometext(amount,l_glue,"trace:s",false,true,stag) +-- elseif subtype == parinitrightskip_code then +-- info = sometext(amount,l_glue,"trace:s",false,false,stag) +-- else +-- info = sometext(amount,l_glue,"trace:m") +-- end +-- (vertical and g_cache_v or g_cache_h)[amount] = info +-- end +-- info = copylist(info) +-- if vertical then +-- info = vpack_nodes(info) +-- end +-- head, current = insertnodebefore(head,current,info) +-- return head, getnext(current) +-- end + + local g_caches = { } for k, v in next, tags do g_caches[k] = caches[v] end ruledglue = function(head,current,vertical,parent) local subtype = getsubtype(current) local width = effectiveglue(current,parent) - local stag = normalize and stags[subtype] - local amount = f_amount(tags[subtype] or (vertical and "VS") or "HS",width*pt_factor) -- can be sped up - local info = (vertical and g_cache_v or g_cache_h)[amount] + local stag = stags[subtype] + local cache = g_caches[subtype] or (vertical and g_cache_v) or g_cache_h + local info = cache[amount] if subtype == intermathskip_code then head = ruledmathglue(head, current) end if info then -- print("glue hit") else + local amount = f_amount(tags[subtype] or (vertical and "VS") or "HS",width*pt_factor) if subtype == spaceskip_code or subtype == xspaceskip_code or subtype == zerospaceskip_code then info = sometext(amount,l_glue,"trace:y") elseif subtype == userskip_code then @@ -1169,21 +1177,25 @@ local ruledglue, ruledmathglue do elseif subtype == indentskip_code or subtype == correctionskip_code then info = sometext(amount,l_glue,"trace:s") elseif subtype == leftskip_code then - info = sometext(amount,l_glue,normalize and "trace:y" or "trace:c",false,true,stag) + info = sometext(amount,l_glue,"trace:y",false,true,stag) elseif subtype == rightskip_code then - info = sometext(amount,l_glue,normalize and "trace:y" or "trace:c",false,false,stag) + info = sometext(amount,l_glue,"trace:y",false,false,stag) elseif subtype == lefthangskip_code then - info = sometext(amount,l_glue,normalize and "trace:y" or "trace:m",false,true,stag) + info = sometext(amount,l_glue,"trace:y",false,true,stag) elseif subtype == righthangskip_code then - info = sometext(amount,l_glue,normalize and "trace:y" or "trace:m",false,false,stag) + info = sometext(amount,l_glue,"trace:y",false,false,stag) elseif subtype == parfillleftskip_code then info = sometext(amount,l_glue,"trace:s",false,true,stag) elseif subtype == parfillrightskip_code then info = sometext(amount,l_glue,"trace:s",false,false,stag) + elseif subtype == parinitleftskip_code then + info = sometext(amount,l_glue,"trace:s",false,true,stag) + elseif subtype == parinitrightskip_code then + info = sometext(amount,l_glue,"trace:s",false,false,stag) else info = sometext(amount,l_glue,"trace:m") end - (vertical and g_cache_v or g_cache_h)[amount] = info + cache[amount] = info end info = copylist(info) if vertical then @@ -1218,6 +1230,78 @@ local ruledglue, ruledmathglue do return head, getnext(current) end + -- we sometimes pass previous as we can have issues in math (not watertight for all) + + local mathvalues = nodes.mathvalues + + mathvalues[-1] = "left" + mathvalues[-2] = "right" + + local morehack = setmetatableindex(function(t,k) + local v = mathematics.classnames[k] -- yet unknown + v = v and string.sub(v,1,3) or string.formatters["x%02x"](k) + t[k] = v + return v + end) + + local temphack = setmetatableindex(function(t,k) + local v = mathvalues[k] + if v then + v = gsub(v,"spacing","") -- old, quads and so + else + v = k - 256 + v = morehack[v//64] .. morehack[v%64] + end + t[k] = v + return v + end) + + local g_cache_qd = caches["mathquad"] + + ruledmathglue = function(head,current,parent) + local name = getfont(current) + local zero = iszeroglue(current) + local fixed = getprop(current,"fixedmathalign") + local color = false + local info = zero and g_cache_gz[name] + local quad = name == 0 + local width = quad and effectiveglue(current,parent) + if not info then + if quad then + info = g_cache_qd[width] + color = "trace:z" + elseif fixed then + info = g_cache_gf[name] + color = "trace:dr" + else + info = g_cache_gn[name] + color = "trace:z" + end + end + if not info then + local amount = quad and f_amount("QUAD",width*pt_factor) or temphack[name] + -- local amount = quad and f_amount("QD",width*pt_factor) or temphack[name] + local text = hpack_string(amount,usedfont) + local rule = new_rule(emwidth/fraction,2*exheight,(zero and 4.25 or 2.75)*exheight) + local list = getlist(text) + setlistcolor(list,color) + setcolor(rule,color) + setlisttransparency(list,color) + settransparency(rule,color) + setshift(text,(zero and 3.5 or 2)*exheight) + info = new_hlist(setlink(rule,text)) + setattr(info,a_layer,l_glue) + if quad then + g_cache_qd[width] = info + elseif fixed then + g_cache_gf[name] = info + else + g_cache_gn[name] = info + end + end + return insertnodebefore(head,current,copylist(info)) + end + end local ruledkern do @@ -1373,32 +1457,41 @@ local ruledpenalty do local p_cache_v = caches["vpenalty"] local p_cache_h = caches["hpenalty"] + local p_cache_m = caches["mpenalty"] local raisepenalties = false - local getpenalty = nuts.getpenalty + local getpenalty = nuts.getpenalty + local pre_penalty_code = nodes.penaltycodes.mathprepenalty + local post_penalty_code = nodes.penaltycodes.mathpostpenalty directives.register("visualizers.raisepenalties",function(v) raisepenalties = v end) - ruledpenalty = function(head,current,vertical) + ruledpenalty = function(head,current,vertical,subtype) local penalty = getpenalty(current) - local info = (vertical and p_cache_v or p_cache_h)[penalty] + local ismath = subtype == pre_penalty_code or subtype == post_penalty_code + local cache = (ismath and p_cache_m) or (vertical and p_cache_v) or p_cache_h + local info = cache[penalty] if info then -- print("penalty hit") else - local amount = formatters["%s:%s"](vertical and "VP" or "HP",penalty) - if penalty > 0 then + local amount = formatters["%s:%s"]((ismath and "MP") or (vertical and "VP") or "HP",penalty) + if ismath then + info = sometext(amount,l_penalty,"trace:s") + elseif penalty > 0 then info = sometext(amount,l_penalty,"trace:b") elseif penalty < 0 then info = sometext(amount,l_penalty,"trace:r") else info = sometext(amount,l_penalty,"trace:g") end - (vertical and p_cache_v or p_cache_h)[penalty] = info + cache[penalty] = info end info = copylist(info) if vertical then info = vpack_nodes(info) + elseif ismath then + setshift(info, 65536*4) elseif raisepenalties then setshift(info,-65536*4) end @@ -1446,6 +1539,7 @@ do local listcodes = nodes.listcodes local linelist_code = listcodes.line + local rowlist_code = listcodes.alignment local vtop_package_state = 3 -- todo: symbolic @@ -1602,7 +1696,8 @@ do goto glue elseif id == penalty_code then if trace_penalty then - head, current = ruledpenalty(head,current,vertical) + subtype = getsubtype(current) + head, current = ruledpenalty(head,current,vertical,subtype) end elseif id == hlist_code or id == vlist_code then goto list @@ -1716,7 +1811,7 @@ do if trace_depth then ruleddepth(current) end - if trace_line and getsubtype(current) == linelist_code then + if trace_line and (getsubtype(current) == linelist_code or getsubtype(current) == rowlist_code) then head, current = ruledbox(head,current,false,l_line,"L__",trace_simple,previous,trace_origin,parent) elseif trace_hbox then head, current = ruledbox(head,current,false,l_hbox,"H__",trace_simple,previous,trace_origin,parent) diff --git a/tex/context/base/mkxl/type-set.mkxl b/tex/context/base/mkxl/type-set.mkxl index adbd9a17a..8a11888e5 100644 --- a/tex/context/base/mkxl/type-set.mkxl +++ b/tex/context/base/mkxl/type-set.mkxl @@ -61,6 +61,7 @@ \definefilesynonym [type-imp-latin-modern.mkiv] [type-imp-latinmodern.mkiv] \definefilesynonym [type-imp-modern-latin.mkiv] [type-imp-modernlatin.mkiv] +\definefilesynonym [type-imp-less-modern-latin.mkiv] [type-imp-modernlatin.mkiv] \definefilesynonym [type-imp-lucida.mkiv] [type-imp-lucida-typeone.mkiv] \definefilesynonym [type-imp-lucidaot.mkiv] [type-imp-lucida-opentype.mkiv] @@ -142,4 +143,7 @@ \definefilesynonym [type-imp-kpfonts-bold.mkiv] [type-imp-kpfonts.mkiv] \definefilesynonym [type-imp-kpfonts-sans.mkiv] [type-imp-kpfonts.mkiv] +\definefilesynonym [type-imp-gentiumplus.mkiv] [type-imp-gentium.mkiv] +\definefilesynonym [type-imp-gentiumbook.mkiv] [type-imp-gentium.mkiv] + \protect \endinput diff --git a/tex/context/base/mkxl/typo-bld.lmt b/tex/context/base/mkxl/typo-bld.lmt index 1a581e118..0920eeafd 100644 --- a/tex/context/base/mkxl/typo-bld.lmt +++ b/tex/context/base/mkxl/typo-bld.lmt @@ -188,7 +188,7 @@ end function constructors.enable () enabled = true end function constructors.disable() enabled = false end -registercallback('linebreak_filter', processor, "breaking paragraps into lines") +registercallback("linebreak_filter", processor, "breaking paragraps into lines") statistics.register("linebreak processing time", function() return statistics.elapsedseconds(parbuilders) @@ -356,7 +356,7 @@ local function hpack_quality(how,detail,n,first,last,filename) setcolor(rule,"cyan") end rule = hpack(rule) - setwidth(rule,0) + setwidth(rule,0) -- maybe better whd all zero setdirection(rule,direction) return tonode(rule) -- can be a nut end diff --git a/tex/context/base/mkxl/typo-lbx.lmt b/tex/context/base/mkxl/typo-lbx.lmt index 5517f3c2f..ac67959d6 100644 --- a/tex/context/base/mkxl/typo-lbx.lmt +++ b/tex/context/base/mkxl/typo-lbx.lmt @@ -217,7 +217,7 @@ do lb_parinitrightskip = parinitrightskip lb_overshoot = overshoot lb_linewidth = getwidth(line) - -- only true for soem cases + -- only true for some cases lb_leftoffset = leftskip + lefthang + parfillleftskip + parinitleftskip + indent lb_rightoffset = rightskip + righthang + parfillrightskip + parinitrightskip - overshoot -- |