brucemiller / LaTeXML

LaTeXML: a TeX and LaTeX to XML/HTML/ePub/MathML translator.
http://dlmf.nist.gov/LaTeXML/
Other
946 stars 101 forks source link

MathML-content with mtext afer postprocessingPostprocessing #69

Closed kohlhase closed 15 years ago

kohlhase commented 16 years ago

[Originally Ticket 1393]

sometimes postprocessing and goes quite wrong, I get the following thing in http://arxmliv.kwarc.info/files/quant-ph/papers/0506062/determinism.xhtml

It seems that all the formulae in this paper have the same weird form.


<m:math display="block">
  <m:semantics>
    <m:mtable rowspacing="0.2ex" columnspacing="0.4em">
      <m:mtr>
        <m:mtd columnalign="left">
          <m:msub>
            <m:mi mathvariant="fraktur">P</m:mi>
            <m:mrow>
              <m:mi>f</m:mi>
              <m:mo>,</m:mo>
              <m:mi>G</m:mi>
            </m:mrow>
          </m:msub>
        </m:mtd>
        <m:mtd columnalign="left">
          <m:mo>=</m:mo>
        </m:mtd>
        <m:mtd columnalign="left">
          <m:mrow>
            <m:munderover>
              <m:mo movablelimits="false">&prod;</m:mo>
              <m:mrow>
                <m:mi>i</m:mi>
                <m:mo>&isin;</m:mo>
                <m:msup>
                  <m:mi>O</m:mi>
                  <m:mi>c</m:mi>
                </m:msup>
              </m:mrow>
              <m:mo>&gt;</m:mo>
            </m:munderover>
            <m:msubsup>
              <m:mi>M</m:mi>
              <m:mi>i</m:mi>
              <m:msub>
                <m:mi>&alpha;</m:mi>
                <m:mi>i</m:mi>
              </m:msub>
            </m:msubsup>
            <m:mo>&InvisibleTimes;</m:mo>
            <m:msubsup>
              <m:mi>K</m:mi>
              <m:mrow>
                <m:mi>G</m:mi>
                <m:mo>&InvisibleTimes;</m:mo>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mrow>
                    <m:mi>f</m:mi>
                    <m:mo>&InvisibleTimes;</m:mo>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>i</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                  </m:mrow>
                  <m:mo>)</m:mo>
                </m:mrow>
              </m:mrow>
              <m:msub>
                <m:mi>s</m:mi>
                <m:mi>i</m:mi>
              </m:msub>
            </m:msubsup>
            <m:mo>&InvisibleTimes;</m:mo>
            <m:msubsup>

              <m:mi>Z</m:mi>

              <m:mi>i</m:mi>
              <m:msub>
                <m:mi>s</m:mi>
                <m:mi>i</m:mi>
              </m:msub>
            </m:msubsup>
            <m:mo>&InvisibleTimes;</m:mo>
            <m:msub>
              <m:mi>E</m:mi>
              <m:mi>G</m:mi>
            </m:msub>
            <m:mo>&InvisibleTimes;</m:mo>
            <m:msubsup>
              <m:mi>N</m:mi>
              <m:msup>
                <m:mi>I</m:mi>
                <m:mi>c</m:mi>
              </m:msup>
              <m:mn>0</m:mn>
            </m:msubsup>
          </m:mrow>
        </m:mtd>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
        <m:mtd/>
      </m:mtr>
    </m:mtable>
    <m:annotation-xml encoding="MathML-Content">
      <m:mtext>PfG=&prod;&gt;&isin;iOc&InvisibleTimes;Mi&alpha;iK&InvisibleTimes;G&InvisibleTimes;fisiZisiEGNIc0</m:mtext>
    </m:annotation-xml>
  </m:semantics>
brucemiller commented 16 years ago

"It seems that all the formulae in this paper have the same weird form. " basically because all the TeX markup has the same "weird form". Namely, it looks like all displayed formula are typeset using either eqnarray or an array with a dozen columns (most of which end up empty).

The immediate cause of what you're seeing is that mtext is the fallback for cmml conversion when latexml doesn't know what else to generate. When I wrote it, it wasn't 100% clear that it was an error, but perhaps merror would be more appropriate?

At the next level, I took some trouble to make at least a little sense out of eqnarrays, but that leads to a dilemma: An eqnarray (or alignments of equations in general) is a single presentational object (either an mtable in mml, or a table at the html level containing mml), but contains several content objects (ie. the equations, themselves, if I could heuristicate them). I can, and do, markup such a beast in latexml, but there's no direct correspondence to an mml semantics structure, which is what you're trying to generate here. In other words, it's not clear what "parallel markup" should be in this case. Any suggestions?

Knowing what the author intended with the array markup, in principle one could generate structures similar to eqnarray, but such a heuristic certainly doesn't apply to math arrays in general.

Finally, the author is using rather specialized notations, bra-ket etc. One could do some interesting semantics here, but it needs human intervention.

In summary, there are some information architecture issues here about what the desired representations should be. But, it also seems unrealistic to expect automatic content extraction from documents like this.

brucemiller commented 15 years ago

In the meantime, I have extended the grammar to handle some quantum mechanical notations.

However, there are 2 basic issues:

Sorry, trac is bugging me to close tickets!