انتقل إلى المحتوى الرئيسي
الوصفة رقم 20

دليل الوصفات · الفصل 6 · الإطارات والملاحظات

تعليقات ختامية في صفحة خاصة بها، في عمودين

معالج مسبق قصير يرقّم ملاحظات [^1] ويجمعها تحت عنوان Notes، ويضعها نمط ذلك العنوان في صفحة خاصة بها في عمودين.

في هذه الصفحة

ص 18–19 · 4–5 من 5

  • نموذج باللغة الإنجليزية: لا توجد طبعة عربية بعد
  • مقاس القص 156 × 234 مم
  • عمود واحد
  • Libre Bodoni 10/13.8
  • Archivo Narrow
  • Besley
  • 5 صفحات
  • المستوى
  • Postext 1.57.1
  • أُخرجت في 74 ms
  • أسطر الشيفرة: 185

باختصار

طبعة صغيرة لمحاضرة علمية شهيرة عن الشمعة. تُريك كيف تجمع الملاحظات في النهاية، في صفحة خاصة بها في عمودين، بدلًا من وضعها أسفل كل صفحة.

ما الذي ستنضده

المحاضرة الأولى من The Chemical History of a Candle لـMichael Faraday، منضدة طبعةً صغيرة للقارئ على صفحة 156 × 234 مم. تُفتتح المحاضرة على حقل من السُّخام تقف على حافته السفلى شمعة مشتعلة، وهي صورة مولَّدة بنماذج الانتشار يطابق سوادها السُّخام، ويجري النص في عمود واحد مضبوط من Libre Bodoni. وحيث يضع الكتاب الحواشي السفلية، ترسل أرقام صغيرة مرفوعة بالبرتقالي الداكن القارئَ إلى نهاية المحاضرة. وتأتي الملاحظات بعدها في صفحة خاصة بها، تحت شريط من السُّخام فيه الشمعة مطفأة، في عمودين غير مضبوطين بحرف 8.2 pt، ورقم كل ملاحظة عريض معلّق في الإزاحة. ثلاث من الملاحظات الست لـWilliam Crookes، من طبعة 1908 لنشرته الصادرة عام 1861؛ والثلاث الأخرى جديدة وموقّعة بـ Ed. وينتهي العمودان على السطر نفسه، وتختم بيانات الطبع العمود الثاني.

تجيب هذه الوصفة عن

  • كيف أضيف الحواشي السفلية؟
  • كيف أنضد قائمة مراجع أو مسردًا (مسافة بادئة معلّقة، حرف أصغر)؟
  • كيف أكتب الأرقام العلوية والسفلية والصيغ الكيميائية من دون محرّك الرياضيات الكامل؟

الجواب المختصر

script.js · الأسطر 29–56في الشيفرة الكاملة
// Use: buildDocument({ markdown: endnotes(markdown) }, config()), with a 'note' paragraph style.
// [^label] in the text → **^n^**, numbered by first citation; bold, so it takes bodyText.boldColor.
// The [^label]: definitions (one line each) print where the first stood, a 'note' paragraph each:
// '**n** text', never '1. text', which would open a numbered list (gotcha: digit-period-list).
function endnotes(markdown, style = 'note') {
  const notes = new Map(); // label → text
  const HOLE = '\u0000'; // marks where a definition stood: the first becomes the notes
  const text = markdown.replace(/^\[\^([^\]\s]+)\]:[ \t]*(.+)\n?/gm,
    (_, label, note) => { notes.set(label, note.trim()); return HOLE; });
  const cited = []; // labels in order of first citation
  const number = (label) => {
    if (!notes.has(label)) throw new Error(`The note [^${label}] has no definition`);
    if (!cited.includes(label)) cited.push(label);
    return cited.indexOf(label) + 1;
  };
  // Markers side by side share one superscript, [^a][^b] → **^1,2^**, never 12 raised (note 12).
  // A word joiner (U+2060, no width) opens each one: after an italic, '*Royal George*' and the
  // bold's ** would make '***', which the parser reads as a bold run, and print the asterisks.
  const marked = text.replace(/(?:\[\^[^\]\s]+\])+/g, (run) => {
    const numbers = [...run.matchAll(/\[\^([^\]\s]+)\]/g)].map(([, label]) => number(label));
    return `⁠**^${numbers.join(',')}^**`;
  });
  const unused = [...notes.keys()].filter((label) => !cited.includes(label));
  if (unused.length) console.warn(`Notes never cited: ${unused.join(', ')}`);
  const entries = cited.map((label, i) => `**${i + 1}** ${notes.get(label)}`);
  const section = `:::paragraphs{style="${style}"}\n${entries.join('\n\n')}\n:::\n`;
  return marked.replace(HOLE, () => section).replaceAll(HOLE, ''); // () =>: '$&' stays text
}

المكونات

الخطوط
Libre Bodoni, Besley, Archivo Narrow (SIL OFL 1.1)
الأصول
  • candle-640.jpg
  • snuffed-600.jpg
  • The lit candle on the lecture’s opener, a photograph (Generated With Diffusion Models, أصلي)
  • The snuffed candle on the notes’ band, a photograph (Generated With Diffusion Models, أصلي)
  • Figure 1, the flame as seen and in section, drawn in code in the page’s palette (Ignacio Ferro, CC BY 4.0)

طريقة التحضير

#1 · حوّل الحواشي السفلية إلى تعليقات ختامية قبل البناء

المعالج المسبق هو الجواب المختصر أعلاه. ينضّد Postext ملاحظات [^1] بنفسه (الحواشي السفلية)، أسفل العمود المستشهِد، أو بعد آخر كتلة في الفصل مع placement: 'chapterEnd'. وفي الحالتين تبقى في عمود الفصل، بحرف المتن، تحت خط قصير. أما هذه الطبعة فتجعل للملاحظات عنوانًا وشريطًا وصفحة في عمودين، ونمط العنوان لا يفعل ذلك إلا لعنوان مكتوب في Markdown. لذلك يعيد المثال كتابة Markdown قبل أن يستدعي buildDocument، فلا يرى المحرّك أي [^1]. يرقّم العلامات بترتيب أول استشهاد بها في النص، ويضع التعريفات كلها، بذلك الترتيب، حيث يقف أولها، تحت ## Notes. تبدأ كل ملاحظة بـ**1**، لأن 1. ستفتح قائمة مرقّمة. ويفتتح كل علامة رابط الكلمات (U+2060)؛ ومن دونه كانت ** الخاصة بالعلامة التي تلي *Royal George* ستلتقي بنجمة إغلاق الخط المائل فتصير ***، وتُطبع النجوم.

#2 · احفظ الخط العريض للعلامات

script.js · الأسطر 60–61في الشيفرة الكاملة
const markers = { boldColor: col('ember'), // **^n^**: a superscript at 58 % of the text size
  referenceBold: false }; // [Fig. 1] follows the bold colour, set roman

يكتب المعالج المسبق كل علامة على صورة **^n^**. تضع علامتا الإقحام الرقم بحجم 58 % من حجم النص، مرفوعًا بمقدار ثلثه (التنسيق داخل السطر)، ويمنحه الخط العريض اللون bodyText.boldColor، وهو متاح لأن Faraday لا يستعمل الخط العريض أبدًا. يحتاج رقم بحجم 5.8 pt إلى تباين 4.5:1 مع الورق، واللهب لا يبلغ إلا 2.6:1، فتأخذ العلامات لون الجمرة الأدكن. وتُطبع الإحالة [Fig. 1] في الصفحة 17 باللون نفسه، بخط قائم، لأن referenceColor يأخذ افتراضيًا لون الخط العريض وreferenceBold: false يُسقط العرض.

#3 · اجعل الملاحظات أصغر، ورقمها في المسافة المعلّقة

script.js · الأسطر 65–79في الشيفرة الكاملة
const NOTE = 8.2; // pt: the notes' size, about four fifths of the text
// The hang is a bold number and an en space, measured in the notes' face once the fonts are in:
// a bold 5 matches 2, 3 and 6 within 0.02 em (the 4 is 0.05 em wider, the 1 0.14 em narrower).
function hang(label = '5') { // from ten notes on, pass the widest label: hang('10')
  const ctx = new OffscreenCanvas(1, 1).getContext('2d');
  const width = (w, s) => { ctx.font = `${w} 100px "${TEXT}"`; return ctx.measureText(s).width; };
  return em((width(700, label) + width(400, ' ')) / 100);
}
// Ragged, as justifying would stretch the en space after each number.
const noteStyles = () => [{ id: 'note', fontSize: pt(NOTE), lineHeight: pt(NOTE * 1.3),
  textAlign: 'left', hangingIndent: hang() },
  // 22 pt above the colophon is copy-fitted: its last line and the first column's share a line.
  { id: 'colophon', fontFamily: LABEL, fontSize: pt(7), lineHeight: pt(9.2), color: col('muted'),
    textAlign: 'left', firstLineIndent: pt(0), marginTop: pt(22) },
];

الملاحظات 8.2 pt على تباعد أسطر 10.7 pt، أي نحو أربعة أخماس حجم النص. يقيس المثال قيمة hangingIndent في النمط بحرف Libre Bodoni بعد تحميل الخطوط: الرقم 5 العريض ومسافة en يبلغان معًا 1.12 em، فتصطف أول كلمة في كل ملاحظة مع أسطرها التالية (أنماط الفقرات). ومع وجود الرقم خارجًا في المسافة المعلّقة، لا تحتاج الملاحظات إلى مسافة بينها. وهي غير مضبوطة لأن الضبط سيمطّ مسافة en تلك، ولأن عمودًا مضبوطًا عرضه 55 مم بحرف 8.2 pt يخرج متخلخلًا. وتضع علامات التلدة الأرقام السفلية كما تضع علامات الإقحام الأرقام المرفوعة، كما في C~25~H~52~ في الملاحظة 4 وH~2~O في الملاحظة 5.

#4 · أعطِ الملاحظات صفحة في عمودين

script.js · الأسطر 116–130في الشيفرة الكاملة
const BAND = 82; // mm from the trim's top: level with the foot of Figure 1 across the spread
// The band sets the reserve too, but the first grid line clear of it lies 3 mm under the soot:
const BAND_GAP = 5; // mm more of minHeight moves the notes down a line
const notesSection = { id: 'notes', // an opener page: the drop folio, no running heads
  breakBefore: { enabled: true, parity: 'any' }, span: 'page', // the next page, either side
  layout: { layoutType: 'double', gutterWidth: mm(6), // two columns of about 40 characters
    columnRule: { enabled: true, color: col('rule') } }, // and a hairline between them
  advancedDesign: { enabled: true, minHeight: mm(BAND - TOP + BAND_GAP), slot: { elements: [
    soot(BAND), art('snuffed', 32, 64, BAND, 12), series,
    text('kicker', '{attr.kicker}', LABEL, 9.5, 'flame', at('container', 'top-left', 0, 16),
      caps(9.5)),
    text('title', '{titleText}', DISPLAY, 52, 'wax', below('kicker', 0.5, 80), display),
    text('intro', '{attr.intro}', LABEL, 8.4, 'rule', below('title', 2.5, 92),
      { lineHeight: 1.3 }),
  ] } } };

يفتح العنوان ## Notes {style="notes" …} قسمًا تأخذ صفحاته تخطيط النمط وتصميمه. يبدأه parity: 'any' في الصفحة التالية، فردية كانت أو زوجية، ويمدّ span: 'page' الشريط عبر العمودين، فيبلغ حدّ القص ويبدأ العمود الثاني تحته (أنماط العناوين). يحدد الشريط المساحة المحجوزة، لكن أول خط شبكة خالٍ منه لا يقع إلا 3 مم تحت السُّخام، فيضيف BAND_GAP إلى minHeight مقدار 5 مم وتبدأ الملاحظات أدنى بسطر. والخط الرفيع بين العمودين هو columnRule في layout الخاص بالنمط نفسه، فلا ترسمه إلا صفحات الحواشي. موازنة الأعمدة مفعّلة افتراضيًا، وتقصّ الصفحة الختامية بحيث ينتهي العمودان على السطر نفسه (موازنة الأعمدة).

#5 · افتتح المحاضرة على حقل من السُّخام

script.js · الأسطر 101–112في الشيفرة الكاملة
const FIELD = 112; // mm from the trim's top
// The field reaches below the heading, so it sets the reserve (gotcha: opener-reserves-anchored);
// the H1's default bottom margin (0.5 em of 18 pt) rides on it: the text starts a grid line lower.
const opener = { enabled: true,
  slot: { elements: [soot(FIELD), art('candle', 40, 100, FIELD, 10), series,
    text('kicker', '{attr.kicker}', LABEL, 9.5, 'flame', below('series', 17, 60), caps(9.5)),
    text('title', '{titleText}', DISPLAY, 48, 'wax', below('kicker', 1.5, 96), display),
    // 86 mm wide, so the subtitle breaks after a dash, never before one
    text('subtitle', '{attr.subtitle}', DISPLAY, 11.5, 'rule', below('title', 3.5, 86),
      { fontWeight: 500, italic: true, lineHeight: 1.3 }),
    text('byline', '{attr.byline}', LABEL, 7.6, 'rule', below('subtitle', 7, 84), caps(7.6)),
  ] } };

الحقل صندوق مربوط بالصفحة، والشمعة، وهي عنصر صورة يرسم ملف JPEG، تقف على حافته السفلى. للمحاضرة عمود واحد، والتصميم الباقي في عموده يُرسم مع ذلك حيث رُبطت عناصره، فيمتد الحقل من حدّ القص عبر الهامش العلوي والهامشين الجانبيين. يأتي السطر التمهيدي والعنوان الفرعي وسطر المؤلف من سطر العنوان، # A Candle {kicker="Lecture I" subtitle="…" byline="…"}، فلن تحتاج المحاضرة الثانية إلى شيفرة جديدة. يمتد الحقل تحت العنوان، فيحدد المساحة المحجوزة. ويُضاف إليه الهامش السفلي الافتراضي للعنوان، 0.5 em، فيبدأ النص سطر شبكة واحدًا تحت أول سطر خالٍ من السُّخام. وعرض العنوان الفرعي 86 مم حتى ينكسر بعد شرطة لا قبلها.

#6 · اللهب على السُّخام، والجمرة على الورق

script.js · الأسطر 14–23في الشيفرة الكاملة
const palette = {
  ink: '#1f1c19', paper: '#fffdf8', // text and the soot of the fields; a warm white page
  flame: '#e08a1e', ember: '#a9560c', // kickers on soot (6:1); markers and numbers (5.1:1)
  wax: '#f6efe1', rule: '#d4c6ad', // type on soot; hairlines and small type on soot (10:1)
  muted: '#6d6356', blue: '#4f7cae', // running heads, colophon (5.8:1); a flame's blue foot
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// The engine's defaults link to 'main-color': point it at the ember, so nothing prints blue.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.ember })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));

للبرتقالي اللهبي تباين 6:1 على السُّخام، لكنه لا يتجاوز 2.6:1 على الورق. يلوّن السطور التمهيدية على الأشرطة الداكنة والشكل 1؛ وكل ما هو صغير ومطبوع بالبرتقالي على الورق (العلامات، أرقام الملاحظات، تسمية الشكل) يأخذ لون الجمرة الأدكن، بتباين 5.1:1. ويشير main-color إلى الجمرة، فالقيمة الافتراضية التي لا تعيد الإعدادات ذكرها تتبع التصميم بدل أن تُطبع بالأزرق.

الوصفة كاملة

Sandbox
// ═══ Postext Cookbook · Nº 020 · Endnotes on a page of their own, in two columns ═════
// https://postext.dev/en/cookbook/endnotes-instead-of-footnotes
// Code: MIT · Text: Faraday, ed. Crookes (PD) · Notes, figure: CC BY 4.0 · Photos: diffusion models
// Fonts: Libre Bodoni, Besley, Archivo Narrow (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
  buildDocumentWithFonts, prepareFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'endnotes-instead-of-footnotes';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: soot, wax and a flame; the ember is the flame dark enough for small type
const palette = {
  ink: '#1f1c19', paper: '#fffdf8', // text and the soot of the fields; a warm white page
  flame: '#e08a1e', ember: '#a9560c', // kickers on soot (6:1); markers and numbers (5.1:1)
  wax: '#f6efe1', rule: '#d4c6ad', // type on soot; hairlines and small type on soot (10:1)
  muted: '#6d6356', blue: '#4f7cae', // running heads, colophon (5.8:1); a flame's blue foot
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// The engine's defaults link to 'main-color': point it at the ember, so nothing prints blue.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.ember })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const TEXT = 'Libre Bodoni', DISPLAY = 'Besley', LABEL = 'Archivo Narrow'; // text; titles; labels
const TOP = 22, INNER = 18, OUTER = 22; // mm: margins, and a 116 mm measure of 74 characters

// #region answer: Markdown footnotes become raised markers and a Notes section
// Use: buildDocument({ markdown: endnotes(markdown) }, config()), with a 'note' paragraph style.
// [^label] in the text → **^n^**, numbered by first citation; bold, so it takes bodyText.boldColor.
// The [^label]: definitions (one line each) print where the first stood, a 'note' paragraph each:
// '**n** text', never '1. text', which would open a numbered list (gotcha: digit-period-list).
function endnotes(markdown, style = 'note') {
  const notes = new Map(); // label → text
  const HOLE = '\u0000'; // marks where a definition stood: the first becomes the notes
  const text = markdown.replace(/^\[\^([^\]\s]+)\]:[ \t]*(.+)\n?/gm,
    (_, label, note) => { notes.set(label, note.trim()); return HOLE; });
  const cited = []; // labels in order of first citation
  const number = (label) => {
    if (!notes.has(label)) throw new Error(`The note [^${label}] has no definition`);
    if (!cited.includes(label)) cited.push(label);
    return cited.indexOf(label) + 1;
  };
  // Markers side by side share one superscript, [^a][^b] → **^1,2^**, never 12 raised (note 12).
  // A word joiner (U+2060, no width) opens each one: after an italic, '*Royal George*' and the
  // bold's ** would make '***', which the parser reads as a bold run, and print the asterisks.
  const marked = text.replace(/(?:\[\^[^\]\s]+\])+/g, (run) => {
    const numbers = [...run.matchAll(/\[\^([^\]\s]+)\]/g)].map(([, label]) => number(label));

يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)

تنويعات

#دع Postext ينضّد الملاحظات

احذف endnotes() والعنوان ## Notes، وضع سطرًا فارغًا بين التعريفات (يقرأ المحرّك التعريف حتى السطر الفارغ التالي)، وأضف footnotes: { placement: 'chapterEnd' } إلى الإعدادات. يرقّم المحرّك العلامات ويضع الملاحظات في نهاية المحاضرة، بعد بيانات الطبع، في عمودها الواحد؛ وتنسّق وصفة حواشٍ سفلية أسفل العمود الذي يستشهد بها الملاحظاتِ التي ينضّدها المحرّك.

#علّم الملاحظات بالحبر

إن كان النص يستعمل الخط العريض لتوكيده الخاص، فاطبع العلامات بالحبر، لأن boldColor يلوّن العلامات وكل كلمة عريضة على حدّ سواء.

-const markers = { boldColor: col('ember'), // **^n^**: a superscript at 58 % of the text size
+const markers = { boldColor: col('ink'), // **^n^**: a superscript at 58 % of the text size

#دع أعمدة الملاحظات تجري دون تسوية

عطّل موازنة الصفحة الختامية، فيمتلئ العمود الأول حتى أسفله قبل أن يبدأ الثاني.

-  headings: { fontFamily: DISPLAY, color: col('ink'), levels: [
+  headings: { fontFamily: DISPLAY, color: col('ink'), balancing: { trailing: false }, levels: [

أخطاء شائعة

خطأ شائع

'1998. ' أو '- ' في أول الفقرة يفتح قائمة

الفقرة التي تبدأ برقم ثم نقطة ثم مسافة، أو بواصلة ثم مسافة، تصير بندًا في قائمة. ضع رابط الكلمات (U+2060) قبل الرقم، واكتب الحوار بالشرطة الطويلة. الهروب والمحارف الحرفية →

خطأ شائع

العنصر العائم 'top' يذهب إلى الصفحة التالية لإحالته ما لم يُسمح له بتصدر صفحة الإحالة

افتراضيًا لا يصعد العنصر العائم أبدًا فوق الإحالة إليه، فالعنصر العائم 'top' الممتد بعرض الصفحة والمُحال إليه في الصفحة N يفتتح الصفحة N+1. اضبط placement.citingPage: true على المورد أو على defaultPlacement لنوعه (أو layout.floatsAtCitingPage للكتاب كله، منذ postext 1.25) فيتصدر الصفحة N بدلًا من ذلك، وينزل النص الذي فوق الإحالة تحته، إذا اتسع له المكان في حدود layout.maxTopFraction وبقي سطر الإحالة في تلك الصفحة. ولا يتصدر أبدًا الصفحة الأولى من فصل ولا صفحة بعد فاصل قسري: فهناك يظل يفتتح الصفحة التالية، ويمكن للموضع 'auto' أو 'bottom' أن يشغل أسفل صفحة الإحالة. موضع الأشكال →

خطأ شائع

تحجز الافتتاحية ارتفاعًا يصل إلى أدنى عناصرها المثبّتة على الصفحة

تحجز الافتتاحية ذات التصميم المتقدّم ارتفاع أدنى عناصرها، وتُحتسب كذلك العناصر المثبّتة على الصفحة أو على النزف تحت العنوان، فالزخرفة في أسفل الصفحة تدفع النص إلى الصفحة التالية. أعطِ مثل هذا العنصر reserve: false (منذ postext 1.5): يُرسَم حيث ثُبّت ولا يحجز شيئًا. أما العناصر التي تتبع الشريط نفسه (المثبّتة على أسفله، أو التي ارتفاعها 'fill') فلا تحدّد ارتفاعه أبدًا. صفحات افتتاح مصمَّمة →

خطأ شائع

لا <marker> ولا مرشِّحات في رسوم SVG (وإلا البديل النقطي)

لا يبقى شكل SVG متّجهيًا في PDF إلا إذا خلا من <marker> والمرشِّحات والأقنعة؛ وإلا عاد إلى صورة نقطية، والمرشِّحات المتداخلة بعمق قد تجعله فارغًا في Chrome. ارسم رؤوس الأسهم مسارات. الأشكال والجداول بوصفها موارد →

خطأ شائع

الصفحة 1 فردية: خطّط الصفحات بأرقامها الفعلية

الصفحة 1 صفحة يمنى والصفحة 2 أول صفحة زوجية، فخطّط الصفحتين المتقابلتين بأرقام الصفحات الفعلية: الافتتاحية في صفحة زوجية تقابل الصفحة الفردية التي تليها. فواصل الصفحات والأعمدة →

الحقوق

الوصفة
Ignacio Ferro
النص
  • The Chemical History of a Candle, Lecture I (abridged), and William Crookes’s notes to it, from the Chatto & Windus impression of 1908 · Michael Faraday; William Crookes · ملك عام
  • The notes signed Ed., the colophon and the drawings · Ignacio Ferro · CC BY 4.0
الصور
  • The lit candle on the lecture’s opener, a photograph · Generated With Diffusion Models · أصلي
  • The snuffed candle on the notes’ band, a photograph · Generated With Diffusion Models · أصلي
  • Figure 1, the flame as seen and in section, drawn in code in the page’s palette · Ignacio Ferro · CC BY 4.0
الخطوط
Libre Bodoni (SIL OFL 1.1) · Besley (SIL OFL 1.1) · Archivo Narrow (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
Sandbox