diff options
author | Hans Hagen <pragma@wxs.nl> | 2012-01-25 13:09:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2012-01-25 13:09:00 +0100 |
commit | 71b6d9367123e33b454886654c24177be3d64880 (patch) | |
tree | edcda6f3cd4ea1de2b89a273439fa75b40b65f4b /tex | |
parent | 97af40831e32337e13acae3b562782a8f6a8e79b (diff) | |
download | context-71b6d9367123e33b454886654c24177be3d64880.tar.gz |
beta 2012.01.25 13:09
Diffstat (limited to 'tex')
35 files changed, 761 insertions, 887 deletions
diff --git a/tex/context/base/attr-ini.lua b/tex/context/base/attr-ini.lua index c382302f0..f3714fcb4 100644 --- a/tex/context/base/attr-ini.lua +++ b/tex/context/base/attr-ini.lua @@ -32,6 +32,9 @@ storage.register("attributes/names", names, "attributes.names") storage.register("attributes/numbers", numbers, "attributes.numbers") storage.register("attributes/list", list, "attributes.list") +names [0] = "fontdynamic" +numbers["fontdynamic"] = 0 + function attributes.define(name,number) -- at the tex end if not numbers[name] then numbers[name] = number @@ -87,21 +90,33 @@ end -- new (actually a tracer) -function attributes.ofnode(n) - local a = n.attr - if a then - a = a.next +local report_attribute = logs.reporter("attributes") + +local function showlist(what,list) + if list then + local a = list.next + local i = 0 while a do local number, value = a.number, a.value - texio.write_nl(format("%s : attribute %3i, value %4i, name %s",tostring(n),number,value,names[number] or '?')) + i = i + 1 + report_attribute("%s %2i: attribute %3i, value %4i, name %s",tostring(what),i,number,value,names[number] or '?') a = a.next end end end +function attributes.showcurrent() + showlist("current",node.current_attr()) +end + +function attributes.ofnode(n) + showlist(n,n.attr) +end + -- interface commands.defineattribute = attributes.define +commands.showattributes = attributes.showcurrent function commands.getprivateattribute(name) context(attributes.private(name)) diff --git a/tex/context/base/attr-ini.mkiv b/tex/context/base/attr-ini.mkiv index 842a25a4f..a1550b4be 100644 --- a/tex/context/base/attr-ini.mkiv +++ b/tex/context/base/attr-ini.mkiv @@ -21,16 +21,20 @@ \registerctxluafile{attr-ini}{1.001} +\installcorenamespace{attributecount} % the counter representing the attribute (attrdef'd) +\installcorenamespace{attributeid} % the internal number +\installcorenamespace{attributestack} % the attribute specific stack + \unexpanded\def\pushattribute#1% - {\global\advance\csname\??ae:\string#1\endcsname\plusone - \global\expandafter\mathchardef\csname\??ae:\string#1:\number\csname\??ae:\string#1\endcsname\endcsname\attribute#1} + {\global\advance\csname\??attributestack\string#1\endcsname\plusone + \global\expandafter\mathchardef\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname\attribute#1} \unexpanded\def\popattribute#1% - {\attribute#1\csname\??ae:\string#1:\number\csname\??ae:\string#1\endcsname\endcsname - \global\advance\csname\??ae:\string#1\endcsname\minusone} + {\attribute#1\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname + \global\advance\csname\??attributestack\string#1\endcsname\minusone} \unexpanded\def\installattributestack#1% - {\expandafter\newcount\csname\??ae:\string#1\endcsname} + {\expandafter\newcount\csname\??attributestack\string#1\endcsname} \newtoks \attributesresetlist @@ -41,31 +45,31 @@ {\dodoubleempty\attr_basics_define} \def\attr_basics_define[#1][#2]% alternatively we can let lua do the housekeeping - {\expandafter\newattribute\csname\??ae:a:#1\endcsname - \expandafter\newconstant \csname\??ae:c:#1\endcsname - \csname\??ae:c:#1\endcsname\c_syst_last_allocated_attribute + {\expandafter\newattribute\csname\??attributecount#1\endcsname + \expandafter\newconstant \csname\??attributeid#1\endcsname + \csname\??attributeid#1\endcsname\c_syst_last_allocated_attribute \ctxcommand{defineattribute("#1",\number\c_syst_last_allocated_attribute)}% - \doifnotinset\s!global{#2}{\appendetoks\csname\??ae:a:#1\endcsname\attributeunsetvalue\to\attributesresetlist}% - \doifinset \s!public{#2}{\expandafter\let\csname#1attribute\expandafter\endcsname\csname\??ae:c:#1\endcsname}} + \doifnotinset\s!global{#2}{\appendetoks\csname\??attributecount#1\endcsname\attributeunsetvalue\to\attributesresetlist}% + \doifinset \s!public{#2}{\expandafter\let\csname#1attribute\expandafter\endcsname\csname\??attributeid#1\endcsname}} \unexpanded\def\definesystemattribute {\dodoubleempty\attr_basics_define_system} \def\attr_basics_define_system[#1][#2]% alternatively we can let lua do the housekeeping {\scratchcounter\ctxcommand{getprivateattribute("#1")}\relax - \expandafter\attributedef\csname\??ae:a:#1\endcsname\scratchcounter - \expandafter\newconstant \csname\??ae:c:#1\endcsname - \csname\??ae:c:#1\endcsname\scratchcounter + \expandafter\attributedef\csname\??attributecount#1\endcsname\scratchcounter + \expandafter\newconstant \csname\??attributeid#1\endcsname + \csname\??attributeid#1\endcsname\scratchcounter %\writestatus\m!system{defining system attribute #1 with number \number\scratchcounter}% - \doifnotinset\s!global{#2}{\appendetoks\csname\??ae:a:#1\endcsname\attributeunsetvalue\to\attributesresetlist}% - \doifinset \s!public{#2}{\expandafter\let\csname#1attribute\expandafter\endcsname\csname\??ae:c:#1\endcsname}} + \doifnotinset\s!global{#2}{\appendetoks\csname\??attributecount#1\endcsname\attributeunsetvalue\to\attributesresetlist}% + \doifinset \s!public{#2}{\expandafter\let\csname#1attribute\expandafter\endcsname\csname\??attributeid#1\endcsname}} % expandable so we can \edef them for speed -\def\dosetattribute#1#2{\csname\??ae:a:#1\endcsname#2\relax} -\def\doresetattribute#1{\csname\??ae:a:#1\endcsname\attributeunsetvalue} -\def\dogetattribute #1{\number\csname\??ae:a:#1\endcsname} -\def\dogetattributeid#1{\number\csname\??ae:c:#1\endcsname} +\def\dosetattribute#1#2{\csname\??attributecount#1\endcsname#2\relax} +\def\doresetattribute#1{\csname\??attributecount#1\endcsname\attributeunsetvalue} +\def\dogetattribute #1{\number\csname\??attributecount#1\endcsname} +\def\dogetattributeid#1{\number\csname\??attributeid#1\endcsname} \let\dompattribute\gobbletwoarguments @@ -96,4 +100,6 @@ \definesystemattribute [ruled] [public] \definesystemattribute [shifted] [public] +\unexpanded\def\showattributes{\ctxcommand{showattributes()}} + \protect \endinput diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua index 7ca6f4f70..4757735e8 100644 --- a/tex/context/base/char-def.lua +++ b/tex/context/base/char-def.lua @@ -603,8 +603,16 @@ characters.data={ description="EQUALS SIGN", direction="on", linebreak="al", - mathclass="relation", - mathname="eq", + mathspec={ + { + class="relation", + name="eq", + }, + { + class="relation", + name="Relbar", + }, + }, unicodeslot=0x003D, }, { @@ -56608,8 +56616,16 @@ characters.data={ description="HORIZONTAL ELLIPSIS", direction="on", linebreak="in", - mathclass="inner", - mathname="ldots", + mathspec={ + { + class="inner", + name="ldots", + }, + { + class="inner", + name="dots", + } + }, specials={ "compat", 0x002E, 0x002E, 0x002E }, unicodeslot=0x2026, }, @@ -60500,8 +60516,16 @@ characters.data={ description="NOT AN ELEMENT OF", direction="on", linebreak="al", - mathclass="relation", - mathname="nin", + mathspec={ + { + class="relation", + name="notin", + }, + { + class="relation", + name="nin", + }, + }, mirror=0x220C, specials={ "char", 0x2208, 0x0338 }, unicodeslot=0x2209, @@ -60606,7 +60630,16 @@ characters.data={ description="MINUS SIGN", direction="es", linebreak="pr", - mathclass="binary", + mathspec={ + { + class="binary", + name="minus", + }, + { + class="relation", + name="relbar", + }, + }, unicodeslot=0x2212, }, [0x2213]={ @@ -61291,6 +61324,8 @@ characters.data={ description="APPROACHES THE LIMIT", direction="on", linebreak="al", + mathclass="relation", + mathname="doteq", unicodeslot=0x2250, }, [0x2251]={ diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 285735ffc..5c49d7dac 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.01.24 14:55} +\newcontextversion{2012.01.25 13:09} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 155b5ad34..d0c9d7ad0 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.01.24 14:55} +\newcontextversion{2012.01.25 13:09} %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/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 1408f82a4..84d102600 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 34a371b7a..54b64a16d 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 291170eae..cb22cd8c6 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.01.24 14:55} +\edef\contextversion{2012.01.25 13:09} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 095cd014b..fdefd19bd 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.01.24 14:55} +\edef\contextversion{2012.01.25 13:09} %D For those who want to use this: diff --git a/tex/context/base/file-mod.mkvi b/tex/context/base/file-mod.mkvi index e740a5631..2ca84b3f0 100644 --- a/tex/context/base/file-mod.mkvi +++ b/tex/context/base/file-mod.mkvi @@ -212,7 +212,7 @@ \readfile{#2.\mksuffix}\donothing\donothing \stopnointerference % \egroup \stopreadingfile - \setgvalue{\??runtimeloaded#2}\empty + \letgvalue{\??runtimeloaded#2}\empty \fi \ifx#1\undefined \writestatus\m!system{command \string#1 not found in file #2}% diff --git a/tex/context/base/file-syn.lua b/tex/context/base/file-syn.lua index bf7ef1dbd..1be9fb4b1 100644 --- a/tex/context/base/file-syn.lua +++ b/tex/context/base/file-syn.lua @@ -31,7 +31,7 @@ end function commands.definefilesynonym(name,realname) local synonym = filesynonyms[name] if synonym then - interfaces.showmessage("files",1,name,realname,synonym) + interfaces.showmessage("files",1,{ name or "?", realname or "?", synonym or "?" }) end filesynonyms[name] = realname end diff --git a/tex/context/base/lpdf-fld.lua b/tex/context/base/lpdf-fld.lua index 41d428004..1ccf41823 100644 --- a/tex/context/base/lpdf-fld.lua +++ b/tex/context/base/lpdf-fld.lua @@ -474,7 +474,7 @@ function codeinjections.exportformdata(name) result[#result+1] = format(" <field name='%s'><value>%s</value></field>",v.name or k,v.default or "") end local base = file.basename(tex.jobname) - local xfdf = format(xfdftemplate,base,table.concat(result)) + local xfdf = format(xfdftemplate,base,table.concat(result,"\n")) if not name or name == "" then name = base end diff --git a/tex/context/base/math-ali.mkiv b/tex/context/base/math-ali.mkiv index bbc77ade6..94800b3ba 100644 --- a/tex/context/base/math-ali.mkiv +++ b/tex/context/base/math-ali.mkiv @@ -38,8 +38,6 @@ % n>1 #### needed, strange # interaction in recurse -\def\presetdisplaymath{\displ@y} - \def\math_build_eqalign {\scratchtoks\emptytoks \dorecurse{\mathalignmentparameter\c!m} @@ -57,17 +55,23 @@ \def\math_math_in_eqalign#1{$\tabskip\zeropoint\everycr\emptytoks\displaystyle{{}#1{}}$} \def\math_text_in_eqalign#1{$\tabskip\zeropoint\everycr\emptytoks#1$} +\def\displayopenupvalue{.25\bodyfontsize} + \def\eqalign#1% why no halign here, probably because of displaywidth - {\emptyhbox\,\vcenter - {\openup.25\bodyfontsize% was: \openup\jot + {\emptyhbox + \mskip\thinmuskip + \vcenter + {\openup\displayopenupvalue % was: \openup\jot \mathsurround\zeropoint - \ialign{\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##{}}$\hfil\crcr#1\crcr}% - }\,} + \ialign{\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##{}}$\hfil\crcr#1\crcr}}% + \mskip\thinmuskip} % preamble is scanned for tabskips so we need the span to prevent an error message \setnewconstant\eqalignmode\plusone +% use zeroskipplusfill + \def\math_prepare_r_eqalign_no {\!!toksa{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}% \!!toksb{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}% @@ -80,7 +84,7 @@ \fi\fi \global\mathnumberstatus\zerocount \math_build_eqalign - \presetdisplaymath + \the\mathdisplayaligntweaks \tabskip\centering} \def\math_prepare_l_eqalign_no @@ -96,12 +100,12 @@ \fi\fi \global\mathnumberstatus\zerocount \math_build_eqalign - \presetdisplaymath + \the\mathdisplayaligntweaks \tabskip\centering} \def\math_both_eqalign_no#1#2% {\ifmmode - \displ@y % \let\doplaceformulanumber\relax % strange hack + \the\mathdisplayaligntweaks % \let\doplaceformulanumber\relax % strange hack \vcenter\bgroup \let\math_finish_eqalign_no\egroup \else @@ -113,7 +117,7 @@ \def\math_both_eqalign_no_aligned#1% {\ifmmode - \displ@y + \the\mathdisplayaligntweaks \global\mathnumberstatus\plusone \ifcase\mathraggedstatus \def\math_finish_eqalign_no{\crcr\egroup}% @@ -144,7 +148,7 @@ \let \leqalignno \math_handle_eqalign_no_l_normal \let\alignreqalignno \math_handle_eqalign_no_r_aligned \let\alignleqalignno \math_handle_eqalign_no_l_aligned -\let \equalignno \math_handle_eqalign_no_r_normal +\let \eqalignno \math_handle_eqalign_no_r_normal \let \aligneqalignno \math_handle_eqalign_no_r_aligned %D Here we implement the user interface part. We start with basic math alignments: @@ -406,7 +410,7 @@ \setupmathcases [\c!distance=1em, \c!numberdistance=2.5em, - \c!left={\left\{\,}, + \c!left={\left\{\mskip\thinmuskip}, \c!right={\right.}] \appendtoks @@ -625,7 +629,7 @@ %D %D \typebuffer \getbuffer %D -%D \definemathmatrix[bmatrix][left={\left[\,},right={\,\right]}] +%D \definemathmatrix[bmatrix][left={\left[\mskip\thinmuskip},right={\mskip\thinmuskip\right]}] %D %D \startbuffer %D \placeformula \startformula[-] \startbmatrix @@ -1146,7 +1150,7 @@ % \NC 3 \NC z \NC c \NR % \stopmatrix \stopformula -% \definemathmatrix[bordermatrix][left={\left[\,},right={\,\right]}] +% \definemathmatrix[bordermatrix][left={\left[\mskip\thinmuskip},right={\mskip\thinmuskip\right]}] % \placeformula \startformula[-] \startbordermatrix % \NC 1 \NC x \NC a \NR diff --git a/tex/context/base/math-arr.mkiv b/tex/context/base/math-arr.mkiv index 326056ffb..f18d6be2b 100644 --- a/tex/context/base/math-arr.mkiv +++ b/tex/context/base/math-arr.mkiv @@ -15,7 +15,30 @@ \unprotect -%D These will be generalized! Is it still needed in \MKIV? +%D These will be generalized! Is it still needed in \MKIV? Also, we need to +%D to it using regular opentype math! + +% Plain code: +% +% \def\rightarrowfill +% {$% +% \mathsurround\zeropoint +% \smash-% +% \mkern-7mu% +% \cleaders\hbox{$\mkern-2mu\smash-\mkern-2mu$}\hfill +% \mkern-7mu% +% \mathord\rightarrow +% $} +% +% \def\leftarrowfill % brrr no longer in luated +% {$% +% \mathsurround\zeropoint +% \mathord\leftarrow +% \mkern-7mu% +% \cleaders\hbox{$\mkern-2mu\smash-\mkern-2mu$}\hfill +% \mkern-7mu +% \smash-$ +% $} \def\exmthfont#1{\mr} % \symbolicsizedfont#1\plusone{MathExtension}} diff --git a/tex/context/base/math-def.mkiv b/tex/context/base/math-def.mkiv index 70e36556d..96c122f51 100644 --- a/tex/context/base/math-def.mkiv +++ b/tex/context/base/math-def.mkiv @@ -24,26 +24,7 @@ \activatemathcharacters -% will be attributes - -\setfalse \automathpunctuation - -\def\enablemathpunctuation {\settrue \automathpunctuation} -\def\disablemathpunctuation{\setfalse\automathpunctuation} - -\def\v!autopunctuation{autopunctuation} - -\appendtoks - \doifelse{\mathematicsparameter\v!autopunctuation}\v!yes\enablemathpunctuation\disablemathpunctuation -\to \everysetupmathematics - -% \appendtoks -% \ifconditional\automathpunctuation\attribute\mathpunctuationattribute\plusone\fi -% \to \everymathematics - -\setupmathematics[\v!autopunctuation=\v!yes] - -% will go to math-ext +% will go to math-ext (if used at all) \Umathchardef\braceld=0 \defaultmathfamily "FF07A \Umathchardef\bracerd=0 \defaultmathfamily "FF07B @@ -125,6 +106,8 @@ \def\doleftbigmath #1{\ifx#1\relax\else\left#1\expandafter\doleftbigmath \fi} \def\dorightbigmath#1{\ifx#1\relax\else\right.\expandafter\dorightbigmath\fi} +\installcorenamespace{mathbig} + \def\choosemathbig#1#2% so we accent \big{||} as well {{\hbox{$% \ifcase\bigmathdelimitermethod @@ -136,17 +119,17 @@ \dorightbigmath#2\relax \else \doleftbigmath#2\relax - \vbox\!!to\getvalue{\??mm:b:\number#1}\bodyfontsize{}% + \vbox\!!to\getvalue{\??mathbig\number#1}\bodyfontsize{}% \dorightbigmath#2\relax \fi \nulldelimiterspace\zeropoint\relax \mathsurround\zeropoint $}}} -\definemathcommand [big] {\choosemathbig\plusone } \setvalue{\??mm:b:1}{0.85} -\definemathcommand [Big] {\choosemathbig\plustwo } \setvalue{\??mm:b:2}{1.15} -\definemathcommand [bigg] {\choosemathbig\plusthree} \setvalue{\??mm:b:3}{1.45} -\definemathcommand [Bigg] {\choosemathbig\plusfour } \setvalue{\??mm:b:4}{1.75} +\definemathcommand [big] {\choosemathbig\plusone } \setvalue{\??mathbig1}{0.85} +\definemathcommand [Big] {\choosemathbig\plustwo } \setvalue{\??mathbig2}{1.15} +\definemathcommand [bigg] {\choosemathbig\plusthree} \setvalue{\??mathbig3}{1.45} +\definemathcommand [Bigg] {\choosemathbig\plusfour } \setvalue{\??mathbig4}{1.75} \definemathcommand [bigl] [open] [one] {\big} \definemathcommand [bigm] [rel] [one] {\big} @@ -161,9 +144,7 @@ \definemathcommand [Biggm] [rel] [one] {\Bigg} \definemathcommand [Biggr] [close] [one] {\Bigg} -% special - -%AM: Optimize this! Add similar options for sums. +%D This needs checking: \def\setoperatorlimits#1#2% operator limits {\savenormalmeaning{#1}% @@ -179,7 +160,9 @@ \setoperatorlimits\ointclockwise \intlimits \setoperatorlimits\ointctrclockwise \intlimits -%D This is a temporary hack until we figure out how to do this correctly. +%D This is a temporary hack until we figure out how to do this correctly, +%D preferably using math parameters but we can also consider doing some +%D node juggling here. \unexpanded\def\implies {\mathrel{\;\Longrightarrow\;}} \unexpanded\def\impliedby{\mathrel{\;\Longleftarrow\;}} @@ -236,18 +219,9 @@ \def\rootwithdegree [#1]{\rootradical{#1}} \def\rootwithoutdegree {\rootradical {}} -\def\PLAINmatrix#1% - {\emptyhbox\,\vcenter{\normalbaselines\mathsurround\zeropoint - \ialign{\hfil$##$\hfil&&\quad\hfil$##$\hfil\crcr - \mathstrut\crcr\noalign{\kern-\baselineskip} - #1\crcr\mathstrut\crcr\noalign{\kern-\baselineskip}}}\,} - \definemathcommand [mathstrut] {\vphantom{(}} \definemathcommand [joinrel] {\mathrel{\mkern-3mu}} -% \definemathcommand [matrix] {\PLAINmatrix} -% \definemathcommand [over] {\normalover} % hack, to do - \unexpanded\def\{{\mathortext\lbrace\letterleftbrace } \unexpanded\def\}{\mathortext\rbrace\letterrightbrace} @@ -294,17 +268,9 @@ \definemathcommand [colonsep] {\mkern-1.2mu} \definemathcommand [doublecolonsep] {\mkern-0.9mu} -%D The next macro vertically centeres its contents. - -\def\@center@math#1% - {\vcenter{\hbox{$\mathsurround\zeropoint#1$}}} - -\def\@center@colon - {\mathpalette\@center@math{\colon}} - -%D Now we define all the colon relations. +%D Now we define all the colon relations .. needs checking with char-def.lua: -\definemathcommand [centercolon] [rel] {\@center@colon} +\definemathcommand [centercolon] [rel] {\mathpalette\vcenter{\hbox{$\mathsurround\zeropoint\colon$}}} \definemathcommand [colonminus] [rel] {\centercolon\colonsep\mathrel{-}} \definemathcommand [minuscolon] [rel] {\mathrel{-}\colonsep\centercolon} \definemathcommand [colonequals] [rel] {\centercolon\colonsep=} @@ -326,8 +292,8 @@ %D Goodies. We might move this elsewhere. -% Be careful in choosing what accents you take (the code -% below uses a combining one): +% Be careful in choosing what accents you take (the code below uses a +% combining one): % % \startbuffer % % $\Umathaccent top 0 0 "20D7 {example}$ @@ -350,15 +316,15 @@ % \setupbodyfont[xits] \getbuffer % \setupbodyfont[cambria] \getbuffer -\def\underleftarrow #1{\mathop{\Uunderdelimiter \defaultmathfamily "2190 {#1}}} -\def\overleftarrow #1{\mathop{\Uoverdelimiter \defaultmathfamily "2190 {#1}}} -\def\underrightarrow#1{\mathop{\Uunderdelimiter \defaultmathfamily "2192 {#1}}} -\def\overrightarrow #1{\mathop{\Uoverdelimiter \defaultmathfamily "2192 {#1}}} +\unexpanded\def\underleftarrow #1{\mathop{\Uunderdelimiter \defaultmathfamily "2190 {#1}}} +\unexpanded\def\overleftarrow #1{\mathop{\Uoverdelimiter \defaultmathfamily "2190 {#1}}} +\unexpanded\def\underrightarrow#1{\mathop{\Uunderdelimiter \defaultmathfamily "2192 {#1}}} +\unexpanded\def\overrightarrow #1{\mathop{\Uoverdelimiter \defaultmathfamily "2192 {#1}}} % watch out: here we have a class (zero): -\def\normaldoublebrace {\Umathaccents 0 \defaultmathfamily "23DE 0 \defaultmathfamily "23DF } -\def\normaldoubleparent{\Umathaccents 0 \defaultmathfamily "23DC 0 \defaultmathfamily "23DD } +\unexpanded\def\normaldoublebrace {\Umathaccents 0 \defaultmathfamily "23DE 0 \defaultmathfamily "23DF } +\unexpanded\def\normaldoubleparent{\Umathaccents 0 \defaultmathfamily "23DC 0 \defaultmathfamily "23DD } \let\normaloverbrace \overbrace \let\normalunderbrace \underbrace diff --git a/tex/context/base/math-del.mkiv b/tex/context/base/math-del.mkiv index b6579cc93..569b4cd3d 100644 --- a/tex/context/base/math-del.mkiv +++ b/tex/context/base/math-del.mkiv @@ -27,22 +27,24 @@ %D \fakerightdelimiter %D \stoptyping -\newcount\delimitercount +% Actually we can do better now with lua hacks. -\def\leftfakedelimiter {\advance\delimitercount\minusone\gobbleoneargument}% -\def\rightfakedelimiter{\advance\delimitercount\plusone \gobbleoneargument}% +\newcount\c_math_delimiter_nesting + +\def\leftfakedelimiter {\advance\c_math_delimiter_nesting\minusone\gobbleoneargument} +\def\rightfakedelimiter{\advance\c_math_delimiter_nesting\plusone \gobbleoneargument} \def\checkdelimiters#1% - {\delimitercount\zerocount + {\c_math_delimiter_nesting\zerocount \setbox\scratchbox\hbox\bgroup \let\left \leftfakedelimiter \let\right\rightfakedelimiter $#1\expandafter$\expandafter \egroup - \expandafter\delimitercount\the\delimitercount\relax} + \expandafter\c_math_delimiter_nesting\the\c_math_delimiter_nesting\relax} -\def\fakeleftdelimiter {\ifnum\delimitercount>\zerocount\left .\fi} -\def\fakerightdelimiter{\ifnum\delimitercount<\zerocount\right.\fi} +\def\fakeleftdelimiter {\ifnum\c_math_delimiter_nesting>\zerocount\left .\fi} +\def\fakerightdelimiter{\ifnum\c_math_delimiter_nesting<\zerocount\right.\fi} %D The following macros are used in the MathML interpreter, so %D there is a good change of them never being documented for @@ -51,11 +53,11 @@ \let\normalordelimiter\secondoftwoarguments \let\normalorfiller \firstoftwoarguments -\def\enabledelimiter {\let\normalordelimiter\secondoftwoarguments} -\def\disabledelimiter{\let\normalordelimiter\firstoftwoarguments} +\unexpanded\def\enabledelimiter {\let\normalordelimiter\secondoftwoarguments} +\unexpanded\def\disabledelimiter{\let\normalordelimiter\firstoftwoarguments} -\def\enablefiller {\let\normalorfiller\secondoftwoarguments} -\def\disablefiller {\let\normalorfiller\firstoftwoarguments} +\unexpanded\def\enablefiller {\let\normalorfiller\secondoftwoarguments} +\unexpanded\def\disablefiller {\let\normalorfiller\firstoftwoarguments} \def\mathopnolimits#1{\mathop{\mr#1}\nolimits} % was \rm, which follows text fonts (used in mml parser) \def\mathopdolimits#1{\mathop{\mr#1}} % was \rm, which follows text fonts (used in mml parser) diff --git a/tex/context/base/math-frc.mkiv b/tex/context/base/math-frc.mkiv index 19070a3a0..59bd588c0 100644 --- a/tex/context/base/math-frc.mkiv +++ b/tex/context/base/math-frc.mkiv @@ -15,6 +15,8 @@ \unprotect +% quite old ... still needed? + %D \macros %D {frac, xfrac, xxfrac} %D @@ -66,10 +68,8 @@ %D So we stick to the next definitions (watch the local %D overloading of \type {\xfrac}). -% \def\dofrac#1#2#3{\relax\mathematics{{{#1{#2}}\over{#1{#3}}}}} - -\def\dofrac#1#2#3{\relax\mathematics{\Ustack{{#1{#2}}\normalover{#1{#3}}}}} -\def\nofrac #1#2{\relax\mathematics{\Ustack{{#1}\normalover{#2}}}} +\def\math_fractions_forced#1#2#3{\relax\mathematics{\Ustack{{#1{#2}}\normalover{#1{#3}}}}} +\def\math_fractions_auto #1#2{\relax\mathematics{\Ustack{{#1}\normalover{#2}}}} % $\mathfracmode0 \frac{1}{2}$ % $\mathfracmode1 \frac{1}{2}$ @@ -82,30 +82,30 @@ \setnewconstant\mathfracmode\zerocount -\unexpanded\def\frac +\unexpanded\def\frac % overloaded later on {\ifcase\mathfracmode - \expandafter\nofrac + \expandafter\math_fractions_auto \or - \expandafter\dofrac\expandafter\displaystyle + \expandafter\math_fractions_forced\expandafter\displaystyle \or - \expandafter\dofrac\expandafter\textstyle + \expandafter\math_fractions_forced\expandafter\textstyle \or - \expandafter\dofrac\expandafter\scriptstyle + \expandafter\math_fractions_forced\expandafter\scriptstyle \or - \expandafter\dofrac\expandafter\scriptscriptstyle + \expandafter\math_fractions_forced\expandafter\scriptscriptstyle \else - \expandafter\dofrac\expandafter\mathstyle + \expandafter\math_fractions_forced\expandafter\mathstyle \fi} \unexpanded\def\xfrac#1#2% {\begingroup \let\xfrac\xxfrac - \dofrac\scriptstyle{#1}{#2}% + \math_fractions_forced\scriptstyle{#1}{#2}% \endgroup} \unexpanded\def\xxfrac#1#2% {\begingroup - \dofrac\scriptscriptstyle{#1}{#2}% + \math_fractions_forced\scriptscriptstyle{#1}{#2}% \endgroup} %D The \type {xx} variant looks still ugly, so maybe it's @@ -113,7 +113,7 @@ \unexpanded\def\xxfrac#1#2% {\begingroup - \dofrac\scriptscriptstyle{#1}{\raise.25ex\hbox{$\scriptscriptstyle#2$}}% + \math_fractions_forced\scriptscriptstyle{#1}{\raise.25ex\hbox{$\scriptscriptstyle#2$}}% \endgroup} %D Something low level for scientific calculator notation: @@ -121,132 +121,12 @@ \unexpanded\def\scinot#1#2% {#1\times10^{#2}} -%D The next macro, \type {\ch}, is \PPCHTEX\ aware. In -%D formulas one can therefore best use \type {\ch} instead of -%D \type {\chemical}, especially in fractions. - -% let's see who complains ... \mathstyle is now a primitive -% -% \unexpanded\def\ch#1% -% {\ifdefined\@@chemicalletter -% \dosetsubscripts -% \mathstyle{\@@chemicalletter{#1}}% -% \doresetsubscripts -% \else -% \mathstyle{\rm#1}% -% \fi} - -% \unexpanded\def\ch#1% -% {\ifdefined\@@chemicalletter -% \dosetsubscripts -% \mathematics{\@@chemicalletter{#1}}% -% \doresetsubscripts -% \else -% \mathematics{\rm#1}% -% \fi} - -%D \macros -%D {/} -%D -%D Just to be sure, we restore the behavior of some typical -%D math characters. - -\bgroup - -\catcode`\/=\othercatcode \global \let\normalforwardslash/ -\catcode`\/=\activecatcode \doglobal\appendtoks\let/\normalforwardslash\to\everymathematics - -\egroup - -% to be checked: - -\unexpanded\def\exmthfont#1% - {\mr} % \symbolicsizedfont#1\plusone{MathExtension}} - -\def\domthfrac#1#2#3#4#5#6#7% - {\begingroup - \mathsurround\zeropoint - \setbox0\hbox{$#1 #6$}% - \setbox2\hbox{$#1 #7$}% - \dimen0\wd0 - \ifdim\wd2>\dimen0 \dimen0\wd2 \fi - \setbox4\hbox to \dimen0{\exmthfont#2#3\leaders\hbox{#4}\hss#5}% - \mathord{\vcenter{{\offinterlineskip - \hbox to \dimen0{\hss\box0\hss}% - \kern \ht4% - \hbox to \dimen0{\hss\copy4\hss}% - \kern \ht4% - \hbox to \dimen0{\hss\box2\hss}}}}% - \endgroup} - -\def\domthsqrt#1#2#3#4#5% - {\begingroup - \mathsurround\zeropoint - \setbox0\hbox{$#1 #5$}% - \dimen0=1.05\ht0 \advance\dimen0 1pt \ht0 \dimen0 - \dimen0=1.05\dp0 \advance\dimen0 1pt \dp0 \dimen0 - \dimen0\wd0 - \setbox4\hbox to \dimen0{\exmthfont#2\leaders\hbox{#3}\hfill#4}% - \delimitershortfall=0pt - \nulldelimiterspace=0pt - \setbox2\hbox{$\left\delimiter"0270370 \vrule height\ht0 depth \dp0 width0pt - \right.$}% - \mathord{\vcenter{\hbox{\copy2 - \rlap{\raise\dimexpr\ht2-\ht4\relax\copy4}\copy0}}}% - \endgroup} - -\unexpanded\def\mthfrac#1#2#3#4#5{\mathchoice - {\domthfrac\displaystyle \textface {#1}{#2}{#3}{#4}{#5}} - {\domthfrac\textstyle \textface {#1}{#2}{#3}{#4}{#5}} - {\domthfrac\scriptstyle \scriptface {#1}{#2}{#3}{#4}{#5}} - {\domthfrac\scriptscriptstyle\scriptscriptface{#1}{#2}{#3}{#4}{#5}}} - -\unexpanded\def\mthsqrt#1#2#3{\mathchoice - {\domthsqrt\displaystyle \textface {#1}{#2}{#3}} - {\domthsqrt\textstyle \textface {#1}{#2}{#3}} - {\domthsqrt\scriptstyle \textface {#1}{#2}{#3}} - {\domthsqrt\scriptscriptstyle\textface {#1}{#2}{#3}}} +% I have no clue what \mthfrac and \mthsqrt are supposed to do but +% I guess that it can be done with tweaking luatex's math parameters. +% Otherwise I'll write something from scratch. -%D Moved from math-new.tex (not that new anyway): - -%D \macros -%D {genfrac} -%D -%D [TH] The definition of \type {\genfrac} \& co. is not -%D trivial, because it allows some flexibility. This is -%D supposed to be a user||level command, but will fail quite -%D desparately if called outside math mode (\CONTEXT\ redefines -%D \type {\over}) -%D -%D [HH] We clean up this macro a bit and (try) to make it -%D understandable. The expansion is needed for generating -%D the second argument to \type {\dogenfrac}, which is to -%D be a control sequence like \type {\over}. - -\unexpanded\def\genfrac#1#2#3#4% - {\edef\!!stringa - {#1#2}% - \normalexpanded - {\dogenfrac{#4}% - \csname - \ifx @#3@% - \ifx\!!stringa\empty - \strippedcsname\normalover - \else - \strippedcsname\normaloverwithdelims - \fi - \else - \ifx\!!stringa\empty - \strippedcsname\normalabove - \else - \strippedcsname\normalabovewithdelims - \fi - \fi - \endcsname}% - {#1#2#3}} - -\unexpanded\def\dogenfrac#1#2#3#4#5% - {{#1{\begingroup#4\endgroup#2#3\relax#5}}} +\unexpanded\def\mthfrac#1#2#3{[mthfrac: #1 #2 #3]} +\unexpanded\def\mthsqrt#1#2#3{[mthsqrt: #1 #2 #3]} %D \macros %D {dfrac, tfrac, frac, dbinom, tbinom, binom} @@ -257,21 +137,23 @@ %D \stopbuffer %D %D \typebuffer -%D %D \getbuffer -\unexpanded\def\dfrac {\genfrac\empty\empty{}\displaystyle} -\unexpanded\def\tfrac {\genfrac\empty\empty{}\textstyle} -\unexpanded\def\frac {\genfrac\empty\empty{}\donothing} +% extra {} after displaystyle etc are needed -\unexpanded\def\dbinom{\genfrac()\zeropoint\displaystyle} -\unexpanded\def\tbinom{\genfrac()\zeropoint\textstyle} -\unexpanded\def\binom {\genfrac()\zeropoint\donothing} +%unexpanded\def\frac #1#2{{ {{#1}\normalover {#2}}}} +%unexpanded\def\xfrac #1#2{{\scriptstyle {{#1}\normalover {#2}}}} +%unexpanded\def\xxfrac#1#2{{\scriptscriptstyle{{#1}\normalover {#2}}}} +\unexpanded\def\dfrac #1#2{{\displaystyle {{#1}\normalover {#2}}}} +\unexpanded\def\tfrac #1#2{{\textstyle {{#1}\normalover {#2}}}} -\unexpanded\def\xfrac {\genfrac\empty\empty{}\scriptstyle} -\unexpanded\def\xxfrac{\genfrac\empty\empty{}\scriptscriptstyle} +%unexpanded\def\binom #1#2{{ {{#1}\normalabovewithdelims()\zeropoint{#2}}}} +\unexpanded\def\dbinom#1#2{{\displaystyle {{#1}\normalabovewithdelims()\zeropoint{#2}}}} +\unexpanded\def\tbinom#1#2{{\textstyle {{#1}\normalabovewithdelims()\zeropoint{#2}}}} -\unexpanded\def\frac#1#2{\mathematics{\genfrac\empty\empty{}\donothing{#1}{#2}}} +\unexpanded\def\binom #1#2{{\Ustack{{#1}\normalabovewithdelims()\zeropoint{#2}}}} + +% \let\frac\math_fractions_auto %D \macros %D {cfrac} @@ -298,12 +180,13 @@ %D %D \getbuffer -\definecomplexorsimple\cfrac +\unexpanded\def\cfrac + {\doifnextoptionalelse\math_cfrac_yes\math_cfrac_nop} -\def\simplecfrac {\docfrac[cc]} -\def\complexcfrac[#1]{\docfrac[#1cc]} +\def\math_cfrac_nop {\math_cfrac_indeed[cc]} +\def\math_cfrac_yes[#1]{\math_cfrac_indeed[#1cc]} -\def\docfrac[#1#2#3]#4#5% +\def\math_cfrac_indeed[#1#2#3]#4#5% {{\displaystyle \frac {\strut @@ -335,17 +218,13 @@ %D \typebuffer \getbuffer %D %D These macros are based on Michael J.~Downes posting on -%D comp.text.tex on 2001/12/06 +%D comp.text.tex on 2001/12/06 but adapted a bit. -\unexpanded\def\splitfrac#1#2% - {\genfrac\empty\empty\zeropoint\textstyle% - {\textstyle#1\quad\hfill}% - {\textstyle\hfill\quad\mathstrut#2}} +\unexpanded\def\splitfrac #1#2% + {{\textstyle {{\textstyle#1\quad\hfill}\normalabove\zeropoint{\textstyle\hfill\quad\mathstrut#2}}}} \unexpanded\def\splitdfrac#1#2% - {\genfrac\empty\empty\zeropoint\displaystyle% - {#1\quad\hfill} - {\hfill\quad\mathstrut #2}} + {{\displaystyle{{ #1\quad\hfill}\normalabove\zeropoint{ \hfill\quad\mathstrut#2}}}} %D For thee moment here, but it might move: @@ -359,11 +238,11 @@ \unexpanded\def\qedsymbol#1% {\ifhmode - \unskip~\hfill#1\par + \unskip\nobreakspace\hfill#1\par \else\ifmmode - \eqno#1\relax % Do we really need the \eqno here? + #1\relax % leading \eqno removed \else - \leavevmode\hbox{}\hfill#1\par + \dontleavehmode\emptyhbox\hfill#1\par \fi\fi} \definesymbol [qed] [\qedsymbol{\mathematics{\square}}] @@ -378,21 +257,11 @@ \unexpanded\def\QED{\symbol[qed]} %D \macros -%D {mathhexbox} -%D -%D [TH] \type {\mathhexbox} is also user||level (already -%D defined in Plain \TEX). It allows to get a math character -%D inserted as if it was a text character. - -\unexpanded\def\mathhexbox#1#2#3% - {\mathtext{$\mathsurround\zeropoint\mathchar"#1#2#3$}} - -%D \macros %D {boxed} %D -%D [HH] Another macro that users expect (slightly adapted): +%D [HH] Another macro that users might expect (slightly adapted): -\unexpanded\def\boxed +\unexpanded\def\boxed % maybe obsolete {\ifmmode\expandafter\mframed\else\expandafter\framed\fi} \protect \endinput diff --git a/tex/context/base/math-ini.lua b/tex/context/base/math-ini.lua index cb1a72926..663f6bb1e 100644 --- a/tex/context/base/math-ini.lua +++ b/tex/context/base/math-ini.lua @@ -8,12 +8,16 @@ if not modules then modules = { } end modules ['math-ext'] = { -- if needed we can use the info here to set up xetex definition files -- the "8000 hackery influences direct characters (utf) as indirect \char's +-- +-- isn't characters.data loaded already ... shortcut it here local format, utfchar, utfbyte = string.format, utf.char, utf.byte local setmathcode, setdelcode = tex.setmathcode, tex.setdelcode local texattribute = tex.attribute local floor = math.floor +local context = context + local contextsprint = context.sprint local contextfprint = context.fprint -- a bit inefficient @@ -316,28 +320,41 @@ end -- needed for mathml analysis -function mathematics.utfmathclass(chr, default) +local function utfmathclass(chr, default) local cd = characters.data[utfbyte(chr)] return (cd and cd.mathclass) or default or "unknown" end -function mathematics.utfmathstretch(chr, default) -- "h", "v", "b", "" +local function utfmathstretch(chr, default) -- "h", "v", "b", "" local cd = characters.data[utfbyte(chr)] return (cd and cd.mathstretch) or default or "" end -function mathematics.utfmathcommand(chr, default) +local function utfmathcommand(chr, default) local cd = characters.data[utfbyte(chr)] local cmd = cd and cd.mathname return cmd or default or "" end -function mathematics.utfmathfiller(chr, default) +local function utfmathfiller(chr, default) local cd = characters.data[utfbyte(chr)] local cmd = cd and (cd.mathfiller or cd.mathname) return cmd or default or "" end +mathematics.utfmathclass = utfmathclass +mathematics.utfmathstretch = utfmathstretch +mathematics.utfmathcommand = utfmathcommand +mathematics.utfmathfiller = utfmathfiller + +-- interfaced + +function commands.utfmathclass (chr) context(utfmathclass (chr)) end +function commands.utfmathstretch(chr) context(utfmathstretch(chr)) end +function commands.utfmathcommand(chr) context(utfmathcommand(chr)) end +function commands.utfmathfiller (chr) context(utfmathfiller (chr)) end + + -- helpers function mathematics.big(tfmdata,unicode,n) diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index 241d34b4a..0e65c8d28 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -27,6 +27,14 @@ \unprotect +\ifdefined\v!autopunctuation \else \def\v!autopunctuation{autopunctuation} \fi +\ifdefined\v!integral \else \def\v!integral {integral} \fi + +\def\s!lcgreek {lcgreek} +\def\s!ucgreek {ucgreek} +\def\s!italics {italics} +\def\s!integral{integral} + %D We move these definitions into the format: % test [[\char948 \cldcontext{utf.char(948)}]] @@ -62,23 +70,52 @@ \setnewconstant\defaultmathfamily \zerocount % 255 +%D Some measures (maybe spac-mth): + +% \def\mathskipsmall {\mskip\thinmuskip} +% \def\mathskipmedium{\mskip\medmuskip} +% \def\mathskipbig {\mskip\thickmuskip} + %D \macros %D {setupmathematics} %D %D Configuration for integrals. (If needed we can speed this up and make it %D installable; no processaction is needed then). -\newtoks\everysetupmathematics +% \newtoks\everysetupmathematics +% +% \unexpanded\def\setupmathematics +% {\dosingleargument\dosetupmathematics} +% +% \def\dosetupmathematics[#1]% +% {\getparameters[\??mo][#1]% +% \the\everysetupmathematics} +% +% \def\mathematicsparameter#1% +% {\ifcsname\??mo#1\endcsname\csname\??mo#1\endcsname\fi} + +\installcorenamespace{mathematics} + +\installswitchcommandhandler \??mathematics {mathematics} \??mathematics + +\unexpanded\def\startmathematics % no grouping, if ever then also an optional second + {\doifnextoptionalelse\math_mathematics_start_yes\math_mathematics_start_nop} + +\unexpanded\def\math_mathematics_start_yes[#1]% + {\pushmacro\currentmathematics + \edef\currentmathematics{#1}% check for valid + \the\everyswitchmathematics} -\unexpanded\def\setupmathematics - {\dosingleargument\dosetupmathematics} +\unexpanded\def\math_mathematics_start_nop + {\pushmacro\currentmathematics + \let\currentmathematics\empty + \the\everyswitchmathematics} -\def\dosetupmathematics[#1]% - {\getparameters[\??mo][#1]% - \the\everysetupmathematics} +\unexpanded\def\stopmathematics + {\popmacro\currentmathematics + \the\everyswitchmathematics} -\def\mathematicsparameter#1% - {\ifcsname\??mo#1\endcsname\csname\??mo#1\endcsname\fi} +\definemathematics[\v!default] % not needed, but nicer when nesting back to normal % Normally this is applied to only one character. % @@ -86,36 +123,38 @@ % todo: only in mmode -\unexpanded\def\mathgreekupright{\attribute\mathgreekattribute22 } -\unexpanded\def\mathgreekitalic {\attribute\mathgreekattribute33 } -\unexpanded\def\mathgreekdefault{\attribute\mathgreekattribute\attributeunsetvalue} +\unexpanded\def\mathgreekupright{\attribute\c_math_greek_attribute22 } +\unexpanded\def\mathgreekitalic {\attribute\c_math_greek_attribute33 } +\unexpanded\def\mathgreekdefault{\attribute\c_math_greek_attribute\attributeunsetvalue} \let\mathgreeknormal\mathgreekupright \let\mathgreeknone \mathgreekdefault -\def\setmathattribute#1#2{\ifmmode\ctxcommand{setmathattribute("#1","#2")}\fi} -\def\setmathalphabet #1{\ifmmode\ctxcommand{setmathalphabet("#1")}\fi} -\def\setmathstyle #1{\ifmmode\ctxcommand{setmathstyle("#1")}\fi} -\def\setmathalternate #1{\ifmmode\ctxcommand{setmathalternate(\number\defaultmathfamily,"#1")}\fi} +\unexpanded\def\setmathattribute#1#2{\ifmmode\ctxcommand{setmathattribute("#1","#2")}\fi} +\unexpanded\def\setmathalphabet #1{\ifmmode\ctxcommand{setmathalphabet("#1")}\fi} +\unexpanded\def\setmathstyle #1{\ifmmode\ctxcommand{setmathstyle("#1")}\fi} +\unexpanded\def\setmathalternate #1{\ifmmode\ctxcommand{setmathalternate(\number\defaultmathfamily,"#1")}\fi} -\def\setmathstylealterternate#1% - {\ifcsname\??mo:\c!alternative:\fontclass:#1\endcsname - \setmathalternate{\csname\??mo:\c!alternative:\fontclass:#1\endcsname}% - \else\ifcsname\??mo:\c!alternative:#1\endcsname - \setmathalternate{\csname\??mo:\c!alternative:#1\endcsname}% +\installcorenamespace{mathstylealternate} % might become a setuphandler + +\unexpanded\def\setmathstylealterternate#1% + {\ifcsname\??mathstylealternate\fontclass:#1\endcsname + \expandafter\setmathalternate\csname\??mathstylealternate\fontclass:#1\endcsname + \else\ifcsname\??mathstylealternate#1\endcsname + \expandafter\setmathalternate\csname\??mathstylealternate#1\endcsname \fi\fi} \unexpanded\def\setupmathrendering % the name might change - {\dodoubleargument\dosetupmathrendering} + {\dodoubleargument\math_setup_rendering} -\def\dosetupmathrendering[#1][#2]% +\def\math_setup_rendering[#1][#2]% {\ifsecondargument - \getparameters[\??mo:\c!alternative:#1:][#2]% + \getparameters[\??mathstylealternate#1:][#2]% \else - \getparameters[\??mo:\c!alternative:][#1]% + \getparameters[\??mathstylealternate][#1]% \fi} -\def\mathaltcal{\setmathalternate{cal}\cal} % ss01 in xits +\unexpanded\def\mathaltcal{\setmathalternate{cal}\cal} % ss01 in xits \let\mathalternate\setmathalternate % obsolete @@ -197,8 +236,8 @@ \newcount\c_math_renderings_attribute \appendtoks - \c_math_renderings_attribute\cldcontext{mathematics.renderset("\mathematicsparameter\c!symbolset")}\relax -\to \everysetupmathematics + \c_math_renderings_attribute\ctxcommand{mathrenderset("\mathematicsparameter\c!symbolset")}\relax +\to \everysetupmathematics % only in mathematics \appendtoks \ifcase\c_math_renderings_attribute\else @@ -216,104 +255,84 @@ \let\mathboldsymbol\relax % yet unsupported, will be -\def\boldsymbol +\unexpanded\def\boldsymbol {\mathortext\mathboldsymbol\bold} %D Helpers: -\def\utfmathclass #1{\cldcontext{mathematics.utfmathclass (\!!bs#1\!!es)}} -\def\utfmathstretch#1{\cldcontext{mathematics.utfmathstretch(\!!bs#1\!!es)}} -\def\utfmathcommand#1{\cldcontext{mathematics.utfmathcommand(\!!bs#1\!!es)}} -\def\utfmathfiller #1{\cldcontext{mathematics.utfmathfiller (\!!bs#1\!!es)}} - -\def\@@mathlimopcomm #1{\mathop{#1}} %no \limits -\def\@@mathnolopcomm #1{\mathop{#1}\nolimits} -\def\@@mathboxcomm #1{\dontleavehmode\hbox\Ustartmath\mathsurround\zeropoint#1\Ustopmath} -\def\@@mathchoicecomm#1{[todo #1]} - -\setnewconstant\mathordcode 0 \let\mathordcomm \mathord -\setnewconstant\mathopcode 1 \let\mathopcomm \mathop -\setnewconstant\mathbincode 2 \let\mathbincomm \mathbin -\setnewconstant\mathrelcode 3 \let\mathrelcomm \mathrel -\setnewconstant\mathopencode 4 \let\mathopencomm \mathopen -\setnewconstant\mathclosecode 5 \let\mathclosecomm \mathclose -\setnewconstant\mathpunctcode 6 \let\mathpunctcomm \mathpunct -\setnewconstant\mathalphacode 7 \let\mathalphacomm \firstofoneargument -\setnewconstant\mathinnercode 0 \let\mathinnercomm \mathinner -\setnewconstant\mathnothingcode 0 \let\mathnothingcomm \firstofoneargument -\setnewconstant\mathlimopcode 1 \let\mathlimopcomm \@@mathlimopcomm -\setnewconstant\mathnolopcode 1 \let\mathnolopcomm \@@mathnolopcomm -\setnewconstant\mathchoicecode 0 \let\mathchoicecomm \@@mathchoicecomm -\setnewconstant\mathboxcode 0 \let\mathboxcomm \@@mathboxcomm - -\setnewconstant\mathaccentcode 8 -\setnewconstant\mathradicalcode 9 - -\def\puremathcode#1{\the\csname math#1code\endcsname} -\def\puremathcomm#1{\csname math#1comm\endcsname} +\def\utfmathclass #1{\ctxcommand{utfmathclass (\!!bs#1\!!es)}} +\def\utfmathstretch#1{\ctxcommand{utfmathstretch(\!!bs#1\!!es)}} +\def\utfmathcommand#1{\ctxcommand{utfmathcommand(\!!bs#1\!!es)}} +\def\utfmathfiller #1{\ctxcommand{utfmathfiller (\!!bs#1\!!es)}} + +%D Not used that much: + +\installcorenamespace{mathcodecommand} + +\unexpanded\def\mathlimop #1{\mathop{#1}} %no \limits +\unexpanded\def\mathbox #1{\dontleavehmode\hbox\Ustartmath\mathsurround\zeropoint#1\Ustopmath} +\unexpanded\def\mathnolop #1{\mathop{#1}\nolimits} + +\let\mathnothing\firstofoneunexpanded +\let\mathalpha \firstofoneunexpanded + +\setnewconstant\mathordcode \zerocount \letvalue{\??mathcodecommand ord}\mathord +\setnewconstant\mathopcode \plusone \letvalue{\??mathcodecommand op}\mathop +\setnewconstant\mathbincode \plustwo \letvalue{\??mathcodecommand bin}\mathbin +\setnewconstant\mathrelcode \plusthree \letvalue{\??mathcodecommand rel}\mathrel +\setnewconstant\mathopencode \plusfour \letvalue{\??mathcodecommand open}\mathopen +\setnewconstant\mathclosecode \plusfive \letvalue{\??mathcodecommand close}\mathclose +\setnewconstant\mathpunctcode \plussix \letvalue{\??mathcodecommand punct}\mathpunct +\setnewconstant\mathalphacode \plusseven \letvalue{\??mathcodecommand alpha}\mathalpha +\setnewconstant\mathinnercode \zerocount \letvalue{\??mathcodecommand inner}\mathinner +\setnewconstant\mathnothingcode \zerocount \letvalue{\??mathcodecommand nothing}\mathnothing +\setnewconstant\mathlimopcode \plusone \letvalue{\??mathcodecommand limop}\mathlimop +\setnewconstant\mathnolopcode \plusone \letvalue{\??mathcodecommand nolop}\mathnolop +\setnewconstant\mathboxcode \zerocount \letvalue{\??mathcodecommand box}\mathbox +\setnewconstant\mathchoicecode \zerocount %letvalue{\??mathcodecommand choice}\mathnothing + +\setnewconstant\mathaccentcode \pluseight +\setnewconstant\mathradicalcode \plusnine + + \def\mathcodenumber #1{\the\csname math#1code\endcsname} +\unexpanded\def\mathcodecommand#1{\csname\??mathcodecommand#1\endcsname} % \startlines % $\mathopnolimits{\rm d}x$ % $\mathopnolimits{\kern\zeropoint \rm d}x$ -% $\puremathcomm{nolop}{\rm d}x$ -% $\puremathcomm{nolop}{\kern\zeropoint\rm d}x$ +% $\mathcodecommand{nolop}{\rm d}x$ +% $\mathcodecommand{nolop}{\kern\zeropoint\rm d}x$ % \blank -% $\puremathcomm{nolop}{\mr d}x$ -% $\puremathcomm{nolop}{\kern\zeropoint\mr d}x$ +% $\mathcodecommand{nolop}{\mr d}x$ +% $\mathcodecommand{nolop}{\kern\zeropoint\mr d}x$ % $\mathop{\kern\zeropoint\mr d}x$ % $\mathopnolimits{\kern\zeropoint d}x$ % \stoplines - -% this will be sorted out: -% \let\mathcharacter \getvalue -% \let\textcharacter \getvalue -% -% \unexpanded\def\definefamilysynonym {\dotripleempty\dodefinefamilysynonym} -% \def\dodefinefamilysynonym [#1][#2][#3]{} -% \unexpanded\def\definemathsymbol {\dosixtupleempty\dodefinemathsymbol} -% \def\dodefinemathsymbol [#1][#2][#3][#4][#5][#6]{} -% \unexpanded\def\definemathcharacter {\dosixtupleempty\dodefinemathcharacter} -% \def\dodefinemathcharacter [#1][#2][#3][#4][#5][#6]{} +\installcorenamespace{mathcommand} \unexpanded\def\definemathcommand - {\dotripleempty\dodefinemathcommand} - -% \def\dodefinemathcommand[#1][#2][#3]#4% command class args meaning -% {\ifthirdargument -% \edef\nofmathcommandarguments{#3}% -% \ifx\nofmathcommandarguments\v!one -% \setuvalue{#1}##1{\puremathcomm{#2}{#4{##1}}}% -% \else\ifx\nofmathcommandarguments\v!two -% \setuvalue{#1}##1##2{\puremathcomm{#2}{#4{##1}{##2}}}% -% \else -% \setuvalue{#1}{\puremathcomm{#2}{#4}}% -% \fi\fi -% \else\ifsecondargument -% \setuvalue{#1}{\puremathcomm{#2}{#4}}% -% \else -% \setuvalue{#1}{\puremathcomm{nothing}{#4}}% -% \fi\fi} - -\def\dodefinemathcommand[#1][#2][#3]#4% command class args meaning + {\dotripleempty\math_define_command} + +\def\math_define_command[#1][#2][#3]#4% command class args meaning {\ifthirdargument \edef\nofmathcommandarguments{#3}% \ifx\nofmathcommandarguments\v!one - \setuvalue{\??mo::#1}##1{\puremathcomm{#2}{#4{##1}}}% + \setuvalue{\??mathcommand#1}##1{\mathcodecommand{#2}{#4{##1}}}% \else\ifx\nofmathcommandarguments\v!two - \setuvalue{\??mo::#1}##1##2{\puremathcomm{#2}{#4{##1}{##2}}}% + \setuvalue{\??mathcommand#1}##1##2{\mathcodecommand{#2}{#4{##1}{##2}}}% \else - \setuvalue{\??mo::#1}{\puremathcomm{#2}{#4}}% + \setuvalue{\??mathcommand#1}{\mathcodecommand{#2}{#4}}% \fi\fi \else\ifsecondargument - \setuvalue{\??mo::#1}{\puremathcomm{#2}{#4}}% + \setuvalue{\??mathcommand#1}{\mathcodecommand{#2}{#4}}% \else - \setuvalue{\??mo::#1}{\puremathcomm{nothing}{#4}}% + \setuvalue{\??mathcommand#1}{\mathcodecommand{nothing}{#4}}% \fi\fi - \letcsnamecsname\csname#1\endcsname\csname\??mo::#1\endcsname} + \letcsnamecsname\csname#1\endcsname\csname\??mathcommand#1\endcsname} \unexpanded\def\mathcommand#1% - {\csname\??mo::#1\endcsname} + {\csname\??mathcommand#1\endcsname} %D Moved from font-ini.mkiv: %D @@ -331,51 +350,59 @@ {\normalmathop \bgroup \let\rm\mf - \let\next=} + \let\nexttoken=} -\def\normalmbox +% this one too: \letvalue{\??mathcodecommand op}\mathop ? + +\unexpanded\def\normalmbox {\normalhbox\bgroup\mf - \dowithnextbox{\flushnextbox\egroup}\normalhbox} + \dowithnextboxcs\math_mbox_finish\normalhbox} + +\def\math_mbox_finish + {\flushnextbox + \egroup} -\def\mbox % we cannot add \dontleavehmode ... else no \setbox0\mbox possible +\unexpanded\def\mbox % we cannot add \dontleavehmode ... else no \setbox0\mbox possible {\ifmmode\normalmbox\else\normalhbox\fi} \unexpanded\def\enablembox - {\appendtoks - \ifx\normalhbox\undefined\let\normalhbox\hbox\fi - \let\hbox\mbox - \to\everymathematics} + {\appendtoks\math_enable_mbox\to \everymathematics} + {\everymathematics\expandafter{\the\everymathematics\math_enable_mbox}} + +\def\math_enable_mbox + {\ifdefined\normalhbox\else\let\normalhbox\hbox\fi % ? + \let\hbox\mbox} %D The next hack is needed needed for sine, cosine etc. -\let\mathfunction\firstofoneargument +\let\mathfunction\firstofoneunexpanded -\let\taggedmathfunction \firstofoneargument -\let\taggedmathfunctionlabeltext\mathlabeltext +\let\math_tags_function \firstofoneunexpanded +\let\math_tags_functionlabeltext\mathlabeltext -\let\taggedmathmo\firstofoneargument -\let\taggedmathmi\firstofoneargument +\let\math_tags_mo\firstofoneunexpanded +\let\math_tags_mi\firstofoneunexpanded -\def\taggedmathmn#1{\begingroup\mr#1\endgroup} -\def\taggedmathms#1{\begingroup\mr#1\endgroup} +\unexpanded\def\math_tags_mn#1{\begingroup\mr#1\endgroup} +\unexpanded\def\math_tags_ms#1{\begingroup\mr#1\endgroup} -\def\mfunction #1{{\mr\taggedmathfunction{#1}}} -\def\mfunctionlabeltext#1{{\mr\taggedmathfunctionlabeltext{#1}}} +\unexpanded\def\mfunction #1{{\mr\math_tags_function{#1}}} +\unexpanded\def\mfunctionlabeltext#1{{\mr\math_tags_functionlabeltext{#1}}} % Once this is stable we can store the number at the tex end which is % faster. Functions getnumbers >= 1000. -\def\dotaggedmathfunction #1{\ctxcommand{taggedmathfunction("#1",false,\ifconditional\c_apply_function true\else false\fi)}} -\def\dotaggedmathfunctionlabeltext#1{\ctxcommand{taggedmathfunction("#1",true ,\ifconditional\c_apply_function true\else false\fi)}} +\expanded\def\math_tags_mathfunction_indeed #1{\ctxcommand{taggedmathfunction("#1",false,\ifconditional\c_apply_function true\else false\fi)}} +\expanded\def\math_tags_mathfunctionlabeltext_indeed#1{\ctxcommand{taggedmathfunction("#1",true ,\ifconditional\c_apply_function true\else false\fi)}} -\def\dotaggedmo#1{\begingroup \attribute\mathcategoryattribute\plusone #1\endgroup} -\def\dotaggedmi#1{\begingroup \attribute\mathcategoryattribute\plustwo #1\endgroup} -\def\dotaggedmn#1{\begingroup\mr\attribute\mathcategoryattribute\plusthree#1\endgroup} -\def\dotaggedms#1{\begingroup\mr\attribute\mathcategoryattribute\plusfour #1\endgroup} +\expanded\def\math_tags_mo_indeed#1{\begingroup \attribute\mathcategoryattribute\plusone #1\endgroup} +\expanded\def\math_tags_mi_indeed#1{\begingroup \attribute\mathcategoryattribute\plustwo #1\endgroup} +\expanded\def\math_tags_mn_indeed#1{\begingroup\mr\attribute\mathcategoryattribute\plusthree#1\endgroup} +\expanded\def\math_tags_ms_indeed#1{\begingroup\mr\attribute\mathcategoryattribute\plusfour #1\endgroup} \newconditional\c_apply_function -\def\taggedmathapply#1#2% +\unexpanded\def\math_tags_apply#1#2% {\begingroup \settrue\c_apply_function #1% @@ -386,20 +413,20 @@ \endgroup} \appendtoks - \let\taggedmathfunction \dotaggedmathfunction - \let\taggedmathfunctionlabeltext\dotaggedmathfunctionlabeltext - \let\taggedmathmo \dotaggedmo - \let\taggedmathmi \dotaggedmi - \let\taggedmathmn \dotaggedmn - \let\taggedmathms \dotaggedms + \let\math_tags_function \math_tags_mathfunction_indeed + \let\math_tags_functionlabeltext\math_tags_mathfunctionlabeltext_indeed + \let\math_tags_mo \math_tags_mo_indeed + \let\math_tags_mi \math_tags_mi_indeed + \let\math_tags_mn \math_tags_mn_indeed + \let\math_tags_ms \math_tags_ms_indeed \to \everyenableelements \appendtoks - \let\mo \taggedmathmo - \let\mi \taggedmathmi - \let\mn \taggedmathmn - \let\ms \taggedmathms - \let\apply\taggedmathapply + \let\mo \math_tags_mo + \let\mi \math_tags_mi + \let\mn \math_tags_mn + \let\ms \math_tags_ms + \let\apply\math_tags_apply \to\everymathematics % \def\mlimitsfunction #1{\mathlimopcomm{{\mr#1}} @@ -410,18 +437,18 @@ \def\currentmscaledstyle{rm} % will be plugged into the typeface text=ss option -\unexpanded\def\do@mathopnolimits #1{\mathop{\mscaledtext{#1}}\nolimits} -\unexpanded\def\do@mfunction #1{\mscaledtext{\taggedmathfunction{#1}}} -\unexpanded\def\do@mfunctionlabeltext#1{\mscaledtext{\taggedmathfunctionlabeltext{#1}}} +\unexpanded\def\math_function_style_opnolimits #1{\mathop{\mscaledtext{#1}}\nolimits} +\unexpanded\def\math_function_style_mfunction #1{\mscaledtext{\math_tags_function{#1}}} +\unexpanded\def\math_function_style_mfunctionlabeltext#1{\mscaledtext{\math_tags_functionlabeltext{#1}}} -\def\setmathfunctionstyle#1% rm ss tt (can be made faster if needed) +\unexpanded\def\setmathfunctionstyle#1% rm ss tt (can be made faster if needed) {\doifsomething{#1} {\def\currentmscaledstyle{#1}% - \let\mathopnolimits \do@mathopnolimits - \let\mfunction \do@mfunction - \let\mfunctionlabeltext\do@mfunctionlabeltext}} + \let\mathopnolimits \math_function_style_opnolimits + \let\mfunction \math_function_style_mfunction + \let\mfunctionlabeltext\math_function_style_mfunctionlabeltext}} -\def\mscaledtext#1% +\unexpanded\def\mscaledtext#1% {\mathchoice {\hbox{\csname\currentmscaledstyle\endcsname\tf #1}} {\hbox{\csname\currentmscaledstyle\endcsname\tf #1}} @@ -455,7 +482,7 @@ %D Some goodies: -\def\Angstrom{\nomathematics{\Aring}} +\unexpanded\def\Angstrom{\nomathematics{\Aring}} %D \macros %D {nonknuthmode, donknuthmode} @@ -510,16 +537,98 @@ % \let_\activemathunderscore % \to \everymathematics % \egroup + +% Here follows some plain legacy: primes. +% +% The \let\prime\math_prime_indeed might become an obsolete as we have +% \doubleprime and \tripleprime and collapsing can nicely handle the +% script then. % -% plain tex legacy: +% Collapsing to 0x2033 and 0x2034 happens elsewhere. + +% \switchtobodyfont[modern] +% \switchtobodyfont[cambria] +% \switchtobodyfont[xits] +% \switchtobodyfont[minion] +% \setupbodyfont[dejavu] +% +% \startbuffer +% \def\SampleLine#1{% +% \NC#1 +% \NC\switchtobodyfont[#1]$f^2$ % 1 +% \NC\switchtobodyfont[#1]$f\prime^2$ % 2 +% \NC\switchtobodyfont[#1]$f\prime\prime^2$ % 3 +% \NC\switchtobodyfont[#1]$f\prime\prime\prime^2$ % 4 +% \NC\switchtobodyfont[#1]$f{\prime}^2$ % 5 +% \NC\switchtobodyfont[#1]$f{\prime\prime}^2$ % 6 +% \NC\switchtobodyfont[#1]$f{\prime\prime\prime}^2$ % 7 +% \NC\switchtobodyfont[#1]$f'(x)$ % 8 +% \NC\switchtobodyfont[#1]$f''(x)$ % 9 +% \NC\switchtobodyfont[#1]$f'''(x)$ % 10 +% \NC\NR +% } +% +% \starttabulate[|Tl|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tc|] +% \NC\NC1\NC2\NC3\NC4\NC5\NC6\NC7\NC8\NC9\NC10\NC\NR +% \SampleLine{modern} +% \SampleLine{cambria} +% \SampleLine{xits} +% \SampleLine{minion} +% \stoptabulate +% \stopbuffer +% +% \typebuffer \getbuffer + +{ \catcode\circumflexasciicode\othercatcode \global\let\othercircumflextoken ^ } +{ \catcode\circumflexasciicode\superscriptcatcode \global\let\superscriptcircumflextoken^ } + +\ifdefined \prime \else + \Umathchardef\prime "0 "0 "2032 +\fi + +\let\math_prime_indeed_normal\prime + +\appendtoks + \let\math_prime_indeed_normal\prime % gets defined later + \let\prime\math_prime_indeed % so this is needed +\to \everydump + +\unexpanded\def\math_prime_indeed + {\iffontchar\textfont\zerocount"FE325\relax + ^\bgroup + \expandafter\math_prime_indeed_virtual % virtual mess (using funny signal) + \else + \expandafter\math_prime_indeed_normal % gets collapsed + \fi} + +\let\prime\math_prime_indeed + +\installcorenamespace{mathprime} + +\def\math_prime_indeed_virtual + {\math_prime_indeed_normal\futurelet\nexttoken\math_prime_indeed_choice} + +\def\math_prime_indeed_choice + {\csname\??mathprime + \ifx '\nexttoken a\else + \ifx \math_prime_indeed_normal\nexttoken a\else + \ifx \prime\nexttoken a\else + \ifx\superscriptcircumflextoken\nexttoken b\else + \ifx\othercircumflextoken \nexttoken b\else + c\fi\fi\fi\fi\fi + \endcsname} + +\setvalue{\??mathprime a}#1{\math_prime_indeed_virtual} +\setvalue{\??mathprime b}#1#2{#2\egroup} +\setvalue{\??mathprime c}{\egroup} + +\let\activemathprime\math_prime_indeed \bgroup \catcode\primeasciicode\activecatcode - \doglobal\appendtoks - \let'\domathprime % todo: do this at the lua end - \to \everymathematics + \global\everymathematics\expandafter{\the\everymathematics\let'\math_prime_indeed} % todo: do this at the lua end \egroup @@ -646,9 +755,9 @@ %D Memory saver: \appendtoks - \doifelse{\mathematicsparameter\c!compact}\v!yes - {\enabledirectives [math.virtual.optional]}% - {\disabledirectives[math.virtual.optional]}% + \ifx\currentmathematics\empty + \doifelse{\mathematicsparameter\c!compact}\v!yes\enabledirectives\disabledirectives[math.virtual.optional]% + \fi \to \everysetupmathematics \setupmathematics @@ -659,10 +768,8 @@ \newconditional\c_math_right_to_left \appendtoks - \doifelse{\mathematicsparameter\c!align}{r2l}% - {\settrue \c_math_right_to_left}% - {\setfalse\c_math_right_to_left}% -\to \everysetupmathematics + \doifelse{\mathematicsparameter\c!align}{r2l}\settrue\setfalse\c_math_right_to_left +\to \everyswitchmathematics \unexpanded\def\math_basics_synchronize_direction {\mathdir T\ifconditional\c_math_right_to_left R\else L\fi T} @@ -670,7 +777,7 @@ \appendtoks \math_basics_synchronize_direction %to \everymathematics % comes too late and I'm not in the mood for a mixed mode kludge now -\to \everysetupmathematics +\to \everyswitchmathematics %D Delayed: greek. %D @@ -683,48 +790,87 @@ % [lc uc] normal (upright) = 2, italic = 3, none = 0/1 -\setevalue{\??mo:greek:\v!normal :\v!normal}{\attribute\mathgreekattribute22 } -\setevalue{\??mo:greek:\v!normal :\v!italic}{\attribute\mathgreekattribute23 } -\setevalue{\??mo:greek:\v!normal :\v!none }{\attribute\mathgreekattribute21 } +% We can move the setting to the lua end and use abstract numbers instead +% if funny ones here. -\setevalue{\??mo:greek:\v!italic :\v!normal}{\attribute\mathgreekattribute32 } -\setevalue{\??mo:greek:\v!italic :\v!italic}{\attribute\mathgreekattribute33 } -\setevalue{\??mo:greek:\v!italic :\v!none }{\attribute\mathgreekattribute31 } +\installcorenamespace{mathgreek} -\setevalue{\??mo:greek:\v!none :\v!normal}{\attribute\mathgreekattribute12 } -\setevalue{\??mo:greek:\v!none :\v!italic}{\attribute\mathgreekattribute13 } -\setevalue{\??mo:greek:\v!none :\v!none }{\attribute\mathgreekattribute\attributeunsetvalue} +\newconstant\c_math_greek_attribute + +\setvalue{\??mathgreek\v!normal :\v!normal}{22} +\setvalue{\??mathgreek\v!normal :\v!italic}{23} +\setvalue{\??mathgreek\v!normal :\v!none }{21} + +\setvalue{\??mathgreek\v!italic :\v!normal}{32} +\setvalue{\??mathgreek\v!italic :\v!italic}{33} +\setvalue{\??mathgreek\v!italic :\v!none }{31} + +\setvalue{\??mathgreek\v!none :\v!normal}{12} +\setvalue{\??mathgreek\v!none :\v!italic}{13} +\letvalue{\??mathgreek\v!none :\v!none }\attributeunsetvalue \appendtoks - \csname\??mo:greek:\@@molcgreek:\@@moucgreek\endcsname -\to \everymathematics + \edef\p_lcgreek_ucgreek{\mathematicsparameter\s!lcgreek:\mathematicsparameter\s!ucgreek}% + \c_math_greek_attribute\csname\??mathgreek + \ifcsname\??mathgreek\p_lcgreek_ucgreek\endcsname\p_lcgreek_ucgreek\else\v!none\fi + \endcsname\relax +\to \everyswitchmathematics -% todo: field specific sets in order to avoid option mess +\appendtoks + \attribute\mathgreekattribute\c_math_greek_attribute +\to \everymathematics \setupmathematics - [lcgreek=\v!italic, - ucgreek=\v!normal] % was: none + [\s!lcgreek=\v!italic, + \s!ucgreek=\v!normal] % was: none %D Math italics (experiment) % we need keys -\setevalue{\??mo:italics:1}{\attribute\mathitalicsattribute\plusone } % fontitalics -\setevalue{\??mo:italics:2}{\attribute\mathitalicsattribute\plustwo } % fontdata -\setevalue{\??mo:italics:3}{\attribute\mathitalicsattribute\plusthree} % quad based -\setevalue{\??mo:italics:4}{\attribute\mathitalicsattribute\plusfour } % combination of 1 and 3 +\installcorenamespace{mathitalics} -\setupmathematics - [italics=] +\setnewconstant\c_math_italics_attribute\attributeunsetvalue + +\letvalue{\??mathitalics 1}\plusone % fontitalics +\letvalue{\??mathitalics 2}\plustwo % fontdata +\letvalue{\??mathitalics 3}\plusthree % quad based +\letvalue{\??mathitalics 4}\plusfour % combination of 1 and 3 +\letvalue{\??mathitalics\v!none}\attributeunsetvalue + +\def\math_italics_initialize + {\ifnum\c_math_italics_attribute=\attributeunsetvalue \else + \ctxcommand{setmathitalics()}% one time + \global\let\math_italics_initialize\relax + \fi} \appendtoks - \doifsomething\@@moitalics{\ctxlua{mathematics.setitalics()}}% -\to \everysetupmathematics + \edef\p_italics{\mathematicsparameter\s!italics}% + \c_math_italics_attribute\csname\??mathitalics + \ifcsname\??mathitalics\p_italics\endcsname\p_italics\else\v!none\fi + \endcsname\relax + \math_italics_initialize +\to \everyswitchmathematics % only in mathematics \appendtoks - \csname\??mo:italics:\@@moitalics\endcsname + \attribute\mathitalicsattribute\c_math_italics_attribute \to \everymathematics +\setupmathematics + [\s!italics=] + +% looks nicer but can generate bogus csnames +% +% \setvalue{\??mathitalics1}{\math_italics_initialize\c_math_italics_attribute\plusone } % fontitalics +% \setvalue{\??mathitalics2}{\math_italics_initialize\c_math_italics_attribute\plustwo } % fontdata +% \setvalue{\??mathitalics3}{\math_italics_initialize\c_math_italics_attribute\plusthree} % quad based +% \setvalue{\??mathitalics4}{\math_italics_initialize\c_math_italics_attribute\plusfour } % combination of 1 and 3 +% +% \appendtoks +% \c_math_italics_attribute\attributeunsetvalue +% \csname\??mathitalics\mathematicsparameter\s!italics\endcsname +% \to \everyswitchmathematics % only in mathematics + %D \macros %D {enablemathpunctuation,disablemathpunctuation} %D @@ -736,16 +882,14 @@ %D %D \blank{\getbuffer}\blank -\setfalse \automathpunctuation - -\def\enablemathpunctuation {\settrue \automathpunctuation} -\def\disablemathpunctuation{\setfalse\automathpunctuation} +\newconditional\automathpunctuation -\ifx\v!autopunctuation\undefined \def\v!autopunctuation{autopunctuation} \fi +\unexpanded\def\enablemathpunctuation {\settrue \automathpunctuation} +\unexpanded\def\disablemathpunctuation{\setfalse\automathpunctuation} \appendtoks - \doifelse{\mathematicsparameter\v!autopunctuation}\v!yes\enablemathpunctuation\disablemathpunctuation -\to \everysetupmathematics + \doifelse{\mathematicsparameter\v!autopunctuation}\v!yes\settrue\setfalse\automathpunctuation +\to \everyswitchmathematics \appendtoks \ifconditional\automathpunctuation\attribute\mathpunctuationattribute\plusone\fi @@ -753,7 +897,7 @@ \setupmathematics [\v!autopunctuation=\v!no] - + %D \macros %D {mathstyle} %D @@ -818,14 +962,6 @@ % error \fi} -\def\cramped#1% - {{\ifcase\normalmathstyle - \crampeddisplaystyle \or \or % 0 -> 1 - \crampedtextstyle \or \or % 2 -> 3 - \crampedscriptstyle \or \or % 4 -> 5 - \crampedscriptscriptstyle \fi % 6 -> 7 - #1}} - \def\mathstylefont#1% #1 is number (\normalmathstyle) {\ifcase#1\relax \textfont \or @@ -839,22 +975,31 @@ \textfont \fi\zerocount} +%D A plain inheritance: + +\def\mathpalette#1#2% + {\mathchoice + {#1\displaystyle {#2}}% + {#1\textstyle {#2}}% + {#1\scriptstyle {#2}}% + {#1\scriptscriptstyle{#2}}} + %D Something similar can be used in the (re|)|definition %D of \type {\text}. This version is a variation on the one %D in the math module (see \type{m-math} and|/|or \type %D {m-newmat}). \unexpanded\def\mathtext - {\mathortext\domathtext\hbox} + {\mathortext\math_text_choice\hbox} -\def\domathtext#1% +\def\math_text_choice#1% {\mathchoice - {\dodomathtext\displaystyle\textface {#1}}% - {\dodomathtext\textstyle \textface {#1}}% - {\dodomathtext\textstyle \scriptface {#1}}% - {\dodomathtext\textstyle \scriptscriptface{#1}}} + {\math_text_choice_indeed\displaystyle\textface {#1}}% + {\math_text_choice_indeed\textstyle \textface {#1}}% + {\math_text_choice_indeed\textstyle \scriptface {#1}}% + {\math_text_choice_indeed\textstyle \scriptscriptface{#1}}} -\def\dodomathtext#1#2#3% no \everymath ! +\def\math_text_choice_indeed#1#2#3% no \everymath ! %{\hbox{\everymath{#1}\switchtobodyfont [#2]#3}} % 15 sec {\hbox{\everymath{#1}\setcurrentfontbody{#2}#3}} % 3 sec (no math) @@ -869,36 +1014,57 @@ \appendtoks \let\text\mathtext \to \everymathematics -%D The next code is derived from plain \TEX. +%D The next code is derived from plain \TEX. The names will change! -\newcount\interdisplaylinepenalty \interdisplaylinepenalty=100 +\newcount\interdisplaylinepenalty \interdisplaylinepenalty\plushundred -\newif\ifdt@p +% Actually, not using an if saves one macro so there is no penalty +% for splitting up this macro. +% +% \newif\ifdt@p +% +% \def\displ@y +% {\global\dt@ptrue +% \openup\displayopenupvalue % was \openup\jot +% \everycr +% {\noalign +% {\ifdt@p +% \global\dt@pfalse +% \ifdim\prevdepth>-\thousandpoint +% \vskip-\lineskiplimit +% \vskip\normallineskiplimit +% \fi +% \else +% \penalty\interdisplaylinepenalty +% \fi}}} + +\newtoks\mathdisplayaligntweaks -\def\displ@y - {\global\dt@ptrue +\appendtoks + \resetdisplaymatheq % moved to here +\to \mathdisplayaligntweaks + +\unexpanded\def\math_display_align_hack % I don't like the global, maybe we should push and pop + {\global\let\math_display_align_hack_indeed\math_display_align_hack_remove_skip \openup\displayopenupvalue % was \openup\jot - \everycr - {\noalign - {\ifdt@p - \global\dt@pfalse - \ifdim\prevdepth>-\thousandpoint - \vskip-\lineskiplimit - \vskip\normallineskiplimit - \fi - \else - \penalty\interdisplaylinepenalty - \fi}}} + \everycr{\noalign{\math_display_align_hack_indeed}}} -\let\normaldispl@y\displ@y +\def\math_display_align_hack_remove_skip + {\ifdim\prevdepth>-\thousandpoint + \vskip\dimexpr-\lineskiplimit+\normallineskiplimit\relax + \fi + \global\let\math_display_align_hack_indeed\math_display_align_hack_insert_penalty} -\def\displ@y{\resetdisplaymatheq\normaldispl@y} +\def\math_display_align_hack_insert_penalty + {\penalty\interdisplaylinepenalty} -\def\m@th{\mathsurround\zeropoint} % obsolete +\appendtoks + \math_display_align_hack +\to \mathdisplayaligntweaks %D Text in math: -\def\mathortext +\unexpanded\def\mathortext {\ifmmode \expandafter\firstoftwoarguments \else @@ -911,7 +1077,7 @@ \ifx\text\undefined \let\text\hbox \fi -\def\mathoptext#1{\mathop{\text{#1}}} +\unexpanded\def\mathoptext#1{\mathop{\text{#1}}} % for a while: diff --git a/tex/context/base/math-inl.mkiv b/tex/context/base/math-inl.mkiv index f3a59d956..2c7284458 100644 --- a/tex/context/base/math-inl.mkiv +++ b/tex/context/base/math-inl.mkiv @@ -15,12 +15,8 @@ \unprotect -% Obsolete, as we do snapping differently now. - -\def\snappedinlineformula {\dosingleempty\dosnappedinlineformula} -\def\dosnappedinlineformula[#1]#2{\mathematics{#2}} -\let\tform \mathematics -\let\gform \snappedinlineformula -\let\enableautomath \relax +% The \MKII\ math grid snapping code has gone. A pity as it was rather effective +% and worked quite well (for a couple of projects where it was demanded). Other code +% might show up / move here. \protect \endinput diff --git a/tex/context/base/math-int.mkiv b/tex/context/base/math-int.mkiv index 97fd48214..84c51cb24 100644 --- a/tex/context/base/math-int.mkiv +++ b/tex/context/base/math-int.mkiv @@ -36,7 +36,7 @@ %D Adapted to mkiv by HH from code by AM. -\ifx\v!integral\undefined \def\v!integral{integral} \fi +\installcorenamespace{mathintegral} \newconstant\mathintlimitmode % 0 nolimits 1 displaylimits 2 limits @@ -49,13 +49,13 @@ \limits \fi} -\letvalue{\??mo::\v!integral::nolimits}\zerocount -\letvalue{\??mo::\v!integral::displaylimits}\plusone -\letvalue{\??mo::\v!integral::limits}\plustwo +\letvalue{\??mathintegral nolimits}\zerocount +\letvalue{\??mathintegral displaylimits}\plusone +\letvalue{\??mathintegral limits}\plustwo \appendtoks - \mathintlimitmode\executeifdefined{\??mo::\v!integral::\@@mointegral}\zerocount -\to \everysetupmathematics + \mathintlimitmode\executeifdefined{\??mathintegral\mathematicsparameter\s!integral}\zerocount +\to \everyswitchmathematics \setupmathematics [\v!integral=nolimits] diff --git a/tex/context/base/math-pln.mkiv b/tex/context/base/math-pln.mkiv index bd5b7ce79..b862bb4cb 100644 --- a/tex/context/base/math-pln.mkiv +++ b/tex/context/base/math-pln.mkiv @@ -11,201 +11,45 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D This is a temporary module, some of this code will move to -%D the other math modules. Much is copied from Plain \TEX. - -% \points should become \bodyfontsize +%D Here we collect some Plain \TEX\ leftovers. \writestatus{loading}{ConTeXt Math Macros / Plain Helpers} \unprotect -\ifx\displ@y\undefined \let\displ@y\relax\fi +% we need proper unicode: + +\def\relbar{\mathrel{\smash-}} % - has the same height as + .. no clue what this refers to + +% might change + +\unexpanded\def\hrulefill{\leaders\hrule\hfill} +\unexpanded\def\dotfill {\cleaders\hbox{$\mathsurround\zeropoint\mkern1.5mu.\mkern1.5mu$}\hfill} + +% will move \def\oalign#1% {\leavevmode \vtop - {\baselineskip\zeroskip \lineskip.25ex% + {\baselineskip\zeroskip + \lineskip.25\exheight \ialign{##\crcr#1\crcr}}} -\def\o@lign - {\lineskiplimit\zeropoint \oalign} - \def\ooalign % chars over each other {\lineskiplimit-\maxdimen \oalign} -\def\sh@ft#1% kern by #1 times the current slant - {\dimen@#1% - \kern\expandafter\withoutpt\the\slantperpoint - \dimen@} - -\def\dots - {\relax\ifmmode\ldots\else$\mathsurround\zeropoint\ldots\,$\fi} - -\def\hrulefill - {\leaders\hrule\hfill} - -\def\dotfill - {\cleaders\hbox{$\mathsurround\zeropoint \mkern1.5mu.\mkern1.5mu$}\hfill} - -\def\rightarrowfill - {$\mathsurround\zeropoint\smash-\mkern-7mu% - \cleaders\hbox{$\mkern-2mu\smash-\mkern-2mu$}\hfill - \mkern-7mu\mathord\rightarrow$} - -\def\leftarrowfill - {$\mathsurround\zeropoint\mathord\leftarrow\mkern-7mu% - \cleaders\hbox{$\mkern-2mu\smash-\mkern-2mu$}\hfill - \mkern-7mu\smash-$} - -% \let\sp=^ % obsolete -% \let\sb=_ % obsolete - -\ifx\,\undefined \def\,{\mskip \thinmuskip } \fi -\ifx\>\undefined \def\>{\mskip \medmuskip } \fi -\ifx\;\undefined \def\;{\mskip \thickmuskip} \fi -\ifx\!\undefined \def\!{\mskip-\thinmuskip } \fi -\ifx\*\undefined \def\*{\discretionary{\thinspace\the\textfont2\char2}{}{}} \fi - -% \switchtobodyfont[modern] -% \switchtobodyfont[cambria] -% \switchtobodyfont[xits] -% \switchtobodyfont[minion] -% \setupbodyfont[dejavu] -% -% \startbuffer -% \def\SampleLine#1{% -% \NC#1 -% \NC\switchtobodyfont[#1]$f^2$ % 1 -% \NC\switchtobodyfont[#1]$f\prime^2$ % 2 -% \NC\switchtobodyfont[#1]$f\prime\prime^2$ % 3 -% \NC\switchtobodyfont[#1]$f\prime\prime\prime^2$ % 4 -% \NC\switchtobodyfont[#1]$f{\prime}^2$ % 5 -% \NC\switchtobodyfont[#1]$f{\prime\prime}^2$ % 6 -% \NC\switchtobodyfont[#1]$f{\prime\prime\prime}^2$ % 7 -% \NC\switchtobodyfont[#1]$f'(x)$ % 8 -% \NC\switchtobodyfont[#1]$f''(x)$ % 9 -% \NC\switchtobodyfont[#1]$f'''(x)$ % 10 -% \NC\NR -% } -% -% \starttabulate[|Tl|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tc|] -% \NC\NC1\NC2\NC3\NC4\NC5\NC6\NC7\NC8\NC9\NC10\NC\NR -% \SampleLine{modern} -% \SampleLine{cambria} -% \SampleLine{xits} -% \SampleLine{minion} -% \stoptabulate -% \stopbuffer -% -% \typebuffer \getbuffer - -{ \catcode\circumflexasciicode\othercatcode \global\let\othercircumflextoken ^ } -{ \catcode\circumflexasciicode\superscriptcatcode \global\let\superscriptcircumflextoken^ } - -% collapsing to 0x2033 and 0x2034 happens elsewhere - -\ifdefined \prime \else - \Umathchardef\prime "0 "0 "2032 -\fi - -\let\normalprime\prime - -% The \let\prime\domathprime might become an obsolete as we have \doubleprime and \tripleprime -% and collapsing can nicely handle the script then - -\appendtoks - \let\normalprime\prime % gets defined later - \let\prime\domathprime % so this is needed -\to \everydump - -\unexpanded\def\domathprime - {\iffontchar\textfont\zerocount"FE325\relax - ^\bgroup\expandafter\dodomathprime % virtual mess (using funny signal) - \else - \expandafter\normalprime % gets collapsed - \fi} - -\let\prime\domathprime - -\def\dodomathprime - {\normalprime\futurelet\nexttoken\dododomathprime} - -\def\dododomathprime - {\csname domathprime@% - \ifx '\nexttoken a\else - \ifx \normalprime\nexttoken a\else - \ifx \prime\nexttoken a\else - \ifx\superscriptcircumflextoken\nexttoken b\else - \ifx\othercircumflextoken \nexttoken b\else - c\fi\fi\fi\fi\fi - \endcsname} - -\def\domathprime@a #1{\dodomathprime} -\def\domathprime@b#1#2{#2\egroup} -\def\domathprime@c {\egroup} - -\let\activemathprime\domathprime - -% {\catcode`\_=\activecatcode \global\let_=\_} % _ in math is either subscript or \_ - -\let\activemathunderscore\_ - -\def\relbar {\mathrel{\smash-}} % - has the same height as + -\def\Relbar {\mathrel=} - -\def\Longrightarrow {\Relbar\joinrel\Rightarrow} % beware, this overloades cambria native -\def\longrightarrow {\relbar\joinrel\rightarrow} -\def\longleftarrow {\leftarrow\joinrel\relbar} -\def\Longleftarrow {\Leftarrow\joinrel\Relbar} -\def\longmapsto {\mapstochar\longrightarrow} -\def\longleftrightarrow{\leftarrow\joinrel\rightarrow} -\def\Longleftrightarrow{\Leftarrow\joinrel\Rightarrow} +% needs checking \def\choose{\atopwithdelims()} \def\brack {\atopwithdelims[]} \def\brace {\atopwithdelims\{\}} -\def\mathpalette#1#2% - {\mathchoice - {#1\displaystyle {#2}}% - {#1\textstyle {#2}}% - {#1\scriptstyle {#2}}% - {#1\scriptscriptstyle{#2}}} - -\def\cong - {\mathrel{\mathpalette\@vereq\sim}} % congruence sign - -\def\@vereq#1#2% - {\lower.5\points\vbox{\lineskiplimit\maxdimen\lineskip-.5\points - \ialign{$\mathsurround\zeropoint#1\hfil##\hfil$\crcr#2\crcr=\crcr}}} - -\def\notin - {\mathrel{\mathpalette\c@ncel\in}} - -\def\c@ncel#1#2% - {\mathsurround\zeropoint\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}} - -\def\rightleftharpoons - {\mathrel{\mathpalette\rlh@{}}} - -\def\rlh@#1% - {\vcenter - {\mathsurround\zeropoint - \hbox - {\ooalign - {\raise2pt\hbox{$#1\rightharpoonup$}\crcr - $#1\leftharpoondown$}}}} +% needs checking -\def\buildrel#1\over#2% +\unexpanded\def\buildrel#1\over#2% {\mathrel{\mathop{\kern\zeropoint#2}\limits^{#1}}} -\def\doteq - {\buildrel\textstyle.\over=} - -\ifx\mfunction\undefined \def\mfunction#1{\mathbin{\rm#1}} \fi - \unexpanded\def\bmod {\nonscript \mskip-\medmuskip @@ -219,11 +63,11 @@ \unexpanded\def\pmod#1% {\allowbreak \mkern18mu - (\mfunction{mod}\,\,#1)} + (\mfunction{mod}\mskip\medmuskip#1)} \unexpanded\def\cases#1% {\left\{% - \,% + \mskip\thinmuskip \vcenter {\normalbaselines \mathsurround\zeropoint @@ -232,114 +76,30 @@ \unexpanded\def\matrix#1% {\emptyhbox - \,% + \mskip\thinmuskip \vcenter {\normalbaselines\mathsurround\zeropoint \ialign{\hfil$##$\hfil&&\quad\hfil$##$\hfil\crcr \mathstrut\crcr\noalign{\kern-\baselineskip} #1\crcr\mathstrut\crcr\noalign{\kern-\baselineskip}}}% - \,} + \mskip\thinmuskip} \unexpanded\def\pmatrix#1% {\left(\matrix{#1}\right)} -\newdimen\mathparentwd - -% \setbox0=\hbox{\tenex B} \mathparentwd=\wd0 % width of the big left ( - -\unexpanded\def\bordermatrix#1% - {\begingroup - \mathsurround\zeropoint - \setbox\zerocount\vbox - {\def\cr{\crcr\noalign{\kern2\points\global\let\cr\endline}}% - \ialign{$##$\hfil\kern2\points\kern\mathparentwd&\thinspace\hfil$##$\hfil - &&\quad\hfil$##$\hfil\crcr - \omit\strut\hfil\crcr\noalign{\kern-\baselineskip}% - #1\crcr\omit\strut\cr}}% - \setbox\plustwo\vbox - {\unvcopy\zerocount\global\setbox\plusone\lastbox}% - \setbox\plustwo\hbox - {\unhbox\plusone\unskip\global\setbox\plusone\lastbox}% - \setbox\plustwo\hbox - {$\kern\wd\plusone\kern-\mathparentwd\left(\kern-\wd\plusone - \global\setbox\plusone\vbox{\box\plusone\kern2\points}% - \vcenter{\kern-\ht\plusone\unvbox\zerocount\kern-\baselineskip}\,\right)$}% - \emptyhbox - \;% - \vbox{\kern\ht\plusone\box\plustwo}% - \endgroup} - -% \def\openup{\afterassignment\@penup\dimen@=} -% -% \def\@penup{\advance\lineskip\dimen@ -% \advance\baselineskip\dimen@ -% \advance\lineskiplimit\dimen@} - \unexpanded\def\openup - {\afterassignment\doopenup\scratchdimen=} + {\afterassignment\math_openup\scratchdimen=} -\def\doopenup +\def\math_openup {\advance\lineskip \scratchdimen \advance\baselineskip \scratchdimen \advance\lineskiplimit\scratchdimen} -% \def\jot{.25\bodyfontsize} % plain tex: 3 pt (todo: better name and configurable) - -\def\displayopenupvalue{.25\bodyfontsize} - -\unexpanded\def\eqalign#1% - {\emptyhbox - \,% - \vcenter - {\openup\displayopenupvalue % was \openup\jot - \mathsurround\zeropoint - \ialign - {\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil\crcr - #1\crcr}}% - \,} - -\def\@lign % restore inside \displ@y - {\tabskip\zeroskip - \everycr{}} - \unexpanded\def\displaylines#1% - {\displ@y + {\the\mathdisplayaligntweaks \tabskip\zeroskip \halign - {\hbox to \displaywidth{$\@lign\hfil\displaystyle##\hfil$}\crcr - #1\crcr}} - -\def\eqalignno#1% \unexpanded (needs testing in alignments) - {\displ@y - \tabskip\centering - \halign to \displaywidth - {\hfil$\@lign\displaystyle{##}$\tabskip\zeroskip - &$\@lign\displaystyle{{}##}$\hfil\tabskip\centering - &\llap{$\@lign##$}\tabskip\zeroskip\crcr - #1\crcr}} - -\def\leqalignno#1% \unexpanded (needs testing in alignments) - {\displ@y - \tabskip\centering - \halign to \displaywidth - {\hfil$\@lign\displaystyle{##}$\tabskip\zeroskip - &$\@lign\displaystyle{{}##}$\hfil\tabskip\centering - &\kern-\displaywidth\rlap{$\@lign##$}\tabskip\displaywidth\crcr + {\hbox to \displaywidth{$\tabskip\zeroskip\everycr\emptytoks\hfil\displaystyle##\hfil$}\crcr #1\crcr}} -% temporary here (weird code) - -% \startcatcodetable \mthcatcodes -% \setcatcodetable\ctxcatcodes -% \catcode`\_ = 13 -% \catcode`\' = 13 -% \stopcatcodetable -% -% \letcatcodecommand \mthcatcodes `\_ \activemathunderscore -% \letcatcodecommand \mthcatcodes `\' \activemathquote - -% \appendtoks \setcatcodetable\mthcatcodes \to \everymath : spoils xml - -% so far - \protect \endinput diff --git a/tex/context/base/math-ren.lua b/tex/context/base/math-ren.lua index 10456ad05..2e7dba13d 100644 --- a/tex/context/base/math-ren.lua +++ b/tex/context/base/math-ren.lua @@ -60,6 +60,10 @@ end mathematics.renderset = renderset +function commands.mathrenderset(list) + context(renderset(list)) +end + -- function commands.setmatrendering(list) -- tex.setattribute(renderset(list)) -- end diff --git a/tex/context/base/math-scr.mkiv b/tex/context/base/math-scr.mkiv index 9ab61911b..2decaa81f 100644 --- a/tex/context/base/math-scr.mkiv +++ b/tex/context/base/math-scr.mkiv @@ -15,57 +15,40 @@ \unprotect -%D These macros were first needed by Frits Spijker (also -%D known as Gajes) for typesetting the minus sign that is -%D keyed into scientific calculators. +%D These macros were first needed by Frits (Gajes) Spijker +%D (of the Math4All project that we participate in), and used +%D for typesetting the minus sign that is keyed into scientific +%D calculators. We use the monospaced signs, that we also define +%D as symbol, so that they can be overloaded. -% This is the first alternative, which works okay for the -% minus, but less for the plus. -% -% \def\dodoraisedmathord#1#2#3% -% {\mathord{{#2\raise.#1ex\hbox{#2#3}}}} -% -% \def\doraisedmathord#1% -% {\mathchoice -% {\dodoraisedmathord5\tf #1}% -% {\dodoraisedmathord5\tf #1}% -% {\dodoraisedmathord4\tfx #1}% -% {\dodoraisedmathord3\tfxx#1}} -% -% \def\negative{\doraisedmathord-} -% \def\positive{\doraisedmathord+} -% -% So, now we use the monospaced signs, that we also -% define as symbol, so that they can be overloaded. +\def\math_scripts_raised_symbol#1% + {\mathchoice + {\math_scripts_raised_symbol_indeed5\tf {#1}}% + {\math_scripts_raised_symbol_indeed5\tf {#1}}% + {\math_scripts_raised_symbol_indeed4\tx {#1}}% + {\math_scripts_raised_symbol_indeed3\txx{#1}}} -\def\dodoraisedmathord#1#2#3% +\def\math_scripts_raised_symbol_indeed#1#2#3% {\mathord{{#2\raise.#1ex\hbox{#2\symbol[#3]}}}} -\def\doraisedmathord#1% +\def\math_scripts_raised_number#1% {\mathchoice - {\dodoraisedmathord5\tf {#1}}% - {\dodoraisedmathord5\tf {#1}}% - {\dodoraisedmathord4\tx {#1}}% - {\dodoraisedmathord3\txx{#1}}} + {\math_scripts_raised_number_indeed\tf {#1}}% + {\math_scripts_raised_number_indeed\tf {#1}}% + {\math_scripts_raised_number_indeed\tx {#1}}% + {\math_scripts_raised_number_indeed\txx{#1}}} -\def\dodonumbermathord#1#2% +\def\math_scripts_raised_number_indeed#1#2% {\setbox\scratchbox\hbox{0}% \mathord{\hbox to \wd\scratchbox{\hss#1\symbol[#2]\hss}}} -\def\donumbermathord#1% - {\mathchoice - {\dodonumbermathord\tf {#1}}% - {\dodonumbermathord\tf {#1}}% - {\dodonumbermathord\tx {#1}}% - {\dodonumbermathord\txx{#1}}} - \definesymbol[positive] [\getglyph{Mono}{+}] \definesymbol[negative] [\getglyph{Mono}{-}] \definesymbol[zeroamount][\getglyph{Mono}{-}] -\def\negative {\doraisedmathord{negative}} -\def\positive {\doraisedmathord{positive}} -\def\zeroamount{\donumbermathord{zeroamount}} +\unexpanded\def\negative {\math_scripts_raised_symbol{negative}} +\unexpanded\def\positive {\math_scripts_raised_symbol{positive}} +\unexpanded\def\zeroamount{\math_scripts_raised_number{zeroamount}} %D How negative such a symbol looks is demonstrated in: %D $\negative 10^{\negative 10^{\negative 10}}$. diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index 2aa59e714..af36a1e19 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -338,9 +338,10 @@ \unexpanded\def#2{\dodoubleempty#4}% \unexpanded\def#5{\mult_interfaces_get_parameters{#1#3:}}} -\unexpanded\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7% +\unexpanded\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8% {\newtoks#5% \newconstant#2% + \newtoks#8% \ifx#6\relax\let#6\empty\fi \def#4[##1][##2]% maybe helper {\ifsecondargument % no commalist here @@ -351,6 +352,7 @@ #2\doingrootsetupnamed \mult_interfaces_get_parameters{#1#3:}[##2]% \the#5% + \ifx#3#6\the#8\fi % only switchsetups if previous == current \let#3#7% \else\iffirstargument \mult_check_for_assignment##1=@@\_end_ % \docheckassignment{##1}% @@ -362,6 +364,7 @@ #2\doingrootsetuproot \mult_interfaces_get_parameters{#1:}[##1]% \the#5% + \the#8% switchsetups \let#3#7% \else % \setuplayout[whatever] @@ -369,6 +372,7 @@ \edef#3{##1}% this will catch reset so one needs to test for it #2\doingrootsetnamed \the#5% % we can check for previous vs current + \the#8% switchsetups \fi \else % \setuplayout @@ -376,6 +380,7 @@ \let#3\empty % current becomes empty #2\doingrootsetroot \the#5% + \the#8% switchsetups \fi\fi #2\zerocount}} % mode is always zero at the end @@ -394,8 +399,8 @@ \expandafter\noexpand\csname setup_#2\endcsname % semi-public \expandafter\noexpand\csname everysetup#2\endcsname \expandafter\noexpand\csname previous#2\endcsname - \expandafter\noexpand\csname saved_setup_current#2\endcsname}} - + \expandafter\noexpand\csname saved_setup_current#2\endcsname + \expandafter\noexpand\csname everyswitch#2\endcsname}} \unexpanded\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8% {\ifx#3\relax\let#3\empty\fi diff --git a/tex/context/base/mult-ini.lua b/tex/context/base/mult-ini.lua index 8769641fa..edaa72459 100644 --- a/tex/context/base/mult-ini.lua +++ b/tex/context/base/mult-ini.lua @@ -157,7 +157,7 @@ function interfaces.showmessage(category,tag,arguments) if type(arguments) == "string" and #arguments > 0 then r(f,lpegmatch(splitter,arguments)) elseif arguments then - r(f,arguments) + r(f,unpack(arguments)) else r(f) end diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index 96224da67..2a68e0cc7 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -98,6 +98,10 @@ return { "startmodule", "stopmodule", "usemodule", -- "typescriptone", "typescripttwo", "typescriptthree", "mathsizesuffix", + -- + "mathordcode", "mathopcode", "mathbincode", "mathrelcode", "mathopencode", "mathclosecode", + "mathpunctcode", "mathalphacode", "mathinnercode", "mathnothingcode", "mathlimopcode", + "mathnolopcode", "mathboxcode", "mathchoicecode", "mathaccentcode", "mathradicalcode", }, ["helpers"] = { -- @@ -121,6 +125,8 @@ return { "unvoidbox", "vfilll", -- + "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", + -- "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", @@ -200,6 +206,8 @@ return { "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", -- + "firstofoneunexpanded", + -- "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", -- diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv index 1e2f07465..eeb5cadfd 100644 --- a/tex/context/base/spac-hor.mkiv +++ b/tex/context/base/spac-hor.mkiv @@ -854,6 +854,11 @@ \let \; \thickspace \let \! \negthinspace +% plain ... +% +% \ifdefined\> \else \unexpanded\def\>{\mskip \medmuskip } \fi +% \ifdefined\* \else \unexpanded\def\*{\discretionary{\thinspace\the\textfont2\char2}{}{}} \fi + \def\flexiblespaceamount#1#2#3% {#1\interwordspace \!!plus#2\interwordstretch diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex fab0350ee..d635a95bc 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 029473566..7f39e4205 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index 482586b94..9c20b18d4 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -1153,7 +1153,7 @@ return { filename = "meta-pag", marktype = "mkiv", status = "okay", - comment = "might get updated when its mp counterpart gets cleaned up", + comment = "might get updated when mp code gets cleaned up", }, { filename = "page-mrk", @@ -1208,12 +1208,13 @@ return { { filename = "math-ini", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "math-pln", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "this file might merge into others", }, { filename = "math-for", @@ -1223,7 +1224,8 @@ return { { filename = "math-def", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "eventually this will be split and spread", }, { filename = "math-ali", @@ -1238,32 +1240,36 @@ return { { filename = "math-frc", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "at least for the moment", }, { filename = "math-scr", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "math-int", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "math-del", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "code get replaced (by autodelimiters)", }, { filename = "math-inl", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "code might move to here", }, { filename = "math-dis", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "code might move to here", }, { filename = "phys-dim", @@ -1298,7 +1304,8 @@ return { { filename = "node-rul", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "maybe some cleanup is needed", }, { filename = "node-spl", diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex index dac5f64f2..85e02eca5 100644 --- a/tex/context/base/status-mkiv.tex +++ b/tex/context/base/status-mkiv.tex @@ -42,6 +42,7 @@ the filename but later we can replace these by longer names (via a script) so module writers should {\bf not} use the core commands with \type{_} in the name \stopitem + \startitem the message system will be unified \stopitem \stopitemize \stopsubject diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 338e4bc63..08c7166a2 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -2833,6 +2833,8 @@ \def\fifthofsixarguments #1#2#3#4#5#6{#5} \def\sixthofsixarguments #1#2#3#4#5#6{#6} +\unexpanded\def\firstofoneunexpanded#1{#1} + %D \macros %D {globalletempty,letempty, %D letvalueempty,letgvalueempty, diff --git a/tex/context/base/type-set.mkiv b/tex/context/base/type-set.mkiv index 932771a61..af08726e9 100644 --- a/tex/context/base/type-set.mkiv +++ b/tex/context/base/type-set.mkiv @@ -39,39 +39,39 @@ \fi -\definefilesynonym [type-imp-lucida.mkiv] [type-imp-lucida-typeone.mkiv] -\definefilesynonym [type-imp-lucidanova.mkiv] [type-imp-lucida-opentype.mkiv] -\definefilesynonym [type-imp-lucidaot.mkiv] [type-imp-lucida-opentype.mkiv] - -\definefilesynonym [type-imp-palatino.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-courier.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-avantgarde.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-helvetica.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-chancery.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-bookman.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-schoolbook.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-times.mkiv] [type-imp-texgyre.mkiv] - -\definefilesynonym [type-imp-cursor.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-adventor.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-heros.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-chorus.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-bonum.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-schola.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-pagella.mkiv] [type-imp-texgyre.mkiv] -\definefilesynonym [type-imp-termes.mkiv] [type-imp-texgyre.mkiv] - -\definefilesynonym [type-imp-mscoretimes] [type-imp-mscore.mkiv] -\definefilesynonym [type-imp-mscorearial] [type-imp-mscore.mkiv] -\definefilesynonym [type-imp-mscorecourier] [type-imp-mscore.mkiv] -\definefilesynonym [type-imp-mscoreverdana] [type-imp-mscore.mkiv] - -\definefilesynonym [type-imp-candara] [type-imp-cleartype.mkiv] -\definefilesynonym [type-imp-consolas] [type-imp-cleartype.mkiv] -\definefilesynonym [type-imp-constantia] [type-imp-cleartype.mkiv] -\definefilesynonym [type-imp-corbel] [type-imp-cleartype.mkiv] -\definefilesynonym [type-imp-calibri] [type-imp-cleartype.mkiv] - -\definefilesynonym [type-imp-antykwa-poltawskiego] [type-imp-antykwapoltawskiego.mkiv] +\definefilesynonym [type-imp-lucida.mkiv] [type-imp-lucida-typeone.mkiv] +\definefilesynonym [type-imp-lucidanova.mkiv] [type-imp-lucida-opentype.mkiv] +\definefilesynonym [type-imp-lucidaot.mkiv] [type-imp-lucida-opentype.mkiv] + +\definefilesynonym [type-imp-palatino.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-courier.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-avantgarde.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-helvetica.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-chancery.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-bookman.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-schoolbook.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-times.mkiv] [type-imp-texgyre.mkiv] + +\definefilesynonym [type-imp-cursor.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-adventor.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-heros.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-chorus.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-bonum.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-schola.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-pagella.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-termes.mkiv] [type-imp-texgyre.mkiv] + +\definefilesynonym [type-imp-mscoretimes.mkiv] [type-imp-mscore.mkiv] +\definefilesynonym [type-imp-mscorearial.mkiv] [type-imp-mscore.mkiv] +\definefilesynonym [type-imp-mscorecourier.mkiv] [type-imp-mscore.mkiv] +\definefilesynonym [type-imp-mscoreverdana.mkiv] [type-imp-mscore.mkiv] + +\definefilesynonym [type-imp-candara.mkiv] [type-imp-cleartype.mkiv] +\definefilesynonym [type-imp-consolas.mkiv] [type-imp-cleartype.mkiv] +\definefilesynonym [type-imp-constantia.mkiv] [type-imp-cleartype.mkiv] +\definefilesynonym [type-imp-corbel.mkiv] [type-imp-cleartype.mkiv] +\definefilesynonym [type-imp-calibri.mkiv] [type-imp-cleartype.mkiv] + +\definefilesynonym [type-imp-antykwa-poltawskiego.mkiv] [type-imp-antykwapoltawskiego.mkiv] \protect \endinput diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 99c9a6da2..b0ddd08c2 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 01/24/12 14:55:51 +-- merge date : 01/25/12 13:09:37 do -- begin closure to overcome local limits and interference |