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

دليل الوصفات · الفصل 3 · العناوين وصفحات الافتتاح

عناوين أقسام بسبعة مستويات

أقسام مرقّمة من 1.1 إلى 1.12 في كبسولة كهرمانية تتسع مع رقمها، وأربعة مستويات أخرى تحتها، ومستوى سابع مصنوع بنمط عنوان.

في هذه الصفحة
المُخرَج
Canvas
المستوى
متوسط
Postext
اختُبرت مع Postext 1.65.0
تتطلب ≥ 1.25.0
الترخيص
حُدّثت في 12 أكتوبر 2026
الشيفرة MIT · النص CC BY 4.0
  • نموذج باللغة الإنجليزية: لا توجد طبعة عربية بعد
  • مقاس القص 176 × 250 مم
  • عمودان, فاصل 6 مم بين الأعمدة
  • IBM Plex Serif 9.4/13.2
  • IBM Plex Mono
  • IBM Plex Sans Condensed
  • 3 صفحات
  • المستوى
  • Postext 1.57.1
  • أُخرجت في 89 ms
  • أسطر الشيفرة: 178

باختصار

فصل من دليل ميداني لعمّال صيانة الممرات الجبلية، عن تصريف الماء من الممرات. يبيّن كيف تُرتَّب العناوين في سبعة مستويات، لكل منها مظهره، فيرى القارئ كيف تترابط الأجزاء.

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

الفصل 1 من دليل ميداني لفريق صيانة الممرات الجبلية، Drainage، في ثلاث صفحات B5 بعمودين: IBM Plex Serif للنص، وIBM Plex Sans Condensed للعناوين وأرقام الأقسام، وIBM Plex Mono للتسميات وأرقام الصفحات وأرقام الأقسام الفرعية. تضع صفحة الافتتاح رقم الفصل في كبسولة كهرمانية كبيرة فوق مقطع ارتفاعات لممر، تعلّم فيه نقاط كهرمانية اثني عشر موقعًا محددة لحواجز تصريف جديدة. كبسولات أصغر ترقّم الأقسام من 1.1 إلى 1.12 وتتسع عند 1.10. والعناوين 1.2.1 و1.5.1 و1.5.2 حروف كبيرة متباعدة تحت خط أخضر. والمستويات 4 إلى 6 بلا أرقام وتغيّر خطها بدلًا من ذلك (serif مائل، وcondensed عريض أخضر، وحروف كبيرة أحادية العرض)، ومستوى سابع بالمائل الرمادي يذكر أسماء الأدوات. تنفتح قواعد السلامة بمصطلحات خضراء داخل السطر. وتختم الفصلَ قائمةُ تحقق بلا رقم، يعلّمها مربع مجوّف، بقوائم مرقّمة 1. وa) وi. ومربعي مهام.

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

  • كيف أرقّم العناوين (1، 1.1، 1.1.1) وأنسّق كل مستوى بطريقة مختلفة؟
  • كيف أبني شارة رقم بجانب العنوان تتسع حين يكبر الرقم (9 → 10)؟
  • كيف أتعامل مع أكثر من ستة مستويات للعناوين؟
  • كيف أخصّص القوائم: نقاط لكل مستوى، وترقيم (a)/(i)، ومربعات اختيار للمهام، وتباعد يبقى على الشبكة؟

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

script.js · الأسطر 34–51في الشيفرة الكاملة
const H2 = 13.5; // pt: the number and the title share one size and one line height,
const LH = 1.2; // so, under the same top padding, they share one baseline
// Every section head starts on a grid line, so the 3 pt the pill falls short of two lines
// is the gap the grid snap leaves between the pill and the text under it.
const PILL_H = 2 * LEAD - 3, PAD = (PILL_H - H2 * LH) / 2; // pt
const face = { fontFamily: DISPLAY, fontWeight: 700, fontSize: pt(H2), lineHeight: LH };
const pill = { kind: 'text', id: 'pill', content: '{number}', ...face, color: col('ink'),
  box: { backgroundColor: col('signal'), borderRadius: mm(3), // no width: the pill is its
    padding: { top: pt(PAD), bottom: pt(PAD), left: mm(1.8), right: mm(1.8) } }, // number
  placement: at('container', 'top-left') }; // plus its padding
// 'right-of' hangs the title on the pill's right edge and aligns its lines left, so a long
// title wraps beside the number, never under it.
const sectionTitle = (from) => ({ kind: 'text', id: 'title', content: '{titleText}', ...face,
  color: col('ink'), overflow: 'wrap', box: { padding: { top: pt(PAD) } },
  placement: at(`#${from}`, 'right-of', mm(2.2)) });
// The H1 counter, a point, the H2 counter: 1.1 … 1.12 in the pill. h2 joins headings.levels.
const h2 = { level: 2, numberingTemplate: '{1}.{2}',
  advancedDesign: { enabled: true, slot: { elements: [pill, sectionTitle('pill')] } } };

المكونات

الميزات
العناوين المرقّمةالنصوص والخطوط والمربعات في تصاميم الصفحةتثبيت عناصر التصميممستويات العناوينأنماط العناوينفصول بلا أرقامصفحات افتتاح مصمَّمةالصور في تصاميم الصفحةسمات العنوانأنماط الفقراتالغامق والمائل وألوانهماالقوائم النقطية وقوائم التحققالقوائم المرقّمةشبكة خطوط الأساسالأسطر الأرامل والأسطر اليتيمة والكلمات المعزولةالترويسات وأرقام الصفحاتالترويسات بحسب دور الصفحةهوامش متناظرةلوحة ألوان دلاليةالأشكال والجداول بوصفها موارد
الخطوط
IBM Plex Serif, IBM Plex Sans Condensed, IBM Plex Mono (SIL OFL 1.1)
الأصول
لا شيء: كل صورة مرسومة بالشيفرة

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

#1 · ضع الرقم في كبسولة تكبر معه

الشيفرة في الجواب المختصر أعلاه. يجمع numberingTemplate: '{1}.{2}' عدّادي الفصل والقسم في 1.1 إلى 1.12 (تجاوزات كل مستوى). المستوى ذو التصميم المتقدم لا يطبع الرقم قبل عنوانه، فيضع التصميم {number} بنفسه. وهو هنا في عنصر نصي له box مملوء مستدير الزوايا وبلا عرض، فتكون الكبسولة بعرض الرقم مع حشوته: 10.1 مم لـ 1.9 و12.7 مم لـ 1.10. يعلّق 'right-of' العنوان على الحافة اليمنى للكبسولة ويحاذي أسطره إلى اليسار، ولهذا يلتف العنوان الطويل للقسم 1.5 بجانب الرقم (موضع العناصر). الكبسولة أقصر من سطري شبكة بـ 3 pt، وكل عنوان قسم يبدأ على سطر من الشبكة، فهذه المسافة البالغة 3 pt هي الفجوة بين الكبسولة والنص تحتها، سواء افتتح العنوان عمودًا أو تلا فقرة.

الصفحة 3: الكبسولة تتسع من 1.9 إلى 1.10، والعنوان يتحرك يمينًا بعرض الرقم الإضافي.

#2 · سطّر المستوى الثالث وباعد حروفه

script.js · الأسطر 55–67في الشيفرة الكاملة
// A rule, a mono number and a tracked title: three elements, so this head is a design.
const small = { fontSize: pt(8.4), lineHeight: LH };
const DROP = 6; // pt: the rule drops this far toward the number, which keeps its grid line
const h3 = { level: 3, numberingTemplate: '{1}.{2}.{3}', // 1.5.1: restarts under every H2
  advancedDesign: { enabled: true, slot: { elements: [
    { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.75), color: col('band'),
      placement: { ...at('container', 'top-left', mm(0), pt(DROP)), size: { width: 'fill' } } },
    { kind: 'text', id: 'num', content: '{number}', fontFamily: LABEL, fontWeight: 500, ...small,
      color: col('band'), placement: at('#rule', 'below', mm(0), pt(LEAD - DROP)) },
    { kind: 'text', id: 'title', content: '{titleText}', fontFamily: DISPLAY, fontWeight: 600,
      ...small, letterSpacing: pt(1.35), textTransform: 'uppercase', color: col('ink'),
      overflow: 'wrap', placement: at('#num', 'right-of', mm(2)) },
  ] } } };

يُرسم المستوى 3 بتصميم أيضًا: خط أخضر بسماكة 0.75 pt، والرقم بخط IBM Plex Mono والعنوان المتباعد الحروف بجانبه. العدّاد الثالث في '{1}.{2}.{3}' يبدأ من جديد تحت كل قسم، فينتهي 1.2.1 و1.5.1 كلاهما بـ 1. يُنزل DROP الخط وحده. والرقم موضوع على بعد LEAD - DROP تحته، فيبقى الرقم والعنوان سطرًا من الشبكة تحت أعلى العنوان مهما كانت قيمة DROP. ولأن الخط أقرب إلى الرقم منه إلى الفقرة التي فوقه، يُقرأ جزءًا من العنوان.

#3 · انزل درجة درجة عبر المستويات 4 إلى 6

script.js · الأسطر 96–107في الشيفرة الكاملة
const headings = { fontFamily: DISPLAY, color: col('ink'), // every head sits on the grid,
  lineHeight: pt(LEAD), marginTop: pt(LEAD), marginBottom: pt(0), // a line above, none below
  levels: [
    // Each chapter opens on a recto.
    { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'odd' },
      numberingTemplate: '{1}', advancedDesign: opener },
    h2, h3,
    // No template below level 3, so no number: each level changes face, colour or case.
    { level: 4, fontFamily: 'IBM Plex Serif', fontWeight: 400, italic: true, fontSize: pt(11) },
    { level: 5, fontSize: pt(9.4), color: col('band') },
    { level: 6, fontFamily: LABEL, fontWeight: 600, fontSize: pt(7.8), textTransform: 'uppercase' },
  ] };

المستوى الذي لا numberingTemplate له لا يطبع رقمًا، فمن المستوى 4 فما دون تختلف العناوين بالخط أو اللون أو حالة الحروف بدلًا من ذلك: serif مائل في المستوى 4، وخط العرض بالأخضر في 5، وحروف كبيرة أحادية العرض نصف عريضة في 6. ارتفاع السطر والهوامش المضبوطة على headings نفسه تبلغ كل المستويات وتضع كل عنوان على الشبكة، بسطر فارغ فوقه ولا شيء تحته. ويفتتح المستوى 1 كل فصل في صفحة فردية، عبر parity: 'odd'.

#4 · اصنع مستوى سابعًا وقسمًا بلا رقم بالأنماط

script.js · الأسطر 111–130في الشيفرة الكاملة
const headingStyles = [
  // Markdown stops at ######: '###### Rock bar {style="level7"}' stays level 6 in the
  // outline and is set in lower case, lighter and grey.
  { id: 'level7', fontFamily: DISPLAY, fontWeight: 500, italic: true, fontSize: pt(8.4),
    textTransform: 'none', color: col('muted') },
  // numbered: false: no number, and the H2 counter does not move. An empty {number} would
  // still paint the amber pill, so the style draws a hollow square in its place.
  { id: 'checklist', numbered: false, advancedDesign: { enabled: true, slot: { elements: [
    { kind: 'box', id: 'box', style: { borderColor: col('signal'), borderWidth: pt(1.8),
      borderRadius: mm(1.5) }, placement: { ...at('container', 'top-left'),
      size: { width: pt(PILL_H), height: pt(PILL_H) } } },
    sectionTitle('box'),
  ] } } },
];
const paragraphStyles = [
  // Run-in heads: the bold term opening each rule prints in the accent, not in body ink.
  { id: 'rules', boldColor: col('band'), firstLineIndent: pt(0) },
  { id: 'colophon', fontFamily: LABEL, fontSize: pt(6.8), lineHeight: pt(9),
    color: col('muted'), textAlign: 'left', firstLineIndent: pt(0), marginTop: pt(LEAD) },
];

يتوقف Markdown عند ######، وكان ###### *Rock bar* سيكون مستوى سادسًا آخر، لكن بالمائل. يضبط نمط العنوان 'level7' أسماء الأدوات بخط condensed مائل رمادي بوزن 500، أخف من وزن 600 في المستوى 6، ويوقف textTransform: 'none' الحروف الكبيرة التي كانت سترثها. وتُقرأ درجةً تحت التسمية أحادية العرض التي فوقها، مع أنها بحجم 8.4 pt أكبر من حجم تلك التسمية البالغ 7.8 pt (أنماط العناوين). يُخرج numbered: false قائمة التحقق من العدّ، فيظل القسم الذي بعدها 1.13. و{number} الفارغ كان سيرسم الكبسولة الكهرمانية رغم ذلك، فيأتي النمط بتصميمه الخاص، بمربع مجوّف في مكان الكبسولة. والمصطلحات الخضراء داخل سطور قواعد السلامة تأتي من boldColor لنمط فقرة.

#5 · غيّر علامات القوائم مع العمق

script.js · الأسطر 134–141في الشيفرة الكاملة
// Zero margins keep lists on the grid; a '- [ ]' item's bullet becomes taskCheckboxChar, '☐'.
const unorderedLists = { gap: mm(2), marginTop: pt(0), marginBottom: pt(0), color: col('band'),
  levels: [{ level: 2, bulletChar: '–', color: col('sage') }] }; // '•' stays at level 1
// Level 1 keeps the defaults: 'arabic' and a full stop.
const orderedLists = { fontFamily: DISPLAY, color: col('band'), gap: mm(1.6),
  marginTop: pt(0), marginBottom: pt(0), levels: [
    { level: 2, numberFormat: 'lower-alpha', separator: ')' },
    { level: 3, numberFormat: 'lower-roman', color: col('muted') }] };

يأخذ كل عمق علامته ولونه وفاصله من levels: قائمة التحقق تعدّ 1. وa) وi. (تجاوزات كل مستوى للقوائم المرتبة) والنقاط تبهت من الأخضر إلى الأخضر الرمادي (تجاوزات كل مستوى للقوائم غير المرتبة). يحتفظ المستوى 1 بالصيغة الافتراضية، 'arabic'. والبندان - [ ] اللذان يختمان قائمة التحقق يطبعان taskCheckboxChar، وهو ☐ افتراضيًا، مكان النقطة، بأخضر نقاط المستوى الأول (امتدادات قوائم المهام). ومع هوامش صفرية فوق وتحت، تبقى كل قائمة على شبكة خطوط الأساس.

#6 · افتح الفصل على مقطع ارتفاعات الممر

script.js · الأسطر 71–92في الشيفرة الكاملة
const DEPTH = 96; // mm: the profile's foot, measured from the top of the page
const CLEAR = 6; // mm: the least room between the profile's foot and the text under it
const LEGEND = 7; // mm: how far the legend's top sits above the profile's foot
const big = { ...face, fontSize: pt(54), lineHeight: 1, color: col('ink') };
// The opener reserves height down to the profile's foot; minHeight reaches CLEAR mm past
// it, so the text starts on the first grid line CLEAR mm or more under the picture.
const opener = { enabled: true, minHeight: mm(DEPTH - TOP + CLEAR), slot: { elements: [
  { kind: 'image', id: 'profile', resourceId: 'profile',
    placement: { ...at('page', 'top-left'), size: { width: 'fill' } } },
  { kind: 'text', id: 'num', content: '{number}', ...big, box: { backgroundColor: col('signal'),
    borderRadius: mm(4), padding: { top: pt(4), bottom: pt(4), left: mm(4), right: mm(4) } },
    placement: at('container', 'top-left') },
  { kind: 'text', id: 'title', content: '{titleText}', ...big, box: { padding: { top: pt(4) } },
    placement: at('#num', 'right-of', mm(4)) },
  { kind: 'text', id: 'lead', content: '{attr.lead}', fontFamily: 'IBM Plex Serif', italic: true,
    fontSize: pt(11.5), lineHeight: 1.3, color: col('ink'), align: 'left', overflow: 'wrap',
    placement: { ...at('#num', 'below', mm(0), mm(5)), size: { width: mm(100) } } },
  // The legend is design text over the picture: each edition words it in its heading.
  { kind: 'text', id: 'legend', content: '{attr.profile}', fontFamily: LABEL, fontWeight: 500,
    fontSize: pt(7), color: col('tint'), placement: at('page', 'top-right', mm(-OUTER),
      mm(DEPTH - LEGEND)) },
] } };

مقطع الارتفاعات عنصر صورة في صفحة الافتتاح، مربوط بالصفحة وبعرضها. ولو كان شكلًا بعرض الصفحة يطفو إلى الأعلى ويُحال إليه في الصفحة 1 لافتتح الصفحة 2 بدلًا من ذلك (عناصر الصور). تحجز صفحة الافتتاح الارتفاع حتى أسفل الصورة، ويمتد minHeight 6 مم بعده، فيبدأ النص على أول سطر شبكة يقع على بعد 6 مم أو أكثر تحت مقطع الارتفاعات. والتسمية التوضيحية على الأخضر نص تصميم، مأخوذ من السمة profile في العنوان. وتعيد الكبسولة الكبيرة استعمال خط كبسولة القسم وتعبئتها، ويطبع {number} رقم الفصل نفسه، من numberingTemplate: '{1}'.

الوصفة كاملة

Sandbox
// ═══ Postext Cookbook · Nº 018 · Section heads seven levels deep ═════════════════
// https://postext.dev/en/cookbook/section-heads-field-manual
// Code: MIT · Text: original (CC BY 4.0) · Picture: drawn in code (MIT)
// Fonts: IBM Plex Serif, Sans Condensed, Mono (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'section-heads-field-manual';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { // forest green for structure, a signal amber for numbers
  ink: '#1d2320', // text: a green-black
  band: '#2f6b3f', // the accent: rules, run-in terms, bullets, numbers, folios (6.4:1)
  signal: '#e0a526', // the number pills, with ink on them (7.3:1)
  sage: '#7a9e80', // the second bullet and the profile's upper contours
  tint: '#e9f0e6', // the opener's sky; the legend on the green (5.5:1)
  muted: '#5f6a62', // running heads, level 7, roman list numbers, the colophon (5.6:1)
};
// col(id): a colour linked to its palette entry, in text styles and design slots alike.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// Defaults this config does not restate link to 'main-color', so it points at the accent.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.band })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const TRIM = { width: 176, height: 250 }; // mm: ISO B5, a common size for field manuals
const [TOP, INNER, OUTER] = [22, 16, 14]; // mm: margins; the running heads align to OUTER
const LEAD = 13.2; // pt: the body leading, the pitch of the baseline grid
const LINES = 44; // grid lines in the text block, so every full column ends on one baseline
const [DISPLAY, LABEL] = ['IBM Plex Sans Condensed', 'IBM Plex Mono']; // with the serif text
const at = (to, edge, x, y) => ({ anchor: { to, edge }, offset: { x, y } });

// #region answer: section numbers 1.1 … 1.12 in an amber pill that widens with the number
const H2 = 13.5; // pt: the number and the title share one size and one line height,
const LH = 1.2; // so, under the same top padding, they share one baseline
// Every section head starts on a grid line, so the 3 pt the pill falls short of two lines
// is the gap the grid snap leaves between the pill and the text under it.
const PILL_H = 2 * LEAD - 3, PAD = (PILL_H - H2 * LH) / 2; // pt
const face = { fontFamily: DISPLAY, fontWeight: 700, fontSize: pt(H2), lineHeight: LH };
const pill = { kind: 'text', id: 'pill', content: '{number}', ...face, color: col('ink'),
  box: { backgroundColor: col('signal'), borderRadius: mm(3), // no width: the pill is its
    padding: { top: pt(PAD), bottom: pt(PAD), left: mm(1.8), right: mm(1.8) } }, // number
  placement: at('container', 'top-left') }; // plus its padding
// 'right-of' hangs the title on the pill's right edge and aligns its lines left, so a long
// title wraps beside the number, never under it.
const sectionTitle = (from) => ({ kind: 'text', id: 'title', content: '{titleText}', ...face,
  color: col('ink'), overflow: 'wrap', box: { padding: { top: pt(PAD) } },
  placement: at(`#${from}`, 'right-of', mm(2.2)) });

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

تنويعات

#أسقط رقم الفصل من الكبسولات

أخرِج عدّاد الفصل من القالب فتقرأ الكبسولات 1 إلى 12، وتتسع عند 10؛ ويطبع المستوى 3 الرقم 1.5.1 إلى أن يُسقط قالبه هو أيضًا {1}.

-const h2 = { level: 2, numberingTemplate: '{1}.{2}',
+const h2 = { level: 2, numberingTemplate: '{2}',

#أعطِ كل الكبسولات العرض نفسه

عرض ثابت، عرض 1.10، يوسّط كل رقم في كبسولة متساوية ويصفّ العناوين في عمود واحد.

-  placement: at('container', 'top-left') }; // plus its padding
+  placement: { ...at('container', 'top-left'), size: { width: mm(12.7) } } };

أخطاء شائعة

خطأ شائع

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

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

فحص Sandbox · headingHierarchy

قفزة في تسلسل العناوين

السبب. عنوان يتخطى مستوى، كعنوان H1 يليه مباشرةً عنوان H3.

الحل. استعمل المستوى التالي مباشرةً، أو أعد تنسيق المستوى الذي قصدته بدل تخطي مستوى. التوثيق →

  • المستوى السابع عنوان من المستوى 6 بالنمط level7، فلا ينزل أي عنوان في العيّنة أكثر من مستوى واحد تحت العنوان الذي قبله: The trench وTools for the trench وSTEEL BARS وRock bar تأتي 4 و5 و6 و6. وتحذير Sandbox «قفزة في تسلسل العناوين» يُبلغ عن هذا القفز تحديدًا، فلا يظهر أبدًا في هذا الفصل.

الحقوق

الوصفة
Ignacio Ferro
النص
نص أصلي, CC BY 4.0
الخطوط
IBM Plex Serif (SIL OFL 1.1) · IBM Plex Sans Condensed (SIL OFL 1.1) · IBM Plex Mono (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
Sandbox