Ticket #1638 (new defect)

Opened 3 years ago

Last modified 10 months ago

piece1.tex does not work at all in latexml

Reported by: kohlhase Owned by: kohlhase
Priority: highest Milestone: GenCS2013
Component: STeX/ltxml Version: trunk
Severity: major Keywords:
Cc: Blocked By:
Blocking: Due to close: YYYY/MM/DD
Include in GanttChart: no Dependencies:
Due to assign: YYYY/MM/DD

Description

I am trying to get symdefs for slides/missing/piece1.tex to work, but I cannot get them through latexml.

Change History

Changed 3 years ago by deyan

  • status changed from new to assigned

It converts for me, it just chokes on the "&" alignment characters. I don't think it is legal to use them in symdefs like this, did you mean to escape them, or?

Changed 3 years ago by deyan

As we discussed, we probably need to rework the piecewise treatments of LaTeX's array environment, so that we can properly write down the semantics.

  • \arrayline - marks up a line of the array, equates to a table row on the XML side.
  • \arraycell - marks up a cell of the array, equates to a table cell on the XML side.

This approach allows \symdef{} definitions to become more reusable, as they can be plugged easily into arbitrary arrays. It also allows for defining array skeletons that one can instantiate with different cells. On the TeX side, we probably want to use \futurelet to enable parsing a sequence of arbitrarily many \arraycell commands (or, instead, look for exactly two in the {array} environment, or as many as have been defined in a matrix or table case).

We should probably extend this markup to tables and matrices in the future.

Changed 3 years ago by kohlhase

I have added the LaTeX side of this to the presentation package. Actually this was very simple. But the documentation took quite some space (see section 2.7 in trunk/sty/presentation/presentation.pdf. Deyan, please re-read this and correct any problems. I will now change missing/en/piece1.tex to the new primitives, so you have a test case. The ball is in your field now.

Changed 3 years ago by kohlhase

we should probably think about other layout primitives as well. Maybe we can fix the symdefs with tikzinside this way as well.

Changed 3 years ago by deyan

In order to make the renderings work, we need to allow <XMCell> and <XMRow> to appear in <XMath>, whenever there is a <rendering ancestor>.

Once that is done I can test the conversion and see if LaTeXML behaves properly.

Changed 3 years ago by kohlhase

what is the content model of XMCell? I guess that of XMRow is XMCell+

Changed 3 years ago by kohlhase

Could you post a couple of XML trees that need to be valid? Currently I do not really see what is needed in the schema.

Changed 3 years ago by deyan

  • The rendering for:
     \symdef{piece}[2]{\arrayline{\arraycell{#1}}{\text{if}\;#2}}
    
    is:
          <rendering>
            <Math xmlns="http://dlmf.nist.gov/LaTeXML" xml:id="piece1.m1" text="[arg:1ifarg:2]">
              <XMath>
                <XMRow>
                  <XMCell>
                    <XMTok role="ID">arg:1</XMTok>
                  </XMCell>
                  <XMCell>
                    <XMText>
                      <text>if</text>
                    </XMText>
                    <XMHint name="thickspace"/>
                    <XMTok role="ID">arg:2</XMTok>
                  </XMCell>
                </XMRow>
              </XMath>
            </Math>
          </rendering>
    

  • And the rendering for:
     \symdef{otherwise}[1]{\arrayline{\arraycell{#1}}{\text{else}}}
    
    is:
          <rendering>
            <Math xmlns="http://dlmf.nist.gov/LaTeXML" xml:id="piece1.m2" text="[arg:1else]">
              <XMath>
                <XMRow>
                  <XMCell>
                    <XMTok role="ID">arg:1</XMTok>
                  </XMCell>
                  <XMCell>
                    <XMText>
                      <text>else</text>
                    </XMText>
                  </XMCell>
                </XMRow>
              </XMath>
            </Math>
          </rendering>
    

Changed 3 years ago by deyan

The schema breaks when you ask for an <XMRow> in <XMath>. Same happens if you ask for <XMCell> in <XMath>. If those two are allowed, one can use \arrayline and \arraycell throughout \symdef commands without any problems.

Changed 3 years ago by kohlhase

I think we fixed this, @Deyan, please test

Changed 3 years ago by deyan

The XMath side of things is now working smoothly.

However, be reminded that we have no translations for <XMArray>, <XMRow> and <XMCell> in the OpenMath? post processor of LaTeXML. We need to think about how to represent arrays in OpenMath? (or you need to tell me, if this is known).

Changed 3 years ago by kohlhase

I do not think that there is any way to represent arrays in OpenMath?, and there should not be one as they are purely presentational devices. This should just return an error (in the XML tradition with severe error handling).

Changed 3 years ago by kohlhase

Note for this that we only use these XMRow and XMCell in the renderings and thus for the pmml part of latexmlpost. See also  https://trac.mathweb.org/LaTeXML/ticket/1514 for a discussion.

Changed 2 years ago by deyan

I think I have handled all problems that were popping up here. You can update&reinstall LaTeXML's branch and take a look.

Please close if things look ok, let me know otherwise.

Changed 2 years ago by kohlhase

note quite: In missing/en/piece1.tex I have

\begin{omtext}[title=Testing piecewise]
  $|x|=\piecewise{\piece{x}{x>0}\piece{-x}{x<0}\otherwise{0}}$
\end{omtext}

and that gives me

         <om:OMOBJ>
            <om:OMA>
              <om:OMS cd="relation1" name="eq"/>
              <om:OMA>
                <om:OMS cd="latexml" name="absolute-value"/>
                <om:OMV name="x"/>
              </om:OMA>
              <om:OMA>
                <om:OMS cd="piece1" name="piecewise"/>
		<om:OMA>
		  <om:OMS cd="arith1" name="times"/>
		  <om:OMA>
                    <om:OMS cd="piece1" name="piece"/>
                    <om:OMV name="x"/>
                    <om:OMA>
                      <om:OMS cd="relation1" name="gt"/>
                      <om:OMV name="x"/>
                      <om:OMI>0</om:OMI>
                    </om:OMA>
                  </om:OMA>
                  <om:OMA>
                    <om:OMS cd="piece1" name="piece"/>
                    <om:OMA>
                      <om:OMS cd="arith1" name="minus"/>
                      <om:OMV name="x"/>
                    </om:OMA>
                    <om:OMA>
                      <om:OMS cd="relation1" name="lt"/>
                      <om:OMV name="x"/>
                      <om:OMI>0</om:OMI>
                    </om:OMA>
                  </om:OMA>
                  <om:OMA>
                    <om:OMS cd="piece1" name="otherwise"/>
                    <om:OMI>0</om:OMI>
                  </om:OMA>
                </om:OMA>
              </om:OMA>
            </om:OMA>
          </om:OMOBJ>

Note that there is a spurious application of times. I looked and found that also in situations, where we have purely sTeX markup, so it must be an artefact of piecewise.

Changed 2 years ago by deyan

We need to make the schema more flexible so that it tolerates our hackery (<render> elements get passed in the form of <XMTok> elements during the .tex.xml XMath stage), namely:

  • Allow <XMTok> in <XMRow> and <XMArray>
  • Allow <render> in <m:tr> and <m:table>

This will be enough to get the renderings looking as expected, but we should be careful, as we might break the auto-open and auto-close functionality of arrays... Could the schema be restricted to allow the two above, only when having a <rendering> ancestor? Then we would be safe.

If not, this might force us to reconsider using <XMTok> as a <render> carrier, since <XMArray> and <XMRow> are extremely strict about their content ("proper" tables only allowed).

It seems a bit tricky. Also, I just committed the \arrayline macro in presentation.dtx, sorry about that.

Changed 2 years ago by kohlhase

  • owner changed from deyan to soprea
  • priority changed from normal to highest
  • status changed from assigned to new

Changed 10 months ago by kohlhase

  • owner changed from soprea to deyan

we should take this up again after the rewrite, or is this fixed already?

Changed 10 months ago by kohlhase

there is another instance of a problem with \arrayline in cfl/en/BNF.tex, we should look at this as well.

Changed 10 months ago by deyan

  • status changed from new to assigned

We looked at the example and we reconfirmed we need to allow <render> in <m:tr> and <m:table>, and keep it allowed in <m:td>.

Respectively, allow <XMTok> in <XMRow> and <XMArray>

Changed 10 months ago by deyan

  • owner changed from deyan to kohlhase
  • status changed from assigned to new

Changed 10 months ago by kohlhase

I have updated the schema, and it now allows all of these, but it still generates spurious XMRow and XMCell in the notation declaration for piecewise. We should look at this together.

Note: See TracTickets for help on using tickets.