pandoc-generated docx misses italic variables in equations

前端 未结 3 417
名媛妹妹
名媛妹妹 2021-01-07 12:30

I have the following segment of Markdown with embedded LaTeX equations:

# Fisher\'s linear discriminant

\\newcommand{\\cov}{\\mathrm{cov}}
\\newcommand{\\A}         


        
相关标签:
3条回答
  • 2021-01-07 12:42

    As discussed above, Windows doesn't have the font Lucida Grande, so substituting the Math Font with Cambria Math should work.

    1. Rename the test.docx to test.zip
    2. vim test.zip and select test/word/settings.xml
    3. find and change Lucida Grande to Cambria Math
    4. save and rename zip to docx. This results in something like this docx.

    You can then also supply that file as a sort of docx template to pandoc with the --reference-docx option.

    0 讨论(0)
  • 2021-01-07 12:51

    In Word 2007, I see a result similar to yours, except that here, I don't see the "question marks in boxes" characters, just space.

    If I then take one of the expressions, and use your trick of going to linear display and back, the characters reappear for that expression.

    If I save and re-open, the other expressions still do not display correctly, but if I save and look at the XML, I notice that

    1. the Math font has been changed to Cambria Math
    2. additional run parameter (w:rPr) XML specifying the Cambria Math font has been inserted in many of the runs (w:r) inside the oMath elements, even in the oMath expressions that do not display correctly. However, in the oMath expression that now displays correctly, this extra XML has been applied to every run. In the others, it has only been applied to some runs (I think I can see the pattern but I'm running out of time here right now...)
    3. If I manually add the XML to the other runs and re-open the document, the expressions appear correctly. Or at least, they do in the one case I have tried.

    Since Word 2010 displays the resuls correctly, I can only assume that it does not rely on these explicit font settings, whereas Word 2007 does. This doesn't really help you yet, because altering all those w:r elements would be even harder than what you are already doing. But it is possible that a default style/font needs to be set, either somewhere higher in the XML hierarchy, or perhaps elsewhere in the .zip (perhaps in fontTable.xml or styles.xml). I'm not familiar enough with Word's XML structures to guess what, if anything might be missing, but may be able to have a look tomorrow.

    I suppose another possibility is that you just have to have all these extra rPr elements for this to work in Word 2007, which would suggest that pandoc may have been written for Word 2010, not 2007. (I don't know anything about the tool).

    As an example, where you have

    <m:r>
      <m:t>(</m:t>
    </m:r>
    

    what you need is

    <m:r>
      <w:rPr>
        <w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math" />
      </w:rPr>
      <m:t>(</m:t>
    </m:r>
    
    0 讨论(0)
  • 2021-01-07 13:00

    I did the following to get rid of the font issue:

    1. Create a new empty word document.
    2. Copy all content to the new document.
    3. Choose Match Source Format.
    0 讨论(0)
提交回复
热议问题