In short
Two pages from a home cookbook, one recipe on each. It shows how to put the ingredients and the cooking steps side by side on a card.
What you'll build
Two facing pages from Salt & Olive Oil, an invented Spanish home cookbook, on a 190 × 250 mm trim, one recipe to a page. A photograph, generated with diffusion models and loaded as a JPEG, bleeds across the top 104 mm: a tortilla with a slice pulled out on a saffron table, a bowl of gazpacho on a sage one. Over it sit a kicker, the title in 42 pt Young Serif, pills for time, difficulty and season, and a note in Caveat handwriting that points at the dish. Below the italic headnote, a white card carries a tomato-red servings tab on its top-right corner. The ingredients run down its left column with olive dashes and tag chips; under the tortilla's, line drawings of a bowl, a pan and a plate head a checklist. The method fills the right column, each step led by a 26 pt old-style figure.
This recipe answers
- How do I put two columns inside a box (a text column beside a figure column)?
- How do I add a numbered tab ("BOX 1-1"), a corner icon, or a margin icon with a rule?
- How do I customise lists: bullets per level, (a)/(i) numbering, task checkboxes, spacing that stays on the grid?
- How do I make inline chips: keyboard keys, tags, word banks for exercises?
- How do I add an author line, a standfirst or a lead with a drop cap to an opener?
The short answer
// In the Markdown, :::callout{type="card" label="SERVES 4"} holds a :::columns{count=2} group
// of two nested boxes, :::callout{type="column" title="Ingredients"} and one for the method.
// The group levels its columns by cutting between blocks or lines, so loose lists would run
// the method on under the ingredients. A nested box is one block that never splits, so the
// only cut left is between the two.
const TAB = 5.6; // mm: the tab's height, and how far it rises above the card
const card = { id: 'card', background: col('card'),
padding: { top: mm(4.5), right: mm(6), bottom: mm(5), left: mm(6) },
// No space of its own above: the tab starts on the first grid line under the opener.
columnGap: mm(7), marginTop: mm(0),
// label="…" on the fence prints here: a tab on the top-right corner, a cutlery pictogram
// beside it and a rule from the far corner that makes the tab part of the card.
label: { fontFamily: TEXT, fontSize: pt(8), color: col('card'), // bold by default
background: col('tomato'), height: mm(TAB), offset: mm(TAB), paddingX: mm(2.6),
icon: { resourceId: 'cutlery', width: mm(TAB * 6 / 8), gap: mm(1.6) }, // as tall as the tab
rule: { enabled: true, color: col('tomato'), width: pt(1.2) } } };
// The two columns: frameless boxes whose only device is a tracked title.
const NONE = { top: mm(0), right: mm(0), bottom: mm(0), left: mm(0) };
const column = { id: 'column', backgroundEnabled: false, padding: NONE,
lists: { gap: mm(2.2), itemSpacing: pt(3.5) }, // for the steps as well as the dashes
titleStyle: { fontFamily: TEXT, fontSize: pt(8), color: col('tomato'), // bold by default
textTransform: 'uppercase', letterSpacing: pt(1.5), gap: mm(2.4) } };
// config() plugs them in: calloutStyles: [card, column, prep].
A white card with a servings tab, two columns inside it
Ingredients
- Features
- Columns in a box or in the textNumbered box tabsNumbered listsNested boxesBox icons and corner badgesInline chipsBullet lists and checklistsCallout boxesDesigned openersFull-width chapter bandHeading stylesHeading attributesText, rules and boxes in page designsPictures in page designsLine breaks in titlesPaper colourRunning heads and foliosSemantic colour paletteParagraph stylesFigures and tables as resources
- Type
- Young Serif, Figtree, Caveat (SIL OFL 1.1)
- Assets
gazpacho-1520.jpgtortilla-1520.jpg- The tortilla on its plate, a photograph (Generated With Diffusion Models, original)
- The bowl of gazpacho, a photograph (Generated With Diffusion Models, original)
- The note’s arrow and the pictograms, drawn in code in the page’s palette (Ignacio Ferro, CC BY 4.0)
Method
#1 · Give each column a box of its own
With loose lists, a columns group in a box cuts where its columns level best, between blocks or between the lines of one, so the gazpacho's first step splits across the gutter: its first line closes the ingredient column and the rest opens the method column. A nested box, as in the short answer above, is one block, and the group never cuts inside it. A picture set in one needs a ::resource with placement 'here', since any other placement makes it a float, which leaves the box and is placed like any cited figure. The card style's label turns the fence's label="SERVES 4" into the tab: an offset equal to its height stands it on the card's top edge, and the rule runs from the far corner to the fork and knife (callout styles).
#2 · Centre the step numbers on two lines
// Young Serif has old-style figures: 1 and 2 stand 0.56 em, a little above its 0.50 em
// x-height, so 5.1 mm at STEP. A list number is centred 0.3 em (of the text) above the item's
// first baseline, with the canvas 'middle' baseline, which Chrome puts 0.24 em above Young
// Serif's own (gotcha: list-number-centred). DROP centres the figures on the step's first two
// lines, from the cap height of the first to the baseline of the second.
const [STEP, FIGURE, MIDDLE, CAP] = [26, 0.56, 0.24, 0.7]; // pt; em of each face
const DROP = (LEAD - CAP * BODY) / 2 + 0.3 * BODY + (FIGURE / 2 - MIDDLE) * STEP; // pt
const orderedLists = { fontFamily: DISPLAY, fontWeight: 400, // Young Serif ships 400 only
numberFontSize: pt(STEP), color: col('tomato'),
separatorColor: col('olive'), separatorGap: pt(0.6), // the default '.' as its own run
numberVerticalOffset: pt(DROP) };
A list number is painted centred a little above the item's first baseline, so numberFontSize alone would set the 26 pt figures level with the first line; numberVerticalOffset lowers them 2.5 mm, to the middle of the band from the first line's capitals to the second line's baseline. Young Serif has old-style figures: 3, 4 and 5 descend below the baseline that 1 and 2 sit on. With separatorColor set, the separator is painted as a run of its own, and the default full stop prints olive beside a red figure (ordered lists).
#3 · Head the checklist with a strip of drawings
// :::callout{type="prep" title="Before you start"}, closed at once, is a header: a box that
// holds only its title and icon. The icon is one picture of three drawings; a width KIT times
// its size makes its box a strip, and the picture is fitted into width × size, left of the
// title. Tasks set inside the box would start after that column, 21 mm in, so the '- [ ]'
// items follow the box, where they print the default task box, '☐'.
const [STRIP, KIT] = [5, 30 / 8]; // mm: the strip's height; the drawing's width over height
const prep = { id: 'prep', backgroundEnabled: false, padding: NONE,
marginTop: pt(LEAD), marginBottom: column.titleStyle.gap, // the tasks follow at this gap
icon: { kind: 'resource', resourceId: 'kit', size: mm(STRIP), width: mm(STRIP * KIT),
align: 'center' }, // the title centred on the strip
titleStyle: { ...column.titleStyle, color: col('olive') } };
The prep box holds only its title and its icon, so it works as a header: an icon width 3.75 times its size stretches the icon's square into an 18.75 × 5 mm strip, and the three drawings fill it left of the title (callout styles). An icon takes a column of its own beside everything in its box, so the tasks go after the box, where they line up with the ingredients' dashes instead of starting 21 mm in. - [ ] items print the default task box, and unorderedLists.marginTop: 0 lets them follow the header at its marginBottom, the 2.4 mm gap the column titles keep (unordered lists).
#4 · Make the tags chips
const chipStyles = [{ id: 'tag', fontSize: em(0.86), bold: true, background: col('tint'),
borderWidth: pt(0), borderRadius: em(1), // no outline; a radius past half the height: a pill
paddingX: em(0.7), paddingY: em(0.18), gap: em(0.3) }];
:chip[Vegetarian]{style="tag"} puts a word in a box that never breaks across lines. A borderRadius larger than half the box's height is clamped to that half, which turns both ends into semicircles; with borderWidth: 0 the pill is drawn in the tint alone. The box is 11.4 pt tall, under the card's 12.8 pt leading, so a second line of tags would not touch the first (chip styles).
#5 · One design, one photograph per recipe
const BAND = 104; // mm: the photo's foot; the pills sit 13 mm above it, the lead 6 mm below
const NOTE = { x: 18, y: 24, w: 70 }; // mm on the page: the box ends 2 mm before the arrow
const at = (x, y, size) => ({ anchor: { to: 'container', edge: 'top-left' },
offset: { x: mm(x), y: mm(y - PAGE.top) }, size }); // y in mm from the top of the page
const text = (id, content, family, size, placement, extra) => ({ kind: 'text', id, content,
fontFamily: family, fontSize: pt(size), color: col('ink'), align: 'left',
overflow: 'wrap', placement, ...extra }); // a foot wraps too, where the default is '…'
const tracked = { fontWeight: 700, textTransform: 'uppercase', letterSpacing: pt(1.6) };
// Pills are text boxes chained right-of each other; each prints one heading attribute.
const pill = (id, after) => text(id, `{attr.${id}}`, TEXT, 8.4, after ? { anchor:
{ to: `#${after}`, edge: 'right-of' }, offset: { x: mm(1.8) } } : at(0, BAND - 13), {
fontWeight: 600, box: { backgroundColor: col('card'), borderRadius: mm(3),
padding: { top: mm(1.1), right: mm(2.8), bottom: mm(1.1), left: mm(2.8) } } });
// One heading style for every recipe; each heading names its photo: art="tortilla".
const opener = { id: 'receta', advancedDesign: { enabled: true, slot: { elements: [
{ kind: 'image', id: 'art', resourceId: '{attr.art}', // filled in per heading, like a text
placement: { anchor: { to: 'page', edge: 'top-left' },
size: { width: mm(PAGE.w), height: mm(BAND) } } },
{ kind: 'image', id: 'arrow', resourceId: 'arrow', // the note's arrow, over the photo
placement: { anchor: { to: 'page', edge: 'top-left' },
size: { width: mm(PAGE.w), height: mm(BAND) } } },
text('note', '{attr.note}', HAND, 19, { anchor: { to: 'page', edge: 'top-left' },
offset: { x: mm(NOTE.x), y: mm(NOTE.y) }, size: { width: mm(NOTE.w) } },
{ fontWeight: 600, align: 'right' }), // on the page, like the arrow and the photo
pill('time'), pill('level', 'time'), pill('season', 'level'),
text('title', '{titleText}', DISPLAY, 42, { anchor: { to: '#time', edge: 'above' },
offset: { y: mm(-3.2) }, size: { width: mm(96) } }, // two lines: the \\ in the heading
{ lineHeight: 1 }), // set solid: 42 pt from line to line
text('kicker', '{attr.kicker}', TEXT, 8.2, { anchor: { to: '#title', edge: 'above' },
offset: { y: mm(-2.4) }, size: { width: mm(96) } }, tracked),
// The lead is the design's lowest element: the opener reserves down to its last line, and
// the card starts under it without a minHeight.
text('lead', '{attr.lead}', TEXT, 10.5, at(0, BAND + 6, { width: mm(122) }),
{ italic: true, lineHeight: 1.45 }),
] } } };
# Tortilla \\ de patatas {style="receta" art="tortilla" kicker="…" lead="…"} picks the heading style and fills its slots from the attributes, the italic headnote among them (heading attributes). The image element's resourceId is '{attr.art}', a placeholder like a text's, so both recipes share one style and each heading names its photograph (image elements). Each pill is anchored right-of the one before it, the title above the first pill and the kicker above the title, so a longer title pushes the kicker up while the pills keep their line. The headnote is the design's lowest element, so the opener reserves down to its last line and the card starts below it without a minHeight. The note is anchored to the page, like the photograph and the arrow, a second image element drawn in code, and ends 2 mm short of the arrow on both pages, although the mirrored margins move the text block 2 mm to the right on the recto.
#6 · Register the pictures as resources
// The opener's image elements and both icons name a resource id; the resource names the file
// the canvas paints (loadImage or loadSvg registers it). No :ref cites them, so none is numbered.
const photo = (id, altText) => ({ id, typeId: 'figure', kind: 'bitmap', createdAt: 0, updatedAt: 0,
altText, bitmap: { fileId: `${id}-1520.jpg`, format: 'jpeg', width: 1520, height: 832 } });
const ART = { // markup, width and height in mm, and the alt text
arrow: [arrow, PAGE.w, BAND, t({ en: 'An arrow to the dish', es: 'Una flecha al plato' })],
cutlery: [cutlery, 6, 8, t({ en: 'Fork and knife', es: 'Tenedor y cuchillo' })],
kit: [kit, 8 * KIT, 8, t({ en: 'A bowl with two eggs, a frying pan and a plate',
es: 'Un bol con dos huevos, una sartén y un plato' })] };
const resources = [
photo('tortilla', t({ en: 'A potato omelette with a slice pulled out, on a blue-rimmed plate '
+ 'and a red-checked napkin', es: 'Una tortilla de patatas con una porción separada, en un '
+ 'plato de borde azul sobre una servilleta de cuadros rojos' })),
photo('gazpacho', t({ en: 'A bowl of gazpacho with diced vegetables and a spoon, on a '
+ 'blue-checked napkin beside a tomato', es: 'Un cuenco de gazpacho con dados de verdura '
+ 'y una cuchara, sobre una servilleta de cuadros azules junto a un tomate' })),
...Object.entries(ART).map(([id, [, w, h, altText]]) => ({ id, typeId: 'figure',
kind: 'svg', createdAt: 0, updatedAt: 0, altText, svg: { fileId: `${id}.svg`, width: w * 10,
height: h * 10 } })), // 10 px a millimetre: the sizes only set the aspect ratio here
];
const photos = resources.filter((r) => r.kind === 'bitmap').map((r) => r.bitmap.fileId);
await Promise.all([...photos.map((file) => loadImage(file, asset(file))),
...Object.entries(ART).map(([id, [svg]]) => loadSvg(`${id}.svg`, svg))]);
The opener's two image elements, the tab's icon and the checklist header's icon each name a resource, and the canvas paints the file loadImage or loadSvg registered for it. No :ref cites these resources, so none becomes a numbered figure. The pictures carry no words: the handwritten notes are design text set over them.
The whole recipe
// ═══ Postext Cookbook · Nº 033 · Recipe card: ingredients beside the method ═══════
// https://postext.dev/en/cookbook/recipe-card
// Code: MIT · Text: original (CC BY 4.0) · Photos: diffusion models · Pictograms: CC BY 4.0
// Fonts: Young Serif, Figtree, Caveat (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'recipe-card';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { ink: '#2b2118', muted: '#76634e', // text; folios and the colophon
paper: '#f7eddb', card: '#fffdf8', // the cream page; the white recipe card on it
tomato: '#bf3d29', olive: '#6b7a3a', tint: '#f6e3c1' }; // numbers and tab; dashes; tags
// Each colour names its palette entry and carries its hex.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// The engine's defaults link to 'main-color': point it at the tomato, so nothing prints blue.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.tomato })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [TEXT, DISPLAY, HAND] = ['Figtree', 'Young Serif', 'Caveat'];
const PAGE = { w: 190, h: 250, top: 22, inner: 18, outer: 16 }; // mm, mirrored margins
const [BODY, LEAD] = [9.4, 12.8]; // pt: the text of the cards and the notes under them
// #region answer: a white card with a servings tab, two columns inside it
// In the Markdown, :::callout{type="card" label="SERVES 4"} holds a :::columns{count=2} group
// of two nested boxes, :::callout{type="column" title="Ingredients"} and one for the method.
// The group levels its columns by cutting between blocks or lines, so loose lists would run
// the method on under the ingredients. A nested box is one block that never splits, so the
// only cut left is between the two.
const TAB = 5.6; // mm: the tab's height, and how far it rises above the card
const card = { id: 'card', background: col('card'),
padding: { top: mm(4.5), right: mm(6), bottom: mm(5), left: mm(6) },
// No space of its own above: the tab starts on the first grid line under the opener.
columnGap: mm(7), marginTop: mm(0),
// label="…" on the fence prints here: a tab on the top-right corner, a cutlery pictogram
// beside it and a rule from the far corner that makes the tab part of the card.
label: { fontFamily: TEXT, fontSize: pt(8), color: col('card'), // bold by default
background: col('tomato'), height: mm(TAB), offset: mm(TAB), paddingX: mm(2.6),
icon: { resourceId: 'cutlery', width: mm(TAB * 6 / 8), gap: mm(1.6) }, // as tall as the tab
rule: { enabled: true, color: col('tomato'), width: pt(1.2) } } };
// The two columns: frameless boxes whose only device is a tracked title.
const NONE = { top: mm(0), right: mm(0), bottom: mm(0), left: mm(0) };
const column = { id: 'column', backgroundEnabled: false, padding: NONE,
lists: { gap: mm(2.2), itemSpacing: pt(3.5) }, // for the steps as well as the dashes
titleStyle: { fontFamily: TEXT, fontSize: pt(8), color: col('tomato'), // bold by default
textTransform: 'uppercase', letterSpacing: pt(1.5), gap: mm(2.4) } };
// config() plugs them in: calloutStyles: [card, column, prep].
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
#Count blocks instead of boxing the columns
Without the column boxes, breaks names the child that opens the right column, and each list item, the tags line and the checklist's header count as one: the gazpacho needs breaks="10" (eight ingredients and the tags come first), the tortilla breaks="11". The column titles and the column style's space between steps disappear with them.
:::callout{type="card" label="SERVES 6"}
-:::columns{count=2}
-:::callout{type="column" title="Ingredients"}
+:::columns{count=2 breaks="10"}
- **1.5 kg** ripe plum tomatoes
@@ seven more ingredients and a blank line @@
:chip[Vegan]{style="tag"} :chip[No-cook]{style="tag"} :chip[Make ahead]{style="tag"}
-:::
-:::callout{type="column" title="Method"}
+
1. Chop the tomatoes, seeded pepper, peeled cucumber and garlic.
@@ steps 2 to 5 @@
:::
-:::
:::#Stand the tab on the left corner
'top-left' mirrors the label: the tab moves to the left corner, the fork and knife to its right, and the rule runs in from the right.
background: col('tomato'), height: mm(TAB), offset: mm(TAB), paddingX: mm(2.6),
+ position: 'top-left', // 'top-right' by defaultPitfalls
Pitfall
A list number is centred on its first line, not set on the baseline
An ordered list's number is painted with the canvas 'middle' baseline, 0.3 em of the text above the item's first baseline, so a number in another face or at a larger numberFontSize grows up and down from there instead of standing on the line: a display face rides high, and a big step number hangs across the first line. Place it with orderedLists.numberVerticalOffset, and check the result at full size. Contents numbers sit on the baseline since postext 1.5; list numbers are still centred. Numbered lists →
Pitfall
A box's lists.color also recolours its list numbers
A callout style's lists.color colours the bullets of the box and the numbers of its ordered lists alike, whenever the style sets it: give a box olive bullets that way and its step numbers turn olive too. (Up to postext 1.4 it reached the numbers only when it differed from unorderedLists.color.) To colour a box's bullets alone, set unorderedLists.color for the document and leave lists.color out of the box style, which keeps the numbers in orderedLists.color. Callout boxes →
Pitfall
Chips taller than the line pitch touch the next line
A chip whose box is taller than the line pitch touches the chips on the next line (the chipOverlap warning). Reduce its vertical padding, border or size, or open the leading. Inline chips →
- A label has no
textTransformorletterSpacing, so SERVES 4 and PARA 4 are typed in capitals in the fences.
Credits
- Recipe
- Ignacio Ferro
- Text
- Original prose, CC BY 4.0
- Images
- The tortilla on its plate, a photograph · Generated With Diffusion Models · original
- The bowl of gazpacho, a photograph · Generated With Diffusion Models · original
- The note’s arrow and the pictograms, drawn in code in the page’s palette · Ignacio Ferro · CC BY 4.0
- Fonts
- Young Serif (SIL OFL 1.1) · Figtree (SIL OFL 1.1) · Caveat (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


