Pular para o conteúdo principal
Receita número 65

Receitas · Capítulo 3 · Títulos e aberturas

Clássico de bolso: capítulos curtos em sequência

Dom Casmurro em livro de bolso: capítulos curtos em sequência sob títulos desenhados na coluna; nenhuma quebra de página deixa linha ou título sozinhos.

Nesta página
Saída
Canvas
Postext
Testada com o Postext 1.65.0
Requer ≥ 1.25.0
Licença
Atualizada em 10 de out. de 2026
Código MIT · Texto MIT

p. 212–213 · 2–3 de 7

  • Amostra em inglês: ainda sem edição em português
  • Refile 110 × 178 mm
  • 1 coluna
  • Tinos 9,5/12,6
  • Abril Fatface
  • League Spartan
  • 7 páginas
  • Nível
  • Postext 1.57.1
  • Diagramado em 68 ms
  • 167 linhas de código

Em poucas palavras

Cinco páginas de um romance clássico brasileiro num livrinho de bolso. Cada capítulo curto começa logo depois do anterior, e nenhuma página começa ou termina com uma linha isolada.

O que você vai compor

Cinco páginas de texto do final de Dom Casmurro, o romance de Machado de Assis de 1899, compostas no português original como um livro de bolso de 110 × 178 mm numa coleção inventada, a Coleção Casuarina. Uma capa em faixas ameixa, creme e ameixa traz o título em Abril Fatface e o selo açafrão da coleção, e uma prancha pintada do mar revolto do Flamengo, gerada com modelos de difusão, fica de frente para a página 213. O texto vai do fim do capítulo CXVIII ao fim do CXXIII, e nenhum capítulo abre página. Cada um começa duas linhas abaixo do fim do anterior (três no CXIX, para encher a página 213), sob um numeral romano ameixa, com o título em maiúsculas espaçadas e um fio curto açafrão. A página 214 tem dois títulos de capítulo; a 215 e a 216, um cada. Toda página de texto, menos a última, termina na 33ª linha, e nenhuma começa com uma linha isolada.

Esta receita responde a

  • Como evito viúvas, órfãs e últimas linhas de uma só palavra, e mantenho cada título junto do seu texto?
  • Como deixo as colunas alinhadas no pé e a última página equilibrada (justificação vertical)?
  • Como numero os títulos (1, 1.1, 1.1.1) e dou a cada nível um estilo diferente?
  • Como configuro os cabeços: título do livro na página esquerda, título do capítulo na direita e fólio do lado de fora?

A resposta curta

script.js · linhas 37–59no código completo
// Machado's chapters run a page or two, so none opens a page. The level's break is off (the
// H1 default would open each chapter on a recto) and a chapter starts two lines under the last.
const [NUMERAL, TITLE, TRACK, GAP] = [14, 7.5, 1.3, 1.6]; // pt, pt, pt, mm
const RULE_Y = NUMERAL * PT + GAP + TITLE * 1.2 * PT + GAP; // mm: under the title's line
const chapterHead = { enabled: true, slot: { elements: [ // no span: the head stays in the text
  { kind: 'text', id: 'numeral', content: '{number}', fontFamily: DISPLAY, fontSize: pt(NUMERAL),
    lineHeight: 1, color: col('plum'), align: 'center',
    placement: { ...at('container', 'top'), size: { width: 'fill' } } },
  { kind: 'text', id: 'title', content: '{titleText}', ...caps(TITLE, TRACK), color: col('ink'),
    align: 'center', overflow: 'wrap', // a long title takes a second line
    placement: { anchor: { to: '#numeral', edge: 'below' }, offset: { y: mm(GAP) },
      size: { width: 'fill' } } },
  { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(1), color: col('saffron'),
    placement: { ...at('container', 'top', 0, RULE_Y), size: { width: mm(8) } } },
] } }; // 11.7 mm deep: the head takes three lines, and the text under it stays on the grid
const chapters = { level: 1, numberingTemplate: '{1:I}', // {number} prints CXIX, CXX…
  fontSize: pt(TITLE), // the hidden heading line, measured in the headings' face
  breakBefore: { enabled: false }, marginTop: pt(2 * LEAD), advancedDesign: chapterHead };
// The keep rules are on by default. avoidWidows keeps widowMinLines (2) lines of a paragraph
// at the foot of a page, and headings.keepWithNext takes the head along when the paragraph
// moves on; avoidOrphans keeps two lines at the head of the next page; avoidRunts weighs a
// last line shorter than about 20 characters as a fault. Column balancing adds lines above
// a head so that the page ends on line 33.

Ingredientes

Tipografia
Tinos (Apache 2.0) · Abril Fatface, League Spartan (SIL OFL 1.1)
Materiais
  • plate-1100.jpg
  • The plate of the sea off Flamengo under the Sugarloaf, a painting (Generated With Diffusion Models, original)
  • The casuarina roundel, drawn in code in the book’s palette (Ignacio Ferro, MIT)

Preparo

#1 · Encadeie os capítulos, cada título junto do seu texto

script.js · linhas 37–59no código completo
// Machado's chapters run a page or two, so none opens a page. The level's break is off (the
// H1 default would open each chapter on a recto) and a chapter starts two lines under the last.
const [NUMERAL, TITLE, TRACK, GAP] = [14, 7.5, 1.3, 1.6]; // pt, pt, pt, mm
const RULE_Y = NUMERAL * PT + GAP + TITLE * 1.2 * PT + GAP; // mm: under the title's line
const chapterHead = { enabled: true, slot: { elements: [ // no span: the head stays in the text
  { kind: 'text', id: 'numeral', content: '{number}', fontFamily: DISPLAY, fontSize: pt(NUMERAL),
    lineHeight: 1, color: col('plum'), align: 'center',
    placement: { ...at('container', 'top'), size: { width: 'fill' } } },
  { kind: 'text', id: 'title', content: '{titleText}', ...caps(TITLE, TRACK), color: col('ink'),
    align: 'center', overflow: 'wrap', // a long title takes a second line
    placement: { anchor: { to: '#numeral', edge: 'below' }, offset: { y: mm(GAP) },
      size: { width: 'fill' } } },
  { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(1), color: col('saffron'),
    placement: { ...at('container', 'top', 0, RULE_Y), size: { width: mm(8) } } },
] } }; // 11.7 mm deep: the head takes three lines, and the text under it stays on the grid
const chapters = { level: 1, numberingTemplate: '{1:I}', // {number} prints CXIX, CXX…
  fontSize: pt(TITLE), // the hidden heading line, measured in the headings' face
  breakBefore: { enabled: false }, marginTop: pt(2 * LEAD), advancedDesign: chapterHead };
// The keep rules are on by default. avoidWidows keeps widowMinLines (2) lines of a paragraph
// at the foot of a page, and headings.keepWithNext takes the head along when the paragraph
// moves on; avoidOrphans keeps two lines at the head of the next page; avoidRunts weighs a
// last line shorter than about 20 characters as a fault. Column balancing adds lines above
// a head so that the page ends on line 33.

O nível de capítulo tem a quebra desativada, e marginTop põe cada título duas linhas abaixo da última linha do capítulo anterior. O design dele não tem span, de modo que o título é desenhado dentro da coluna, num bloco de três linhas de altura, e o texto embaixo dele fica na grade (quebra antes, span e design avançado). As regras de coesão ficam nos valores padrão. Os parágrafos de quatro linhas sob o CXIX e o CXXI deixam cada um duas linhas ao pé da página e levam duas para a seguinte; com avoidOrphans: false, eles se dividiriam em três e uma, e as páginas 214 e 215 começariam com uma linha isolada (órfãs, viúvas e linhas curtas). O equilíbrio de colunas acrescenta uma terceira linha de espaço acima do CXIX, para que a página 213 termine na linha 33 (equilíbrio de colunas).

Página 213: o capítulo CXIX começa três linhas abaixo do fim do CXVIII e mantém duas linhas do texto ao pé.

#2 · Monte uma página de 33 linhas, com hifenização portuguesa

script.js · linhas 63–70no código completo
const bodyText = { fontFamily: TEXT, fontSize: pt(BODY), lineHeight: pt(LEAD),
  color: col('ink'), referenceColor: col('ink'), // a :ref added later prints in ink
  firstLineIndent: mm(5) }; // every paragraph indented, the first after a head too
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 * PT), // 16.3 mm
    left: mm(INNER), right: mm(OUTER), mirror: true } };
const LOCALE = 'pt'; // the Portuguese hyphenation patterns

A margem inferior tem 16,3 mm, o que sobra dos 178 mm de altura depois da margem superior de 15 mm e de 33 linhas de 12,6 pt, por isso toda página cheia termina na mesma linha. A Tinos, que tem as larguras da Times New Roman, compõe cerca de 59 caracteres por linha na medida de 84 mm em corpo 9,5. locale: 'pt' hifeniza com os padrões do português: at-tracção, af-fluencia, genealogica-mente (idiomas suportados). Todo parágrafo leva recuo, inclusive o primeiro depois de um título, como costumam fazer as edições portuguesas e brasileiras, por isso indentAfterHeading fica no valor padrão.

#3 · O nome do livro na página par e o capítulo na ímpar

script.js · linhas 74–87no código completo
const SHIFT = (INNER - OUTER) / 2; // mm: the text block sits off the page's centre
const [HEAD_Y, FOLIO_Y] = [8.5, 167]; // mm below the top edge
const head = (id, content, parity, x) => ({ kind: 'text', id, content, parity,
  pages: 'body', // never on the cover or the plate, which are opener pages
  ...caps(7.5, TRACK), color: col('muted'), align: 'center',
  placement: at('page', 'top', x, HEAD_Y) });
const folio = (id, parity, edge, x) => ({ kind: 'text', id, content: '{pageNumber}', parity,
  pages: 'body', ...caps(7.5, 0), color: col('ink'), placement: at('page', edge, x, FOLIO_Y) });
const header = { elements: [
  head('verso-title', '{title}', 'even', -SHIFT), // the title in the frontmatter
  head('recto-chapter', '{chapterTitle}', 'odd', SHIFT), // last chapter begun on or before it
] };
const footer = { elements: [folio('verso-folio', 'even', 'top-left', OUTER),
  { ...folio('recto-folio', 'odd', 'top-right', -OUTER), align: 'right' }] };

{title} imprime o título do front matter, e {chapterTitle}, o último capítulo que começa na página ou antes dela, de modo que a página 217 nomeia o CXXIII, que começou na 216 (elementos de texto). A página 213 nomeia o CXIX, que começa ao pé dela, embora as primeiras 25 linhas fechem o CXVIII. {chapterTitleAtTop} nomeia, em vez disso, o capítulo em que a página abre, mas este trecho não traz o título do CXVIII. SHIFT leva os cabeços para o centro da mancha, 1 mm fora do centro da página, porque a margem interna é 2 mm mais larga que a externa.

#4 · Desenhe a capa e a prancha como títulos

script.js · linhas 91–134no código completo
// span: 'page', in one column too, makes each an opener page: its art runs past the foot of
// the text column, and no running head or folio prints on it. Each design reaches the foot of
// the page, so the heading reserves the whole page and the text starts on the next one.
const onPage = (y, size) => ({ ...at('page', 'top', 0, y), ...(size && { size }) });
const cover = { id: 'cover', numbered: false, span: 'page',
  advancedDesign: { enabled: true, slot: { elements: [
    { kind: 'box', id: 'top-band', style: { backgroundColor: col('plum') },
      placement: { ...at('page', 'top-left'), size: { width: 'fill', height: mm(62) } } },
    { kind: 'text', id: 'author', content: '{author}', ...caps(10, 2.4), color: col('paper'),
      align: 'center', placement: at('page', 'top', 0, 44) },
    { kind: 'text', id: 'title', content: '{titleText}', fontFamily: DISPLAY, fontSize: pt(44),
      lineHeight: 1, color: col('plum'), align: 'center', overflow: 'wrap',
      placement: onPage(72, { width: 'fill' }) },
    { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(1.5),
      color: col('saffron'), placement: onPage(111, { width: mm(12) }) },
    { kind: 'box', id: 'foot-band', style: { backgroundColor: col('plum') },
      placement: { ...at('page', 'top-left', 0, 124), size: { width: 'fill', height: mm(54) } } },
    { kind: 'image', id: 'roundel', resourceId: 'roundel',
      placement: onPage(133, { width: mm(20) }) },
    { kind: 'text', id: 'series', content: 'Coleção Casuarina', ...caps(7.5, 1.8),
      color: col('saffron'), align: 'center', placement: at('page', 'top', 0, 159) },
  ] } } };
// The plate faces the first page of text: the morning sea off Flamengo, captioned with the
// line of chapter CXXIII it illustrates, which the heading carries in its quote attribute.
const plate = { id: 'plate', numbered: false, span: 'page',
  advancedDesign: { enabled: true, slot: { elements: [
    { kind: 'image', id: 'sea', resourceId: 'sea',
      placement: { ...at('page', 'top-left'), size: { width: 'fill', height: 'fill' } } },
    { kind: 'text', id: 'label', content: '{titleText}', ...caps(7.5, 1.6), color: col('saffron'),
      align: 'center', placement: at('page', 'top', 0, 146) },
    { kind: 'text', id: 'quote', content: '{attr.quote}', fontFamily: TEXT, italic: true,
      fontSize: pt(8.6), lineHeight: 1.35, color: col('paper'), align: 'center', overflow: 'wrap',
      placement: onPage(152, { width: mm(78) }) },
  ] } } };
const resources = [
  { id: 'roundel', typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0,
    svg: { fileId: 'roundel.svg', width: 60, height: 60 },
    altText: 'The series mark: a casuarina tree in a ring.' },
  // The plate is a painting, a JPEG in assets/ cut to the trim, declared at its pixels.
  { id: 'sea', typeId: 'figure', kind: 'bitmap', createdAt: 0, updatedAt: 0,
    bitmap: { fileId: 'plate-1100.jpg', format: 'jpeg', width: 1100, height: 1780 },
    altText: 'A heavy morning sea under the Sugarloaf, a low sun, and a lone swimmer among '
      + 'the breakers.' },
];

As duas são estilos de título com numbered: false, de modo que o primeiro capítulo numerado continua sendo o CXIX. span: 'page' faz de cada uma uma página de abertura. Sem ele, a faixa do pé da capa e a imagem da prancha param no pé da mancha, e o cabeço e o fólio são impressos nas duas páginas. A legenda da prancha vem do título: CAPÍTULO CXXIII é o texto do título, e a citação em itálico é o atributo quote (atributos de título). Cada design chega ao pé da página, por isso o título reserva a página inteira e o texto começa na seguinte, sem nenhum :::pagebreak.

#5 · Diga ao trecho onde ele fica no livro

script.js · linha 276no código completo
const continuation = { headings: { h1: 118, h2: 0, h3: 0, h4: 0, h5: 0, h6: 0 } };

continuation.headings dá os contadores de títulos a partir dos quais o trecho começa. Com h1: 118, o primeiro título numerado é o capítulo CXIX; sem ele, os cinco capítulos são numerados de I a V. numberingTemplate: '{1:I}' no nível de capítulo compõe esses números em algarismos romanos, e o design os imprime com {number}. :::numbering{startAt=212}, depois da capa, numera a prancha como 212 e as páginas de texto de 213 a 217 (numeração).

A receita completa

Sandbox
// ═══ Postext Cookbook · Nº 065 · Pocket classic: short chapters that run on ═══════════
// https://postext.dev/en/cookbook/short-chapters-run-on
// Code: MIT · Text: Machado de Assis, Dom Casmurro, 1899 (PD, Gutenberg #55752) · Plate: painted
// Fonts: Tinos (Apache 2.0), Abril Fatface, League Spartan (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 viewer's title; the sample is Portuguese
const RECIPE = 'short-chapters-run-on';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = {
  ink: '#24202a', // the text: a violet near-black
  paper: '#f6f1e6', // the pocket book's paper
  plum: '#4f2a49', // the series colour: cover bands, the chapter numerals
  saffron: '#d9a03c', // the second ink: rules and drawings, never text on paper (2.1:1)
  muted: '#6b616e', // the running heads and the colophon (5.2:1 on 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 default bold and italic colours link to main-color, set here to the ink, not blue.
  { id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
const [TEXT, DISPLAY, LABEL] = ['Tinos', 'Abril Fatface', 'League Spartan'];
const TRIM = { width: 110, height: 178 }; // mm: a pocket book
const [TOP, INNER, OUTER] = [15, 14, 12]; // mm; mirrored, so the inner margin is at the spine
const [BODY, LEAD, LINES] = [9.5, 12.6, 33]; // pt, pt, and the lines of a full page
const PT = 25.4 / 72; // mm per point
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const caps = (size, track) => ({ fontFamily: LABEL, fontWeight: 600, fontSize: pt(size),
  letterSpacing: pt(track), textTransform: 'uppercase' });

// #region answer: chapters that run on, each under a centred head drawn in the column
// Machado's chapters run a page or two, so none opens a page. The level's break is off (the
// H1 default would open each chapter on a recto) and a chapter starts two lines under the last.
const [NUMERAL, TITLE, TRACK, GAP] = [14, 7.5, 1.3, 1.6]; // pt, pt, pt, mm
const RULE_Y = NUMERAL * PT + GAP + TITLE * 1.2 * PT + GAP; // mm: under the title's line
const chapterHead = { enabled: true, slot: { elements: [ // no span: the head stays in the text
  { kind: 'text', id: 'numeral', content: '{number}', fontFamily: DISPLAY, fontSize: pt(NUMERAL),
    lineHeight: 1, color: col('plum'), align: 'center',
    placement: { ...at('container', 'top'), size: { width: 'fill' } } },
  { kind: 'text', id: 'title', content: '{titleText}', ...caps(TITLE, TRACK), color: col('ink'),
    align: 'center', overflow: 'wrap', // a long title takes a second line
    placement: { anchor: { to: '#numeral', edge: 'below' }, offset: { y: mm(GAP) },
      size: { width: 'fill' } } },

O script.js montado funciona como está: cole-o como script de módulo em qualquer página ou abra a receita no CodePen. Pasta da receita no GitHub ↗ (abre em uma nova aba)

Variações

#Abra cada capítulo numa página nova

Com uma quebra antes de cada capítulo, as cinco páginas de texto viram sete: a página 214 traz só o CXIX, com o título e quatro linhas, e a página 213, onde nenhum capítulo começa, recebe o título da prancha, CAPÍTULO CXXIII, como cabeço.

-  breakBefore: { enabled: false }, marginTop: pt(2 * LEAD), advancedDesign: chapterHead };
+  breakBefore: { enabled: true, parity: 'any' }, marginTop: pt(2 * LEAD),
+  advancedDesign: chapterHead };

#Ponha o número do capítulo na página ímpar

{chapterNumber} imprime o numeral do mesmo capítulo de onde vem o título: CXIX · NÃO FAÇA ISSO, QUERIDA.

-  head('recto-chapter', '{chapterTitle}', 'odd', SHIFT),
+  head('recto-chapter', '{chapterNumber} · {chapterTitle}', 'odd', SHIFT),

Erros comuns

Erro comum

avoidWidows cuida do pé da coluna, avoidOrphans do alto

O Postext dá nomes próprios às duas linhas isoladas: avoidWidows (widowMinLines, widowPenalty) impede que a primeira linha de um parágrafo fique sozinha no pé de uma coluna, e avoidOrphans (orphanMinLines, orphanPenalty) impede que a última fique sozinha no alto da seguinte. Muitos manuais de estilo usam os dois nomes ao contrário, então escolha a configuração pelo lugar onde ela age. As duas vêm ativadas, exceto numa grade de caracteres (cjk.grid): ali avoidWidows vem desativada, e avoidOrphans também na região do Japão, para que a página contenha as linhas que a grade conta (desde o postext 1.28). Elas funcionam como penalidades: a diagramação compara cada uma com as linhas vazias que obedecê-la deixaria. Viúvas, órfãs e linhas curtas →

Erro comum

:::numbering vale a partir da página seguinte

:::numbering muda a contagem a partir da próxima página que começa, não da atual. Coloque-o logo depois de um :::pagebreak (com paridade odd antes do primeiro capítulo) para que a nova numeração comece onde você quer. Elementos pré-textuais em romanos →

  • Subir widowMinLines para 3 deixa o parágrafo de quatro linhas sob o CXIX sem onde se dividir: três linhas e uma abririam a página 214 com uma linha isolada. O título passa para a página seguinte com o texto, e a 213 termina seis linhas antes.
  • Se o CXVIII crescer algumas linhas, o CXIX só terá espaço para uma linha sob o título. keepWithNext então leva o título para a página 214, e a página 213 termina quatro ou cinco linhas mais curta; com keepWithNext: false, o título fecha a página 213 sem texto embaixo.
  • A prancha é um H1, por isso {chapterTitle} recorre a ela: uma página de texto em que nenhum capítulo começou desde a prancha, como a 213 depois que o CXIX muda de página, imprime CAPÍTULO CXXIII como cabeço. Com runningChapter: false no estilo da prancha, os cabeços passam por cima dela.
  • Desative avoidRunts e a última linha do livro fica só com manhã. em vez de nadador da manhã.
  • Essas quebras de página só valem para este texto, em 9,5 sobre 12,6 pt numa medida de 84 mm. Depois de mudar o texto, o corpo ou a medida, confira de novo o pé de cada página e o espaço acima de cada título.

Créditos

Texto
  • Dom Casmurro (1899), from the end of chapter CXVIII to the end of chapter CXXIII, in the spelling of the Garnier edition, with one transcription slip corrected (homens, chapter CXXIII) · Machado de Assis · domínio público
  • The colophon, and the series name Coleção Casuarina (invented for this recipe) · Postext Cookbook · original
Imagens
  • The plate of the sea off Flamengo under the Sugarloaf, a painting · Generated With Diffusion Models · original
  • The casuarina roundel, drawn in code in the book’s palette · Ignacio Ferro · MIT
Fontes
Tinos (Apache 2.0) · Abril Fatface (SIL OFL 1.1) · League Spartan (SIL OFL 1.1)
Sandbox