Specification · Chapter 2 / 7
Document structure
On this page
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.