Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docx to html conversion: aligned equations not working #150

Open
davidmckinnon opened this issue Dec 29, 2019 · 4 comments
Open

docx to html conversion: aligned equations not working #150

davidmckinnon opened this issue Dec 29, 2019 · 4 comments

Comments

@davidmckinnon
Copy link

davidmckinnon commented Dec 29, 2019

I am converting docx to html using pandoc (v2.9.1) called from conda Python (3.7.1).

I have attached two examples of aligned equations in a docx file where I have aligned them at the equality sign within the Word document.
testmath.docx

The Latex code lacks the \begin{aligned} ... \end{aligned} words, lacks the decorated equality sign '&=' needed for alignment, and the line breaks are not properly implemented.

@jgm
Copy link
Owner

jgm commented Jan 3, 2020

Here's what the XML looks like for the first two equations. The aligning is done by m:aln in m:rPr.

      <m:oMathPara>
        <m:oMath>
          <m:sSub>
            <m:sSubPr>
              <m:ctrlPr>
                <w:rPr>
                  <w:rFonts w:ascii="Cambria Math"
                  w:hAnsi="Cambria Math" />
                  <w:i />
                </w:rPr>
              </m:ctrlPr>
            </m:sSubPr>
            <m:e>
              <m:r>
                <w:rPr>
                  <w:rFonts w:ascii="Cambria Math"
                  w:hAnsi="Cambria Math" />
                </w:rPr>
                <m:t>E</m:t>
              </m:r>
            </m:e>
            <m:sub>
              <m:r>
                <w:rPr>
                  <w:rFonts w:ascii="Cambria Math"
                  w:hAnsi="Cambria Math" />
                </w:rPr>
                <m:t>Na</m:t>
              </m:r>
            </m:sub>
          </m:sSub>
          <m:r>
            <m:rPr>
              <m:aln />
            </m:rPr>
            <w:rPr>
              <w:rFonts w:ascii="Cambria Math"
              w:hAnsi="Cambria Math" />
            </w:rPr>
            <m:t xml:space="preserve">
=61.5 
</m:t>
          </m:r>
          <m:r>
            <m:rPr>
              <m:sty m:val="p" />
            </m:rPr>
            <w:rPr>
              <w:rFonts w:ascii="Cambria Math"
              w:hAnsi="Cambria Math" />
            </w:rPr>
            <m:t>mV</m:t>
          </m:r>
          <m:r>
            <w:rPr>
              <w:rFonts w:ascii="Cambria Math"
              w:hAnsi="Cambria Math" />
            </w:rPr>
            <m:t xml:space="preserve">
 
</m:t>
          </m:r>
          <m:r>
            <m:rPr>
              <m:sty m:val="p" />
            </m:rPr>
            <w:br />
          </m:r>
        </m:oMath>
        <m:oMath>
          <m:sSub>
            <m:sSubPr>
              <m:ctrlPr>
                <w:rPr>
                  <w:rFonts w:ascii="Cambria Math"
                  w:hAnsi="Cambria Math" />
                  <w:i />
                </w:rPr>
              </m:ctrlPr>
            </m:sSubPr>
            <m:e>
              <m:r>
                <w:rPr>
                  <w:rFonts w:ascii="Cambria Math"
                  w:hAnsi="Cambria Math" />
                </w:rPr>
                <m:t>E</m:t>
              </m:r>
            </m:e>
            <m:sub>
              <m:r>
                <w:rPr>
                  <w:rFonts w:ascii="Cambria Math"
                  w:hAnsi="Cambria Math" />
                </w:rPr>
                <m:t>Na</m:t>
              </m:r>
            </m:sub>
          </m:sSub>
          <m:r>
            <m:rPr>
              <m:aln />
            </m:rPr>
            <w:rPr>
              <w:rFonts w:ascii="Cambria Math"
              w:hAnsi="Cambria Math" />
            </w:rPr>
            <m:t xml:space="preserve">
=61.5 
</m:t>
          </m:r>
          <m:r>
            <m:rPr>
              <m:sty m:val="p" />
            </m:rPr>
            <w:rPr>
              <w:rFonts w:ascii="Cambria Math"
              w:hAnsi="Cambria Math" />
            </w:rPr>
            <m:t>mV</m:t>
          </m:r>
          <m:r>
            <w:rPr>
              <w:rFonts w:ascii="Cambria Math"
              w:hAnsi="Cambria Math" />
            </w:rPr>
            <m:t xml:space="preserve">
 
</m:t>
          </m:r>
          <m:r>
            <m:rPr>
              <m:sty m:val="p" />
            </m:rPr>
            <w:br />
          </m:r>
        </m:oMath>

@jgm
Copy link
Owner

jgm commented Jan 3, 2020

The omml parser for texmath currently ignores the m:aln property.

@jgm
Copy link
Owner

jgm commented Jan 3, 2020

See the tex parser's treatment of align environments to see how this is handled. (A tabular is generated.)

@davidmckinnon
Copy link
Author

I currently fix the latex code that is generated by pandoc using post-processing with Python. This is satisfactory for me but aligned equations are pretty common so it would seem like it is something that should be handled. Not sure if it is priority. I would offer to help but I don't know the first thing about either OMML or Haskell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants