Pular para o conteúdo principal
Receita número 113

Receitas · Capítulo 5 · Estrutura do livro

Um taḥqīq: notas por página e pré-textuais em abjad

Pré-textuais com fólios أ ب ج د, o texto a partir de ١, notas do editor numeradas (١) de novo em cada página e um índice que ordena os nomes sem o artigo ال.

Nesta página
Saída
Canvas · PDF
Nível
Avançado
Postext
Testada com o Postext 1.65.0
Requer ≥ 1.25.0 · postext-pdf ≥ 1.25.0
Licença
Atualizada em 10 de out. de 2026
Código MIT · Texto MIT

p. د–١ · 4–5 de 11

  • Amostra em inglês: ainda sem edição em português
  • Refile 170 × 240 mm
  • 1 coluna
  • Amiri 13/22,5
  • Aref Ruqaa
  • 11 páginas
  • Nível
  • Postext 1.65.0
  • Diagramado em 432 ms
  • 165 linhas de código

Em poucas palavras

O começo da Muqaddima de Ibn Khaldūn como edição crítica árabe moderna: a introdução numerada com letras, o texto com algarismos e notas de rodapé que voltam a contar do um em cada página.

O que você vai compor

Onze páginas de uma edição crítica árabe moderna, um taḥqīq, da primeira seção da Muqaddima de Ibn Khaldūn, sobre a excelência da história. Os pré-textuais recebem fólios em letras abjad, como fazem as edições do Cairo e de Beirute: uma folha de rosto أ, o verso com os créditos ب, depois a introdução do editor ج e د. O texto recomeça em ١ na página ímpar seguinte. As notas do editor ficam no pé de cada página, numeradas (١), (٢), (٣) e reiniciadas a cada página, sob um fio curto à direita; elas explicam palavras raras, identificam as pessoas e os lugares que Ibn Khaldūn cita e dão a sura e o versículo de cada citação do Corão. Um índice de nomes fecha o livro, ordenado como se ordenam os índices árabes, sem o artigo ال. As notas e a introdução foram escritas para esta receita.

Esta receita responde a

  • Como numero os elementos pré-textuais de um livro árabe com letras abjad (أ، ب، ج)?
  • Como numero as notas de rodapé árabes por página, entre parênteses: (١)?

A resposta curta

script.js · linhas 33–48no código completo
// 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') },
};

Ingredientes

Tipografia
Amiri, Aref Ruqaa (SIL OFL 1.1)
Materiais
Nenhum: todas as imagens são desenhadas em código

Preparo

#1 · Duas séries de fólios e notas por página

O código é a resposta curta acima. page.pageNumbering começa o livro em 'abjad', as letras na ordem abjad, com هـ para o cinco. Antes do texto, duas diretivas recomeçam a contagem na página ímpar seguinte, com os algarismos do documento (:::numbering, Algarismos e estilos de numeração). As notas usam numbering: 'page', um markerTemplate de '({n})' e noteNumberPosition: 'inline', de modo que a chamada fica elevada no texto e a nota abre com o número na linha (Notas de rodapé).

Página ١: as notas recomeçam em (١), sob um fio no lado da página onde a linha começa.

#2 · Um índice que ignora o artigo

script.js · linhas 52–60no código completo
// 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

Os nomes são marcados no texto, :index[المسعودي], e :::index os imprime no fim. Com ignoreArticle, المسعودي fica sob م e الطبري sob ط, enquanto ابن إسحاق continua sob ا; uma remissiva manda de إسرائيل para يعقوب (Sumário e índice). Os números de página do índice são os rótulos das páginas, por isso um nome da introdução remete a ج.

#3 · Cabeços sobre um fio

script.js · linhas 88–110no código completo
// 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) };

A página par traz o título do livro e a ímpar a seção, sobre um fio fino com a largura da mancha, com o fólio na ponta externa. Num livro encadernado pela direita, a página par fica à direita, por isso o fólio dela vai no alto à direita (Ordem das páginas e encadernação pela direita). As aberturas e os pré-textuais levam, em vez disso, um fólio centralizado no pé.

#4 · Uma folha de rosto e o seu verso de créditos

script.js · linhas 114–135no código completo
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) };

A folha de rosto e os créditos no verso dela são estilos de título sem nada no fluxo: as linhas vêm de atributos do título, de modo que as linhas latinas dos créditos, que mudam a cada edição, são um atributo no Markdown.

A receita 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 = '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') },
};

O script.js montado funciona como está: cole-o como script de módulo em qualquer página ou abra a receita no CodePen. Pasta da receita no GitHub ↗ (abre em uma nova aba)

Variações

#Usar os numerais abjad

'arabic-abjad' escreve os numerais abjad aditivos em vez da série simples de letras: a décima primeira página é يا, não ك.

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

#Numerar as notas ao longo da seção

numbering: 'chapter' continua a contagem das notas de uma página para a outra, como fazem algumas edições mais antigas.

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

Erros comuns

Erro comum

Marque um livro árabe como 'ar', não com LANG

As edições de uma receita são en e es, mas uma amostra árabe é árabe nas duas: `locale: LANG` a comporia da esquerda para a direita, a encadernaria pela esquerda, numeraria as suas páginas 1 2 3 e chamaria as suas figuras de Figure ou Figura. Desde o postext 1.30 a marcação é também o idioma em que o texto é composto (em que é medido, pintado e incorporado), então, sob uma marcação inglesa ou espanhola, uma fonte como a Markazi Text não desenha as formas árabes das aspas angulares e dos pontos, e as linhas quebram em outro ponto. Escreva você mesmo a marcação: 'ar' (algarismos arábico-índicos, a convenção do Machrek), uma região como 'ar-EG' ou 'ar-SA', ou 'ar-MA', 'ar-DZ' ou 'ar-TN' para uma edição magrebina com algarismos europeus. Uma página latina que só cita árabe mantém o seu próprio locale. Texto da direita para a esquerda →

Erro comum

Fontes árabes precisam do seu arquivo arabic, pelo bloco arabic

O Fontsource serve Amiri, Noto Naskh Arabic ou Scheherazade New em um arquivo por subconjunto, e as letras árabes estão no arquivo arabic. loadFonts baixa só latin (e latin-ext), então na tela o árabe vem de uma fonte do sistema e é medido errado, e o fontsourceProvider entrega ao PDF esse arquivo latin, que imprime caixas vazias. Inclua o bloco arabic do kit, chame loadArabicFonts(FONTS, markdown) depois de loadFonts, com todos os pesos que as páginas usam em árabe listados em FONTS, e passe a renderToPdf fontProvider: arabicPdfProvider. Fontes árabes →

Erro comum

:::numbering vale a partir da página seguinte

:::numbering muda a contagem a partir da próxima página que começa, não da atual. Coloque-o logo depois de um :::pagebreak (com paridade odd antes do primeiro capítulo) para que a nova numeração comece onde você quer. Elementos pré-textuais em romanos →

Créditos

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