zhouder

latex-forge

Convert Microsoft Word .docx files and PDF .pdf files into compilable LaTeX projects. Use when Codex needs to transform DOCX/PDF sources into a project containing main.tex, figures/, references.bib, and a conversion report while preserving headings, lists, tables, equations, footnotes, images, captions, and Chinese document support with ctexart or xeCJK. Also use to inspect PDFs for extractable text and stop with an OCR-required message for scanned/image-only PDFs.

zhouder 0 Updated 1mo ago

Resources

9
GitHub

Install

npx skillscat add zhouder/latex-forge

Install via the SkillsCat registry.

SKILL.md

LaTeX Forge

Convert .docx and .pdf sources into editable LaTeX project folders.

Default Workflow

Use the unified client first:

python scripts/latex_forge.py convert input.docx output-project
python scripts/latex_forge.py convert input.pdf output-project

For non-technical users who want a local graphical client:

python scripts/latex_forge_gui.py

For Windows distribution, build the app EXE and installer EXE:

powershell -ExecutionPolicy Bypass -File packaging\build_windows.ps1

Expected output:

output-project/
  main.tex
  figures/
  references.bib
  conversion-report.md

For Chinese documents, compile with XeLaTeX or LuaLaTeX. The converters detect CJK text and default to:

\documentclass[UTF8]{ctexart}

If ctex is unavailable, rerun with:

python scripts/latex_forge.py convert input.docx output-project --engine xeCJK

Commands

Inspect a file before converting:

python scripts/latex_forge.py inspect input.pdf
python scripts/latex_forge.py inspect input.docx

Convert and attempt a local LaTeX build when a TeX engine exists:

python scripts/latex_forge.py convert input.docx output-project --compile

Run the converters directly only when debugging:

python scripts/docx_to_latex.py input.docx output-project
python scripts/pdf_to_latex.py input.pdf output-project

Run self-tests after editing the skill:

python scripts/smoke_test.py

Conversion Contract

DOCX conversion should preserve or approximate:

  • Headings as section commands
  • Ordered and unordered lists
  • Tables as tabular
  • OMML equations as approximate LaTeX math
  • Footnotes as \footnote{...}
  • Images copied into figures/
  • Caption-styled paragraphs attached to adjacent figures or tables

PDF conversion should:

  • Extract text from searchable PDFs
  • Create a compilable draft main.tex
  • Refuse scanned/image-only PDFs with a clear OCR-required message
  • Avoid claiming semantic fidelity for PDF tables, equations, and references

Review Gate

Before final delivery to a user:

  1. Confirm main.tex, figures/, references.bib, and conversion-report.md exist.
  2. Read conversion-report.md for warnings.
  3. Inspect and repair equations, tables, captions, citations, and cross-references.
  4. Compile with XeLaTeX when available, especially for Chinese documents.
  5. Tell the user when OCR, manual equation repair, table cleanup, or citation reconstruction remains.

Detailed Reference

Read references/conversion-notes.md when:

  • A conversion has warnings
  • A source document contains complex equations, tables, captions, references, or Chinese text
  • A PDF appears scanned or low-quality
  • The user asks how to install, run, or validate the skill outside Codex