In short
A four-page magazine story laid out from a template: the text runs from one column to the next and on to new pages by itself, and wraps round a quote and the outline of a photo.
What you'll build
Pages 46 to 49 of Patio, an invented quarterly about city life: a feature on a retired typesetter who keeps fourteen hives on the roof of the printing works where she worked for thirty years. The verso of the opening spread is the photograph, with the headline set over the gravel and a tinted box of figures in the sky. The recto carries the standfirst and the first two columns, with a pull quote across the gutter and a straw skep cut out of its background, the lines of the second column following its dome. The story then runs on to as many pages as it needs, three columns each, and ends where it ends. The Spanish, English and German editions are the same template with other words, and German runs its long compounds through 60 mm columns.
This recipe answers
- How do I thread a magazine article through linked frames across several pages?
- How do I lay out a magazine in sections, each article opening on a spread with its lead photo on the facing page?
- Can Postext set three or more text columns, or wrap text around an image?
The short answer
const opening = {
id: 'apertura',
spread: true,
header: false,
frames: [
{ name: 'titulo', takes: 'h1', layer: 2, width: mm(150),
placement: at('container', 'bottom-left', 4, -14) },
{ name: 'datos', style: 'datos', layer: 2, width: mm(64),
placement: at('container', 'top-left', 4, 6) },
{ name: 'entradilla', width: mm(2 * COLUMN + GAP),
placement: at('container', 'top-left', RECTO) },
// The story names no slot, so it goes to the flow frame, then on down the chain.
{ name: 'col-1', flow: true, next: 'col-2', width: mm(COLUMN), height: 'fill',
placement: at('#entradilla', 'below', 0, 7) },
// What the last column cannot hold goes on to a page added after the spread.
{ name: 'col-2', width: mm(COLUMN), height: 'fill',
placement: at('#col-1', 'right-of', GAP),
overflow: { continueIn: 'template:seguido' } },
...pushers,
],
decoration: { elements: [
{ kind: 'image', id: 'foto', resourceId: '{attr.foto}',
fit: 'cover',
placement: { ...at('bleed', 'top-left'), size: { width: mm(W), height: 'fill' } } },
{ kind: 'text', id: 'seccion', content: '{attr.seccion}', fontFamily: SANS, fontSize: pt(9),
fontWeight: 700, letterSpacing: pt(2), textTransform: 'uppercase', color: col('paper'),
placement: at('#titulo', 'above', 0, -3) },
] },
};
The opening spread: a story in two chained columns that goes on
Ingredients
- Features
- Threaded text framesFrames that push text, by box or contourComposed pagesMirrored marginsPictures in page designsHyphenation and document languageRunning heads and foliosParagraph stylesDrop caps in openersCallout boxesSemantic colour paletteFigures and tables as resourcesPages on a canvasPDF export
- Also uses
- Drop caps in body paragraphsSpread templatesFrames continued on the next pageDecoration anchored to framesFigures exactly hereFonts embedded in the PDFCustom resource types
- Type
- Literata, Fraunces, Instrument Sans (SIL OFL 1.1)
- Assets
rooftop-1400.jpgskep-720.png- Painted hives on a factory roof at sunrise (the opening spread) (Generated With Diffusion Models, original)
- A straw bee skep on a transparent ground (the cut-out the text runs round) (Generated With Diffusion Models, original)
Method
#1 · One template, one story
The code is the short answer above. The whole feature is one ::::page{template="apertura" spread} fence: the heading goes to the frame that takes: 'h1', the figures and the standfirst to their slots, and everything else, which names no slot, to the flow frame col-1. When col-1 is full the text goes on in col-2, broken again at its width, and what col-2 cannot hold goes on to a page added after the spread (overflow.continueIn: 'template:seguido'), after the words Continued in the reader's language. The text names no column and no page: cut a paragraph and every line after it moves back.
#2 · The pages the story adds
// The third column continues into this same template: the story goes on in the frame its
// chain starts in, so every added page fills all three columns.
const seguido = {
id: 'seguido',
frames: [
{ name: 'seguido-1', flow: true, next: 'seguido-2', height: 'fill', width: mm(60.3) },
{ name: 'seguido-2', next: 'seguido-3', height: 'fill', width: mm(60.3),
placement: at('#seguido-1', 'right-of', 5) },
{ name: 'seguido-3', height: 'fill', width: mm(60.3),
placement: at('#seguido-2', 'right-of', 5),
overflow: { continueIn: 'template:seguido' } },
],
};
Each added page is three chained columns of 60.3 mm, and one template serves all of them. The third column continues into this same template, and the story goes on in the frame its chain starts in, seguido-1: every added page fills all three columns, however many it takes. Nothing has to pin the type size either: a frame that can go on to another page goes on before the text is set smaller, so a story five lines too long gets a new page, not 92.5 % on its last.
#3 · Two frames that push the columns aside
const pushers = [
// The pull quote straddles the gutter: each column loses the side it covers.
{ name: 'cita', style: 'cita', exclude: 'push', width: mm(62),
placement: at('#entradilla', 'below', COLUMN - 27.5, 82) },
// The skep's frame pushes with the shape of its picture, read from the PNG's alpha.
{ name: 'recorte', exclude: 'push', wrap: 'contour', layer: 2, width: mm(58),
placement: at('container', 'bottom-right', 9, -8) },
];
Neither frame takes part in the story: each pushes the lines of the columns it overlaps. The pull quote is anchored to the standfirst, 82 mm down, and straddles the gutter, so the first column loses its right side and the second its left. The skep's frame has wrap: 'contour': the lines beside it are set as short as the picture is wide at their height, plus a 2.5 mm margin, so the second column follows the dome and runs full width again under its base.
#4 · An outline that travels with the picture
const photo = { id: 'azotea', typeId: 'foto', kind: 'bitmap', createdAt: 0, updatedAt: 0,
caption: '', altText: t({
es: 'Seis colmenas de colores en la azotea de una fábrica, con la ciudad al amanecer',
en: 'Six painted hives on a factory roof, with the city behind them at sunrise',
de: 'Sechs bunte Bienenkästen auf einem Fabrikdach, dahinter die Stadt im Morgenlicht' }),
bitmap: { fileId: 'rooftop-1400.jpg', format: 'jpeg', width: 1400, height: 1848 } };
let skep = { id: 'cesto', typeId: 'foto', kind: 'bitmap', createdAt: 0, updatedAt: 0,
caption: '', altText: t({ es: 'Un cesto de paja para abejas', en: 'A straw bee skep',
de: 'Ein Bienenkorb aus Stroh' }),
contour: { threshold: 0.5, margin: mm(2.5) },
bitmap: { fileId: 'skep-720.png', format: 'png', width: 720, height: 828 } };
await loadImage('rooftop-1400.jpg', asset('rooftop-1400.jpg'));
await loadImage('skep-720.png', asset('skep-720.png'));
// The layout reads pictures by size, never by pixels: the outline travels as a trace.
const trace = await traceResourceContour(skep, imageBytes('skep-720.png'), 'image/png');
skep = withContourTrace(skep, trace);
const resources = [photo, skep];
The layout reads a picture by its size, never by its pixels, so the outline comes from the PNG's alpha channel once, with traceResourceContour, and travels on the resource as contour.traced. The skep is a 720 px PNG with 200 colours and a transparent ground (225 KB). The photograph on the verso is a decoration image, resourceId: '{attr.foto}', so the fence chooses the picture and the template its place. It is set with fit: 'cover': whatever the photograph's proportions, it fills the verso and the box crops what runs past it.
#5 · Running heads that read the fence
const head = (id, content, parity, edge, x, extra = {}) => ({
kind: 'text', id, content, parity, fontFamily: SANS, fontSize: pt(7.5), fontWeight: 600,
letterSpacing: pt(1.2), textTransform: 'uppercase', color: col('muted'),
placement: at('page', edge, x, 11), ...extra,
});
const folio = { fontWeight: 700, color: col('honey') };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUT, folio),
head('verso-title', '{title}', 'even', 'top-left', OUT + 9),
head('recto-title', '{attr.seccion}', 'odd', 'top-right', -(OUT + 9)),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUT, folio),
] };
The opening spread hides the running heads (header: false); the added pages print the magazine's name on the verso and the section on the recto. The section comes from the fence, seccion="City", which {attr.seccion} reads on the pages the story adds as on the spread itself.
The whole recipe
// ═══ Postext Cookbook · Nº 160 · A magazine feature threaded through frames ═════
// https://postext.dev/en/cookbook/magazine-threaded-frames
// Code: MIT · Text: original (CC BY 4.0) · Pictures: Generated With Diffusion Models
// Fonts: Literata, Fraunces, Instrument Sans (SIL OFL 1.1) · Needs postext ≥ 1.65.0
//
// A six-page feature of an invented city magazine, set as one composed page: an opening
// spread whose frames are drawn in the config, and pages the text adds as it runs on.
// Every word, the photo's id and the section name are in content.<lang>.md.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
traceResourceContour, withContourTrace,
} 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' | 'de')
const RECIPE = 'magazine-threaded-frames';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: honey on warm paper, every colour linked by id
const palette = {
ink: '#211c18', // text
honey: '#a65a12', // the accent: kickers, rules, the drop cap, the pull quote
tint: '#f5ecdc', // the fact box
rule: '#d8c6a6', // hairlines
muted: '#6b6158', // running heads, credits
paper: '#ffffff',
shade: '#1a1612', // the plate under the headline on the photo
};
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: 'honey (defaults)', value: { hex: palette.honey, model: 'hex' } },
];
// #endregion
const SERIF = 'Literata';
const DISPLAY = 'Fraunces';
const SANS = 'Instrument Sans';
const W = 225; // trim width in mm; the spread's sheet is twice as wide
const IN = 16; // inner margin
const OUT = 18; // outer margin
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
// The spread's content area runs from the verso's outer margin to the recto's: a frame
// on the recto starts RECTO mm in from its left edge.
const RECTO = W - OUT + IN;
const COLUMN = 92; // the two columns of the recto
const GAP = 7;
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
#Wrap the skep by its box
Without wrap: 'contour' the frame pushes with its rectangle, and the lines beside the dome stop at a straight edge.
- { name: 'recorte', exclude: 'push', wrap: 'contour', layer: 2, width: mm(58),
+ { name: 'recorte', exclude: 'push', layer: 2, width: mm(58),#Drop the continuation mark
mark: false ends the cut piece on its last line, without the words Continued: the column holds one line more.
- overflow: { continueIn: 'template:seguido' } },
+ overflow: { continueIn: 'template:seguido', mark: false } },Pitfalls
- A heading the template sends to a frame of its own opens no drop cap in the text frames. The first paragraph of the story is wrapped in
:::paragraphs{style="inicio"}, and the style carries thedropCap.
Credits
- Recipe
- Ignacio Ferro
- Text
- Original prose, CC BY 4.0
- Images
- Painted hives on a factory roof at sunrise (the opening spread) · Generated With Diffusion Models · original
- A straw bee skep on a transparent ground (the cut-out the text runs round) · Generated With Diffusion Models · original
- Fonts
- Literata (SIL OFL 1.1) · Fraunces (SIL OFL 1.1) · Instrument Sans (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


