Image → LaTeX (OCR) → MathML → OMML → Word (native equation)
- pix2tex — neural network that recognizes a formula from a photo and returns LaTeX code.
- latex2mathml — converts LaTeX to MathML.
- MML2OMML.XSL — Microsoft XSLT transformation converts MathML to OMML (Office Math Markup Language).
- python-docx — inserts the OMML element as a native Word equation.
- 📷 Recognition from photo — open an image or paste from clipboard (Ctrl+C screenshot → "Paste from clipboard")
- ✂️ Select one formula — draw a box around the needed formula in the photo
- ⌨️ Manual LaTeX input — type or edit a formula manually
- 📋 Copy formula — copies MathML to clipboard, pastes into Word as a native equation (Ctrl+V)
- 💾 Save to Word — one or multiple formulas to a .docx file
- 🌐 Bilingual UI — Ukrainian and English (toggle button in the top-right corner)
- Python 3.10+
- Microsoft Office (requires
MML2OMML.XSLfile, shipped with Office) - Internet connection on first run (downloads OCR model ~500 MB)
# 1. Clone the repository
git clone https://github.com/<your-username>/formulas-to-word.git
cd formulas-to-word
# 2. Create a virtual environment
python -m venv venv
.\venv\Scripts\Activate.ps1
# 3. Install PyTorch (CPU)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
# 4. Install dependencies
pip install -r requirements.txtpython formula_to_word.pyOr double-click run.bat.
Tab "Recognize from photo":
- Click "Open photo" or "Paste from clipboard" (for screenshots).
- Select one formula with the mouse on the image.
- Click "Recognize" — the program will return LaTeX code.
- Check / edit LaTeX in the text field.
- "Preview" — see how the formula will look.
- "Save to Word" — saves to a .docx file.
- "Copy formula" — copies to clipboard, paste into Word via Ctrl+V.
Tab "Enter LaTeX":
- Type a formula manually, preview and save or copy.
- Batch mode: add multiple formulas via "Add to list", then save all at once.
The program searches for this file automatically. Typical locations:
C:\Program Files\Microsoft Office\root\Office16\MML2OMML.XSL
C:\Program Files (x86)\Microsoft Office\root\Office16\MML2OMML.XSL
If not found automatically, the program will ask you to locate it manually.
formulas-to-word/
├── formula_to_word.py # Main script (GUI + logic)
├── FormulyWord.spec # PyInstaller spec (portable EXE build)
├── run.bat # Quick launcher (Windows)
├── requirements.txt # Python dependencies
├── .gitignore
└── README.md
Для збірки EXE без встановлення Python:
pip install pyinstaller
pyinstaller FormulyWord.spec --noconfirm