Generate world-class, professionally designed Microsoft Word (.docx) documents that look like a designer and communications specialist worked on them together — not AI output. Use when producing any .docx file: reports, proposals, manuals, specifications, letters, or any formal document. Covers Pandoc/python-docx generation, typography, layout, visual hierarchy, clear writing, Word styles, tables, headers/footers, TOC, cover pages, and final document polish. Produces documents that pass a professional design and editorial review.
Two things kill document quality equally: bad design and bad writing. A document must pass both tests. This skill addresses both.
Reference files (read when needed):
references/typography-layout.md — fonts, spacing, margins, colour palettes, visual hierarchyreferences/written-communication.md — structure, clarity, tone, anti-patternsreferences/word-features.md — styles, TOC, tables, images, sections, cover pages, watermarksreferences/quality-checklist.md — pre-delivery checklist (run before every delivery)Every document produced must pass this bar: a professional communications specialist and a document designer would both be satisfied. This means:
Documents are produced via Pandoc + python-docx + reference.docx template:
Markdown source (structured content)
↓ pandoc --reference-doc=templates/reference.docx
.docx (styles applied from reference.docx)
↓ manual python-docx post-processing (cover page, TOC, header/footer)
Final .docx → PDF export
# Single document
pandoc source.md -o output.docx --reference-doc=templates/reference.docx
# With table of contents
pandoc source.md -o output.docx --reference-doc=templates/reference.docx --toc --toc-depth=3
# Rebuild reference.docx from scratch
python scripts/create-reference-docx.py
Pandoc maps Markdown elements to named Word styles in reference.docx. Never bypass this with direct formatting.
| Markdown element | Word style |
|---|---|
# Heading | Heading 1 |
## Heading | Heading 2 |
### Heading | Heading 3 |
#### Heading | Heading 4 |
| Body paragraph | Normal |
```code block``` | Source Code / Verbatim |
`inline code` | Verbatim Char |
> blockquote | Block Text |
| Table | Table Grid |
YAML title: | Title |
YAML subtitle: | Subtitle |
*Caption* below figure/table | Caption |
If a style needs to change, change it in reference.docx — never in the document directly.
These rules are mandatory. They determine how the document breathes across pages and whether the reader can follow the structure without effort.
Every # Heading 1 forces a page break before it. Major sections never share a page with the section that precedes them. This makes the document scannable: readers flipping through pages immediately see where each chapter/section begins.
Word setting: Paragraph → Line and Page Breaks → Page break before = ON
python-docx:
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
h1 = doc.styles['Heading 1']
h1.paragraph_format.page_break_before = True
h1.paragraph_format.keep_with_next = True # heading never orphaned alone
If the heading plus its first following paragraph do not entirely fit on the current page, the whole unit moves to the next page. A heading that appears at the bottom of a page with its content on the next page is a design failure.
Word settings on Heading 2 and Heading 3:
Word setting on Normal / body paragraphs:
This combination means: the heading is glued to the paragraph that follows it, and that paragraph will not be split across pages. If the pair doesn't fit, both move to the next page.
python-docx:
for style_name in ['Heading 2', 'Heading 3']:
style = doc.styles[style_name]
style.paragraph_format.keep_with_next = True
style.paragraph_format.keep_together = True
# Body paragraphs: never split mid-paragraph
doc.styles['Normal'].paragraph_format.keep_together = True
No paragraph's first line appears alone at the bottom of a page (orphan), and no paragraph's last line appears alone at the top of a page (widow).
Word setting: Paragraph → Line and Page Breaks → Widow/Orphan control = ON (this is the Word default but must be confirmed in reference.docx).
doc.styles['Normal'].paragraph_format.widow_control = True
| Style | Page break before | Keep with next | Keep lines together | Widow/orphan |
|---|---|---|---|---|
| Heading 1 | ON | ON | — | — |
| Heading 2 | OFF | ON | ON | — |
| Heading 3 | OFF | ON | ON | — |
| Heading 4 | OFF | ON | ON | — |
| Normal | OFF | OFF | ON | ON |
| Body Text | OFF | OFF | ON | ON |
| Caption | OFF | OFF | OFF | OFF |
Read references/typography-layout.md for full font stacks and spacing tables. The standard corporate stack:
| Element | Font | Size | Colour |
|---|---|---|---|
| Title | Calibri Light | 28pt Bold | #1F3864 |
| Heading 1 | Calibri Light | 16pt Bold | #1F3864 |
| Heading 2 | Calibri Light | 13pt Bold | #2E5D8A |
| Heading 3 | Calibri | 11pt Bold | #4472C4 |
| Body / Normal | Calibri | 11pt Regular | #262626 |
| Code | Consolas | 9.5pt Regular | #1A1A1A |
| Caption | Calibri | 9pt Regular | #595959 |
| Header/Footer | Calibri | 9pt Regular | #595959 |
Heading 1 visual anchor: 4.5pt navy left border bar — applied via style paragraph border, not manual formatting.
Never press Enter twice to create space. Use style space-after settings.
| Style | Before | After | Line |
|---|---|---|---|
| Heading 1 | 20pt | 6pt | Single |
| Heading 2 | 14pt | 4pt | Single |
| Heading 3 | 10pt | 3pt | Single |
| Normal | 0pt | 6pt | 1.15× |
---