Just found that the code below does not work as intended, because \ππ’π¦ will be parsed as \π followed by π’π¦. Canβt tell if it ought to be changed, though one could think other cases where it might be natural. The command definition of \π works though. \setupbodyfont[xits,10pt] \setupmathematics[lcgreek=normal, default=normal] \definemathcommand[ππ’π¦][nolop]{\mfunction{ππ’π¦}} \definemathcommand[π][nolop]{\mfunction{ππ’π¦}} \starttext Note that $\ππ’π¦ π = π«$, although $\dim π = 4$. \stoptext
Found a workaround: The idea is to use \csname β¦\endcsname with two delimiters not likely to be used in math mode, below chosen to ββ¦β. But then there seems to be a bug in the LuaTex \letcharcode command: There must be a character between β$β and the first occurring \activecatcode letter. Possibly this also causes a bug in \startformula, as discussed before. \setupbodyfont[xits,10pt] \setupmathematics[lcgreek=normal, default=normal] \def\usemathcommand#1β{\csname #1\endcsname} \appendtoks \catcode`β=\activecatcode \letcharcode `β \usemathcommand \to \everymathematics \definemathcommand[ππ’π¦][nolop]{\mfunction{ππ’π¦}} \starttext Note that $ βππ’π¦β π = π«$, although $\dim π = 4$. And a bug: $βππ’π¦β π$. \stoptext
On 9/12/2016 8:25 PM, Hans Γ berg wrote:
Found a workaround: The idea is to use \csname β¦\endcsname with two delimiters not likely to be used in math mode, below chosen to ββ¦β.
But then there seems to be a bug in the LuaTex \letcharcode command: There must be a character between β$β and the first occurring \activecatcode letter. Possibly this also causes a bug in \startformula, as discussed before.
it's not a bug .. tex looks ahead for a second $ and in the process expands the next token which happens to be a letter at that point so it gets injected as letter (it's the way tex works) \appendtoks \catcode`π\lettercatcode \catcode`π’\lettercatcode \catcode`π¦\lettercatcode \to \everymathematics \definemathcommand[ππ’π¦][nolop]{\mfunction{π¦π’π}} \starttext Note that $ \ππ’π¦ π = π«$, although $\dim π = 4$. And a bug: $\ππ’π¦ π$. \stoptext fwiw, the current beta makes math characters also letters now ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 12 Sep 2016, at 21:45, Hans Hagen
wrote: On 9/12/2016 8:25 PM, Hans Γ berg wrote:
But then there seems to be a bug in the LuaTex \letcharcode command: There must be a character between β$β and the first occurring \activecatcode letter. Possibly this also causes a bug in \startformula, as discussed before.
it's not a bug .. tex looks ahead for a second $ and in the process expands the next token which happens to be a letter at that point so it gets injected as letter (it's the way tex works)
Iβm not sure what you mean here: I must write $ βππ’π¦β π$, because $βππ’π¦β π$ will not see the \catcode`β=\activecatcode. So LuaTeX must see an ordinary letter after $ before it can see an \activecatcode character. It does not happen with TeX using \catcode`\β=\active \defβ#1β{\csname #1\endcsname}
On 9/12/2016 10:02 PM, Hans Γ berg wrote:
On 12 Sep 2016, at 21:45, Hans Hagen
wrote: On 9/12/2016 8:25 PM, Hans Γ berg wrote:
But then there seems to be a bug in the LuaTex \letcharcode command: There must be a character between β$β and the first occurring \activecatcode letter. Possibly this also causes a bug in \startformula, as discussed before.
it's not a bug .. tex looks ahead for a second $ and in the process expands the next token which happens to be a letter at that point so it gets injected as letter (it's the way tex works)
Iβm not sure what you mean here: I must write $ βππ’π¦β π$, because $βππ’π¦β π$ will not see the \catcode`β=\activecatcode. So LuaTeX must see an ordinary letter after $ before it can see an \activecatcode character.
It does not happen with TeX using \catcode`\β=\active \defβ#1β{\csname #1\endcsname}
sure, but when you do \appendtoks \catcode`\β=\active \defβ#1β{\csname #1\endcsname} \to ... only tokens get added to the register ... so the β after the \def is not active (yet) in addition when tex sees a $ it will look for a next token (in case it's a $ for display mode) and it sees a quote (no everymath doen then) which it will push back Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 13 Sep 2016, at 07:57, Hans Hagen
wrote: On 9/12/2016 10:02 PM, Hans Γ berg wrote:
It does not happen with TeX using \catcode`\β=\active \defβ#1β{\csname #1\endcsname}
sure, but when you do
\appendtoks \catcode`\β=\active \defβ#1β{\csname #1\endcsname} \to ...
only tokens get added to the register ... so the β after the \def is not active (yet)
in addition when tex sees a $ it will look for a next token (in case it's a $ for display mode) and it sees a quote (no everymath doen then) which it will push back
OK. TeX does not parse the way I expected.
On 13 Sep 2016, at 07:57, Hans Hagen
wrote:
sure, but when you do
\appendtoks \catcode`\β=\active \defβ#1β{\csname #1\endcsname} \to β¦
FYI, this does not work for me; I must use LuaTeX \letcharcode: \def\usemathcommand#1β{\csname #1\endcsname} \appendtoks \catcode`β=\activecatcode \letcharcode `β \usemathcommand \to \everymathematics Then β$β must be followed by a character other than β for this command to be seen, but it works with β$$β.
participants (2)
-
Hans Hagen
-
Hans Γ berg