[Specification](https://komalang.org/spec/) · Chapter 4 / 7

# 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

```koma
===
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$.
]
```

> Bold “one”, emphasised “Swapping”, highlighted “No booking needed”, H2O with a subscript 2, a rounded New tag, 10 struck through, and the formula pi r squared.

#### 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](#footnote)).

- **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__`.
  - `style` is written as on elements: CSS declarations in double quotes. The properties allowed are `font-family`, `font-size`, `font-style`, `font-weight`, `color` and `text-decoration-line`. Values are checked and ranked as for each declaration of [Elements](https://komalang.org/spec/elements/#element). Unsupported declarations and values are not applied, are reported as `bad-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 `#id` or another unsupported attribute keeps its source and is treated as text. An empty text is reported as `empty-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. `.chip` is a rounded ground with bold text (in the official themes). A class with no definition is reported as `unknown-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 in `1^{st}` and `H_{2}O`. A pair complete on one line is read; an unclosed pair, an escaped one, a pair inside code or math, and `file_name` keep 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's `mark` ([Inline classes](https://komalang.org/spec/styles/#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](#brace-first-attributes)).

- **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](https://komalang.org/spec/lexical/#isolation) 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](https://komalang.org/spec/structure/#page-break)): 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 as `citation-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 as `dashes-not-rule` (warning), with one fix to `***`. A `---` in column 0 is [Page settings](https://komalang.org/spec/structure/#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**2` makes `word` bold; `2*3*4` emphasises the middle `3`. 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 (as `2\*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.

- **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, `h3` in HTML. `h1` is only the document's title and `h2` only the page's title (the `title` element). The level does not change with whether the page has a title, or with nesting ([HTML elements and reading order](https://komalang.org/spec/semantics/#html-elements)).
  - `##` to `######` are read as headings too (so pasted Markdown is not broken). In HTML each extra mark is one level deeper from `#`'s `h3`, down to `h6`; they look the same as `#`. They are reported as `deep-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 with `koma check --write --unsafe`. `koma check --write`, saving and tidying never change the marks.
  - `h3` to `h6` are 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](https://komalang.org/spec/semantics/#html-elements).

- **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 $10` is 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](https://komalang.org/spec/conformance/#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](https://komalang.org/spec/structure/#page-break)). 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

```koma
[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.
]
```

> Bold terms Swap table and Reading room on the left, each explanation aligned to the right of its term.

#### Details

- In HTML, `dl`, `dt` and `dd`.
- 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-terms` on 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

```koma
[title: The busiest hour]
[main:
  On weekdays, 7 pm is the busiest hour[^1].

  [^1]: Central Library survey (fictional).
]
```

> A small superscript [1] after the sentence, and the footnote “[1] Central Library survey (fictional).” at the bottom of the page.

#### 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]: text` from 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](https://komalang.org/spec/styles/#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](https://komalang.org/spec/semantics/#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 as `duplicate-footnote` (warning), and both are kept.

- Notes (`"""` blocks, [Elements](https://komalang.org/spec/elements/#element)) 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](#inline-markup)). 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.
