In short
The printed programme of a two-day conference about printing and lettering. Its timetable lets one talk stretch across all the rooms or over two time slots, with each topic in its own colour.
What you'll build
The printed programme of an invented typography conference in Girona, written in Catalan. The cover draws the capital ela geminada, L·L, as three coloured modules on ink. Each day opens on a 76 mm ink band with the day of the month as a 144 pt numeral. Thursday's schedule is a table. The opening lecture fills one ink cell across the three rooms, and each workshop takes two time slots. The parts of the day head their rows across the whole grid, and each talk is a tile in its track's colour, keyed by the swatches in the caption. The grid is taller than a page, so it fills page 3 and ends on page 4 under its repeated head row. Friday's shorter grid fits whole at the foot of its opening page.
This recipe answers
- How do I make a table with header rows, merged cells, column widths and per-cell alignment?
- How do I split a long table across pages with a repeated header and a "continued" marker?
- How do I add colour-key swatches to text, captions or table notes?
- How do I get "Figure" and "Table" labels in my document's language?
- How do I make a chapter opener with a full-bleed colour band, a big chapter number and the title?
The short answer
const ROOMS = ['Sala Gran', 'Sala de les Premses', 'Aula Taller'];
const TRACKS = { T: 'tipo', D: 'digital', E: 'edicio', '*': 'ink' }; // '*': a plenary
const at = (row, c) => ({ row, col: c });
const span = (r0, c0, r1, c1) => ({ start: at(r0, c0), end: at(r1, c1) });
const lines = (code, text) => text.split(' / ').map((line, i) => { // title, then speaker
const run = i === 0 ? `**${line}**` : line;
return code === '*' ? chip(run, 'blanc') : run; // paper-white type on the ink fill
}).join('\n'); // a line break in a cell starts a new paragraph
function schedule(text) { // '11.15 | T Title / Speaker | ^' · a bare line: a part of the day
let m = { headerRowCount: 1, columnWidths: [12, 42, 42, 42], // weights of the 138 mm measure
rows: [['Hora', ...ROOMS].map((room) => ({ content: room.toUpperCase(), isHeader: true }))] };
for (const line of text.trim().split('\n')) {
const [time, ...slots] = line.split(' | ');
const r = m.rows.push(['', ...ROOMS].map(() => ({ content: '' }))) - 1; // four empty cells
if (!slots.length) { // one cell across the table; a split keeps it with the rows it heads
m = setCellContent(m, at(r, 0), chip(time.toUpperCase(), 'franja'));
m = mergeCells(m, span(r, 0, r, 3));
continue;
}
m = setCellContent(m, at(r, 0), chip(time, 'hora'));
slots.forEach((slot, i) => {
if (slot === '^') { // the session above runs on: one cell down both rows, centred in them
m = mergeCells(m, span(r - 1, i + 1, r, i + 1));
m = setAlignment(m, at(r - 1, i + 1), 'left', 'middle');
return;
}
const [, code = '', body = slot] = /^([TDE*]) (.+)$/.exec(slot) ?? [];
m = setCellContent(m, at(r, i + 1), lines(code, body));
m = setCellBackground(m, at(r, i + 1), col(TRACKS[code] ?? 'pause'));
});
if (slots.length === 1) m = mergeCells(m, span(r, 1, r, 3)); // the same for all three rooms
}
return m; // mergeCells marks the covered cells hiddenBy (gotcha: merged-cells-hiddenby)
}
A day's schedule as a table with merged cells, track fills and a head row
Ingredients
- Features
- Tables from dataTables across pagesCell fillsColour swatchesInline chipsFigure placementTable styleCaption styleDesigned openersFull-width chapter bandHeading attributesHeading stylesCovers, title pages and colophonsFigure and Table in your languageCustom resource typesParagraph stylesRunning heads and foliosSemantic colour palette
- Also uses
- Bibliographies and glossariesCitations that place figuresHeads by page roleFigures and tables as resourcesRunning heads per sectionUnnumbered chapters
- Type
- Schibsted Grotesk, Unbounded, Chivo Mono (SIL OFL 1.1)
- Assets
- None: every picture is drawn in code
Method
#1 · Turn each line of the programme into a row
The code is the short answer above. Each day is plain text in a content file, one line per time slot: | separates the rooms, a letter names the track, * marks a plenary on an ink fill, / starts each line after the title, and ^ continues the session of the slot above. mergeCells makes every span. A line with one session, such as the plenary or a break, takes the three room columns. A workshop takes its cell and the one below, and a part of the day (MATÍ, TARDA), written as a line with no |, takes all four columns. The cells a merge covers stay in the grid, marked hiddenBy, because a cell's column is its index in the row (Building table models). headerRowCount: 1 makes the room names the head row. The columnWidths are relative weights, and 12 + 3 × 42 adds up to the 138 mm measure, so the hour column is 12 mm wide and each room 42 mm. setAlignment(…, 'left', 'middle') centres each workshop vertically in its two rows.
#2 · Let Thursday run over and keep Friday whole
// The built-in types in Catalan, Figura and Taula; a grid's caption goes above it.
const resourceTypes = defaultResourceTypes('ca').map((type) => ({ ...type,
...(type.id === 'table' && { captionStyle: { position: 'above' } }),
numberingTemplate: '{n}', resetOn: 'never' })); // Taula 1, Taula 2: one count, not per day
const SPLIT = { overflow: 'split', // the default; the other values are 'clip' and 'hide'
// The engine's own Catalan strings are '(cont.)' and 'Continua': these spell them out.
continuedSuffix: '(continuació)', // after the caption of every part but the first
continuesMarker: 'Continua a la pàgina següent' }; // under every part but the last
// Thursday is cited on page 2 and placed at the top, so it opens page 3 (gotcha:
// top-float-next-page) and splits; Friday goes whole to the foot of the page that cites it.
const PLACE = { dijous: { position: 'top', span: 'page' },
divendres: { position: 'bottom', span: 'page' } };
Thursday's grid is cited on page 2 and placed at the head of a page. A float never goes above its reference, so the grid opens page 3. It is taller than the page, and overflow: 'split' cuts it between two rows, never inside a merged cell (Tables taller than the page). Page 3 ends with the 17.30 row and the marker under it. Page 4 repeats the head row and the whole caption, swatch key included, followed by (continuació), and the note prints only under this last part. Friday's grid goes to the foot of a page and fits under the text that cites it on page 5. defaultResourceTypes('ca') names the types in Catalan, Figura and Taula. The engine's own Catalan strings for a split table are (cont.) and Continua; the table style spells both out instead. numberingTemplate: '{n}' with resetOn: 'never' counts both grids in one series, Taula 1 and Taula 2.
#3 · Cut the fills into tiles
const tableStyle = { ...SPLIT, borderColor: col('paper'), borderWidth: pt(1.6), // grid rules
headerBackground: col('ink'), headerColor: col('paper'), headerFontFamily: LABEL,
headerFontSize: pt(7.5), bodyFontSize: pt(8.2),
cellPadding: mm(1.5) };
const bare = (id, extra) => ({ id, backgroundEnabled: false, borderWidth: pt(0),
paddingX: pt(0), ...extra }); // a chip that only changes the face, the size or the colour
const chipStyles = [bare('blanc', { color: col('paper') }), // the plenary's type, on ink
bare('hora', { fontFamily: LABEL, fontSize: em(0.96), bold: true }),
bare('franja', { fontFamily: LABEL, fontSize: em(0.92), bold: true, color: col('accent') }),
bare('sala')]; // keeps each room of the plan's note on one line
setCellBackground in the short answer gives each session its track's palette entry, and grid rules 1.6 pt wide in the paper colour cut the fills into tiles with white gutters (Table style). A table has one text colour for its body cells, so the plenary's white type is a chip whose style sets the colour and turns off the chip's fill, border and side padding. The times and the parts of the day are chips too, in Chivo Mono (Chip styles). A chip never breaks across lines; a plenary's title and its speaker line each fit on one line of the three-room cell. In the plan's note, the sala chip leaves the text as it is and keeps each room's number and name on one line, as a no-break space between its words would.
#4 · Open each day on a band
const BAND = 76, STRIP = 8, AIR = 7; // mm: band from the trim, its strip of modules, air below
const text = (id, content, family, size, color, placement, extra) => ({ kind: 'text', id,
content, fontFamily: family, fontSize: pt(size), color: col(color), placement, align: 'left',
overflow: 'wrap', ...extra }); // a long line wraps, in the running heads too
const pin = (to, edge, x, y, size) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
...(size && { size }) });
const caps = (size) => ({ fontWeight: 500, textTransform: 'uppercase',
letterSpacing: pt(size * 0.18) });
const NUMERAL = 144; // pt
// mm: Unbounded 800's 1 at 144 pt starts its ink 0.76 mm into its box, the date's first capital
// at 8 pt 0.1 to 0.2 mm into its own (P 0.19, S 0.09): 0.6 mm to the left lines up the two inks
const BEARING = 0.6;
const BASELINE = 0.8; // a design line's baseline sits 0.8 down its box (lineHeight 1)
const opener = { enabled: true, minHeight: mm(BAND - PAGE.top + AIR), slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('ink') },
placement: pin('bleed', 'top-left', 0, 0, { width: 'fill', height: mm(BAND) }) },
{ kind: 'image', id: 'strip', resourceId: 'strip', placement: pin('page', 'top-left', 0,
BAND - STRIP, { width: mm(PAGE.w), height: mm(STRIP) }) }, // on the band's foot
text('date', '{attr.date}', LABEL, 8, 'edicio', pin('container', 'top-left', 0, 0), caps(8)),
text('numeral', '{attr.day}', DISPLAY, NUMERAL, 'paper', pin('#date', 'below', -BEARING, 1),
{ fontWeight: 800, lineHeight: 1 }), // a 144 pt line box
text('title', '{titleText}', DISPLAY, 26, 'paper', // its baseline level with the numeral's
pin('#numeral', 'right-of', 5, BASELINE * (NUMERAL - 26) * PT),
{ fontWeight: 700, lineHeight: 1 }),
] } };
The first-level heading's design draws the band: a box 76 mm deep from the bleed edge, with the strip of modules along its foot. The date comes from the heading's date attribute and the numeral from day. The 1 of Unbounded 800 at 144 pt starts its ink 0.76 mm into its box and the date's first capital 0.1 to 0.2 mm into its own, so the numeral moves 0.6 mm left, and the date, the numeral and the text start their ink within 0.2 mm of each other. The day's name sits to the right of the numeral, lowered by BASELINE × (144 − 26) pt so that the two baselines meet, because a design text with lineHeight: 1 has its baseline 0.8 of the way down its box. minHeight reserves the page down to 7 mm below the band, and the baseline grid rounds the reserve up to 14 lines, so the first line box of text starts 10.2 mm under the band. With AIR = 0 the numeral's own box, which reaches past the band's foot, sets the height instead, and the text starts 5.6 mm under the band.
#5 · Indent the speakers' turnovers
const paragraphStyles = [
{ id: 'bio', hangingIndent: mm(4) }, // the name at the column edge, the lines under it 4 mm in
{ id: 'colophon', fontFamily: LABEL, fontSize: pt(7.4), lineHeight: pt(LEAD * 0.75),
textAlign: 'left', color: col('muted'), firstLineIndent: pt(0), marginTop: pt(LEAD) },
];
Each speaker is one paragraph of a :::paragraphs{style="bio"} block. The bold name starts at the column's edge and the lines under it step in 4 mm, so the names line up down the column as in an index (Paragraph styles).
The whole recipe
// ═══ Postext Cookbook · Nº 053 · Conference programme with a merged schedule grid ═══════
// https://postext.dev/en/cookbook/conference-programme
// Code: MIT · Text: original, in Catalan (CC BY 4.0) · Drawings: generated in code (CC BY 4.0)
// Fonts: Schibsted Grotesk, Unbounded, Chivo Mono (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
buildDocumentWithFonts, prepareFonts, renderPageToCanvas, registerResourceImage,
defaultResourceTypes, mergeCells, setCellContent, setCellBackground, setAlignment,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'conference-programme';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = {
ink: '#1d1b24', paper: '#ffffff', // a violet near-black; type on the ink fills
tipo: '#b09cf2', digital: '#4fc7bb', edicio: '#f4b43a', // the three tracks: fills and swatches
pause: '#ecebf1', // registration, breaks and meals
accent: '#6a3ed3', // kickers, caption labels, the parts of the day
muted: '#67636f', // running heads and notes
};
// Each colour carries its hex and the palette entry it follows.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent }) // defaults' id
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [TEXT, DISPLAY, LABEL] = ['Schibsted Grotesk', 'Unbounded', 'Chivo Mono'];
const PAGE = { w: 170, h: 240, top: 22, bottom: 20, inner: 17, outer: 15 }; // mm, mirrored
const LEAD = 13; // pt: the body's leading and baseline grid
const PT = 25.4 / 72; // mm in a point
const chip = (text, style) => `:chip[${text}]{style="${style}"}`;
// #region answer: a day's schedule as a table with merged cells, track fills and a head row
const ROOMS = ['Sala Gran', 'Sala de les Premses', 'Aula Taller'];
const TRACKS = { T: 'tipo', D: 'digital', E: 'edicio', '*': 'ink' }; // '*': a plenary
const at = (row, c) => ({ row, col: c });
const span = (r0, c0, r1, c1) => ({ start: at(r0, c0), end: at(r1, c1) });
const lines = (code, text) => text.split(' / ').map((line, i) => { // title, then speaker
const run = i === 0 ? `**${line}**` : line;
return code === '*' ? chip(run, 'blanc') : run; // paper-white type on the ink fill
}).join('\n'); // a line break in a cell starts a new paragraph
function schedule(text) { // '11.15 | T Title / Speaker | ^' · a bare line: a part of the day
let m = { headerRowCount: 1, columnWidths: [12, 42, 42, 42], // weights of the 138 mm measure
rows: [['Hora', ...ROOMS].map((room) => ({ content: room.toUpperCase(), isHeader: true }))] };
for (const line of text.trim().split('\n')) {
const [time, ...slots] = line.split(' | ');
const r = m.rows.push(['', ...ROOMS].map(() => ({ content: '' }))) - 1; // four empty cells
if (!slots.length) { // one cell across the table; a split keeps it with the rows it heads
m = setCellContent(m, at(r, 0), chip(time.toUpperCase(), 'franja'));
m = mergeCells(m, span(r, 0, r, 3));
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
#Round the grid's corners
A split table rounds the top corners of its first part, on page 3, and the bottom corners of its last part, on page 4, where only the right one shows because the hour column has no fill.
- cellPadding: mm(1.5) };
+ cellPadding: mm(1.5), borderRadius: mm(2.5) };#Number each day's grid on its own
Counting per level-1 heading, as the built-in types do, gives Taula 1.1 and Taula 2.1 and turns the plan into Figura 2.1; the cover's style is not numbered, so Thursday is heading 1.
- numberingTemplate: '{n}', resetOn: 'never' })); // Taula 1, Taula 2: one count, not per day
+ numberingTemplate: '{h1}.{n}', resetOn: 'h1' })); // Taula 1.1, Taula 2.1: per dayPitfalls
Pitfall
A 'top' float goes to the page after its citation unless it may head the citing page
By default a float never goes above its own reference, so a page-wide 'top' float cited on page N opens page N+1. Set placement.citingPage: true on the resource or its type's defaultPlacement (or layout.floatsAtCitingPage for the whole book, since postext 1.25) and it heads page N instead, the text above the reference moving down under it, when it fits within layout.maxTopFraction and the citing line stays on that page. It never heads a chapter's first page or a page after a forced break: there it still opens the next page, and 'auto' or 'bottom' can take the foot of the citing page. Figure placement →
Credits
- Recipe
- Ignacio Ferro
- Text
- The programme’s Catalan text, both schedules included, written for this recipe, and the cover, band and floor-plan drawings, generated in code · Ignacio Ferro · CC BY 4.0
- Fonts
- Schibsted Grotesk (SIL OFL 1.1) · Unbounded (SIL OFL 1.1) · Chivo Mono (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


