简单来说
一份简短的立法对照文件。先列出法律的旧文,删去的词划掉,新增的词加下划线,再把修正后的整节放进一个灰色的框里。
成品一览
一份随法案印发的委员会文件:五页,展示 1998 年《桑尼·波诺版权期限延长法》第 102 条对《美国法典》第 17 编做了哪些修改。法律本身只说“删去‘fifty’,插入‘70’”;这份文件把修改前的法律排出来,每处改动标在原位,删去的划删除线,新增的加下划线,上面印着联邦和各州起草人员在这类文本前印的图例;随后是修正后的第 302 条,放在一个浅色底的框里,各款字母在框边,正文及其转行悬挂在后。西班牙语版用同样的办法排出西班牙宪法 1992、2011 和 2024 年在《国家官方公报》(BOE)上公布的三次修改。
这道食谱解答
- 怎样展示一项修正:删去的词加删除线,新增的词加下划线?
简短回答
// In the text, ~~fifty~~ strikes a deleted word and :underline[70] underlines the new one.
// Both lines are painted from the face's own metrics and take no room, so the struck and
// the inserted words justify and hyphenate like any others. The amended text then sits in
// a box whose paragraphs hang: '(a)', a tab, and every turnover line under the text.
const label = { fontFamily: SANS, fontSize: pt(7.5), fontWeight: 700, letterSpacing: pt(1.1),
textTransform: 'uppercase', color: col('accent') };
const clauses = { fontFamily: SERIF, fontSize: pt(9.5), lineHeight: pt(13), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), textAlign: 'left', // a box's measure is short
hangingIndent: HANG, // every line but the first starts 7 mm in (postext ≥ 1.71)
tabStops: [{ position: HANG }] }; // and the tab after the marker takes the text there
const pad = (v, h) => ({ top: mm(v), right: mm(h), bottom: mm(v), left: mm(h) });
const calloutStyles = [
// The coding legend: a red rule down its side, the label face.
{ id: 'legend', backgroundEnabled: false,
stripe: { enabled: true, side: 'left', width: pt(2.5), color: col('accent') },
padding: pad(1.5, 3.5), body: { fontFamily: SANS, fontSize: pt(9), lineHeight: pt(12.5),
color: col('ink'), boldColor: col('accent'), firstLineIndent: pt(0), textAlign: 'left' } },
// The bill's own words: a red rule on top, clauses hung, no tint.
{ id: 'bill', backgroundEnabled: false,
stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('accent') },
padding: pad(2.5, 0), body: clauses, keepTogether: false, // it may run on to the next page
// its title keeps its case: "(b)" stays "(b)"
titleStyle: { ...label, textTransform: 'none', letterSpacing: pt(0.2), fontSize: pt(8.5),
color: col('ink') } },
// The text as amended: a tint, the clauses hung the same way.
{ id: 'amended', background: col('tint'), padding: pad(3.5, 4.5), titleStyle: label,
body: clauses },
];
用料
做法
#1 · 在改动发生的地方标出改动
代码就是上面的简短回答。标记写在 Markdown 里:~~fifty~~ :underline[70] 划掉旧词,给新词加下划线(删除线、下划线)。两种线都不占位置,所以一段六行的被删条款和周围的正文一样两端对齐、断词;第 3 页上旧的第 304(b) 款整段划掉,新条文在同一段里加下划线。每条线都按字体本身的删除线和下划线参数画出,颜色跟随文字,所以小型大写的款目标题有自己高度上的线。
#2 · 让框里的条款悬挂排列
在框样式里设 body.hangingIndent,框内所有段落都悬挂排列(框内的排版):首行从框的内边开始,其余各行退进 7 mm。在同样 7 mm 处设一个制表位,把“(a)”或“(c)”后面的正文带到这条边上,不管字母多宽;所以 Markdown 里写 (a):tab In General.—…。法案条款和修正后的条文用同一套排版,只是框不同:法案上方一条红线,现行条文后面一层底色。法案的框可以拆开(keepTogether: false),所以第 1 页以它的前两项结束。
#3 · 开篇的色带
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const BAND = 66; // mm from the trim top to the foot of the band
const opener = { enabled: true, minHeight: mm(BAND - 22 + 6), marginBottom: pt(0), slot: {
elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('band') },
placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: mm(BAND + 3) } } },
{ kind: 'text', id: 'kicker', content: '{attr.kicker}', ...label, color: col('pale'),
placement: { ...at('container', 'top-left', 0, 6), size: { width: mm(112) } } },
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: SERIF, fontWeight: 700,
fontSize: pt(30), lineHeight: 1.05, color: col('paper'), align: 'left',
placement: { ...at('#kicker', 'below', 0, 3), size: { width: mm(112), height: 'auto' } } },
{ kind: 'text', id: 'dek', content: '{attr.dek}', fontFamily: SERIF, italic: true,
fontSize: pt(10.5), lineHeight: 1.3, color: col('pale'), align: 'left',
placement: { ...at('#title', 'below', 0, 3.5), size: { width: mm(104), height: 'auto' } } },
] } };
深蓝色带从页面上边和左右两边出血,栏目标签和导语来自标题行上的属性(标题属性)。minHeight 决定图例从哪里开始,在色带下方几毫米处。
#4 · 按奇偶页排的书眉
const head = (id, content, parity, edge, x, extra = {}) => ({
kind: 'text', id, content, parity, pages: 'body', fontFamily: SANS, fontSize: pt(7.5),
fontWeight: 600, letterSpacing: pt(1.1), textTransform: 'uppercase', color: col('muted'),
placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(13) } }, ...extra });
const folio = { fontWeight: 700, color: col('ink') };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
head('verso-title', '{title}', 'even', 'top-left', OUTER + 8),
head('recto-title', '{firstMark.h2}', 'odd', 'top-right', -(OUTER + 8)),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, folio),
] };
const footer = { elements: [head('drop-folio', '{pageNumber}', 'all', 'top', 0,
{ ...folio, pages: 'opener', placement: at('container', 'top', 0, 9) })] };
偶数页印文件标题,奇数页印该页开头所在的部分,取自页上第一个二级标题。pages: 'body' 让书眉不出现在开篇页,开篇页改在页脚印页码。
完整食谱
// ═══ Postext Cookbook · Nº 182 · An amendment shown struck through and underlined ═════
// https://postext.dev/en/cookbook/amendment-redline
// Code: MIT · Text: Pub. L. 105-298 and 17 U.S.C. (US Gov., PD); Constitución Española (BOE)
// Fonts: Source Serif 4, Source Sans 3 (SIL OFL 1.1) · Needs postext ≥ 1.73.0
// A comparative print: the law as it stood, each deletion ~~struck through~~ and each
// insertion :underline[underlined], then the amended text in a box whose clauses hang.
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'amendment-redline';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a government-print navy, one red for rules and labels
const palette = {
ink: '#1b1d22', // text: a cool near-black
band: '#1f2b47', // the opener's band: navy
accent: '#a1321f', // labels, stripes, the legend's rule
tint: '#eef0f4', // the box of the amended text
rule: '#c7ccd6', // hairlines
muted: '#5d6370', // running heads, notes, colophon
paper: '#ffffff',
pale: '#c9d2e6', // the kicker and the standfirst on the band
};
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' } })),
{ id: 'main-color', name: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
// #endregion
const SERIF = 'Source Serif 4', SANS = 'Source Sans 3';
const TRIM = [152, 229], INNER = 20, OUTER = 17; // mm: a 6 × 9 in committee print
const LEAD = 14; // pt: the body leading
const HANG = mm(7); // how far the clauses of a box hang: the width of "(a)" and a space
// #region answer: the marks live in the Markdown; the boxes hang their clauses
// In the text, ~~fifty~~ strikes a deleted word and :underline[70] underlines the new one.
// Both lines are painted from the face's own metrics and take no room, so the struck and
// the inserted words justify and hyphenate like any others. The amended text then sits in
// a box whose paragraphs hang: '(a)', a tab, and every turnover line under the text.
const label = { fontFamily: SANS, fontSize: pt(7.5), fontWeight: 700, letterSpacing: pt(1.1),
textTransform: 'uppercase', color: col('accent') };
const clauses = { fontFamily: SERIF, fontSize: pt(9.5), lineHeight: pt(13), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), textAlign: 'left', // a box's measure is short
hangingIndent: HANG, // every line but the first starts 7 mm in (postext ≥ 1.71)
tabStops: [{ position: HANG }] }; // and the tab after the marker takes the text there
const pad = (v, h) => ({ top: mm(v), right: mm(h), bottom: mm(v), left: mm(h) });
const calloutStyles = [
组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)
变化
#把新增部分写成 ++text++
打开 plusUnderline 后,++70++ 和 :underline[70] 一样加下划线,这是 Pandoc 和 markdown-it 表示插入文字的写法。
textAlign: 'justify', firstLineIndent: mm(4.5), indentAfterHeading: false,
+ plusUnderline: true, // ++text++ underlines; C++ in the text is then written C\+\+#让法案的条款不拆开
去掉 keepTogether: false,整个框移到第 2 页,第 1 页停在引出它的那一行。
- padding: pad(2.5, 0), body: clauses, keepTogether: false, // it may run on to the next page
+ padding: pad(2.5, 0), body: clauses,常见问题
- 以数字加句点开头的段落(
2. Solamente…)会被当作列表项,在句点前加反斜杠则会把反斜杠印出来。西班牙语版在正文里于数字和句点之间放一个字连接符(U+2060),在框里则把制表符紧跟在句点后面写成1.:tab,这不是列表标记。 - 只靠颜色经不起复印,而这类文件常常就是复印着传阅的;删除线和下划线在黑白复印件上照样看得清,起草人员正是因此选用它们。
致谢
- 文本
- Section 102 of the Sonny Bono Copyright Term Extension Act (Pub. L. 105-298, 112 Stat. 2827, 1998) and sections 302–304 of title 17, United States Code, as in force in 1997 · United States Congress · 公有领域
- Articles 13.2, 49 and 135 of the Spanish Constitution in their 1978 wording and the reforms of 1992, 2011 and 2024 (official texts, not subject to copyright under art. 13 LPI) · Cortes Generales, Boletín Oficial del Estado · 公有领域
- The editor’s notes, the coding legends and the colophons · Ignacio Ferro · CC BY 4.0
- 字体
- Source Serif 4 (SIL OFL 1.1) · Source Sans 3 (SIL OFL 1.1)


