かんたんな説明
アラビア語の学術誌の5ページです。論文、脚注、文献一覧、索引が入ります。索引ではアラビア語の索引の習慣どおり、الكشيدةを冠詞الではなくكの項に並べます。
できあがり
架空のアラビア語学術誌のある号から、87ページで始まる5ページを17 × 24 cmで組みます。カシーダによる両端そろえが読む速さを落とすかどうかを論じた論文で、本文は12 ptのAmiri、節見出しはNoto Kufi Arabicです。注は各ページの地に置き、アラビア語の学術誌の慣例どおり、ページごとに«(١)»、«(٢)»と1から番号を振ります。Markdownに[@ayalon2016]と書いた引用も注になり、アラビア語のCSLロケールを使ったシカゴ方式(注)のスタイルで整形されます。続いてアラビア語の文献を先に並べた文献一覧があり、2段組みの索引で論文が終わります。索引ではالكشيدةをكの項に、الصحف اليوميةをصの項に並べ、冠詞الは数えません。シカゴ式の注を付けた歴史論文は同じことを英語で行います。
このレシピが答える質問
- アラビア語の索引を、冠詞الを除いて並べるには?
- アラビア語の記事で、脚注と参考文献を使って出典を引用するには?
手短な答え
// Citations are written [@ayalon2016, 45] in the text; a note style puts each one in a
// footnote, numbered with the author's own [^notes]. The CSL locale is Arabic: ص for a page.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const citations = {
style: 'chicago-notes-bibliography', notes: 'footnote', locale: 'ar',
bibliography: { fontSize: em(0.9), lineHeight: pt(17), hangingIndent: em(2),
entrySpacing: pt(2) },
};
const footnotes = {
markerTemplate: '({n})', // «(١)», in the document's digits
numbering: 'page', // from (١) again on every page, as Arabic journals number them
noteNumberPosition: 'inline', // the note opens with (١) on the line, not raised
fontSize: pt(10), lineHeight: pt(18), spaceBetween: pt(2), // 1.8 ×: tanwīn clears the line
textAlign: 'start', // ragged from the right: a Latin title would open wide gaps
separator: { width: 0.3, lineWidth: pt(0.5), color: col('red') }, // on the start side
};
// The index sorts by the word after the article: الكشيدة files under ك, not under ا.
// ignoreArticle is already true for an Arabic index; it is written out to be seen.
const index = {
ignoreArticle: true,
fontFamily: TEXT, fontSize: pt(10.5), lineHeight: pt(16), indent: em(1.2),
main: { bold: true }, // the page that defines the term
groups: { fontFamily: LABEL, fontSize: pt(10), fontWeight: 700, color: col('red') },
};
材料
- 機能
- 文書の言語としてのアラビア語冠詞を無視して並べる索引注による引用脚注引用スタイルによる引用参考文献から作る文献一覧索引右から左のテキストアラビア語のフォント生成される番号の数字番号付き見出し見出しスタイルデザインした章扉柱とノンブル囲みPDFの書き出し
- 種類
- Amiri, Noto Kufi Arabic (SIL OFL 1.1)
- 素材
- なし:画像はすべてコードで描画
作り方
#1 · 注、引用、索引を1か所で設定する
コードは前出の手短な答えにあります。脚注の設定は、アラビア語の本が求める3つです。括弧を付けるmarkerTemplate: '({n})'、ページごとに番号を振り直すnumbering: 'page'、注の行頭に«(١)»を置くnoteNumberPosition: 'inline'です。数字は文書の数字を使い、罫は右に立ちます(脚注)。引用は注と番号を共有します。citations.locale: 'ar'でCSLの用語がアラビア語になり、たとえば号数にはعددが付きます。index.ignoreArticleは各項目をالのあとの語で並べ、ハムザの諸形を同一視するので、أميريもالأعمدةもاの項に入ります(目次と索引)。アラビア語の索引では既定でオンですが、ここでは見えるように書いておきます。

#2 · 帯のない誌名欄
const centred = (y, extra = {}) => ({ anchor: { to: 'container', edge: 'top' },
offset: { y: mm(y) }, size: { width: 'fill' }, ...extra });
const line = (id, content, family, size, colour, y, extra = {}) => ({ kind: 'text', id,
content, fontFamily: family, fontSize: pt(size), color: col(colour), align: 'center',
overflow: 'wrap', placement: centred(y), ...extra });
const masthead = { enabled: true, minHeight: mm(70), slot: { elements: [
line('journal', JOURNAL, LABEL, 9, 'red', 0, { fontWeight: 700 }),
line('issue', '{attr.issue}', LABEL, 8, 'muted', 6),
{ kind: 'rule', id: 'rule', thickness: pt(0.5), color: col('rule'),
placement: centred(13) },
line('title', '{titleText}', TEXT, 22, 'ink', 18, { fontWeight: 700, lineHeight: 1.45 }),
line('author', '{attr.author}', TEXT, 13, 'ink', 45),
line('affiliation', '{attr.affiliation}', TEXT, 10, 'muted', 52),
] } };
論文の表題は1レベル見出しで、デザインで描きます。誌名と号数、細罫、2行に中央そろえした表題、著者が並びます。号数の行はアラビア・インド数字で入力しています。デザインの属性は著者が書いたテキストで、エンジンは書き換えないからです。ノンブルは87から始まる(page.pageNumbering.startAt)ので、論文が号のどこに載っているかがノンブルからわかります。
#3 · 小口の角から柱を置く
const head = (id, content, parity, edge, x) => ({ kind: 'text', id, content, parity,
pages: 'body', fontFamily: LABEL, fontSize: pt(7.5), color: col('muted'), align: edge,
placement: { anchor: { to: 'page', edge: `top-${edge}` }, offset: { x: mm(x), y: mm(13) } } });
const folio = (id, parity, edge, x) => ({ ...head(id, '{pageNumber}', parity, edge, x),
fontWeight: 700, color: col('red') });
const header = { elements: [
folio('r-folio', 'even', 'right', -SIDE.outer),
head('r-head', JOURNAL, 'even', 'right', -(SIDE.outer + 9)),
head('l-head', SHORT_TITLE, 'odd', 'left', SIDE.outer + 9),
folio('l-folio', 'odd', 'left', SIDE.outer),
] };
右ページには誌名を、左ページには著者と短い表題を入れ、それぞれ小口の角にノンブルを添えます。ヘッダーの要素は物理的な左右を保つので、この綴じ方で右側に来る偶数ページはtop-rightを基準にします。
レシピの全体
// ═══ Postext Cookbook · Nº 107 · An Arabic research article with notes, citations and an index ═══
// https://postext.dev/en/cookbook/arabic-research-article
// Code: MIT · Text: original Arabic prose (CC BY 4.0) · Pictures: none
// Fonts: Amiri, Noto Kufi Arabic (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
buildDocument, 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 frame; the article is Arabic in both editions
const RECIPE = 'arabic-research-article';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a journal's dark red on a warm white
const palette = {
ink: '#1d1a19', // text
red: '#7d2028', // the accent: the journal's name, section numbers, the notes' rule
rose: '#f1e4e1', // the abstract's ground
rule: '#c8bcb5', // hairlines
muted: '#655d58', // running heads, the colophon
paper: '#fffdfa',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.red })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [TEXT, LABEL] = ['Amiri', 'Noto Kufi Arabic'];
const [BODY, LEAD] = [12, 20]; // pt: Amiri, partly vocalised, at 1.67 × the size
const TRIM = { width: 170, height: 240 }; // mm: 17 × 24 cm, the Arab journal
const SIDE = { inner: 22, outer: 18 }; // mm
const JOURNAL = 'مجلة دراسات الكتاب والنشر';
const SHORT_TITLE = 'سلمى الخطيب: أثر الكشيدة في سرعة القراءة'; // the recto's running head
// #region answer: notes «(١)» per page, the citations among them, an index without ال
// Citations are written [@ayalon2016, 45] in the text; a note style puts each one in a
// footnote, numbered with the author's own [^notes]. The CSL locale is Arabic: ص for a page.
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const citations = {
style: 'chicago-notes-bibliography', notes: 'footnote', locale: 'ar',
bibliography: { fontSize: em(0.9), lineHeight: pt(17), hangingIndent: em(2),
entrySpacing: pt(2) },
};
const footnotes = {
markerTemplate: '({n})', // «(١)», in the document's digits
numbering: 'page', // from (١) again on every page, as Arabic journals number them
noteNumberPosition: 'inline', // the note opens with (١) on the line, not raised
fontSize: pt(10), lineHeight: pt(18), spaceBetween: pt(2), // 1.8 ×: tanwīn clears the line
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
よくあるつまずき
つまずき
アラビア語の本のタグは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を渡してください。 アラビア語のフォント →
つまずき
見出しスタイルはその階層の改ページを受け継ぐ
headingStylesの項目は、指定しなかったフィールドをすべて見出しの階層から受け継ぎ、breakBeforeも例外ではありません。:::pagebreakのあとのH1に付けた目次や奥付のスタイルはparity 'odd'を受け継ぎ、白ページの後ろに置かれます。こうしたスタイルにはbreakBefore: { enabled: false }を指定してください。 見出しスタイル →
- CSLスタイルが書く約物はスタイルのものです。注の各部分のあいだのコンマ、セミコロン、引用符はラテン文字のもので、الهاشمي, الحرف العربيのようになります。日付と数値はデータから取るので、アラビア語の文献には
issued: {literal: "٢٠١٩"}や[@hashimi2019, ٧٧]のようなロケーターを書いています。ラテン文字の文献は0–9のままです。 - ラテン文字の文献を挙げた注や文献はアラビア語のページの段落のままで、右から組まれ、その中は左から右へ読みます。エンジンが文献を隔離された一続きとして組むので、URL、引用符、最後のピリオドは文献の終わりに残ります。
クレジット
- 本文
- A research article written in Arabic for the recipe; its journal, author, experiment and Arabic sources are invented · Postext Cookbook · オリジナル
- フォント
- Amiri (SIL OFL 1.1) · Noto Kufi Arabic (SIL OFL 1.1)


