Layout
Layout is the engine's job. The author states order and relationship;
compile decides measure, breaks and page boundaries, and render draws what
that decision produced.
Containers
| Container | Direction | Attributes |
|---|---|---|
<col> | Top to bottom | gap, keep, id, unit |
<row> | Left to right | gap, keep, id, unit |
<columns> | Column-by-column, then next page | count, gap, unit |
<div> | Grouping box | gap, keep, id |
<section> | Named grouping | labelled-by, gap |
<body> | The page's content | gap |
gap is a length (default mm) inserted between children. A col with
gap={4} spaces every child four millimetres apart.
<col gap={3}>
<h2 id="method">{label()} Method</h2>
<p>…</p>
<p>…</p>
</col>
section, div and bib accept the same stacking as col. They are not
visual boxes with backgrounds or borders; they exist to group and to carry
keep or an id.
Rows
A row divides its width among its children:
- a child with
widthtakes that length; - a child with
weighttakes a share of the space left after fixed widths; - a text child without either takes its intrinsic (unbroken) width;
- a child with neither width, weight nor intrinsic content shares the remaining space equally with other such children.
<row>
<p font-size={7} align="left">MNRAS 553, 1–8 (2026)</p>
<div weight={1} />
<p font-size={7} align="right">https://doi.org/…</p>
</row>
An empty <div weight={1} /> is how two ends of a row are pushed apart. A row
splits at block and line boundaries across pages; it is not forced onto one
page.
Columns
<columns count={2}> is the third layout mode. Its children fill the first
column, then the next, then the next page's first column.
<columns count={2} gap={5}>
<p>…</p>
<p>…</p>
<p>…</p>
</columns>
- The last page is filled, not balanced. If there is less content than columns, the first columns take it.
- The default gap is 4 mm, or
element.columns.gapin the project file, or the region's owngap. The region'sgapuses itsunit; a config gap is millimetres. - Break rules are counted per column: the fragment minimum and a table's split are measured in the column the content is in, not across the page.
- A float inside the region may span its own column or the whole page — see Figures and floats.
Nested <columns> is balanced into a sub-row of columns inside its parent, so
it is side-by-side rather than flattened. A nested region does not itself split
across pages.
Page parts and page functions
The page has four slots — header, content, notes, footer. A <header> or
<footer> in <head> is the document-wide default; a page-local one overrides
it.
These core functions are available in a page's header or footer, which are expanded while that page is laid out:
| Function | Returns |
|---|---|
pageNo() | The number of the page being laid out |
pageCount() | The total number of pages |
isEven(n) | Whether n is even (available anywhere) |
isOdd(n) | Whether n is odd (available anywhere) |
isPage(n) | Whether the page being laid out is page n |
label() | The number of the heading it is written inside |
pageNo(), pageCount() and isPage() are not available in the page body,
because the body is expanded before layout. Using one there is an error
(page-no-outside-page, page-count-outside-page).
pageCount() costs one extra pagination pass: the document is laid out once to
learn the total, then again with the answer. A document that never prints it
stays single-pass.
<footer>
<row>
<p font-size={8}>{pageNo()}</p>
<div weight={1} />
<p font-size={8}>of {pageCount()}</p>
</row>
</footer>
What splits, and where
| Item | Behaviour |
|---|---|
| A flowing page | Splits between lines; continues until the content ends |
| A box | Splits by default |
| A line | Never splits |
| An image | Never splits |
| A rule | Never splits |
A text block with keep | Does not split |
| A heading | Always keeps with the lines that follow |
| A table | Splits between rows, never inside a row or cell |
| A row | Splits at block and line boundaries |
| A fixed page | Never splits; overflow is clipped and reported |
pagination.fragment-min (default 2) requires at least that many lines on both
sides of a break. pagination.heading-min (default 2) additionally requires
that many lines of the following block to fit beside a heading, so a heading
cannot end a page alone.
{
"pagination": {
"fragment-min": 3,
"heading-min": 2,
"baseline": 12
}
}
pagination.baseline is a fixed step in points. Line boxes snap up to a whole
number of steps, so 12 puts every line box on a 12 pt grid.
keep is enforced for text blocks. On a container it is accepted but not yet
honoured by the paginator, so a break can still fall between an image and its
caption. See status.
Footnotes and the notes area
A footnote reserves space at the bottom of the page, above the footer. The content area shrinks by exactly what the notes need. A line carrying a marker moves to the next page when its note does not fit, so a note never separates from its marker. See Notes.
Forcing a break
End the current <page> and open another. There is no break element:
<page flow>
…
</page>
<page flow>
…
</page>
The new page inherits the document geometry, so a break does not repeat the
page box. If the content of a fixed page overflows, it is clipped and reported
(fixed-page-overflow); a flowing page simply makes another page.