Author: Luo Qiang, Jimei University
Convert bare Markdown variables into Word native equations (OMML), then optionally batch-convert OMML equations into MathType OLE objects.
- Finds bare variables in Markdown, such as
P_sc,k,a_k in [0,1],eta_dc,alpha. - Guides conversion into standard LaTeX.
- Uses Pandoc to generate Word native OMML equations.
- Optionally calls MathType's Word macro to convert all OMML equations into MathType OLE objects.
Default output is Word native OMML. MathType conversion is optional and should only run when explicitly needed.
Core Markdown to Word workflow:
- Pandoc
- Microsoft Word or another
.docxviewer for checking output
Optional MathType workflow:
- Windows
- Microsoft Word
- MathType installed as Word add-in
- Python 3.9+
pywin32
Install Python dependency:
pip install -r requirements.txtCheck MathType:
python .\scripts\convert_omml_to_mathtype.py --checkConvert:
python .\scripts\convert_omml_to_mathtype.py "input.docx" "output_mathtype.docx"Success criteria:
Remaining OMML: 0
Output OLE objects: <same as initial OMML count>
Output Equation.DSMT4 markers: <same as initial OMML count>
If MathType batch conversion reports "No equations were found and/or updated"
while the document does contain Word native OMML equations, the issue may be
caused by MathType's OMML2MML.XSL conversion file.
Reference: CSDN troubleshooting note.
Fix:
- Locate the Microsoft Office installation directory that contains Word's
WINWORD.EXE, for example:C:\Program Files\Microsoft Office\root\Office16. - In that same Office directory, replace
OMML2MML.XSLwith the uploaded file:assets/OMML2MML.XSL. - Open the Word shortcut properties and set Start in to the Office directory from step 1.
- Start Word from that shortcut, then run MathType batch conversion again.
The replacement OMML2MML.XSL file has been uploaded to this repository and
can be downloaded directly.
The screenshot below shows Pandoc-generated OMML equations converted into MathType OLE objects and opened in MathType:
- Do not hand-build low-quality OMML for production. MathType may convert unknown nodes into
?. - Recommended route: standard LaTeX -> Pandoc/Word OMML -> MathType conversion.
- For Windows paths with Chinese characters, first copy the file to an ASCII path, then run Python tools.
- Do not commit real papers, generated
.docxfiles,~$*.docxlock files, or__pycache__/.
Apache License 2.0. See LICENSE.
