---
name: Academic Formula Inserter
slug: academic-formula-inserter
category: Writing
description: Academic Formula Inserter inserts, formats, numbers, and validates math equations in Word and LaTeX academic papers. Use it to convert LaTeX formulas to Word OMML, auto-number equations, or check journal-style compliance.
github: "https://github.com/fuwenhao12/academic-ref-inserter/tree/main/.trae/skills/academic-formula-inserter"
language: Python
stars: 55
forks: 1
install: "npx degit https://github.com/fuwenhao12/academic-ref-inserter/tree/main/.trae/skills/academic-formula-inserter ~/.claude/skills/academic-formula-inserter"
installs_to: ~/.claude/skills/academic-formula-inserter
source_path: .trae/skills/academic-formula-inserter/SKILL.md
collection_size: 4
category_size: 1012
collection_url: "https://dirskills.com/collections/fuwenhao12/academic-ref-inserter"
added: 2026-08-12T04:44:06.909Z
last_synced: 2026-08-12T04:44:06.909Z
canonical_url: "https://dirskills.com/skills/academic-formula-inserter"
---

# Academic Formula Inserter

Academic Formula Inserter inserts, formats, numbers, and validates math equations in Word and LaTeX academic papers. Use it to convert LaTeX formulas to Word OMML, auto-number equations, or check journal-style compliance.

**Install:**

```bash
npx degit https://github.com/fuwenhao12/academic-ref-inserter/tree/main/.trae/skills/academic-formula-inserter ~/.claude/skills/academic-formula-inserter
```

## README

# Academic Formula Inserter

Insert, format, number, and validate math formulas in academic papers. Supports **Word (.docx)** with native OMML equations and **LaTeX (.tex)** output, with automatic formatting per journal standards.

## Supported Journal Formats

| Category | Formats | Examples |
|----------|---------|---------|
| **Chinese Core** | GB/T 7714 formula style | 中文核心、CSCD、CSSCI |
| **International** | IEEE, APA, Nature, Science | Elsevier, Springer, Taylor & Francis |
| **General Academic** | Custom numbering & style | Thesis, dissertation, report |

## Formula Numbering Styles

| Style | Example | Used By |
|-------|---------|---------|
| `chinese` | `式(1)` `式(2)` | Chinese core journals |
| `parentheses` | `(1)` `(2)` | IEEE, general |
| `brackets` | `[1]` `[2]` | Some physics journals |
| `section` | `(1.1)` `(2.3)` | Thesis with section-based numbering |
| `latex-tag` | `\tag{1}` `\label{eq:1}` | LaTeX native |

## Commands

### `insert-formula` — Insert LaTeX formula into Word document

Converts LaTeX string to native Word OMML equation and inserts at cursor or specified location.

**Usage:**
```bash
python insert_formula.py insert-formula <docx_path> --latex "<formula>" [--display] [--style <style>] [--number <num>]
```

**Options:**
| Argument | Description |
|----------|-------------|
| `<docx_path>` | Path to .docx file |
| `--latex` | LaTeX formula string (e.g. "E=mc^2") |
| `--display` | Display equation (centered, default: inline) |
| `--style` | Numbering style: `chinese`, `parentheses`, `brackets`, `section`, `none` |
| `--number` | Specific number for the equation |
| `--position` | Paragraph index to insert at |
| `--label` | Equation label for cross-reference |
| `--interactive` | Interactive mode: prompt to choose numbering style from a menu |

### `batch-convert` — Batch convert all LaTeX in document

Scans the document for `$...$` and `$$...$$` patterns and converts them to native OMML equations.

**Usage:**
```bash
python insert_formula.py batch-convert <docx_path> [--backup] [--mode quick|safe|full]
```

### `number-formulas` — Auto-number all equations

Detects all equations in the document and numbers them sequentially according to the specified style.

**Usage:**
```bash
# 指定编号风格
python insert_formula.py number-formulas <docx_path> --style parentheses

# 交互模式: 程序提示用户选择编号风格
python insert_formula.py number-formulas <docx_path> --interactive
```

**支持编号风格 (交互提示):**
```
  编号   名称          示例              说明
  ----------------------------------------------
    1    中文核心      式(1)             适用于中文核心期刊
    2    圆括号        (1)               适用于 IEEE、Elsevier 等国际期刊
    3    方括号        [1]               适用于部分物理/数学期刊
    4    章节编号      (1.1)             适用于学位论文/多章节文档
    5    LaTeX标签     \tag{1}           LaTeX 原生格式
    6    中文+括号     式(1)             中文括号组合
    7    无编号        无                不添加编号
  ----------------------------------------------
  输入编号 (1-7)，或按 Enter 使用默认 [2-圆括号]
```

### `validate-format` — Validate formula format for journal

Checks if all formulas in the document conform to the target journal's style requirements.

**Usage:**
```bash
python insert_formula.py validate-format <docx_path> --journal <journal>
```

### `export-latex` — Export formulas as LaTeX

Extracts all OMML equations from a Word document and exports them as LaTeX code.

**Usage:**
```bash
python insert_formula.py export-latex <docx_path> [--output <output.tex>]
```

### `list-styles` — List all supported journal styles

```bash
python insert_formula.py list-styles
```

## Conversion Pipeline

```
LaTeX string
    │
    ▼
latex2mathml ──── LaTeX → MathML
    │
    ▼
pandoc/mml2omml ── MathML → OMML (Office Math Markup Language)
    │
    ▼
python-docx ────── Insert OMML into .docx paragraph
    │
    ▼
Word native equation (editable, scalable)
```

## Architecture

```
academic-formula-inserter/
├── SKILL.md                           # Skill definition
├── scripts/
│   ├── formula_inserter.py            # Main entry (CLI)
│   ├── latex_omml_converter.py        # LaTeX ↔ OMML conversion
│   ├── formula_numbering.py           # Auto-numbering engine
│   ├── format_validator.py            # Journal format validation
│   └── utils/
│       ├── docx_utils.py              # Word document utilities
│       ├── journal_profiles.py        # Journal format definitions
│       └── omml_builder.py            # Low-level OMML XML building
```

## Requirements

- Python 3.8+
- python-docx
- latex2mathml
- lxml

Optional:
- pandoc (for advanced MathML→OMML conversion)
- pylatex (for LaTeX export)

## Examples

### Insert a display equation with Chinese numbering
```python
python insert_formula.py insert-formula paper.docx ^
    --latex "\sum_{i=1}^{n} x_i = \mu" ^
    --display --style chinese --number 5
```
Result: centered equation with `式(5)` right-aligned

### Batch convert for IEEE submission
```bash
python insert_formula.py batch-convert paper.docx --backup
python insert_formula.py number-formulas paper.docx --style parentheses
python insert_formula.py validate-format paper.docx --journal ieee
```

### Export to LaTeX
```bash
python insert_formula.py export-latex paper.docx --output formulas.tex
```
