跳到主要内容
食谱编号38

排版食谱 · 第9章 · 完整出版物

平装小说:下沉的章首页与右页起章

把《The Awakening》排成140 × 216 mm的平装本:一幅绘画封面、一页不带书眉的版权页,然后每章都从右页开始,正文下沉,上面是一个斜体章序号。

本页内容
  • 英文样例:尚无中文版本
  • 成品尺寸140 × 216 mm
  • 1栏
  • Crimson Pro 10.5/14
  • Cormorant Garamond
  • Cormorant SC
  • 8页
  • 难度
  • Postext 1.57.1
  • 排版用时74 ms
  • 196行代码

简单来说

一部美国小说的前两章,排成平装本。每章都从右页开始,正文从页面较低处起排,上方是大号章节数字。

成品一览

一本140 × 216 mm平装书的八页,排的是Kate Chopin的The Awakening(1899)的前两章。封面是一幅用扩散模型生成、以JPEG载入的画,画的是从Grand Isle上Lebrun家的小屋望出去的海湾:水橡树之间,地平线上有一艘小帆船,白色阳伞穿过春黄菊走上来。版权页排在它背面那一页的底部。每章都从右页开始,正文下沉到81 mm处,上面依次是48 pt的斜体章序号、一条18 mm长的铁锈红细线,以及用小型大写字母排的本章首句,按意思断成两行居中。第I章在第5页结束,末尾是一朵春黄菊章尾花,所以第6页留空,不带书眉和页码,第II章从第7页开始。书眉在左页印作者名,在右页用斜体印书名。

这道食谱解答

  • 怎样强制分页或分栏,并让每章都从右页开始?
  • 怎样给章首页加作者行、提要或带首字下沉的导语?
  • 怎样插入有意留白的页面,或让某一部分从新的跨页开始?
  • 怎样设置书眉:左页放书名,右页放章名,页码在外侧?
  • 怎样制作封面、简扉页、扉页和版权页?
  • 空行不起作用时,怎样在两个块之间加额外的垂直间距?
  • 怎样排不编号的插图:饰图、小花饰、标志?

简短回答

script.js · 第47–77行在完整代码中
// # 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.jpg
  • cover-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;*之后。首句的框从版心顶端往下第九条网格线开始,minHeight设为12行,在它下面留出一个空行;不设minHeight,正文会紧贴在首句下面(通栏与高级设计)。marginBottom: pt(0)替换了这一级标题默认的半个em的外边距,否则正文会再往下挪一行。

breakBefore的parity设为'odd',把每一章都送到右页,只有前一章结束在右页时才留一张空白左页(前置分页)。没有标题却需要强制换到右页时,在Markdown里写:::pagebreak{parity="odd"};在两栏及以上的版面里,:::columnbreak则把正文移到下一栏(:::pagebreak)。

#2 · 由整行构成的平装书页面

script.js · 第33–43行在完整代码中
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的成品高度减去上页边距和35行14 pt之后剩下的部分,所以每个排满的页面都结束在同一行上,第3页和第4页就是这样。设了mirror: true之后,20 mm的内页边距在右页和左页上都落在书脊一侧(对称页边距)。104.5 mm的行长可以容纳约69个10.5 pt的Crimson Pro字符。正文把词间距限定在正常值的0.7到1.9倍之间;如果用默认的最小值0.6,这几页上有一行会收紧到0.62。

#3 · 跳过章首页和空白页的书眉

script.js · 第81–101行在完整代码中
// {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'让这四个元素都不出现在章首页上,也不出现在第6页,也就是奇偶分页补出的那页空白左页。如果用pages: 'all',那一页会印出6和Kate Chopin。章首页改用页脚页码,这是一个页脚元素,由pages: 'opener'限定只出现在章首页(文本元素)。

#4 · 封面是一个不带书眉的分节

script.js · 第105–128行在完整代码中
// 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排前置元数据里的书名,用小型大写字母排作者名。这个样式同样作用于该标题开启的分节,即第1页和第2页,直到第I章为止。样式里的header和footer都是空的,这样封面上不出现页脚页码,版权页上也不出现书眉。它的上页边距把版权页放在版心最后六条网格线上,使版权页的最后一行与第3页的最后一行平齐(标题样式)。这个分节的栏从165 mm处开始,而设计锚定在页面和出血边上,照样画在栏顶以上:留在栏内的设计只会在栏的底端被裁掉。

第2页:封面背面底部的版权页,没有书眉和页码。

#5 · 每章以一朵章尾花收尾

script.js · 第132–164行在完整代码中
// 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这种资源类型没有题注前缀,所以春黄菊花饰不带标签,在::resource{id="tailpiece-1"}所在的位置印出,宽度为行长的17%(资源类型)。行内嵌入的资源上方保留一条网格线,前面的:::space又在本章最后一行和花饰之间加了一条(:::space)。两朵章尾花用两个id绘制同一个文件fleuron.svg,因为一个资源只能放置一次。

完整食谱

沙盒
// ═══ 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' },

#在章内标出场景转换

把同一朵花饰放在两行:::space之间,就可以标出场景转换,因为indentAfterHeading是关闭的,花饰后面的段落顶格起排。放在*seemed long to him.*之后,花饰落在第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="…"}才能被识别;其他写法会作为一行可见文字留在正文中。 图就放在这里 →

沙盒检查 · parityCascade

奇偶分页连续补页

原因. 奇偶换页层层叠加,连续产生了两页以上的空白页。

解决. 检查always-odd换页和breakBefore的奇偶设置;章较短时,parity设为any通常可以避免这些空白页。 文档 →

  • 用'always-odd'时,每个分节后面都会先跟一页空白分隔页,再做奇偶补页,于是第I章会移到第5页,排在两页空白页之后,全书变成十页。
  • 这几页的篇幅是逐页调过的。外页边距从15.5 mm改成16 mm后,第7页会在第二个连字符处把after-din-ner断开,少排一行;第8页会以残片*spondent.*结束一段;第二朵章尾花则落到第九页。改动行长、字号或下沉深度后,要检查每一页的底部。
  • *Mr.和Mrs.用不换行空格(U+00A0)与人名连在一起。以seemed long to him.*结尾的那一段保留了普通空格,因为在那里把人名连起来,会使它的第一行词间距张开到正常值的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)
沙盒