In short
Two facing pages of a history textbook made as one: a coloured band crosses the middle of the book, six picture cards hang from it, and the template draws one card and one line, whatever the number of dates.
What you'll build
Pages 48 and 49 of a lower-secondary history book: The paper road, a thousand years of papermaking from Cai Lun's workshop to Keller's grindstone. The left page opens with the title and two paragraphs, the right page with a box on how a sheet was made by hand. Across the middle runs the timeline: an indigo band for Asia, a terracotta band for Europe that starts on the left page and crosses the spine. Under it, six cards with a picture each, hung from the band by a ring and a drop. The template draws one Asian card, one European card and one connector per band: a grid lays a card for every date the Markdown gives, and the connector finds every card the grid laid. Every word is in the Markdown, in Spanish, English and Japanese.
This recipe answers
- How do I lay out a timeline across a double page, with a band over the spine and cards on both pages?
- How do I let a row of boxes share its width, so the one with the longest text gets wider?
The short answer
const pageTemplates = [{
id: 'timeline',
spread: true, // two facing pages laid as one sheet; it opens on a verso
gutter: mm(10), // the band round the spine that frames keep off
grid: { columns: 2, rows: ROWS, columnGap: mm(2 * PAGE.inner), rowGap: mm(ROW_GAP) },
frames: [
{ name: 'title', takes: 'h1' },
{ name: 'lead', flow: true, fit: { minScale: 0.8 } },
{ name: 'box', style: 'box', grid: { col: 2, row: 1, rows: 4 }, height: 'fill',
padding: { right: mm(66) }, fit: { minScale: 0.85 } },
{ name: 'box-picture', layer: 2, width: mm(56), placement: at('#box', 'top-right', -5, 10) },
{ name: 'band-1', style: 'band-asia', grid: { col: 1, row: 5 }, height: mm(BAND) },
{ name: 'band-2', style: 'band-europe', crossGutter: true, width: 'fill', height: mm(BAND),
padding: { left: mm(2 * PAGE.inner + 4) }, // the colour crosses the fold, the words do not
placement: at('#band-1', 'right-of') },
card('asia', 'card-asia'), card('europe', 'card-europe'),
{ name: 'colophon', style: 'colophon', optional: true, width: mm(170),
placement: at('page', 'bottom-right', -PAGE.outer, -7) },
],
groups: [
{ name: 'opening', kind: 'stack', grid: { col: 1, row: 1, rows: 4 }, gap: mm(4),
frames: ['title', 'lead'] },
// A row of cards under each band, as many as the Markdown has: a longer text makes its
// row taller, and the other cards of the row stretch to the same height.
row('asia', 1), row('europe', 2),
],
decoration: { elements: [ground(), ticks('band-1', 'asia'), ticks('band-2', 'europe')] },
}];
One sheet for two pages, a band across the spine, two rows of cards
Ingredients
- Features
- Spread templatesGrids that repeat a frame setConnectors between framesComposed pagesFrames that grow in a groupDecoration anchored to framesNumbered box tabsCallout boxesAnchoring design elementsRunning heads and foliosMirrored marginsNumbered listsChinese, Japanese and Korean fontsSemantic colour palettePages on a canvasPDF export
- Also uses
- Figures exactly hereFonts embedded in the PDFCustom resource typesFigures and tables as resources
- Type
- Literata, Archivo, Noto Serif JP, Noto Sans JP (SIL OFL 1.1)
- Assets
forma-800.jpgv105-1000.jpgv1150-1000.jpgv1282-1000.jpgv1844-1000.jpgv610-1000.jpgv751-1000.jpg- A Han court official watches a craftsman lift a bamboo mould from a vat. (Generated With Diffusion Models, original)
- A monk shows two Japanese courtiers how to hold a papermaking mould. (Generated With Diffusion Models, original)
- Papermakers by a canal in Samarkand, sheets drying on a wall. (Generated With Diffusion Models, original)
- A paper workshop below the castle of Xàtiva. (Generated With Diffusion Models, original)
- A Fabriano mill with its water wheel; a sheet held up to the light. (Generated With Diffusion Models, original)
- A craftsman grinds a spruce log against a stone into wood pulp. (Generated With Diffusion Models, original)
- Two hands lift a papermaker's mould from a vat of pulp. (Generated With Diffusion Models, original)
Method
#1 · One sheet for two pages
const pageTemplates = [{
id: 'timeline',
spread: true, // two facing pages laid as one sheet; it opens on a verso
gutter: mm(10), // the band round the spine that frames keep off
grid: { columns: 2, rows: ROWS, columnGap: mm(2 * PAGE.inner), rowGap: mm(ROW_GAP) },
frames: [
{ name: 'title', takes: 'h1' },
{ name: 'lead', flow: true, fit: { minScale: 0.8 } },
{ name: 'box', style: 'box', grid: { col: 2, row: 1, rows: 4 }, height: 'fill',
padding: { right: mm(66) }, fit: { minScale: 0.85 } },
{ name: 'box-picture', layer: 2, width: mm(56), placement: at('#box', 'top-right', -5, 10) },
{ name: 'band-1', style: 'band-asia', grid: { col: 1, row: 5 }, height: mm(BAND) },
{ name: 'band-2', style: 'band-europe', crossGutter: true, width: 'fill', height: mm(BAND),
padding: { left: mm(2 * PAGE.inner + 4) }, // the colour crosses the fold, the words do not
placement: at('#band-1', 'right-of') },
card('asia', 'card-asia'), card('europe', 'card-europe'),
{ name: 'colophon', style: 'colophon', optional: true, width: mm(170),
placement: at('page', 'bottom-right', -PAGE.outer, -7) },
],
groups: [
{ name: 'opening', kind: 'stack', grid: { col: 1, row: 1, rows: 4 }, gap: mm(4),
frames: ['title', 'lead'] },
// A row of cards under each band, as many as the Markdown has: a longer text makes its
// row taller, and the other cards of the row stretch to the same height.
row('asia', 1), row('europe', 2),
],
decoration: { elements: [ground(), ticks('band-1', 'asia'), ticks('band-2', 'europe')] },
}];
spread: true makes the template one sheet as wide as both pages, and the page fence says the same with spread. A spread opens on a verso, so the build passes continuation: { pageIndexOffset: 1, pageNumbering: { startAt: 48 } }: page 1 of this excerpt is the book's page 48, a left page, and no blank page comes first. The grid has one column per page, with a gap of twice the inner margin, so nothing but the band comes near the fold. The second band sets crossGutter and a left padding of 36 mm: its colour runs from the end of the first band across the spine, and its words start on the right page, where the layout reads them.
#2 · One card, repeated by a grid
// Each `:::frame{slot="asia"}` of the page is an item of the `asia` grid: the grid lays the
// card frame once per item, three to a row, and names the copies `#asia[1]`, `#asia[2]`…
const card = (name, style) => ({ name, style, minHeight: mm(CARD) }); // auto above that height
const row = (name, col) => ({ name: `${name}-row`, kind: 'grid', columns: 3, columnGap: mm(5),
grid: { col, row: 6, rows: ROWS - 5 }, repeat: { frames: [name] } });
A group of kind: 'grid' with repeat: { frames: ['asia'] } lays the asia frame once for every :::frame{slot="asia"} of the page, three to a row, in the template grid's cell col: 1, rows 6 to 12. The copies are named #asia[1], #asia[2] and #asia[3], and each takes its own fence's label, the date on its tab. A card is at least minHeight tall and auto above that: when one text runs long, as the 1844 card does in Spanish and Japanese, its row grows and the other cards of the row stretch to the same height (rowAlign is 'stretch' by default). A fourth date in the Markdown starts a second row under the first; the template does not change.
#3 · A connector for every band
// `routing: 'tree'` with `trunk: 0` draws no bar of its own: each drop hangs from the band's
// foot straight down to the middle of a card's top, and `#asia[*]` names every card laid.
function ticks(band, cards) {
return { kind: 'connector', id: `${cards}-ticks`, routing: 'tree', trunk: 0,
from: { to: `#${band}`, side: 'bottom', gap: mm(2.4) }, to: { to: `#${cards}[*]`, side: 'top' },
color: col(cards), width: pt(1), startCap: 'ring', capSize: mm(3.6) };
}
The ticks are one connector per band in the template's decoration. routing: 'tree' joins one parent to many children; with trunk: 0 it draws no bar of its own, only a straight drop from the band's foot to the middle of each card's top, and startCap: 'ring' puts a ring at the head of each drop, 2.4 mm under the band (gap). A ring is a hollow dot drawn in the line's width, 3.6 mm across its outer edge (capSize), and the drop stops at that edge, so the cream ground shows in the hole. #asia[*] names every card the grid laid on the page, so a date added or removed in the Markdown adds or removes its drop. Connectors are laid after the frames, so when a row grows the drops still meet the cards. The cream ground is decoration too, a box anchored to the bleed's foot whose height runs up to the foot of #band-1 (size: { height: { to: '#band-1', edge: 'bottom' } }), so it follows the band.
#4 · Pictures at the size they print
const ART = {
v105: t({ es: 'Un funcionario de la corte Han mira cómo un artesano saca de la tina un molde '
+ 'de bambú lleno de pasta, junto a corteza, trapos y redes viejas.',
en: 'A Han court official watches a craftsman lift a bamboo mould full of pulp from a vat, '
+ 'beside bark, rags and old nets.',
ja: '漢の役人が見守るなか、職人が竹のすき枠を漉き舟から引き上げる。そばに樹皮、ぼろ布、古い網。' }),
v610: t({ es: 'Un monje enseña a dos cortesanos japoneses a sostener el molde sobre una tina, '
+ 'con ramas de kozo en una estera.',
en: 'A monk shows two Japanese courtiers how to hold the mould over a tub, with kozo '
+ 'branches on a mat.',
ja: '僧が二人の宮廷人に、桶の上ですき枠を持つ手つきを見せる。むしろの上に楮の枝。' }),
v751: t({ es: 'Papeleros de Samarcanda junto a un canal; las hojas se secan al sol contra un '
+ 'muro de adobe.',
en: 'Samarkand papermakers by a canal; the sheets dry in the sun against a mud-brick wall.',
ja: '水路のそばで働くサマルカンドの紙すき職人。日干しれんがの壁に紙が張られて乾いている。' }),
v1150: t({ es: 'Un taller de Xàtiva bajo el castillo: un operario golpea trapos en una pila '
+ 'de piedra y las hojas cuelgan de cuerdas.',
en: 'A workshop in Xàtiva below the castle: a worker pounds rags in a stone trough and the '
+ 'sheets hang on ropes.',
ja: '城の下のシャティバの工房。職人が石の槽でぼろ布をたたき、紙が綱につるされている。' }),
v1282: t({ es: 'Un molino de Fabriano con su rueda hidráulica y sus mazos; un papelero mira '
+ 'una filigrana al trasluz.',
en: 'A Fabriano mill with its water wheel and hammers; a papermaker holds a watermark up '
+ 'to the light.',
ja: '水車と木づちのあるファブリアーノの製紙場。職人が紙を光にかざして透かしを見ている。' }),
v1844: t({ es: 'Un artesano aprieta un tronco de abeto contra una muela que gira; debajo se '
+ 'amontonan las fibras.',
en: 'A craftsman presses a spruce log against a turning grindstone; the fibres pile up '
+ 'below.',
ja: '職人がトウヒの丸太を回る砥石に押し当て、その下に木の繊維が積もっていく。' }),
forma: t({ es: 'Dos manos sacan de la tina el molde con una capa fina de fibras.',
en: 'Two hands lift the mould from the vat with a thin layer of fibres on it.',
ja: '両手ですき枠を引き上げる。網の上に繊維の薄い層ができている。' }),
};
const SIZE = { forma: [800, 800, 363] }; // pixels and ppi: 56 mm wide; the cards' are 46 mm
const resources = await Promise.all(Object.entries(ART).map(async ([id, altText]) => {
const px = SIZE[id] ?? [1000, 667, 550];
const fileId = `${id}-${px[0]}.jpg`;
await loadImage(fileId, asset(fileId));
return { id, typeId: 'picture', kind: 'bitmap', caption: '', altText, createdAt: 0,
updatedAt: 0,
bitmap: { fileId, format: 'jpeg', width: px[0], height: px[1], resolution: px[2] } };
}));
The vignettes are 1,000 px wide at 550 ppi, 46 mm on the page, and a picture is never enlarged. The grid's three equal columns are 56.3 mm wide on each page, so each picture sits inside its card's 3.5 mm padding at its own size and the rest of the card is text.
The whole recipe
// ═══ Postext Cookbook · Nº 158 · An illustrated timeline across a double page ═══════
// https://postext.dev/en/cookbook/illustrated-timeline-spread
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Literata, Archivo, Noto Serif JP, Noto Sans JP (SIL OFL 1.1) · Needs postext ≥ 1.49.0
import {
buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the sample document ('es' | 'en' | 'ja')
const RECIPE = 'illustrated-timeline-spread';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: one ink, an accent for each half of the timeline, a pale ground
const palette = {
ink: '#22201d', // text
asia: '#2f4f7a', // indigo: the Asian half of the timeline
europe: '#a2412a', // terracotta: the European half
ground: '#f1ebdf', // the cream under the cards
rule: '#c9bfae', // hairlines and the card borders
muted: '#6b6359', // running heads and the colophon
paper: '#ffffff',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'europe (defaults)', value: { hex: palette.europe, model: 'hex' } },
];
// #endregion
const JA = LANG === 'ja';
const SERIF = JA ? 'Noto Serif JP' : 'Literata';
const SANS = JA ? 'Noto Sans JP' : 'Archivo';
// A Western textbook page is 210 × 280 mm; a Japanese one is AB判, 210 × 257 mm.
const PAGE = { w: 210, h: JA ? 257 : 280, top: 22, bottom: 20, inner: 16, outer: 15 };
const ROWS = 12;
const ROW_GAP = 3;
const ROW = (PAGE.h - PAGE.top - PAGE.bottom - (ROWS - 1) * ROW_GAP) / ROWS; // one grid row, mm
const BAND = 9; // the timeline band, in grid row 5
const CARD_TOP = 5 * (ROW + ROW_GAP); // grid row 6
// The drawn height of a card; 16 mm of the area stay free for a longer text.
const CARD = PAGE.h - PAGE.top - PAGE.bottom - CARD_TOP - 16;
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
// #region cards: one card frame per row, repeated by a grid once for each card of the Markdown
// Each `:::frame{slot="asia"}` of the page is an item of the `asia` grid: the grid lays the
// card frame once per item, three to a row, and names the copies `#asia[1]`, `#asia[2]`…
const card = (name, style) => ({ name, style, minHeight: mm(CARD) }); // auto above that height
The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)
Variations
#Four cards to a row
With columns: 4 each band takes four dates side by side; the cards are narrower and their texts run longer, so the rows grow taller.
-const row = (name, col) => ({ name: `${name}-row`, kind: 'grid', columns: 3, columnGap: mm(5),
+const row = (name, col) => ({ name: `${name}-row`, kind: 'grid', columns: 4, columnGap: mm(5),#Arrows instead of rings
endCap: 'arrow' puts an arrowhead where each drop meets its card, and startCap: 'none' takes the rings away.
Pitfalls
- A grid lays one cell per item, and an item is a
:::frame{slot="asia"}fence of its own: two cards' texts inside one fence make one card. #asiawithout[*]is the grid's box, not its cards: a connector to it draws one drop to the middle of the row.- A size that runs to an edge of another box counts from the element's own anchor point: the ground is anchored to the bleed's foot and grows up to
#band-1. An edge behind the anchor gives a height of 0.
Credits
- Recipe
- Ignacio Ferro
- Text
- The paper road, a double-page timeline written for this recipe in Spanish, English and Japanese · Postext Cookbook · CC BY 4.0
- Images
- A Han court official watches a craftsman lift a bamboo mould from a vat. · Generated With Diffusion Models · original
- A monk shows two Japanese courtiers how to hold a papermaking mould. · Generated With Diffusion Models · original
- Papermakers by a canal in Samarkand, sheets drying on a wall. · Generated With Diffusion Models · original
- A paper workshop below the castle of Xàtiva. · Generated With Diffusion Models · original
- A Fabriano mill with its water wheel; a sheet held up to the light. · Generated With Diffusion Models · original
- A craftsman grinds a spruce log against a stone into wood pulp. · Generated With Diffusion Models · original
- Two hands lift a papermaker's mould from a vat of pulp. · Generated With Diffusion Models · original
- Fonts
- Literata (SIL OFL 1.1) · Archivo (SIL OFL 1.1) · Noto Serif JP (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


