# KomaDocs > KomaDocs is a slide editor whose document is one plain `.koma` file, written in the Koma language. People edit it as text and on a canvas; agents can edit the same file. Koma is new and probably not in your training data. It looks like Markdown but is not Markdown, Marp or reveal.js slides: do not guess its syntax from them. The language's complete writing reference, with checked examples and typical mistakes, is https://komalang.org/llms-full.txt; this page adds how KomaDocs treats the file. Keep existing source, comments, memos, images and unknown attributes. Change only the requested content. Saving and formatting do not automatically migrate old syntax or wrap loose Markdown. ## Pages and content - An unindented `+++` line always starts a new page, even inside an element, a code or math fence, YAML, CSS, notes or a memo. Anything left open before it is diagnosed and does not carry over to the next page. - `---` is only for page settings, before a page's content. A horizontal rule is `***` (`___` is also read); a `---` after content is reported as `misplaced-settings` and is not drawn, and a `---` line inside an element is shown as written and reported as `dashes-not-rule`. - Everything inside a code or math fence is content: no element, setting or comment starts there. There are no Setext headings. - Write a title as `[title: Night Light and Moths]`, an optional label as `[label: City Moth Survey]`, and a subtitle as `[subtitle: Light changes where moths gather]`. On a cover only, the slots `authors`, `affiliations` and `date` are written as they should appear; `[footer: …]` is an optional footer. Write each slot once per page: a second one is still drawn, on top of the first unless it has a position, and is reported as `duplicate-slot`; where one title is needed, the first is used. - Write visible Markdown inside an explicit `[main: …]` or another box. Loose page-level prose is a box with no place: each run between elements flows inside the page padding, and where that area overlaps a frame written on the page it is reported with `flow-over-slots`. - Write lists, links, tables and footnotes inside the body, along with `**bold**`, `*italic*`, `__underline__`, `~~strike-through~~`, `==highlight==`, superscript `1^{st}` and subscript `H_{2}O`. Write a heading inside the body with one `#`; `##` and deeper are reported as `deep-heading`. Footnotes are `[^label]` with their definition in the same element, and collect at the foot of the page. - Write a short label as `[Ready]{.chip}`. The default, talk and report themes draw `.chip` as a small rounded label and `.primary` as text in the theme's primary colour. Separate multiple classes with spaces, as in `[Ready]{.chip .mark}`. The document's `css:` can define other classes. Undefined classes are reported as `unknown-class`. The brackets and attributes stay on the same line, and code and math keep their own contents. - A definition list is a term on one line, then lines that start with `: ` and give its description (`Transmon` then `: A superconducting circuit`), as Pandoc writes one. Several descriptions per term are allowed; continue a description on an indented line; a blank line between items is allowed. Only a one-line paragraph followed by `: ` is a term, so a `: ` line elsewhere stays text. Terms are drawn on the left with descriptions beside them; a box of class `stack-terms` puts each description under its term. - A figure shows part of its picture with `crop=(top, right, bottom, left)` on its image: shares of the picture cut off each side, in the order CSS inset() uses (`crop=(10%, 0, 5%, 20%)`). The picture file is not changed; PowerPoint gets the whole picture cut by its own crop. - Math is LaTeX: `$...$` inline, or `$$` on its own lines around display math. Code uses fenced blocks with its language; a `mermaid` fence becomes a diagram. - Separate paragraphs with a blank line and let the theme set the space. In slide and poster bodies and boxes, a local heading (`#`) keeps a small space below and a larger one above; consecutive paragraphs and list items use a tight 0.8em default maximum gap; a list or a display block (display math, code, table, quotation, diagram, figure) has the same space above and below, the larger winning where two meet. A frame that does not fit closes these gaps up together before shrinking its text. - Do not add no-break spaces or word joiners to steer line breaks. KomaDocs keeps a number with its unit or Japanese counter (`5 GHz`, `2 回`), and in Japanese text breaks between phrases, lengthens a last line of one or two characters and keeps hyphenated Latin words whole, without changing the source. - Write names inside math (bSWAP, CR, PEQ) with `\text{…}`: they take the face and weight of the surrounding text. The rest of a formula stays regular, in a title or in bold text too; write `\mathbf{…}` or `\boldsymbol{…}` for bold math. - An element's `style="--math-font: fira"` (or `stix2`, or `newcm` for New Computer Modern: the names a theme's `mathFont` takes) draws every formula inside it in that font, nested elements included; the innermost wins, and CSS may set it on a class (`.figure-math { --math-font: fira; }`). Use it to set a figure's math in sans, Greek letters included (`\mathsf` leaves Greek serif). Any other value is reported as `bad-value`. - Pictures use `![what it shows](figures/plot.svg)` on a line of its own, a path relative to the document. Preserve the referenced asset beside the source. In something with a height of its own (the page, a layout frame, rows sharing a height, an element with `h`) such a picture is drawn as a figure with no caption: it fills the space left, keeping its proportions, shared equally with the other figures there. - A picture on its own is `[image src="figures/plot.svg" alt="what it shows":]`; an image has no text inside it. A captioned picture is a figure holding the image: it opens with `[figure:`, has `[image src="figures/plot.svg" alt="what it shows":]` and then its caption on the next lines, indented two spaces, and closes with `]` on a line of its own. Its caption always sits right under the picture, and the picture and caption start at the top of a taller frame; `style="align-content: center"` or `end` moves them. A caption may take several lines and inline notation. When each column of a run of `[col]` holds just one figure, the figures line up by themselves: their pictures share one height and sit at its foot, so the captions start on one line; `align-content` on any of them leaves that run as written. `alt` is optional; `alt=""` marks a decorative picture. With neither `w` nor `h` it fills the space left in what holds it, keeping the picture's proportions; two such figures share that space equally. - A table read from data opens with `[table src="assets/results.csv":`, its caption on the next line, indented two spaces, then `]`; a `.tsv` file is separated by tabs, and cells are plain text. `widths=(1, 3, 2)` on a `[table]` shares its width among the columns by ratio, one positive number for each column; a wrong count is reported with `bad-value` and the columns keep their own widths. A data table's first body paragraph is its caption, drawn above the table; further paragraphs are table notes, drawn under it. To give a Markdown table widths, a caption or notes, write the table inside `[table widths=(1, 3):`, indented two spaces, closed with `]`: one paragraph before the table is its caption, paragraphs after it (past a blank line) are its notes. Two paragraphs before the table, or two tables, are reported. In a Markdown cell, `
` breaks the line; a line break inside a quoted CSV field does the same. A table takes styles as classes, any of them together: `[table .accent .grid .striped .row-heads:`. `grid` rules every column and row; `striped` grounds every other body row; `accent` draws a thick accent line over the table and sets the header row in the accent colour on a faint accent ground, centred; `row-heads` makes each body row's first cell its header (``, bold). The theme sets their colours; with none, a table has horizontal rules only. - Presenter notes sit between two lines containing only `"""`, written with one empty line before the opening line and one after the closing line, like `+++`. They are private to the presenter and are excluded from audience output. Opener attributes are kept and reported as unknown, including the retired `speak`. Inside notes, `[[ Point to the figure ]]` (spaces around the cue are recommended) is a quiet stage direction in plain words that is not read aloud and never a pause; the presenter sees it in single brackets. A line of `[[` alone in column 0 opens an unspoken Markdown block and a line of `]]` alone in column 0 closes it; indent the lines between by two spaces. The presenter sees it as a quiet block, PowerPoint keeps it as a quiet memo, and speech skips it. `[…]{speak=false}` and `[…]{pause=…}` are plain text. Keep these as written. - A memo is a note for the author, placed on the page in the editor and shown by no presentation or export. It opens with a line of `:::` and attributes in column 0 (`x` and `y`, `%` of the page or `px`, may lie off the page; `w` and `h` size it; `collapsed` set to `true` folds it to a pin) and closes with a line of `:::` alone. Its text is plain text, never Markdown, elements or settings. In KomaDocs, Add Memo beside the insert bar puts one on the shown page. Keep the memos you find unless asked to resolve them. A bare `:::` with no attributes is not a memo and is reported. - A line starting with `;` (after an element's structural indentation) is a source comment through to the line's end, on the page, in a box, in loose text and in presenter notes; it is never shown or exported. Write it as `; comment`, one space after `;`. Inside code or math fences, `[code:]`, `[math:]` and `[diagram:]` bodies, YAML and CSS it is text; a `;` within a line is text, and `\;` starts a line with a literal `;`. `//` is not a comment: it is ordinary text. A page-level comment's attachment to a page is not inferred during page moves, copies or deletion; those operations may be refused to preserve it. ## Document and page settings Document YAML at the start uses `===` opening and closing lines and does not belong to any page. Pages are separated by `+++`, with a blank line before and after it. Before its content, a page may have YAML settings between two `---` lines. The first page needs no `+++`. ```text === title: Night Light and Moths theme: default size: 16:9 paginate: true === --- layout: cover --- [title: Night Light and Moths] [subtitle: A fictional night survey] +++ --- layout: content --- [title: City Moth Survey] [main: Every number here is invented. *** This thematic break stays inside the same page. ] ``` The KomaDocs public preview focuses on slides, including page sizes such as 16:9, A4 and A0. Page size does not change the editor. The language also defines article and poster types; those are not the focus of the preview. Document settings include `title`, `type` (`slide`, the default, `article` or `poster`; it never follows from the size), `size`, `theme`, `lang`, `paginate`, `logo`, `logo-alt`, `total-duration`, `transition`, `step-effect`, `functions` and `css`; `layout` may also be a document default; `id`, `class` and `skip` belong to pages. Page settings include `layout`, `id`, `class`, `paginate`, `skip`, `logo`, `logo-alt`, `lang`, `duration`, `transition`, `step-effect` and `style`; `title`, `type` and `size` written there are reported as `setting-out-of-scope`. A page's `transition` is `none`, `fade` or `push`. `step=1`, `step=2` on an element reveals it on that step while presenting, and `step-effect` (`appear`, `fade` or `rise`) sets how it enters. Use `skip: true` to omit a page from presentation and audience exports. `paginate: false` hides that page's number while keeping it in the count. `logo: none` hides an inherited logo. A page's `duration: 1:30` (minutes and seconds) is the time planned for it, and the document's `total-duration: 20:00` the planned whole (else the sum of the pages' durations, skipped pages not counted); the presenter view compares the talk with them, and they are never exported. Any other form is reported as `bad-value` and plans nothing. Notes are never read as time: a first notes line such as `0:59 + 0:04 = 1:03` is reported as `notes-time`, with a fix that moves it into `duration:`. Write `duration:`. YAML comments begin with `#`; CSS comments use `/* … */`. Preserve unknown keys and comments. Unclosed YAML or CSS is retained and diagnosed; do not silently repair or reinterpret it. Page reordering can be refused if comments or shared settings cannot be moved safely. ## Layout and boxes The basic page layouts are `cover`, `section`, `content` and `blank` (a page with no frames). A `theme.koma` can define additional layouts; the official Default, Talk and Report themes add only `outline` (a numbered contents page with larger text and wider lines); they also offer a `[subtitle: …]` on `section` pages. Two columns, a figure beside its explanation or three side by side are a `content` page with `[col]` in its body. Columns are as tall as the tallest one's content, and what follows comes right below; inside an element with `h` they fill that height. A box with a style alone in a column fills the column, and a figure or picture alone in one is as wide as the column. Elements one under the next in a flow are one theme gap apart (`--koma-flow-gap`, 1em); text after text keeps its own spacing. A page added with the list’s + button inherits the selected Koma page’s layout, including `cover`. Master-slide editing, legacy HTML layouts and the old Markdown master syntax are not connected to `.koma` pages. A page takes its own `layout`, then the theme default or `content`. Content is assigned by explicit roles such as `[title: …]`, `[subtitle: …]` and `[main: …]`. Free placement uses a box with percentage or pixel coordinates: ```text [box #memo .tint x=60% y=60% w=30%: Every number here is invented. ] ``` Positions and sizes carry a unit, `%` of the parent or `px`; only `0` may leave its unit out. Attributes of your own start with `data-` (`data-source=fig3`); any other unknown attribute is reported as `unknown-attribute`. A bracketed line without the colon, such as `[TODO]`, is text; start a line with `\[` to keep an element-shaped line as text. The standard form, which `koma format` writes, separates the tag, ID and each class with spaces. In this form, an element whose head has a `key=value` attribute and has content opens on a line of its own ending in `:`, its content indented two spaces below and `]` on its own line; an element without such attributes may stay on one line (`[title: …]`, `[box .tint: …]`); an empty element ends `:]` with no space (`[image src="a.png":]`). Attributes say what an element is and where it goes (`x`, `y`, `w`, `h`, `rotate`, a line's ends and `arrow`, `marker`, `#id`, `.class`); its class and its `style` say how it looks, one way for each. Looks layer theme, then class, then `style`, the later winning. Never write a look as an attribute (`gap=`, `opacity=`, `color=`, `fill=`, `stroke=`): it has no effect and is reported as `presentation-attribute`, with a fix that moves it into `style`. A picture fades by its element's `style="opacity: 50%"`; a line's thickness and dash are `style="stroke-width: 4px; stroke-dasharray: 12px 8px"`; a line on one side of an element's frame is written as CSS names it, `style="border-bottom: 2px solid #2d287f"` (`border-top`, `border-right`, `border-bottom`, `border-left`, each also with `-width`, `-color` and `-style`; the `border` shorthand is not supported), and a theme's CSS takes the same (`title { border-bottom: 2px solid #2d287f; }`); padding on one side is `padding-top`, `padding-right`, `padding-bottom` or `padding-left` with the lengths `padding` takes (`style="padding: 8px; padding-left: 32px"`, the later declaration winning; other values are `bad-value`); a line has no `h` (`line-no-height`). A line's end may name an element on the same page instead of a point: `[line from=#a to=#b arrow=end:]` joins the facing sides' middles and follows the elements; `from-side`/`to-side` (`top`, `right`, `bottom`, `left`) choose a side, and `from-at`/`to-at` a place on it as a share from its top or left end (`to-at=30%`; the middle when not written); `route=elbow` turns it at right angles and `route=curve` bends it as a curve. Text in a line stays in the source; put visible text in a separate text box. Do not also write `x1 y1` for a connected end (`line-end-overridden`); an id not on the page is `unknown-target` and the line is not drawn. Head shapes are classes `.stealth-head`, `.open-head`, `.dot-head`, `.diamond-head` (triangle by default), or per end `style="--head-start: dot; --head-end: stealth"`. Head sizes are `sm`, `md` (default) and `lg`: `style="--head-size: lg"` for both ends, `--head-start-size`/`--head-end-size` for one; heads scale with the line width, as PowerPoint's `headEnd`/`tailEnd` `type`, `w` and `len`. Other values are `bad-value`. A line through more points is `[line points=((100, 200), (300, 260), (500, 200)) arrow=end:]` (pairs `x,y` in logical px, quoted, the first and last its ends; fewer than two is `bad-value`); the class `.smooth` draws a smooth curve through them. A line with `points` connects no elements and takes no route: `x1`…`y2`, `from`, `to` and `route` written with it have no effect (`line-points-overridden`). PowerPoint gets it as a freeform. A curve draws a formula of `t`, which runs from 0 at its box's left to 1 at its right: `[curve x=10% y=20% w=30% h=10% f="sin(2*pi*6*t) * 0.5*(1-cos(2*pi*t))" arrow=end:]`, with no content. Its value is placed between the box's bottom (-1) and top (1), or between the two values of `range=(0, 1)`, fixed rather than fitted; a curve without `h` is a quarter as tall as it is wide. A formula takes numbers (`1e-3`), `t`, `pi`, `e`, `+ - * / ^` (`^` groups from the right and binds tighter than unary minus: `-2^2` is -4), parentheses and `sin cos tan asin acos atan atan2 sinh cosh tanh exp log log10 sqrt abs sign floor ceil round min max mod erf erfc sinc gamma step` (`log` is natural, `sinc(x)` is sin(x)/x with `sinc(0)` 1, `step` is 1 from 0 on, `mod` has the sign of its second argument). Write `*` for every product: `2t` is not read. Define functions under `functions:` in the document's `===` settings, or a theme's (the document's win by name), one per line as `rc(t): 0.5*(1-cos(2*pi*t))` then `drive(t): rc(t)*sin(2*pi*6*t)`; a definition takes one or more parameters, may call others, and may not call itself, directly or through another. An unknown name, a wrong argument count or an unreadable formula is `bad-value` and nothing is drawn; where the formula has no finite value the curve breaks. There are no built-in shapes. Heads, colour, width and dash are a line's (`arrow`, `.stealth-head`, `--head-size`, `.primary`, `stroke-width`); a head points along the curve's end tangent. PowerPoint gets a freeform through the curve's points, its heads as line ends. A style is a class on a box, a callout or a shape, quietest first: `outline` (a thin grey line all round), `card` (a raised white card), `tint` (a light tint of the primary colour), `bar` (a line down the left, tinted from it) or `fill` (solid primary colour, white text); with none, a box has no border or background. A figure takes `card` or `outline`. On shapes and lines, the official themes' `.primary` and `.secondary` take the theme's two role colours. The element's own border and background colours, written in `style=`, override the theme's: `bar` tints from the border colour, and `fill` turns its text dark when white would be hard to read. `[callout: …]` is a box with a marker in a column on its left; everything it holds runs to the right of the marker. Its marker is 💡 unless `marker=` names one emoji or one symbol (`marker="⚠"`, `marker="⇒"`, `marker="※"`); `marker=none` draws none. A text such as `marker=Cost` is no marker: it is drawn as 💡 and reported as `text-marker`; write a text heading as a definition list (the term on one line, the next line starting with `: `). Every marker column is as wide, so callouts written one after another line up. A callout with no style is `tint`, and its content is centred down its height. For a warning, open with `[callout marker="⚠" style="background-color: #fef2f2":`; for a slide's conclusion, with `[callout marker="∴":`, the text on the lines below. A box takes no marker. A `[shape type=ellipse:` element, its text on the lines below, draws an ellipse with the text inside its outline; `type=rect` with `radius=16px` makes a rounded rectangle. Use `[col: …]` and `[row: …]` for nested arrangements; their `weight` sets proportions, and the space between them is `gap` in the `style` of the element that holds them (`[main style="gap: 24px":`). To rule a run of columns, write the class `ruled` on one of them (`[col .ruled: …]`): a thin line is drawn in the middle of each gap, as tall as the columns (across, for rows). To flow one container's content across newspaper-style multi-column columns (for exercise sheets, worksheets, or two-column handouts, as in the `worksheet` theme), write `columns`, `column-gap` and `column-rule` in the container's `style` or theme CSS (`style="columns: 2; column-gap: 24px; column-rule: 1px solid currentColor"`); `column-span: all` spans across columns and `break-inside: avoid` keeps an item whole. To place a column's content down its height, write `align-content` (`start`, `center` or `end`) in its `style` (`[col style="align-content: center":`, its content on the lines below), for example to centre text beside a taller figure; the body frame takes it too, and a theme or the document's CSS sets a layout's default with `@layout content { body { align-content: center; } }`. Preserve existing IDs, classes and geometry unless asked to change them. `[group: …]` only keeps elements together: it has no place, size or look, and what it holds reads and draws exactly as without it, each element keeping its own place. Its head takes only an `#id` and classes. Groups can hold any element, including other groups. Moving or resizing a group on the canvas moves or resizes each element it holds. ## Document CSS Write the document's CSS under `css:` in the `===` settings. After `css: |` it is CSS written in the document; a one-line value ending in `.css` is a CSS file inside the document's folder; a list holds either, applied in the order written. There is no page CSS: give a page a `class` in its settings and select it with `page.class`. `page { … }` styles every page, and `@layout cover { page { … } }` styles pages of one layout. A line along the page's edges is a page border: `page { border-bottom: 8px solid #2d287f; }`, `@layout content { page { … } }`, or one page's own `style: "border-bottom: 8px solid #2d287f"` setting, which wins; a page's `style:` takes only `border` and `border-top|right|bottom|left` (and their `-width`, `-color`, `-style`), anything else is `bad-value`. The line is drawn inside the page under its content, nothing moves, and PowerPoint has each side as a thin filled rectangle along the edge (a line that is not solid stops the export). The document's CSS reaches Markdown's parts inside elements by their HTML names (`p`, `li`, `img`, `th`, `td`). ```text === title: A fictional styled document css: | title { color: #245b78; } page.warm { background: #fdf3e7; } === [title: First page] +++ --- layout: content class: warm --- [title: This page uses its own colour] [main: Visible Markdown. ] ``` CSS stays inside each rendered slide and follows the theme in the normal cascade. A CSS file must stay inside the document's folder and be at most 256 KiB. Imports, external resource URLs and selectors that escape the slide are rejected; an invalid CSS block is retained without applying it. Arbitrary CSS is not guaranteed to reproduce in PowerPoint or match every export format. ## Themes and open documents The current theme source is a `theme.koma` document. Refer to it with document YAML such as `theme: ./themes/example/theme.koma`; keep required assets beside that theme document and with the source when sharing. Open the document’s folder so the theme can be read. The official names are `default`, `talk` and `report`; a document that names no theme uses `default`, and any other name is reported and drawn with `default`. `koma theme copy default -o themes/example` makes an editable copy of an official theme, and `koma theme freeze talk.koma` copies the document's theme beside it and pins `theme:` to that copy. New documents can start with the official Default, Talk or Report themes. Default is a quiet general starting point with Noto Sans CJK JP text and New Computer Modern math (a cover and section pages whose title frame holds three lines with the title at its foot, and whose subtitle frame holds two from its top, so the two meet at one place however long the title is), Talk uses larger text and more space, and Report fits more figures and notes; Talk and Report use Fira math. Their appearance and layouts come from their bundled `theme.koma` documents; specify them as `theme: default`, `theme: talk` or `theme: report`. A theme’s sample page uses `layout: name` to define a layout. Named boxes directly on that page supply default `x/y/w/h` values to matching boxes in the document. The document’s explicit coordinates take priority, and sample text is not copied. The theme document’s document CSS and layout decorations apply to the document. Preserve unsupported content and report diagnostics. A theme document defines appearance and layouts; a document template is a separate `.koma` containing starting content and pages. The person may have the document open in KomaDocs while you edit it. Save whole, valid files and keep unrelated bytes unchanged. Do not reformat or migrate a private document without an explicit request. ## Checking your work and connecting to KomaDocs Check every file you write with the `koma` command (`npm i -g @komalang/koma`, or `npx @komalang/koma`). `koma check talk.koma` reports each problem with its code and line and changes nothing; `koma check --write talk.koma` applies the fixes that keep the meaning and writes the standard form; fixes that may change the meaning need `--write --unsafe`, only when the person asked for that change; `koma check --layout talk.koma` also draws the pages to find overflowing text, using an installed Chrome, Chromium or Edge. Repeat until `koma check` exits with 0. `koma import notes.md -o talk.koma` translates Markdown to Koma, `koma pack talk.koma --cover` builds a `.komadoc` archive carrying an optional first-page cover preview (`Content.textbundle/preview.png`, KDOC-013), and `koma export talk.koma -o talk.pdf` writes HTML, PDF or PowerPoint by the output's ending. In the macOS app, the chat-first Agent panel renders offline LaTeX equations and connects to local models (Ollama / LM Studio in `Settings › AI Models`), Continue with ChatGPT, or external MCP agents. To connect an external MCP agent, the person opens the compact `MCP` popover at the top of the Agent panel and turns on **Share This Document** (and can register clients in one click or manage remembered approvals stored in `remembered.json` under `Settings › External AI (MCP)`). An MCP client then connects over stdio with the server command `komadocs mcp`. Through it an agent reads the open document, its pages, pictures and problems, and proposes edits that the person accepts or rejects hunk by hunk; nothing changes until a proposal is accepted, and one Undo takes an accepted proposal back. On macOS, **Edit Theme** opens the document's `theme.koma` in its own window (`desktop_open_theme`). To serve files without the app, `koma mcp talk.koma` serves named files over stdio, read-only: the client reads, renders and lints them, and edits the source itself. KomaDocs itself sends nothing to any AI service unless the person explicitly enables one.