简单来说
《爱丽丝漫游奇境》的几页注释本,编者的注解印在页边。每条注解紧挨着它解释的段落,用一个彩色字母标出。
成品一览
《爱丽丝漫游奇境》(Alice’s Adventures in Wonderland)第七章疯狂的茶会的开头,排成注释本的三页,开本为156 × 234 mm的普通图书。卡罗尔的原文用Unna排成一栏两端对齐,每行约66个字符。切口一侧33 mm宽的旁注栏放编者的八条旁注,每条都紧挨带有其字母的段落,所以在右页它们排在右边,在左页排在左边。关于词语和笑话的旁注用绿色,关于历史的用红色,正文中的每个字母也取其旁注的颜色。本章开头是一幅俯视茶桌的水彩画,接着是章节编号、用Rozha One排的标题,以及以绿色首字下沉开头的斜体题记;关于本版本的说明放在题记旁的页边。
这道食谱解答
- 怎样把边注或旁注排在它所解释的段落旁边?
- 脚注怎么做?
- 怎样做一栏半版式,一个宽的正文栏加一个窄的侧栏?
- 怎样给章首页加作者行、提要或带首字下沉的导语?
简短回答
const layout = {
layoutType: 'oneAndHalf', // one text column and a narrower side column
sideColumnPercent: 26, // of the 127 mm between the margins: a 33 mm channel
sideColumnRole: 'floats', // no text runs in it: it holds side boxes and figures
sideColumnSide: 'outer', // at the fore-edge, which mirrored margins move page by page
gutterWidth: mm(4.5), // the text column keeps 127 − 33 − 4.5 = 89.5 mm
};
// A gloss is :::callout{type="note" span="side" title="a · …"} in the Markdown.
// span="side" moves it out of the flow into the channel, level with the block after
// the fence, so the fence goes just before the paragraph that carries its letter.
// Glosses never float. One that meets the gloss above stacks under it. One that would
// run past the column's foot slides up, as far as the gloss above allows, until its
// foot sits on the foot; if it still does not fit, it waits for the next page
// (gotcha: side-box-starts-at-fence).
const gloss = (id, hue) => ({ id,
backgroundEnabled: false, // one device: a hairline over the gloss, in its colour
stripe: { enabled: true, side: 'top', width: pt(0.5), color: col(hue) },
padding: { top: mm(1.5), right: pt(0), bottom: pt(0), left: pt(0) },
// Cormorant SC draws lower case as small capitals: the title needs no textTransform.
titleStyle: { fontFamily: LABEL, fontWeight: 600, fontSize: pt(8.5),
letterSpacing: pt(0.3), color: col(hue), gap: mm(0.8) },
// Face and colours come from bodyText. A box body also inherits its 4 mm first-line
// indent, which a gloss sets back to 0.
body: { fontSize: pt(7.8), lineHeight: pt(10), textAlign: 'left',
firstLineIndent: pt(0) } });
const calloutStyles = [gloss('note', 'lawn'), gloss('context', 'jam')]; // words, history
用料
做法
#1 · 把切口一侧留给边注
代码见上面的简短回答。在一栏半版式中,sideColumnPercent: 26从页边距之间的127 mm里分给侧栏33 mm,扣除4.5 mm栏间距后正文还有89.5 mm。sideColumnRole: 'floats'让卡罗尔的正文不进入侧栏,侧栏只放用span: 'side'指定的内容。脚注要等到栏底、排在一条线下;而在页边,每条旁注与它所解释的那一行齐平,也不占用正文栏的行。两种旁注样式只在细线和标题的颜色上不同,读者不用读内容,就能分辨是词语注还是历史注。
#2 · 镜像页面,让边注栏跟着切口走
const PT = 25.4 / 72; // mm in a point
const [TRIM_W, TRIM_H] = [156, 234]; // mm
const [TOP, BOTTOM, INNER, OUTER] = [22, 22, 15, 14]; // mm: 38 lines of text
const page = { width: mm(TRIM_W), height: mm(TRIM_H), dpi: 150,
backgroundColor: col('paper'),
// left is a recto's inner margin; mirror swaps the sides on a verso, and 'outer' moves
// the channel with them: right on a recto, left on a verso.
margins: { top: mm(TOP), bottom: mm(BOTTOM), left: mm(INNER), right: mm(OUTER),
mirror: true } };
const CONTENT_W = TRIM_W - INNER - OUTER; // 127 mm
const SIDE_W = CONTENT_W * layout.sideColumnPercent / 100; // 33 mm: the glosses' measure
const TEXT_W = CONTENT_W - SIDE_W - layout.gutterWidth.value;
设了mirror: true,页边距在每个左页上左右互换,sideColumnSide: 'outer'让旁注栏随之移动,所以旁注在第81页和第83页排在右边,在第82页排在左边。上下页边距各22 mm,留出190 mm,可容纳38行14 pt,每条旁注都从同一网格的某一行开始。
#3 · 在所解释的段落之前为每条边注写围栏
const bodyText = { // justified and hyphenated (en-us) by default
// Copy-fitted to the 89.5 mm column: at 9.5 pt '“Have some wine,” the March Hare said in
// an encouraging tone.' fits one line. At 10.4 pt every measure from 77 to 93 mm left
// it a short last line: 'couraging tone.', 'aging tone.', 'ing tone.' or 'tone.'.
fontFamily: TEXT, fontSize: pt(9.5), lineHeight: pt(LEAD), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), firstLineIndent: mm(4),
// The chapter's first paragraph is set flush, though the fences of glosses a and b stand
// between the heading and it: a box that leaves the flow is not the block after a heading.
indentAfterHeading: false,
// Unna's space is narrow, 0.22 em. At the default 0.6 the line breaker set 'Alice felt
// dreadfully puzzled. The Hatter’s remark seemed to have' with its spaces at 0.69.
minWordSpacing: 0.75,
// The dictionary divides the heroine's name, 'said Al-' | 'ice indignantly' on page 81.
// The list keeps it whole wherever it stands; every other word is divided as before.
hyphenation: { exceptions: ['Alice'] } };
在:::callout围栏上加span="side"的框会离开文本流,与围栏之后的块齐平,排在旁注栏里;所以每条旁注的围栏都紧写在带有其字母的段落之前,如下所示。旁注a和b应位于第一段旁,所以它们的围栏写在标题和该段之间。离开文本流的框不算标题之后的块,所以indentAfterHeading: false照样让该段顶格。正文按栏宽调整了字号:9.5 pt时,以“Have some wine,”开头的那段正好排成一行89.5 mm;而10.4 pt时,行长从77 mm到93 mm都会留下“ing tone.”或“tone.”这样过短的末行。Unna的词间空格很窄,只有0.22 em;minWordSpacing取默认值0.6时,第83页有一行的空格被压到这个宽度的0.69;minWordSpacing: 0.75排除了这一行。第81页上,词典把主人公的名字断成“Al-”和“ice”,所以该段写在:::paragraphs{style="whole"}里:这个样式设了hyphenation: false,全段只在“together”中键入的软连字符(U+00AD)处断词。
:::callout{type="context" span="side" title="c · Hair"}
Tenniel drew Alice with long, loose hair. …
:::
“Your hair wants cutting,”:chip[^c^]{style="context"} said the Hatter. …#4 · 字母印成其边注的颜色
// A letter in the text is a chip named after its gloss's type, :chip[^a^]{style="note"}:
// the Markdown has no mark for coloured text, and a chip style sets a colour. With no
// fill, outline, padding or gap the chip adds no width, so the lines break as they would
// with a plain ^a^.
const letter = (id, hue) => ({ id, backgroundEnabled: false, borderWidth: pt(0),
paddingX: pt(0), gap: pt(0), color: col(hue), bold: true });
const chipStyles = [letter('note', 'lawn'), letter('context', 'jam')];
Markdown没有给文字上色的标记,但行内标签样式可以设置文字颜色,所以每个字母都是一个行内标签,其样式与所属旁注的类型同名。:chip[^c^]{style="context"}印出一个红色的c,与旁注c的细线和标题同为红色。没有填充、轮廓、内边距和间隙时,行内标签不增加宽度,每一行的断行位置都与用普通^c^时相同。
#5 · 在茶桌下开始本章
const HEADPIECE = 72; // mm: the depth of the painting at the head of the page
const HEADNOTE = { size: 9.8, lead: LEAD }; // pt: the headnote keeps the body's leading
const CAPS = { text: 0.597, initial: 0.56 }; // cap heights, em: Unna and Rozha One
// The initial's size: its capital runs from the first line's cap height down to the
// last baseline it spans. At the default size it stops short of the first line's capitals.
const dropSize = (lines) => pt(((lines - 1) * HEADNOTE.lead + CAPS.text * HEADNOTE.size)
/ CAPS.initial);
const below = (id, y, width) => ({ anchor: { to: `#${id}`, edge: 'below' },
offset: { y: mm(y) }, size: { width } });
// The opener reserves the height of its lowest element, rounded up to the grid, and the
// heading's default bottom margin adds one blank line: with a four-line headnote the
// text starts on line 23. The kicker, the title and the headnote hang below the painting.
const opener = { enabled: true, slot: { elements: [
// An image element draws a resource without number or caption. It hangs from the
// trim's corner, over the top margin and both side margins.
{ kind: 'image', id: 'headpiece', resourceId: 'tea-table',
placement: { anchor: { to: 'page', edge: 'top-left' },
size: { width: mm(TRIM_W) } } },
// The numeral comes from the heading line,
// # A Mad Tea-Party {num="VII" headnote="…" …}: the excerpt stands alone, so
// {chapterNumber} would count its one heading and print 1.
{ kind: 'text', id: 'kicker', content: 'Chapter {attr.num}', fontFamily: LABEL,
fontWeight: 600, fontSize: pt(9), letterSpacing: pt(2), textTransform: 'uppercase',
color: col('jam'), align: 'left',
placement: { anchor: { to: 'container', edge: 'top-left' },
offset: { y: mm(HEADPIECE - TOP + 8) } } }, // 8 mm under the painting's foot
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: DISPLAY,
fontSize: pt(40), lineHeight: 1.05, color: col('ink'), align: 'left', // wraps when longer
placement: below('kicker', 2, 'fill') },
// The drop cap opens the headnote, the editor's voice, italic and ragged; Carroll's
// text opens in the flow, justified.
{ kind: 'text', id: 'headnote', content: '{attr.headnote}', fontFamily: TEXT,
italic: true, fontSize: pt(HEADNOTE.size),
lineHeight: pt(HEADNOTE.lead), color: col('ink'),
align: 'left',
dropCap: { lines: 2, fontFamily: DISPLAY, fontSize: dropSize(2), color: col('lawn'),
gap: mm(1.5) },
placement: below('title', 5, mm(TEXT_W)) },
// The note on this edition stands in the channel, level with the headnote's top.
{ kind: 'text', id: 'edition-label', content: 'This edition', fontFamily: LABEL,
fontWeight: 600, fontSize: pt(8.5), letterSpacing: pt(0.3), color: col('muted'),
align: 'left', placement: { anchor: { to: '#headnote', edge: 'right-of' },
offset: { x: layout.gutterWidth }, size: { width: mm(SIDE_W) } } },
{ kind: 'text', id: 'edition', content: '{attr.source}', fontFamily: TEXT,
fontSize: pt(7.5), lineHeight: pt(10), color: col('muted'), align: 'left',
placement: { anchor: { to: '#edition-label', edge: 'below' }, offset: { y: mm(0.8) },
size: { width: mm(SIDE_W) } } },
] } };
标题的设计槽跨越整页,水彩画才能伸到裁切线。眉题、标题和题记挂在水彩画下方,章首的预留高度到其中最低者为止,向上取整到网格;标题默认的下外边距再加一个空行。题记四行时,正文从第23行开始,多一行就会移到第24行。章节编号、题记和本版本说明来自标题属性{num="VII" headnote="…" source="…"}。编号从这里取,是因为节选本身是一个独立文档,{chapterNumber}会印出1。首字下沉用在编者的题记上,题记用斜体齐左排;卡罗尔的正文在下方文本流中两端对齐开始。dropSize()计算首字大小,使其顶端与题记第一行大写字母的顶端对齐。
#6 · 按解释对象给边注上色
const palette = {
ink: '#1f1b1a', // text: a warm near-black
lawn: '#1e6f6b', // glosses on words and jokes, the drop cap
jam: '#b23a48', // glosses on history, the kicker
muted: '#6e645b', // running heads, the note on this edition
paper: '#f8f3e6', // the page, and the tablecloth
};
// col(id): a colour linked to its palette entry, with the entry's hex beside the id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const entry = (id, hex, name = id) => ({ id, name, value: { hex, model: 'hex' } });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => entry(id, hex)),
// The engine's defaults link to 'main-color': aimed at the green, nothing prints blue.
entry('main-color', palette.lawn, 'lawn (defaults)'),
];
草坪绿标记关于词语、俗语和笑话的旁注,果酱红标记关于人物、日期和文本历史的旁注。在同一个palette对象里改一下jam的值,关于历史的旁注、它们的字母和眉题就一次全部换色;上方的水彩画也是按同样的草坪绿和果酱红挑选的。
完整食谱
// ═══ Postext Cookbook · Nº 032 · Annotated classic with margin glosses ════════════
// https://postext.dev/en/cookbook/annotated-classic-glosses
// Code: MIT · Text: Lewis Carroll (PD), glosses (CC BY 4.0) · Headpiece: diffusion models
// Fonts: Unna, Rozha One, Cormorant SC (SIL OFL 1.1) · Needs postext ≥ 1.28.0
// The mad tea-party as an annotated edition: the text keeps to one column, and its glosses stand
// in the outer margin beside the lines they explain, changing sides with the spread.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en')
const RECIPE = 'annotated-classic-glosses';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a lawn green and a jam red on cream paper
const palette = {
ink: '#1f1b1a', // text: a warm near-black
lawn: '#1e6f6b', // glosses on words and jokes, the drop cap
jam: '#b23a48', // glosses on history, the kicker
muted: '#6e645b', // running heads, the note on this edition
paper: '#f8f3e6', // the page, and the tablecloth
};
// col(id): a colour linked to its palette entry, with the entry's hex beside the id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const entry = (id, hex, name = id) => ({ id, name, value: { hex, model: 'hex' } });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => entry(id, hex)),
// The engine's defaults link to 'main-color': aimed at the green, nothing prints blue.
entry('main-color', palette.lawn, 'lawn (defaults)'),
];
// #endregion
const [TEXT, DISPLAY, LABEL] = ['Unna', 'Rozha One', 'Cormorant SC'];
const LEAD = 14; // body leading in pt: the grid of every page
// #region answer: a float-only channel at the fore-edge, and two gloss styles for it
const layout = {
layoutType: 'oneAndHalf', // one text column and a narrower side column
sideColumnPercent: 26, // of the 127 mm between the margins: a 33 mm channel
sideColumnRole: 'floats', // no text runs in it: it holds side boxes and figures
sideColumnSide: 'outer', // at the fore-edge, which mirrored margins move page by page
gutterWidth: mm(4.5), // the text column keeps 127 − 33 − 4.5 = 89.5 mm
};
// A gloss is :::callout{type="note" span="side" title="a · …"} in the Markdown.
// span="side" moves it out of the flow into the channel, level with the block after
// the fence, so the fence goes just before the paragraph that carries its letter.
// Glosses never float. One that meets the gloss above stacks under it. One that would
// run past the column's foot slides up, as far as the gloss above allows, until its
// foot sits on the foot; if it still does not fit, it waits for the next page
组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)
变化
#边注每页都放在右边
如果这个版本是在屏幕上一页一页地读,就关掉镜像:'outer'于是表示每页的右边缘;书眉位置不变,因为它们锚定在裁切线上。
- mirror: true } };
+ mirror: false } };#把长注放到页脚
页边放不下的长注写成脚注:正文里写[^1],段落下写它的[^1]:定义。Postext把它排在正文栏底部,宽89.5 mm,上面有一条短线,旁注栏仍归旁注所用。食谱“脚注排在引用它的那一栏底部”讲的是这类注释的样式。
常见问题
易错点
侧栏框与其围栏之后的块齐平开始
在postext 1.4.1中,span: 'side'的框在侧栏中的位置,是正文排到其围栏处时的高度,落在下一个网格行上,并排在已在那里的框之下。把旁注围在它所解释的段落之前:围在段落之后,旁注就会从下一段旁边开始。会超出栏底的框会向上滑,在上方框允许的范围内,直到底边落在栏底;仍然放不下的,就等到下一页的侧栏。 旁注 →
- 旁注按Markdown中的顺序一条接一条往下叠,所以一条长旁注会把下一条推下去。在第81页,两个字母都落在第一段的第二行:旁注a与该段齐平开始,旁注b排在它下面,比自己的字母低五行。字母挨得近的地方,旁注要写短。
致谢
- 文本
- Alice’s Adventures in Wonderland (1865), the opening of chapter VII, “A Mad Tea-Party” · Lewis Carroll · 公有领域
- The headnote, the eight glosses and the note on this edition · Ignacio Ferro · CC BY 4.0
- 图片
- The tea-table seen from above, a watercolour · Generated With Diffusion Models · 原创
- 字体
- Unna (SIL OFL 1.1) · Rozha One (SIL OFL 1.1) · Cormorant SC (SIL OFL 1.1)


