word2latex
Skill8 starsChanged 2 months agoMITView on GitHub
Convert a Word .docx template (Mitacs, CRSNG, FRQNT, UQAC, partner forms) into a faithful LaTeX source. Use when the user asks to translate a Word gabarit to LaTeX, when a generated .tex must match a .docx visually, or for /word2latex. Drives pandoc + applies the standard patch sequence (Arial, full-grid tables, centered sections, landscape geometry, first-page banner). Delegates the actual patch work to the word-to-latex agent.
- Installs packages
In this repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/skills/AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- aider-setupSkill
- deliberationSkill
- drawio2tikzSkill
- extract-contributionsSkill
- extract-futureworksSkill
- extract-paper-ideaSkill
- extract-statisticSkill
- form-serviceSkill
- geolocalisationSkill
- latex-hygieneSkill
- loop-engineerSkill
- narrative-cvSkill
- obsidian-cliSkill
- opt-local-stt-vramSkill
- opt-local-vram-llmSkill
- paper2talkSkill
- recommendation-letterSkill
- rt-observeSkill
- scholar-evaluationSkill
- scientific-writingSkill
- scopusSkill
- word2latexSkill
- aider-setupSkill
- deliberationSkill
- drawio2tikzSkill
- extract-contributionsSkill
- extract-futureworksSkill
- extract-paper-ideaSkill
- extract-statisticSkill
- form-serviceSkill
- geolocalisationSkill
- latex-hygieneSkill
- loop-engineerSkill
- narrative-cvSkill
- obsidian-cliSkill
- opt-local-stt-vramSkill
- opt-local-vram-llmSkill
- paper2talkSkill
- recommendation-letterSkill
- rt-observeSkill
- scholar-evaluationSkill
- scientific-writingSkill
- scopusSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 41
Run the inspector to extract every value the LaTeX preamble needs:
- Distinctive: line 127
If any page does not match, return to the agent with the specific page index and the discrepancy.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
word2latex Skill
Prerequisites
Before running, verify:
pandocinstalled:pandoc --versionpython-docxavailable (used bydocx_inspect.py):python -c "import docx; print('OK')"— if missing,pip install python-docxpdflatexandpdftoppmreachable from the shell (any TeX distribution + poppler)- The
.docxfile is closed in Word (otherwise the~$lock file blocks reads)
Mode dispatch
$ARGUMENTS is the path to the .docx file (or a directory containing exactly one .docx).
/word2latex <path-to-docx>Optional flags appended after the path:
| Flag | Effect |
--engine=pdflatex (default) | Use helvet to approximate Arial |
--engine=xelatex | Use fontspec with native Arial |
--no-banner | Skip the first-page TikZ banner block (use for plain documents without a colored header strip) |
--legal-landscape | Enable the Legal-landscape macros (14×8.5 in) — needed only if the docx has <w:pgSz w:w="20160" w:h="12240"> |
--bibliography | Manuscript mode: extract the numbered bibliography to a first-pass .bib, rewrite inline citations to \cite, then validate via /bibclean + /scopus. Opt-in; off for form gabarits. |
Workflow
Step 1 — Inspect the .docx
Run the inspector to extract every value the LaTeX preamble needs:
cd "<docx directory>"
python "<workspace>/.claude/skills/word2latex/scripts/docx_inspect.py" <file.docx>The script prints a structured report with:
- Default font + size
- Line spacing
- Each
<w:sectPr>(orientation, page size, margins, header/footer references) - Heading1 / Heading2 / Title styles (font, size, color, alignment)
- Table border defaults
- Image catalog (path, dimensions, dominant color, transparency stats)
- Header and footer text per section
Save the report — every preamble decision below traces back to it.
Step 2 — Run pandoc
pandoc "<file.docx>" -o "<file>.tex" --extract-media="img_<file>"This produces a .tex with longtables, hyperlinks, and image references in place but without the visual fidelity adjustments. Do not edit the pandoc output until step 3.
Step 3 — Delegate to the word-to-latex agent
Hand off to the agent with the inspector report as context:
Use the word-to-latex agent to patch <file>.tex against the inspector report above.
Apply the full standard patch sequence in order. The banner uses image<N>.png
(white wordmark) on the left; pages <M>–<P> are landscape <orientation>.The agent applies the 10-step patch sequence documented in
.claude/skills/word2latex/references/preamble_patches.md.
Step 3b — Manuscript bibliography (optional, --bibliography only)
Skip this step for form gabarits. Run it only when the .docx is a manuscript
(numbered references + inline citations) and --bibliography was passed.
- Second pandoc pass to markdown (keeps explicit
1.numbering):pandoc "<file.docx>" -t gfm -o "<file>.md" - Extract the bibliography and rewrite citations:
Producespython "<workspace>/.claude/skills/word2latex/scripts/manuscript_bib.py" ` "<file>.tex" --bib-source "<file>.md"<file>.cited.tex(citations as\cite{...}) and<file>.first-pass.bib. - Validate and enrich the bibliography (respects the project reference rules —
approved publishers, clickable DOI):
/bibclean <file>.first-pass.bib /scopus validate <file>.first-pass.bib - The agent (Step 3) then injects the
biblatexpreamble and replaces the pandoc-rendered reference list with\printbibliography.
Full details: .claude/skills/word2latex/references/manuscript_bibliography.md.
Step 4 — Compile and render
pdflatex -interaction=nonstopmode -output-directory=out "<file>.tex"
pdflatex -interaction=nonstopmode -output-directory=out "<file>.tex"
Remove-Item out\page-*.png -ErrorAction SilentlyContinue
pdftoppm -png -r 120 out\<file>.pdf out\pageTwo pdflatex passes are required for \pageref{LastPage} and longtable column widths.
Step 5 — Visual verification
Read at minimum:
- Page 1 — banner, white wordmark on left, title centered, icon on right, no duplicate header
- Each landscape page — text + table on the same page, full grid visible
- The last page — footer reads correctly, no orphan content from a previous section
If any page does not match, return to the agent with the specific page index and the discrepancy.
Output formatting
Final response to the user lists:
- The
.texfile path - The page count of the resulting PDF
- For each landscape page: dimensions in inches
- Any unresolved overfull
\hbox≥ 5 pt (smaller are absorbed by\hfuzz=3pt) - The verification rendering folder (
out/page-*.png)
Error handling
| Error | Action |
pandoc: command not found | Ask user to install pandoc or add it to PATH |
python-docx missing | pip install python-docx then retry |
~$<file>.docx lock present | Ask user to close the document in Word |
! Misplaced \noalign | A \toprule/\midrule was missed by the rule-replacement pass — re-run replace booktabs rules with \hline |
Command \endLegalLand already defined | Macro name collides with \begin{LegalLand} / \end{LegalLand} semantics — rename to \Open.../\Close... |
paperwidth not available in \newgeometry | Geometry forbids paper-size keys mid-document — set \pdfpagewidth and \paperwidth before the \newgeometry call |
| Calendar table spills to a second page | Apply row-compaction: replace minipage+enumerate cells with \textbf{N) text}, set \renewcommand{\arraystretch}{0.95}, use \footnotesize |
| Right header text missing | Header logo image has no width constraint and pushes the right slot off-page — set width=3.5cm,keepaspectratio on the \includegraphics in \fancyhead[L] |
Entries : 0 from manuscript_bib.py | The bibliography is not numbered as 1./2. in the source — run the -t gfm markdown pass and pass it via --bib-source |
| Unresolved cites > 0 after validation | A \cite{refN} survived — the source citation number has no matching numbered reference; fix the source numbering or the reference list |
See also
- Agent:
.claude/agents/word-to-latex.md - Patch reference:
.claude/skills/word2latex/references/preamble_patches.md - Manuscript bibliography reference:
.claude/skills/word2latex/references/manuscript_bibliography.md - Inspector script:
.claude/skills/word2latex/scripts/docx_inspect.py - Bibliography module:
.claude/skills/word2latex/scripts/manuscript_bib.py
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

