In short
The front page and page 2 of a local weekly newspaper. It shows how to run big headlines across the full page and place a strip of short news items at the bottom.
What you'll build
The front page and page 2 of The Elverdale Courier, an invented valley weekly, on a 246 × 328 mm sheet. A blackletter nameplate sits between a weather ear and a price ear, over a thick and a thin rule and the dateline. The lead story opens with a two-line banner in Libre Franklin Black at 56 pt across both columns, an italic deck and a photo band 222 mm wide, then runs in two justified columns parted by a hairline. At the foot, four briefs share a tinted strip, one to a column, each led by a red chip. Page 2 opens on a red section flag and holds the bridge story with a drawing made in code, a five-day forecast at the head of the right column, a second headline across the page, the letters and a table of the ward votes with a bar in every row.
This recipe answers
- Can Postext set three or more text columns, or wrap text around an image?
- How do I set a box across both columns mid-page, such as a 3-up "in numbers" panel?
- How do I control where a figure goes: top of page, across both columns, exactly here, or in the margin?
- How do I set a chapter title across the page while the body runs in two columns below?
The short answer
const layout = { layoutType: 'double', gutterWidth: mm(GUTTER), // the body of every page
columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.5) } };
// The strip is a tinted, titled box, so its four columns are a :::columns group in a :::callout.
// The fence spans the page and floats the box to the foot, so the story fills the columns above:
// :::callout{type="briefs" span="page" placement="bottom" title="In brief"}
// :::columns{count=4 breaks="2,3,4"} ← each brief opens a column (child 2, 3 and 4)
// …four paragraphs…
// :::
// :::
// The style could carry span and placement too; on the fence they stay in sight in the text.
// hook-up: config() takes layout as it is and lists briefs in calloutStyles.
const briefs = { id: 'briefs',
background: col('tint'), // one device: a tint, no stripe or border
padding: { top: mm(3), right: mm(4), bottom: mm(4), left: mm(4) },
columnGap: mm(GUTTER), // the inner columns keep the page's gutter
titleStyle: { ...caps(9, 800, 'flag'), gap: mm(2) },
body: { fontFamily: 'PT Serif', fontSize: pt(8.6), lineHeight: pt(11.4), textAlign: 'left',
firstLineIndent: pt(0) } }; // ragged and unindented, unlike the columns
A two-column body, and the four-up strip as a box with columns of its own
Ingredients
- Features
- Boxes across the pageColumns in a box or in the textFloated boxesDesigned openersFull-width chapter bandHeading stylesHeading attributesAnchoring design elementsText, rules and boxes in page designsRunning heads and foliosColumn ruleCallout boxesInline chipsParagraph stylesFigure placementFigures exactly hereText wrap round pictures and boxesNamed table stylesCustom resource typesPictures in table cells
- Also uses
- Citations that place figuresPaper colourPage and column breaksFigures and tables as resourcesRunning heads per section
- Type
- Grenze Gotisch, PT Serif, Libre Franklin (SIL OFL 1.1)
- Assets
ridge-2400.jpg- Wind turbines on a snowy ridge (the front-page photograph, cropped to a band) (Jason Blackeye, CC0 1.0)
- The bridge drawing and the bars in the ward table, drawn in code in the page's palette (Ignacio Ferro, CC BY 4.0)
Method
#1 · Newsprint, ink and one red
const palette = {
ink: '#111315', // text and the heavy rules: a cold near-black
paper: '#f8f5ee', // newsprint, and type reversed out of ink or red
flag: '#a6192e', // the one accent: section flags, kickers, the Yes bars
tint: '#ebe6db', // the In brief strip
rule: '#9a978f', // hairlines: the column rule, table rules
muted: '#5d5a55', // bylines, the folio line's title and date, credit notes, the imprint
};
// Every colour is linked to its palette entry by id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [ // defaults link to 'main-color': point it at the ink, never blue
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
The page is newsprint (#f8f5ee) and the type near-black ink (#111315). The one red, #a6192e, goes on the section flags, the kickers, the chips and the yes bars. Each colour is linked to its palette entry through paletteId. main-color points at the ink, so the bold, the italics, the two references on page 2 and every default the config leaves alone print in ink; left at its own value, they would print in the default blue, #295AA3.
#2 · The nameplate is the front page's H1
const NAME = 52; // pt: the blackletter nameplate
const EAR = 31; // mm: each ear, in the room the nameplate leaves at either side
const EAR_DROP = 1.8; // mm: measured so the ears' big figures sit on the nameplate's baseline
const AIR = 2; // mm between the lower rule and the masthead's foot, where the banner box starts
const ear = (side, lines) => lines.map(([id, content, look], i) => text(id, content,
{ ...look, align: side }, { ...(i === 0 ? at('container', `top-${side}`, 0, EAR_DROP)
: at(`#${lines[i - 1][0]}`, 'below', 0, 1)), size: { width: mm(EAR) } }));
const serif = { fontFamily: 'PT Serif', fontSize: pt(9), italic: true, color: col('ink'),
lineHeight: 1.25 };
const nameplate = { enabled: true, slot: { elements: [
depth(7), // the masthead is seven grid lines deep; the rules and dateline hang from its foot
{ kind: 'rule', id: 'foot', thickness: pt(0.5), color: col('ink'),
placement: { ...at('#depth', 'align-bottom', 0, -AIR), size: { width: 'fill' } } },
...[['left', '{attr.issue}'], ['center', '{publishDate}'], ['right', '{attr.area}']].map(
([align, content]) => text(`date-${align}`, content, { ...caps(7.5, 600), align },
{ ...at('#foot', 'above', 0, -1.4), size: { width: 'fill' } })),
rule('thin', '#date-left', 0.5, 1.6), rule('heavy', '#thin', 2.5, 0.6), // the Oxford rule
text('name', '{titleText}', { fontFamily: 'Grenze Gotisch', fontSize: pt(NAME),
fontWeight: 700, lineHeight: 1, align: 'center' },
{ ...at('#heavy', 'above', 0, -1.2), size: { width: 'fill' } }), // centred between the ears
...ear('left', [['w-kicker', 'Weather', caps(7, 700, 'flag')],
['w-outlook', '{attr.outlook}', serif], ['w-temps', '{attr.temps}', franklin(15, 800)]]),
...ear('right', [['p-kicker', '{attr.since}', caps(7, 700, 'flag')],
['p-day', '{attr.day}', serif], ['p-price', '{attr.price}', franklin(15, 800)]]),
] } };
// hook-up: headingStyles gets { id: 'front', advancedDesign: nameplate, header: { elements:
// [] } }, H1 already spans the page, and the Markdown opens with
// # The Elverdale Courier {style="front" issue="…" area="…" outlook="…" temps="…" since="…"
// day="…" price="…"}
# The Elverdale Courier takes the front heading style, which fills the masthead from the heading's text and seven of its attributes (issue, area, outlook, temps, since, day and price); the date comes from publishDate in the frontmatter. An empty box seven grid lines deep (31.1 mm) sets the height of the opener. The rules, the dateline and the name hang from its foot, so the opener ends on a grid line.
#3 · A headline across both columns is a box
// :::callout{type="banner" span="page" title="Transport"} ← an optional kicker, then the H2
const banner = { id: 'banner', backgroundEnabled: false,
padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
titleStyle: { ...caps(8, 800, 'flag'), gap: mm(1.2) }, // a kicker, when the fence has a title
marginTop: pt(0), // flush under the nameplate or the section flag
marginBottom: pt(LEAD / 2), // half a line, then the columns start on the next grid line
body: { fontFamily: 'PT Serif', fontSize: pt(13), lineHeight: pt(16.5), textAlign: 'left' } };
// A story that starts mid-page: the same box under a rule. The columns above it are cut level.
const story = { ...banner, id: 'story', marginTop: pt(LEAD),
stripe: { enabled: true, side: 'top', width: pt(1), color: col('ink') }, // its one device
padding: { top: mm(2.5), right: pt(0), bottom: pt(0), left: pt(0) } };
// Inside the box the headline is an H2 in a heading style: one size for each rank of story.
const headline = (id, size, look = {}) => ({ id, fontSize: pt(size), lineHeight: pt(size * 1.02),
marginBottom: pt(size * 0.2), ...look }); // tight leading, a fifth of it below
A heading spans both columns only as an opener, and an opener starts a new page. Put span: 'page' on the ward story's H2 instead of its box and that story moves to a third page. A frameless box with span="page" can start mid-page. On page 2 the columns are cut level above it and resume below. The box holds the H2 in one of three heading styles (56, 30 or 22 pt), the italic deck and, on the front page, the photograph. Its marginBottom of half a line starts the columns on the next grid line, 3.4 mm under the deck on page 2. At the default margin the gap is 7.8 mm and the letters run onto a third page.
#4 · The four-column strip is a box with columns
The code for this step is the short answer above. The body of both pages runs in two columns (Layout types). The briefs need four only at the foot of page 1, under a title and on a tint, so they go in a box, here a page-wide one holding a :::columns group. breaks counts the group's blocks, one per brief, so briefs 2, 3 and 4 open columns 2, 3 and 4. Each column is 49 mm wide, with the page's 6 mm gutter between them.
:::callout{type="briefs" span="page" placement="bottom" title="In brief"}
:::columns{count=4 breaks="2,3,4"}
:chip[TRANSPORT]{style="flag"} **Bus 44 back on Sundays.** The Elverdale to Kirkby bus …
:chip[SCHOOLS]{style="flag"} **An orchard for Brook Lane.** Pupils at Brook Lane …
…
:::
:::placement="bottom" floats the box to the foot of page 1, where it takes 36.9 mm, and the story fills the 83 mm of columns above it. The lead photo stays a band across both columns inside the banner box: the text runs beside a picture narrower than its column, on one side of it, never round a picture across two columns. The bridge drawing on page 2 has its text beside it (step 5).
#5 · Pictures inline, tables as floats
// A caption label prints only when captionPrefix has text: '' leaves no "Figure 1".
const unnumbered = (id, name, captionStyle) => ({ id, name, shortLabel: name, captionPrefix: '',
numberingTemplate: '', resetOn: 'never', counterFormat: 'decimal', captionStyle });
const resourceTypes = [unnumbered('picture', 'Picture'), // captions under the picture
unnumbered('panel', 'Panel', { position: 'above', fontSize: pt(9.5) })]; // tables: titled above
const resource = (id, typeId, kind, body, extra) => ({ id, typeId, kind, [kind]: body,
createdAt: 0, updatedAt: 0, ...extra });
const resources = [
// Set inline in the page-span banner box: a 'top' float never lands above the line that
// cites it (gotcha: top-float-next-page). It keeps the float gap above it, inside the box too.
// 2400 px at 150 dpi is 406 mm: the photo shrinks to the box (gotcha: bitmap-print-size).
resource('ridge', 'picture', 'bitmap', { fileId: 'ridge-2400.jpg', format: 'jpeg', width: 2400,
height: 800 }, { placement: { position: 'here' },
altText: 'Wind turbines on a snow-covered ridge under a bright, cloudy sky.',
caption: '**File picture:** turbines on an upland ridge. Each of the three planned for '
+ 'Harrow Ridge would generate 2.3 megawatts.',
note: 'Photograph: Jason Blackeye, CC0, via Wikimedia Commons' }),
// Drawn in code (the art region) and set inline, where ::resource puts it in column 1,
// at the column's right with the next paragraph running beside it (text wrap).
resource('bridge', 'picture', 'svg', { fileId: 'bridge.svg', width: 1190, height: 460 },
{ placement: { position: 'here', wrap: 'right', width: 0.47 },
altText: 'Drawing of a two-arch stone bridge between sloping river banks; under its '
+ 'central pier, a red concrete footing.',
caption: '**The rebuilt pier.** Its new concrete footing (red) goes six metres below the '
+ 'riverbed. Both arches were relaid with their own stones.',
note: 'Drawing: The Courier' }),
// A page-span 'bottom' float sits under both columns of the page that cites it. On the last
// page it follows the balanced columns, so the copy there is fitted to bring it to the foot.
resource('wards', 'panel', 'table', { styleId: 'results', model: resultsTable() },
{ placement: { position: 'bottom', span: 'page' }, caption: '**How the wards voted**',
note: 'Red: yes. Grey: no. The black line marks half the vote. '
+ 'Source: Elverdale Town Council.' }),
// A column 'top' float waits for the head of the next column with room.
resource('forecast', 'panel', 'table', { styleId: 'forecast', model: forecastTable() },
{ placement: { position: 'top', span: 'column' }, caption: '**The next five days**',
note: 'Sunrise 6.57, sunset 19.03 on Thursday. Forecast: Wend Valley Weather Station.' }),
];
The photograph is inline in the banner box because a page-wide top float never lands above the line that cites it; as a float, the photo would open page 2 (see Pitfalls). The bridge drawing is inline too, after the paragraph about the pier, and wrap: 'right' with width: 0.47 sets it at the right of column 1, 47 % of the column wide, the next paragraphs running beside it and then under it at the full measure (text wrap). At that width no line beside it is set loose; the copy of the story was refitted to the shorter drawing. The forecast floats to the head of a column and lands at the top of the right one. The ward table floats under both columns, where the column rule stops. On the last page it sits right under the balanced columns, so the copy above it was fitted to bring it down to the foot. Both resource types set captionPrefix: '', and a caption label prints only when the prefix has text, so no caption starts with "Figure 1".
#6 · An inside page opens on a section flag
const section = { enabled: true, slot: { elements: [
depth(2), // two grid lines: the flag sits on a 3 pt bar, 1.6 mm above the foot
{ kind: 'rule', id: 'bar', thickness: pt(3), color: col('ink'),
placement: { ...at('#depth', 'align-bottom', 0, -1.6), size: { width: 'fill' } } },
text('flag', '{titleText}', { ...caps(11, 800, 'paper'), box: { backgroundColor: col('flag'),
padding: { top: mm(1.3), right: mm(3), bottom: mm(1.1), left: mm(3) } } },
at('#bar', 'above')),
] } };
const FOLIO = 6; // mm from the top edge to the folio line; its rule 4 mm lower
const folio = (parity, side, s) => [ // s: +1 on a verso (folio on the left), −1 on a recto
text(`n-${parity}`, '{pageNumber}', { ...franklin(9, 800), align: side },
at('page', `top-${side}`, s * MARGIN.side, FOLIO)),
text(`t-${parity}`, '{title} · {publishDate}', { ...caps(7, 600, 'muted'), align: side },
at(`#n-${parity}`, s > 0 ? 'right-of' : 'left-of', s * 3, 0.9)),
].map((element) => ({ ...element, parity }));
const header = { elements: [...folio('even', 'left', 1), ...folio('odd', 'right', -1),
{ kind: 'rule', id: 'folio-rule', thickness: pt(0.5), color: col('ink'),
placement: { ...at('page', 'top-left', MARGIN.side, FOLIO + 4), size: { width: mm(TRIM.width
- 2 * MARGIN.side) } } }] };
# Town & Valley is an H1 whose breakBefore has the parity 'any', so the section opens page 2 without a blank page before it. Its design is a red flag on a 3 pt bar, hung from an empty box two grid lines deep. The folio line is a header anchored 6 mm below the top edge of the page, with one version for even pages and one for odd. The front page's style empties the header, so no folio line prints above the nameplate.
The whole recipe
// ═══ Postext Cookbook · Nº 027 · Newspaper front page ═══════════════════════════
// https://postext.dev/en/cookbook/newspaper-front-page
// Code: MIT · Text: original (CC BY 4.0) · Photo: Jason Blackeye (CC0)
// Fonts: Grenze Gotisch, PT Serif, Libre Franklin (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 = 'newspaper-front-page';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: newsprint, ink and one red for the section flags
const palette = {
ink: '#111315', // text and the heavy rules: a cold near-black
paper: '#f8f5ee', // newsprint, and type reversed out of ink or red
flag: '#a6192e', // the one accent: section flags, kickers, the Yes bars
tint: '#ebe6db', // the In brief strip
rule: '#9a978f', // hairlines: the column rule, table rules
muted: '#5d5a55', // bylines, the folio line's title and date, credit notes, the imprint
};
// Every colour is linked to its palette entry by id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [ // defaults link to 'main-color': point it at the ink, never blue
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
// #endregion
const TRIM = { width: 246, height: 328 }; // mm: a 3 : 4 compact, smaller than a tabloid
const MARGIN = { top: 14, bottom: 15, side: 12 }; // newspaper margins: narrow, not mirrored
const GUTTER = 6; // mm between the two body columns, and between the In brief columns
const LEAD = 12.6; // body leading in pt: the baseline grid
const franklin = (size, weight, look = {}) => ({ fontFamily: 'Libre Franklin',
fontSize: pt(size), fontWeight: weight, color: col('ink'), ...look });
const caps = (size, weight, colour = 'ink') => franklin(size, weight, { color: col(colour),
textTransform: 'uppercase', letterSpacing: pt(size * 0.16) }); // capitals tracked 0.16 em
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, align: 'left',
overflow: 'wrap', color: col('ink'), ...look, placement }); // design text defaults to centred
// and black, and a header's text to an ellipsis
// A rule across the slot whose bottom sits `gap` mm above the element it names.
const rule = (id, under, weight, gap = 0) => ({ kind: 'rule', id, thickness: pt(weight),
color: col('ink'), placement: { ...at(under, 'above', 0, -gap), size: { width: 'fill' } } });
// An empty box exactly `lines` grid lines deep sets an opener's depth, and the rest hangs from
// its foot: the opener ends on a grid line, where the columns and their rule begin.
const depth = (lines) => ({ kind: 'box', id: 'depth', style: {}, placement: {
...at('container', 'top-left'), size: { width: 'fill', height: pt(lines * LEAD) } } });
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
#Keep the briefs under the photograph
Without placement="bottom" in content.en.md, the strip stays where its fence is, right under the photograph, and the lead story runs below it to the foot of the page.
-:::callout{type="briefs" span="page" placement="bottom" title="In brief"}
+:::callout{type="briefs" span="page" title="In brief"}Pitfalls
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 →
Pitfall
Bitmaps take their print size from a resolution: declare it, not print-size pixels
A bitmap without a resolution is laid out one pixel per layout pixel at the document's dpi, so a 2400 px photo is 406 mm wide on a 150 dpi page. Declare the file's real pixels and give the picture its resolution (bitmap.resolution: 300), or set layout.bitmapResolution for every bitmap: a ppi, or 'file' to read the one the file states. The column still caps the picture. Figures and tables as resources →
- Give the photograph
placement: { position: 'top', span: 'page' }and it moves off page 1 to stand alone on page 2. The story on page 1 then ends 92 mm above the briefs strip, and the section moves to page 3.
Credits
- Recipe
- Ignacio Ferro
- Text
- Original prose, CC BY 4.0
- Images
- Wind turbines on a snowy ridge (the front-page photograph, cropped to a band) · Jason Blackeye · CC0 1.0
- The bridge drawing and the bars in the ward table, drawn in code in the page's palette · Ignacio Ferro · CC BY 4.0
- Fonts
- Grenze Gotisch (SIL OFL 1.1) · PT Serif (SIL OFL 1.1) · Libre Franklin (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


