跳到主要内容
食谱编号113

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

校勘本(taḥqīq):按页编注,前置部分用abjad编页

前置部分页码为أ ب ج د,正文从١开始,校者注每页重新编号为(١),索引排序时忽略冠词ال。

本页内容
类型
教科书
输出
Canvas · PDF
难度
高级
Postext
已用Postext 1.65.0测试
需要≥ 1.25.0 · postext-pdf ≥ 1.25.0
许可证
更新于2026年10月10日
代码MIT · 文本MIT

页码د–١ · 第4–5页,共11页

  • 英文样例:尚无中文版本
  • 成品尺寸170 × 240 mm
  • 1栏
  • Amiri 13/22.5
  • Aref Ruqaa
  • 11页
  • 难度
  • Postext 1.65.0
  • 排版用时432 ms
  • 165行代码

简单来说

把伊本·赫勒敦《历史绪论》的开头排成一部现代阿拉伯文校勘本:导言页用阿拉伯字母编页,正文用阿拉伯数字,页脚的校者注每页都从一重新编号。

成品一览

伊本·赫勒敦《历史绪论》(Muqaddima)第一部分“论历史学之可贵”的现代阿拉伯文校勘本,共十一页。前置部分按开罗和贝鲁特的版本习惯用abjad字母编页:书名页أ,其背面的版权页ب,然后是校者导言ج和د。正文在下一个奇数页从١重新开始。校者注放在每页页脚,编为(١)、(٢)、(٣),每页重新起算,排在右侧一条短线下;注释解释生僻词,考订伊本·赫勒敦提到的人名地名,并为每段古兰经引文注明章节。书末是人名索引,按阿拉伯文索引的习惯排序,不计冠词ال。注释和导言都是为这个食谱撰写的。

这道食谱解答

  • 阿拉伯文书的前置部分怎样用abjad字母(أ، ب، ج)编页码?
  • 阿拉伯文脚注怎样按页编号并加括号:(١)?

简短回答

script.js · 第33–48行在完整代码中
// The page counter starts in abjad letters: the title page is أ, its back ب, the editor's
// introduction ج and د. Before the text, two directives in the Markdown count again from 1,
// in the document's digits (١ ٢ ٣ in an `ar` document), on the next odd page:
//   :::pagebreak{parity="odd"}
//   :::numbering{format="arabic-indic" startAt=1}
// {pageNumber} prints each page's own label, so one footer and one header serve both runs.
const pageNumbering = { format: 'abjad', startAt: 1 }; // أ ب ج د هـ و ز ح…
// The editor's notes: numbered again on every page, written «(١)», raised after the word in
// the text and on the line at the head of the note. The rule over the notes and each note's
// number stand on the start side, the right, because the page runs right to left.
const footnotes = {
  numbering: 'page', markerTemplate: '({n})', noteNumberPosition: 'inline',
  fontSize: pt(10.5), lineHeight: pt(18.5), color: col('ink'), textAlign: 'justify',
  spaceAbove: pt(14), spaceBelowRule: pt(6),
  separator: { width: 0.28, lineWidth: pt(0.6), color: col('rule') },
};

用料

类型
Amiri, Aref Ruqaa(SIL OFL 1.1)
素材
无:所有图片都用代码绘制

做法

#1 · 两套页码,按页编注

代码见上文的简短回答。page.pageNumbering让全书从'abjad'开始,即按abjad顺序排列的字母,五写作هـ。正文之前,两个指令在下一个奇数页用文档数字重新计数(:::numbering、数字系统与编号样式)。脚注设为numbering: 'page'、markerTemplate为'({n})'、noteNumberPosition: 'inline',所以注码在正文中上标,注释则以平排的序号开头(脚注)。

第١页:注释重新从(١)开始,排在页面起始一侧的短线下。

#2 · 跳过冠词的索引

script.js · 第52–60行在完整代码中
// Marks in the text, `:index[المسعودي]`, `:index[الطّبريّ]{term="الطبري"}`. With
// ignoreArticle, المسعودي files under م and الطبري under ط; ابن الكلبي stays under ا.
// It is the default when the index sorts in Arabic: written out here to say so.
const index = { ignoreArticle: true, fontFamily: NASKH, fontSize: pt(11), lineHeight: pt(17),
  color: col('ink'), groups: { fontFamily: NASKH, fontWeight: 700, fontSize: pt(13),
    color: col('accent'), marginTop: pt(8) } };
const indexStyle = { id: 'index', numbered: false, toc: false, span: 'page',
  breakBefore: { enabled: true, parity: 'any' },
  layout: { layoutType: 'double', gutterWidth: mm(10) } }; // two columns under the title

人名在正文里用:index[المسعودي]标记,:::index把它们印在书末。设了ignoreArticle后,المسعودي归在م下,الطبري归在ط下,而ابن إسحاق仍在ا下;一条参见把إسرائيل引向يعقوب(目录与索引)。索引中的页码是页面的标签,所以导言里的人名指向ج。

#3 · 线上的书眉

script.js · 第88–110行在完整代码中
// Running heads are physical. In a book bound on the right the verso (even) is the right
// page: its outer edge, the folio's, is the right one, and its text block starts INNER mm
// from the left edge; the recto (odd) mirrors it.
const HEAD_Y = 14; // mm from the trim
const blockX = (parity) => (parity === 'even' ? INNER : OUTER); // the text block's left edge
const heads = (parity, content) => [
  text(`${parity}-head`, content, NASKH, 10.5,
    { ...at('top-left', blockX(parity), HEAD_Y, 'page'), size: { width: mm(MEASURE) } },
    { color: col('muted'), parity, pages: 'body' }),
  text(`${parity}-folio`, '{pageNumber}', NASKH, 11.5, parity === 'even'
    ? at('top-right', -OUTER, HEAD_Y, 'page') : at('top-left', OUTER, HEAD_Y, 'page'),
  { parity, pages: 'body', align: parity === 'even' ? 'right' : 'left' }),
  { ...rule(`${parity}-rule`, HEAD_Y + 7, MEASURE, 'top-left', 'page', blockX(parity)),
    parity, pages: 'body' },
];
const header = { elements: [...heads('even', '{title}'), ...heads('odd', '{chapterTitle}')] };
const dropFolio = (pages) => text(`folio-${pages}`, '{pageNumber}', NASKH, 11.5,
  at('bottom', 0, -12, 'page'), { pages });
const footer = { elements: [dropFolio('opener')] }; // on the openers, under the text
// Front matter: no running heads, the abjad folio centred at the foot of every page.
const front = { id: 'front', numbered: false, toc: false,
  breakBefore: { enabled: true, parity: 'any' }, header: { elements: [] },
  footer: { elements: [dropFolio('all')] }, advancedDesign: titleOnly(22) };

偶数页书眉印书名,奇数页印章节名,下面是一条与版心等宽的细线,页码在外端。右侧装订的书,偶数页在跨页右边,所以它的页码在右上(页序与右侧装订)。章首页和前置部分则把页码居中放在页脚。

#4 · 书名页和版权页

script.js · 第114–135行在完整代码中
const onPage = (y) => at('top', 0, y, 'page');
const blind = { numbered: false, toc: false, span: 'page', runningChapter: false,
  breakBefore: { enabled: true, parity: 'any' }, header: { elements: [] },
  footer: { elements: [] } }; // blind folios: أ and ب count, but do not print
const titlePage = { id: 'title', ...blind, advancedDesign: design([
  text('book', '{attr.book}', NASKH, 14, onPage(44), { color: col('muted') }),
  rule('rule-top', 58, 40, 'top', 'page'),
  text('title', '{titleText}', RUQAA, 44, onPage(64), { fontWeight: 700,
    color: col('accent'), lineHeight: 1.3 }),
  rule('rule-foot', 92, 40, 'top', 'page'),
  text('author', 'تأليف {author}', NASKH, 15, onPage(100), { fontWeight: 700 }),
  text('years', '{attr.years}', NASKH, 12, onPage(110)),
  text('part', '{attr.part}: {subtitle}', NASKH, 13, onPage(132)),
  text('editor', '{attr.editor}', NASKH, 12, onPage(178), { color: col('accent') }),
  text('latin', '{attr.latin}', NASKH, 9.5, { ...onPage(196), size: { width: mm(110) } },
    { color: col('muted'), direction: 'ltr' }), // a Latin line: its own direction
], 0) };
const imprintPage = { id: 'imprint', ...blind, advancedDesign: design([
  text('edition', '{attr.edition}', NASKH, 11, onPage(170)),
  text('imprint', '{attr.imprint}', NASKH, 9, { ...onPage(180), size: { width: mm(100) } },
    { color: col('muted'), lineHeight: 1.45, direction: 'ltr' }),
], 0) };

书名页和它背面的版权页都是正文流里没有内容的标题样式:各行取自标题属性,所以版权页上随版本语言变化的拉丁文行,在Markdown里只是一个属性。

完整食谱

沙盒
// ═══ Postext Cookbook · Nº 113 · A critical edition (taḥqīq) with notes per page ═══════
// https://postext.dev/en/cookbook/tahqiq-critical-edition
// Code: MIT · Text: Ibn Khaldūn, al-Muqaddima, ar.wikisource (PD) · Pictures: none
// Fonts: Amiri, Aref Ruqaa (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import { buildDocument, withLoadedFonts, 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 = 'tahqiq-critical-edition';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// A modern Cairo taḥqīq: black Naskh on a cream paper, headings and rules in one dark red.
const palette = {
  ink: '#1e1a16', // text and notes: a warm near-black
  accent: '#8a2a1d', // headings, the title, the index letters
  rule: '#8c7a62', // hairlines: the rule under the running heads, the rule over the notes
  muted: '#5e564c', // running heads, the imprint
  paper: '#fbf8f0', // a cream paper
};
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' } },
];
const NASKH = 'Amiri'; // text, notes, headings in bold, running heads, index
const RUQAA = 'Aref Ruqaa'; // display: the title on the title page
const [W, H] = [170, 240]; // mm: 17 × 24 cm, the size of most Cairo and Beirut editions
const [TOP, INNER, OUTER] = [22, 20, 16]; // mm; `left` is the inner margin on both pages
const MEASURE = W - INNER - OUTER; // 134 mm
const [SIZE, LEAD] = [13, 22.5]; // pt: 1.73 ×, so the few vowels marked clear the line above

// #region answer: abjad folios for the front matter, Arabic-Indic from the text, notes (١)
// The page counter starts in abjad letters: the title page is أ, its back ب, the editor's
// introduction ج and د. Before the text, two directives in the Markdown count again from 1,
// in the document's digits (١ ٢ ٣ in an `ar` document), on the next odd page:
//   :::pagebreak{parity="odd"}
//   :::numbering{format="arabic-indic" startAt=1}
// {pageNumber} prints each page's own label, so one footer and one header serve both runs.
const pageNumbering = { format: 'abjad', startAt: 1 }; // أ ب ج د هـ و ز ح…
// The editor's notes: numbered again on every page, written «(١)», raised after the word in
// the text and on the line at the head of the note. The rule over the notes and each note's
// number stand on the start side, the right, because the page runs right to left.
const footnotes = {
  numbering: 'page', markerTemplate: '({n})', noteNumberPosition: 'inline',
  fontSize: pt(10.5), lineHeight: pt(18.5), color: col('ink'), textAlign: 'justify',
  spaceAbove: pt(14), spaceBelowRule: pt(6),
  separator: { width: 0.28, lineWidth: pt(0.6), color: col('rule') },
};

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

变化

#改用abjad数字

'arabic-abjad'写出累加式的abjad数字,而不是简单的字母序列:第十一页是يا,而不是ك。

-const pageNumbering = { format: 'abjad', startAt: 1 }; // أ ب ج د هـ و ز ح…
+const pageNumbering = { format: 'arabic-abjad', startAt: 1 }; // … ط ي يا يب

#整节连续编注

numbering: 'chapter'让注释跨页连续编号,一些旧版本就是这样做的。

-  numbering: 'page', markerTemplate: '({n})', noteNumberPosition: 'inline',
+  numbering: 'chapter', markerTemplate: '({n})', noteNumberPosition: 'inline',

常见问题

易错点

阿拉伯文书标记为'ar',不要用LANG

食谱的版本是en和es,但阿拉伯文示例在两个版本里都是阿拉伯文:`locale: LANG`会让它从左向右排、左装订、页码印成1 2 3,并把图标注为Figure或Figura。postext 1.30起,这个标记也是文字成形所用的语言(测量、绘制和嵌入都按它进行),所以标记成英文或西班牙文时,Markazi Text这样的字体不画尖角引号(« »)和句点的阿拉伯文字形,断行的位置也随之改变。自己写出标记:'ar'(阿拉伯-印度数字,马什里克惯例),或带地区的'ar-EG'、'ar-SA';马格里布版本用欧洲数字,写'ar-MA'、'ar-DZ'或'ar-TN'。只引用阿拉伯文的拉丁文页面保留自己的locale。 从右向左的文字 →

易错点

阿拉伯文字体需要通过arabic块加载其arabic文件

Fontsource把Amiri、Noto Naskh Arabic或Scheherazade New按子集分成多个文件提供,阿拉伯字母在arabic文件里。loadFonts只获取latin(以及latin-ext),所以屏幕上的阿拉伯文来自系统字体,测量不准;fontsourceProvider交给PDF的也是这个latin文件,印出来是空框。列出kit中的arabic块,在loadFonts之后调用loadArabicFonts(FONTS, markdown),并在FONTS中列出页面用于阿拉伯文的每个字重,再给renderToPdf传fontProvider: arabicPdfProvider。 阿拉伯文字体 →

易错点

:::numbering从下一页起生效

:::numbering从下一个开始的页面起改变计数,而不是当前页。把它紧跟在:::pagebreak之后(第一章之前用parity odd),新的编号才会从你想要的地方开始。 罗马数字页码的前置部分 →

致谢

文本
  • The opening section of the Muqaddima, “On the excellence of history”, as ar.wikisource gives it (revision 610595), without its notes · Ibn Khaldūn · 公有领域
  • The editor’s introduction in Arabic, the notes, the index and the imprint · Postext Cookbook · 原创
字体
Amiri (SIL OFL 1.1) · Aref Ruqaa (SIL OFL 1.1)
沙盒PDF