Saltar al contingut principal
Recepta número 113

Receptari · Capítol 5 · Estructura del llibre

Un taḥqīq: notes per pàgina i preliminars en abjad

Preliminars foliats أ ب ج د, el text des de ١, notes de l'editor numerades (١) de nou a cada pàgina i un índex que ordena els noms sense l'article ال.

En aquesta pàgina
Sortida
Canvas · PDF
Nivell
Avançat
Postext
Provada amb Postext 1.65.0
Requereix ≥ 1.25.0 · postext-pdf ≥ 1.25.0
Llicència
Actualitzada el 10 d’oct. del 2026
Codi MIT · Text MIT

pp. د–١ · 4–5 de 11

  • Mostra en castellà: encara no hi ha edició en català
  • Format 170 × 240 mm
  • 1 columna
  • Amiri 13/22,5
  • Aref Ruqaa
  • 11 pàgines
  • Nivell
  • Postext 1.65.0
  • Compost en 352 ms
  • 165 línies de codi

En poques paraules

El començament de la Muqaddima d'Ibn Khaldun com a edició crítica àrab moderna: la introducció numerada amb lletres, el text amb xifres i notes a peu de pàgina que tornen a començar per u a cada pàgina.

Què compondràs

Onze pàgines d'una edició crítica àrab moderna, un taḥqīq, de la primera secció de la Muqaddima d'Ibn Khaldun, sobre l'excel·lència de la història. Els preliminars es folien amb lletres abjad, com fan les edicions del Caire i de Beirut: una portada أ, la seva pàgina de crèdits ب i la introducció de l'editor ج i د. El text torna a començar a ١ a la pàgina senar següent. Les notes de l'editor van al peu de cada pàgina, numerades (١), (٢), (٣) i reiniciades a cada pàgina, sota un filet curt a la dreta; glossen paraules rares, identifiquen les persones i els llocs que anomena Ibn Khaldun i donen la sura i el verset de cada cita de l'Alcorà. Un índex de noms tanca el llibre, ordenat com s'ordenen els índexs àrabs, sense l'article ال. Les notes i la introducció s'han escrit per a aquesta recepta.

Aquesta recepta respon a

  • Com numero els preliminars d'un llibre àrab amb lletres abjad (أ، ب، ج)?
  • Com numero les notes a peu de pàgina àrabs per pàgina, entre parèntesis: (١)?

La resposta curta

script.js · línies 33–48al codi complet
// 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') },
};

Ingredients

Tipografia
Amiri, Aref Ruqaa (SIL OFL 1.1)
Recursos
Cap: totes les imatges es dibuixen en codi

Elaboració

#1 · Dues sèries de folis i notes per pàgina

El codi és la resposta curta de dalt. page.pageNumbering comença el llibre en 'abjad', les lletres en l'ordre abjad, amb هـ per al cinc. Abans del text, dues directives reinicien el compte a la pàgina senar següent amb les xifres del document (:::numbering, Xifres i estils de numeració). Les notes porten numbering: 'page', un markerTemplate de '({n})' i noteNumberPosition: 'inline', de manera que la crida va volada al text i la nota comença amb el seu número a la línia (Notes a peu de pàgina).

Pàgina ١: les notes tornen a començar a (١), sota un filet al costat on comença la línia.

#2 · Un índex que se salta l'article

script.js · línies 52–60al codi complet
// 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

Els noms es marquen al text, :index[المسعودي], i :::index els imprimeix al final. Amb ignoreArticle, المسعودي va sota م i الطبري sota ط, mentre que ابن إسحاق es queda sota ا; una remissió porta d'إسرائيل a يعقوب (Índex general i índex analític). Els números de pàgina de l'índex són les etiquetes de les pàgines, així que un nom de la introducció remet a ج.

#3 · Capçaleres sobre un filet

script.js · línies 88–110al codi complet
// 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) };

La pàgina parella porta el títol del llibre i la senar la secció, sobre un filet fi de l'amplada de la caixa, amb el foli a l'extrem exterior. En un llibre enquadernat per la dreta la pàgina parella queda a la dreta, així que el seu foli va a dalt a la dreta (Ordre de les pàgines i enquadernació per la dreta). Les obertures i els preliminars porten en canvi el foli centrat al peu.

#4 · Una portada i la seva pàgina de crèdits

script.js · línies 114–135al codi complet
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) };

La portada i la pàgina de crèdits del seu dors són estils d'encapçalament sense res al flux: les seves línies surten d'atributs del títol, així que les línies llatines dels crèdits, que canvien amb l'edició, són un atribut al Markdown.

La recepta completa

Sandbox
// ═══ 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 = 'es'; // @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') },
};

L'script.js compost funciona tal com és: enganxa'l com a script de mòdul en qualsevol pàgina o obre la recepta a CodePen. Carpeta de la recepta a GitHub ↗ (s'obre en una pestanya nova)

Variants

#Fes servir els numerals abjad

'arabic-abjad' escriu els numerals abjad additius en lloc de la sèrie simple de lletres: la pàgina onze és يا, no ك.

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

#Numera les notes al llarg de la secció

numbering: 'chapter' continua comptant les notes d'una pàgina a l'altra, com fan algunes edicions antigues.

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

Errors freqüents

Error freqüent

Etiqueta un llibre àrab 'ar', no amb LANG

Les edicions d'una recepta són en i es, però una mostra àrab és àrab en totes dues: `locale: LANG` la compondria d'esquerra a dreta, l'enquadernaria per l'esquerra, numeraria les seves pàgines 1 2 3 i anomenaria Figure o Figura les seves figures. Des de postext 1.30 l'etiqueta és a més la llengua en què es compon el text (en què es mesura, es pinta i s'incrusta), de manera que sota una etiqueta anglesa o castellana una font com Markazi Text no dibuixa les formes àrabs de les cometes angulars i dels punts, i les línies es parteixen per un altre lloc. Escriu tu l'etiqueta: 'ar' (xifres aràbigo-índiques, la convenció del Màixriq), una regió com 'ar-EG' o 'ar-SA', o 'ar-MA', 'ar-DZ' o 'ar-TN' per a una edició magribina amb xifres europees. Una pàgina llatina que només cita àrab conserva el seu propi locale. Text de dreta a esquerra →

Error freqüent

Les fonts àrabs necessiten el seu fitxer arabic, amb el bloc arabic

Fontsource serveix Amiri, Noto Naskh Arabic o Scheherazade New en un fitxer per subconjunt, i les lletres àrabs són al fitxer arabic. loadFonts només baixa latin (i latin-ext), de manera que a la pantalla l'àrab surt d'una font del sistema i es mesura malament, i fontsourceProvider lliura al PDF aquell fitxer latin, que imprimeix caixes buides. Afegeix el bloc arabic del kit, crida loadArabicFonts(FONTS, markdown) després de loadFonts, amb tots els pesos que les pàgines fan servir en àrab llistats a FONTS, i passa a renderToPdf fontProvider: arabicPdfProvider. Fonts àrabs →

Error freqüent

:::numbering s'aplica a la pàgina següent

:::numbering canvia el compte a partir de la pàgina següent que comença, no de l'actual. Col·loca'l just després d'un :::pagebreak (amb paritat odd abans del primer capítol) perquè la numeració nova comenci on vols. Preliminars en romans →

Crèdits

Text
  • The opening section of the Muqaddima, “On the excellence of history”, as ar.wikisource gives it (revision 610595), without its notes · Ibn Khaldūn · domini públic
  • The editor’s introduction in Arabic, the notes, the index and the imprint · Postext Cookbook · original
Fonts
Amiri (SIL OFL 1.1) · Aref Ruqaa (SIL OFL 1.1)
SandboxPDF