The specification on one page
On this page
Every chapter of the specification, in order, so the browser’s find searches all of it.
Lexical structure
How a .koma file is read as characters and lines, before any element is recognised.
Grammar
The individual rules are normative. The grammar outlines the structure. Indentation depth starts at zero, with two spaces per level. Root delimiter lines (===, ---, +++, :::, """) start in column 0.
# Document and pages
Document <- BOM? Preamble Page (PageBreak Page)*
Preamble <- BlankLine* (DocumentSettings BlankLine*)?
DocumentSettings <- DelimiterLine('=') YamlLine* DelimiterLine('=')
Page <- (BlankLine / CommentLine(0))* PageSettings? PageItem*
PageSettings <- DelimiterLine('-') YamlLine* DelimiterLine('-')
PageBreak <- DelimiterLine('+')
PageItem <- Element(0) / Notes / Memo / CommentLine(0) / BlankLine / Recovery / PageText
Notes <- '"""' (HorizontalSpace+ AttributeAssignment)* HorizontalSpace* LineEnd NoteLine* '"""' HorizontalSpace* LineEnd
Memo <- ':::' ':'* (HorizontalSpace+ AttributeAssignment)+ HorizontalSpace* LineEnd MemoLine* ':::' ':'* HorizontalSpace* LineEnd
# Elements and tags
Element(depth) <- Indent(depth) (SingleLineElement / MultiLineElement(depth))
SingleLineElement <- '[' Tag HorizontalSpace* ':' ' '? Content? ']' HorizontalSpace* LineEnd
MultiLineElement(depth) <- '[' Tag AttributeLine(depth)* TagEnd(depth) ' '? Content? LineEnd ContentLine* ElementEnd(depth)
Tag <- TagName? IdShorthand? ClassShorthand* (HorizontalSpace+ Attribute)*
AttributeLine(depth) <- HorizontalSpace* LineEnd Indent(depth + 1) Attribute (HorizontalSpace+ Attribute)*
TagEnd(depth) <- (HorizontalSpace* LineEnd Indent(depth + 1))? HorizontalSpace* ':'
# Attributes and values
Attribute <- IdShorthand / ClassShorthand / AttributeAssignment
IdShorthand <- '#' Id
ClassShorthand <- '.' ClassName
AttributeAssignment <- AttributeName '=' AttributeValue
AttributeName <- Word
AttributeValue <- QuotedString / ValueList / UnquotedScalar
QuotedString <- '"' (Escape / !('"' / '\\' / LineEnd) .)* '"'
UnquotedScalar <- (Dimension / Percentage / Number / HashValue / Word) &(HorizontalSpace / ':' / ']' / LineEnd)
Word <- [A-Za-z] [A-Za-z0-9_-]*
Number <- [+-]? (Digit+ ('.' Digit+)? / '.' Digit+) ([eE] [+-]? Digit+)?
Percentage <- Number '%'
Dimension <- Number Unit
HashValue <- '#' Id
ValueList <- '(' HorizontalSpace* (ValueListItem (HorizontalSpace* ',' HorizontalSpace* ValueListItem)*)? HorizontalSpace* ')'
ValueListItem <- QuotedString / ValueList &(HorizontalSpace* (',' / ')')) / Expression
Expression <- (Parenthesized / !(',' / ')' / '(' / '"' / LineEnd) .)+
Parenthesized <- '(' (Parenthesized / !(')' / LineEnd) .)* ')'
# Common lexical rules
DelimiterLine(c) <- c c c c* ReservedDelimiterSuffix? HorizontalSpace* LineEnd
ReservedDelimiterSuffix <- HorizontalSpace+ (!LineEnd .)+
BlankLine <- HorizontalSpace* LineEnd
CommentLine(depth) <- Indent(depth) ';' (!LineEnd .)* LineEnd
Indent(0) <- ''
Indent(depth + 1) <- ' ' Indent(depth)
HorizontalSpace <- ' ' / '\t'
LineEnd <- '\r\n' / '\n' / '\r'
# Recovery and diagnostics
Recovery <- MisplacedPageSettings / ReservedBlock
MisplacedPageSettings <- DelimiterLine('-')
# Marks a reserved block. Its full extent is described below.
ReservedBlockStart <- ':::' ':'*
- A
+++in column 0 breaks the page even inside an element, code, math, CSS, YAML or notes. Recognize page breaks first and confine other structures to a page (Page boundaries). PageTextis prose written directly on a page. Each consecutive run enters the page's flow as one[box:]with no explicit position. A line beginning with[in column 0 that producesmissing-colonorunclosed-elementfalls outside that prose (Placement).- An ID or class shorthand can also be joined to the tag name. Attribute lines are two spaces deeper than the opening line. The tag-ending
:can follow the last token or stand alone at the same depth as an attribute line (Elements and Tag and content). ContentLineandElementEndfollow the rules for the kind of content. An ordinary multiline element closes with a]on its own line at the opening depth or at the end of the last content line. Comments are recognized at the start of a page or notes line or after structural indentation in an element. Code and math fences and raw element content keep them as text (Page boundaries, Elements, Text inside elements and Code and math are isolated).Recoveryshows the main line-based recovery cases. A---after content is preserved as a line. AReservedBlockis isolated starting at a:::in column 0 that does not open aMemoand ending at its matching closing line or the end of the page. An unquoted attribute value with no lexical kind is preserved, and the attribute's rules determine its interpretation and diagnostic (Document settings, Page settings and The kinds of a value).
Characters and line ends
Encoding and line ends
A .koma file is UTF-8 text. Line ends are read as LF, and the line ends that were read are kept when saving.
How to write
Save as UTF-8. Line ends may be LF, CRLF or CR (Page boundaries).
Details
- A file with mixed line ends is saved with the most common one (LF on a tie).
- A UTF-8 file that began with a byte order mark keeps it when saved.
Code and math fences
Code and math are isolated
Everything inside a code or math fence is content: no element and no page starts there.
How to write
Fence with lines of ` or ~~~ (four or more are fine too; a fence closes at a line of the same character, at least as many as opened it), or with lines of $$.
Example
Output of koma export
Source
[title: Inside a fence is content]
[main:
```
[box: this line is code, not an element]
```
]Details
- The exception is a
+++in column 0, which is a page break even inside a fence (Page boundaries).
Math delimiters
Inline and display math
Math in text is written $...$, and displayed math $$ ... $$.
How to write
Math in text is $x^2$; displayed math is enclosed in $$. The delimiters of displayed math may stand on their own lines or on the formula's line (the recommended form is in Text inside elements).
An escaped dollar sign
\$ is not a math delimiter but a literal $.
How to write
To write $ as a character, as in prices, write \$ (\$5).
Attribute values
The kinds of a value
An attribute's value has one of seven kinds, decided by how it is written; only a value that is not a string or a list may go unquoted.
How to write it
| Kind | Form | Examples |
|---|---|---|
| Word | a letter, then letters, digits, - and _ | end, elbow, stix2, fig-3 |
| Number | a CSS number (a sign, a fraction, an exponent) | 2, -0.5, .5, 1e-3 |
| Percentage | a number and % | 40%, -5% |
| Length | a number and a CSS unit | 240px, 0px, 2em |
# value | #, then letters, digits, - and _ (as an #id) | #plot, #2d287f, #図1 |
| String | always double-quoted | "assets/fig.svg", "Distance from the nest", "sin(x); cos(x)" |
| List | values apart by commas in parentheses | (0, 40), ("a", "b") |
[image x=10% w=240px src="assets/decay.svg" alt="How sound fades" crop=(0, 0, 10%, 0):]
[box #clap x=10% y=40% w=20%:]
[box #wall x=70% y=40% w=20%:]
[line from=#clap to=#wall arrow=end:]Details
- A number is a CSS
<number>: a sign+or-,1.5and.5(1.is not a number), and an exponent witheorE. A dimension consists of a number and a CSS unit (lengths, angles, times, resolutions andfr; case does not matter). Which units an attribute takes stays as Elements says (%andpxforx,wand the like,pxfor a line's ends); any other CSS unit isbad-unit. A number with a unit CSS does not have (3foo) has no kind. - A
#value: a colour (#and 3, 4, 6 or 8 hexadecimal digits, as in CSS) and a reference to an element (from=#a) are the same#value as written, and the attribute decides which it is (as CSS's hash).from=#abcreads as a reference, never a colour. - Only a word, a number, a percentage, a dimension or a
#value may go unquoted. A value starting with:, a blank,/or., or holding Japanese, an emoji, a URL or an expression (drive(t)) is a string and is quoted. An unquoted value of no kind (src=assets/a.svg,alt=日本語,marker=⚠,f=drive(t)) keeps its source, reads as a string, is reported asinvalid-unquoted-scalar(warning) and has one fix that adds the quotes. The fix keeps what is read, sokoma check --writeandkoma format --writemake it. On a length attribute, a value of no kind is reported bymissing-unitorbad-unit. - A quoted value on an attribute of a set kind (a length; a number such as
step,rotateorweight; a word such asarrow; an attribute that takes a list) reads as it does unquoted (w="240px"), and the formatter (The standard form) takes the quotes off. On an attribute with no definition (data-and the like), a quoted value is kept apart as a string. - A number written with a sign, a fraction or an exponent (
+1,.5,1e3) on a text attribute (label,idand the like) reads as the text it was written as. - Escapes inside a string are as in JSON (an invalid one is
bad-value).style="…"stays a string of CSS declarations.
Lists of values
Several values are written as a list: values apart by commas in parentheses.
How to write it
[curve f="x -> sin(x)" domain=(-pi, pi) range=(-1, 1):]
[table src="assets/results.csv" widths=(1, 3, 2):]
[line .smooth points=((430, 500), (760, 300), (1160, 300)):]Details
- A list is written in parentheses only. Square brackets are never used for values, and there is no other form for a tuple.
- An item is a value of a kind (a word, a number, a percentage, a dimension, a
#value or a string, The kinds of a value) or a list. Blanks around a comma are free; the formatter writes(a, b)(one space after each comma, none inside the parentheses). An empty list()and a list of one item(a)may be written; the attribute decides whether they mean anything. - An unquoted value starting with
(is a list when its first parenthesis closes at its end, or never closes. A value whose parenthesis closes before its end ((1-x)*x,(draft)v2) is no list but a value of no kind (The kinds of a value). - An item of more than one word (
2 * pi,-pi) is an expression, read only by the attributes that take expressions (domainandrange). Parentheses inside an expression pair ((0, (1 + 2) * pi)). An expression on any other attribute isbad-value. - An item of
cropis a percentage from 0, or0; an item ofwidthsis a number above 0 (both written as CSS numbers). - Each attribute takes its own number of items; another number is reported as
bad-value, the attribute has no effect and the source is kept:croptakes 4 (top, right, bottom, left, in the order of CSSinset()),domainandrange2,pointstwo or more lists of two numbers (points=((0, 0), (100, 50))),widthsone or more (as many as the table has columns). - A trailing comma (
(a, b,)), an empty item ((a, , b)) and a parenthesis left open are reported asbad-value; the attribute has no effect and the source is kept. A list left open ends at a:or]outside quotes, or at a blank before the nextkey=, so the attributes after it are read as their own. Neither the app nor MCPsetAttributesrewrites a tag holding a list left open. - The
:that ends a tag is the first:outside quotes and lists (a:or]in a string inside a list is the value's). A list does not run across lines. - The attributes that take a list:
crop=(top, right, bottom, left),widths=(…),domain=(left, right),range=(bottom, top),points=((x, y), …)(pairs of unitless logical px). - There are no dictionaries (
{…}). Pairs of a name and a value are attributes, and nesting is written with child elements. A{at the start of an attribute's value is reserved and isbad-valueunquoted.
Document structure
A document is document settings followed by pages. Each line that separates them has one job.
Document and pages
Elements and text
A document is made of elements placed on its pages and the text inside them. The specification keeps the names for what is written (the source) apart from the names for what is read (the core).
How to write
An element is written in square brackets, [tag attr: content], with text in Markdown and LaTeX inside.
Details
- Source: the whole bracketed block
[tag attr: content]is a Koma element, or simply an element. The leading name (such astitleorcol) is the tag name. Markdown and LaTeX may be written inside an element. This is not HTML's tag syntax. - Core: the tree that reading produces. Its
Nodeis a general node that also stands for pages, notes and the like; it is not the same idea as an element in the source. The core's code uses names that fit each responsibility and does not call every general node an element. A generated area or a drawn rectangle is not, by itself, an element written in the source. Drawing, export and the GUI use the core. - The theme decides the look and the default positions and sizes of the layouts. Positions and sizes written in the document take precedence over those defaults (Who decides size).
Document settings
Document settings apply to the whole document and are written as YAML between === lines at the top of the file.
How to write
Put a === line at the top of the file, write title, type, size, theme and the like in YAML, and close with another === line. Page settings are written separately, in each page's --- block (Page settings).
===
title: Talk
size: 16:9
===
---
layout: cover
---
[title: Why echoes]
+++
[title: Next]Details
- Document settings belong to no page. Reordering, duplicating or deleting pages leaves them at the top, comments and unknown keys included.
title,type,size,themeand the like apply to the whole document.typeis the document kind (slide,article,poster, Kinds of page) andsizethe page size (Page size); the two are independent. The rules for each value follow Page settings and Settings YAML.- Editing settings keeps unknown information, quoting, comments and line breaks. Unclosed YAML keeps its source and is reported as
unclosed-settings; its content is never read as elements instead. - No
#langdeclaration is needed. Document settings and page settings may each be left out; content without an opening marker is the first page.
A document declares no language version. The document setting key koma is reserved: written in document or page settings, it is reported as reserved-setting and sets nothing.
Page breaks and comments
Page boundaries
A page break is a line of three or more + in column 0, separating one page from the next.
How to write
After a page, write a line of +++ alone, starting at the beginning of the line. None is needed before the first page.
Example
Output of koma export
Page 1
Page 2
Source
[title: A night at the library]
[main: Friday, 7–10 pm]
+++
[title: Finding the room]
[main: Take the stairs beside the entrance.]Details
- A line of three or more
+in column 0, followed by the end of the line or a space, is a page break. It opens nothing, and the next page starts with a fresh reading state. Even inside an element, code, math, CSS, YAML or notes, it is a boundary in column 0, and a structure left unclosed is not carried to the next page. An indented mark stays in the body. - Each delimiter has one role:
===document settings (Document settings),---page settings (Page settings),+++a page break.---is never a horizontal rule; a horizontal rule is***(___is read too, Text inside elements). ===,---and+++are delimiters with three or more characters in column 0. The count has no meaning and is kept as written when editing. Nothing is reported for the count; only explicit tidying makes it three (The standard form).- What follows a delimiter is reserved for attributes added later. Any character other than trailing spaces keeps its source, is reported as
delimiter-text-reserved, and means nothing. A+++with text still works as a recovery point. - The first page needs no leading
+++. Consecutive boundaries make empty pages. Trailing spaces, a byte order mark, line ends and source outside the language are kept. - Comments: from a
;at the start of a line to the line's end is a comment for yourself, neither shown nor exported, and kept in the source. It is a comment directly on a page, inside an element, in bare text and in notes. Inside an element, a;after the structural indentation (up to depth × two spaces) starts a comment. Inside code and math fences, the bodies of[code:],[math:]and[diagram:], settings YAML (whose comments are#) and CSS, it does not. A;in the middle of a line and a full-width;are text. To start a line with a literal;, write\;(\;draws;in the middle of a line too). A comment at the root is not guessed to belong to a page, and a move, deletion or duplication whose owner is unclear is not applied.- The standard form is
; comment(one space after the;).;commentwithout the space is read as a comment too. The app and the examples write the standard form. Ordinary saving keeps what was written; only explicit tidying (The standard form) adds the space. A;line with nothing after it, and a line of several;such as;;, get no space.//is ordinary text, not a comment.
- The standard form is
Page settings and YAML
Page settings
Page settings apply to one page and are written as YAML between --- lines in the page's preamble.
How to write
At the start of a page (after +++, or after the document settings on the first page), put a --- line, write layout and the like in YAML, and close with another --- line. A blank line may stand between +++ and the settings.
Example
Output of koma export
Page 1
Page 2
Source
===
theme: default
===
[title: A night at the library]
+++
---
layout: section
---
[title: Evening programme]Details
---always opens settings; whether what follows is settings or body is never guessed from the next line. A---in column 0 inside settings always closes them, even inside an unclosed YAML quote,[or{(the unclosed value isbad-yaml, and the block is kept, Settings YAML).- The preamble is the part after
+++(after the document settings on the first page) and before the page's elements and text start. Tidying puts one blank line between+++and the settings (The standard form). Blank lines and comments do not end the preamble. The first page needs no+++. Page settings are independent of the document's===settings. - A
---in column 0 written after a page's elements or text is not settings: that one line is reported asmisplaced-settings(error) and not shown. The lines after it are not isolated; they read as if the line were not there. Two fixes are offered, and neither is chosen automatically:***for a horizontal rule,+++for a page break. The message adds “a page break is+++”. - When the preamble's
---does not close (unclosed-settings) or its YAML cannot be read (bad-yaml), the message also adds “a page break is+++”. When unreadable settings YAML has a value containing:, it adds that the value should be quoted. When document-wide settings (title,sizeand the like) are written in the first page's---, it adds that document settings go in===. - A page may set
layout,id,class,paginate,skip,logo,logo-alt,lang,duration(Planned speaking time), andstylefor the line around the page's edge (Page-edge lines).title,typeandsizebelong to the document only. Unknown or unsupported settings are kept and reported. - Editing keeps the rest of the source, and never drops comments or unknown information. Page settings move with their page; document settings (with their
css:) stay at the top.
Settings YAML
Document and page settings are read as YAML 1.2 Core, and each setting's value is checked for its type.
How to write
title, theme, layout and the like are strings; paginate and skip are booleans. To write true or a number as a string, quote it. A YAML comment is #; ; is not a comment inside YAML.
===
title: "2024"
theme: default
===
---
layout: section
paginate: false
---
[title: Evening programme]Details
- The document's and the theme's
functionsmap function heads to expressions (Curves from a formula). - Strings, quoting, multi-line values, maps and lists are read as YAML means them; unknown settings keep their source and are reported. A theme's
tagsfollow their schema, and custom tags are never guessed from sample elements. A theme's layout frames are defined not in YAML but by sample elements with positions and sizes (Frames from sample elements).slots:is not read as a setting. - Invalid syntax and duplicate keys leave the whole block unapplied, are reported, and keep their source. Circular references and oversized alias expansion are refused. No YAML tag is ever run as code.
Planned time
Planned speaking time
Planned times are settings for how long to speak on a page (duration:) and in the whole talk (total-duration:).
How to write
Write duration: in page settings (---) and total-duration: in document settings (===). Both take minutes and seconds as m:ss (1:03, 20:00; up to three digits of minutes, and two digits of seconds up to 59). In YAML 1.2, 1:03 is a string, so no quotes are needed.
===
title: Talk
total-duration: 20:00
===
---
duration: 1:03
---
[title: Why echoes fade]Details
durationmay be written only on pages,total-durationonly on the document. Written in the other block, it is reported assetting-out-of-scope(Page settings).- A value of another form (
2m,1:75, an unquoted number such as90) is reported asbad-value(warning), with how to write it (asduration: 1:30). The page (fortotal-duration, the document) is treated as having no plan, and the source stays as written. - Without
total-duration, the plan for the whole talk is the sum of thedurationof the pages that have one. A page withskip: trueis not presented, so itsdurationis left out of the sum and out of the presenter view's counting. Pages without a plan are left out of the sum. - The key for a page's plan is
duration:. A page'stime:is not read as a plan: like any unknown key it is reported asunknown-setting(warning) and is not a plan. No fix or rewrite by tidying is offered, and the GUI does not rewrite it. A document'stime:isunknown-settingtoo. - Notes (Elements) are text for people, not read as times. When a page has no
durationand the first line of its notes (not counting blank lines and;lines) has the form ofm:ssjoined by+and ending in= m:ss(0:59 + 0:04 = 1:03), or is a barem:ss, it is reported asnotes-time(note), with one fix that moves that line toduration:in the page settings. The value moved is the one right of=(read as this page's time), or else the sum. If the page has no settings block, one is made; notes left with nothing else are removed with it. Nothing is rewritten automatically (choose the fix in the GUI, runkoma check --write --unsafe, or fix it by hand; the fix may change the meaning). - How the presenter view shows it is the presenter view’s rules. HTML and PDF do not show it.
Page transitions
A page's transition determines how it comes into view. Use none, fade, or push in the document or page settings. A page setting overrides the document setting. The default is none.
A forward turn to an adjacent page takes the arriving page's effect. Going back reverses the same boundary. A push enters from the right when going forward and from the left when going back. Non-adjacent turns, direct number entry, Home, End, and starting a presentation show the page immediately. Skipped pages are left out of the sequence. An invalid value is reported as bad-value and uses the inherited value. Articles and posters retain the setting with a type-unused-feature note.
Page size and coordinates
Page size
The size of the pages is chosen with size in the document settings. The size decides only the pages' dimensions and the PDF's paper size.
How to write
Write size: 4:3, size: A4, size: A4 landscape or size: 1080 x 1920 in the document settings. Without it, 16:9.
===
type: article
size: A4
===Example
Output of koma export
Source
===
size: 4:3
===
[title: A 4:3 page]
[box .card x=10% y=40% w=80%:
1440 by 1080 logical px.
]Details
- Screen ratios:
16:9(1920×1080),4:3(1440×1080). - Paper sizes:
A5,A4,A3,A2,A1,A0,B5,B4,letter. An orientation may follow, as inA4 landscape; portrait is the default. - Dimensions written directly:
1189mm x 841mm,1080 x 1920(logical px without a unit). aspect: 4:3of other settings problems means the same assize: 4:3.- The size never decides the kind (Kinds of page): any kind takes any size. For example: slides at 16:9 (no
size), slides on A4 landscape (size: A4 landscape, a lecture handout to print), a portrait A4 document (type: article,size: A4), a 4:3 document read on screen (type: article,size: 4:3), a portrait A0 poster (type: poster,size: A0), a poster for an upright screen (type: poster,size: 1080 x 1920).
Paper in logical pixels
Paper sizes are converted to logical px at 96 logical px to the inch (the same as CSS px).
How to write
On paper pages too, an element's x, y, w, h are written in these logical px (the coordinate system of Coordinates, extended to the page's size). For example, portrait A4 is 794×1123, and portrait A0 is 3179×4494.
Kinds of page
The document kind (slide, article or poster) is chosen with type in the document settings. Without it, the document is slides. The kind decides how the document is used.
How to write
Write one of type: slide, type: article or type: poster in the document settings. Without it, slide. It can be written in the document settings only, not in a page's settings (---). The retired kind: key is unknown. Use type: article for an article.
===
title: Field notes
type: article
size: A4
===Details
- The kind is never inferred from the size (Page size). A document without
typeis slides whatever itssize, so existing documents read as before. - A value it does not read (
type: slides,type: report) is drawn as slides and reported asbad-value(a warning); the source stays as written.typein a page's settings issetting-out-of-scope. - Slides are shown one page at a time and presented, with the presenter view, speaker notes, animation, skipped pages (
skip) and planned times (duration,total-duration). An article is read page after page, from the top. A poster is one large page looked at by zooming and moving; it is usually one page, but may have more. - The kind does not change the notation (elements, attributes, layouts, the document's CSS), the page size, or the formats a document exports to. In an article or a poster, speaker notes, animation,
skipanddurationstay in the source and are kept through reading and saving; they are only not used. paginatedefaults to off for slides and posters and on for articles;paginatewritten in the document or a page decides (Page settings).- Notes (the lightest level; exit code 0):
type-not-setwhen there is notypeand thesizeis paper ("this document is drawn as slides; writetype: articlefor a document,type: posterfor a poster"). Withtype: slidewritten, nothing is said (slides on A4 landscape, for example).type-unused-featureon each line where a document or a poster has speaker notes, animation (step),skip,durationortotal-duration.
An unreadable size
An unreadable size is drawn as the default 16:9 and reported as a problem of the document settings.
How to write
Write a value of Page size in size.
Details
- An unreadable one (such as
size: huge) is treated as in other settings problems.
Coordinates
The coordinate system is logical px with its origin at the page's top left; the default slide page is 1920×1080 (Page size).
How to write
Lengths written in px (x=96px, w=480px) and a line's ends x1, y1, x2, y2 are logical px of this system (positions are measured from the parent, Elements). When the page size changes, it becomes the logical px of that size (Page size, Paper in logical pixels).
Layouts
The kinds of .koma page, and the default position and size of the generated areas (logo, footnotes, page number, footer, cover fields). The numbers are tuning values of the layout, neither notation nor rules of the language. A theme decides only the look, and a position and size written in the document take precedence (Who decides size).
Page layouts
A page layout is the pattern of what goes where on a page, chosen with layout: in the page settings. It is never guessed from the content.
How to write
Write layout: cover and the like in page settings. There are four basic layouts: the cover (cover), the section opener (section), the ordinary page (content) and the page with no frames (blank). Without it, content. Written in the document settings, it is the default for every page.
Example
Output of koma export
Source
---
layout: cover
---
[label: Night at the library · 2]
[title: The book swap]
[subtitle: Leave one book, take another]
[authors: Mira Okafor]
[affiliations: Central Library]
[date: Friday, 7 pm]Details
blankis a layout that only has no frames; it is treated like any other. The logo andpaginatework as on other layouts (to hide the logo,logo: none), and content is placed freely withxandy. A frame's tag (title,mainand so on) written there is reported asslot-not-in-layout, as for a tag with no frame on any other layout.- A theme document may add named layouts (Frames from sample elements). A table of contents is written as the content of an ordinary page.
- The cover's frames are the six
label,title,subtitle,authors,affiliationsanddate; there is nomainframe (a[main:]on a cover is reported asslot-not-in-layout, like any tag with no frame). The cover stacks the subtitle under the title, then the authors, affiliations and date under it, only those written, in order (no space is kept for what is not written; each has a set height, and adding lines in one never moves the others). - An ordinary page's subtitle has room for one short sentence on one line by default. There is no variant for a two-line subtitle. Two-line text itself is not forbidden, and no text is cut. A page that needs more stays an ordinary
contentpage, and the author adjusts the subtitle's height and the body's position and height with explicit positions and sizes. Subtitles and labels (label) are never shrunk to fit;koma check --layoutreports when they do not fit. Unless explicit positions and sizes change, pages of the same layout start their body at the same place whatever their headings hold. - Columns and rows of content are written with
[col:]and[row:]in the body (Columns and rows). A theme may also define default placements for them. The official four themes have only five layouts: the basic four andoutlinefor a table of contents. Two columns, a figure with its explanation, three side by side and a summary are made with[col:]and[row:]in acontentbody; no layouts are added for them. - An unknown name is not accepted as an alias: it is reported as
unknown-layout. The preview uses thecontentplacement, but the written settings and body are kept, and tidying alone never replaces them. - Posters are outside this rule.
The document's logo
A logo is an image written in the document or page settings, drawn in the top right place the layout sets aside.
How to write
Write logo (the image's path, relative inside the document's folder) and logo-alt (its alternative text) in settings. In the document block they are every page's default; in a page block they apply to that page only (Page settings). To leave it off a page, logo: none.
Details
- Written nowhere, there is no logo, and no empty place is left. There is no notation for its position.
- Not written,
noneand an empty string are read as different things (not mixed up as truthiness). - The alternative text goes with
logoas a pair. A page that replaces the image does not inherit the document'slogo-alt. A page may rewrite only thelogo-altof an image it inherits. An image in effect without alternative text is reported asmissing-logo-alt(warning) and is not taken as decorative. Onlylogo-alt: ""makes it decorative; nothing is guessed from the file name or the document's name. Alogo-altwritten with no image in effect issetting-not-applied(warning). - The layout decides the place, and the theme only the look (Who decides size). The cover, section opener and ordinary page all use the same top right place. On a page with a logo, the layout first takes that place and the gap, and sets the default width of label, title and subtitle to its left. Nothing overlaps. The widths are tuning values of the layout, neither notation nor rules of the language (the values: the logo at 80% from the left and 3% from the top, 15% wide and 10% high, with a 3% gap; headings that would meet it end at 77% from the left; an ordinary page's label and title are 72% wide).
- A layout never hides the logo implicitly; hiding it is written as
logo: none. - Elements with their own positions are never rewritten to avoid the logo. Overlaps and overflow are reported by
koma check --layout. - The image fits its place keeping its aspect ratio (never cut or stretched), aligned to the top right. Slides do not change colour with the app's light or dark mode, so there are no separate light and dark images.
- Over the page's bands (Layout grids): the logo is placed at its corner from the page's top left, as an element with
xandyis; it is not drawn in the header band and takes none of its height. - Meaning: the logo is generated, owned by the document or page settings. In HTML it sits in the page's heading area, outside
hgroup(which cannot hold the logo's image). No free element is made. - The image uses the same lookup, sanitising and bundling into exports as other images. No outside image service or new permission is used. A missing image is reported by
koma check, like other images, and export stops, naming the page.
Footnotes and the page number
Footnotes (Footnotes) are gathered in the page's footer band (The bottom band), 5% from the page's left edge, in the order their definitions are written. Their width is what remains after the left 5%, the common physical margin used by the page number at the lower right, the actual current / total and a 1em gap. A page without a number uses the full width.
The page number current / total at the lower right stands right of the body's right edge, with the same margin in logical px from the right and bottom edges: the common --koma-counter-margin, by default 3% of the page height (32.4 px on 1920×1080).
The baseline of the footnotes' last line aligns with the page number's baseline, and more lines grow upward, the body above giving up as much room. Footnotes sit at the bottom even on a page without a number. Short items stand side by side and wrap between items; a long item wraps inside, never separating its mark from its first word.
The footer and footnotes
[footer: sources and the like] is an element directly on any page, selected, moved, resized and edited like any other. It is never added automatically to a new page. Its default frame, the same on every layout, is one line at 5% from the left, 68% wide (89.5% from the top, 7.5% high). A footer frame declared by the theme is used if there is one. A footer with no position or height written stands in the footer band at the frame's left edge and width (Frames from sample elements, The bottom band): the bottom of its last line's text sits on the page number's line, 3% above the page's bottom, and more lines grow upward at the same size, the body above giving up as much room, up to the band's max-height (one third of the page inside its padding unless the theme sets it); beyond that the text shrinks (down to half), and if it still does not fit, this is reported. A footer with y or h written keeps that position and height, from the page's top left; with h, the height is fixed and the text shrinks to fit.
The page's footnotes follow the first explicit footer's content after a 0.5em gap, and move with it. In the footer band, the last line including the footnotes sits on the page number's line and the footer moves up by that much; a footer placed with y or h leaves its footnotes in the band. The footer and the generated footnotes are separate areas: editing the footer never mixes in footnotes, and footnote definitions and the page's text are never moved or copied. Several footers are not joined; they stay separate and are reported as duplicate-slot. A nested footer, or a box merely given role=footer, is never where footnotes go.
Without a footer, footnotes stand alone in the footer band. The page number stands at the lower right whatever the footer does. The editor, HTML, PDF and PowerPoint use the same placement; overflow off the page is reported by the layout check.
Authors and affiliations on the cover
On the cover, the authors and affiliations stand close together as one group, with a small break before the date. By default the authors are 5% of the page high, the affiliations 6.5% (room for two lines) and the date 4.5%, with a 1% gap before the date when authors or affiliations precede it. Fields not written leave no height, and a date with nothing before it has no gap. Coordinates and sizes written for a field take precedence; the source, title, subtitle and text look are not changed.
Elements and attributes
Everything placed on a page is an element in square brackets: a tag, a colon, and the content.
The form of an element
Elements
A Koma element (below, simply an element) is something placed on a page, written in square brackets.
How to write
Write [tag: content]. Separate the tag name and attributes with spaces and follow the tag with :. Write attributes as key=value or with the shorthands #id and .class. When the content runs over several lines, open with a [tag: line and usually close with a line of ] alone at the opening's depth. Elements written inside are indented two spaces deeper per level.
[title: a one-line element]
[box #memo .card x=10% y=50% w=40%:
a multi-line element
[box .tint: a nested element]
]Example
Output of koma export
Source
[title: Night at the library]
[box .card x=6% y=30% w=36%:
The reading room is upstairs.
Read in quiet.
]
[shape .primary x=60% y=28% w=10% h=18% type=ellipse:]
[line x1=860px y1=400px x2=1120px y2=400px arrow=end:]
[math x=52% y=66% w=36%:
19{:}00 + 3\,\mathrm{h} = 22{:}00
]Details
- One-line form:
[tag: content]. The whole line is in brackets, and the brackets match. - Multi-line form: it starts with
[tag:and runs to its closing]. The tag ends with:, and may be split over several lines (Tag and content). The body may start right after the colon or on the next line. At most one space right after the colon on the opening line is a separator; anything after it is body. On later lines, up to depth × two spaces are structural; tidying adds what is missing, and more is kept as body. The closing]may stand on its own line or end the body's last line. Matching brackets in the body, Markdown links, images and footnotes, an escaped\], and brackets in inline code, math or fences do not close. To write an unmatched]at a line end as text, write\]. An opening line without:is not an element (When brackets are an element). A:inside quotes is part of the value. An unclosed element keeps its source and a diagnostic. - Tag: the standard form is
name #id .class .class key=value…, ending with:. A tag holds a name and attributes, written as#id,.classorkey=value. The name,#idand classes may each be left out (without a name,box). The joined form (box#id.card) is read too. Newly inserted elements, examples and explicit tidying use the standard form; ordinary saving and dragging keep the form that was written. - Attribute values: in the
key=valueform, the right-hand side is the attribute value. A value's kind (a word, a number, a percentage, a dimension, a value starting with#, a string or a list) follows from how it is written, and only a value of a kind may go unquoted (The kinds of a value). Several values are written as a list in parentheses,(a, b)(Lists of values). For lengths,weight,stepandrotate, quoting does not change the meaning. For undefined attributes, a quoted number or value with a unit is kept apart as a string. The formatter leaves quotes out only for a value of a kind, when syntax and the value's type and meaning are kept. Inside a double-quoted value, quotes, backslashes and the like are escaped as in JSON. An invalid escape is reported asbad-value, the value is not applied, and the source is kept. In a correctly double-quoted string,[and]are characters of the value and are not counted as brackets of an element or its body. - Lengths and units: a length attribute carries a unit:
xandwas%of the parent's width,yandhas%of its height, or logical pixelspx(x=10% w=40%,w=240px). A line's endsx1,y1,x2,y2take onlypx.0may omit its unit. A number without a unit is reported asmissing-unit, an unaccepted unit (mm,%for a line's ends, …) asbad-unit, and the attribute has no effect (the source stays as written, and the bracket is still an element even when the value has no effect).xandymay be negative.w=0andh=0are reported aszero-size. - Parent: the parent that positions and sizes are measured against is the whole page directly on a page, or else the parent element's content rectangle (inside padding and border). Moving an element into or out of another in the GUI also rewrites its position against the parent's content rectangle as drawn, so it does not move on the page (
pxstayspx). Writing back keeps the value's unit (pxstayspx,%stays%); new values are%to one decimal place. Only an explicit action changes the unit. - Text direction: the direction of text is the attribute
dir:dir=rtl(right to left) ordir=ltr(left to right, the default). Other values are reported asbad-valueand have no effect. - Unquoted words: a word without
=in a tag (likertlin[box rtl: …]) is not in the grammar: its source is kept as written, it has no effect, and each is reported asbare-word(warning).rtlis a bare word too, with no fix offered. A bare word is read as a word of the tag only when the name is a known tag name (Kinds of name) or the tag has an#idor class, and only before the:. Other bracketed lines ([see figure: 3]) stay text (When brackets are an element). - Nesting and indentation: elements may nest. Openings, one-line elements and standalone closing lines start at the beginning of the line or after the current depth × two spaces; a standalone closing line aligns with the depth of the parent it closes. In a multi-line body, up to the element's depth × two leading spaces are structural and more are kept as body. Explicit tidying adds only the structural spaces a line lacks. Tabs do not count as structural space. To write a bracketed line that is reserved at that position in a deep nest as text, escape it with a backslash or put it in a code fence. Code and math fences and their content are read as Markdown after the same structural indentation is removed, keeping any extra indentation. Notes at the root have no structural indentation and keep their source.
- The same attribute twice: when the same attribute is written twice (
#aandid=b,.redandclass=blue,x=1% x=2%), none is removed andduplicate-attribute(warning) is reported. The first one takes effect, and the tag's#idand.classcount beforeid=andclass=wherever they stand. Changing the value rewrites the one in effect, in its own form (#ato#c). Removing removes every occurrence, so no other value starts to take effect. A new ID or class is written in the tag as a standalone#idor.class, unless reading it back would not give the same value (it contains.or a space, or is empty): then it is writtenid="…"orclass="…", and the#idor.classthat would take precedence is removed, so the written value takes effect. An empty value is written as a value; only no value (null) removes. The app (the format panel) and MCPsetAttributeswrite with the same writer (setAttrs). - Attributes and looks: attributes say what an element is and where it goes (
x,y,w,h,rotate, a line's ends andarrow,marker,#idandid=,.classandclass=, and so on). The look is said by classes andstyle, each in one way. Looks layer as theme, class, thenstyle, the later winning. A look written as an attribute (gap=,opacity=,color=,fill=,stroke=and the like) has no effect, keeps its source as written, is reported aspresentation-attribute(warning), and whenstylecan read the value, one fix moves it there. The app (the format panel, inserting), MCPsetAttributesandkoma formatnever write a look as an attribute. - The language's attributes and the user's: an attribute whose name has no prefix belongs to the language. Users who want attributes of their own add
data-([box data-source=fig3: …]). Adata-attribute stays in the source, has no effect, and is not reported. An unprefixed attribute the language does not have (other than the name of a look) has no effect, keeps its source as written, and is reported asunknown-attribute(warning). Reordering (Order of attributes) puts it after the language's attributes. A line runs from end to end, sohhas no effect on it and is reported asline-no-height(warning). - Look classes: styles (Named styles) are classes:
[box.tint: …],[box.fill: …],[box.outline: …],[box.bar: …],[box.card: …]. Callouts and shapes take the same classes. The look classes (tint,fill,outline,bar,card) are drawn by the theme. No class changes content, placement or reading order. A class whose name is not in the theme stays in the source, for the theme's or the document's CSS to draw. To split across or down, write[col:]and[row:](Columns and rows). style:style="color: red; border-width: 2px"holds CSS declarations for that element; placement is decided byx,y,w,h. These declarations of appearance may be used:align-content,background-color,border-color,border-style,border-width, the per-side linesborder-top,border-right,border-bottom,border-leftwith their-width,-colorand-style(for examplestyle="border-bottom: 2px solid #2d287f"),border-radius,box-shadow,color,font-family,font-size,font-style,font-weight,gap(between split areas, Columns and rows; in an element without a split, between its direct children, Cards without positions),letter-spacing,line-height,opacity,paddingand the per-sidepadding-top,padding-right,padding-bottom,padding-left(a length or percentage like one side ofpadding; other values arebad-value; withpadding, the one written later wins, as instyle="padding: 8px; padding-left: 32px"),stroke-dasharrayandstroke-width(a line's dashes and width),text-align,text-decoration-line(strike-through of the whole element),text-spacing-trim(the space of full-width brackets at line ends; CSS Text 4 values, Brackets at line ends), the arrow-head variables--head-startand--head-end(triangle,stealth,open,dot,diamond) and--head-size,--head-start-size,--head-end-size(sm,md,lg), and the face of the math inside,--math-font(fira,stix2,newcm), where the innermost wins. Other values of these variables arebad-value. Values that load outside resources and unsupported declarations are not applied, give a warning, and keep their source. A theme's shared CSS and ordinaryvar()work too. Precedence follows the ordinary CSS cascade.- Per-side lines: no new attribute or class is added; they are written with their CSS names in
style. A theme's CSS can hold the same declarations (title { border-bottom: 2px solid #2d287f; }). HTML and PDF draw them as the browser does. A side line takes inner space like a full border, as on an element with a surface (Named styles). PowerPoint writes four sides of the same width and colour as the shape's outline, a left side alone as a left band, and otherwise each side as a thin rectangle filled at the line's width along the inside of the frame (rotated with the element). Sides that are not solid (dashed, dotted, double and so on) are reported before export, which stops. On a rounded element, side lines are straight bands without the rounding. Thebordershorthand is not supported.
- Per-side lines: no new attribute or class is added; they are written with their CSS names in
- Rotation: an element on a page that has no child elements and is not the footer can be rotated in degrees, as
[box x=10% y=20% rotate=30: Example]; quoting does not change the meaning. Rotating the footer, a nested element or an element with children is not supported: the source is kept, reported, and not applied when drawing. HTML, PDF and the PowerPoint output that supports it show the rotation. - Steps: the common attribute
step(Steps):[box step=1: text],[col step=2: text],[row step=2: text]. Only a safe integer of 1 or more is valid; an invalid value is reported as abad-valuewarning, keeps its source, and is ignored as a step. A nested element's step is the largest of its own and its ancestors'; a child without one inherits its parent's. There is no attribute syntax for a standalone Markdown paragraph. - Shapes and lines: a rectangle or an ellipse is written
shapewithtype=rect|ellipseandx,y,w,h; a rectangle's rounded corners areradius(Shapes). A freely placed line is writtenlinewithx1,y1,x2,y2in logical px, witharrowleft out orstart,endorboth. A line through three or more points is writtenpoints=((x, y), (x, y), …): each point is a list(x, y)of unitless logical px, and there are two points or more (Lists of values)..smoothmakes it a curve through the points. - Math, code and diagrams: to place them on their own, write
[math: x^2],[code language=python: print(1)]and[diagram: graph LR; A --> B]. Their bodies are read as TeX, code in the named language and Mermaid, and are never converted as Markdown (how each element reads its body: How an element reads its body). Code withoutlanghas no language.$…$,$$…$$and code fences in text work as well.- Each line of a multi-line body is written at least two spaces deeper than the element; after the structural indentation is removed, the remaining indentation and characters are the body. The closing
]stands on its own line at the opening's depth. An indented],---or;inside is body text. A missing close is reported, and never takes in the next page or an unindented element. In the one-line form, the last]closes and earlier brackets are body text. - Standalone math, code and diagrams share placement and selection. A theme's custom tag that
extendsthem is not supported: it is reported, and the source is kept.
- Each line of a multi-line body is written at least two spaces deeper than the element; after the structural indentation is removed, the remaining indentation and characters are the body. The closing
- Figures: write
[figure:, on the next line the picture[image src="assets/result.svg" alt="Line chart of the measurements":], then the caption, and close with]. A picture without a caption is written as[image src="…" alt="…":]alone (Figures and images).srcfollows the same path and safety rules as other image references,altis the image's alternative text, and the text of the figure's body outside what it shows is the caption in Markdown.altmay be left out, and nothing is reported; a decorative image hasalt="". An empty[figure:]is kept as an unfilled field of a new page; a caption alone or an emptysrcis reported as a missing reference. A figure goes in the theme's figure slot if there is one, else in the body's flow; coordinates written in the document take precedence.- Size: a figure with a height written scales its image, keeping the aspect ratio, within its frame less the caption's area. A figure with only a width written fits its image to that width, keeping the aspect ratio. A figure with neither takes all the space left in its parent as its area and fits its image there in the same way as a figure with a height. Several such figures in one parent share what is left equally. The caption is part of the figure's area. When the parent has no height of its own (inside an element that grows with its content), or the figure is placed with
xandyand no size, the image is drawn at its natural size. A parent has a height of its own in the page's flow, in a layout frame, in a[col:]or[row:]area (when the parent holding it has a height), and whenhis written. - Picture-only paragraphs: a paragraph holding only
on its line is drawn the same way, as a figure without a caption. Directly in a parent with a height, it takes all the space left as its area, fits the picture there keeping its aspect ratio, and shares what is left equally with the other figures and picture-only paragraphs of that parent. A run of pictures written directly on a page is drawn the same way, as figures in the page's flow. A picture-only element placed withxandy, and a picture inside an element that grows with its content, are drawn at their natural size (the placed element's width). - Caption: picture and caption are one group, the caption always right under the picture, with the theme's caption gap between them. A figure with only a width written is as high as the fitted picture plus the caption, and its text is not shrunk (Who decides size). When the frame is taller than the group, the group sits at the top by default, centred across.
align-contentin the figure'sstyle(start,center,end, also withsafe) puts the group at the top, middle or bottom of the frame. HTML, PDF, images, PowerPoint, editing and drawing all use the same place. PowerPoint too keeps the position and proportions of the image as shown. - Resources: a figure's resources are dependencies when saving, packing and exporting, like other images. HTML uses
figure,imgandfigcaption. - Cropping:
crop=(top, right, bottom, left)on[image:]is how much to cut from each side of the original image (the order of CSSinset(), all four written; values are%or0, Lists of values). The aspect ratio of what remains becomes the image's, and the frame's size (w,h, a column's width) is decided as it would be anyway. The original image file is never changed. An unreadable value is reported asbad-value(crop), and the image is drawn uncropped. A cropped image fits its frame by the same rules as an uncropped image of the remaining size (whether the figure hash, a position, no size, is alone in a column, or stands in a row). Only the inside of the frame is drawn: the cut parts are not drawn and the page does not move (a page clips its content and never scrolls). A PDF page used as a figure is cropped the same way. HTML and PDF are as drawn; PowerPoint places the whole image and crops it to the same area (srcRect). A PDF page goes in as a figure of the remaining part only.
- Size: a figure with a height written scales its image, keeping the aspect ratio, within its frame less the caption's area. A figure with only a width written fits its image to that width, keeping the aspect ratio. A figure with neither takes all the space left in its parent as its area and fits its image there in the same way as a figure with a height. Several such figures in one parent share what is left equally. The caption is part of the figure's area. When the parent has no height of its own (inside an element that grows with its content), or the figure is placed with
- CSV and TSV tables: write
[table src="assets/results.csv": Results]..tsvis separated by tabs, anything else by commas. The body is a Markdown caption. CSV cells are plain text, never read as elements, Markdown or math. The first row is the column headings. UTF-8 (with or without a byte order mark), commas, double quotes, doubled quotes and line breaks inside quotes are read; a row with a different number of columns loses nothing, is padded with empty cells, and gives a warning. Invalid quoting or UTF-8, missing files and files over the limit never produce an incomplete table.widths=(1, 3, 2)on[table:]is the ratio of column widths; for a Markdown table, wrap just the table in[table widths=…:…]withoutsrc.- A table's
srcis limited to a relative.csvor.tsvpath inside the document's folder, and only referenced files are read. Nothing is written to files and no formula is evaluated. The file is read again when presenting or exporting starts. A package includes the referenced CSV; when it cannot be read, no incomplete package is made.
- A table's
- Notes: Markdown attached to a page and never shown to the audience. They open with
"""directly on a page and close with a line of the same characters alone. The opening line may holdkey=valueattributes in the form of an element's tag. None is defined: each is kept and reported as unknown, including the retiredspeak, whose block is now read like any other. Several notes are joined in order with a blank line between. A slide app uses them as speaker notes. They are not tied to the next element. The recommended form puts one blank line before the opening"""line and one after the closing"""line, like+++and---(none inside at the start or end, and none at the start or end of the file). Tidying and the app write notes in this form (The standard form). Reading is the same without the blank lines.- Within notes, double brackets mark what is not said. On one line,
[[Point to the figure]]is a stage direction in plain words: nothing inside it is read as an instruction, so[[look here about 10s]]is only words, never a pause. The speaker sees it quietly in single brackets ([Point to the figure]); PowerPoint's speaker notes do the same. Speech skips it. Empty brackets,\[[and the same text inside a code span or fence are literal, and the page outside notes never reads double brackets. The former[…]{speak=false}and[…]{pause=…}are plain text. - In the recommended form, put one ASCII space between a stage direction and the text on either side of it. At the start or end of a line, only the side with text needs a space. For example,
Clap once. [[Wait for the echo]] Then listen.Both spaced and unspaced directions are recognized. Tidying preserves the author's spaces (The standard form). - For more than a line, a line of
[[alone in column 0 opens an unspoken block and a line of]]alone in column 0 closes it; spaces after either mark are allowed. Without]]the block runs to the end of the notes. The recommended form indents the lines between by two spaces, as Koma indents structure; that indent, up to two spaces shared by every written line, is not part of the content, so unindented lines read the same. The content is Markdown (lists, emphasis, math, blank lines), shown to the speaker as a quiet block, kept in PowerPoint's speaker notes as a quiet memo, and left out of speech and measured speech time.[[and]]inside a code or math fence, or indented, are text. Tidying keeps the block as written.
[title: Why echoes fade] """ Pop the balloon first. [[Point at the window]] [[ If someone asks: - *Why does it fade?* Each wall keeps a little. - Keep a spare balloon nearby. ]] """ +++- A
---inside closed notes is kept as part of their Markdown and is not a page break. A;at the start of a notes line is a comment, shown neither in the presenter view nor in PowerPoint's speaker notes (Page boundaries). Quotes and marks inside code and math fences belong to the fence. Notes end at a"""outside any code or math fence that closes. An unfinished fence in the text is not mistaken for unclosed notes. - When notes do not close, reading recovers at the first page break at the root outside a fence, or at the end, and reports
unclosed-notes(error). The text up to there is isolated from the audience and kept. Empty notes are allowed. - The
.komafile, the presenter view and PowerPoint's speaker notes carry the notes on purpose. The audience's HTML, PDF, slides and thumbnails never carry their text, not even in hidden elements or attributes. Diagnostics never copy it. The older form and unclosed notes failkoma checkandkoma format, andkoma exportrefuses before writing output.
- Within notes, double brackets mark what is not said. On one line,
- Memos: a
:::line with attributes directly on a page opens a memo for the author, which no output shows (Memos).
Tag and content
A colon separates an element's tag from its content, and a tag always ends with :.
How to write
Before the : is the tag, after it the content: [box.tint x=5% y=8%: content], [title: let x = 5]. An element without content still has its : and closes with :] ([title:]). When a tag is long, continue its attributes on lines two spaces deeper than the opening line, and put the : right after the last attribute or on its own line at the depth of the attribute lines.
[box
.card
x=10%
w=40%
:
content
]Example
Output of koma export
Source
[title: A tag over several lines]
[box
.card
x=10%
y=32%
w=50%
:
A box with one attribute per line.
]
[box .tint x=10% y=64% w=50%:]Details
- The
:may be attached to the tag's last word or stand apart. - An attribute continuation line contains one or more attributes in the
#id,.classorkey=valueform. An attribute value is never broken across lines. The body starts after the:. Tidying puts one attribute per line and the:on its own line. - Elements without content:
[title:],[box.card:],[title x=5%:]. A multi-line element's tag ends with:too. A tag without:is not an element (When brackets are an element). - A line with a word that cannot be read as a tag (
[title Koma]) is not an element. If the name is a known tag name, it is reported asmissing-colonwith one fix that adds:after the name. The line is a half-made element: it is not drawn, and is not put in a bare-text box (Placement). To draw it as text, start it with\. Everything after the name is never read as content. - In a one-line element, at most one space right after the
:is syntax; further leading spaces and trailing spaces of the body are body, kept and shown.[label:text]without a space is valid. The body of[label: text]istext; that of[label: text]starts with one space. A colon inside an attribute value, as in a URL, is not this boundary.
When brackets are an element
A bracketed line is read as an element only in set forms; any other bracketed line stays text.
How to write
To make an element, end the tag with : ([title: content], [box.card:]). A bracketed line without :, such as a name alone ([1], [NOTE], [Note this matters]), is drawn as text (for the exceptions, see element-shaped lines below). To draw a line shaped like an element as text, start it with \ (\[theorem: literal]).
Example
Output of koma export
Source
[title: Brackets that stay text]
[main:
[NOTE]
Doors open at 7 pm.
\[theorem: this line is text]
See [1], Library News, issue 3.
]Details
- One-line form: a line whose tag ends with
:is an element. A line without:is text ([1],[NOTE],[title:],[box:],[TODO],[Note this matters]). - Multi-line form: the tag has the form of Elements, ends with
:, and has a matching line of]alone. - Element-shaped lines (
missing-colon): lines without:that are one of these. (a) One-line, readable as a tag, with an attribute after the name (including an assignment whose value is invalid and has no effect):[box#memo],[box.card x=5%]. (b) One-line, a known tag name (Kinds of name) followed by a word that is not an attribute:[title Koma]. (c) Multi-line, an opening line with a Elements tag and a matching line of]alone:[box x=10%…]. These are not drawn, are not put in a bare-text box (Placement), and are reported asmissing-colon(error) with one fix that adds:(at the end of the tag for (a) and (c), after the name for (b)). For (c), the lines and child elements inside are held back with it. - Lines with a name alone:
[title]and[NOTE]are not (a) and are drawn as text. They are reported only when the name is known: a built-in tag name (Kinds of name), or a tag name or layout frame name of the theme in use (Frames from sample elements), is taken as a forgotten:and reported asname-without-colon(note). Other names ([AM1],[TODO],[1], a definition-list term on its line) report nothing. Tidying leaves these lines as written and never adds:. - Elements with an unknown name:
[theorem: content]and[theorem:/content/]are both elements, keeping their source, range and children. Names are resolved when drawing. A name that is neither built in (Kinds of name) nor a tag or frame name defined by the theme in use (Frames from sample elements) is anunknown-tagerror, shown with its line number and range, and the element's content is drawn where it is written, in the flow, as a plain[box:]with no placement or style (directly on a page, the same as bare text, Placement). Neither the name nor the tag's attributes take effect, and it does not go into that name's frame. Child elements and footnotes are drawn as inside a[box:]. Only[notes: …]draws its content on no page (speaker notes are written in"""blocks, Elements). Once the name is fixed or the definition is loaded, it is an ordinary element. The canvas, HTML, PDF, PowerPoint and image output all draw it the same way. An unknown element alone never makes the export of the whole document fail. - The command line: a check without a browser reads
theme.komain the document's folder to know the names; only when the theme cannot be read does it report a pending name with a theme reference astheme-tag-uncheckedinstead.koma checkandkoma lintreportunknown-tagas an error and exit with 1. The CLI returns the diagnostics of the tree actually resolved. - Elements without a close: the search for a close never crosses a
+++in column 0. When no close is found, the opening line keeps its source, is reported asunclosed-element, and reading recovers on the next page. That line, and directly on a page what follows it to the end of the page, are not drawn, being the content of an element without a close (Placement). - Keeping a line as text: when a line meant as text is read as an element (
unknown-tagandmissing-colonfor[Note: …]), the message says that a leading\keeps it as text. A\at the start of a line stops it being read as an element or a list item.[docs](https://example.com), images, footnotes,[0, 1)and[[wiki]]keep their Markdown meaning; no name is guessed into an element. A line of a reserved form meant as text is written\[theorem: literal]or in a code fence.
Names and attributes
Kinds of name
There are three kinds of element name: slot names, which go to fixed places of the layout; reserved words, which have no fixed place in the layout; and custom tags, which a theme declares.
How to write
Write what goes to a fixed place of the layout with a slot name ([label: …], [title: …], [subtitle: …], [main: …], [footer: …]). A cover also takes the cover-only slots authors, affiliations and date. Write an element with no fixed place in the layout with a reserved word: box, callout, shape or group.
Example
Output of koma export
Source
[label: Night at the library · 2]
[title: How the swap works]
[subtitle: Leave one book, take another]
[main:
The swap table is by the entrance.
]
[box .tint x=60% y=70% w=32%:
No booking needed.
]Details
- Slot names (
label,title,subtitle,main, and the optionalfooter) go to fixed places of the layout (Page layouts). They are named for the role of their content:labelis a short label of the page's or the talk's context, such as the chapter or the event;titleis what the page discusses (usually a one-line noun phrase);subtitlefollows the title with the one sentence the page wants to say;mainholds figures, tables and explanation. On every page,subtitleforms one heading with the title (HTML elements and reading order). References at the bottom of a page (references) are not a place to write; they are made from footnotes (Footnotes). The page number is not written but turned on withpaginate. - The slot
labelhas no alias and is not the layout namesection.layout: section(a kind of page, the section opener) and[label: …](a slot for the chapter or event name) are different things. - Slots of the cover only:
authors(the presenters; one or more),affiliations,date(as written; never today's date). Their content is ordinary text (Markdown), with no pairing of authors and affiliations. On any other layout they are reported asslot-not-in-layout(warning), like other slots, and the content is kept. - Reserved words:
box(a plain element),callout(a box with a marker column, Callouts),shape(a shape with its text inside its outline, Shapes),group(a container that only gathers elements, Groups). Speaker notes are written in"""blocks (Elements). - Custom tags are declared in the theme's YAML and follow HTML's valid custom element names: they start with an ASCII lower-case letter, contain a hyphen, contain no ASCII upper-case letter, space, NUL,
/or>, and are not names HTML reserves. Standard tags never use a hyphen (nor will tags added later). A declaration of a name not of this form (such ascard) or of a standard tag's name is reported as a problem of the theme (inkoma check, a warning on the theme document), and only that declaration is unused. The theme's source stays as written. An element of that name in a document isunknown-tag(When brackets are an element), like an undeclared name: its content is drawn as an ordinary box, and its source is unchanged. While the theme has a problem, export (PDF, HTML, PowerPoint,koma export) reports it and stops. A tag and where it goes are separate: a custom slot takes[box slot=left: …]. Elements of the same tag may appear on a page any number of times. - One pair of brackets is one element. The same slot written twice on a page is not joined: the second stays a separate element, with its id, and is reported.
- Two or more of the same slot on one page are all drawn: none is dropped, merged or made an error.
duplicate-slotstays a warning and does not stop export. Without positions they are drawn on top of each other in the same frame, so the message says what happens and how to fix it: they are drawn on top of each other; give one a position, or keep one. - Where one title of the page is needed (the document's name, the heading read aloud, checks of the title's content), the first in the source is used, as with HTML's
<title>.
Order of attributes
The order of attributes in an element's tag has no meaning: any order reads the same, and only explicit tidying puts them in a set order.
How to write
Write attributes in any order. When an attribute is written twice, the first takes effect (Elements). Tidying orders them as name, #id, classes, x y w h rotate z, other known attributes, and unknown attributes. For example, tidying turns [box.note style="color: red" w=40% x=10.5% data-n=1: into [box .note x=10.5% w=40% style="color: red" data-n=1:.
Details
- Explicit tidying (
koma format,koma check --write, the app's Tidy) separates the tag's words with spaces in this order: 1. The element's name; 2.#id; 3. each.class(keeping their order among themselves).id=andclass=come after them. 4.xywhrotatez5. Other known attributes in this order: what to draw (slotsrcaltcroplangwidthsfrangebaselinefillfill-opacitystrokepoints), a line's ends and connections (x1y1x2y2fromfrom-sidefrom-attoto-sideto-atroutearrowlabel-atlabel-side), and the rest (weightmarkerdirstepstep-effectstyle) 6. Unknown attributes (including looks written as attributes, likeopacity=) last, in the order written - Values move as written: no rounding, no change of unit, no change of quoting (quotes are removed only where tidying could always remove them, Elements).
- A tag with a duplicated attribute (
#idandid=,.classandclass=count as the same attribute), with a bare word (bare-word), or withname=orrole=, has its joined name, ID and classes separated, and keeps the order of each word. - Rewrites other than explicit tidying (moving or resizing on the canvas, the format panel, MCP
setAttributes) keep the written order. Attributes whose value changes are rewritten in place; attributes whose value does not change are not rewritten. A new attribute goes into its place in the order above without moving written ones: before the first written attribute that comes later in that order, or else at the end of the tag (even when the written order differs from the order above). Several attributes added at once follow the order above. So a tidied tag stays tidy after the GUI rewrites it. - The command line and the app use the same tidying function.
Groups
Groups
A group is a container that only makes its elements belong together, with no position, size or look of its own.
How to write
Open with a [group: line, list the elements to gather one level deeper, and close with a line of ] alone. The tag takes only an #id and classes.
Example
Output of koma export
Source
[title: Two rooms]
[group #venue:
[box .card x=10% y=40% w=35%:
Reading room, first floor
]
[box .card x=55% y=40% w=35%:
Swap table by the entrance
]
]Details
- The elements inside are read and drawn as they would be without the group. A positioned element keeps its position relative to the group's parent (Elements), a flowing element flows in the parent's flow, and a frame element (
[title:]and the like) goes into the layout's frame. Text inside reads as if written in the group's parent (directly on a page, bare text, Placement). The group's opening and closing lines break a run of bare text, like any element's lines. Otherwise, wrapping elements in a group or unwrapping them does not change what is drawn. - Any element may go inside: frame elements, positioned elements, flowing elements,
[col:]and[row:], other[group:]s. Nesting has no depth limit.[col:]and[row:]splits (Columns and rows) are counted from outside the group: a[col:]wrapped in a group joins the same split as the[col:]beside it. - Attributes other than the
#idand classes keep their source, have no effect, and are each reported asgroup-attribute(warning). A group with nothing inside (including one of only blank lines and comments) is reported asempty-group(warning) and kept. A group without:is held back with its content asmissing-colon, like any element (When brackets are an element). - Its extent is the rectangle around its elements as drawn (a rotated element as rotated), never written in the source. Stacking order is source order (an element with
zfollows the stacking-order rules). Reading order (HTML elements and reading order), footnotes (Footnotes) and steps (Steps) belong to each element inside. - HTML, PDF and images draw as without the group. Tidying indents it like other containers (The standard form).
Callouts
Callouts
A callout, [callout: …], is a box with a marker column on the left and a content column on the right.
How to write
Write [callout marker="⚠": content]. marker= takes one emoji or symbol; without it, the marker is 💡. A callout takes the same attributes as a box.
Example
Output of koma export
Source
[title: What to bring]
[main:
[callout marker="⚠":
Bring your own cup; there is no kitchen.
]
[callout:
Write your name in your book, so it can find its way back.
]
]Details
- The marker is drawn at the top of the left column. All content (paragraphs, lists, math, nested elements) flows in the right column and never wraps under the marker.
- The marker is written
marker=: one emoji, one symbol (⇒ ∴ ※ ✔ ⚠ ⓘ and the like: one character that is neither a letter nor a digit), ornone. Without it, 💡.- Emoji and symbols are drawn a little larger than the text (1.25 times). A symbol takes the box's text colour; an emoji keeps its own colours. What a reader sees as one character (one grapheme, such as a skin tone or a flag) counts as one.
- Text (any value that is not one emoji or symbol: two or more characters, or one letter or digit, such as
marker=Cost) is not a marker. It keeps its source, 💡 is drawn, and it is reported astext-marker(warning). The fix is to choose an emoji or symbol, or to write a text heading as a definition list (Definition lists). marker=nonedraws neither marker nor column; the content starts at the inner padding.- An empty value or one with a line break is reported with the general attribute warning
bad-value, keeps its source, and 💡 is drawn.
- The class
badgehas no special meaning. Like any class it stays in the source, changes nothing unless the theme's or document's CSS defines it, and is not reported. - The column is as wide as a symbol (
1.25em), with0.5em(of the body text size) between marker and content. Every marker has the same width, so consecutive callouts align their content's left edge. When the marker column is wider than a quarter of the callout's inner width (between its left and right padding, including the column),koma check --layoutreportslong-marker(warning) with the percentage of the width the marker takes.- With
paddingwritten instyle, the marker column is still taken inside that padding: the left padding is the written one plus the column (padding: 0puts the marker at the box's left edge). The marker never leaves the box. Editing, drawing and PowerPoint agree.
- With
- The content is centred vertically, with equal top and bottom inner padding (Named styles). In a frame taller than its content (with
hwritten, or stretched to a column's height), the content sits in its middle;align-contentinstylewins. The marker aligns with the content's first line (the first even when there are several), and its line is as high as one line of body text, so even with one line the marker's and the text's centres line up, and the marker never makes the box taller. Editing and drawing put it in the same place. - A callout without a style class (Named styles) is drawn
tint. It takes the same attributes as a box, can go wherever a box can, and nests. [box:]has no marker. Amarker=on a box keeps its source, draws nothing, and is not reported.- Tidying indents it like other containers (The standard form). HTML, PDF and images draw it as the screen does.
Shapes
Shapes
A shape ([shape:]) is an element that draws the outline of a rectangle or an ellipse and puts its text in the rectangle inside it; its kind is written type, and a rectangle's rounded corners radius.
How to write
[shape type=rect: …] is a rectangle and [shape type=ellipse: …] an ellipse. Without type it is a rectangle. For a circle, write the same w and h. Round the corners with radius: [shape radius=16px: …], or a share of the shorter side, [shape radius=10%: …] (50% makes the ends half circles). The text is written as in a [box:] and drawn in the middle of the rectangle inside the shape.
[shape x=10% y=30% w=320px h=180px type=rect radius=16px:
Measure
]
[shape .tint x=55% y=30% w=240px h=240px type=ellipse:
Compare
]Details
[shape:]is an element apart from[box:]. A box is a container for text and layout (flow, columns and rows, frames, the base of a theme's custom tags), and its rounded corners only shape its fill without changing where its text goes. A shape's outline comes first: it decides the text rectangle, the points lines connect to and the PowerPoint shape.- The values of
typearerectandellipse, the names of the SVG elements (<rect>,<ellipse>). Any other value is reported asbad-value(type) and drawn as a rectangle. The attribute has the same name as a chart's kind (typeon a chart). radiusis a length:px, or%of the shape's shorter side (not a share of each side as CSS's%, so the corners never turn elliptical).0may leave out its unit. A value over half the shorter side (50%) is taken as half, as CSS rounded corners are, and nothing is reported. A number without a unit ismissing-unit, another unit or a value that is no lengthbad-unit, and a value below 0bad-value(radius).radiushas no effect on an ellipse: its source is kept as written and it is reported asradius-on-ellipse(warning), with a fix that removes it (safe: what is drawn does not change). It takes effect again if the shape becomes a rectangle, sokoma format --writedoes not remove it.- Only
radiusdecides the corners.border-radiuswritten for a shape (instyle, a theme or the document's CSS) is not used; instyleit is reported asshape-border-radius(warning). The fix moves it toradiuson a rectangle (it may change the meaning, since what is drawn changes) and removes it on an ellipse (safe). A theme cannot round every shape's corners: the shape is what its source says. - The text rectangle: the text goes in the rectangle that fits inside the outline's line, less its
padding.- Rectangle: the rectangle inside the line, and with a
radiusof r, a further r × (1 − 1/√2) (about 0.29 r) in from each side: the rectangle that touches the corner arcs at 45°. - Ellipse: the rectangle inscribed in the ellipse inside the line, with the ellipse's proportions (its width and height 1/√2 of the ellipse's), centred.
- Rectangle: the rectangle inside the line, and with a
- Alignment: by default centred both ways (the theme's CSS
shape { text-align: center; align-content: safe center; }). Change it withtext-alignandalign-contentinstyle. - Size: without
h, the text rectangle is as tall as its text (a rectangle as a[box:]; an ellipse √2 times the text rectangle's height). Placement (free or in the flow), the width withoutw, what the body may hold (Markdown and child elements), shrinking and overflow (Who decides size) are as for[box:], each taking the text rectangle as the box's content rectangle. - Look: by default a thin line in the text colour and no fill. The style classes (
tint,fill,outline,bar,card,.accentand so on) andstyletake the same declarations as[box:]. Themes and the document's CSS selectshapeandshape.tint. - Connected lines: a rectangle, rounded or not, has the connection points top 0, left 1, bottom 2, right 3; an ellipse top 0, left 2, bottom 4, right 6. A line's end stops on the outline.
Figures and images
Figures and images
A figure ([figure:]) is a container holding what it shows and the text of its caption; the picture itself is written as an image ([image:]). A figure is written one way: what it shows as a child, and the rest of its text as the caption.
How to write it
[figure:
[image src="assets/decay.svg" alt="Sound level falling over time in three rooms":]
How the echo fades in each room
]
[image x=70% y=10% w=20% src="assets/logo.svg" alt="":]
A picture without a caption is written as [image:] alone. A chart with a caption is wrapped in [figure:] the same way.
Details
- The attributes of
[image:]:src(the same path and safety rules as other image references),alt(alternative text; nothing is reported when it is left out; a decorative image hasalt=""),crop(cropping, as a listcrop=(0, 0, 10%, 0), with the order and meaning of the cropping in Elements), and the commonx,y,w,h,#id, classes,style,stepandrotate. It has no body. Text in its body keeps its source, is not drawn and is reported asimage-body(error), with one fix that wraps it in a figure as its caption (it may change the meaning). An emptysrcis reported as a missing reference,bad-value(image src). - The attributes of
[figure:]are only the commonx,y,w,h,#id, classes,styleandstep. An[image:]inside a figure gives the figure's picture only itssrc,altandcrop; the figure decides place, size,#id, classes, look andstep.src,altandcropon the tag of a figure that holds an[image:], and the other attributes of the inner[image:], have no effect: their source is kept and they are reported asfigure-attribute-ignored(warning); the picture is the[image:]'s. - What a figure shows:
[image:],[chart:],[diagram:],[math:]and[code:]. A line at the structural position of the figure's body (after depth × 2 spaces) that starts an element with one of these names (the element form of When brackets are an element) is shown; every other line is the caption's Markdown. The caption's lines join in the order written, whether before or after what is shown. The formatter does not reorder them. - Two or more shown elements stand side by side at equal widths in the figure's area, with one caption under them all (no caption for each). Any other element (
[box:],[table:],[col:]and so on) as a child keeps its source, is drawn in the same row as what is shown, and is reported asfigure-child-unsupported(warning). A table has its own caption and notes, so it is not wrapped in a figure. - Size, the caption's place,
align-content, lines (border-*) and rounded corners follow the figure rules of Elements, reading "the picture" as "the area of what is shown". An[image:]placed on its own is drawn by the size rules of a figure without a caption. - An empty
[figure:]is kept as an unfilled field of a new page. A figure with a caption and nothing shown is reported as a missing reference.
How an element reads its body
An element's body is read in the one way set for the element's name. For each element, one rule says where child elements may stand, what is read as Markdown and what goes to another grammar.
How to write it
| Element | Child elements | Markdown | Body in another grammar |
|---|---|---|---|
| Directly on a page | Allowed | Text between elements (a bare text box, Placement) | None |
Frames (title, main and so on), box, callout, shape, col, row | Allowed | Text between the children | None |
group | Allowed | As if written in the parent (Groups) | None |
figure | What it shows (Figures and images) | Text outside what it shows is the caption | None |
table | Not allowed | The caption and notes; without src, one table | The CSV or TSV of src (a file) |
math | Not allowed | Not read | TeX |
code | Not allowed | Not read | The language of language |
diagram | Not allowed | Not read | Mermaid |
chart | Not allowed | Not read | CSV |
image, curve | Not allowed | No body (:]) | None |
line | Not allowed | The body is kept and not drawn | None |
Details
- In a body in another grammar (
math,code,diagram,chart), neither elements, Markdown nor comments (a;at the start of a line) begin. What remains of each line after its structural indentation (depth × 2 spaces, and 2 more) is the body: further indentation, symbols,[,],$and;are kept as body text. The closing]stands on its own line at the opening's depth (Elements). - A
+++at column 0 is a page break in any body, and a recovery point that does not carry an unclosed element over to the next page (Page boundaries). The same holds inside achart's CSV. - Text written in an element without a body (
image) keeps its source, is not drawn and is reported (image-body, Figures and images). - A theme's custom tag reads its body as the element it
extends. An element whose body is in another grammar cannot be extended.
Curves
Curves from a formula
A curve is an element for pulses and envelopes that draws the values of a formula f in its box, and has no fixed shapes (shape=) or carrier attributes (carrier=).
How to write
Write the formula in f, and place the box with x, y, w and h as for any element. A curve has no content (:]). domain= gives the horizontal range and range= the vertical one; arrows are arrow=, as on lines. Formulas used often can be named and defined under functions: in the document's settings.
[curve x=10% y=20% w=30% h=10% f="sin(2*pi*6*t) * 0.5*(1-cos(2*pi*t))" arrow=end:]Example
Output of koma export
Source
===
functions:
rc(t): 0.5*(1-cos(2*pi*t))
drive(t): rc(t)*sin(2*pi*6*t)
===
[title: A pulse with an envelope]
[curve .muted x=10% y=30% w=80% h=45% f="rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .muted x=10% y=30% w=80% h=45% f="-rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .primary x=10% y=30% w=80% h=45% f="drive(t)" arrow=end:]Details
- The horizontal range is given as a list of the left and right ends, as
domain=(-pi, pi)(Lists of values). Each end is a finite constant expression. Without it, 0 to 1. An invalid end, or two equal ends, is reported asbad-value(domain), nothing is drawn, and the source is kept.x=and the like place the box as for any element. - The left side of
f="x -> sin(x)"is the input variable, local to the formula. Without it,xand, for compatibility,tboth name the horizontal value. Vertically, −1 is at the bottom of the box and 1 at the top by default;range=(0, 1)(a list of the bottom and top, each a constant expression as an end ofdomainis) changes that. To show the amplitude as it is, the range never adapts to the values; values outside it are drawn outside the box. Arangethat is not two finite values, or two equal ones, is reported asbad-value(range) and nothing is drawn. - A curve without
his a quarter as high as it is wide. - Formulas: numbers (
2,0.5,1e-3), the input variable,pi,e,+ - * / ^, unary minus, parentheses and function calls.^binds tighter than unary minus and associates to the right (-2^2is −4,2^3^2is 2⁹). Multiplication cannot be left out (2tdoes not read). Built-in functions: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.logis the natural logarithm,sinc(x)is sin(x)/x (sinc(0)is 1; not divided by π),step(x)is the Heaviside step (1 forx≥ 0, 0 below),mod(a, b)takes the sign ofb,roundrounds halves up, andminandmaxtake two or more arguments.erfanderfcuse the Numerical Recipes approximation (error below 1.2×10⁻⁷), andgammathe Lanczos approximation with the reflection formula, with no value at 0 or negative integers. The app reads formulas itself, with neitherevalnor a library. - Defining functions: under
functions:in the document's settings (===), listname(arguments, …): expression. A theme's settings (===) may hold them too; for the same name, the document's wins. A function has one or more arguments; its name starts with a letter followed by letters, digits or_. Definitions may call other definitions. A definition that calls itself directly or through others (recursion), takes the name of a built-in function,piore, cannot be read, or uses a name that is not an argument (inside a function,tis usable only when written as an argument) is reported on thefunctions:line asbad-value(functions, with the definition's head and the reason), and only that definition is unused.functions:in page settings (---) issetting-out-of-scope.=== functions: rc(t): 0.5*(1-cos(2*pi*t)) drive(t): rc(t)*sin(2*pi*6*t) === [curve x=10% y=30% w=40% h=20% f="drive(t)" arrow=end:]
- When
fcannot be read, uses an unknown name, or calls with the wrong number of arguments, it is reported asbad-value(f, naming an unknown name; forpulse, the screen says “The formula uses pulse, which is not defined”), and nothing is drawn; the source is kept. - Drawing: the formula is evaluated at about one point per px of the box's width (at least 2, at most 2000) and the points are joined. A point whose value is not a finite number (
sqrt(-1),1/0, a pole) breaks the line, which starts again at the next finite point. Once on the page, points are taken again at the drawn size (a nested curve, a size in%). - Heads and look are those of lines:
arrow=start|end|both, the head-shape classes and--head-start,--head-end, sizes such as--head-size. A triangle's tip is at the curve's end; the point one head-length back along the curve is the centre of its base, and the line stops there. The triangle points from the centre of its base to the tip, with butt line caps. An open head follows the end's direction; dots and diamonds are centred on the end. Colour, width and dashes take the same classes as lines (.accent,.muted,.thick,.dashed) andstyle(stroke-width,stroke-dasharray). - Fill:
fill=shades the area between the curve and a horizontal baseline, drawn behind the line. It takes a colour role (primary,secondary) or a CSS colour (a name,#2563eb,#2563eb33,rgba(37, 99, 235, 0.18),hsl(…));fill-opacity=(0 to 1) fades it further.baseline=is a finite constant expression on the vertical scale; without it, the baseline is 0 when 0 is insiderange, else the bottom ofrange. Each run of the curve is filled on its own, closed straight down (or up) to the baseline at its first and last points.stroke=set tononedraws the fill alone, with no line and no heads; a line width of 0 (style="stroke-width: 0") draws no line either. Afill,fill-opacityorbaselinethat cannot be read (abaselinethat is not finite or not constant) is reported asbad-value(fill,fill-opacity,baseline) and no fill is drawn; astrokeother thannoneisbad-value(stroke). The curve itself is still drawn. On a curve these four are its own attributes, not looks (Elements); built-inminandmaxshade where curves overlap.=== functions: g(x, m): exp(-((x - m) / 8)^2) === [curve x=10% y=40% w=40% h=12% f="g(x, 35)" domain=(0, 100) range=(0, 1) fill="rgba(37,99,235,0.18)":] [curve x=10% y=40% w=40% h=12% f="g(x, 55)" domain=(0, 100) range=(0, 1) fill="rgba(37,99,235,0.18)":] [curve x=10% y=40% w=40% h=12% f="min(g(x, 35), g(x, 55))" domain=(0, 100) range=(0, 1) fill="rgba(220,38,38,0.32)" stroke=none:]
- HTML and PDF draw an SVG path, the fill as a path of its own under the line.
Step-by-step display
Steps
Steps reveal elements one stage at a time while presenting.
How to write
Write the order to show in the common attribute step: [box step=1: text], [col step=2: text], [row step=2: text]. An element without step is shown from the start. The form {step=1} is not in the grammar.
Example
Output of koma export
Source
[title: Tonight]
[main:
[col:
7 pm Doors open
]
[col step=1:
8 pm Book talks
]
[col step=2:
9 pm The swap
]
]Details
- The value is a safe integer of 1 or more. Presenting reveals the valid steps from the smallest, those with the same number together, and goes to the next page once all are shown. A nested element's step is the largest of its own and its ancestors'; a child without one inherits its parent's. The written value is never rewritten. No empty steps are made for numbers no element uses.
- Going back hides the last step shown. Going to the previous page shows its last step; Home is the first page's start, End the last page fully shown. Restarting the presentation shows the chosen page's start. A hidden element still takes its space.
- Editing, static HTML, PDF and PowerPoint show everything. No timelines or animations are added.
Entrance effects
An entrance effect (step-effect) decides how an element first becomes visible on its step. Write it in the document or page settings, or use it as an element attribute. The accepted values are appear, fade, and rise. The element's value wins, followed by the nearest ancestor that provides a value, then the page, then the document. The default is appear. A rise reveals the element from its bottom edge without moving it.
Only the outermost element that becomes visible on a step animates. Children that share their parent's step appear with that parent. A child with a later step enters with its own effective effect. Going backward hides a step immediately. step-effect-unused identifies an effect written where the element enters together with a parent or where neither the element nor its descendants have a step. Invalid values are reported as bad-value and fall back to the inherited effect. Quoting a value keeps its meaning. The formatter places the attribute after step. Articles and posters retain it with a type-unused-feature note.
Memos
Memos
A memo is a note for the author placed on a page, which no presentation or export shows.
How to write
Open with ::: and key=value attributes in column 0 on a page, write the text on the lines after it, and close with a line of ::: alone. x and y place the memo, and w and h size it.
[title: Results]
::: x=64% y=18% w=28%
Check the units on the axis.
:::Details
- Attributes:
xandyare%of the page orpx, and may be negative or beyond 100% to place the memo on the pasteboard around the page; a missing one is0.wandhare optional positive lengths of the same kinds. Withoutwthe editor gives the memo its default width, and withouthit is as tall as its text.collapsedset totruefolds it to a pin;falseis the default. Another attribute is kept and reported asunknown-memo-attribute(warning). An unreadable value is reported asbad-value(warning), and the default applies. Later attributes, such as a colour, are added in the same form. - Text: plain text, kept as written. It is not read as Markdown, elements, settings or notes. A
+++in column 0 still breaks the page (Page boundaries). A line of the text that would close the memo or break the page is written with a leading\, which is not part of the text. - A memo that does not close ends at the next page break or the end of the file, keeps its text and is reported as
unclosed-memo(error). - Only a
:::line followed by attributes and nothing else opens a memo. A bare:::and::: namekeepmisplaced-scoped-blockandunsupported-declaration(Document settings) in the preamble and on a page. An indented:::inside an element is text. - A memo belongs to its page and takes no part in its layout, flow, reading order, notes or footnotes. The presentation, the presenter view, HTML, PDF, PowerPoint, images and thumbnails never draw it or carry its text. The Koma AST has a
memonode (Syntax tree nodes). The resolved page lists its memos with their place and text, which only the editor's canvas and the agent tools read. - Tidying keeps a memo's lines as written and puts one blank line before and after a closed memo, as for notes (The standard form).
Text and inline markup
Inside an element, text is Markdown with LaTeX math, plus a few additions of Koma’s own.
Markdown and LaTeX
Text inside elements
Text inside an element is written in Markdown and LaTeX.
How to write
In running text you can use Markdown emphasis (*…*, **…**), underline (__…__), strike-through (~~…~~), highlight (==…==), code, links and footnotes; superscript ^{…} and subscript _{…}; LaTeX math $…$; and attributes on a span, [text]{.class}. A # at the start of a line is a heading, *** a horizontal rule, and lines of $$ around a formula make displayed math.
Example
Output of koma export
Source
===
lang: en
===
[title: Marking up text]
[main:
Bring **one** book. *Swapping* is free.
==No booking needed==. Open 7 to 10 pm. Bottles of H_{2}O are welcome.
[New]{.chip} This month ~~10~~ 12 books arrived. The area is $\pi r^2$.
]Details
- The inline notation is Markdown's emphasis, code, links and footnotes, LaTeX math, and Pandoc-style inline attributes. Raw HTML is kept and shown as the characters written. Emphasising one word is written with Markdown's
**; the look is the theme's. - Links are drawn with the theme's link colour and underline. Only links inside footnotes take the footnote text's look (Footnotes).
- Inline attributes: the standard forms are
[text]{.class .another},[text]{style="color: #234080"}, and both together,[text]{.class style="font-weight: normal"}. The closing]and the attribute's{touch, and attributes are separated by spaces. Text and attributes are on the same line. Emphasis, highlight, code, math, links and footnotes inside the text are kept. The same brackets work on a span that holds formatting:[**important** result]{style="color: #b42318"}makes only “important” strong and colours the whole span;[==important==]{style="font-weight: 700"}adds weight to a highlight.[text]{.underline}is read as an existing class; a new underline is written__text__.styleis written as on elements: CSS declarations in double quotes. The properties allowed arefont-family,font-size,font-style,font-weight,colorandtext-decoration-line. Values are checked and ranked as for each declaration of Elements. Unsupported declarations and values are not applied, are reported asbad-value, and keep their source.- Koma element tags, Markdown links and reference links, and footnotes are read first; inside code and LaTeX, inline attributes are not read. An empty text (nothing, or only spaces, between the brackets), a missing close, or an
#idor another unsupported attribute keeps its source and is treated as text. An empty text is reported asempty-span: an answer blank is written with text inside, as[answer]{.blank}(its look set by the class) or[\_\_\_\_]{.blank}. Class names take the same characters as on elements. - The look of a class is set by the theme's and the document's CSS.
.chipis a rounded ground with bold text (in the official themes). A class with no definition is reported asunknown-class, and the text shown is kept. - HTML and PDF draw the same way.
- Superscript and subscript: superscript in text is
^{superscript}, subscript_{subscript}, as in1^{st}andH_{2}O. A pair complete on one line is read; an unclosed pair, an escaped one, a pair inside code or math, andfile_namekeep their source. Strike-through~~…~~and LaTeX$x^{2}$are read as strike-through and math. Superscripts and subscripts written with older classes are shown for compatibility and are subject to explicit migration. - Highlight:
==text==. A span complete on one line is read and drawn with HTML'smark(Inline classes). Unclosed, escaped, and inside code or math, the marks stay as they are.[text]{.mark}is read as text with a class, and keeps the document's own class. Attribute delimiters with the brace in front are text of the body (Brace-first attributes are text). - How the notation relates to others: shared with Pandoc are emphasis, links, code, footnotes, strike-through, highlight and
[text]{attributes}. LaTeX follows Code and math are isolated and the rules for math. Superscript and subscript are Org mode's braced forms (^{…},_{…}). A;at the start of a line is a Koma manuscript comment (Page boundaries): kept when saving, left out of display and export. - Citations reserved:
[@key]is reserved for a way of citing yet to come. It is shown as written and reported ascitation-unsupported. Citations are written as footnotes,[^label]. Nothing is reported inside code and math. - Horizontal rules:
***;___is read too. The formatter writes***. There are no Setext headings with---and===; the line before is never made a heading. A line of only===is text. A line of only---(indented or not) is not a horizontal rule: it is shown as written, reported asdashes-not-rule(warning), with one fix to***. A---in column 0 is Page settings. - Emphasis, underline and strike-through:
*x*is emphasis,**x**strong importance,__x__underline,~~x~~strike-through. In every language, including Japanese, emphasis is italic and strong importance is bold.- Old Koma
_…_,__…__and___…___are read by the old rules in the command line's explicit migration and changed to*…*,**…**and***…***. Ordinary saving and tidying never migrate. Before applying, the text is read again to confirm the meaning is the same. ***x***is both strong importance and emphasis. It may hold complete inline math, code, links and footnotes. Link text is read as ordinary Koma Markdown. The same triple marks inside, and other complex nesting, are not supported: the outer marks and the inner content are kept.- So that a selected span can be formatted whatever the language and the neighbouring characters,
*-family emphasis may touch characters, digits included, and punctuation without spaces.1**word**2makeswordbold;2*3*4emphasises the middle3. Emphasis is never refused by guessing that digits around it make a formula. Multiplication is written as math (as$2*3*4$), and the literal symbol escaped (as2\*3\*4) or as code. Only complete delimiters are read, and the existing protection is kept: just inside spaces, escapes, code, math and link targets. Existing source is never rewritten automatically. - Underline reads even when the marks touch the characters on both sides. A single mark as in
file_name, and marks in code, math and link targets, are not underline.
- Old Koma
- Headings:
#is a heading (not a page). A heading's level is its depth in the document, not its size.- The heading mark is a single
#. A#in plain text (directly on a page) and a#inside an element are both headings within the page's body,h3in HTML.h1is only the document's title andh2only the page's title (thetitleelement). The level does not change with whether the page has a title, or with nesting (HTML elements and reading order). ##to######are read as headings too (so pasted Markdown is not broken). In HTML each extra mark is one level deeper from#'sh3, down toh6; they look the same as#. They are reported asdeep-heading(note), with one fix to#, This fix changes the level and so may change the meaning: it is applied only when chosen in the GUI or withkoma check --write --unsafe.koma check --write, saving and tidying never change the marks.h3toh6are bold at the effective size of the text around them, with a small space below. A#in a figure caption takes the caption text's size. The space can be changed with the theme's--koma-local-heading-gap.- There is no notation for a large heading in plain text, and no Setext headings or HTML tags. Large text is written with classes and the document's CSS, or with inline attributes.
- A heading in the flow of text is
#; a heading standing on its own is a separate element or a child element. No element per heading is required. - The guide, examples and the GUI write headings in the source with
#only. - The HTML elements are HTML elements and reading order.
- The heading mark is a single
- Line breaks and spaces: a line break inside a paragraph is a line break. Leading and trailing spaces left after the structural indentation is removed are kept even in ordinary paragraphs, and the extra spaces are shown. Inside elements there are no Markdown indented code blocks: four or more spaces still read as text. Code blocks are fences, which can name a language. When pasting Markdown with indented code, fence the code.
- Math:
$…$and$$ … $$(by Pandoc's rules, so$5 and $10is not math). For displayed math, the recommended form puts the opening$$and the closing$$each on its own line (three lines:$$, the formula,$$), and tidying writes this form (The standard form). A one-line$$ formula $$is read as the same math. - Comments: a
;at the start of a line inside an element (after the structural indentation) is a comment (Page boundaries). Inside fences and raw bodies, and in the middle of a line,;is text.
Definition lists
Definition lists
A definition list sets out terms, each paired with its explanation.
How to write
Write a term on one line, and the explanation on the next line starting with : (a colon and a space or tab), the same form as Pandoc and Markdown Extra.
Example
Output of koma export
Source
[title: Around the library]
[box x=8% y=30% w=70%:
Swap table
: Leave one book and take another.
Reading room
: Quiet until 9 pm.
]Details
- In HTML,
dl,dtanddd. - A term may have several explanations (more
:lines). Continuation lines of an explanation are indented two or more spaces. Blank lines between items are optional (a term after blank lines continues the same list). - A
:line is read as a definition only when it follows a one-line paragraph (one line after a blank line or after another block). After a paragraph of two or more lines, after a list, table or heading, and with no space after the:(:1), it is text. An element tag's colon, page and document settings, and code and math are read first and are never definitions. Terms and explanations take the inline notation (emphasis, math, links,[…]{.chip}). - Look (changeable with the theme's CSS): by default the term is bold on the left and the explanation on the right, their tops aligned. The term column is as wide as the longest term, up to three tenths of the box. With the class
stack-termson the box, explanations are stacked, indented, under their terms. The space between items is that between list items, on a slide tightened in the same order when they do not fit. Between a term's second and later explanations, half of it. - Export: HTML and PDF are as on screen.
- A line of only a colon is read as text, and a warning offers a fix that removes the line.
- The formatter keeps the form as written.
Footnotes
Footnotes
A footnote is a mark in the text whose note is gathered at the bottom of the page. References and side notes alike are written as footnotes.
How to write
Write a mark [^label] in the text, and its footnote from the start of a line as [^label]: text (as in Markdown). Written inside any element, it is a footnote of the page.
Example
Output of koma export
Source
[title: The busiest hour]
[main:
On weekdays, 7 pm is the busiest hour[^1].
[^1]: Central Library survey (fictional).
]Details
- References are written only with footnotes. Bibliography and side notes alike are footnotes, gathered into the references at the bottom of the page. There is no other way to write them and no other slot. In the body or the subtitle, the mark sits where it is written.
[^label]in text is a footnote mark.[^label]: textfrom the start of a line is that mark's footnote (one line).- A page's footnotes are its references (
references), drawn gathered in the page's footer band in the order their definitions are written, under the page's[footer:]when it has one (The bottom band). Their position, width and alignment with the page number follow the layout. As the band grows with them, the body above it shrinks, so body text placed by the layout ends above them (body text with a position of its own stays as it is). The theme decides only the look (Who decides size). - A mark with no footnote is drawn as written,
[^label](as in the footnote drawing rules). The same mark's footnote written twice is reported asduplicate-footnote(warning), and both are kept. - Notes (
"""blocks, Elements) are not footnotes. Footnotes inside notes are not gathered. - A link in a footnote is drawn, in every theme, in the footnote text's colour without underline, and works as a link (clickable on screen, a link in PDF and HTML). PowerPoint too uses the footnote text's colour without underline (the look of links in the body is unchanged).
How footnotes are written
Footnotes are written as in GFM (GitHub Flavored Markdown).
How to write
Write [^label] in the text, and [^label]: text at the start of a line; continuation lines are indented. A label is a string without spaces. How they are drawn is the footnote drawing rules.
Footnote labels
The string after ^ in [^1] or [^AM1] is shown as written, at the mark and in the definition. Nothing is numbered automatically. Footnotes resolve per page; the same label defined twice on a page is reported as duplicate-footnote and both are kept. An undefined mark is shown as [^label] with no further diagnostic. Marks in the body and subtitle are small superscripts; labels in the definitions at the bottom are at the normal height. Drawing, local editing, HTML, PDF and PowerPoint use the matching label and never rewrite the source. Speaker notes are not part of a page's footnote definitions.
Older inline attributes
Brace-first attributes are text
A brace written in front ({.chip: text}) is not an attribute but text of the body.
How to write
Attributes in text are written after the text, as [text]{.class} (Text inside elements). A brace put in front, as in {.chip: new}, is drawn as written, as text.
Details
- Half-width (
{.chip: new}) and full-width ({.tag:新しい}) alike get no diagnostic and no automatic fix, and tidying keeps the source.
Styles and themes
Attributes say what an element is and where it goes; its look comes from the theme, its classes and its style.
Document CSS
A document's CSS is written in css: in the document settings (===). The value is read by its YAML shape, never guessed from its content.
===
title: Talk
css:
- styles/talk.css
- |
title { color: #294d73; }
page.dark { background: #17212d; color: white; }
===
- A literal block (
css: |,|-,|+) is CSS written in the document. - A one-line string ending in
.css(in any case) is the path of a CSS file inside the document's folder. It may be quoted. It is relative, separated by/, with any leading./dropped. A URL, anything starting with/, and anything with\, an empty part or..is not a path. - A sequence lists those two kinds, applied in the order written, joined as one CSS.
- Any other value (a folded
>, a one-line string not ending in.css, a number, a map, an empty sequence, a sequence with a non-path string) is reported asbad-value, and none of it is applied.
CSS files are read under the same rules as images: only inside the document's folder, checked by their real path, never leaving the folder through .. or links, UTF-8 and 256 KiB at most. A file that cannot be read is reported as css-file-unavailable (error), and only that file is left out. url() inside a file is relative to the document's folder. CSS from a URL is never read. @import is not read, in written CSS or in files, and is reported. Scoping, page.class and the checks are the same for written CSS and files.
Page settings have no css: (setting-out-of-scope); there is no per-page CSS. A page's look comes from the class in its page settings, put on the page's outer frame and selected by page.class in the document's CSS. No other selector of pages is added, except that a page's edge lines may be written as declarations in that page's style: (Page-edge lines). Line declarations on page { … } (border and the per-side border-*) apply to a line layer inside the page, not to its outer frame, and move nothing on the page.
::: followed by attributes opens a memo (Memos); otherwise it is a reserved mark with no use. A bare ::: line in column 0, in the document's preamble or on a page, isolates its source up to the matching ::: (or the next +++ in column 0) and is reported as misplaced-scoped-block, pointing to the document's css:. A ::: name line at the root is reserved for future declarations, reported as unsupported-declaration, and isolated the same way. An indented ::: inside an element is Markdown text.
Tag, ID, class, compound and list selectors and * match only the document's Koma elements. The page itself is selected with page { … } and page.class { … }, written like an element. page is the name of a virtual parent, reserved as a tag name and never written in the source (a written [page …] is unknown-tag). page takes one class at most; an ID, two or more classes, combinators or pseudo-classes are reported and the block is not applied. The automatic page number is selected with the reserved name page-number, as page-number { … } (also inside @layout name { … }); it takes neither ID nor class, and if given one, the block is reported and not applied. page-number is reserved as a tag name and cannot be a custom tag. The page's three bands are selected the same way with the reserved names page-header, page-body and page-footer (Layout grids): each alone in its rule, with neither ID nor class, also inside @layout name { … }; they hold no Markdown parts and cannot be custom tags. A grid written on page itself is reported as legacy-page-grid and not applied. @slide { … } and @page-number { … } are reported and not applied, like any unknown at-rule. Looks for one layout go inside @layout name { … } (Looks for one layout). Unsupported combinators, attributes and pseudo-classes are reported, and no block is partly applied. No outside resource or executable code is loaded.
Looks for one layout
@layout name { … } makes rules in the document's and the theme's CSS apply only to pages of one layout.
How to write
Write the layout's name after @layout (Page layouts, including a theme's named layouts), and ordinary rules inside { … }. For example: @layout cover { subtitle { font-size: 46px; font-weight: 400; } }. @layout cover { page { … } } applies to the pages of that layout themselves. padding written on page decides the area of the flow directly on the page (Placement).
Example
Output of koma export
Page 1
Page 2
Source
===
css: |
@layout cover { subtitle { color: #b42318; } }
===
---
layout: cover
---
[title: The book swap]
[subtitle: Only the cover's subtitle is red]
+++
[title: An ordinary page]
[subtitle: The ordinary page keeps its default colour]Details
- It works the same way for every tag (
title,subtitle,label, custom tags, classes, IDs). No tag has an exception of its own. - Only rules may go inside. There is one name, unquoted. Declarations written directly inside, nested
@rules, and a missing name or more than one are reported, and the block is not applied. - When a rule for all pages and a rule of the layout both match the same element, the layout's rule wins whatever the order written (it weighs one class more).
- The official themes use this to give the cover's subtitle the look of the cover subtitle’s look (lead size, not bold, body colour).
Markdown parts in elements
The document's and the theme's CSS can select the parts Markdown makes inside Koma elements (paragraphs, list items, headings, pictures, table headers and cells) by their HTML names.
How to write
Write the part's name after a selector of Koma elements and a space (box.tint p { … }, callout li { … }). A part's name alone selects it inside any element (h3 { margin-block-end: 0.3em; }). + between two parts selects the one right after (p + p { margin-block-start: 0.6em; }).
Details
- Parts:
p,li,h3,img,th,td.caption,figcaptionandtableare selected as before. The list namesul,ol, anddlapply only on either side of+, alone or in a part-only:is(). A bareul, a bare:is(ul), or an element followed by:is(ul, li)does not select list containers. Generatedpageandpage-numberhave no Markdown parts. Report these forms aspart-selector-unmatchedand omit that rule alone. - Forms:
[selector of Koma elements] part, orpart + part(each a name, or:is()listing part names only). A part takes no ID, class, pseudo-class or attribute.>,~, a part after a part, and a Koma element after a part are not applied. - The part names are reserved and never name a tag.
- Only what an element's own text writes in Markdown is selected: not the footnotes Koma draws, nor a frame's own text (
label,titleand so on), which its tag selects. - In specificity a part counts as one type selector. The document's CSS is outside the theme layer and always wins over the theme.
- Other HTML names inside elements (
strong,a,blockquote…) are not selected; text is styled by text classes (Text inside elements). - A Markdown name written in a form that selects nothing (
ul { … },box > li { … },strong { … }) leaves out that rule alone and is reported aspart-selector-unmatched, naming the forms that work. Report at the document CSS selector, or at thecss:setting when it references the stylesheet. Other rules apply. Editing, presentation, HTML, PDF and images share rendering. PowerPoint copies the result’s sizes, colours and spacing.
@keyframes in a verified theme and in document CSS are applied to the editor, presenting and HTML with their names kept apart per page. Only document CSS is separated per page; the order of theme then document, specificity, !important and ordinary var() are kept. CSS that cannot be separated is not partly applied, and the reason is given. PDF, PNG and PowerPoint are still output in the base style without animation, and say so. Stilling other media such as video is not promised.
Themes
What a theme decides
A theme decides the look of the slides and the default placement of the layouts.
- Theme CSS uses Koma selectors such as
theorem#result.importantandpage { … }. Declare shared custom properties on the page and use the public theme tokens listed in Public variables.
How to write
Choose it with theme: in the document settings (Choosing a theme). Positions and sizes written in the document take precedence over the theme's defaults.
Details
- What is published: The public styling surface comprises tag, ID and class selectors for elements, Markdown component selectors (Markdown parts in elements), ordinary CSS declarations, and the variables listed in Public variables.
- Official themes: default, talk and report. A theme (look and layouts) is kept apart from templates for a document's structure.
- Math face: the document YAML of theme.koma may set
mathFont: fira,mathFont: stix2ormathFont: newcm(New Computer Modern Math). Without it, Fira; an unknown value is reported. Within a theme, inline and display math use the same face. The official themes use newcm for default, and Fira for talk and report.--math-font: fira|stix2|newcmin an element'sstyledraws only the math inside that element in a face other than the theme's. Math is drawn to suit the kind of face of the text it sits in; only words in\text{…}follow the surrounding weight. Surrounding bold or italic adds no formatting to math. In every theme, bold and italic written explicitly in TeX are kept. The math data, licences, size and checks are recorded in the math boundary. - Text faces: the local Noto assets are used for the default sans and code, and for serif when named. Licences, coverage, weight matching and the boundary of output are recorded in text faces. Choosing an element's role is the format panel’s rules.
- Colours (common to the three official themes): each theme writes on
pagethe primary colour--koma-primary, the text on it--koma-on-primary, the secondary role--koma-secondaryand its text colour--koma-on-secondary(Colour roles, Text on role colours), the line--koma-line, the body colour, the tint background derived by Soft tint, the figure caption colour--koma-caption-color(the body colour), and the footnote colour--koma-footnote-colorand muted colour--koma-muted(both ink-2).labelandbox.citation, footnotes, footers and muted text use the same weak text colour (ink-2); figure captions, table captions and table notes the body colour;page-numbera lighter grey; and an ordinary page'ssubtitlethe primary colour. ink-2, the page-number grey and the soft ground are made from the primary's hue with default's saturation and default's contrast on white (ink-2 about 6:1, the page number about 3.4:1, the soft ground about 1.09:1). Body text and ink-2 reach 4.5:1 or more on the ground and the soft ground, and text on the primary colour 4.5:1 or more.- default: body
#16161d, ink-2#5f626f, page number#888b98, soft ground#f4f5f9, primary#2d287f. - talk: body
#17212d(16.3:1 on white), ink-2#576564(6.1:1), page number#7d8f8d(3.4:1), soft ground#eff6f6, primary#0f6b63(white text 6.4:1). - report: body
#17212d(16.3:1), ink-2#5c646c(6.0:1), page number#858d95(3.4:1), soft ground#f3f5f8, primary#3b4754(white text 9.5:1). - One grey for weak text: label,
box.citation, footnotes, footers and muted text (.muted) are all ink-2. Only the page number stays a lighter grey. The default of themes that are not built in (slide.css) is one colour too (#595959), and--koma-mutedpoints to--koma-footnote-color. - Figure captions, table captions and table notes take the body colour. Grey is left only to footnotes, footers, page numbers and labels. The three official themes set
--koma-caption-colorto the body colour, and table notes use--koma-caption-color(or else the surrounding text colour). HTML, PDF and PowerPoint agree.
- default: body
- Sizes follow the frame: the body size is written in
--koma-font-size(which the page kinds of Values per kind of page may change), figure captions arefigure { font-size: 0.7em },box.citationis0.7em, and tables write no size and inherit from the frame. So that afont-sizeon a box reaches the figure captions, sources and tables inside, none of these has a fixed px size. - Space between list items: each theme writes on
pagea wide value--koma-item-gap: 0.8emand a narrow value--koma-item-gap-min: 0.35em(the names--koma-list-item-gapand-minare not read). Items normally take the wide value, and lists inside an item half of it. When a slide's frame does not fit, the gap narrows continuously to the narrow value before the text gets smaller. When a theme or document sets both to the same value, nothing narrows. Documents and posters take their kind's fixed value instead, 0.25em, which never narrows (Values per kind of page). Being in em, they follow the text size of the frame or box. The table of contents layoutoutlinetakes no space from line height; the body's wide value is default 1.05em, talk 0.67em, report 1.03em (the narrow value stays 0.35em, narrowing when it does not fit). - label: the default weight is 400 (regular). A label is a small note above the title; in regular weight and the weak text colour, it does not compete with the (bold) title. Being regular, part of it can be bold, as in
**Study I** multi-qubit control. No letter spacing is added. The three official themes keep 400 for the labels of ordinary pages and the cover, and make only a section opener's label a chapter heading, 700 in the primary colour (Cover and section pages). - Page number and footer: the page number's default colour is the same grey as the label at the top left. A theme can set its colour with
page-number { … }(Page settings). A page'sfooterdefaults to the same weak text colour as footnotes (--koma-footnote-color). Both stand in the footer band (The bottom band), which a theme selects aspage-footer { … }; the header and the body arepage-headerandpage-body(Layout grids). - Default line breaking and typesetting (a theme or the document's
css:can change them with bare selectors such aspage,box,tableandcallout; table captions are selected ascaptionand figure captions asfigcaption, as in HTML, with no ID or class; the default rules have no specificity):- Between paragraphs: in slide bodies and boxes, paragraph, list and definition-list boundaries use the same proportional gap and automatic fitting as list items, using
--koma-item-gapand--koma-item-gap-min. Documents, posters, captions, table notes, footnotes, and presenter notes use 0.5em between paragraphs, wider than a document's or a poster's list items (Values per kind of page). Keep the first and last edges clear. Authors may set adjacent-part CSS or explicit--koma-paragraph-gap. Nested list spacing follows the editing view’s rules. Display math, code, tables, quotations, diagrams, figures and grids take the block gap above and below, which closes up with the item gap (HTML elements and reading order); elements in a flow use the flow gap (Columns and rows). Editor blank lines and HTML, PDF, and PowerPoint spacing agree. - Between caption text and the image or table edge, use 28 px by default, 12 px on articles, and 40 px on posters. Themes and documents can set
figcaption { margin-block-start: … }andcaption { margin-block-end: … }. Table notes sit at 75% of this gap below the table. - Text is broken so that the last line is not left with one word or character (
text-wrap: pretty). Titles and subtitles are broken into lines of even length (balance). - When the document's language is Japanese (
lang: ja), text breaks at phrase boundaries, table cells included (word-break: auto-phrase). But frames, elements and captions whose inner width is less than 8 characters of their text break anywhere (an extra line is better than a word cut in the middle). - Where the browser has no
auto-phrase(as in the macOS app's WebKit view), the drawn text of a Japanese page gets a<wbr>at each phrase boundary from BudouX, the model Chromium's own phrase breaking uses, and those elements break only there (word-break: keep-all; overflow-wrap: anywhere, with no specificity). It is fetched on first need, kept for offline use, and never loaded where the browser breaks phrases itself; the pages are fitted again once it arrives. Math, code, preformatted text, drawings, editors and URLs get no breaks, nor does a place before a closing mark or after an opening one, and narrow blocks keep breaking anywhere. The source, tidying, the editor and copied text are unchanged. - Tables break only words longer than the column, anywhere (
overflow-wrap: anywhere, on the table elements). - When the last line of a Japanese paragraph (paragraphs and list items of frames and elements in a
lang: jadocument) has two characters or fewer, the paragraph is drawn again narrower by 1 em at a time, up to 3 em, and the width that leaves at least three characters on the last line without adding a line is used. If none fits, the original width stays. - In paragraphs with kana or kanji, a line never breaks after a hyphen inside a Latin word (such as
heavy-hex) (when drawing, a U+2060 goes after the hyphen; the source and tidying are unchanged). - Inline math stays on the line of the opening bracket right before it, and of the closing bracket or punctuation right after it (
(,),、,。and so on). Without an opening bracket, the one phrase right before it (a word and the kana after it, with any space or U+00A0 between; for example 約 in 「約 $1.57\Delta$」) stays on the math's line. - A space between a number and a unit (
GHz,ns,dB,mK,%and so on; the list is in one place in the code) is drawn as a non-breaking space. The source and tidying are unchanged. A U+00A0 written stays. - Full-width brackets at the ends of lines on Japanese pages have their space trimmed in the three official themes (
text-spacing-trim: trim-both, Brackets at line ends). - HTML, PDF, images and editing break lines the same way.
- Between paragraphs: in slide bodies and boxes, paragraph, list and definition-list boundaries use the same proportional gap and automatic fitting as list items, using
The source of a theme
A theme's original is a .koma document, with the fonts and images it needs beside it.
How to write
Write the theme in theme.koma and put its fonts and images in the same folder. How to write a theme document is in the section on themes whose original is a .koma document.
Details
- A folder that uses
theme.cssand the like is treated as another format. - No script is run.
- How far a document can pin the version of the theme it uses is recorded in the record of pinning. There is no mechanism for managing or sharing themes.
- A theme folder's
layouts/is not read, in either format. Its files are not used for drawing or checking, cannot be reached from the theme's CSS or a theme document'scss:(they are reported as unavailable), and are not put into new packages, frozen themes or sharing copies. In a theme frozen earlier, its bytes are kept for checking the freeze but not read or counted toward size limits, and the rest of the theme applies.koma lintandkoma checkreport alayouts/folder in the document's theme folder (for a theme document, its own folder) astheme-layouts-unused(a note). The source and the files are not changed.
Choosing a theme
A document points to its theme with theme: in the document settings.
How to write
A built-in theme by name (theme: default, theme: talk, theme: report), a folder beside the document by relative path (theme: ./themes/my-theme), a URL by its address. A document without theme: is drawn with the default theme, default.
Details
- The default theme is named
default. The UI shows Default in English and標準in Japanese. - The app (a new document, choosing a theme) and
koma newwritedefault. - A theme at a relative path travels with the document.
- A theme at a URL is fetched and kept locally (it works offline).
Checking a theme's CSS
A theme's CSS is checked when it is loaded, so that other people's themes can be used safely.
How to write
A theme's CSS is ordinary CSS. The selectors written are confined to the slides, and outside resources are limited to the theme's folder and fonts.
Details
- Selectors are confined to the slides; the app's own screen cannot be changed.
- Outside resources (
@import, outsideurl()) are limited to the theme's folder and fonts. - What the check refuses is left out alone, as a browser leaves out a rule it cannot read: a rule with a selector that is not a Koma selector, a nested rule, an at-rule a theme may not use, a declaration that loads from outside the theme's folder, or text the CSS parser cannot read. The rest of the theme applies: its other rules, its layouts and its tags.
- Each is reported where it is written, as
theme-css(a warning): at its line intheme.komawhen the theme document is checked; with its style sheet's name and line, at thecss:line, for a sheet the theme names; and with the theme's file and line, at thetheme:line, when a document is checked.koma lint,koma checkwith or without--layout, and the language server report it; the app lists it with the theme's problems, naming the file and line. An export is refused while one remains, as it is for a document's CSS.
The theme layer
A theme's CSS is drawn in the CSS cascade layer koma-theme, so the document's CSS and elements' style always win over the theme.
How to write
Layers are never written by hand. The document's CSS (css:), page edge lines in page settings' style: (Page-edge lines) and elements' style (Elements) sit outside the layer, so they win whatever the specificity of the theme's rules (the theme CSS cascade layer).
Details
- In the layer: Koma's built-in slide rules (the base shared by every theme), the CSS of theme documents (official themes, themes in the document's folder,
theme.koma), rules made from theme data (theme.json), and the per-page rules made from the theme's@keyframes. Inside the layer, specificity and order written decide (base, theme, theme data). - Between pieces of document CSS, and between document CSS and elements'
style, the ordinary CSS cascade holds (stylewins). !important: as CSS defines,!importantinside the layer beats!importantoutside it. What built-in rules fix with!important(measuring table widths, the left-only line of abarbox) does not change even with!importantin the document.!importantin an element'sstylebeats!importantinside the layer too.- Neither a theme's nor a document's CSS may write
@layer(like other unknown at-rules, it is reported and not applied). Only Koma decides the layer's name and order. - The editor, presenting and the presenter view, theme previews, export (PDF, PNG, PowerPoint, HTML,
koma export), the try-it embeds and the VS Code preview draw alike. While a theme document is open and being edited, itscss:goes in the layer too. HTML export keeps the layer.
Public variables
The CSS variables a theme or a document may set are the public ones listed here; every other look is written as ordinary CSS.
How to write
Public variables go on page (and its @layout): page { --koma-primary: #2d287f; --koma-item-gap: 0.8em; }. Anything else is a selector and ordinary declarations: box.tint { padding: 0.75em 1em; border-radius: 12px; }, figcaption { margin-block-start: 28px; }, th { background: #f4f5f9; }.
Details
- Public variables can be set in theme and document CSS.
Variable Meaning Related rule --koma-primary,--koma-on-primaryPrimary colour and text over it. Koma chooses the text colour when omitted. What a theme decides, Named styles --koma-secondary,--koma-on-secondarySecondary colour and text over it. Koma chooses the text colour when omitted. What a theme decides --koma-lineLines in outline,bar, tables, and divisions.What a theme decides, Named styles --koma-muted,--koma-footnote-color,--koma-caption-colorMuted text, footnotes and footer, and figure captions. What a theme decides --koma-chart-1to--koma-chart-6Chart series colours, independently of the primary and secondary roles. CHT --koma-item-gap,--koma-item-gap-minMaximum and minimum list spacing used for fitting a slide; a document's or a poster's fixed list spacing (Values per kind of page). What a theme decides --koma-font-sizeBody font size, which can vary by page kind. What a theme decides, Values per kind of page --koma-padding-block,--koma-padding-inlineDefault page-kind padding. Set page-specific padding with page { padding }(Placement).Values per kind of page --koma-gapDefault split gap. Columns and rows --koma-transition-durationDuration of a page transition, 400 ms by default. Motion durations --koma-step-durationDuration of an element's entrance effect, 250 ms by default. Motion durations --math-fontMath face within an element, set in its style.What a theme decides
- Unlisted
--koma-*and--_koma-*variables are internal. Their names and meanings can change. - Former public variables are ignored. There is no aliasing or
legacy-css-variablemigration. Use the current primary and secondary role pairs,.markfor highlights, andbox.tintorcallout.tintfor tint. Use the relevant CSS declarations for spacing, margins, table appearance, box padding and radius, and title typography. Keep the rules for--koma-heading-rule-*(Cover and section pages) and--koma-ja-text-spacing-trim(Brackets at line ends). - Public variables express colour relationships or feed calculations such as fitting and page-kind defaults. Use ordinary CSS declarations for a single component's appearance.
Colour roles
Themes use --koma-primary and --koma-secondary as colour roles for built-in styles.
- Primary is the document's principal colour. Default uses
#2d287f, Talk#0f6b63, and Report#3b4754. It appears in[text]{.primary}(Role classes), the ordinary pagesubtitle, sectionlabel,fillboxes,.chipbackgrounds, the tableaccentclass, shapes and lines using.primary, tint (Soft tint), and chart series one. - Secondary is
#edb909in all three official themes. It colours the left line ofbarand its 8% background, as well as highlight==…==or.mark. Highlights mix 50% secondary into the page background usingcolor-mix(in srgb, var(--koma-secondary, var(--koma-primary)) 50%, var(--koma-background, #fff)). Secondary also applies to.secondaryshapes and lines, chart series two, and the markers of single-series charts. If secondary is absent, use primary. - With no explicit
--koma-chart-1to--koma-chart-6, series one and two use the role colours. Series three through six alternate the two colours at lighter 35% and 60% mixes with the page background.
Text on role colours
Text placed on a role colour uses --koma-on-primary or --koma-on-secondary. When omitted at the rule or element that sets the role colour, Koma chooses whichever of white (#ffffff) or the page text colour gives the higher WCAG contrast ratio. If the chosen colour still falls below 4.5:1, role-contrast reports a note without altering rendering.
Soft tint
Soft tints (.tint and plain callouts) mix --koma-primary at 6% into the page background (color-mix(in srgb, var(--koma-primary) 6%, var(--koma-background, #fff))) as an opaque fill.
Role classes
Official themes provide .primary for primary-coloured inline text ([word]{.primary}) and .primary / .secondary for shapes and lines. Inline text has no .secondary, and boxes/callouts attach no built-in look to .primary or .secondary.
Motion durations
Two CSS variables set motion duration. The user's reduced-motion preference disables the effects.
How to write
Set the variables on page or its @layout. For example, page { --koma-transition-duration: 400ms; --koma-step-duration: 250ms; }.
Details
--koma-transition-durationcontrols the page transition and defaults to400ms. Use the value in effect on the incoming page.--koma-step-durationcontrols an entrance effect and defaults to250ms. Use the value on the outermost element entering at that step (Entrance effects). Normal CSS inheritance lets the page set the default. Elementstyleor document CSS can override an element and its descendants.- Use CSS times in
msors.0sis immediate. Negative or invalid values fall back to the default without a diagnostic. fadeis linear.pushandriseuseease-out. Koma fixes easing.- Under
prefers-reduced-motion: reduce, transitions and steps are immediate. The playback device's preference takes precedence for presentation and HTML. Themes and documents cannot override it. - Default, Talk, and Report rely on the defaults.
Flow columns
A theme or document may write the multi-column and fragmentation properties of CSS on Koma elements and page, and authored block margins between items in a flow are kept.
Example
Output of koma export
Source
===
css: |
box.sheet {
columns: 2;
column-gap: 36px;
column-rule: 1px solid #c3c9d0;
row-gap: 16px;
}
.span { column-span: all; }
box.item { break-inside: avoid; }
===
[box .sheet:
[box .span:
# Tidepool field sheet
South Cove · low tide at 14:20
]
[box .item .outline:
**1. High shore**
Count barnacles in a 20 cm square near the dry line.
]
[box .item .outline:
**2. Mid shore**
Note limpets and dog whelks under damp ledges.
]
[box .item .outline:
**3. Lower pools**
Record water temperature $T$ and shade cover before moving on.
]
[box .item .tint:
**Reminder**
Leave turned stones face down so organisms underneath stay shaded.
]
]Details
- On a container:
columns,column-count,column-width,column-gap,column-ruleand its-width,-styleand-color,column-fill. On an item:column-span,break-inside,break-before,break-after. gapandrow-gapwritten in theme or document CSS on an element set the space between what its flow holds, asstyle="gap: …"does (Cards without positions);gapkeeps its CSS meaning on the element too, so on a multi-column container it also sets the column gap.margin-block-startandmargin-block-end, and the block sides ofmargin-top,margin-bottom,margin-blockandmargin, written on an element (not on a Markdown part or the page) add to the gap before and after it, in every flow, not only in columns. This is how a theme leaves answer space after a problem. Amarginwhose sides a variable may stand for is applied as written.- Ruled lines are written as ordinary CSS, such as a
repeating-linear-gradientbackground on the container behind items with a background of their own. There is no Koma-specific ruling property. - Pseudo-elements and counters (
::before,counter-increment) stay outside the public surface; numbers such as “Problem 1” and “(1)” are written in the source.
Theme data
A theme's look is written in CSS alone; legacy theme data (tokens, boxStyles with look keys, elements) is no longer read or migrated.
How to write
In theme.koma's css:, or theme.css for a folder theme. The display names of styles are written like pageStyles: boxStyles: { quote: Quote } (class name: display name).
Details
boxStylesthat only names classes (quote: Quote) is kept.
Theme documents
A theme is edited as an ordinary .koma document, theme.koma. Opened in the editor, its frames can be edited on the canvas as samples of the layouts. Each sample page's layout: name setting stands for that layout, and the sample elements on it with a position and size define its frames (Frames from sample elements). Custom tags are declared in the document YAML's tags, never implied by sample elements. Sample text is for previewing the theme and is never copied into documents that use it. Even when a frame of the same name as a tag is chosen by default, a tag's kind and its slot are different ideas, and the document's text, images and explicit coordinates are kept. Invalid, duplicated or unsupported names or coordinates keep their source and are reported. A theme may define the default placement of cover, section, content and blank too.
No YAML key is required to mark a document as a theme. It is opened and edited like any .koma, and its definitions are checked when it is chosen as a theme with theme: or in the app. By convention the theme's source is theme.koma; when a document meant as slides is chosen and lacks the layout definitions it needs, this is reported rather than guessed. A CSS-only theme needs no pages.
The css: in a theme document's document settings (Document settings: written CSS and CSS files in the theme's folder) is applied as the theme. Assets and CSS files are kept as paths relative to the theme document, and go through the same safe reading and scoping. A document selects a custom theme with a reference such as theme: ./themes/editorial/theme.koma. A theme folder can be pointed to as well, but two sources are never mixed. Elements on a layout page that are not frames become that layout's decoration (Layout decoration). Unsupported per-page CSS is reported, never mistaken as drawn.
Page styles are defined by page.class in the theme document's or the document's css:. A theme may give their display names in its document settings' pageStyles as class name: display name (pageStyles: { dark: Dark background }). Class names start with a lower-case letter followed by lower-case letters, digits and hyphens; display names are non-empty strings; anything else keeps its source and is reported. A class without a display name shows its class name. Display names of layouts are written the same way in layoutNames.
A theme .koma and a .koma template for documents, with content and pages, serve different purposes; making a document never changes the template. The command line can copy an official theme, or a local theme.koma with the images it needs, into a new folder for editing; the original theme and the document's reference are not changed, and the shared checks refuse missing files and unconfirmed fonts (editing copies records the boundary). The web menu and palette can make an editing copy too. A theme.koma being edited is copied with its unsaved text, and the document is never switched automatically. The theme version of a saved document can be pinned explicitly in the web app, the VS Code GUI and the command line; the limits are in the record of pinning. There is no dedicated way to create a new theme without a file name, and no GUI for managing themes. Existing theme.css and theme.json folders are not this .koma document format.
Frames from sample elements
A theme's layout frames are defined by sample elements placed in the theme document.
How to write
On a layout page of theme.koma (a page whose settings have layout:), place elements with positions and sizes (x, y, w, h, in % or px). Each element is, as it stands, the definition of the frame of its name. [title x=6% y=11% w=88% h=9%: sample] is the title frame; [box slot=left x=… : …] is the left frame.
Details
- Only elements placed in frames by name (built-in tags with a default frame, custom tags declared in the document YAML, and elements with
slot=) name a frame. Aboxwithoutslot, flowing elements such as figures and tables, and unknown elements define no frame. - The footer frame: on every layout, the footer stands with the footnotes in the footer band below the body (The bottom band), at the frame's left edge and width; it grows upward with its content as the band does. An element whose document writes
yorhis placed as written. - When two elements define the same frame, the first is used and the second is reported as
theme-slot-duplicate. A naming element with no position or size, a unit other than%orpx, a size of 0 or less, or the same attribute written twice is not a frame definition, and is reported in the source panel astheme-slot-no-geometry(“Give the theme's frame a position and a size”). The source is not rewritten. - Frames without a definition use the built-in default positions. Sample text is not copied into documents. Frames are ordered as in the sample, and new pages write frames in that order.
- Vertical order: on a layout whose theme CSS writes a grid on
page-body, the sample's vertical position is the value the grid is made from, and the grid decides where the frame is drawn (Layout grids). The sample frames remain for the horizontal position and width, for the position on layouts without a grid, and as the way to edit the sample on the canvas. - Page edge lines:
page { border-bottom: … }and@layout name { page { … } }in the theme's CSS draw a line at the edge of every page or of a layout's pages (Page-edge lines). The line is drawn inside the page and moves neither frames nor the bands. PowerPoint looks the same. - The padding:
page { padding }and@layout name { page { padding-… } }in the theme's CSS decide the room around the page's header, body and footer bands on that layout's pages, and so the flow's area, which fills the body (Placement, Layout grids). They move no frame placed by its sample'sxandy. The built-in themes (default,talk,report) align left and right with the body frame's sides (5%, 7%, 3.5%); on each layout with a grid they write its first frame's top as the top padding (Layout grids). Elsewhere the top stays the page kind's default and the bottom is the page number's margin, with the footer band keeping the rest of the kind's bottom padding (The bottom band), and the flow starts at the body's top left.
Layout decoration
A layout's decorations are elements on a layout page of the theme document that name no frame.
How to write
On a layout page of theme.koma, place a box, shape, line, figure or the like with neither slot nor a frame name. There is no special notation. On every page using that layout, they are drawn at the written position and size, behind the page's edge lines (Page-edge lines) and its content.
Details
- They cannot be selected or moved from a document, and do not appear in the document's source panel. To change them, edit the theme. When the theme document itself is open, decorations are ordinary elements to edit. Speaker notes are never decorations.
- Whether covers and section openers have them depends on whether the theme places decorations on that layout's page.
- The canvas, page list, presenting, HTML, PDF and images draw them alike.
Layout grids
Every page is a header, a body and a footer stacked inside the page's padding; a theme lays out a layout's frames with the CSS grid it writes on page-body, and the body's rows measure the body.
It replaces a grid written on page that measured the whole page (page bands).
How to write
In the theme's CSS, for each layout:
@layout content {
page-body { grid-template-rows: minmax(43px, auto) 11px minmax(97px, auto) minmax(65px, auto) 65px minmax(0, 1fr); }
label { grid-row: 1; }
title { grid-row: 3; }
subtitle { grid-row: 4; }
main { grid-row: 6; }
}
page-header, page-body and page-footer name the three bands of the page, as page-number names its number (Looks for one layout). They take neither ID nor class and are allowed inside @layout name { … }.
Details
- Structure: the page (
page) keeps its size, its padding and the origin ofxandy. Inside its padding stand, one under the next, the header (auto; with nothing in it, 0 high), the body (minmax(0, 1fr)) and the footer (auto, up to itsmax-height, The bottom band). The three bands are drawn on every page of every document type (slide, article, poster) and every layout; an empty one takes no room, so nothing switches on what the page holds. - Drawn as:
<section class="slide">(the page) holds.koma-page-header,.koma-page-bodyand.koma-page-footeras its grid rows (Koma writesdisplay: grid; grid-template-rows: auto minmax(0, 1fr) autoand the padding on the page itself). The page's decorations (Layout decoration) and its edge line (Page-edge lines) stay on their own layers over the whole page. - Header: kept for the deck's running head, nothing written on a page; nothing is drawn in it yet, so it is 0 high. The deck's logo keeps its corner place over the page (The document's logo).
[label:]is a slot of the body, not the header. - Body: the frames of the layout (
label,title,subtitle,main, cover fields, custom frames) are the body's direct children. The body is always a CSS grid, oneminmax(0, 1fr)row and column unless the theme writes its own; authors never write itsdisplay. The page's flow (Placement), what the page holds withoutxory, is drawn in.koma-page-flow, a direct child of the body that fills the body's whole area and adds nothing to the height of its rows. Continuous text on articles and blank layouts therefore starts at the body's top and ends at the footer's top. - Frames in the grid: the frames the theme gives a
grid-rowthat the document writes neitherynorhfor. A frame the document writesyorhfor is placed as written, from the page's origin (out of the grid), and moves no other frame; the theme'sgrid-rowdoes not apply to it. - Placed elements: an element with
xoryis placed from the page's top left corner, never the body's, whatever band its source belongs to (Placement). The bands are not containing blocks; the page is. - A frame is as tall as its row. A
minmax(least, auto)row takes its least height even with little in it and grows with more; anautorow is 0 when its frame is not written. - Declarations that apply in a theme's CSS: on
page-body,grid-template-rows,grid-template-columns,row-gap,column-gapandgap; onpage-header,min-heightandmax-height; onpage-footer,min-height,max-height,row-gap,column-gapandgap(The bottom band); on a frame,grid-row,grid-column,align-self,justify-self,margin-block-start,margin-block-end(andmargin-top,margin-bottom),min-height,max-height.page-headerandpage-footeralso take looks:color,background,border,padding,font-size,font-weight,font-style,font-family,line-height,letter-spacing,text-alignandopacity, with their longhands, so a theme can draw a rule line over the footer. Custom properties apply to every band. Anything else on a band, such astransformandtranslate, which move only the drawing, or a look onpage-body, is said where it is written and left out; the rest of the rule applies. Looks of the body stay onpage, its decorations and its frames. - A
%ingrid-template-rowsis of the body's height, as in CSS for the grid container; a%margin is of the width. The official themes write rows in px of a 1080 px page (scaled with the page) and cut them to a 64th of a pixel as the samples' positions are. A row that only skipped the page's top margin or reserved the footer is not written: the padding and the footer are their own. Each layout with a grid writes its first frame's top as its top padding (@layout content { page { padding-top: … } }) and, when its last frame does not end at the body's bottom, the room under it as the footer band'smin-height, so frames stand where their samples are while the footer is short. - Horizontal position and width come from the sample frame (
x,wof Frames from sample elements), measured from the page's left edge as before; Koma subtracts the page's left padding when it places the frame in the body. - Content pages: label, title and subtitle from the body's top, then
mainin the lastminmax(0, 1fr)row. A two-line title pushes the subtitle and the main frame's top down; the main frame's bottom is the body's bottom. The title grows to three lines and is then fitted. An unwritten label or subtitle keeps its least height, so pages of one layout start their main frame at one place when the title is one line and the header is the same. - Section openers: rows
1fr auto auto fixed, all in the body. The title keeps its bottom and grows upward with more lines, the label right above it; the subtitle stands in the last row. - Covers: title and subtitle from the body's top; authors, affiliations and date from the body's bottom in
autorows, so an unwritten one takes no room and the gap before it does not remain either. - Migration: a
display,grid-template-rows,grid-template-columns,row-gapor other grid declaration written onpageis reported aslegacy-page-grid(warning) at its rule and left out; the rest of the rule applies.koma format --writeon a.komadocument ortheme.komawrites each such grid in its own CSS for the body, so its frames stay where they were drawn: a leading fixed row that holds no frame becomes the layout's top padding, a closing fixed row that holds no frame becomes the footer band'smin-height, a closing row that holds frames ends at the body's bottom, a%of the page is written as that share of the page's height (var(--page-height)), and the frames'grid-rownumbers follow their rows. The official themes are written this way. A grid in a CSS file the document names is reported but not rewritten.legacy-page-gridis removed in 0.2.0. - Stacking frames (
stacks:) are retired without compatibility fallback or migration notes. - Canvas, page list, presenting, HTML, PDF, images and PowerPoint draw the same. Moving a grid frame on the canvas writes
xandyfrom the page's origin, which takes it out of the grid.
The bottom band
The footer band holds the footer, the footnotes and the page number; as it grows, the body above it shrinks, and the two never overlap.
It replaces a footer band in the last row of the layout's grid that left the body's bottom in place (page bands).
How to write
As before ([footer: …], [^1]). The theme may cap the band with page-footer { max-height: … }, keep room for it with min-height, and draw it with looks such as border-top (Layout grids).
Details
- In the band, the footer and the page's footnotes stand in one column, one under the next (
row-gap, 0.5em by default), aligned to the band's foot; the page number stands to their right on the line of the last one, the page number's margin (--koma-counter-margin, 3% of the page's height) from the page's right edge. The band reaches right to that margin, past the page's right padding, where the page number has always stood. The column's left edge and width are the footer frame's (Frames from sample elements); footnotes with no footer start where the default footer frame does, 5% from the page's left edge, and reach the page number. - Drawn as:
.koma-page-footerholds.koma-footer-group(the[footer:]element and.slot[data-slot="references"]) and.page-counter. A page with neither footer, footnotes nor page number has an empty band, 0 high. - Room: the band is at least its
min-heighttall, its content aligned to its foot. Where the page's CSS writes no bottom padding, the page's bottom padding is the page number's margin and the band'smin-heightis the rest of the page kind's bottom padding, so the page number stays at its corner and the body ends where the page kind's padding does while the footer is short. A page rule that writes its bottom padding sets that margin itself, and the band then keeps no room of its own. - Growth: the band takes the height of its content up to its
max-height(a%is of the page's height inside its padding; one third when the theme writes none). The body takes what is left, so the main frame's bottom moves up by what the band gains, and frames in the body are fitted in their new size. Past itsmax-heightthe band's text is made smaller (to half), and what still does not fit is reported asoverflow. - Order: the header and the footer are measured first, then the body, so fitting never runs in a loop.
- The same band serves every layout and document type, with or without a grid in the body; there is no separate placement for pages without a footer or without a grid. A footer the document writes
yorhfor is placed as written from the page's origin; its footnotes stay in the band.
Style classes
Named styles
Style classes name appearances for boxes, callouts (Callouts), and shapes. The theme defines their CSS.
How to write
Write a class in the tag, as in [box .tint: …] or [callout .card: …]. Themes support the following choices in this order. Each background supports text contrast of at least 4.5:1.
| Name | Class | Appearance |
|---|---|---|
| None | — | No fill or outline |
| Outline | outline | Rounded corners with a 2 px --koma-line border, 1.5 pt in PowerPoint |
| Card | card | White background, shadow and rounded corners |
| Tint | tint | Pale role-colour background and rounded corners |
| Bar | bar | Left line with a pale background derived from it |
| Fill | fill | Rounded --koma-primary fill and --koma-on-primary text |
Example
Output of koma export
Source
[title: Six styles]
[main:
[col:
[box:
None
]
]
[col:
[box .outline style="flex: 1":
Outline
]
]
[col:
[box .card style="flex: 1":
Card
]
]
[col:
[box .tint style="flex: 1":
Soft
]
]
[col:
[box .bar style="flex: 1":
Bar
]
]
[col:
[box .fill style="flex: 1":
Fill
]
]
]Details
- Explicit element fields take precedence. Apply
border-color,border-width, andborder-styleto all sides of Outline or the left side of Bar. Outline defaults to the theme line or a 22% text-colour mix with the background. Default's line and primary are#d9dbe5and#2d287f, Talk's are#d8dadfand#0f6b63, and Report's are#d8dce2and#3b4754. Their primary text is white. Authoredbackground-coloroverrides the style background. Fill defaults to white text, falling back to#111827if white lacks 4.5:1 contrast. Authored text colour wins. - Visible fill, border or shadow earns padding on a box or callout whether produced by a class or authored style. An unstyled box uses zero padding for alignment with surrounding content. For visible surfaces the defaults are
0.75emvertically and1emhorizontally, relative to the box's font size. Use ordinary CSS padding and radius to override them. All official themes use the default padding. Outline and Bar draw their lines inside padding so their appearance does not shift text. - Explicit
paddingand side-specific CSS override the applicable defaults (Elements). Top and bottom defaults are equal. Avoid adding a final paragraph, list, or nested element's trailing gap inside the box. Flow from the top, with callouts vertically centred (Callouts). The default radius is 12 px and Report uses 6 px. Padding fits within the box width. - Tables use four combinable classes,
grid,striped,accent, androw-heads, shown together in the three official theme examples. Theme completion offers the five visible styles, these table classes, text classes such astag,sup,sub,markandunderline, and named theme styles. Source completion identifies theme looks and also offers document CSS classes. Custom classes always remain in source. - Shapes accept all six choices. Tint uses the shape's pale colour, Fill its colour and white text, Outline a thick line, Bar a left line and pale fill, and Card white with shadow. The style preserves the shape outline. Figures support Card and Outline only.
- A theme may add a heading band with CSS on a styled box's first heading. The built-in themes leave it unspecified.
- Use an element's CSS
list-style-typefor a custom marker or numbering. Quoted marker strings such as"✔ "and CSS values such asdecimalapply to immediate list children. Nested lists keep their own values. Editor, presentation and export agree. Invalid unquoted markers and unknown names reportbad-valuewithout applying. A theme can provide a default. - A folder theme can declare additional names in
theme.jsonunderboxStylesand define their CSS intheme.css. Show these classes after built-in styles.
Inline classes
The official themes have the text classes .sup, .sub and .mark.
How to write
In text, write [1]{.sup} and the like; superscript is usually ^{…}, subscript _{…} and highlight ==…== (Text inside elements). The names follow HTML's element names; they are written alongside .chip (Text inside elements) and can be redrawn with the document's CSS. The official themes (default, talk, report) have them, so unknown-class is not reported.
Details
.sup:vertical-align: super, text at 0.75em,line-height: 0(the line does not get taller)..sub:vertical-align: sub, text at 0.75em,line-height: 0.- A highlight is drawn as a band of the
--koma-markcolour over the lower 40% of each line. Its colour and height ratio (--koma-mark-height,40%by default) can be changed with the document's CSS. Text colour, weight and line spacing are inherited, and no space is added. Each wrapped line is drawn the same way. Body text and the default band have a contrast of 4.5:1 or more. The compatibility class.markcan be set independently of the document's CSS. - Text with both
.supand.subgets.sub, written later in the theme's CSS. - Superscripts and subscripts in math are written
$x^2$..supand.subare for characters in text (1^{st},H_{2}O, note marks).
Page kinds and edges
Values per kind of page
A theme can hold --koma-* values for each kind of page (Kinds of page), and pages take a default layout by their kind. The values are chosen by the kind, not the size.
How to write
In the theme's CSS, write the --koma-* values for text size, padding and spacing for each kind: for example, smaller body text and paper-style margins for documents, and sizes read from afar for posters. A theme of your own can write per-kind values by the same contract (What a theme decides).
Details
- A theme with no values for a kind uses its slide values. The built-in themes (Default, Talk, Report) hold values for all three kinds.
- The same theme name is used for every kind. Changing the kind keeps the theme; only the theme's values for the kind change.
- A poster is read from one to two metres: printed on A0, its body text is at least 24 pt (48 px, 36 pt, in the built-in themes) and its title about three times that. Themes multiply their title sizes by
--koma-title-scale(1 for slides and documents, 1.75 for posters). - The default layout: when neither the page nor the document writes
layout, slides takecontent, as before; documents and posters takeblank(no frames; what the page holds flows from the top inside the page's padding, Placement). A page that uses frames such as[title:]writeslayout:. An added page takes the layout of the page before it. - Vertical spacing on documents and posters is set as on paper: it follows the text's size and leading and how blocks relate, and it is fixed by the kind's values, never closed up or opened out to fill a box. From tightest to widest: a paragraph or a list right under a local heading (
--koma-local-heading-gap, 0.125em in the built-in values); items of a list and the pairs of a definition list (--koma-item-gap, 0.25em, half that between the items of a nested list, Definition lists); paragraphs, and a paragraph and a list (--koma-paragraph-gap, 0.5em); the space around a display block (a table, figure, display math, code, quotation, diagram or grid), after a heading too (--koma-block-gap, 12 px on documents and 40 px on posters); and the space above a local heading after a block (1.35em). Each em is the text's own, so the spacing follows the text size of a box. A theme can set these values for the kind (What a theme decides); a document'scss:and an element'sstyleoverride them. Slides keep their own spacing, which fitting closes up (HTML elements and reading order).
Page-edge lines
Page edge lines draw a line such as a band along the bottom of the page without a background image (linear-gradient and the like cannot be exported to PowerPoint).
How to write
A page takes border, the per-side border-top, border-right, border-bottom and border-left, and their -width, -color and -style (also border-width, border-color and border-style). page { border-bottom: 8px solid #2d287f; } in the document's or theme's CSS applies to every page, page.class { … } to pages of that class, @layout content { page { … } } to pages of that layout (Looks for one layout), and style: in page settings (---) to that page only (style: "border-bottom: 8px solid #2d287f").
Example
Output of koma export
Source
---
style: "border-bottom: 16px solid #2d287f"
---
[title: A page with an edge line]
[main: The band at the bottom is a line written in the page settings' style.]Details
- A page's
style:takes only the line declarations above. Other declarations (such ascolor) have no effect, keep their source as written, and are reported asbad-value(warning). A page's other looks are decided by the document's CSS and the page'sclass(Page settings).style:in document settings (===) issetting-out-of-scope. - Layering: by the ordinary CSS cascade, every page in the document's and theme's CSS, then the layout (one class heavier), then the page's own
style:(strongest). Each declaration layers on its own, so a layout can change only the colour. - Drawing: the line is drawn inside the page, along its edge, below what is on the page. The page's size, padding, the flow's area, and the positions of frames and elements do not change with the line (the line may overlap content). HTML, PDF and images are as the browser draws.
Official themes
Text faces
InformativeText faces: the default sans and mono are bundled and used first, and faces named by a document or theme are taken from the computer.
How to write
Write a face's name in font-family in the document's or theme's CSS.
Details
- The default sans and mono (Noto Sans CJK JP, Noto Sans Mono CJK JP) are bundled with both
komaand KomaDocs and used first in default drawing, so every computer shows the same look. - The serif faces are bundled only with KomaDocs, not with
koma. A document naming the serif face underkomais drawn with it if the computer has it, and otherwise gets the warning below. - Faces named by a document or theme are taken from the computer.
- When a named face is not on the computer, it is not replaced silently: a warning is given (not a failure). Only the first name in each text's list of faces (the one the writer chose) counts; later fallback names and generic families such as
serif,sans-serif,monospaceandsystem-uido not. The warning names the face and, when known, the face used instead.koma check --layout: afont-unavailablewarning per page.koma export: afont-unavailablewarning, once per face, in the--jsonfindings and on standard error. The output is made, and the exit code is that of a warning.
- How it is told: once drawing has loaded the faces, a sample string is compared on a canvas with three generic families (monospace, serif, sans-serif); a name that changes none of their widths is “not there”. A face the page declares is judged by its loading state.
document.fonts.check()answers “there” even for names with no face, so it is not used.
Font weights
InformativeThe bundled faces have a face per weight, and a weight the face lacks is drawn with the nearest one.
How to write
Write the weight in font-weight. sans has faces at 400, 500 and 700; serif and mono at 400 and 700.
Details
- Bundled faces: sans (Noto Sans CJK JP) has three, Regular 400, Medium 500 and Bold 700; serif and mono have two, Regular 400 and Bold 700. Medium is Noto CJK's pinned static face, subset and bundled by the same steps as the others (text faces). Variable fonts are out of scope.
- Each weight has its own
@font-face, and the browser loads only the faces used. A document that does not use Medium gets nothing more. - A face counts as missing only for a reason: no face matched, a face ended in error, the font set refused, or the face was still not in after 60 s. A face still loading after 15 s is slow, not missing, and is waited for. A failure is not remembered, so the next view or output asks again. Each fallback names its face and one of four reasons (no face matched, a face in error, refused, or timed out) in the page's
data-text-font-failureand the web inspector's console. - A weight the face lacks is drawn with the nearest face by CSS weight matching. The Medium face covers 500 to 600, so
font-weight: 600in sans is drawn with Medium (500). In serif and mono, 600 is Bold (700). Built-in looks (page numbers, authors) write their weight as 700. koma check --layout: writing a weight a bundled face lacks gives the warningfont-weight-unavailable(as"Noto Serif CJK JP" has no 600; drawn at 700), once per face and weight per page. Weight added by the browser'sbolderforstronginside bold text does not count.- HTML and PDF embed only the faces used (Medium only when Medium is used).
Line height of titles
InformativeThe line spacing of titles and subtitles depends on the document's language (lang, Document settings).
How to write
Nothing needs to be written. To change it, write title { line-height: … } and the like in the document's or theme's CSS (no :lang is needed).
Details
- In a
lang: jadocument, titles (title) are 1.25 and subtitles (subtitle) 1.4. Inen, other languages, and documents withoutlang, titles are 1.15 and subtitles 1.3. A page whoselangdiffers from the document's follows the page's language. - Covers, section openers and ordinary pages use the same values; only the text size changes with the layout. The built-in CSS sets
--koma-title-line-heightand--koma-subtitle-line-heightby the page's language, and titles and subtitles are drawn with them. The three official themes write no line spacing for titles and subtitles. - Precedence:
line-heightin an element'sstyle>line-heightwritten in the document's or theme's CSS > the default by language. - Titles that mix Japanese and Latin text are drawn with one line spacing per element too. The gap between title and subtitle, body line spacing and letter spacing do not change.
- A title that does not fit its frame shrinks as the rules for fitting text to its frame says, keeping its line spacing. The canvas, presenting, HTML, PDF, images and PowerPoint use the same line spacing.
Brackets at line ends
InformativeThe space of full-width brackets at line ends follows CSS Text 4's text-spacing-trim, and the official themes trim it on Japanese pages.
How to write
Write text-spacing-trim with a standard value (normal, space-all, space-first, trim-start, trim-both, trim-all, auto) in a theme's CSS, the document's css: or an element's style (Elements).
Details
- Other values are
bad-valuein an element'sstyle. The ordinary CSS cascade and inheritance apply. - The three official themes (default, talk, report) use
trim-bothon Japanese pages (lang: ja; by Page settings, a page without a language is read as Japanese too). The theme writes--koma-ja-text-spacing-trim: trim-bothonpage, and the built-in CSS puts that value astext-spacing-trimon Japanese pages only (a rule without specificity). Japanese pages of themes that do not write the variable, and pages that are not Japanese, arenormal. A value written in the document's CSS (page { text-spacing-trim: normal }) or an element'sstylewins. - When the browser knows the value, the browser typesets it. For values it does not know, Koma fills in only part of the standard, where the value applies, and only these two:
- When a paragraph's first character is an opening bracket
(,「,『,【or〔, the half space before it is trimmed (trim-start,trim-both,trim-all). - When a paragraph's last character is a closing bracket
),」,』,】or〕, the half space after it is trimmed (trim-both,trim-all). - A paragraph is one run of text of a paragraph, heading, table cell, definition-list term or explanation, or a frame such as a title. Footnotes and task items have a number or box in front, so only their ends count. Line ends wrapped inside a paragraph, after a line break (
<br>), and between brackets side by side are left to the browser. The behaviour ofspace-first,normalandautois not filled in.
- When a paragraph's first character is an opening bracket
- How it is filled in: when drawing, only those two characters are put in marked
spans, and the trimming CSS (a −0.5 em outer margin on thespan) is written only inside@supports not (text-spacing-trim: <value>)for each value. Where the browser can typeset the value it has no effect, so nothing is trimmed twice. There is no switching per renderer and no measuring on every keystroke. The value is read from a variable holding the same value astext-spacing-trim(--koma-text-spacing-trim, which Koma adds to each declaration), so even unknown values cascade the same way. The source and tidying are unchanged. - When the Chromium Koma draws with knows
trim-both(CSS.supports('text-spacing-trim', 'trim-both')is true), these fillingspans and their CSS are removed. - HTML, PDF, images and the canvas agree.
Cover and section pages
InformativeThe official themes' covers and section openers have no colour bands, no full-width hairlines and no short rule above the subtitle, and use the primary colour only for a section opener's label.
How to write
Choose the cover or section opener layout (layout: cover, layout: section); nothing else is needed. Sizes are px of 1920 × 1080, written in the theme's sample frames (Frames from sample elements).
Details
- Section opener frames: a section opener's
label,titleandsubtitlestand in the rows1fr auto auto fixedof the theme CSS's grid (Layout grids), and do not use the three-line rule below, which is for covers only. The title keeps its bottom edge and grows upward by its lines, and the label stands right above the title's first line (with the sample frames' gap). With a one-line title it is as in the sample; with two or three lines the label stays with the title, and the title does not shrink. The subtitle's frame does not move. - Title and subtitle frames (for section openers, as above): a cover's
titleframe is three lines of that layout's title size and line spacing (plus the built-in 0.15em space below the title, rounded up to px). The title sits at the frame's bottom (align-content: end, Page layouts). Thesubtitleframe is two lines of that layout's subtitle size and line spacing, aligned to the top. Between the bottom of the title frame and the top of the subtitle frame: 28 px for default, 2.65% of the page height for report (about 28.6 px at 1080 px). So the boundary between title and subtitle stays put whether the title has one line or three. A title of more than three lines shrinks as the rules for fitting text to its frame says.- The line spacing used is that of Japanese documents (Line height of titles: title 1.25, subtitle 1.4; default's cover subtitle is 36 px × 1.4 × 2 = 100.8, so 101). In other languages the line spacing is tighter, leaving space above the title frame and below the subtitle frame.
- default: the left margin is 96.
- Cover: the top line has
labelon the left (the same colour and weight 400 as body pages' labels, only the size 26 px). The top right is left free for the document's logo, with no theme element.titleis 68 px, its frame at y=266 and 266 high (68 × 1.25 × 3 + 10.2, rounded up), its bottom at y=532.subtitleis at y=560 and 101 high (36 px, weight 400, the weak text colour ink-2). Below, aligned left:authorsat y=862 (36 px, 700),affiliationsat y=922 (28 px, ink-2),dateat y=966 (28 px, ink-2). The bottom right is left free for the page number. - Section opener:
titleis 78 px, its frame at y=416 and 120 high, its bottom at y=536.label(30 px, 700, primary colour) is right above the title frame at y=372, 40 high.subtitleis at y=560, 140 high. - Ordinary pages and the table of contents (outside the cover and section rules; frame values only): an ordinary page (
content) haslabelat y=4%, 4% high;titleat y=9%, 9% high;subtitleat y=18%, 6% high;mainat y=30%, 60% high. The table of contents (outline) haslabelat y=4%, 4% high;titleat y=9%, 9% high;mainat y=26%, 64% high. All are 5% from the left and 90% wide. There are gaps below the label (8%) and above the title (9%), and below the subtitle (24%) and above the body (30%), so nothing overlaps at 16:9 or 4:3.
- Cover: the top line has
- Spacing: the frames of covers, section openers and content pages stand in the rows of the theme CSS's grid (Layout grids). The coordinates above are their places when the title is one line and every field is written.
- On a cover,
authors,affiliationsanddatego from the bottom, and an unwritten one takes no room (the fields above it move down). The gaps between them are written withmargin-block-start. - On a content page, a two-line title moves the subtitle and the start of the body down. The body's bottom edge does not move; only a growing footer band moves it up (The bottom band).
- A one-line title sits right above the subtitle, leaving space above. Second and third lines grow upward.
- Without a subtitle, its place is simply empty; the title and the lines below do not move.
- Without
dateoraffiliations, that line is simply empty; the other lines do not move.
- On a cover,
- Report (the same parts and rules as Default, each in its theme's places): no colour bands, full-width lines or rules. On the cover,
label,affiliationsanddate, and on covers and section openerssubtitle, are ink-2 at weight 400 (the label at the same weight as body pages' labels, What a theme decides).authorsis 700. A section opener'slabelis 700 in the primary colour, standing right above the title's first line (Layout grids). Title and subtitle frames follow the rules above.- report: aligned left with the same frame roles and order as default. Left and right margins are 4%, and frames widen to the outer margin. Body text is 30 px. The ratios of each element's text, unitless line spacing, and spacing proportional to text size are shared with default.
- Talk has no default frames for
labelandsubtitleon the cover, section openers, body pages and table of contents. The cover centres the title, with authors, affiliations and date packed below it. A section opener has only the title; body and table-of-contents pages give the body plenty of room below the title. The source and explicit coordinates are kept, and a tag without a position is treated as having no frame defined. - The rule mechanism (the theme's choice): the built-in CSS draws a short rule in the primary colour before the subtitle of covers and section openers only when the theme writes
--koma-heading-rule-width,--koma-heading-rule-heightand--koma-heading-rule-gaponpage(and--koma-heading-rule-margin-inline: autoto centre it). The three official themes do not. In a theme that does, HTML, PDF and images draw the same picture.
Semantics
What a document means once it is read: where each element is placed, how large it is, and what is reported.
Placement and size
Placement
Placement is where on the page an element is drawn: in a slot, at a free position, or in the flow.
How to write
A slot element (such as [title: …]) goes to its place in the layout. An element with x or y goes to that position in its parent. Any other element, and text written directly on a page, joins the flow where it stands.
Example
Output of koma export
Source
Text written directly on the page joins the flow as a box.
[box .tint x=55% y=60% w=35%:
A box with a position goes there.
]Details
- Slots: the position the layout decides (Page layouts). Writing
x y w hoverrides it with those values. - An element with
xory: a free position in its parent. - Neither: the element joins the flow where it stands. With only
worh, that is its size in the flow. - The flow directly on a page: an element placed directly on a page without
xory([col:],[row:],[figure:],[box:]and so on) has the page (page) as its parent and flows in the page's area.pageis a stand-in parent never written in the source. On every layout, the page's area is its body band: inside the page's padding (padding), below its header band and above its footer band (Layout grids, The bottom band), unaffected by frames such as the body frame. The padding is set by the CSSpage { padding: … }, and per layout by@layout content { page { padding-top: … } }(Looks for one layout). Sides not written use the page kind's--koma-padding-block(top) and--koma-padding-inline(left and right); a bottom not written is the page number's margin, and the footer band keeps the rest of the kind's--koma-padding-block, so the area ends where it did while the footer is short.%is of the page's height for top and bottom, and of its width for left and right. When the page has a footer or footnotes, the area ends above them, at the footer band's top (Footnotes).[col:]and[row:]split this area (Columns and rows). It is not an implicit body, and the theme'smainrules do not apply.xandyare positions on the whole page (a full-bleed image can be placed too). - Overlap with frames: only when the page's area overlaps the rectangle of a frame tag written on that page (
title,mainand so on) is it drawn as it is, withflow-over-slots(warning) reported for each flowing element, advising to write it inside[main:]to put it in the body frame. The overlap is decided from the page's padding and the frames' rectangles, the same way inkoma checkand the app. Only sharing area overlaps; touching edges do not. When the padding starts below the headings, a page of headings alone is not reported.[main:]and bare text on the same page are reported, since the body frame overlaps the area. Elements withxoryare not reported. - Unquoted text: text directly on a page that is in no element is read as a
[box:]with no placement written (an element in the flow directly on the page). It is a box written without brackets or[box:]: its drawing and export (HTML, PDF, PowerPoint) are the same as for[box: …]holding the same text. It is not an implicit body, and the theme'smainrules do not apply.- A
boxwith no style has no border or background; it is just a rectangular area. Reading bare text as a box does not draw a frame around it. - Runs: text continuing between elements is one box. Paragraphs separated by blank lines, and comments (
;) between them, go in the same box. An element between them (including a freely placed box) splits the box there, and the parts join the flow in the order written. A line of only spaces draws nothing. - Decided by syntax alone: document and page settings (including the document's CSS,
css:), reserved:::blocks, comments, notes, code and math fences, and text inside elements keep their own meaning. A footnote definition[^id]: …becomes a footnote of the page, and a run of only footnote definitions makes no box. - Lines starting with
[in column 0: lines When brackets are an element reads as text ([1] Smith 2020.,[NOTE] check this,[docs](url),[[wiki]],[0, 1)and the like) go into the box as ordinary text. Half-made element lines — those reported asmissing-colon([title Koma],[box x=10%], a block whose opening line has no:) and asunclosed-element(a half-typed[ti, or[mainbefore its]is written) — are not put in a box and not drawn, and the diagnostic is given. Lines directly on the page after an element without a close are its content (its]is still missing), and no box is made up to the end of the page. This is a syntax rule by a line's first character, so that half-typed source does not make the drawing flicker. - Reports: like other flowing elements,
flow-over-slotsis reported only when the page's area overlaps a frame written on that page.
- A
- Document and page settings, comments and notes are not text for display. The content and placement rules of explicit elements such as body are kept.
Who decides size
An element's outer rectangle comes from the position and size written in the document, or else from the layout's default, and its content flows inside it.
How to write
To decide position and size, write x, y, w, h on the element.
Details
- A theme document may define a layout's default rectangles, but never overrides positions and sizes written in the document. When the content does not fit, the text is shrunk (RND's fit) or the overflow is reported.
- Shrinking (the rules for fitting text to its frame seen from the language): on a slide, an element that does not fit first narrows its stretchable gaps together and continuously: the space between items and paragraphs (lists, tables of contents, definition lists) from the theme's wide value (
--koma-item-gap) to its narrow value (--koma-item-gap-min), and the block gap around display blocks towards 0.35em (HTML elements and reading order). A document's or a poster's gaps are its kind's and never narrow (Values per kind of page). If it still does not fit, or on a document or a poster, all its text sizes (body, headings, lead, code, captions, footnotes) are reduced together by the same ratio, the largest ratio that fits, down to half. The rectangle's position and size do not change. A page's subtitle (subtitle) and label (label) are never shrunk: they keep their size, and overflow is reported when they do not fit (Page layouts). Shrinking is decided for each slot and each element placed on the page; a size written in the document is used as it is when nothing overflows. A shrunk element is reported bykoma check --layoutastext-shrunk, with how many px of width or height would fit it at its own size (output specification). - Overflow: an element's content sticking out below or beside its rectangle, or a placement outside the page. Glyphs drawn slightly beyond their line's height (as Japanese faces do) are not overflow. A figure with only a width written is as high as its picture and caption, so the element holding it, not the figure, takes the overflow. When it does not fit even at half size,
koma check --layoutandkoma exportreport the overflow.
Splitting an area
Columns and rows
Columns and rows are elements that split their parent's area across or down.
How to write
Write [col:] as many times as the columns you want across, and [row:] as many times as the rows down. To change the ratio, write weight ([col weight=2: left] and [col: right] give 2:1).
Example
Output of koma export
Source
[title: Two columns, 2:1]
[main:
[col .ruled weight=2:
The left column is twice as wide as the right.
]
[col:
The right column
]
]Details
- The area split is in the parent: inside
[main:]the body frame, inside a positioned[box:]that box, directly on a page the page's area (inside its padding, Placement). - In one parent, a run of
[col:]with no text or other element between them is one split across, and a run of[row:]one split down. Unquoted text directly on a page is a[box:](Placement), so between splits it separates the runs like an explicit[box:], and flows outside the splits at its natural height. Half-made element lines (missing-colon,unclosed-element) and the unclosed content after them are not drawn and make no box. Source order is never changed. A single[col:]is a split too (one area filling the parent).[row:]may go inside[col:], and[col:]inside[row:]. - Size:
weightis a positive finite number (unitless, 1 by default). What is left of the split's axis after the gaps is shared in the ratio of the siblings'weight(2and1, like0.2and0.1, are 2:1, and both use all that is left). The ratio does not change when content overflows (overflow is reported). Zero, negative and non-numeric values are reported asbad-weight. Only the editing view draws them as 1;koma checkandkoma exportdo not pass, and no file is written. - Height of a split in the flow: a split across (a run of
[col:]) is as high as its tallest column's content, and does not stretch to the frame's bottom. But inside an element whose file writes a height (h), inside an area of a split down that shares height, and in the flow directly on a page (when the split across is that flow's only item), the split across fills what is left of that height (Cards without positions; a split with a column holding only one picture does not fill in a row's area or directly on a page, since the picture keeps its aspect ratio) (overflow is reported if it does not fit). The columns side by side all take that height. Following elements come right below. Freely placed children do not count towards the content's height. When the content does not fit its parent, text shrinks or overflow is reported (Who decides size), and columns do not shrink — except that a run with a column holding only one figure or picture shrinks to the height that fits its parent, the figure shrinking with its column. - Column content: a column lays out its content from the top. When a column holds exactly one box with a visible ground, line or shadow (a style class, or a fill, line or shadow in
style, or a callout) and nothing else, that box stretches to the column's height (content from the top; a callout centred vertically, Callouts). With several boxes, or text or figures beside the box, nothing stretches. When the column itself has a ground or line, that surface fills the column's height. When a column holds only one figure ([figure:]) with no width written and no height or a%height, or one picture-only paragraph (the column's height comes from its content, so a%height has no effect), the figure is drawn at the column's full width, fitted to the height if that is short (keeping its aspect ratio). A figure beside other things is drawn at its own size. - Gaps: the gap between a split's areas is
gapin thestyleof the element holding the split (style="gap: 24px"). It is a look, so it is not written as an attribute (Elements). Two values are the row gap, then the column gap. Without it, the theme's default (--koma-gap). The gaps of that element's flow do not change. In an element without a split,gapis the gap of its direct flow (Cards without positions). - Dividing lines: when any
[col:]of a run has the classruled, a vertical line is drawn between each pair of adjacent columns; in a run of[row:], horizontal lines. The line has the theme's line colour (--koma-line, or else the text colour mixed lightly into the ground), is 2px wide, sits in the middle of the gap (half the gap on each side), and is as long as the split (for a split across, the height decided by the height rules above). PowerPoint draws a line at the same place, in the same colour and width. - Vertical alignment:
[col:]and[main:]put what they hold at the top, middle or bottom of their frame withalign-contentinstyle(start,center,end; the same withsafe). Without it, from the top. Column height follows the height rules above (columns side by side take the tallest one's height), so in two columns of a figure and text,centeron the text column puts the text at the middle of the figure's height. The theme's and document's CSS can set a default per layout, as@layout content { main { align-content: center; } }(no new notation is added). When a frame holds a split, or only one stretched box or figure (a vertical flex), the same value works the same way (marked withdata-alignafter drawing). In an aligned frame, the space below the last paragraph or element is 0, so the visible content sits at the middle or bottom. The single HTML file is written with the same positions. - The first heading in a column has no space above it. The space between a heading and its text stays the theme's heading gap.
- Height of a split down: inside a parent of set height (the body, an element with
h, an area of a split down that shares height), when a split down (a run of[row:]) is the only thing in that parent's flow, the rows share the parent's height in the ratio ofweight. A split down beside other things has its content's height, like a split across. A split down in a parent whose height is not set is reported assplit-unresolved: the editing view draws its content flowing down as it is, andkoma checkandkoma exportdo not pass. - Flow gap (the theme's
--koma-flow-gap,1emby default): in the body frame, inside elements, in columns and in the flow directly on a page, when either of two things following each other down is an element (a box, callout, figure, table, a run of[col:]or[row:], a[group:]) or a Markdown table, the gap between them is this one value. It is never less than an element's inner padding (--koma-style-pad-block). Withgapwritten in thestyleof an element without a split, the gap of its direct flow is that value, and the inner padding is not a minimum (Cards without positions). Gaps between paragraphs, headings and lists stay the theme's text spacing. - Freely placed elements (
xory) do not join a split. A[col:]or[row:]withxoryis a free element, not an area. Even inside a split, it is placed in the parent's content rectangle (Elements). - Examples:
[col weight=2: left]/[col: right]is two columns, 2:1.[col:/[row: top]/[row: bottom]/]/[col: right]is two columns, the left one split into top and bottom (a[col:whose content runs over several lines closes with a]at the end). - Figures side by side: when each
[col:]of a run across holds exactly one[figure:], their picture areas line up. The area's height is that of the tallest picture with each figure fitted to its column's width, but no more than what the column leaves above its longest caption. Pictures sit at the bottom of the area keeping their aspect ratio, and captions start below it, so their first lines line up across. A caption (the content of[figure …:) may have several lines and inline notation; its alignment follows the box'stext-align. If any figure hasalign-contentwritten, that run is not aligned (it is placed as Elements says). PDF, HTML and PowerPoint are as drawn. There is no way to line up figures in a[row:]without wrapping each in a[col:].
A column is one flex
A column is one vertical flex that lays out what it holds from the top, the same whatever it holds.
How to write
What a column holds goes from the top in the order written. To make something as tall as its column, write it in its style: [box .tint style="flex: 1": …].
Details
- A column's height is Columns and rows's: in a parent with a height of its own, columns fill what is left; elsewhere they are as tall as the tallest column's content. What a column holds never changes this.
- A column is a CSS vertical flex. It stretches and shrinks nothing itself;
flex: 1fills the rest of the column, andheight: 100%works as in CSS, where the column's height is set. - A figure or a paragraph of pictures with no size fits the rest of a column with a set height (Elements), and otherwise keeps its own size, up to the column's width. Figures side by side are not lined up by a rule of their own.
Cards without positions
Cards placed without positions line up their gaps and heights through gap in the parent's style and the rule that splits fill what is left of a parent of set height.
How to write
Write gap in the style of the element that holds the cards ([main style="gap: 24px": …]). To place them across, use [col:].
Example
Output of koma export
Source
[title: Three rooms]
[main style="gap: 24px":
[col:
[box .card style="flex: 1":
Reading room
]
]
[col:
[box .card style="flex: 1":
Swap table
]
]
[col:
[box .card style="flex: 1":
Lounge
]
]
]Details
- Per-element flow gap:
gapin thestyleof an element without a split is the gap between the elements of its direct flow (in place of the theme's flow gap,--koma-flow-gap). When written, the element's inner padding is not a minimum (morepaddingon a card does not change the gap between cards). In an element with a split, it is the gap between areas (Columns and rows). PowerPoint and HTML keep the gap as drawn. - A split across in a parent of set height fills what is left: besides an element with
h, in an area of a split down that shares height and in the flow directly on a page (when the split across is that flow's only item), the split across fills what is left of the parent's height. Columns side by side take that height, and a column's only box with a surface stretches to the column's height (Columns and rows). - Koma has no run that wraps to fit the number of children.
- A split across with a column holding only one picture does not fill what is left in a row's area sharing height or in the flow directly on a page; the picture is drawn at the column's width (Columns and rows). A picture keeps its aspect ratio, so it is not stretched. Inside an element with
h, it does fill what is left.
The core tree and the syntax tree
The core tree
The core tree is the internal tree made by reading a .koma file; it is not a published text language.
How to write
Nothing is written by hand. There is no text form for reading or writing the core tree; the .koma file is the only original.
Details
- What it must do (requirements): keep the source (writing back from the GUI touches only the written range, Writing back from the app); keep meaning (role, content, reading order, footnotes, links) through placement; know where in the source each element came from and whether it can be edited. Drawing and output are made from this tree (the layer boundaries are the design of the layers).
- Unknown names and attributes are kept, not removed, and reported.
- Its current form (not a requirement; names, the number of kinds and the mapping to Pandoc may change): the parser scans a
.komafile into the Koma AST (a unist-compliant syntax tree), and from it a read-only display model (Document) is computed. A box is the general nodekoma; pages and notes are told apart byrole. Attribute names (such aslayout) are internal names, separate from the text written (the terms are indocs/glossary.md). The text nodes (p,h,ul,table,fnand so on) are the vocabulary of the current drawing. A function that writes the tree as[head attributes… children…]is kept only for tests and debugging, and its output is never read back.
The implementation is src/core/lang/ast/tree.ts (types) and src/core/lang/parser.ts (parseKoma(source) builds it; parseWithDiagnostics(source) also returns diagnostics). Node kinds, their fields and positions are covered by conformance (see Conformance) and, with the kinds of sourceLine, change only under the language's compatibility policy. data and its content (such as the scanner's records of lines, the Internal column of Syntax tree nodes's table) and the internals of the implementation that builds the tree are not. Each change to the promised shape also takes the next AST version (The AST version).
Syntax tree nodes
Each node of the Koma AST holds set fields for its kind (type).
How to write
Nothing is written by hand: parseKoma(source) builds the tree. A tool that reads the tree reads the fields in the table below and the kinds of line.
Details
- Every node has a
typeand its source rangeposition. A node that holds source lines keeps, indata, the scanner's record of each line (so the semantic reading can rebuild lines from the tree alone).datais internal and not promised: its values and shape may change between versions, so tools that read the tree read the Fields and the line kinds, neverdata.
type | Parent | Fields | Internal (not promised) | Meaning |
|---|---|---|---|---|
root | yes | children | data.openFence (the mark of a fence left open at the end, else null) | The whole document. Its direct children are the document settings and blank lines and comments before the first page |
page | yes | children, body (from after the delimiter and complete settings to the next page), boundary (the +++ line; absent on the implicit first page) | none | One page. Pages divide the source without gaps (the line break just before the next page belongs to this page) |
settings | yes | scope (document or page), body (inside the delimiters), children (sourceLine) | none | A closed YAML settings block. Values are interpreted separately |
notes | yes | body, closed, children (sourceLine) | none | Notes ("""). Elements and delimiters inside are isolated as content. Unspoken [[ blocks are part of the body (Elements) |
memo | yes | attributes (tagToken, each an attribute assignment of the opening ::: line), body, closed, children (sourceLine) | none | A memo (::: key=value … :::) on a page. Its text is isolated as content and never output (Memos) |
element | yes | tagName (the name, else null), children, opening and closing (a multi-line element's opening and closing lines; closing has the bracket's position bracket and whether it is on the body's last line, inline) | data.line and data.close (the scanner's records of the opening and closing lines) | A bracketed element |
elementTag | yes | children (tagToken) | none | An element's tag |
tagToken | no (value) | kind (selector, attributeAssignment, bareWord; selector is a tag name with any joined shorthands or a standalone ID or class shorthand; bareWord is a bare word outside the tag's grammar, kept as written, Elements), value (the word as written), and for attribute assignments separator (the position of =) and valueKind (the kind of the value as written), and for a list items (Value kinds in the tree) | none | A word of the tag. Duplicates and invalid values are kept. What a value means (units, a colour or a reference) is not in it |
sourceLine | no (value) | kind (the kind of line, in the table below), value, and when needed finding, fence (code, math), settingValueAt | data.line (the scanner's record of the line) | One source line |
raw | no (value) | value | none | The source of an element's body |
A sourceLine's kind is one of these. Element lines (a one-line element, an opening line, a closing line) never become a sourceLine; they are the element and its opening and closing.
kind | Meaning |
|---|---|
setting | A key: value line inside settings delimiters. settingValueAt is where its value starts (Page settings, Settings YAML) |
setting-other | A line inside settings delimiters that the subset does not read (nesting, a list and so on) |
front | A delimiter around settings: === for the document's, --- for a page's (Document settings, Page settings) |
blank | A blank line before a page's content (at the start of the file, after a page delimiter, inside settings) |
page | A page delimiter +++ (Page boundaries) |
attribute-line | A line of an element tag that continues after its opening line (Tag and content) |
comment | A comment line (Page boundaries) |
blocked | A line isolated with its block and reported: settings out of place or unclosed, an unused ::: block and so on (Document settings, Page settings) |
notes | A notes delimiter """ and the lines inside |
memo | A memo's ::: lines and the lines inside (Memos) |
fenced | A line inside a code fence or $$, and the fence lines. fence is code or math (Code and math are isolated) |
literal | A line of the body of a math, code or diagram element, kept as written |
text | A line of text. A bracket line that stays text says why in finding (When brackets are an element) |
- Ranges:
position.startandposition.endare half-open. Lines and columns count from 1,offsetfrom 0, in UTF-16 code units. CRLF is two units and one line; a lone CR is one line too. A leading byte order mark in the input is included in positions. - Never dropped: the written order and duplicates of tag names and attributes; quoting; unknown settings; bare text; comments; unclosed YAML, fences and elements. Unreadable parts keep their source and diagnostics.
- Unquoted text directly on a page stays as the page's
sourceLinechildren. The semantic reading reads each run as a[box:]without position (Placement); the tree has no implicit box node, because the syntax tree shows only what is written, and where one box ends is a semantic decision made from the kinds of lines. In the semantic tree (Node) that box is a container withgenerated: 'unplaced-text'and no brackets in the source. - The tree and diagnostics round-trip through JSON.
unist
The Koma AST follows unist.
How to write
Nothing is written by hand; unist tools (such as unist-util-visit) walk the tree as it is.
Details
- Each node type is built on
@types/unist'sNode,ParentandLiteral, and the type checker ensures it.PointandPositionare unist's, andoffsetis always present. As unist intends,dataholds only line information for rebuilding the tree, never canonical values of the language (internal and not promised, Syntax tree nodes).
- unist tools (
unist-util-visit,unist-builder,unist-util-remove-position) can walk it, build it and strip positions. Positions are computed by an index of its own (positionIndex), which answers asvfile-locationdoes.
Value kinds in the tree
An attribute assignment in the syntax tree (a tagToken of kind attributeAssignment) carries the kind of its value as written, and the items of a list.
Details
valueKind:word,number,percentage,dimension,hash,quotedString,valueListorinvalid(an unquoted value of no kind, or a string or list that cannot be read).valueis the word as written.- A list has
items(each withvalueKind,valueandposition, and a list item has its ownitems; an expression item'svalueKindisexpression). - What an attribute means (whether it takes a unit, a colour or a reference) is not in it: the semantic stage (the diagnostics in language-semantics.md) decides that.
The AST version
The promised shape of the Koma AST has a version, the AST version, and any change to that shape takes the next one.
How to write
Nothing is written by hand. koma parse --json names the version as astVersion and the library exports it as AST_VERSION; a tool checks the number before it reads the tree.
Details
- The promised shape is what Syntax tree nodes to Value kinds in the tree list: the node kinds, their fields, the kinds of
sourceLine, of values and of list items, and the positions. A change to any of them, even an added field or kind, takes the next whole number.data, the readable output and the parser's internals change without it. - Version
nhas its JSON Schema athttps://komalang.org/schemas/koma-parse-v<n>.schema.json, with every node closed, so that a tool can tell a version it does not know from a broken tree. A published version's schema never changes; it stays in the package and on the site beside later ones. - The AST version is separate from the language version: a release that changes what notation means may keep the tree's shape, and the other way round.
- The current version is 1.
HTML and reading order
HTML elements and reading order
InformativeThe rules for HTML elements and reading order aim, step by step rather than by rebuilding, at output that can be explained as how slides ought to be built in HTML.
How to write
You never write HTML. The document's title becomes h1, a page's title h2 and # in the body h3, and the DOM follows the order of the source (or an explicit order of meaning).
Details
- The language's core holds syntax, attributes, content, parent and child, and the mapping to the source; it holds no HTML elements. A shared resolution of meaning decides roles and ownership — the document's title, a page's title, subtitle, label, footer and so on — from explicit roles, slot names and templates, never from coordinates or id strings. HTML drawing maps the decided roles to elements.
- The outer shell of every source element is always
div.koma. id, class, data-role, the source range, placement, background, border and padding are on the shell. The same identifiers and.komaare never repeated inside. - The document's title is the document's
h1; a page's simple title text is anh2inside the shell. One phrasing block (with emphasis, links, code, line breaks and inline math) becomes the heading. A title holding several paragraphs, a list, a table or child elements keeps all its content as flow in source order, and gives the warningcomplex-title-content. No first paragraph is extracted, no heading hidden, saving is not refused, and nothing is fixed automatically. - Simple text of label, subtitle and the like is an inner
p; body and box are natural flow elements. Separate elements are not wrapped inhgroup. - Reading order and meaning are kept apart from placement. The DOM follows the source order (or an explicit order of meaning). Nesting depth does not become heading level. Placement and the theme decide position and look, and never switch the elements of meaning.
- HTML export uses the same HTML rules as drawing. Containers such as
hgroupnever break each element's id, its mapping to the source (data-from,data-to), or the basis of coordinates. Tests check the DOM structure, reading order, visual regressions and the mapping to the source. - Heading levels: the document's title is
h1, a page's titleh2. Headings in the body, in plain text or inside elements, areh3for#,h4for##, and one level deeper for each further mark, down toh6(Text inside elements). Body headings never makeh1orh2. Levels do not change with whether there is a[title:]or with nesting depth. A#in a figure caption is anh3insidefigcaption. The levels read aloud in HTML and PDF are these; PPTX copies the drawn look (bold at the size of the body text). h3toh6are bold at the effective size of the text around them, with a small space below, adjustable with--koma-local-heading-gapand not added to paragraph spacing. Figure titles follow the effective size of the caption text.- Vertical spacing in slide bodies and boxes follows three rules, all closed up together when fitting. (1) A local heading keeps its small space below (
--koma-local-heading-gap) and has 1.35em above it after a paragraph, list or display block. (2) Paragraphs have no space above, so a paragraph after a heading keeps the heading's space; consecutive paragraphs are set apart by the space between list items (--koma-item-gap). (3) Every other block has the same space above and below, the larger where two meet: a list or definition list the space between items, a display block (display math, code, table, quotation, diagram, figure, grid) the block gap, from the theme's--koma-block-gaptowards--koma-block-gap-min(0.35em). Only one side of each pair carries the space, so nothing adds up in a column. The first block has no space above it. Element flows keep their flow gap (Columns and rows). Captions, table notes, footnotes, list items and the parts of a grid or figure keep fixed spacing. Documents and posters keep their kind's fixed spacing, never closed up (Values per kind of page): a paragraph or a list under a heading at the heading's gap, items at the item gap, paragraphs and a paragraph and a list at the paragraph gap, a display block at the block gap, and a heading 1.35em after a block, which gives up its own margin. The editor draws the same spacing.
CSS motion and stepped elements
An authored CSS animation or transition on a stepped element plays in presentation and HTML. PowerPoint retains the entrance effect and reports omission of the CSS motion with step-css-motion-not-exported.
How to write
Use the existing CSS syntax. For example, apply box.reveal { animation: slide-in 300ms; } to [box.reveal step=1: …].
Details
- The note applies to an element with a valid
stepwhen authored theme or document CSS sets nonzerotransition-durationor ananimation-nameother thannone. The built-in entrance effect itself (Entrance effects) is outside that check. - Presentation, HTML, and embeds play the authored CSS motion, including when it coincides with an entrance effect. See the document CSS rules.
- Give one informational
step-css-motion-not-exportedfinding per affected element in Problems andkoma check. Advise usingstep-effectto obtain a PowerPoint entrance. There is no automatic fix for mapping arbitrary CSS motion to the three effects. A note alone does not failkoma check. - Suppress
animation-staticon the same element. PDF and PNG still use their normal static output.
Diagnostics
Diagnostics never rewrite the source. For most errors the source is isolated and the rest is drawn; whether export works is given by the Export column (✓ exports, ✗ is refused by koma export and the app's export). Severity follows what happens to what was written. An error refuses export or leaves written content out of the output. A warning means the output is made but may differ from the author's intent. A note only informs. koma lint and koma check exit with 0 when there are only notes, and 1 when there is a warning or an error.
Every diagnostic says how to fix it as well as what happened: what to write or change on which part of which element, with the attribute's name and the value's form when known (x=40%, step=2). The app says it in English and Japanese; the command line gives a short English fix at the end of each text line and as advice in each --json diagnostic. Diagnostics marked "one fix" have that fix written by koma check --write, and their advice says so. A fix also marked "may change the meaning" can change what is drawn, the structure or what is read, even where the page looks the same: koma check --write leaves it, and it is made when chosen one by one in the GUI or with koma check --write --unsafe, which the advice names.
| Code | Severity | Export | Meaning | Fix |
|---|---|---|---|---|
missing-colon | Error | ✓ | An element-shaped line (When brackets are an element (a)–(c)) has no :. It is not an element, goes in no bare-text box, and is not drawn. A multi-line form is held back with its content and children (Tag and content, Placement) | Write : at the end of the tag (after the name, when a known tag name is followed by a word); one fix, may change the meaning. To keep it as text, start the line with \ |
bare-word | Warning | ✓ | A word without = in a tag. Its source is kept, but it does nothing (Elements) | Write it as key=value or remove it (rtl too; no fix offered) |
group-attribute | Warning | ✓ | An attribute other than #id and classes in a group's tag. Kept, but has no effect (Groups) | Remove it, or write it on an element inside |
empty-group | Warning | ✓ | A group with nothing inside. Kept, and draws nothing (Groups) | Remove it, or put elements in it |
reserved-setting | Warning | ✓ | The setting key koma is reserved for the future and sets nothing (Document settings) | Remove the line |
unsupported-declaration | Error | ✓ | A ::: name at the root is an unsupported declaration; its source is kept up to the matching ::: and not applied (Document settings) | Write CSS in the document settings' css: |
citation-unsupported | Warning | ✓ | Citations [@key] are not supported and are shown as written (Text inside elements) | Use a footnote [^label] |
empty-span | Warning | ✓ | []{.class} or [ ]{.class}: brackets with no text, or only spaces, are not a span and are shown as written (Text inside elements) | Write text inside, as [answer]{.blank} or [\_\_\_\_]{.blank} for an answer blank |
empty-definition | Warning | ✓ | A line with only a colon is drawn as text with no description (Definition lists) | Remove the line (one fix, may change the meaning) |
unknown-class | Warning | ✓ | The class in [text]{.class} is written in neither the theme's CSS nor the document's css:. The text is drawn as is (Text inside elements) | Use .chip, or write the class in the document's css: |
theme-slot-no-geometry | Warning | ✓ | A sample in a theme document that names a frame has no valid position and size, so it defines no frame (Frames from sample elements) | Write x, y, w, h in % or px |
theme-slot-duplicate | Warning | ✓ | A second sample in a theme document defines the same frame; the first is used (Frames from sample elements) | Remove the second, or rename the frame |
theme-layouts-unused | Note | ✓ | The document’s theme folder (for a theme document, its own folder) holds a layouts/ folder; Koma does not read it (The source of a theme) | Nothing has to change; define layouts in theme.koma |
type-not-set | Note | ✓ | The size is paper and there is no type; the document is drawn as slides (Kinds of page) | Write type: article for a document, type: poster for a poster, or type: slide to keep slides on paper |
type-unused-feature | Note | ✓ | A document or a poster holds something only slides use (speaker notes, step, skip, duration, total-duration); the source keeps it and it is not used (Kinds of page) | Nothing has to change |
delimiter-text-reserved | Warning | ✓ | Text after ===, --- or +++. It is a reserved area and means nothing (Page boundaries) | Remove the text after the delimiter |
unclosed-settings | Error | ✗ | === or --- settings do not close; isolated up to the next +++. For a page's ---, adds "a page break is +++" (Page settings) | Add the closing line |
bad-yaml | Error | ✗ | The settings YAML cannot be read; none of the block is applied (Settings YAML). Suggests quoting a value with :, and for a page's --- adds "a page break is +++" (Page settings) | One key: value per line, indented with spaces |
duplicate-setting | Error | ✗ | The same setting key twice | Remove one |
unknown-setting | Warning | ✓ | An unknown setting key; its source is kept | Fix the spelling or remove it |
bad-setting-line | Warning | ✓ | A line that cannot stand in a settings block | Write it as key: value |
setting-out-of-scope | Warning | ✓ | A document-only setting (title, size) on a page. On the first page, adds that document settings go in === (Page settings) | Move it to the document settings |
setting-not-applied | Warning | ✓ | A written setting takes no effect (such as logo-alt with no image in effect) | Write the setting it pairs with, or remove it |
misplaced-settings | Error | ✓ | A --- in column 0 after a page's content. That one line is not shown and later lines are not isolated; adds "a page break is +++". A second settings block in the preamble is isolated (Page settings) | *** for a horizontal rule, +++ for a page break (two fixes) |
tab-indent | Warning | ✓ | A line inside an element indented with a tab. Read with the tab as two spaces it would be an element at that depth, but as written it is drawn as text (The standard form) | Turn the tab into two spaces (one fix, may change the meaning) |
root-outside-math | Warning | ✓ | √ before a digit, letter or bracket outside math. Only the sign is drawn, without the bar over the radicand (Text inside elements) | Write $\sqrt{…}$ (one fix, may change the meaning) |
dashes-not-rule | Warning | ✓ | A line of only --- inside an element or bare text. It is not a rule and is shown as written (Text inside elements) | For a horizontal rule write *** (one fix, may change the meaning) |
misplaced-scoped-block | Error | ✗ | ::: is a reserved mark with no use. In the document's preamble or on a page, it is isolated up to the matching ::: (Document settings) | Write CSS in the document settings' css:, and select pages with the page class and page.class |
css-file-unavailable | Error | ✗ | The CSS file css: points to is not in the document's folder, cannot be read, is not UTF-8, or is too large. Only that file is left out (Document settings) | Fix the path, or put the file in the document's folder |
unclosed-notes | Error | ✗ | Notes """ do not close; isolated up to the next page break | Add the closing """ |
unknown-note-attribute | Warning | ✓ | An unrecognised attribute on the notes' opening line, including the retired speak (Elements) | Remove the attribute |
unclosed-memo | Error | ✗ | A memo's ::: does not close; isolated up to the next page break (Memos) | Add the closing ::: |
unknown-memo-attribute | Warning | ✓ | An unrecognised attribute on a memo's opening line (Memos) | Remove the attribute |
notes-time | Note | ✓ | The page has no duration: and the first line of its notes (blank and ; lines aside) has the form 0:59 + 0:04 = 1:03. Notes are not read as time (Planned speaking time) | Move it to the page's duration: (one fix, may change the meaning: the value right of =, else the sum; notes with nothing else are removed with it) |
flow-over-slots | Warning | ✓ | The page's area where elements written directly on the page without x and y flow (inside the page's padding) overlaps the rectangle of a frame written on the page (title, main and so on). Drawn as is (Placement) | To put it in the body frame, write it inside [main:] |
unknown-tag | Error | ✓ | A tag neither built in nor in the theme. That element is not drawn (When brackets are an element) | Fix the tag name or define it in the theme. To keep it as text, start the line with \ (\[Note: …]) |
unclosed-element | Error | ✓ | An element has no closing ]. Its tag line stays in the source but is not drawn, and directly on a page the bare text up to the end of the page makes no box (Placement) | Add a ] at the same depth |
stray-close-line | Note | ✓ | A line of only ] with no matching opening | Remove it, or write \] |
deep-heading | Note | ✓ | A heading written with ## to ######. It is read as a heading one level deeper per mark, and looks the same as # (Text inside elements, HTML elements and reading order) | Write it with one # (one fix, may change the meaning) |
name-without-colon | Note | ✓ | A bracketed line with only a name, and a known one (a built-in tag name, a theme's tag or frame name: [title], [box]). Without :, it is drawn as text. Unknown names ([AM1], [NOTE]) are not reported (When brackets are an element) | For an element, write : ([title:]); to keep it as text, \[ also works |
unclosed-fence | Warning | ✓ | A code or math fence does not close | Add the closing mark |
duplicate-slot | Warning | ✓ | The same slot twice on a page. Both are drawn, overlapping when they have no position (Kinds of name) | Write positions, or keep one |
slot-not-in-layout | Warning | ✓ | A slot the layout does not have | Choose a layout with that frame, or use another element |
unknown-layout | Warning | ✓ | An unknown layout name; drawn with content's placement (Page layouts) | Use cover, section, content, blank, or a layout the theme defines |
custom-layout-unresolved | Warning | ✓ | A theme layout cannot be resolved | Write the layout's frame elements directly on the page, not inside other elements or between bare text |
complex-title-content | Warning | ✓ | title holds paragraphs, a list, a table or child elements (HTML elements and reading order) | Make the title one paragraph, and move lists, tables and elements to [main:] |
duplicate-attribute | Warning | ✓ | The same attribute twice; the first takes effect (Elements) | Keep one |
presentation-attribute | Warning | ✓ | A look written as an attribute (gap=, opacity=, color=, fill=, stroke= and the like). Looks go in classes or style, so it has no effect; the source is kept (Elements) | Move it to style (one fix when style can read the value; may change the meaning) |
unknown-attribute | Warning | ✓ | An attribute with no prefix that the language does not have ([box foo=1: …]). It has no effect; the source is kept as written. A look's name is presentation-attribute, and attributes starting with data- are not reported (Elements) | Check the spelling. For your own attribute, add data- (data-foo=1) |
line-label-content | Warning | ✓ | A line's body holds a block other than one paragraph (a list, a table, a heading, a second paragraph, or a child element) | Keep the line label as one paragraph of text, math, or line breaks, and move other blocks into a box |
label-at-unused | Note | ✓ | label-at or label-side on a line that has no label text; it has no effect and the source is kept | Write label text in the line's body, or remove label-at / label-side (one fix) |
line-no-height | Warning | ✓ | h on a line. A line runs from end to end and has no height, so it has no effect (Elements) | Remove h (one fix); move the ends with x1, y1, x2, y2 |
invalid-unquoted-scalar | Warning | ✓ | An unquoted value that is none of a word, a number, a percentage, a dimension or a value starting with # (src=assets/a.svg, alt=日本語, f=drive(t)). The source is kept and it reads as a string (The kinds of a value) | Put the value in double quotes (one fix; koma format --write writes it too) |
image-body | Error | ✓ | Text written in the body of an image ([image:]). An image has no body, so the source is kept and not drawn (Figures and images) | For a caption, wrap it in a figure and write the text after the image ([figure: … ]; one fix, which may change the meaning) |
figure-attribute-ignored | Warning | ✓ | src, alt or crop on the tag of a figure that holds an [image:], or an #id, class, place, size, style, step and the like on the [image:] inside a figure. A figure takes its picture from the [image:] and its place and look from the figure, so these have no effect; the source is kept (Figures and images) | Remove it, or move it where it counts (the picture to the [image:], placing to the figure) |
figure-child-unsupported | Warning | ✓ | An element in a figure that is not one a figure shows (an image, chart, diagram, math or code). The source is kept and it is drawn in the same row as what is shown (Figures and images) | Move it out of the figure. A table has its own caption, so it is not wrapped in a figure |
legacy-page-grid | Warning | ✓ | The theme's or the document's CSS writes a grid on page (display, grid-template-rows and the like). The layout's grid is the page body's now, so those declarations are left out and the rest of the rule applies (Layout grids) | Write the grid on page-body; koma format --write rewrites it so the frames stay where they were |
part-selector-unmatched | Warning | ✓ | The theme's or the document's CSS names an HTML name Markdown draws (ul, li, strong and the like) in a form that selects nothing (ul { … }, box > li { … }). That rule alone is not applied (Markdown parts in elements) | Write a part inside an element (box li { … }), a part alone (li { … }), or parts joined by + (p + ul { … }). Style text with text classes (Text inside elements) |
role-contrast | Note | ✓ | The automatic text colour chosen on a role colour does not reach a 4.5:1 contrast ratio. | Adjust the role colour or specify a text colour that reaches at least 4.5:1. |
radius-on-ellipse | Warning | ✓ | radius on an ellipse shape. An ellipse has no corners, so it has no effect; the source is kept (Shapes) | Remove radius (one fix) |
shape-border-radius | Warning | ✓ | border-radius in a shape's style. A shape's corners are its radius alone, so it has no effect (Shapes) | On a rectangle, move it to radius (one fix; it may change the meaning); on an ellipse, remove it (one fix) |
unknown-target | Warning | ✓ | The #id in a line's from or to is not on the same page (missing, or on another page). The line is not drawn; the source is kept | Write the #id of an element on the same page, or give the end as coordinates |
line-end-overridden | Warning | ✓ | from and x1, y1 (or to and x2, y2) on the same end of a line. The connected end wins and the coordinates have no effect | Remove the coordinates |
line-points-overridden | Warning | ✓ | A line with points also has x1, y1, x2, y2, from, to (with sides and positions) or route. points wins and the rest have no effect | Remove all but points |
missing-unit | Warning | ✓ | A length without a unit | Write % or px (x=40% and the like) |
bad-unit | Warning | ✓ | A unit that is not accepted | Use % or px (w=40% and the like) |
bad-value | Warning | ✓ | A value of the wrong type or range (step, style, marker empty or with a line break, escapes in quotes and the like). A list that cannot be read (a trailing comma, an empty item, a parenthesis left open), a list with another number of items than its attribute takes (crop 4, domain and range 2, points two or more lists of two numbers), an expression in a list whose attribute takes none, or an unquoted value starting with { (Lists of values). A curve's f cannot be read or uses an unknown name (named), range is not two different values, or a functions: definition cannot be read or is recursive (Curves from a formula) | Fix the value. The command line gives each attribute's form (step=2, rotate=15, dir=rtl, crop=(0, 0, 10%, 0), paginate: true and so on) |
text-marker | Warning | ✓ | Text in a callout's marker= (not one emoji or symbol, as marker=Note). Kept, and 💡 is drawn (Callouts) | Write one emoji or symbol, or none. Write a text heading as a definition list (a term on one line, its description on the next starting with : ; Definition lists) |
zero-size | Warning | ✓ | w=0 or h=0 | Write a size or remove the attribute |
bad-size | Warning | ✓ | The document's size cannot be read | Write 16:9, 4:3, a paper size such as A4 landscape, or two lengths such as 1280 x 720 |
bad-weight | Error | ✗ | weight is not a positive number (Columns and rows) | Use a positive number (weight=2 and the like) |
split-unresolved | Error | ✗ | [row:] inside a parent without a decided height | Give the parent a height (h, or a frame with a height) |
step-effect-unused | Note | ✓ | The element shares its parent's step or neither it nor any descendant has a step. | Set the effect on the parent or use a separate step. |
step-css-motion-not-exported | Note | ✓ | Authored CSS motion on a stepped element is omitted from PowerPoint. | Use step-effect for the entrance effect in PowerPoint. |
unsupported-rotation | Warning | ✓ | rotate on an element that cannot rotate | Remove rotate, or rotate an element directly on the page without nested elements |
missing-logo-alt | Warning | ✓ | The logo image has no alternative text (The document's logo) | Write logo-alt (logo-alt: "" for decoration) |
duplicate-footnote | Warning | ✓ | The same footnote defined twice on a page (Footnotes) | Remove one |
duplicate-id | Warning | ✓ | The same #id twice | Rename one #id |
font-unavailable | Warning | ✓ | A face the document names is not on the computer; another face is drawn (Text faces) | Install the face, or use a face koma ships (sans, mono) |
chart-not-number | Warning | ✓ | A cell of a chart's value columns is not a number (1,234, 12%, 3 s); it is drawn as a missing point, the first such cell's row and column said | Write the number without separators or units |
chart-data-conflict | Warning | ✓ | A chart's data is written in more than one of its body's CSV, src and f; the source is kept and only the frame is drawn | Keep one |
chart-no-data | Warning | ✓ | A chart has no data, or a header row alone | Write a header row and rows of values |
csv-uneven | Warning | ✓ | Rows of a CSV/TSV have different numbers of columns; missing cells are left empty | Give every row as many items as the first |
animation-static | Warning | ✓ | Animation was left out of still output (PDF, PNG, PowerPoint) | Nothing to do (a notice). Export HTML or present to keep the motion |
Conformance
Conformance covers syntax and meaning, checked by a conformance suite. How a page is drawn is described, not tested pixel by pixel.
What conformance promises
Conformance promises syntax and meaning. Rendering is described in prose, and pixel-equal output is not promised.
- Syntax: the same source produces the same Koma AST with the same positions. The promised shape is the node kinds (
type) and fields in Syntax tree nodes's table, the kinds ofsourceLine(type), and the positions (position) of unist.data(the Internal column of Syntax tree nodes's table;data.openFence,data.lineanddata.closeare the scanner's records) and the internals of the implementation that builds the tree are not promised. - When the tree's shape is promised: a version promises the tree's shape and positions only when all three hold: the kinds of
sourceLineare listed in Syntax tree nodes, a test compares the spec's tables with the types insrc/core/lang/ast/tree.ts, anddataand the other internals are marked as outside the promise. A version where they do not all hold promises only meaning and diagnostics, and the tree's shape moves to the next version. All three hold now. That depends on the unit test that compares the tables with the types and with trees read from the bundled examples (Syntax tree nodes) staying green. - Diagnostics: the same source produces diagnostics with the same codes, severities and ranges (see the list of diagnostics in Semantics).
- Meaning: the same source produces the same placement and sizes (Placement, Who decides size, Columns and rows).
- The conformance suite: a set of
.komainputs, each with its expected syntax tree, diagnostics and placement in numbers, cut from the unit tests that name a spec ID and use no DOM, and filed by rule ID. - Rendering: how HTML, PDF and PowerPoint look (HTML elements and reading order and the official themes' looks) is informative prose, outside the conformance suite.
- Writers: tools that tidy or edit also keep the standard form (The standard form) and the source they did not change (Saving without change, Rewriting only what changed, Writing back from the app).
- Versions: how the language's version changes follows the compatibility policy below.
Writers
The standard form
The standard form is the set way of writing .koma that only explicit tidying writes.
How to write
Tidy with koma format --write, koma check --write, or the app's Tidy. Saving and reading never tidy. koma check reports source not in the standard form as not-formatted. For example, tidying turns [box.card x=10%: content] into three lines: [box .card x=10%:, content, ].
Details
- Tidying is one API (
formatKoma), run only on an explicit action. Existing documents are never rewritten in bulk. - Tags and structural lines: an element's tag ends with
:(Tag and content). A line without:is text or a held-back element shape, so tidying never adds:and leaves the line as written (that would change its meaning; the user adds it with themissing-colonfix). The words of a tag are separated by one space, attributes are reordered in the order of Order of attributes, the:is attached to the tag's last word, and one space comes before the content. Attribute values lose the quotes of a value of a kind, gain quotes on unquoted text of no kind, and lists are written(a, b)(The kinds of a value, Lists of values). Trailing spaces on bracketed structural lines are removed.===,---and+++are made three characters, while the reserved characters after them and the inside of YAML (including the value ofcss:) stay as written. Only bracketed structural lines are indented, two spaces per depth. - Multi-line elements: a multi-line opening that ends with
:keeps it, and one without it never gets it. A multi-line element's body is aligned, from the line after the opening, to the structural indentation of depth × two spaces, the same as its child elements. Attributes split over several lines are left alone.- A closing
]of a multi-line element at the end of a body line is moved to a closing line of its own, keeping the body's spaces and meaning. When the meaning cannot be kept, the line stays as it was. - Body text following a multi-line element's opening line moves to the next line, keeping the meaning and the body's spaces, with the structural spaces of its depth. When the meaning cannot be kept, the line stays as it was.
- A closing
- One-line elements: an element whose tag has no
key=valueattribute and whose content is a single run of ordinary text stays on one line ([title: …],[box.tint: a word],[callout: a word]; a tag with only an#idor classes counts as having no attributes). An element with content whose tag has even onekey=valueattribute is not kept on one line, even when its content is one line: the opening line ends with:, the content goes on the next line indented one level, and]stands on its own line at the original indentation (three lines:[table src="…":, the text,]). An empty one-line element puts]right after the:, with no space ([image src="…":],[title:]); reading accepts: ]with the same meaning. An empty element written over several lines, such as body, stays as it is. Content with Markdown structure such as emphasis, links, images or math is expanded into separate opening, content and closing lines. Only the structural indentation a line lacks is added; extra is never removed. A one-line element is written with the syntactic one space after the colon and the body exactly as read; spaces in the body are not collapsed. - Comments (Page boundaries): a
;without a following space gets one, making; comment. A;line with nothing after it, a line that already has a space (or tab), and a line of several;such as;;stay as written. Indentation, as in the body, only gets the missing structural spaces. Comments inside notes are not tidied. Keep note opener attributes, inline speech directions, and the whitespace around them (Elements) as written. - Blank lines: one blank line goes right before each page break and settings opening line that standard reading recognises. None is added at the start of the file, and none inside closing markers or protected areas.
- One blank line goes before and after a
+++page break. When the page's---settings follow the+++directly, the same applies:+++, a blank line, then the settings. One blank line also goes right after the closing===or---. Closed notes (Elements) get one blank line before the opening"""line and after the closing"""line, and closed memos (Memos) the same around their:::lines; none is added at the start or end inside notes, or at the start or end of the file, and unclosed notes keep their surroundings as written. No blank line is added where it would change how the body reads. Existing extra blank lines are not removed. No close or blank line is guessed into an unfinished or invalid YAML block or at the end. An unclosed---right after a+++is left as written.
- One blank line goes before and after a
- What is kept: every character other than safe opening boundaries, the body's structural indentation and the normalisation of the emphasis recognised by Text inside elements; root comments, unknown information, notes and blank lines; Markdown hard breaks; code, math and relative indentation apart from structural indentation and the line split of displayed math; line ends and the byte order mark. A candidate that would change the meaning, such as a new element arising from the body, is not applied. On a page with an unclosed element, structural lines are protected, and from the unclosed opening on, the source is not changed either, since matching with later closing brackets could change. Unclosed or misplaced YAML or CSS and notes stay isolated and reported; tidying never completes them, guesses, or turns them into body text.
- Tabs: elements are indented two spaces per depth. A line indented with a tab is not read as an element but drawn as text. A line that would be an element at that depth if the tab were read as two spaces is reported as
tab-indent(warning), with one fix that turns the tab into spaces. Tabs inside the body, fences,[code:],[math:],[diagram:], settings, CSS and notes are not reported. Tidying leaves the line as written. - Displayed math: written with the opening
$$and the closing$$each on its own line. A line holding only$$ formula $$(also as a one-line element's content or an opening line's content) becomes three lines:$$, the formula,$$. The formula's characters are unchanged, and all three lines take the original line's indentation (or, if it is short, the structural indentation of its depth, by the rule above). The document's line ends are used. Math already in three lines,$…$in text, an unclosed$$, and a line not read as math (starting$$ formulawith its close on a later line) stay as written. - Selections: tidying a selection first widens the lines it touches to the whole elements that hold them.
- Invariants: before and after tidying, the tree read (apart from source positions, the order of a tag's attributes and how the same value is spelled: quoted or not), the reports (apart from
invalid-unquoted-scalar, which is only about spelling) and the drawing are the same, and tidying again changes nothing. not-formattedinkoma checkis measured against this form.
Saving without change
A file read and saved without changes is byte for byte the same as the original.
How to write
Nothing is needed from the writer: the source, with its line ends, byte order mark, spaces and comments, stays as it is.
Rewriting only what changed
Koma rewrites only the range of characters a change is about.
How to write
Nothing is needed from the writer. The formatting of everything else (blank lines, indentation, how attributes are written) is unchanged.
Writing back from the app
App writeback changes only the source ranges touched by explicit operations. Preserve comments, whitespace, abbreviated forms and unknown attributes. Move geometry updates only the written axes. Refuse an insertion at the end of an unclosed code or math block and explain how to close it.
Versions and compatibility
Compatibility policy: during 0.x, a minor version (0.1 to 0.2) may change what notation means, and a patch version (0.1.0 to 0.1.1) never does. Each change comes with a one-off migration script and release notes, and older notation is not read for compatibility. When the notation is settled the version becomes 1.0.0, and meanings no longer change. The first release is 0.1.0; until then the development version number stays.