Giter Site home page Giter Site logo

Operator problem with docx about texmath HOT 2 CLOSED

jgm avatar jgm commented on September 24, 2024
Operator problem with docx

from texmath.

Comments (2)

jgm avatar jgm commented on September 24, 2024

Here's the xml from typing into Word:

<m:oMathPara>
  <m:oMath>
    <m:d>
      <m:dPr>
        <m:ctrlPr>
          <w:rPr>
            <w:rFonts w:ascii="Cambria Math"
            w:hAnsi="Cambria Math" />
            <w:i />
          </w:rPr>
        </m:ctrlPr>
      </m:dPr>
      <m:e>
        <m:nary>
          <m:naryPr>
            <m:chr m:val="" />
            <m:limLoc m:val="undOvr" />
            <m:supHide m:val="1" />
            <m:ctrlPr>
              <w:rPr>
                <w:rFonts w:ascii="Cambria Math"
                w:hAnsi="Cambria Math" />
                <w:i />
              </w:rPr>
            </m:ctrlPr>
          </m:naryPr>
          <m:sub>
            <m:r>
              <w:rPr>
                <w:rFonts w:ascii="Cambria Math"
                w:hAnsi="Cambria Math" />
              </w:rPr>
              <m:t>x</m:t>
            </m:r>
          </m:sub>
          <m:sup />
          <m:e>
            <m:r>
              <w:rPr>
                <w:rFonts w:ascii="Cambria Math"
                w:hAnsi="Cambria Math" />
              </w:rPr>
              <m:t>x</m:t>
            </m:r>
          </m:e>
        </m:nary>
      </m:e>
    </m:d>
    <m:d>
      <m:dPr>
        <m:ctrlPr>
          <w:rPr>
            <w:rFonts w:ascii="Cambria Math"
            w:hAnsi="Cambria Math" />
            <w:i />
          </w:rPr>
        </m:ctrlPr>
      </m:dPr>
      <m:e>
        <m:nary>
          <m:naryPr>
            <m:chr m:val="" />
            <m:limLoc m:val="undOvr" />
            <m:supHide m:val="1" />
            <m:ctrlPr>
              <w:rPr>
                <w:rFonts w:ascii="Cambria Math"
                w:hAnsi="Cambria Math" />
                <w:i />
              </w:rPr>
            </m:ctrlPr>
          </m:naryPr>
          <m:sub>
            <m:r>
              <w:rPr>
                <w:rFonts w:ascii="Cambria Math"
                w:hAnsi="Cambria Math" />
              </w:rPr>
              <m:t>i</m:t>
            </m:r>
          </m:sub>
          <m:sup />
          <m:e>
            <m:r>
              <w:rPr>
                <w:rFonts w:ascii="Cambria Math"
                w:hAnsi="Cambria Math" />
              </w:rPr>
              <m:t>x</m:t>
            </m:r>
          </m:e>
        </m:nary>
      </m:e>
    </m:d>
  </m:oMath>
</m:oMathPara>

By comparison, here's the xml produced by pandoc:

<m:oMathPara>
  <m:oMathParaPr>
    <m:jc m:val="center" />
  </m:oMathParaPr>
  <m:oMath>
    <m:d>
      <m:dPr>
        <m:begChr m:val="(" />
        <m:endChr m:val=")" />
        <m:grow />
      </m:dPr>
      <m:e>
        <m:limLow>
          <m:e>
            <m:r>
              <m:t>∑</m:t>
            </m:r>
          </m:e>
          <m:lim>
            <m:r>
              <m:t>i</m:t>
            </m:r>
          </m:lim>
        </m:limLow>
        <m:sSub>
          <m:e>
            <m:r>
              <m:t>x</m:t>
            </m:r>
          </m:e>
          <m:sub>
            <m:r>
              <m:t>i</m:t>
            </m:r>
          </m:sub>
        </m:sSub>
      </m:e>
    </m:d>
    <m:nary>
      <m:naryPr>
        <m:chr m:val="" />
        <m:limLoc m:val="undOvr" />
        <m:subHide m:val="0" />
        <m:supHide m:val="1" />
      </m:naryPr>
      <m:sub>
        <m:r>
          <m:t>i</m:t>
        </m:r>
      </m:sub>
      <m:sup />
      <m:e>
        <m:sSub>
          <m:e>
            <m:r>
              <m:t>x</m:t>
            </m:r>
          </m:e>
          <m:sub>
            <m:r>
              <m:t>i</m:t>
            </m:r>
          </m:sub>
        </m:sSub>
      </m:e>
    </m:nary>
  </m:oMath>
</m:oMathPara>

from texmath.

jgm avatar jgm commented on September 24, 2024

I see what's happening. Look at the native output:

[EDelimited "(" ")" [Right (EUnder True (ESymbol Op "\8721") (EIdentifier "i")),Right (ESub (EIdentifier "x") (EIdentifier "i"))],EUnder True (ESymbol Op "\8721") (EIdentifier "i"),ESub (EIdentifier "x") (EIdentifier "i")]

In the OMML writer, we do a preliminary transformation to convert selected EUnder, EUnderOver, etc. into nary:

everywhere (mkT $ handleDownup dt)

where

handleDownUp :: DisplayType -> [Exp] -> [Exp]

This gets the second EUnder but not the first one, since the first one is in an EDelimited context where each non-delimiter element has the Right constructor.

The whole thing is pretty ugly, there must be a better way1

from texmath.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.