かんたんな説明
Ibn Khaldūnの『歴史序説』の冒頭を、現代のアラビア語の学術校訂版として組みます。序文のページは文字で、本文は数字で番号を振り、脚注はページごとに1から数え直します。
できあがり
Ibn Khaldūnの『歴史序説』(Muqaddima)のうち、歴史学の優れた点を論じる最初の節を、現代のアラビア語の校訂版、つまりタフキーク(taḥqīq)として11ページ組みます。前付けには、カイロやベイルートの版と同じようにアブジャドの文字でノンブルを振ります。扉がأ、その裏の刊記がب、続く校訂者の序文がجとدです。本文は次の奇数ページで١から数え直します。校訂者の注は各ページの地に、右寄りの短い罫の下に置き、(١)、(٢)、(٣)と番号を振って、ページごとに振り直します。注は珍しい語を説明し、Ibn Khaldūnが挙げる人物と土地を特定し、クルアーンの引用ごとに章(スーラ)と節を示します。巻末には人名索引を置き、アラビア語の索引の流儀どおり、冠詞الを除いて並べます。注と序文はこのレシピのために書いたものです。
このレシピが答える質問
- アラビア語の本の前付けに、アブジャド文字(أ، ب، ج)でノンブルを振るには?
- アラビア語の脚注に、ページごとにかっこ付きの番号((١))を振るには?
手短な答え
// 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') },
};
材料
- 機能
- 脚注アラビア語の番号スタイルローマ数字の前付け生成される番号の数字右から左のテキスト右綴じの本アラビア語のフォント文書の言語としてのアラビア語見出しスタイル見出しの属性デザインした章扉柱とノンブルページの役割ごとの柱索引冠詞を無視して並べる索引段落スタイルセマンティックカラーパレットPDFの書き出しPDFに埋め込むフォント
- 種類
- Amiri, Aref Ruqaa (SIL OFL 1.1)
- 素材
- なし:画像はすべてコードで描画
作り方
#1 · 2系統のノンブルと、ページごとの注
コードは上の手短な答えにあります。page.pageNumberingは本を'abjad'、つまりアブジャド順の文字で始めます。5はهـです。本文の前に置いた2つのディレクティブが、次の奇数ページから文書の数字で数え直させます(:::numbering、数字と番号の書式)。注にはnumbering: 'page'、markerTemplateの'({n})'、noteNumberPosition: 'inline'を設定します。こうすると合印は本文の中で上がり、注は行の中でその番号から始まります(脚注)。

#2 · 冠詞を飛ばす索引
// 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 · 罫の上の柱
// 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 · 扉とその刊記
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上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#アブジャド数字を使う
'arabic-abjad'は、単純な文字の並びではなく、加算式のアブジャド数字を書きます。11ページ目はكではなくياになります。
-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',よくあるつまずき
つまずき
アラビア語の本のタグはLANGではなく'ar'にする
レシピの版は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'です。アラビア語を引用するだけのラテン文字のページは、自分のロケールのままにします。 右から左のテキスト →
つまずき
アラビア語の書体にはarabicブロックを通じてarabicファイルが必要
FontsourceはAmiri、Noto Naskh Arabic、Scheherazade Newをサブセットごとに1ファイルとして配信し、アラビア文字はarabicファイルに入っています。loadFontsが取得するのはlatin(とlatin-ext)だけなので、画面ではアラビア文字がシステムの書体で出て計測が狂い、fontsourceProviderはPDFにそのlatinファイルを渡すため、空の四角が印字されます。キットのarabicブロックを挙げ、loadFontsのあとにloadArabicFonts(FONTS, markdown)を呼び(ページでアラビア文字に使うすべてのウェイトをFONTSに挙げておきます)、renderToPdfにfontProvider: arabicPdfProviderを渡してください。 アラビア語のフォント →
つまずき
:::numberingは次のページから効く
:::numberingは、現在のページではなく、次に始まるページから番号を変えます。:::pagebreak(第1章の前なら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)


