Preface¶
When working on document-related workflows in DeepSeek Harness (DSH), a common pipeline is: the model or script first produces a .docx containing LaTeX, which is then handed off to the author for typesetting in Word. If the final deliverable targets journals or collaborators still using MathType, manually converting \[...\] and $...$ into MathType objects is costly and prone to disrupting equation numbering, SEQ fields, bookmarks, and REF cross-references.
The community plugin dsh-mathtype (maintainer DIPPER12138) addresses this: on Windows, it leverages the MathType SDK and Word automation to replace LaTeX placeholders in a document in-place with OLE objects whose ProgID="Equation.DSMT4", rather than Word’s built-in OMML or images. The rest of the document’s structure is preserved without a full rebuild.
What Is This¶
dsh-mathtype is a plugin registered with DSH. Once mounted, it adds a callable skill mathtype to ctx.skills. Its core capability: read LaTeX placeholder paragraphs conforming to a defined rule set from a Word .docx, use the MathType SDK to write them as genuine MathType equations that can be double-clicked for editing in Word, and preserve existing numbering and field logic as much as possible.
- Repository: DIPPER12138/dsh-mathtype
- Community directory: SkillHub plugin page
- License: MIT (
package.jsonversion 0.1.0) - The plugin package has no third-party JavaScript dependencies; registration logic uses only
node:fs,node:path, andnode:url, facilitating offline installation.
Core Features¶
Conversion Model¶
The plugin edits the original document through Word’s own automation, so the README explicitly states that existing equation numbering, SEQ fields, bookmarks, REF cross-references, figures, tables, and styles will not be rebuilt wholesale.
Recognition rules (one placeholder per paragraph) — examples:
| Source text | Result |
|---|---|
\[a=b\tag{7}\] |
Centered MathType object, number (7) on the right |
\[a=b\tag{2a}\] |
Number (2a), sub-number letter preserved |
\[a=b\] |
Centered object, no number |
$a=b$ |
Inline object |
Numbers inside \tag{...} are not regenerated; existing SEQ fields, bookmarks, or literal values (e.g., 2a) are preserved as-is so that REF can still resolve them.
Scripts and Skills Shipped with the Plugin¶
The README summarizes the responsibilities of the main files as follows (all within the skill directory, available for model or command-line invocation):
| Path | Purpose |
|---|---|
mt_env.py |
Discovers MathType, MT6.dll, Word, and Python dependencies; runs a smoke test on the SDK |
mt_sdk.py |
Wraps MT6.dll: connect, set_latex, get_text, close |
mt_prefs.py |
Adjusts equation font size via the registry; restores after completion |
word_session.py |
Word session resilient to RPC crashes and late binding |
convert_docx.py |
Executes conversion; supports --dry-run, --overrides, --report |
verify_docx.py |
Structural validation: ProgID, CFB, Equation Native, relationships, ShapeID, bookmarks, fields, etc. |
render_check.py |
Exports PDF, generates per-page and per-equation QA tables (optional dependencies) |
make_fixture.py |
Generates a test document with 6 equations and real SEQ fields |
Command-Line Arguments (Conversion)¶
--size: Equation font size (e.g.,10.5or"10.5 pt"); restores the user’s original MathType settings after the run.--align none: Does not modify paragraph formatting.--overrides fixes.json: Replace individual equations by tag.
The README provides a magnitude reference: converting approximately 54 equations takes about 10–15 minutes.
Environment Requirements¶
| Component | Requirement |
|---|---|
| OS | Windows 10/11 (no macOS/Linux equivalent for COM/OLE) |
| MathType | MathType 7 desktop full installation (a fonts-only package does not include System\<arch>\MT6.dll) |
| Word | Desktop Word 2016/2019/2021/365, not a viewer, not LibreOffice |
| Python | 3.10+, bitness matching MT6.dll (64-bit Python corresponds to System\64\MT6.dll) |
| Python packages | pywin32, lxml; optional pymupdf, Pillow (for render_check only) |
Installation paths are not hardcoded: MathType directories, SDK DLLs, and preference files are resolved from the registry at runtime.
python -m pip install pywin32 lxml
python -m pip install pymupdf Pillow # optional, render check only
Installation and Activation¶
The plugin cannot install MathType, Word, or Python packages for you. After installing the plugin, restart dsh, and the mathtype skill directory will appear. If you have previously manually copied a skill of the same name to ~/.dsh/skills/mathtype, delete it first to avoid duplicate registration.
# from GitHub — use the profile you actually run (`desktop` or `web`)
dsh plugin --profile desktop add github:DIPPER12138/dsh-mathtype
# or from a local checkout, for development
dsh plugin --profile desktop add /absolute/path/to/dsh-mathtype
Uninstallation:
dsh plugin --profile desktop remove dsh-mathtype
Permissions and security: The plugin runs with the permissions of the current dsh process and will invoke local Word, MathType, and COM. Please review the repository source code and the MIT license yourself before installation; this introduction is not a substitute for your security review.
Typical Usage¶
1. Verify the Machine First¶
python <skill-dir>/scripts/mt_env.py
The exit code is 0 only when the MathType directory, DLL, Word version, dependencies, and MTAPIConnect are all ready. A new environment can use the built-in fixture to walk through the pipeline end-to-end (the README says about two minutes):
python scripts/make_fixture.py -o fixture.docx -f
python scripts/convert_docx.py fixture.docx -o fixture-out.docx --size 10.5
python scripts/verify_docx.py fixture.docx fixture-out.docx --expect 6
2. Dry Run and Full Conversion¶
The dry run reads the .docx package only; it does not launch Word or touch COM:
python scripts/convert_docx.py manuscript.docx -o manuscript-MathType.docx --dry-run
Full conversion with report writing:
python scripts/convert_docx.py manuscript.docx -o manuscript-MathType.docx \
--size 10.5 --report conversion.json
3. Validation and Optional Render Check¶
python scripts/verify_docx.py manuscript.docx manuscript-MathType.docx --expect 54
python scripts/render_check.py manuscript-MathType.docx --outdir qa
In a DSH conversation, once mounting is complete, mathtype appears in the skill directory, and the agent calls the above script paths according to the skill instructions; specific prompts are governed by the skill definition within the repository.
Use Cases and Limitations¶
Suitable for: In a Windows submission pipeline, .docx files that already contain LaTeX placeholders and need to be batch-converted into double-clickable, editable MathType OLE objects while preserving SEQ/bookmark/cross-reference structures — a post-processing step for dissertations, textbooks, or journal manuscripts.
Not suitable for or cannot do (limitations from the README):
- Non-Windows environments.
- Not responsible for writing or validating mathematical content; it only converts existing placeholders.
- Does not provide batch MathType → LaTeX (the SDK wrapper layer does have
get_text()for single equations). - Does not generate Word OMML (that is a different direction).
- Requires locally installed MathType; the plugin does not bundle the SDK DLL.
MathType is a trademark of Design Science; this plugin only calls the MathType SDK on the user’s machine.
Closing¶
dsh-mathtype consolidates “LaTeX placeholder .docx → real Equation.DSMT4” into a reusable skill within DSH, bundled with environment detection, conversion, structural validation, and optional QA export. If your workflow’s endpoint is Word + MathType rather than pure OMML, install the plugin on a Windows machine with MathType and Word, following the README, and run mt_env.py first.
- Directory page: https://www.skillhub.cn/plugins/DIPPER12138/dsh-mathtype
- GitHub: https://github.com/DIPPER12138/dsh-mathtype
The community directory SkillHub is an independent site with no official affiliation with DeepSeek or High-Flyer; the plugin’s source and behavior are governed by the repository README.