かんたんな説明
ブラジルの古典小説の5ページを小さなポケット版として組みます。短い章はどれも前の章のすぐ後から始まり、1行だけでページが始まったり終わったりすることはありません。
できあがり
マシャード・ジ・アシスが1899年に発表した小説『Dom Casmurro』の終わり近くから本文5ページを、ポルトガル語の原文のまま、架空の叢書「Coleção Casuarina」の110×178mmのポケット版として組みます。プラム、クリーム、プラムの帯で構成した表紙にはAbril Fatfaceの題と叢書のサフラン色の丸い紋章が載り、拡散モデルで生成したフラメンゴ沖の重い海を描いた口絵が213ページと向かい合います。本文は第CXVIII章の終わりから第CXXIII章の終わりまで続き、ページの頭で始まる章はひとつもありません。各章は前の章の終わりから2行あけて(213ページを埋めるためCXIXだけは3行)、プラムのローマ数字、字間を広げた大文字の題、短いサフラン色の罫の下から始まります。214ページには章見出しが2つ、215ページと216ページには1つずつあります。最後のページを除き、本文のどのページも33行目で終わり、1行だけで始まるページはありません。
このレシピが答える質問
- ウィドウ、オーファン、最終行の一語(ラント)を避け、見出しを本文と離さないようにするには?
- 段の下端をそろえ、最終ページの段の長さを均等にするには(垂直方向の両端そろえ)?
- 見出しに番号(1、1.1、1.1.1)を振り、レベルごとに異なるスタイルにするには?
- 柱を設定するには(左ページに書名、右ページに章タイトル、ノンブルは小口側)?
手短な答え
// 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.
材料
- 機能
- ウィドウ、オーファン、ラントデザインした章扉奇数ページから始まる章番号付き見出し段末そろえハイフネーションと文書の言語字下げ、行そろえ、段落間隔柱とノンブルページの役割ごとの柱見出しスタイル番号のない章表紙、扉、奥付改ページと改段ページデザインの画像ページデザインのテキスト・罫・ボックス見出しの属性見開きの余白フロートする囲み文書のメタデータ
- 種類
- Tinos (Apache 2.0) · Abril Fatface, League Spartan (SIL OFL 1.1)
- 素材
plate-1100.jpg- The plate of the sea off Flamengo under the Sugarloaf, a painting (Generated With Diffusion Models, オリジナル)
- The casuarina roundel, drawn in code in the book’s palette (Ignacio Ferro, MIT)
作り方
#1 · 章を追い込みで続け、見出しを本文から離さない
// 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.
章のレベルでは改ページをオフにし、marginTopで各見出しを前の章の最終行から2行下に置きます。そのデザインにはspanがないので、見出しは段の中に3行分の深さのブロックとして描かれ、その下の本文はグリッドに乗ったままです(前で改ページ、幅と詳細デザイン)。ページをまたぐときの保持の規則は既定値のままです。CXIXとCXXIの下にある4行の段落は、それぞれページの下端に2行を残し、2行を次のページへ送ります。avoidOrphans: falseにすると3行と1行に分かれ、214ページと215ページは1行だけで始まります(オーファン、ウィドウ、ラント)。段末そろえがCXIXの上に3行目の空きを加え、213ページが33行目で終わるようにします(段末そろえ)。

#2 · ポルトガル語のハイフネーションで33行のページを組む
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
地の余白は16.3mmです。178mmの高さから天の余白15mmと12.6ptの33行を引いた残りなので、すべての満ページが同じ行で終わります。Times New Romanと同じ字幅のTinosを9.5ptで組むと、84mmの行長に1行約59字が入ります。locale: 'pt'はポルトガル語のパターンでハイフネーションします。「at-tracção」「af-fluencia」「genealogica-mente」のように分かれます(対応するロケール)。ポルトガルやブラジルの版の多くと同じく、見出しの直後の最初の段落も含めてすべての段落を字下げするので、indentAfterHeadingは既定値のままです。
#3 · 偶数ページの柱に書名、奇数ページの柱に章名
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}はフロントマターの題を、{chapterTitle}はそのページかそれより前で始まった最後の章を印刷します。そのため217ページの柱は216ページで始まったCXXIIIの名を示します(テキスト要素)。213ページの柱は、最初の25行でCXVIIIを締めくくっているにもかかわらず、下端で始まるCXIXの名を示します。{chapterTitleAtTop}ならページの頭が属する章を示しますが、この抜粋にはCXVIIIの見出しがありません。SHIFTは柱を版面の中央へ移します。のどの余白が小口より2mm広いので、ページの中央から1mmずれます。
#4 · 表紙と口絵を見出しとして描く
// 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.' },
];
どちらもnumbered: falseを付けた見出しスタイルなので、最初の番号付きの章はやはりCXIXです。span: 'page'でそれぞれを扉のページにします。これがないと、表紙の下の帯と口絵は版面の下端で止まり、柱とノンブルが両方のページに印刷されます。口絵のキャプションは見出しから作られます。CAPÍTULO CXXIIIが見出しのテキストで、イタリックの引用はそのquote属性です(見出しの属性)。どちらのデザインもページの下端まで届くので、見出しはページ全体を確保し、本文は:::pagebreakなしで次のページから始まります。
#5 · 抜粋に本の中での位置を伝える
const continuation = { headings: { h1: 118, h2: 0, h3: 0, h4: 0, h5: 0, h6: 0 } };
continuation.headingsは、抜粋が始まる時点の見出しのカウンターを与えます。h1: 118で最初の番号付き見出しが第CXIX章になります。これがないと5つの章はIからVと番号が振られます。章のレベルのnumberingTemplate: '{1:I}'がその番号をローマ数字にし、デザインは{number}でそれを印刷します。表紙の改ページの後にある:::numbering{startAt=212}は、口絵を212、本文のページを213から217とします(番号付け)。
レシピの全体
// ═══ 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' } } },
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#章ごとに新しいページで始める
各章の前で改ページすると、本文の5ページは7ページになります。214ページにはCXIXの見出しと4行しか入らず、章が始まらない213ページは口絵の題CAPÍTULO CXXIIIを柱にします。
- breakBefore: { enabled: false }, marginTop: pt(2 * LEAD), advancedDesign: chapterHead };
+ breakBefore: { enabled: true, parity: 'any' }, marginTop: pt(2 * LEAD),
+ advancedDesign: chapterHead };#奇数ページの柱に章番号を入れる
{chapterNumber}は、題を取るのと同じ章の数字を印刷します。「CXIX · NÃO FAÇA ISSO, QUERIDA」となります。
- head('recto-chapter', '{chapterTitle}', 'odd', SHIFT),
+ head('recto-chapter', '{chapterNumber} · {chapterTitle}', 'odd', SHIFT),よくあるつまずき
つまずき
avoidWidowsは段の末尾を、avoidOrphansは段の頭を守る
Postextは2種類の孤立行に独自の名前を付けています。avoidWidows(widowMinLines、widowPenalty)は段落の1行目が段の末尾に1行だけ残るのを防ぎ、avoidOrphans(orphanMinLines、orphanPenalty)は段落の最終行が次の段の頭に1行だけ残るのを防ぎます。多くの組版の手引きはこの2つの名前を逆に使っているので、設定は効く位置で選んでください。どちらも既定で有効ですが、文字グリッド(cjk.grid)上では違います。グリッド上ではavoidWidowsが既定でオフになり、日本の地域設定ではavoidOrphansもオフになります(postext 1.28以降)。ページがグリッドの数える行数を収めるためです。どちらもペナルティとして働きます。レイアウトは、それぞれを、従った場合に生じる空行と比べて判断します。 ウィドウ、オーファン、ラント →
つまずき
:::numberingは次のページから効く
:::numberingは、現在のページではなく、次に始まるページから番号を変えます。:::pagebreak(第1章の前ならparity odd)の直後に置けば、新しい番号付けが意図した位置から始まります。 ローマ数字の前付け →
widowMinLinesを3に上げると、CXIXの下の4行の段落は分ける場所がなくなります。3行と1行に分ければ、214ページが1行だけで始まるからです。見出しは本文と一緒に次のページへ移り、213ページは6行短く終わります。- CXVIIIが数行増えると、CXIXの見出しの下には1行分の場所しか残りません。すると
keepWithNextが見出しを214ページへ送り、213ページは4、5行足りないまま終わります。keepWithNext: falseにすると、見出しが本文を伴わずに213ページの最後に来ます。 - 口絵はH1なので、
{chapterTitle}は口絵に戻ってしまいます。CXIXが先へ移ったときの213ページのように、口絵の後でまだ章が始まっていない本文のページは、CAPÍTULO CXXIIIを柱に印刷します。口絵のスタイルにrunningChapter: falseを指定すると、柱は口絵を飛ばします。 avoidRuntsをオフにすると、本の最後の行は「nadador da manhã.」ではなく「manhã.」だけになります。- これらの改ページが成り立つのは、このテキストを9.5/12.6ptで84mmの行長に組んだときだけです。テキスト、サイズ、行長を変えたら、すべてのページの下端とすべての見出しの上のアキを見直してください。
クレジット
- 本文
- 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 · パブリックドメイン
- The colophon, and the series name Coleção Casuarina (invented for this recipe) · Postext Cookbook · オリジナル
- 画像
- The plate of the sea off Flamengo under the Sugarloaf, a painting · Generated With Diffusion Models · オリジナル
- The casuarina roundel, drawn in code in the book’s palette · Ignacio Ferro · MIT
- フォント
- Tinos (Apache 2.0) · Abril Fatface (SIL OFL 1.1) · League Spartan (SIL OFL 1.1)


