Skip to main content

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​

ContainerDirectionAttributes
<col>Top to bottomgap, keep, id, unit
<row>Left to rightgap, keep, id, unit
<columns>Column-by-column, then next pagecount, gap, unit
<div>Grouping boxgap, keep, id
<section>Named groupinglabelled-by, gap
<body>The page's contentgap

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 width takes that length;
  • a child with weight takes 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.gap in the project file, or the region's own gap. The region's gap uses its unit; 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:

FunctionReturns
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​

ItemBehaviour
A flowing pageSplits between lines; continues until the content ends
A boxSplits by default
A lineNever splits
An imageNever splits
A ruleNever splits
A text block with keepDoes not split
A headingAlways keeps with the lines that follow
A tableSplits between rows, never inside a row or cell
A rowSplits at block and line boundaries
A fixed pageNever 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.

Current limit

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.