かんたんな説明
アメリカの小説の最初の2章を、並製本の本にした例です。どの章も右ページの少し下から、大きな章番号の下で始まります。
できあがり
140 × 216 mmの並製本の8ページに、Kate Chopinの『The Awakening』(1899)の最初の2章を収めます。表紙は拡散モデルで生成し、JPEGとして読み込んだ画像で、Grand IsleのLebrun家のコテージから見た湾を描いています。ウォーターオークのあいだの水平線にラガー船が浮かび、白い日傘がカモミールの中を上ってきます。奥付はその裏の偶数ページの地に置きます。各章は奇数ページから始まり、本文は81 mm下がった位置から始まります。その上に48 ptのイタリックの章番号、18 mmのさび色の細罫、スモールキャピタルで組んだ章の最初の一文が並び、この一文は意味の切れ目で2行に分けて中央にそろえます。第I章は5ページでカモミールの尾飾りとともに終わるので、6ページは柱もノンブルもない白ページになり、第II章は7ページから始まります。柱は偶数ページに著者名、奇数ページにイタリックの書名を載せます。
このレシピが答える質問
- 改ページや改段を強制し、すべての章を右ページから始めるには?
- 章扉に著者名の行、リード文、ドロップキャップ付きの導入文を加えるには?
- 意図的に白ページを入れたり、節を新しい見開きから始めたりするには?
- 柱を設定するには(左ページに書名、右ページに章タイトル、ノンブルは小口側)?
- 表紙、小扉、扉、奥付を作るには?
- 空行を入れても効かないとき、2つのブロックの間に縦のスペースを追加するには?
- 番号のないアートワーク(オーナメント、カット、ロゴ)を組むには?
手短な答え
// # 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 };
材料
- 機能
- デザインした章扉奇数ページから始まる章節ごとの柱見開きの余白見出しスタイル表紙、扉、奥付見出しの属性ページデザインのテキスト・罫・ボックスページデザインの画像節ごとのページ構成ページの役割ごとの柱柱とノンブル文書のメタデータ段落スタイル明示的な縦のアキリソースとしての図と表独自のリソースの種類その場に置く図用紙の色ウィドウ、オーファン、ラント
- 種類
- Crimson Pro, Cormorant Garamond, Cormorant SC (SIL OFL 1.1)
- 素材
cover-1190.jpgcover-it-1190.jpg- The cover’s view of the gulf, a painting (Generated With Diffusion Models, オリジナル)
- 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, パブリックドメイン)
- The camomile tailpiece, drawn in code in the page’s palette (Ignacio Ferro, MIT)
作り方
#1 · 章扉は見出しとその属性から作る
コードは上の手短な答えにあります。Chopinの章には題がないので、各見出しには番号だけを書き(# I)、それを{titleText}が印刷します。{attr.lead}は見出しのlead属性を印刷します。この属性には章の最初の一文が入り、見出しの下のMarkdownの段落はその次の文から始まります(見出しの属性)。最初の一文は中央そろえにし、各属性の\nで意味の切れ目、つまりcageの後と「bright;」の後で改行します。最初の一文のボックスは版面の上端からグリッド線9本分下で始まり、minHeightを12行にするとその下に空き行が1行残ります。minHeightがなければ、本文は最初の一文のすぐ下から始まります(幅と詳細デザイン)。marginBottom: pt(0)は、このレベルの既定の半emの下のアキを置き換えます。既定のままでは本文が1行下に押し下げられます。
breakBeforeのparityを'odd'にすると、どの章も奇数ページに送られます。白い偶数ページが入るのは、前の章が奇数ページで終わるときだけです(前で改ページ)。見出しのない箇所で奇数ページに送るには、Markdownに:::pagebreak{parity="odd"}と書きます。2段以上のレイアウトでは、:::columnbreakを使うと本文が次の段へ移ります(:::pagebreak)。
#2 · 行の整数倍でできた並製本のページ
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 },
};
下の余白は、216 mmの仕上がりから天の余白と14 ptの行35行分を引いた残りです。そのため、3ページと4ページのように、組み切ったページはどれも同じ行で終わります。mirror: trueにすると、20 mmののどの余白が奇数ページでも偶数ページでも背の側に来ます(見開きの余白)。104.5 mmの行長には、10.5 ptのCrimson Proがおよそ69字入ります。本文は語間を通常の0.7倍から1.9倍のあいだに保ちます。既定の最小値0.6のままでは、このページの1行が0.62まで詰まります。
#3 · 章扉と白ページを飛ばす柱
// {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'は偶数ページにCormorant SCのスモールキャピタルで著者名を、'odd'は奇数ページにイタリックで書名を置きます。ノンブルは版面の小口側の端に立ちます。pages: 'body'は、この4つの要素を章扉からも、パリティの改ページが加える白ページである6ページからも外します。pages: 'all'にすると、そのページに6とKate Chopinが印刷されます。章扉には代わりに下ノンブルを付けます。これはフッターの要素で、pages: 'opener'で章扉だけに限っています(テキスト要素)。
#4 · 表紙は柱のない節
// 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 Awakening {style="cover"}という見出しです。そのスタイルが上部134 mmに画像を置き、フロントマターの書名を50 ptで、著者名をスモールキャピタルで組みます。スタイルはこの見出しが始める節、つまり第I章までの1ページと2ページにも適用されます。スタイルのheaderとfooterを空にしてあるので、表紙には下ノンブルが、奥付には柱が付きません。スタイルの天の余白は奥付を版面の最後の6本のグリッド線に置くので、奥付の最終行は3ページの最終行と高さがそろいます(見出しスタイル)。この節の段は165 mm下から始まりますが、ページと塗り足しに固定したデザインは段の上端より上にも描かれます。段の中に収まるデザインを切るのは段の下端だけです。

#5 · 章の終わりに尾飾りを置く
// 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}.` }))),
];
ornamentの種類にはキャプションの接頭辞がないので、カモミールの花はラベルなしで、行長の17%の幅で、::resource{id="tailpiece-1"}を書いた位置に印刷されます(リソースの種類)。行内に埋め込んだリソースは上にグリッド線1本分のアキを保ち、その前の:::spaceが章の最終行と花のあいだにもう1本分を加えます(:::space)。リソースは1か所にしか置けないので、2つの尾飾りは同じファイルfleuron.svgを2つのidで描いています。
レシピの全体
// ═══ 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
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#第II章を次のページから始める
parityを'any'にすると、第II章は偶数ページの6ページから始まり、本は7ページで終わります。下ノンブルはページではなく版面の中央にそろうので、その偶数ページでも本文の中央の下に来ます。
-const chapter = { level: 1, breakBefore: { enabled: true, parity: 'odd' },
+const chapter = { level: 1, breakBefore: { enabled: true, parity: 'any' },#章の中で場面の区切りを示す
同じ花を2つの:::spaceの行で挟むと、場面の区切りになります。indentAfterHeadingがオフなので、その後の段落は字下げなしで始まります。「seemed long to him.」の後に置くと、花は4ページの地に入り、2つ目のアキはそこに収まらずに捨てられます。区切りを入れると4行増え、第I章の尾飾りだけが柱の付いた6ページへ押し出されます。区切りを加えたら、章の行数をもう一度調整してください。
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, …よくあるつまずき
つまずき
1ページは奇数ページ。ページは物理的な番号で計画する
1ページは右ページで、2ページが最初の偶数ページです。見開きは物理的なページ番号で計画してください。偶数ページの章扉は、その次の奇数ページと向かい合います。 改ページと改段 →
つまずき
::resource{id="…"}は二重引用符でしか書けない
ブロックの埋め込みとして認識されるのは、二重引用符を使った::resource{id="…"}の形だけです。ほかの書き方は、目に見える1行として本文に残ります。 その場に置く図 →
Sandboxの検査 · parityCascade
奇偶指定の連鎖
原因. 奇偶指定の改ページが重なり、白ページが3ページ以上続いています。
対処. always-oddの改ページとbreakBeforeの奇偶指定を見直してください。短い章では、parityをanyにすると白ページを避けられることが多くあります。 ドキュメント →
'always-odd'にすると、パリティのための白ページを入れる前に、各節の後に区切りの白ページが1枚入ります。そのため第I章は2枚の白ページの後の5ページへ移り、本は10ページになります。- このページは行数を調整して組んであります。小口の余白を15.5 mmから16 mmにすると、7ページではafter-din-nerが2つ目のハイフンで分割されて1行短く終わり、8ページでは段落が切れ端の「spondent.」で終わり、2つ目の尾飾りは9ページ目に落ちます。行長、文字サイズ、章頭の下げを変えたら、すべてのページの地を確かめてください。
- 「Mr.」と「Mrs.」は、ノーブレークスペース(U+00A0)で名前とつないであります。「seemed long to him.」で終わる段落では普通のスペースのままにしてあります。そこで名前をつなぐと、段落の1行目の語間が通常の2.2倍まで開くからです。
クレジット
- 本文
- The Awakening (1899), chapters I and II · Kate Chopin · パブリックドメイン
- Quincas Borba (1891), chapters I to III, the Portuguese edition’s text, in modern spelling · Machado de Assis · パブリックドメイン
- Madame Gervaisais (1869), chapters I and II, the French edition’s text, in the first edition’s spelling · Edmond et Jules de Goncourt · パブリックドメイン
- 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 · パブリックドメイン
- 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 · パブリックドメイン
- The colophon · Postext Cookbook · オリジナル
- 画像
- The cover’s view of the gulf, a painting · Generated With Diffusion Models · オリジナル
- 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 · パブリックドメイン
- The camomile tailpiece, drawn in code in the page’s palette · Ignacio Ferro · MIT
- フォント
- Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Cormorant SC (SIL OFL 1.1)


