In short
A two-page newsletter for a gardening club. The main story fills a wide column and continues on page 2, while short news items fill a narrow column beside it.
What you'll build
The spring issue of The Allotment Gazette, the newsletter of an invented allotment society, printed on both sides of one A4 sheet. A straw band carries the name in Titan One on two lines, a row of seedlings along its foot and a tomato tab with the issue number and season. Below it the page divides into a 113 mm column and a 57 mm one. The lead story, about three new compost bays, fills the wide column under a plan of the site drawn in code and stops at a “Continued on page 2” tag. The narrow column holds five briefs, each opening with pill-shaped tags. Page 2 picks the story up under a jump head and centres a temperature chart in the column. Further down, the paragraph about a planting bed runs beside its drawing, set at the right of the column. Eight notices fill the narrow column.
This recipe answers
- How do I make a column-and-a-half layout, with a wide text column and a narrow side column?
- Can Postext set three or more text columns, or wrap text around an image?
- How do I put two columns inside a box (a text column beside a figure column)?
- How do I make inline chips: keyboard keys, tags, word banks for exercises?
The short answer
const layout = {
layoutType: 'oneAndHalf', // the narrow column sits on the right and takes text (the
// defaults of sideColumnSide and sideColumnRole; 'floats' would keep text out of it)
sideColumnPercent: 32, // 57 mm of the 178 mm measure
gutterWidth: mm(8), // the wide column keeps the other 113 mm
columnRule: { enabled: true, color: col('rule') }, // a 0.5 pt hairline in the gutter
};
// The text runs down the wide column, then the narrow one, then the next page's wide
// column. A :::columnbreak sends the next block on to the following column, so the
// Markdown decides what each column holds:
// ## Shared compost bays open by the top gate ← the lead, in the wide column
// … :chip[Continued on page 2]{style="jump"}
// :::columnbreak ← the briefs open the narrow column
// ## In brief {style="rail"}
// …
// :::columnbreak ← from the last column: next page
// :chip[Continued from page 1]{style="jump"} ← the lead goes on in the wide column
A wide column for the lead, a narrow one for the briefs, one flow
Ingredients
- Features
- Column and a halfPage and column breaksInline chipsText wrap round pictures and boxesHeading stylesFigure placementCallout boxesFigures exactly hereColumn ruleDocument metadataDesigned openersHeading attributesRunning heads and foliosHeads by page roleParagraph stylesCustom resource typesSource and credit linesSemantic colour palettePages on a canvasFigures and tables as resources
- Also uses
- Full-width chapter bandPaper colour
- Type
- Work Sans, Titan One, Courier Prime (SIL OFL 1.1)
- Assets
- The site plan, the temperature chart, the square-metre bed and the row of seedlings under the nameplate, drawn in code in the page's palette (Ignacio Ferro, CC BY 4.0)
Method
#1 · Let the Markdown fill each column
The layout settings are in the short answer above. In a oneAndHalf layout the narrow column takes text by default, and the text runs down the wide column, then the narrow one, then the wide column of the next page (layout types). A :::columnbreak ends a column where it stands (directives): after the lead's “Continued on page 2” tag it opens the narrow column for the briefs, and after the last brief, in the last column of the page, it opens page 2. In this issue both columns of page 1 are fitted to end on the same grid line, 275 mm from the top edge, so deleting either break leaves the pages as they are. The breaks matter once the copy changes. Cut the lead's second paragraph and, without the first break, “In brief” starts 247 mm down the wide column, under the tag, and the first brief runs over into the narrow column, where its second half is broken again for the column's 57 mm measure.
#2 · Build the nameplate from the frontmatter
const BEARING = 0.6; // mm: Titan One's left side bearing at 60 pt (T 0.42, G 0.63, L/H 0.85)
const DRILL = { id: 'drill', typeId: 'drawing', kind: 'svg', createdAt: 0, updatedAt: 0,
svg: { fileId: 'drill.svg', width: 2100, height: 80 } }; // drawn by the design, not the text
const masthead = { enabled: true,
minHeight: pt(10 * LEAD), // ten grid lines: the text starts one line clear of the band
slot: { elements: [
// The band is 62 mm deep. The column rule starts under the masthead, where the text does.
{ kind: 'box', id: 'band', style: { backgroundColor: col('straw') },
placement: { ...at('page', 'top-left'), size: { width: mm(210), height: mm(62) } } },
{ kind: 'image', id: 'drill', resourceId: 'drill', // seedlings along the band's foot
placement: { ...at('page', 'top-left', 0, 54), size: { width: mm(210), height: mm(8) } } },
{ kind: 'text', id: 'society', content: '{subtitle}', ...caps(8, 'leaf'), align: 'left',
placement: { ...at('page', 'top-left', SIDE, 12), size: { width: mm(150) } } },
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: DISPLAY, fontSize: pt(60),
lineHeight: 0.9, // 54 pt from line to line
color: col('leaf'), align: 'left', overflow: 'wrap', // two lines in 178 mm
placement: { ...at('page', 'top-left', SIDE - BEARING, 17), size: { width: mm(178) } } },
// {attr.issue} comes from the H1 line, {publishDate} from the frontmatter.
{ kind: 'text', id: 'tab', content: '{attr.issue} · {publishDate}', ...caps(9, 'paper'),
align: 'right', box: { backgroundColor: col('tomato'),
padding: { top: mm(1.8), right: mm(3.2), bottom: mm(1.6), left: mm(3.2) } },
placement: at('page', 'top-right', -SIDE, 44) },
] } };
The H1 takes a heading style whose design draws the nameplate, and span: 'page' sets that design above both columns. {titleText} at 60 pt breaks into two lines in its 178 mm box. The tab joins {attr.issue}, written on the H1 line, and {publishDate} from the frontmatter (text elements). Without minHeight the masthead would reserve room down to the foot of the band, 62 mm from the top edge, and the text would start on the next grid line, at 62.5 mm, touching the band. A minHeight of ten grid lines starts it at 67 mm.
#3 · Tag the briefs with chips
const chip = (id, look) => ({ id, fontFamily: LABEL, bold: true,
fontSize: pt(7.7), // in points: em(0.82) is 7.7 pt in the text, 6.6 pt on the 8 pt jump lines
borderWidth: pt(0), borderRadius: em(1), // a radius past half the height draws a pill
paddingX: em(0.5), paddingY: em(0.14), ...look }); // em: of the chip's own size
const chipStyles = [
chip('tag', { background: col('tomato'), color: col('paper') }), // the first is the default
chip('free', { background: col('marigold'), color: col('ink') }),
chip('when', { backgroundEnabled: false, borderWidth: pt(0.8), borderColor: col('leaf'),
color: col('leaf') }),
chip('jump', { background: col('straw'), color: col('ink') }),
];
Declaring chipStyles replaces the built-in pale-blue chip, and a chip without a style takes the first one (chip styles). A radius larger than half the box's height draws a pill. A chip never breaks inside, so a line breaks only at the space before or after a chip, and a date like “Sat 11 April” stays on one line. The tags are typed in capitals in the Markdown because chip styles have no letter-case setting. The vertical padding is painted outside the line, so the 13.4 pt grid holds.
#4 · Run the text beside the drawing
// wrap sets the drawing at that side of its column, width of it, and the text after the
// ::resource line runs beside it at the measure left over, then under it at full width:
// #### Sixteen squares by the gate {style="kicker"}
// ::resource{id="bed"} ← 51 mm at the right of the 113 mm column
// The demonstration bed by the gate is 1.2 metres square … ← beside it, then under it
const WRAP = { wrap: 'right', width: 0.45 }; // a body line of white between it and the text
wrap: 'right' sets the bed drawing at the right edge of the 113 mm column, 45 % of it wide (51 mm), and the paragraph after the ::resource line runs beside it at the 57 mm left over, a body line clear of the drawing and its caption (text wrap). The drawing's top is level with the paragraph's first line, and every line stays on the 13.4 pt grid. A longer paragraph would go on under the drawing at the full 113 mm, as one paragraph; a heading or another figure that came while the drawing was still beside the text would go under it. The level-4 head over it takes a heading style that only changes its colour to the leaf green.
#5 · Centre a narrow chart in its band
const drawing = (id, w, h, placement = {}) => ({ id, typeId: 'drawing', kind: 'svg',
svg: { fileId: `${id}.svg`, width: w * 10, height: h * 10 }, // mm × 10: fitted to the column
placement: { position: 'here', ...placement }, // drawn where ::resource{id} stands
caption: CAPTIONS[id][0], note: CAPTIONS[id][1], altText: CAPTIONS[id][2],
createdAt: 0, updatedAt: 0 });
// width is a fraction of the column and align where the figure sits in it: the text above
// and below never moves into the white either side.
const HEAT = { width: 0.62, align: 'center' };
const resources = () => [drawing('plan', 114, 56.5), drawing('heat', 68, 40, HEAT),
drawing('bed', 50, 50, WRAP), DRILL];
// Newsletter drawings carry no "Figure 1": an empty prefix prints no label.
const resourceTypes = [{ id: 'drawing', name: 'Drawing', shortLabel: 'Drawing',
captionPrefix: '', numberingTemplate: '', resetOn: 'never', counterFormat: 'decimal' }];
width: 0.62 sets the chart 70.1 mm wide in the 113 mm column, and align: 'center' leaves 21.5 mm of paper on each side (placement). The text above and below keeps the full measure and never flows into that white. The drawings belong to a resource type with an empty captionPrefix, so each caption starts with its own bold words, with no “Figure 1” before them.
The whole recipe
// ═══ Postext Cookbook · Nº 042 · Community newsletter: lead story and briefs ═════
// https://postext.dev/en/cookbook/community-newsletter
// Code: MIT · Text: original (CC BY 4.0) · Drawings: generated in code (CC BY 4.0)
// Fonts: Work Sans, Titan One, Courier Prime (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, inlineSvgFonts,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'community-newsletter';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: garden colours, every one linked by id
// ink: text · leaf: nameplate and headlines · tomato, the accent: tags, tab, column heads ·
// straw: the band · marigold: second tag · tint: pale greens · rule: hairlines · muted: notes
const palette = { ink: '#1d211c', leaf: '#2f6b3a', tomato: '#c43f2a', straw: '#f2d492',
marigold: '#e2b33c', tint: '#eef4e8', rule: '#cfd3c6', muted: '#5f6659', paper: '#fbfaf5' };
// Each colour carries its hex and the palette entry it follows.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [ // defaults link to 'main-color': point it at the leaf, never blue
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'leaf (defaults)', value: { hex: palette.leaf, model: 'hex' } },
];
// #endregion
const [TEXT, DISPLAY, LABEL] = ['Work Sans', 'Titan One', 'Courier Prime'];
const SIDE = 16; // mm: the side margins of one A4 sheet, printed on both sides
const LEAD = 13.4; // body leading in pt: the baseline grid
const caps = (size, colour) => ({ fontFamily: LABEL, fontSize: pt(size), fontWeight: 700,
textTransform: 'uppercase', letterSpacing: pt(size * 0.12), color: col(colour) });
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
// #region answer: a wide column for the lead, a narrow one for the briefs, one flow
const layout = {
layoutType: 'oneAndHalf', // the narrow column sits on the right and takes text (the
// defaults of sideColumnSide and sideColumnRole; 'floats' would keep text out of it)
sideColumnPercent: 32, // 57 mm of the 178 mm measure
gutterWidth: mm(8), // the wide column keeps the other 113 mm
columnRule: { enabled: true, color: col('rule') }, // a 0.5 pt hairline in the gutter
};
// The text runs down the wide column, then the narrow one, then the next page's wide
// column. A :::columnbreak sends the next block on to the following column, so the
// Markdown decides what each column holds:
// ## Shared compost bays open by the top gate ← the lead, in the wide column
// … :chip[Continued on page 2]{style="jump"}
// :::columnbreak ← the briefs open the narrow column
// ## In brief {style="rail"}
// …
// :::columnbreak ← from the last column: next page
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
#Put the briefs on the left
The wide column still reads first, so the same Markdown sets the lead on the right and the briefs on the left.
layoutType: 'oneAndHalf',
+ sideColumnSide: 'left',#Set the briefs across the page
Body text runs in two columns at most. The newspaper front page runs four briefs across the foot of the page in a box with :::columns{count=4}.
Credits
- Recipe
- Ignacio Ferro
- Text
- Original prose, CC BY 4.0
- Images
- The site plan, the temperature chart, the square-metre bed and the row of seedlings under the nameplate, drawn in code in the page's palette · Ignacio Ferro · CC BY 4.0
- Fonts
- Work Sans (SIL OFL 1.1) · Titan One (SIL OFL 1.1) · Courier Prime (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


