Ticket #1492 (closed defect: fixed)

Opened 3 years ago

Last modified 9 months ago

complex operators

Reported by: kohlhase Owned by: deyan
Priority: normal Milestone: LTXML parity
Component: STeX/ltxml Version:
Severity: major Keywords:
Cc: miller Blocked By:
Blocking: 1672 Due to close: YYYY/MM/DD
Include in GanttChart: no Dependencies:
Due to assign: YYYY/MM/DD

Description

I am sure I remember that this is already implemented, but I cannot find the documentation for it. My Problem is that \symdef{eqdFN}{=:} is converted to

    <notation cd="mathtalk-definitions" name="eqdFN" xml:id="mathtalk-definitions.p2">
      <prototype>
        <om:OMS cd="mathtalk-definitions" name="eqdFN"/>
      </prototype>
      <rendering>
        <m:mrow>
          <m:mo>=</m:mo>
          <m:mo>⁣</m:mo>
          <m:mo>:</m:mo>
        </m:mrow>
      </rendering>
    </notation>

where I would have liked

    <notation cd="mathtalk-definitions" name="eqdFN" xml:id="mathtalk-definitions.p2">
      <prototype>
        <om:OMS cd="mathtalk-definitions" name="eqdFN"/>
      </prototype>
      <rendering>
       <m:mo>=:</m:mo>
      </rendering>
    </notation>

I have the feeling that I would have to write \symdef{\complexmo{eqdFN}} to indicate that this is a complex operator, but as I said, I cannot find the documentation on this. The obvious test case for this is [source slides/dmath/en/mathtalk-definitions.tex]

But something weird is going on here, since \symdef{defeqFN}{:=} is converted to

    <notation cd="mathtalk-definitions" name="defeqFN" xml:id="mathtalk-definitions.p10">
      <prototype>
        <om:OMS cd="mathtalk-definitions" name="defeqFN"/>
      </prototype>
      <rendering>
        <m:mo>:=</m:mo>
      </rendering>
    </notation>

Change History

follow-up: ↓ 2   Changed 3 years ago by deyan

  • cc miller added
  • status changed from new to assigned

As far as I remember, we only implemented complex tokens, by introducing a \vname constructor. We haven't really looked into complex operators, or have we?

  • In principle the first example should work if one uses the inbuilt TeX scoping command sequences:
      \mathop, \mathrel, \mathbin, \mathord, \mathopen, \mathclose, \mathpunct
    
    In this case I would consider \symdef{eqdFN}{\mathrel{=:}} to be a fair solution. There is a problem with the grammar interpreting "=:" as a two element list way too early, and then failing to act on the \mathrel-induced RELOP application. I will look into mending this in our branch of LaTeXML

@Bruce: do you think this is indeed a good thing to correct?

  • The latter example works out due to ":=" having been predeclared natively as an operator in LaTeXML (via a DefMathI in TeX.pool.ltxml)

in reply to: ↑ 1 ; follow-up: ↓ 3   Changed 3 years ago by kohlhase

Replying to deyan:

As far as I remember, we only implemented complex tokens, by introducing a \vname constructor. We haven't really looked into complex operators, or have we?

I guess that I just (mis)remembered \mathop.

* In principle the first example should work if one uses the inbuilt TeX scoping command sequences: {{{ \mathop, \mathrel, \mathbin, \mathord, \mathopen, \mathclose, \mathpunct }}} In this case I would consider \symdef{eqdFN}{\mathrel{=:}} to be a fair solution.

I consider this as a good solution. Especially, since it could make for better spacing in the PDF platform. But of course this is a lot of work. I will also have to find good documentation on \math*, someone still has my TeX book :-(.

But I tried your suggestion, but it does not change the result. I also tried \mathop without effect.

There is a problem with the grammar interpreting "=:" as a two element list way too early, and then failing to act on the \mathrel-induced RELOP application. I will look into mending this in our branch of LaTeXML

Hmmm, I guess that what you are saying is that I should not expect to see a change yet?

@Bruce: do you think this is indeed a good thing to correct? * The latter example works out due to ":=" having been predeclared natively as an operator in LaTeXML (via a DefMathI in TeX.pool.ltxml)

in reply to: ↑ 2   Changed 3 years ago by deyan

Replying to kohlhase:

I will also have to find good documentation on \math*, someone still has my TeX book :-(.

There is one at the library and there are also electronic solutions to this problem, that I can help with.

But I tried your suggestion, but it does not change the result. I also tried \mathop without effect.

There is a problem with the grammar interpreting "=:" as a two element list way too early, and then failing to act on the \mathrel-induced RELOP application. I will look into mending this in our branch of LaTeXML

Hmmm, I guess that what you are saying is that I should not expect to see a change yet?

Exactly.

  Changed 3 years ago by kohlhase

  • milestone changed from sTeX4GenCS to sTeX: second CTAN release

this is not critical for GenCS (at least now), bumping the milestone.

  Changed 3 years ago by kohlhase

  • milestone changed from sTeX: second CTAN release to LTXML parity

  Changed 3 years ago by deyan

@Bruce:

Looking at this again, I presume the best thing to change is the MathML.pm treatment of the resulting XMath.

The offending XML right now is:

<XMApp role="RELOP">
  <XMTok meaning="list" role="FENCED" separators="⁣"/>
  <XMTok meaning="equals" role="RELOP">=</XMTok>
  <XMTok name="colon" role="METARELOP">:</XMTok>
</XMApp>

So I would hypothesize that whenever one sees an <XMApp> with role "RELOP", or any of the other operator roles, the body of the XMApp should be merged into a single XMTok with that role. In this case:

 <XMTok role="RELOP">=:</XMTok>

Of course, if one sees other attributes on the XMApp they should be transferred down to this new token (meaning, etc.). Does this sound like a good idea? I am thinking of implementing it on the branch.

  Changed 3 years ago by kohlhase

Deyan,

since we hear nothing from Bruce, you should just go ahead and try this out on the branch.

  Changed 3 years ago by deyan

After some thinking, I think the right way of implementing this is with a native DefMathRewrite rule (since we are talking about native \mathrel, \mathop, etc. macros).

I have added the rewrite rule at the bottom of TeX.pool.ltxml on our LaTeXML branch and it currently supports the \mathrel case, which is relevant for this ticket. Extending it to all other cases is trivial and should probably also be considered.

Please, reinstall the branch LaTeXML and try \mathrel{=:} . Let me know if related features come to mind.

@Bruce: Let me know if you are still around, I do believe this is an actual deficiency in LaTeXML trunk/ which should be addressed there as well.

  Changed 3 years ago by kohlhase

I updated LaTeXML and made install, then I re-generated dmath/en/mathtalk-definitions, and the symdefs for eqdFN and friends have not changed.

Is there anything else I should do?

  Changed 3 years ago by deyan

It is great that you saw this - I sometimes forget checking the final .omdoc once the .tex.xml works well. There was an error in postprocessing, as I had forgot to set a namespace when doing the rewrite.

If you update and reinstall the branch once more, this should be working well now.

  Changed 3 years ago by kohlhase

Ah, wonderful, this is what like. You said the remaining cases should be similer, could you knock them off and close?

  Changed 3 years ago by deyan

  • status changed from assigned to closed
  • resolution set to fixed

I have added role values BIGOP, OP, ADDOP, OPEN, CLOSE and PUNCT to the XMApp rewrite rule.

This effectively means you can use the following TeX primitives safely: \mathop, \mathrel, \mathbin, \mathopen, \mathclose, \mathpunct

Two last notes:

  • \mathord could produce an XMApp with role="ID" which is something we are currently using in the experimental treatment for complex variables. Hence, I am not adding support for that case as it would lead to a conflict.
  • In general, the current solution is too simplistic, and should probably be improved in the future - right now I am just taking all the text content withing the XMApp element and use it as the body of a single token. However, complex tokens may prove to be useful in the future.

So for now my recommendation is - use the above \math* primitives only when you want a single token constructed from their bodies.

Closing.

  Changed 22 months ago by soprea

  • blocking 1669 added

(In #1669) This is related to ticket 1492 (reopened not working anymore)

  Changed 22 months ago by soprea

  • blocking 1672 added

(In #1672) This is related to ticket 1492 (reopened, not working anymore)

  Changed 22 months ago by soprea

  • status changed from closed to reopened
  • resolution fixed deleted
  • blocking 1669, 1672 removed
\symdef{eqdFN}{=:}

gives the wrong thing again.

  Changed 22 months ago by soprea

  • blocking 1672 added

  Changed 9 months ago by deyan

  • status changed from reopened to closed
  • resolution set to fixed

This had regressed from my reintegration cleanup of the LaTeXML branch I had done at NIST.

I have reintroduced the enhancement, now at presentations.sty.ltxml until Bruce merges it into trunk. I also opened a  LaTeXML ticket.

Note that you need to always write \mathrel{=:} if you want to designate the symbol as a relation, as has been explained above as well.

Note: See TracTickets for help on using tickets.