Skip to main content
Recipe number 13

Cookbook · Chapter 1 · Page & grid

A book page on a baseline grid

A mirrored two-column page whose text block is exactly 44 leads tall, so the body text sits on one grid across the gutter and the spine.

p. 9 · 1 of 3

  • Trim 210 × 280 mm
  • 2 columns, 6 mm gutter
  • Vollkorn 9.8/13.4
  • Playfair Display
  • Vollkorn SC
  • 3 pages
  • Level
  • Postext 1.57.1
  • Laid out in 82 ms
  • 217 lines of code

In short

Three pages of an essay about how old books were laid out. It shows how to make every line of text sit at the same height across both columns and both facing pages.

What you'll build

Pages 9 to 11 of The Ruled Page, a collection on bookmaking, hold “The Secret Canon”, an essay on the proportions medieval scribes gave their pages. Its margins follow the canon it describes, 2:3:4:6 and mirrored, on a 210 × 280 mm trim around two columns of Vollkorn. A baseline grid is drawn over the pages in pale red, and the body text of both columns and both facing pages stands on it. The Playfair Display title fills the first column of the opener and the drawing of the canon heads the second. Section heads sit half a line off the grid, and the text under them goes back onto it. A workshop note in smaller type runs on a 10 pt leading of its own. On page 11 the essay ends under a page-wide figure in two columns cut to the same length, and the colophon closes the second.

This recipe answers

  • How do I set up a book page: trim size, mirrored inner and outer margins, two columns and a gutter?
  • How do I lock text to a baseline grid so lines align across columns and facing pages?
  • How do I get flush column bottoms and a balanced last page (vertical justification)?
  • How do I avoid widows, orphans and one-word last lines (runts), and keep a heading with its text?

The short answer

script.js · lines 32–53in full code
const LEAD = 13.4; // pt: the body leading is the pitch of the baseline grid
const UNIT = 8; // mm: the margins step 2:3:4:6 in units of 8 mm, like the canon's
const LINES = 44; // lines per column: the text block is a whole number of leads tall
const TRIM = { width: 210, height: 280 }; // mm
const MM_PER_PT = 25.4 / 72;
const page = {
  sizePreset: 'custom', width: mm(TRIM.width), height: mm(TRIM.height), dpi: 150,
  backgroundColor: col('paper'),
  margins: { mirror: true, // left is the inner margin; mirror swaps it on every verso
    left: mm(2 * UNIT), top: mm(3 * UNIT), right: mm(4 * UNIT), // 16, 24 and 32 mm
    bottom: mm(TRIM.height - 3 * UNIT - LINES * LEAD * MM_PER_PT) }, // 48 mm: six units
  // The layout keeps to the grid whether or not the overlay draws it.
  baselineGrid: { enabled: true, color: col('grid') },
};
const GUTTER = 6; // mm: 162 mm of text block make two columns of 78 mm
const layout = { layoutType: 'double', gutterWidth: mm(GUTTER),
  columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.4) } };
const body = { fontFamily: 'Vollkorn', fontSize: pt(9.8), lineHeight: pt(LEAD) };
// Lists add no space of their own (any whole number of leads would do). The grid never
// absorbs a list's top margin: the default 1.5 em (14.7 pt here) would set the items
// 1.3 pt off the lines of the column beside them, until the list reaches a new column.
const onGrid = { marginTop: pt(0), marginBottom: pt(0) };

One grid for the whole spread: trim, mirrored margins, two columns, leading

Ingredients

Type
Vollkorn, Playfair Display, Vollkorn SC (SIL OFL 1.1)
Assets
  • The two drawings, made in code in the page's palette (Postext Cookbook, CC BY 4.0)

Method

#1 · Let heads leave the grid, never lists

script.js · lines 99–112in full code
  headings: { fontFamily: 'Playfair Display', color: col('ink'), balancing,
    levels: [
      // parity 'odd': the essay opens on a recto.
      // Two lines of 46 pt, each four leads tall, then one lead: the text starts on line 10.
      { level: 1, breakBefore: { enabled: true, parity: 'odd' },
        fontSize: pt(46), lineHeight: pt(4 * LEAD), italic: true, color: col('rubric'),
        marginBottom: pt(LEAD) },
      // A lead and a half above puts the head between two grid lines. The margin below
      // needs no fitting: the engine snaps the text under a head to the next grid line.
      { level: 2, fontSize: pt(12.5), lineHeight: pt(LEAD), marginTop: pt(1.5 * LEAD) },
    ] },
  // Lists add no space of their own (onGrid, in the short answer): items stay on the grid.
  unorderedLists: { ...onGrid, bulletChar: '–', color: col('rubric'), fontWeight: 400 },
  orderedLists: { ...onGrid, color: col('rubric') }, // numbers in the rubric, text in ink

The space above a heading is kept exactly as set, so 1.5 leads put the heading between two grid lines, and the text under it is snapped to the next line (baseline grid). A list is not snapped before its first item, so the short answer sets list margins to zero (any whole number of leads would also work); with the default 1.5 em, the three items on page 10 would sit 1.3 pt below the lines of the column beside them. The title’s two lines of 46 pt take four leads each and its bottom margin one more, so the essay starts on line 10.

Page 10: the list in the second column keeps to the grid of the paragraphs beside it; the workshop note falls between the grid lines, and the heading under it sits half a line off them, with its text back on the grid.

#2 · Leave the grid on purpose, and come back

script.js · lines 115–120in full code
  paragraphStyles: [
    { id: 'note', fontSize: pt(7.8), lineHeight: pt(10), color: col('muted'),
      boldColor: col('rubric'), firstLineIndent: pt(0), marginTop: pt(LEAD / 2) },
    { id: 'colophon', fontFamily: 'Vollkorn SC', fontSize: pt(7.5), lineHeight: pt(10),
      color: col('muted'), textAlign: 'left', firstLineIndent: pt(0), marginTop: pt(LEAD) },
  ],

The note is a :::paragraphs container set 7.8 on 10 pt, off the grid. After its last paragraph the position is rounded up to the next grid line, so the heading that follows sits where it would after body text (the :::paragraphs container). The colophon uses the same container at 7.5 on 10 pt: its four lines take 40 pt, 0.2 pt short of three leads, so the essay’s last column ends level with the one beside it.

#3 · Place the figures where the grid can absorb them

script.js · lines 319–332in full code
// mm: a column wide and just short enough for a 17-lead band with its caption; a block wide
const CANON = [COLUMN_W, 61.8], PAGES = [BLOCK_W, 64];
const figure = (id, [width, height], placement, [caption, altText]) => ({
  id, typeId: 'figure', kind: 'svg', svg: { fileId: `${id}.svg`, width, height },
  placement, caption, altText, createdAt: 0, updatedAt: 0,
});
const resources = [
  // A float never lands above the paragraph that cites it. A column 'top' float cited in
  // the first column can still take the head of the second, on the same page.
  figure('canon', CANON, { position: 'top' }, t(CAPTIONS.canon)),
  // A page-wide 'top' float cannot, so it waits for the next page (gotcha: top-float-next-page).
  // Each band is rounded up to whole leads, so the text under it stays on the grid.
  figure('pages', PAGES, { position: 'top', span: 'page' }, t(CAPTIONS.pages)),
];

A float never lands above the paragraph that cites it (placement). The canon, cited in the first column, can still take the head of the second on page 9; the page-wide comparison, cited on page 10, waits for page 11. Each band is rounded up to whole leads, so the text under a drawing starts on a grid line, level with the column beside it and with the facing page. Size a drawing to that rounding: at 61.8 mm the canon’s band, caption included, takes 17 leads; at 62.5 mm it would take 18 and leave almost a line of white under the caption.

Page 11: the text under the page-wide figure starts on a grid line, and the essay ends in two level columns, the colophon closing the second.

#4 · Let balancing square the columns

script.js · lines 86–87in full code
// On by default: it fills a column a keep rule leaves short, and cuts the last page level.
const balancing = { enabled: true };

Every full column on pages 9 and 10 ends on line 44, because the text block is exactly 44 leads and the copy was fitted to it. Keep-with-next and the widow, orphan and runt rules are on by default. When one of them ends a column a line short, balancing puts the missing space above an earlier heading (column balancing), where it shows as a gap, so fit the copy until balancing has nothing to fill. On the last page it divides the remaining lines so that both columns end on the same line.

#5 · Mirror the margins, and number from page 9

script.js · lines 57–82in full code
const OUTER = 4 * UNIT; // mm: the heads end where the text block does
const RISE = 1.5 * UNIT; // mm: heads 12 mm into the head margin; the drop folio 12 mm below
const TAB = 7; // mm from a folio to the title beside it
const onPage = (edge, x) => ({ anchor: { to: 'page', edge },
  offset: { x: mm(x), y: mm(RISE) } });
const head = (id, content, parity, placement, extra = {}) => ({
  kind: 'text', id, content, parity, placement, pages: 'body', // never on the opener
  fontFamily: 'Vollkorn SC', fontSize: pt(8.5), fontWeight: 600, letterSpacing: pt(0.8),
  color: col('muted'), ...extra,
});
const folio = { fontFamily: 'Vollkorn', fontWeight: 700, letterSpacing: pt(0),
  color: col('rubric') };
const header = { elements: [
  head('verso-folio', '{pageNumber}', 'even', onPage('top-left', OUTER), folio),
  head('verso-title', '{title}', 'even', onPage('top-left', OUTER + TAB)),
  head('recto-title', '{chapterTitle}', 'odd', onPage('top-right', -(OUTER + TAB))),
  head('recto-folio', '{pageNumber}', 'odd', onPage('top-right', -OUTER), folio),
] };
// The opener drops its folio into the foot margin, centred under the text block.
const underBlock = { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(RISE) } };
const footer = { elements: [
  head('drop-folio', '{pageNumber}', 'all', underBlock, { ...folio, pages: 'opener' }),
] };
// startAt prints the folios from 9; pageIndexOffset counts the 8 pages before them, so
// mirroring, parity and breakBefore follow the book (7 would add a blank page).
const continuation = { pageIndexOffset: 8, pageNumbering: { startAt: 9 } };

The short answer computes the foot margin: the 280 mm trim less the 24 mm head margin and a text block of exactly LINES leads (44 × 13.4 pt = 208 mm) leaves 48 mm, six units, as the 2:3:4:6 progression requires. With mirror: true the 16 mm set as left is the inner margin, on the left of a recto and on the right of a verso (mirrored margins), so heads anchored OUTER millimetres from the page edge end where the text block does, on the fore-edge side; pages: 'body' keeps them off the opener. startAt: 9 prints folios 9 to 11, and pageIndexOffset: 8 counts the eight pages before them, so mirroring, the heads’ parity and breakBefore: 'odd' follow the bound book. With an offset of 7 the first page would count as a verso, and the odd-page break would put a blank page before the essay.

The whole recipe

Sandbox
// ═══ Postext Cookbook · Nº 013 · A book page on a baseline grid ═════════════════════
// https://postext.dev/en/cookbook/baseline-grid-book-page
// Code: MIT · Text: original (CC BY 4.0) · Pictures: drawn in code (CC BY 4.0)
// Fonts: Vollkorn, Playfair Display, Vollkorn SC (SIL OFL 1.1) · Needs postext ≥ 1.46.2
// An essay on the canon of page proportions, on a page that shows its geometry and grid.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the sample document's language ('en' | 'es' | 'pt' | 'fr' | 'de' | 'it')
const RECIPE = 'baseline-grid-book-page';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// A scribe's colours: ink, one rubric red and the pale red of a ruled page.
const palette = {
  ink: '#211d1a', // text: a warm near-black
  rubric: '#b3261e', // the one accent: title, numbers, folios, the drawings' lines
  grid: '#efc6bd', // the baseline grid, as pale as a manuscript's ruling
  rule: '#d5cbbb', // the column rule and the drawings' hairlines
  muted: '#716860', // running heads, the workshop note, the colophon (5.1:1 on paper)
  tint: '#ede4d3', // the ground of the drawings
  paper: '#fbf8f1',
};
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' } })),
  // Defaults this config does not restate link to main-color: point it at the rubric.
  { id: 'main-color', name: 'rubric (defaults)', value: { hex: palette.rubric, model: 'hex' } },
];

// #region answer: one grid for the whole spread: trim, mirrored margins, two columns, leading
const LEAD = 13.4; // pt: the body leading is the pitch of the baseline grid
const UNIT = 8; // mm: the margins step 2:3:4:6 in units of 8 mm, like the canon's
const LINES = 44; // lines per column: the text block is a whole number of leads tall
const TRIM = { width: 210, height: 280 }; // mm
const MM_PER_PT = 25.4 / 72;
const page = {
  sizePreset: 'custom', width: mm(TRIM.width), height: mm(TRIM.height), dpi: 150,
  backgroundColor: col('paper'),
  margins: { mirror: true, // left is the inner margin; mirror swaps it on every verso
    left: mm(2 * UNIT), top: mm(3 * UNIT), right: mm(4 * UNIT), // 16, 24 and 32 mm
    bottom: mm(TRIM.height - 3 * UNIT - LINES * LEAD * MM_PER_PT) }, // 48 mm: six units
  // The layout keeps to the grid whether or not the overlay draws it.
  baselineGrid: { enabled: true, color: col('grid') },
};
const GUTTER = 6; // mm: 162 mm of text block make two columns of 78 mm
const layout = { layoutType: 'double', gutterWidth: mm(GUTTER),
  columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.4) } };

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

#Hide the grid for the printer

enabled only controls the lines drawn over the finished pages; the layout keeps to the 13.4 pt grid either way, so no line moves.

-  baselineGrid: { enabled: true, color: col('grid') },
+  baselineGrid: { enabled: false },

#See what balancing does

With balancing off, page 11 runs its last eight lines and the colophon down the first column and leaves the second empty.

-const balancing = { enabled: true };
+const balancing = { enabled: false };

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 →

  • The rule that a top float never lands on its citing page holds for page-wide floats. A column top float can land on its citing page, at the head of a later column, as Figure 1.1 does on page 9.
  • Page sizes, margins and the gutter take absolute units (mm, pt, cm, in). An em there has no type size to measure against, and the build stops with “dimensionToPx: baseFontSizePx is required for unit "em"”.
  • Vollkorn’s word space is narrow, 0.2 em, so in a column of about 50 characters some justified lines come out loose or tight. The sample was fitted line by line against the capture’s loose-line report; check it again after any change to the text or the measure.

Credits

Text
  • The essay “The Secret Canon” and its Spanish version “El canon secreto”, written for this recipe · Postext Cookbook · CC BY 4.0
Images
  • The two drawings, made in code in the page's palette · Postext Cookbook · CC BY 4.0
Fonts
Vollkorn (SIL OFL 1.1) · Playfair Display (SIL OFL 1.1) · Vollkorn SC (SIL OFL 1.1)
Sandbox