跳到主要内容
食谱编号98

排版食谱 · 第5章 · 图书结构

每章自带参考文献表的论文集

三位作者的三篇论文,各是buildBundle里的一个独立文档,每章末尾有一份Chicago著者-出版年制的文献表,只列本章引用的文献。

本页内容
输出
Canvas · PDF
难度
高级
Postext
已用Postext 1.65.0测试
需要≥ 1.28.0 · postext-pdf ≥ 1.28.0
许可证
更新于2026年10月11日
代码MIT · 文本CC BY 4.0
  • 英文样例:尚无中文版本
  • 成品尺寸155 × 235 mm
  • 1栏
  • Libre Caslon Text 9.6/13.8
  • IBM Plex Sans Condensed
  • Libre Caslon Display
  • 10页
  • 难度
  • Postext 1.57.1
  • 排版用时545 ms
  • 187行代码

简单来说

一本由不同作者撰写的论文集。每篇论文的标题下署着作者的名字,结尾附上自己的参考文献表,和常见的论文集一样。

成品一览

《The Working Page》是一本关于印刷史的小论文集,两位编者,三位作者。每位作者交来的稿子是一个Markdown文件,附着自己的BibTeX块,书里也按这个样子保存:155 × 235 mm的开本,正文用Libre Caslon,书名页是一块红色,各章开头是章号、标题和作者名。每章末尾是自己的References,按Chicago著者-出版年制排,只列这篇论文引用过的文献。Eisenstein的The Printing Press as an Agent of Change被两位作者引用,因此出现在两份表里;Gaskell的A New Introduction to Bibliography在第1章和第3章的表里也各有一条。

这道食谱解答

  • 怎样让论文集的每一章有自己的作者和自己的参考文献表?
  • 怎样按APA、IEEE或其他引用样式引用文献并生成参考文献表?

简短回答

script.js · 第39–55行在完整代码中
// Citations are [@key] in the text; each contributor's BibTeX goes in a :::references block
// in their own chapter. Register the engine once, before the first build.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const citations = {
  style: 'chicago-author-date', // the humanities' author-date: (Eisenstein 1979)
  bibliography: {
    // 'chapter': a :::bibliography lists the works its own document cites, so a work two
    // contributors cite appears in both lists. 'book' (the default) would print one list,
    // after the last chapter. The scope is per document, not per H1: each essay must be a
    // document of its own in buildBundle (see the chapters region).
    scope: 'chapter',
    title: '', // no bold title paragraph: each chapter has its own ## References heading
    fontSize: em(0.9), lineHeight: pt(12.4), hangingIndent: mm(5), entrySpacing: pt(2.6),
  },
};
// Numbering and disambiguation still see the whole book: two Smiths of 2001 in different
// chapters would print 2001a and 2001b, as one bibliography would.

用料

类型
Libre Caslon Text, Libre Caslon Display, IBM Plex Sans Condensed(SIL OFL 1.1)
素材
无:所有图片都用代码绘制

做法

#1 · 每位作者一个文档

script.js · 第337–340行在完整代码中
// A chapter's :::bibliography lists what that document cites; one Markdown file holding all
// three essays would make every list repeat the works of the chapters before it.
const chapters = [front, lowe, okafor, ferrer].map((markdown) => ({ markdown }));
const book = () => buildBundle({ chapters, config: config(), resources: [] });

简短回答里的范围指的是一个文档。buildBundle把四个文档排成一本书,页码、章号和目录连续下去,而每个:::bibliography只收集自己文件里的引文。参考文献留在作者写下它的地方。任何一章定义的代号在全书都有效,所以共用的文献其实只需写一次;但各章自成一体,调换顺序或替换一篇论文时就不会弄坏别的章的文献表。

#2 · 署名是标题属性

script.js · 第59–65行在完整代码中
// # The Compositor's Day {author="Margaret Lowe" short="The Compositor's Day"}
const byline = text('byline', '{attr.author}', { fontFamily: TEXT, italic: true,
  fontSize: pt(12), color: col('ink'), align: 'left' }, below('title', 4));
const versoAuthor = head('verso-author', '{attr.author}', 'even',
  at('page', 'top-left', MARGIN.outer + 8, 13)); // in the running head
const tocAuthor = { enabled: true, attr: 'author', fontFamily: TEXT, fontSize: pt(9.5),
  color: col('muted') }; // a line under each title in the contents (italic by default)

每篇论文的标题带有author="…",还有一个供书眉用的短标题short="…"。章首把作者印在标题下面,左页书眉写出该页所属论文的作者,目录在每个条目下面加一行作者名。前置部分不必再列一遍作者。

#3 · 章首

script.js · 第69–81行在完整代码中
// Nine lines of reserve and a line of margin under them (the level's marginBottom): ten
// lines, 48 mm, under a one-line title. A two-line title reaches past the reserve, and the
// margin then carries the text a line lower, clear of the rule.
const opener = { enabled: true, minHeight: pt(LEAD * 9), slot: { elements: [
  text('kicker', t({ en: 'Chapter {number}', es: 'Capítulo {number}' }), { ...label,
    fontSize: pt(8.5), letterSpacing: pt(1.7), color: col('accent') },
  at('container', 'top-left', 0, 4)),
  text('title', '{titleText}', { fontFamily: DISPLAY, fontSize: pt(28), lineHeight: 1.08,
    color: col('ink'), align: 'left', overflow: 'wrap' }, below('kicker', 3, { width: 'fill' })),
  byline,
  { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(1.2), color: col('accent'),
    placement: { ...below('byline', 6), size: { width: mm(16) } } },
] } };

眉题、标题和署名从版心顶端往下排,每个元素锚定在前一个的下方,所以像第3章那样的两行标题会把署名和短线一起推下去。标题只有一行时,预留高度让正文下沉48 mm,即十行;两行标题再多占一行,短线不会压到正文,第3章的正文因此比另外两章低一行开始。

#4 · 多作者书的页眉

script.js · 第85–99行在完整代码中
function head(id, content, parity, placement, look = {}) { // hoisted: the byline uses it
  return { ...text(id, content, { ...label, fontWeight: 500, fontSize: pt(7.5),
    letterSpacing: pt(1.1), color: col('muted'), ...look }, placement), parity, pages: 'body' };
}
const folio = { fontWeight: 600, color: col('ink') };
const header = { elements: [
  head('verso-folio', '{pageNumber}', 'even', at('page', 'top-left', MARGIN.outer, 13), folio),
  versoAuthor,
  head('recto-title', '{attr.short}', 'odd', at('page', 'top-right', -(MARGIN.outer + 8), 13),
    { align: 'right' }),
  head('recto-folio', '{pageNumber}', 'odd', at('page', 'top-right', -MARGIN.outer, 13),
    { ...folio, align: 'right' }),
] };
const footer = { elements: [{ ...head('drop-folio', '{pageNumber}', 'all',
  at('container', 'top', 0, 9), { ...folio, align: 'center' }), pages: 'opener' }] };

论文集在左页写作者、右页写章名;专著在这两个位置写的是书名和章名。页眉限定为pages: 'body',所以章首页只在页脚印一个页码。

#5 · 前置部分

script.js · 第103–133行在完整代码中
const bare = { numbered: false, toc: false, header: { elements: [] }, footer: { elements: [] } };
const cover = { enabled: true, slot: { elements: [
  { kind: 'box', id: 'field', style: { backgroundColor: col('accent') },
    placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: mm(150) } } },
  text('title', '{titleText}', { fontFamily: DISPLAY, fontSize: pt(58), lineHeight: 1,
    color: col('paper'), align: 'left', overflow: 'wrap' },
  { ...at('page', 'top-left', MARGIN.inner, 64), size: { width: mm(118) } }),
  text('subtitle', '{subtitle}', { fontFamily: TEXT, italic: true, fontSize: pt(15),
    color: col('paper'), align: 'left' }, below('title', 5)),
  text('editors', '{attr.editors}', { ...label, fontSize: pt(9), letterSpacing: pt(1.8),
    color: col('accent') }, at('page', 'top-left', MARGIN.inner, 162)),
  text('contributors', '{attr.contributors}', { fontFamily: TEXT, italic: true, fontSize: pt(12),
    color: col('ink'), align: 'left' }, below('editors', 3)),
  text('imprint', '{attr.imprint}', { ...label, fontWeight: 500, fontSize: pt(7.5),
    letterSpacing: pt(1.5), color: col('muted') }, at('page', 'bottom-left', MARGIN.inner, -16)),
] } };
const contentsOpener = { enabled: true, minHeight: mm(40), slot: { elements: [
  text('kicker', '{title}', { ...label, fontSize: pt(8.5), letterSpacing: pt(1.7),
    color: col('accent') }, at('container', 'top-left', 0, 4)),
  text('title', '{titleText}', { fontFamily: DISPLAY, fontSize: pt(28), color: col('ink'),
    align: 'left' }, below('kicker', 3)),
] } };
const contents = {
  levels: [{ level: 1, fontFamily: TEXT, fontSize: pt(12.5), lineHeight: pt(LEAD),
    numberFontFamily: LABEL, numberFontSize: pt(10), numberFontWeight: 600,
    numberColor: col('accent'), numberWidth: mm(6), numberGap: mm(3), marginBottom: pt(LEAD) }],
  pageNumber: { fontFamily: LABEL, fontSize: pt(9), fontWeight: 600, color: col('ink'),
    width: mm(7) },
  leader: { char: '. ', gap: mm(2) },
  subtitle: tocAuthor,
};

书名页和目录是第一个文档里两个不编号的标题,没有页眉,也不进目录。它们的设计从前置元数据读取{title}和{subtitle},编者和作者则取自标题自身的属性。

完整食谱

沙盒
// ═══ Postext Cookbook · Nº 098 · An edited volume with a bibliography per chapter ═════
// https://postext.dev/en/cookbook/edited-volume-chapter-bibliographies
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: Libre Caslon Text & Display, IBM Plex Sans Condensed (OFL 1.1) · Needs postext ≥ 1.28.0
// Three essays by three contributors, each a Markdown document of its own with its own
// BibTeX block, laid out by buildBundle as one volume: every chapter closes on its own list.
import {
  buildBundle, prepareFonts, withLoadedFonts, renderPageToCanvas, registerCitationEngine,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
import { createCiteprocEngine, STYLES, LOCALES } from 'https://esm.sh/postext-citeproc';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'edited-volume-chapter-bibliographies';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: printer's red on a warm paper, the rest in ink
const palette = {
  ink: '#211c19', // text: a warm near-black
  accent: '#8e2b1f', // printer's red: the cover field, kickers, the references heading
  rule: '#cdbfb2', // hairlines
  muted: '#6b5f57', // running heads, the contents' contributors, the colophon
  paper: '#fcfaf6', // the page, and the type on the red field
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const TEXT = 'Libre Caslon Text', DISPLAY = 'Libre Caslon Display';
const LABEL = 'IBM Plex Sans Condensed';
const MARGIN = { top: 23, bottom: 22, inner: 20, outer: 18 }; // mm, mirrored
const LEAD = 13.8; // body leading in pt: the baseline grid
const label = { fontFamily: LABEL, fontWeight: 600, textTransform: 'uppercase', align: 'left' };
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const below = (id, y, size) => ({ ...at(`#${id}`, 'below', 0, y), ...(size && { size }) });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, ...look, placement });

// #region answer: one list per chapter: scope 'chapter' over a book of separate documents
// Citations are [@key] in the text; each contributor's BibTeX goes in a :::references block
// in their own chapter. Register the engine once, before the first build.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const citations = {
  style: 'chicago-author-date', // the humanities' author-date: (Eisenstein 1979)
  bibliography: {
    // 'chapter': a :::bibliography lists the works its own document cites, so a work two
    // contributors cite appears in both lists. 'book' (the default) would print one list,
    // after the last chapter. The scope is per document, not per H1: each essay must be a
    // document of its own in buildBundle (see the chapters region).

组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)

变化

#全书一份文献表

有些出版社把所有文献集中成书末的一份总表。改一下范围,删掉三个## References标题,文献表就排在最后一章之后。

-    scope: 'chapter',
-    title: '', // no bold title paragraph: each chapter has its own ## References heading
+    scope: 'book',
+    title: 'Bibliography',

#改用APA

社会科学的论文集只改样式,别的不动。

-  style: 'chicago-author-date', // the humanities' author-date: (Eisenstein 1979)
+  style: 'apa',

常见问题

易错点

重复定义的键只保留第一条,且没有警告

文献数据对全书有效:同一个键在两章中各写一次时,保留第一处定义,第二处被忽略且没有警告。多位作者合写的书,给每位作者的键加上前缀。 由参考文献数据生成的文献表 →

易错点

属性值:不能含{ or };含"的值用单引号

属性值在右花括号处结束,所以不能包含{ or }。含双引号的值要放在单引号里;美元符号没有问题。 标题属性 →

易错点

标题样式会继承其级别的分页设置

headingStyles中的条目没有写出的字段都取自它所属的标题级别,breakBefore也不例外。在:::pagebreak之后以H1设置样式的目录页或版权页会继承parity 'odd',结果落在一张空白页之后。给这类样式设置breakBefore: { enabled: false }。 标题样式 →

  • scope: 'chapter'列出的是文档在:::bibliography之前引用的文献,不是某个H1小节引用的文献。如果所有论文都写在同一个Markdown文件里,第二份表会重复第一篇的文献,第三份表会重复前两篇的。
  • 全书以每个代号的第一次定义为准。两位作者若都用smith2001指不同的书,后一篇会悄悄引用前一位作者的那本:给每位作者的代号加前缀,或者拿文献表和原稿核对。
  • 消歧在全书范围内进行。不同章里两部不同的Smith 2001年著作可能印成2001a和2001b,即使某一章的表里只有其中一部。
  • 开页的小标题默认会去掉上方的全部空白,对齐网格所需的不足一行的空白于是落在它下方:第10页页首的Whose letters离正文会比同页下方的What the reader sees更远。headings.columnHeadSpace: 'remainder'把这不足一行的空白留在小标题上方(标题)。它适合单栏的书:旁边没有另一栏,看不出小标题比页首略低。

致谢

文本
原创文字, CC BY 4.0
字体
Libre Caslon Text (SIL OFL 1.1) · Libre Caslon Display (SIL OFL 1.1) · IBM Plex Sans Condensed (SIL OFL 1.1)
沙盒PDF