slatex / LaTeXML-Plugin-sTeX

A LaTeXML Plugin for Semantic LaTeX (sTeX)
LaTeX Project Public License v1.3c
2 stars 3 forks source link

piecewise notation swallows argument #92

Open angerhang opened 8 years ago

angerhang commented 8 years ago

In .../MathHub/smglom/mv/source/piecewise.tex we have

\symdef[name=defined-piecewise]{piecewise}[1]{\left\{\parray{rl}{#1}\right.}

which generates the notation definition

    <omdoc:notation cd="piecewise" name="defined-piecewise" stex:macro_name="piecewise" stex:nargs="1" xml:id="piecewise.notation8" about="#piecewise.notation8" stex:srcref="smglom/mv/source/piecewise.tex#textrange(from=10;0,to=10;76)">
      <omdoc:prototype>
        <om:OMA>
          <om:OMS cd="piecewise" cr="fun" name="defined-piecewise"/>
          <omdoc:expr name="arg1"/>
        </om:OMA>
      </omdoc:prototype>
      <omdoc:rendering>
        <m:mrow>
          <m:mo>{</m:mo>
          <m:mtable columnspacing="5pt" rowspacing="0pt">
            <m:mtr/>
          </m:mtable>
        </m:mrow>
      </omdoc:rendering>
    </omdoc:notation>

This is wrong, instead of <m:mtr/> it should be

<m:mtd>
    <omdoc:render name="arg1"/>
</m:mtd>

there is also an error that seems to describe what is happening:

Warning:not_parsed:>OPEN MathParser failed to match rule 'Anything'
    Anonymous String#textrange(from=0;1,to=0;0)
    In "\@@use{\left\{\parray{rl}{arg:1}\right.}"
    > \left\{[[OPEN]] \parray{rl}{arg:1}[[UNKNOWN]]
angerhang commented 8 years ago

I am not even sure that the LaTeX is what it should be. I am currently looking at using a more standard "associative argument" markup:

\symdef[name=defined-piecewise,assocarg=1]{piecewise}[1]{\left\{\parray{rl}{\assoc{#1}{}}\right.}
\symtest{piecewise}{|x|:=\piecewise{\piece{x}{x>0},\piece{-x}{x<0},\otherwise{0}}}

and that generates

     <omdoc:prototype>
        <om:OMA>
          <om:OMS cd="piecewise" cr="fun" name="defined-piecewise"/>
          <omdoc:exprlist name="args">
            <omdoc:expr name="arg"/>
          </omdoc:exprlist>
        </om:OMA>
      </omdoc:prototype>
      <omdoc:rendering>
        <XMTok xmlns="http://dlmf.nist.gov/LaTeXML" role="OPEN">{</XMTok>
        <XMArray xmlns="http://dlmf.nist.gov/LaTeXML">
          <omdoc:iterate name="args">
            <omdoc:separator>
              <omdoc:render name="arg1"/>
            </omdoc:separator>
            <omdoc:render name="arg"/>
          </omdoc:iterate>
        </XMArray>
        <XMHint xmlns="http://dlmf.nist.gov/LaTeXML"/>
      </omdoc:rendering>
    </omdoc:notation>

which looks a bit better. But it does not work at all in the PDFLaTeX case, and there are quite a few schema errors in the LaTeXML case as well.

I have the feeling that this will be the more fruitful avenue.