简单来说
一份1981年的公共卫生周报,用信纸开本重新排版。报告里每一种段落(病例、报告医生名单、编者的评论)都有自己的样子,参考文献自动编号。
成品一览
六页美国信纸开本的流行病学周报,重印美国疾病控制中心(CDC)首次描述后来被称为艾滋病的两篇报告:洛杉矶的五例Pneumocystis肺炎(1981年6月5日),以及随后的卡波西肉瘤病例(1981年7月3日)。报头是原创设计,借鉴那个年代政府公报的风格:一条蓝色色带,压缩无衬线体的刊名,下面是两栏Plex Serif正文。报告里的每一种声音都有自己的样式:病例在粗体编号标签之下,Reported by一行用小号斜体,还有Editorial Note(编者按)、括号中的引用序号和编号的文献表。正文、参考文献和表格都按CDC当年的印本;时间线和第2页的病例表由编者添加。
这道食谱解答
- 怎样排周报中的报告:报头、病例、编者按和编号参考文献?
- 怎样按APA、IEEE或其他引用样式引用文献并生成参考文献表?
- 怎样做一个有表头行、合并单元格、栏宽和逐格对齐的表?
- 怎样用Postext重新排版arXiv或PubMed Central上的开放获取论文,并保留引用、图和许可声明?
简短回答
// :::paragraphs{style="…"} wraps the blocks of each voice; **Patient 1:** is a run-in label.
const voice = (id, family, size, lead, extra) => ({ id, fontFamily: family, fontSize: pt(size),
lineHeight: pt(lead), color: col('ink'), boldColor: col('ink'), ...extra });
const aside = { textAlign: 'left', firstLineIndent: pt(0), snapToGrid: false };
const paragraphStyles = [
// Case histories and the Editorial Note: the body texture, bold labels in the accent.
voice('case', TEXT, 9.5, LEAD, { boldColor: col('accent'), boldFontWeight: 600 }),
voice('editorial', TEXT, 9.5, LEAD, { boldColor: col('accent'), boldFontWeight: 600 }),
// "Reported by …": the authors' line, italic small type in the condensed sans, off the grid.
voice('reported', LABEL, 7.8, 10.2, { ...aside, italic: true, color: col('muted'),
hyphenation: false, marginTop: pt(4), marginBottom: pt(6) }),
// A line the reprint adds, in the label face and the accent: never taken for 1981 text.
voice('editor', LABEL, 8, 10.6, { ...aside, italic: true, color: col('accent'),
marginTop: pt(3), marginBottom: pt(5) }),
voice('colophon', LABEL, 7.4, 9.6, { ...aside, color: col('muted'), marginTop: pt(LEAD) }),
];
// MMWR cited (1) in citation order, and each report (its H1 is a chapter) counted from 1.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const citations = { style: 'american-medical-association', marker: 'parentheses',
numbering: 'chapter', bibliography: { scope: 'chapter', fontSize: em(0.86),
lineHeight: pt(10.6), entrySpacing: pt(1.5), labelAlign: 'right' } };
用料
- 类型
- IBM Plex Serif, Libre Franklin, IBM Plex Sans Condensed(SIL OFL 1.1)
- 素材
- Figure 1, timeline of the five cases, drawn in code from the dates in the case reports (Ignacio Ferro, 原创)
做法
#1 · 每种声音一个段落样式
代码就是上面的简短回答。周报中的报告有几种语域:病例、报告人名单和编者的评论。用:::paragraphs{style="…"}把每一段包起来,就能在不改动文字的情况下给它一种外观:Reported by一行缩到7.8 pt的压缩斜体,脱离基线网格;病例则保持正文的质感,**Patient 1:**标签用强调色。引用写作[@walzer1974];american-medical-association加上marker: 'parentheses'把它们印成(1),并按引用顺序排列文献表,与周报当年一致;numbering: 'chapter'让每篇报告的引用从1开始编号,scope: 'chapter'在每篇报告下放一份使用同样编号的文献表。
#2 · 开启第一篇报告的报头
// Kicker and dateline are attributes of each report's H1; {titleText} read with inlineMarks
// keeps the italic genus. The July report opens where June ends, under a double rule.
const reportHead = (y, size) => [
text('kicker', '{attr.kicker}', LABEL, 8.5, { ...caps(8.5), color: col('accent'),
placement: at('container', 'top-left', 0, y, MEASURE) }),
text('title', '{titleText}', DISPLAY, size, { fontWeight: 800, lineHeight: 1.08,
inlineMarks: true, placement: at('#kicker', 'below', 0, 2.2, MEASURE) }),
text('dateline', '{attr.dateline}', LABEL, 9, { color: col('muted'),
placement: at('#title', 'below', 0, 2, MEASURE) }),
];
const masthead = { enabled: true, minHeight: mm(72), slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('accent') }, placement: {
anchor: { to: 'page', edge: 'top-left' }, size: { width: 'fill', height: mm(49) } } },
// The series line, the reprint's number, its description and contents are the first H1's.
text('series', '{attr.series}', LABEL, 8,
{ ...caps(8), color: col('paper'), placement: at('page', 'top-left', SIDE, 11, 120) }),
text('number', '{attr.reprint}', LABEL, 8, { ...caps(8), color: col('paper'), align: 'right',
placement: at('page', 'top-right', -SIDE, 11, 50) }),
text('wordmark', 'Surveillance Notes', DISPLAY, 50, { fontWeight: 800, color: col('paper'),
letterSpacing: pt(-1), lineHeight: 1, placement: at('page', 'top-left', SIDE - 1, 18) }),
text('issue', '{attr.issue}', TEXT, 9.5,
{ lineHeight: 1.3, placement: at('container', 'top-left', 0, 29, 92) }),
text('contents', '{attr.contents}', LABEL, 8, { inlineMarks: true, lineHeight: 1.3,
placement: at('container', 'top-right', 0, 29, 76), align: 'left' }),
rule('rule-a', 46.5, 2), rule('rule-b', 48, 0.5), ...reportHead(52, 23),
] } };
const opener = { enabled: true, minHeight: mm(26), slot: { elements: [rule('rule-a', 0, 2),
rule('rule-b', 1.5, 0.5), ...reportHead(5, 18)] } };
报头是第一篇报告标题样式的设计,所以只在第1页出现一次,书眉跳过这一页(pages: 'body')。眉题和日期行来自每篇报告H1的属性,标题则是{titleText}:文本元素设了inlineMarks: true,就保留标题中属名的斜体。7月的报告在一条双线下用同样的三个元素开头。它的标题样式以spanBreak: false横跨整页,所以标题从6月报告结束的地方开始:上方各栏底部齐平,下方正文在两栏中继续,就像周报把一篇报告接在另一篇之后那样。
#3 · 由制表符分隔文本生成的三张表
const NUMBER = /^[\d,.()% –]*$/; // a column of counts aligns right, its heading centred
const table = (tsv, headerRows, columnWidths) => {
const model = parseTSV(tsv, { headerRows });
const numeric = model.rows[0].map((_, c) => model.rows.slice(headerRows)
.every((row) => NUMBER.test(row[c].content)));
return { ...model, columnWidths, rows: model.rows.map((cells, r) => cells.map((cell, c) =>
(numeric[c] ? { ...cell, align: r < headerRows ? 'center' : 'right' } : cell))) };
};
// Two header rows, as the weekly printed them: "25th week ending" spans two columns.
const notifiable = [[0, 0, 1, 0], [0, 1, 0, 2], [0, 3, 1, 3], [0, 4, 0, 6]]
.reduce((m, [r1, c1, r2, c2]) => mergeCells(m, { start: { row: r1, col: c1 },
end: { row: r2, col: c2 } }), table(NOTIFIABLE, 2, [3.6, 1, 1, 1, 1.1, 1.1, 1.1]));
const added = 'Compiled for this reprint from the case reports; not part of the 1981 report.';
const res = (id, typeId, kind, placement, more) => ({ id, typeId, kind, placement,
createdAt: 0, updatedAt: 0, ...more });
const resources = [
res('fig-timeline', 'figure', 'svg', { position: 'bottom', span: 'page' }, {
svg: { fileId: 'timeline.svg', width: 1780, height: 490 },
caption: 'The five patients, September 1980 to May 1981, by month. The illness before '
+ 'the pneumonia is counted back from the month of diagnosis, as each report gives it.',
note: `Drawn by the editors. ${added}`,
altText: 'A timeline of five rows, one per patient: Pneumocystis pneumonia diagnosed '
+ 'between February and April 1981, two deaths in March and May.' }),
res('tbl-cases', 'table', 'table', { position: 'top', span: 'page' }, {
caption: 'The five case reports at a glance.', note: added,
table: { model: table(CASES, 1, [0.7, 0.45, 1, 2.2, 2.4, 1.5]) } }),
res('tbl-complaints', 'table', 'table', { position: 'bottom' }, {
caption: 'Presenting complaints in 20 patients with Kaposi’s sarcoma',
table: { model: table(COMPLAINTS, 1, [2, 1.15]) } }),
res('tbl-notifiable', 'table', 'table', { position: 'here' }, {
caption: 'Summary — cases of specified notifiable diseases, United States',
note: 'Cumulative totals include revised and delayed reports through previous weeks.',
table: { model: notifiable, styleId: 'weekly' } }),
];
每张表都是一个内容槽,里面是制表符分隔的文本,也就是电子表格复制出来的格式,parseTSV把它变成表格模型。数字列右对齐,列标题居中;四次mergeCells调用构成法定报告传染病汇总表的两行表头。表格类型在每个H1处重新计数(resetOn: 'h1'),所以每篇报告都有自己的表1,和1981年一样。
#4 · 一种蓝色,处处关联
const palette = { ink: '#1c1f24', accent: '#1f3f74', tint: '#e6eaf1', rule: '#a7b1c2',
muted: '#566070', paper: '#ffffff' };
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' } }));
色带、标签、页码、表头和图表都引用同一个调色板条目:把accent换成自己周报的颜色,六页一次全部改色。
完整食谱
// ═══ Postext Cookbook · Nº 143 · A weekly bulletin report: the first AIDS reports ═══
// https://postext.dev/en/cookbook/outbreak-report-bulletin
// Code: MIT · Text: CDC, MMWR 1981;30:250–252 and 305–308 (public domain) · Chart: original
// Fonts: IBM Plex Serif, Libre Franklin, Plex Sans Condensed (OFL) · Needs postext ≥ 1.34.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerCitationEngine, registerResourceImage,
defaultResourceTypes, parseTSV, mergeCells, inlineSvgFonts,
} 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 = 'outbreak-report-bulletin';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a federal blue on office white, every colour linked by id
const palette = { ink: '#1c1f24', accent: '#1f3f74', tint: '#e6eaf1', rule: '#a7b1c2',
muted: '#566070', paper: '#ffffff' };
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, DISPLAY, LABEL] = ['IBM Plex Serif', 'Libre Franklin', 'IBM Plex Sans Condensed'];
const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 22, 20, 19, 6.35];
const MEASURE = TRIM_W - 2 * SIDE; // US Letter, two columns of 86 mm
const LEAD = 13; // pt: 9.5 pt Plex Serif, as a bulletin sets two columns of Letter
const text = (id, content, family, size, extra) => ({ kind: 'text', id, content, align: 'left',
fontFamily: family, fontSize: pt(size), color: col('ink'), overflow: 'wrap', ...extra });
const at = (to, edge, x, y, width) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
...(width && { size: { width: mm(width), height: 'auto' } }) });
const caps = (size, extra) => ({ fontFamily: LABEL, fontSize: pt(size), fontWeight: 600,
letterSpacing: pt(size * 0.18), textTransform: 'uppercase', ...extra });
const rule = (id, y, thickness) => ({ kind: 'rule', id, color: col('accent'),
thickness: pt(thickness), placement: at('container', 'top-left', 0, y, MEASURE) });
// #region masthead: the bulletin's band, issue strip and contents over the first report
// Kicker and dateline are attributes of each report's H1; {titleText} read with inlineMarks
// keeps the italic genus. The July report opens where June ends, under a double rule.
const reportHead = (y, size) => [
text('kicker', '{attr.kicker}', LABEL, 8.5, { ...caps(8.5), color: col('accent'),
placement: at('container', 'top-left', 0, y, MEASURE) }),
text('title', '{titleText}', DISPLAY, size, { fontWeight: 800, lineHeight: 1.08,
inlineMarks: true, placement: at('#kicker', 'below', 0, 2.2, MEASURE) }),
text('dateline', '{attr.dateline}', LABEL, 9, { color: col('muted'),
placement: at('#title', 'below', 0, 2, MEASURE) }),
];
const masthead = { enabled: true, minHeight: mm(72), slot: { elements: [
组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)
变化
#上标的参考文献序号
多数医学期刊把序号排成上标,而不是放在括号里。
-const citations = { style: 'american-medical-association', marker: 'parentheses',
+const citations = { style: 'american-medical-association', marker: 'superscript',#每篇报告另起一页
分篇归档的重印系列让每篇报告从新的一页开始。
- { id: 'report', span: 'page', spanBreak: false, advancedDesign: opener },
+ { id: 'report', span: 'page', advancedDesign: opener },#温哥华格式的文献表
温哥华格式的医学论文修改了自带的elsevier-vancouver样式,使之符合NLM的参考文献格式。
常见问题
- 不设
numbering: 'chapter'时,参考文献序号贯穿整个文档,scope: 'chapter'只是把文献表分开:7月的报告会引用第4和第6至23号文献,而周报当年印的是1至19号。 - 1981年的脚注Paired specimens not run in parallel用星号标注:
footnotes.numberFormat: 'symbols'依次使用*、†、‡,并在每页重新开始。这些符号中只有星号在Fontsource字体的latin文件里(剑号在latin-ext里,双剑号两者都没有),所以一页有两三条脚注时,需要换用带这些符号的字体,或者设symbols: ['*', '§', '¶']。 - 1981年的文字按原样保留,包括当时的术语,版权说明里写明了这一点。重印不修改所复制的正文;编者添加的内容(时间线、病例表、第一段下面的蓝色斜体说明)用自己的样式并加以标注。
致谢
- 文本
- "Pneumocystis Pneumonia — Los Angeles", MMWR 1981;30(21):250–252, and "Kaposi's Sarcoma and Pneumocystis Pneumonia Among Homosexual Men — New York City and California", MMWR 1981;30(25):305–308, re-set in full from the printed issues; Table 1 of the first report and Figure 1 added by the editors from the case reports. "All material in the MMWR Series is in the public domain and may be used and reprinted without special permission; citation as to source, however, is appreciated." · Centers for Disease Control (CDC) · 公有领域
- 图片
- Figure 1, timeline of the five cases, drawn in code from the dates in the case reports · Ignacio Ferro · 原创
- 字体
- IBM Plex Serif (SIL OFL 1.1) · Libre Franklin (SIL OFL 1.1) · IBM Plex Sans Condensed (SIL OFL 1.1)


