You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to add a math equation to Word document using python-docx. By default, the font used for the equation is Cambria Math. I want to change it to some other font.
How can I change it using python-docx or otherwise?
I am adding math equation to the docx paragraph using below code snippet -
doc_1 = docx.Document()
doc_para = doc_1.add_paragraph()
# create MathML structure
expr1xml = latex2mathml.converter.convert(<math equation as LaTeX expression>)
tree = etree.fromstring(expr1xml)
# convert to MS Office structure
xslt = etree.parse('C:/Program Files/Microsoft Office/root/Office16/MML2OMML.XSL')
transform = etree.XSLT(xslt)
new_dom = transform(tree)
doc_para._element.append(new_dom.getroot())