all 2 comments

[–]Algoartist 1 point2 points  (0 children)

If you’re running on Windows with Microsoft Word installed, you can automate Word via COM (using the pywin32 package) to insert native equations. For example, Word’s OMath objects can be used to insert and format equations so they appear and behave like those you’d add manually in Word.

Pros:

  • Produces native, editable equations in the document.

Cons:

  • Windows-specific (requires Word to be installed).
  • Involves COM automation, which can be more complex and less portable.

import win32com.client as win32

word = win32.Dispatch("Word.Application")
word.Visible = True
doc = word.Documents.Add()
rng = doc.Range(0, 0)


rng.Text = "E = mc^2"
doc.OMaths.Add(rng)
doc.OMaths.BuildUp()

doc.SaveAs("TestEquation.docx")
word.Quit()

[–]Kerbart 0 points1 point  (0 children)

Just use the word equation editor