Skip to main content
Recipe number 38

Cookbook · Chapter 9 · Complete publications

Trade paperback: sunk openers and recto chapters

The Awakening as a 140 × 216 mm trade paperback: a painted cover and a colophon with no running heads, then chapters sunk on rectos under an italic numeral.

  • Trim 140 × 216 mm
  • 1 column
  • Crimson Pro 10.5/14
  • Cormorant Garamond
  • Cormorant SC
  • 8 pages
  • Level
  • Postext 1.57.1
  • Laid out in 74 ms
  • 196 lines of code

In short

The first two chapters of an American novel as a paperback book. Each chapter starts on a right-hand page, lower down, under a large chapter number.

What you'll build

Eight pages of a 140 × 216 mm trade paperback hold the first two chapters of Kate Chopin’s The Awakening (1899). The cover, a painting generated with diffusion models and loaded as a JPEG, shows the gulf from the Lebrun cottages on Grand Isle: a lugger on the horizon between the water-oaks, and the white sunshade coming up through the camomile. The colophon sits at the foot of its verso. Each chapter opens on a recto with its text 81 mm down, under a 48 pt italic numeral, an 18 mm rust-red hairline and the chapter’s first sentence in small capitals, broken by sense into two centred lines. Chapter I ends on page 5 with a camomile tailpiece, so page 6 stays blank, with no running head or folio, and chapter II opens on page 7. The running heads carry the author on versos and the title in italic on rectos.

This recipe answers

  • How do I force a page or column break, and start every chapter on a right-hand page?
  • How do I add an author line, a standfirst or a lead with a drop cap to an opener?
  • How do I insert deliberate blank pages, or start a section on a fresh spread?
  • How do I set running heads: book title on the left page, chapter title on the right, page number outside?
  • How do I make a cover, a half title, a title page and a colophon?
  • How do I add extra vertical space between two blocks, when blank lines do nothing?
  • How do I set unnumbered artwork: ornaments, vignettes, logos?

The short answer

script.js · lines 47–77in full code
// # I {lead="A green and yellow parrot, … kept repeating over and over:"}
// The heading's text is the numeral, printed by {titleText}; the chapter's first sentence
// travels as the heading's lead attribute, printed by {attr.lead} in small capitals: a
// centred display, which a \n in the attribute breaks by sense.
const [LEAD_AT, BODY_AT] = [9, 12]; // grid lines: the lead's top; where the text starts
const NUMERAL = 48; // pt
const RULE_Y = (LEAD_AT - 1.5) * LEAD * MM_PER_PT; // mm: a line and a half above the lead
const NUMERAL_Y = RULE_Y - NUMERAL * MM_PER_PT - 3; // mm: the numeral's box ends 3 mm above it
const centred = (y) => ({ anchor: { to: 'container', edge: 'top' }, offset: { y } });
const opener = {
  enabled: true,
  // The two-line lead ends on line LEAD_AT + 2; minHeight leaves a blank line under it and
  // starts the text on line BODY_AT (a one-line lead would leave two).
  minHeight: line(BODY_AT),
  slot: { elements: [
    { kind: 'text', id: 'numeral', content: '{titleText}', fontFamily: DISPLAY, italic: true,
      fontWeight: 500, fontSize: pt(NUMERAL), lineHeight: 1, color: col('ink'),
      align: 'center', placement: centred(mm(NUMERAL_Y)) },
    { kind: 'rule', id: 'hairline', direction: 'horizontal', thickness: pt(0.6),
      color: col('rubric'), placement: { ...centred(mm(RULE_Y)), size: { width: mm(18) } } },
    { kind: 'text', id: 'lead', content: '{attr.lead}', fontFamily: LABEL, fontWeight: 600,
      fontSize: pt(9.5), letterSpacing: pt(0.6), color: col('ink'), align: 'center',
      lineHeight: LEAD / 9.5, // one grid line to each line of the lead
      placement: { ...centred(line(LEAD_AT)), size: { width: mm(MEASURE) } } },
  ] },
};
// Every chapter opens on a recto: 'odd' adds a blank verso only after a chapter that ends on
// a recto, where the default 'always-odd' leaves a blank page after every chapter.
// marginBottom 0: the level's default 0.5 em would start the text a line lower.
const chapter = { level: 1, breakBefore: { enabled: true, parity: 'odd' },
  marginBottom: pt(0), italic: true, advancedDesign: opener };

A sunk opener: the numeral, a hairline, and the first sentence in small caps

Ingredients

Type
Crimson Pro, Cormorant Garamond, Cormorant SC (SIL OFL 1.1)
Assets
  • cover-1190.jpg
  • cover-it-1190.jpg
  • The cover’s view of the gulf, a painting (Generated With Diffusion Models, original)
  • The Italian edition’s cover: a detail of Settignano (c. 1880), oil on canvas; scan from Wikimedia Commons, a 1,744 × 1,669 px cut reduced to 1,190 px wide (Telemaco Signorini, public domain)
  • The camomile tailpiece, drawn in code in the page’s palette (Ignacio Ferro, MIT)

Method

#1 · The opener comes from the heading and its attribute

The code is the short answer above. Chopin’s chapters have no titles, so each heading holds only its numeral (# I), which {titleText} prints. {attr.lead} prints the heading’s lead attribute, which holds the chapter’s first sentence; the Markdown paragraph under the heading starts with the sentence after it (heading attributes). The lead is a centred display, and the \n in each attribute breaks it by sense, after cage and after bright;. The lead’s box starts nine grid lines below the top of the text block, and a minHeight of 12 lines leaves one blank line under it; without minHeight the text starts right under the lead (span and advanced design). marginBottom: pt(0) replaces the level’s default half-em margin, which would push the text a line lower.

breakBefore with parity 'odd' sends every chapter to a recto, with a blank verso only after a chapter that ends on a recto (break before). To force a recto where there is no heading, write :::pagebreak{parity="odd"} in the Markdown; in a layout of two or more columns, :::columnbreak moves the text to the next column instead (:::pagebreak).

#2 · A trade page of whole lines

script.js · lines 33–43in full code
const TRIM = { width: 140, height: 216 }; // mm: 5½ × 8½ in
const [TOP, INNER, OUTER] = [22, 20, 15.5]; // mm; mirrored, so INNER is left on a recto
const LINES = 35; // every full page ends on the same line
const MEASURE = TRIM.width - INNER - OUTER; // 104.5 mm: about 69 characters of Crimson Pro
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: { top: mm(TOP), bottom: mm(TRIM.height - TOP - LINES * LEAD * MM_PER_PT),
    left: mm(INNER), right: mm(OUTER), mirror: true },
};

The bottom margin is what the 216 mm trim leaves after the top margin and 35 lines of 14 pt, so every full page ends on the same line, as pages 3 and 4 do. With mirror: true the 20 mm inner margin falls on the spine side of rectos and versos alike (mirrored margins). The 104.5 mm measure holds about 69 characters of Crimson Pro at 10.5 pt. The body text keeps word spaces between 0.7 and 1.9 of normal; at the default minimum of 0.6, one line on these pages closes to 0.62.

#3 · Running heads that skip openers and blank pages

script.js · lines 81–101in full code
// {author} and {title} come from the frontmatter.
const HEAD_Y = 12; // mm from the top edge to the top of the running heads
const SHIFT = (INNER - OUTER) / 2; // mm: the text block's centre is off the page's centre
const head = (id, content, parity, edge, x, style) => ({
  kind: 'text', id, content, parity, pages: 'body', // never on openers or blank pages
  fontSize: pt(9), color: col('muted'), ...style,
  placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(HEAD_Y) } },
});
const smallCaps = { fontFamily: LABEL, fontWeight: 600, letterSpacing: pt(1.2) };
const italic = { fontFamily: DISPLAY, italic: true, fontWeight: 500, fontSize: pt(9.75) };
const folio = { fontFamily: TEXT, color: col('ink') };
const header = { elements: [
  head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
  head('verso-author', '{author}', 'even', 'top', -SHIFT, smallCaps),
  head('recto-title', '{title}', 'odd', 'top', SHIFT, italic),
  head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, folio),
] };
// Openers carry a drop folio instead, centred under the text block.
const footer = { elements: [{ kind: 'text', id: 'drop-folio', content: '{pageNumber}',
  pages: 'opener', fontFamily: TEXT, fontSize: pt(9), color: col('muted'), align: 'center',
  placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(7) } } }] };

parity: 'even' puts the author in Cormorant SC small capitals on versos, and 'odd' puts the title in italic on rectos; the folios stand at the outer edge of the text block. pages: 'body' keeps all four elements off the openers and off page 6, the blank verso the parity break adds. With pages: 'all' that page would print 6 and Kate Chopin. The openers get a drop folio instead, a footer element that pages: 'opener' limits to them (text elements).

#4 · The cover is a section with no running heads

script.js · lines 105–128in full code
// Page 1 is a recto (gotcha: parity-page1-recto): the cover, the colophon on its verso, and
// chapter I on page 3. # The Awakening {style="cover"} opens the section; chapter I closes it.
// The colophon: 2 + 2 + 1 lines of 11 pt and two gaps of 14.5 pt make 84 pt, six grid lines.
const COLOPHON_LINES = 6;
const COLOPHON_TOP = TOP + (LINES - COLOPHON_LINES) * LEAD * MM_PER_PT; // mm: the section's margin
const onPage = (y) => ({ anchor: { to: 'page', edge: 'top' }, offset: { y: mm(y) } }); // y mm down
const cover = {
  id: 'cover',
  header: { elements: [] }, footer: { elements: [] }, // no running heads on p. 1 or p. 2
  margins: { top: mm(COLOPHON_TOP) },
  advancedDesign: { enabled: true, slot: { elements: [
    { kind: 'image', id: 'art', resourceId: 'cover',
      placement: { anchor: { to: 'bleed', edge: 'top-left' }, size: { width: 'fill' } } },
    { kind: 'text', id: 'title', content: '{title}', fontFamily: DISPLAY, italic: true,
      fontWeight: 500, fontSize: pt(50), lineHeight: 1, color: col('ink'), align: 'center',
      placement: onPage(155) },
    { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.6),
      color: col('rubric'), placement: { ...onPage(179), size: { width: mm(18) } } },
    { kind: 'text', id: 'author', content: '{author}', ...smallCaps, fontSize: pt(12),
      letterSpacing: pt(2.4), color: col('rubric'), align: 'center', placement: onPage(184) },
  ] } },
};
const colophon = { id: 'colophon', fontSize: pt(8), lineHeight: pt(11), color: col('muted'),
  textAlign: 'left', firstLineIndent: pt(0), spaceBetween: pt(14.5) };

The cover is a heading, # The Awakening {style="cover"}. Its style places the painting over the top 134 mm, the frontmatter’s title at 50 pt and the author in small capitals. The style also applies to the section the heading opens, pages 1 and 2, until chapter I. Its empty header and footer keep the drop folio off the cover and the running heads off the colophon. Its top margin puts the colophon on the last six grid lines of the text block, so the colophon’s last line is level with the last line of page 3 (heading styles). The section’s column starts 165 mm down, and the design, anchored to the page and the bleed, still paints above it: only the foot of a column cuts a design kept in it.

Page 2: the colophon at the foot of the cover’s verso, with no running head or folio.

#5 · A tailpiece closes each chapter

script.js · lines 132–164in full code
// At a chapter's end: :::space, then ::resource{id="tailpiece-1"} (double quotes: gotcha
// resource-double-quotes). The space adds a line to the gap the embed keeps above it.
const ornament = { id: 'ornament', name: 'Ornament', shortLabel: '', captionPrefix: '',
  numberingTemplate: '{n}', resetOn: 'never', counterFormat: 'decimal',
  defaultPlacement: { position: 'here', width: 0.17, align: 'center' } };
const svg = (id, fileId, width, height, altText) => ({ id, typeId: 'ornament', kind: 'svg',
  svg: { fileId, width, height }, altText, createdAt: 0, updatedAt: 0 });
// The cover is a painting, a JPEG in assets/ cut to the art's 140 × 134 mm, declared at its pixels;
// the it edition's is a detail of Signorini's Settignano.
const painting = { id: 'cover', typeId: 'ornament', kind: 'bitmap', createdAt: 0, updatedAt: 0,
  bitmap: { fileId: t({ en: 'cover-1190.jpg', it: 'cover-it-1190.jpg' }), format: 'jpeg',
    width: 1190, height: 1139 },
  altText: t({ en: 'The gulf seen between the trunks of water-oaks, a lugger on the horizon; a '
    + 'white sunshade comes up from the beach through the camomile.',
  pt: 'O mar visto entre os troncos de duas árvores, um veleiro no horizonte; uma sombrinha '
    + 'branca sobe da praia por um caminho entre flores amarelas e brancas.',
  fr: 'La mer vue entre les troncs de deux arbres, un voilier à l’horizon ; une ombrelle '
    + 'blanche monte de la plage par un chemin entre des fleurs jaunes et blanches.',
  de: 'Das Meer zwischen den Stämmen zweier Bäume, ein Segelboot am Horizont; ein weißer '
    + 'Sonnenschirm kommt vom Strand einen Weg zwischen gelben und weißen Blumen herauf.',
  it: 'Una strada di Settignano: la bottega del pane e del vino, una donna seduta sulla '
    + 'soglia, un gatto sul selciato al sole.' }) };
const resources = [
  painting,
  // ::resource places each ornament once, so each chapter end has its own id.
  ...t({ en: ['I', 'II'], pt: ['I', 'II', 'III'], fr: ['I', 'II'], de: ['I', 'II'], it: ['I', 'II'] })
    .map((n, i) => svg(`tailpiece-${i + 1}`, 'fleuron.svg', 40, 12,
      t({ en: `A camomile flower between two sprigs closes chapter ${n}.`,
        pt: `Uma flor de camomila entre dois ramos fecha o capítulo ${n}.`,
        fr: `Une fleur de camomille entre deux brins clôt le chapitre ${n}.`,
        de: `Eine Kamillenblüte zwischen zwei Zweigen schließt das Kapitel ${n}.`,
        it: `Un fiore di camomilla tra due rametti chiude il capitolo ${n}.` }))),
];

The ornament type has no caption prefix, so the camomile flower prints without a label, 17% of the measure wide, where ::resource{id="tailpiece-1"} stands (resource types). An inline embed keeps one grid line above it, and the :::space before it adds a second between the chapter’s last line and the flower (:::space). Both tailpieces draw the same file, fleuron.svg, under two ids, because a resource is placed only once.

The whole recipe

Sandbox
// ═══ Postext Cookbook · Nº 038 · Trade paperback: sunk openers and recto chapters ═══
// https://postext.dev/en/cookbook/trade-paperback-novel
// Code: MIT · Text: Chopin, Machado, Goncourt, Collodi, Keyserling (PD) · Covers: diffusion models, Signorini
// Fonts: Crimson Pro, Cormorant Garamond, Cormorant SC (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: 'en' Chopin|'pt' Machado|'fr' Goncourt|'de' Keyserling|'it' Collodi
const RECIPE = 'trade-paperback-novel';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { // every colour in the config links to one of these
  ink: '#231d18', // the text: a warm near-black
  rubric: '#8e3b22', // the one accent: the opener's hairline, the author, the tailpiece
  muted: '#6e655b', // running heads, folios on openers, the colophon
  paper: '#fbf7ef', // a cream book paper
};
// Each colour names its palette entry and carries its hex.
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' } })),
  // The engine's defaults (headings, lists, callouts, captions) link to 'main-color', the rubric.
  { id: 'main-color', name: 'rubric (defaults)', value: { hex: palette.rubric, model: 'hex' } },
];
const TEXT = 'Crimson Pro'; // the text face
const DISPLAY = 'Cormorant Garamond'; // italic numerals and the cover's title
const LABEL = 'Cormorant SC'; // small capitals: the lead, the author's name
const [BODY, LEAD] = [10.5, 14]; // pt: the body size and its leading, the grid's pitch
const line = (n) => pt(n * LEAD); // n grid lines

// #region page: a 140 × 216 mm trade page whose text block holds 35 whole lines
const TRIM = { width: 140, height: 216 }; // mm: 5½ × 8½ in
const [TOP, INNER, OUTER] = [22, 20, 15.5]; // mm; mirrored, so INNER is left on a recto
const LINES = 35; // every full page ends on the same line
const MEASURE = TRIM.width - INNER - OUTER; // 104.5 mm: about 69 characters of Crimson Pro
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: { top: mm(TOP), bottom: mm(TRIM.height - TOP - LINES * LEAD * MM_PER_PT),
    left: mm(INNER), right: mm(OUTER), mirror: true },
};
// #endregion

// #region answer: a sunk opener: the numeral, a hairline, and the first sentence in small caps
// # I {lead="A green and yellow parrot, … kept repeating over and over:"}
// The heading's text is the numeral, printed by {titleText}; the chapter's first sentence

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

#Let chapter II follow on the next page

With parity 'any', chapter II opens on page 6, a verso, and the book ends on page 7; the drop folio is centred on the text block, not the page, so on that verso it still stands under the middle of the text.

-const chapter = { level: 1, breakBefore: { enabled: true, parity: 'odd' },
+const chapter = { level: 1, breakBefore: { enabled: true, parity: 'any' },

#Mark a scene break inside a chapter

Set between two :::space lines, the same flower marks a scene break, and the paragraph after it starts flush because indentAfterHeading is off. Placed after seemed long to him., the flower falls at the foot of page 4; the second space no longer fits there and is dropped. The break adds four lines, which push chapter I’s tailpiece alone onto page 6, under a running head, so copy-fit the chapter again after you add one.

 const resources = [
+  svg('break-1', 'fleuron.svg', 40, 12, 'A scene break.'),
That was why the morning seemed long to him.
 
:::space
 
::resource{id="break-1"}
 
:::space
 
“You are burnt beyond recognition,” he added, …

Pitfalls

Pitfall

Page 1 is a recto: plan pages with physical numbers

Page 1 is a right-hand page and page 2 the first verso, so plan spreads with physical page numbers: an opener on an even page faces the odd page after it. Page and column breaks →

Pitfall

::resource{id="…"} takes double quotes only

A block embed is recognised only as ::resource{id="…"} with double quotes; any other form stays in the text as a visible line. Figures exactly here →

Sandbox check · parityCascade

Parity cascade

Why. Parity breaks stack up and produce more than two blank pages in a row.

Fix. Review always-odd breaks and breakBefore parities; for short chapters, parity any usually avoids the blanks. Docs →

  • With 'always-odd' a blank separator page follows every section before any parity padding, so chapter I would move to page 5, after two blank pages, and the book would run to ten pages.
  • These pages are copy-fitted. With an outer margin of 16 mm instead of 15.5, page 7 splits after-din-ner at a second hyphen and ends a line short, page 8 ends a paragraph on the scrap spondent., and the second tailpiece falls onto a ninth page. Check the foot of every page after you change the measure, the type size or the sink.
  • Mr. and Mrs. are tied to the name with a no-break space (U+00A0). The paragraph that ends seemed long to him. keeps an ordinary space, because tying the name there opens its first line to 2.2 times the normal word space.

Credits

Text
  • The Awakening (1899), chapters I and II · Kate Chopin · public domain
  • Quincas Borba (1891), chapters I to III, the Portuguese edition’s text, in modern spelling · Machado de Assis · public domain
  • Madame Gervaisais (1869), chapters I and II, the French edition’s text, in the first edition’s spelling · Edmond et Jules de Goncourt · public domain
  • Beate und Mareile (Beate and Mareile, 1903), chapters 1 and 2 (the second abridged), the German edition’s text, in the spelling of S. Fischer’s edition · Eduard von Keyserling · public domain
  • Le avventure di Pinocchio (The Adventures of Pinocchio, Felice Paggi, Florence, 1883), chapters I and II, the Italian edition’s text, in the first edition’s spelling, without the chapter summaries · Carlo Collodi · public domain
  • The colophon · Postext Cookbook · original
Images
  • The cover’s view of the gulf, a painting · Generated With Diffusion Models · original
  • The Italian edition’s cover: a detail of Settignano (c. 1880), oil on canvas; scan from Wikimedia Commons, a 1,744 × 1,669 px cut reduced to 1,190 px wide · Telemaco Signorini · public domain
  • The camomile tailpiece, drawn in code in the page’s palette · Ignacio Ferro · MIT
Fonts
Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Cormorant SC (SIL OFL 1.1)
Sandbox