Home

Word (DOCX) Theme Target

Overview

When Stencila renders DOCX, theme tokens are translated into Word styles (paragraph, character, and table styles) plus section layout. The encoder uses computed theme variables so CSS values (including calc() and color-mix()) resolve before mapping into DOCX.

This translation happens whenever you create a Word document with Stencila, for example using the CLI's render command:

stencila render report.myst report.docx

Theme Module Coverage

The DOCX encoder maps specific theme modules into Word styles. This keeps the mapping predictable and aligns with the CSS architecture.

Theme moduleDOCX outputImplementation
tokens-semantic.cssDocument defaults + Normalencode_theme.rs
headings.cssHeading1-9 + Heading1Char-9Charencode_theme.rs
paragraphs.cssNormal + BodyTextencode_theme.rs
code.cssVerbatimChar (inline code)encode_theme.rs
links.cssHyperlink styleencode_theme.rs
quotes.cssBlockText styleencode_theme.rs
lists.cssList paragraph spacing (markers via numbering.xml)encode_theme.rs
tables.cssTable style + TableCaptionencode_theme.rs
figures.cssImageCaption + CaptionedFigureencode_theme.rs
works.cssTitle, Author, Abstract, AbstractTitleencode_theme.rs
pages.cssPage size, margins, headers/footersencode_page_layout.rs

Page Layout (Paged Media)

Paged media tokens (e.g. --page-width, --page-margin-*, --page-top-*-content) are translated into DOCX section properties and header/footer content. First-page overrides (--page1-*) map to the DOCX first-page header/footer definitions.

Gaps and Not-Yet-Mapped Areas

Some web-only or interactive modules are not mapped to DOCX styles. As of the current implementation:

  • Not yet mapped: admonitions.css, breaks.css, citations.css, labels.css, references.css

  • Not applicable to DOCX: datatables.css, diagrams.css, images.css, plots.css, math.css

For the authoritative mapping details, see encode_theme.rs and encode_page_layout.rs.

© 2026 Stencila