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

دليل الوصفات · الفصل 5 · بنية الكتاب

أجزاء ملوّنة من سمة واحدة

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

في هذه الصفحة
  • نموذج باللغة الإنجليزية: لا توجد طبعة عربية بعد
  • مقاس القص 150 × 200 مم
  • عمود واحد
  • Alegreya 10.5/14.5
  • Barlow Condensed
  • Zilla Slab
  • 10 صفحات
  • المستوى
  • Postext 1.57.1
  • أُخرجت في 70 ms
  • أسطر الشيفرة: 245

باختصار

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

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

Birds of the Estuary دليل ميداني للجيب في جزأين، جزء لكل موطن. تُطبع السهول الطينية ببني الطين، وأحراش القصب بأخضر القصب، ويُكتب كل لون مرة واحدة، في :::part الذي يفتتح موطنه. كل صفحة فاصلة مساحة ملوّنة حتى النزف، عليها رقم روماني بحجم 150 pt وقائمة أنواع الموطن بلون كريمي. ويُطلى ظهر الورقة بما يطابقها، مع لسان الجزء معكوس الألوان عند الحافة الأمامية. وفي صفحات الأنواع يأخذ لون الجزء كلٌّ من لسان الإبهام ورقم الصفحة والعنوان التمهيدي والخط تحت الاسم اللاتيني والعلامات الميدانية العريضة والنقاط وتسمية اللوحة. وتبدأ المحتويات تحت شريط من صورة المصبّ، وتخصّص لكل جزء شريطًا بلونه، مع رقم صفحته الفاصلة. الغلاف والشريط واللوحات الأربع رسوم مولّدة بنماذج الانتشار (diffusion)، محمّلة صورًا نقطية JPEG؛ ولوحة ألوان الجزء لا تصل إلى الصور، فألوانها ألوانها.

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

  • كيف أقسّم كتابًا إلى أجزاء أو أقسام، لكل منها لونه وصفحته الفاصلة؟
  • كيف أخفي الترويسات في صفحات الافتتاح والصفحات الفارغة، أو ألوّن صفحة زوجية فارغة بلون الجزء؟
  • كيف أضيف جدول محتويات يحدّث نفسه (نقاط توجيه، أرقام صفحات، مؤلفون، صفوف الأجزاء)؟
  • كيف ألوّن المصطلحات الرئيسية (العريضة أو المائلة) في المتن أو داخل الإطارات؟

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

script.js · الأسطر 53–86في الشيفرة الكاملة
// In the Markdown:  :::part{number="I" title="The \\ Mudflats" palette="band=#8c5e24"}
// Every colour below that is linked to 'band' takes #8c5e24 until the next part.
const parts = { // passed to the config as `parts`
  // A divider opens on a recto by default. The break after it goes to the next recto too, so
  // the back of the leaf stays blank and versoDesign paints it (gotcha: verso-design-breakafter).
  breakAfter: { parity: 'odd' },
  margins: { top: mm(125) }, // the fence's text starts low, under the title
  design: { elements: [ // the divider: its container is the whole trim
    box('field', col('band'), { ...at('top-left', 0, 0, 'bleed'), ...fill }),
    text('part', t({ en: 'Part', es: 'Parte' }), { ...label, fontSize: pt(10),
      letterSpacing: pt(2.4), color: col('paper') },
    at('top-left', MARGIN.inner, MARGIN.top)), // a recto: the inner margin is on the left
    // Roman for the parts, Arabic for the species. {numberRoman} re-formats number="I" (or
    // "1"); the species design prints {number}, from numberingTemplate '{1}'.
    text('numeral', '{numberRoman}', { ...display, fontSize: pt(150), lineHeight: 0.9,
      color: col('paper') }, below('part', 0)),
    // The \\ in the title breaks the line here; the contents and the heads get one line.
    text('title', '{titleText}', { ...display, fontSize: pt(46), lineHeight: 0.98,
      color: col('paper') }, below('numeral', 2, { width: mm(MEASURE) })),
    rule('rule', col('paper'), 1, below('title', 7, { width: mm(14) })),
  ] },
  // The back of the leaf: the same band, edge to edge, the part's tab in reverse at the
  // fore-edge (a verso's is on the left) and its name at the foot.
  versoDesign: { elements: [
    box('field', col('band'), { ...at('top-left', 0, 0, 'bleed'), ...fill }),
    text('tab', '{partNumber}', { ...label, fontSize: pt(9), color: col('band'), align: 'center',
      box: { backgroundColor: col('paper') } }, { ...at('top-left', 0, TAB.y), size: TAB.size }),
    text('name', '{partTitle}', { ...label, fontSize: pt(9), letterSpacing: pt(2.4),
      color: col('paper') }, at('bottom-left', MARGIN.outer, -MARGIN.bottom)),
  ] },
  // The fence's list of species, in the paper colour on the band.
  bodyStyle: { fontSize: pt(11), color: col('paper'), textAlign: 'left', numberColor: col('paper'),
    orderedLists: { fontFamily: 'Barlow Condensed', separator: '', gap: mm(4) } },
};

المكونات

الخطوط
Alegreya, Zilla Slab, Barlow Condensed (SIL OFL 1.1)
الأصول
  • cover-1152.jpg
  • curlew-1200.jpg
  • redshank-1200.jpg
  • reedling-1200.jpg
  • strip-1536.jpg
  • warbler-1200.jpg
  • The cover: a curlew on the estuary mud, reeds in front (Generated With Diffusion Models, أصلي)
  • The contents strip: a curlew and a redshank on the mud, the reedbed beyond (Generated With Diffusion Models, أصلي)
  • Plate 1: Eurasian curlew (Generated With Diffusion Models, أصلي)
  • Plate 2: common redshank (Generated With Diffusion Models, أصلي)
  • Plate 3: bearded reedling (Generated With Diffusion Models, أصلي)
  • Plate 4: common reed warbler (Generated With Diffusion Models, أصلي)

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

#1 · مدخل واحد في لوحة الألوان تتجاوزه الأجزاء

script.js · الأسطر 16–29في الشيفرة الكاملة
const palette = {
  ink: '#1f2624', // text: a green-tinted near-black
  band: '#3c4b4f', // the house slate, before any part; each :::part brings its own
  paper: '#f6f3ea', // the page, and the type set on a band
  rule: '#d5d1c4', // hairlines
  muted: '#61675f', // running heads, Latin names, the colophon
};
// The paletteId is the link a part's palette="band=#…" follows, in text and designs alike.
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' } })),
  // The engine's defaults link to 'main-color': point it at the ink, so nothing prints blue.
  { id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];

يتجاوز الجزء مداخل لوحة الألوان بمعرّفاتها، لذلك يرتبط كل ما يجب أن يتغيّر مع الموطن بمدخل واحد، band. قيمته الخاصة، رمادي أردوازي، لا تُطبع إلا خارج الأجزاء (العنوان التمهيدي في الغلاف وعنوان الملاحظة تحت المحتويات)، ولا يستعمل أي لون آخر في الإعدادات القيمة الست عشرية نفسها. تُرفق col() بكل لون معرّفه paletteId، وهذا المعرّف هو ما يتبعه تجاوز الجزء، في أنماط النص وفي عناصر التصميم على السواء.

#2 · صفحة فاصلة، وظهرها، وقائمتها

شيفرة هذه الخطوة هي الجواب المختصر أعلاه. يفتح :::part صفحة فاصلة على صفحة فردية، ويخرجها parts.design على مساحة القص كلها. يبدأ Markdown الواقع بين سطرَي فتحه وإغلاقه على بعد 125 mm من الحافة العليا، تحت العنوان: أسطر قليلة عن الموطن بنمط الفقرة habitat، ثم قائمة أنواعه بالنمط bodyStyle. يطلي versoDesign ظهر الورقة (المساحة الملوّنة، واللسان معكوس الألوان) حين تكون تلك الصفحة فارغة فقط، ويُبقيها breakAfter: { parity: 'odd' } فارغة بإرسال النوع الأول إلى الصفحة الفردية التالية. يطبع {numberRoman} قيمة number="I" الخاصة بالجزء رقمًا رومانيًا (و"1" كانت ستطبع I نفسها)، بينما تُرقَّم الأنواع من 1 إلى 4 بالأرقام العربية. ويقطع \\ في العنوان السطر في الصفحة الفاصلة وحدها؛ أما المحتويات والترويسات فتنضّد العنوان على سطر واحد.

#3 · ألوان التمييز في النص تتبع الجزء

script.js · الأسطر 90–108في الشيفرة الكاملة
const bodyText = {
  fontFamily: 'Alegreya', fontSize: pt(10.5), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('band'), // the field marks: **Bill**, **Voice.**
  italicColor: col('ink'), referenceColor: col('ink'),
  firstLineIndent: mm(4), indentAfterHeading: false,
  // Tighter than the 0.6–2 defaults. runtMinCharacters counts word spaces, not letters:
  // 45 are about 20 letters of Alegreya (the default 20, about 9); a shorter last line is a runt.
  minWordSpacing: 0.75, maxWordSpacing: 1.7, runtMinCharacters: 45,
};
const unorderedLists = { bulletChar: '•', color: col('band'), // the field marks' bullets
  marginTop: pt(0), marginBottom: pt(0) };
// The plates are numbered with the species, and their label is in the part's colour.
const resourceTypes = [{ id: 'plate', numberingTemplate: '{n}', resetOn: 'never',
  counterFormat: 'decimal', ...t({
    en: { name: 'Plate', namePlural: 'Plates', shortLabel: 'Pl.', captionPrefix: 'Plate' },
    es: { name: 'Lámina', namePlural: 'Láminas', shortLabel: 'Lám.', captionPrefix: 'Lámina' },
  }) }];
const captionStyle = { fontSize: pt(8.5), labelColor: col('band'), descriptionItalic: true,
  gap: mm(1.8) };

من :::part إلى الذي يليه، يأخذ كل لون نص يساوي القيمة الخاصة بالمدخل band قيمةَ الجزء (الحاوية :::part). وهي هنا العلامات الميدانية العريضة والنقاط وتسميات اللوحات. ويبقى المتن والنص المائل بلون الحبر. اللوحات نوع مورد مستقل، تسميته Plate ولا يُعاد ضبطه أبدًا، فتُعَدّ من 1 إلى 4 بالتوازي مع الأنواع.

#4 · صفحة افتتاح النوع

script.js · الأسطر 112–123في الشيفرة الكاملة
const species = { enabled: true, slot: { elements: [
  text('kicker', '{number} · {attr.status}', { ...label, fontSize: pt(8.5),
    letterSpacing: pt(1.7), color: col('band') }, at('top-left', 0, 1, 'container')),
  // 'cm' is a unit symbol: it keeps its lower case, so the size is not set in capitals.
  text('size', '{attr.size}', { ...label, textTransform: 'none', fontSize: pt(8.5),
    letterSpacing: pt(0.5), color: col('muted') }, at('top-right', 0, 1, 'container')),
  text('name', '{titleText}', { ...display, fontSize: pt(22), lineHeight: 1.05,
    color: col('ink') }, below('kicker', 1.5, { width: 'fill' })),
  text('latin', '{attr.latin}', { fontFamily: 'Alegreya', italic: true, fontSize: pt(11.5),
    color: col('ink') }, below('name', 0.8)),
  rule('rule', col('band'), 0.75, below('latin', 2, { width: mm(MEASURE) })),
] } };

تطبع صفحة افتتاح النوع ثلاثًا من سمات العنوان: status في العنوان التمهيدي بعد الرقم، وsize على يمين العنوان التمهيدي، وlatin تحت الاسم. يرتبط العنوان التمهيدي والخط تحت الاسم اللاتيني بالمدخل band، فيخدم تصميم واحد الموطنين كليهما. لا يضع العنوان فاصل صفحة خاصًا به: يبدأ كل نوع بعد :::pagebreak، أو بعد الفاصل الذي يلي الجزء، فتُعَدّ صفحته صفحة متن وتطبع الترويسات. ويُنضَّد الحجم بلا الحروف الكبيرة التي في التسمية، لأن cm رمز وحدة.

#5 · شريط لكل جزء في المحتويات

script.js · الأسطر 127–145في الشيفرة الكاملة
const contents = {
  levels: [{ level: 1, fontFamily: 'Zilla Slab', fontSize: pt(12), fontWeight: 600,
    numberFontFamily: 'Barlow Condensed', numberFontWeight: 600, numberColor: col('muted'),
    numberWidth: mm(5), numberGap: mm(3), marginTop: pt(4) }],
  pageNumber: { fontFamily: 'Barlow Condensed', fontSize: pt(10), fontWeight: 600, width: mm(7) },
  leader: { char: '. ' },
  subtitle: { enabled: true, attr: 'latin', fontFamily: 'Alegreya', fontSize: pt(9.5),
    color: col('muted') }, // the Latin name, in italic by default
  // A part row lays out this design with the part's number, title, page and palette.
  parts: { height: mm(8.5), marginTop: pt(LEAD), design: { elements: [
    box('row', col('band'), { ...at('top-left', 0, 0, 'container'), ...fill }),
    text('part', t({ en: 'Part {number}', es: 'Parte {number}' }), { ...label, fontSize: pt(8),
      letterSpacing: pt(1.6), color: col('paper') }, at('left', 3, 0, 'container')),
    text('title', '{titleText}', { ...display, fontSize: pt(12), color: col('paper') },
      at('left', 20, 0, 'container')),
    text('page', '{pageNumber}', { ...label, fontSize: pt(10), color: col('paper'),
      align: 'right' }, at('right', -2.5, 0, 'container')),
  ] } },
};

يخصّص :::toc لكل :::part سطرًا ويخرج فيه toc.parts.design برقم ذلك الجزء وعنوانه وصفحته الفاصلة ولوحة ألوانه (جدول المحتويات)، فيُطبع الصندوق نفسه بنيًا للسهول الطينية وأخضر لأحراش القصب. ويُظهر كل سطر نوع تحت الشريط رقمه وخطًا منقّطًا وصفحته، مع الاسم اللاتيني من السمة latin في السطر التالي.

#6 · الجزء في الترويسات وفي اللسان

script.js · الأسطر 149–162في الشيفرة الكاملة
const head = (id, content, parity, placement, style = {}) => ({ ...text(id, content, { ...label,
  fontSize: pt(8), letterSpacing: pt(1.4), color: col('muted'), overflow: 'clip', ...style },
placement), parity, pages: 'body' }); // dividers are 'part' pages, their versos 'blank'
const folio = { fontSize: pt(9), fontWeight: 700, color: col('band') };
const tab = (parity, edge) => head(`tab-${parity}`, '{partNumber}', parity,
  { ...at(edge, 0, TAB.y), size: TAB.size },
  { fontSize: pt(9), color: col('paper'), align: 'center', box: { backgroundColor: col('band') } });
const header = { elements: [
  head('verso-folio', '{pageNumber}', 'even', at('top-left', MARGIN.outer, HEAD.y), folio),
  head('verso-title', '{title}', 'even', at('top-left', MARGIN.outer + HEAD.gap, HEAD.y)),
  head('recto-title', '{partTitle}', 'odd', at('top-right', -(MARGIN.outer + HEAD.gap), HEAD.y)),
  head('recto-folio', '{pageNumber}', 'odd', at('top-right', -MARGIN.outer, HEAD.y), folio),
  tab('even', 'top-left'), tab('odd', 'top-right'), // on the fore-edge, left on a verso
] };

مع pages: 'body' تُطبع الترويسات في صفحات المتن وحدها. الصفحات الفاصلة صفحات part، وظهورها المطلية صفحات blank؛ ويبدأ كل من الغلاف والمحتويات بعنوان بعرض الصفحة، فيجعلهما ذلك صفحتي افتتاح. تطبع ترويسة الصفحة الزوجية {title}، أي العنوان الوارد في frontmatter، فيبقى اسم الكتاب في نص Markdown. وتطبع ترويسة الصفحة الفردية {partTitle} على سطر واحد، ويطبع اللسان عند الحافة الأمامية {partNumber} على صندوق ترتبط خلفيته بالمدخل band.

الوصفة كاملة

Sandbox
// ═══ Postext Cookbook · Nº 019 · Parts in colour from one attribute ═══════════════════════
// https://postext.dev/en/cookbook/parts-in-colour
// Code: MIT · Text: original (CC BY 4.0) · Pictures: diffusion models
// Fonts: Alegreya, Zilla Slab, Barlow Condensed (SIL OFL 1.1) · Needs postext ≥ 1.57.0
// A pocket field guide to two habitats. Each :::part names its own 'band' colour, and every
// colour linked to 'band' takes it: the divider and its verso, the tab, the field marks.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'parts-in-colour';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: 'band' is the entry the parts override; the others keep their value
const palette = {
  ink: '#1f2624', // text: a green-tinted near-black
  band: '#3c4b4f', // the house slate, before any part; each :::part brings its own
  paper: '#f6f3ea', // the page, and the type set on a band
  rule: '#d5d1c4', // hairlines
  muted: '#61675f', // running heads, Latin names, the colophon
};
// The paletteId is the link a part's palette="band=#…" follows, in text and designs alike.
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' } })),
  // The engine's defaults link to 'main-color': point it at the ink, so nothing prints blue.
  { id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
// #endregion
const TRIM = { width: 150, height: 200 }; // a pocket guide
const MARGIN = { top: 22, bottom: 20, inner: 19, outer: 21 }; // mirrored; room for a thumb
const MEASURE = TRIM.width - MARGIN.inner - MARGIN.outer; // 110 mm, about 70 characters
const LEAD = 14.5; // body leading in pt: the baseline grid
const STRIP = 44; // the contents' picture strip, from the top edge (mm)
const HEAD = { y: 12, gap: 8 }; // running heads from the top edge; folio to title (mm)
const TAB = { y: 26, size: { width: mm(8), height: mm(24) } }; // the thumb tab, at the fore-edge
const TITLE_DROP = 6; // mm from the foot of the contents strip to the title's box
const BOOK = t({ en: 'Birds of the Estuary', es: 'Aves del estuario' });
const label = { fontFamily: 'Barlow Condensed', fontWeight: 600, textTransform: 'uppercase' };
const display = { fontFamily: 'Zilla Slab', fontWeight: 700 };
const at = (edge, x, y, to = 'page') => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const below = (id, y, size) => ({ ...at('below', 0, y, `#${id}`), ...(size && { size }) });
const fill = { size: { width: 'fill', height: 'fill' } };
const text = (id, content, style, placement) => ({ kind: 'text', id, content, overflow: 'wrap',
  align: 'left', ...style, placement });
const box = (id, color, placement) => ({ kind: 'box', id, style: { backgroundColor: color },
  placement });

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

تنويعات

#أضف موطنًا ثالثًا

كتلة :::part قبل أول نوع من أنواع المستنقعات المالحة يضيف لونًا ثالثًا، مع صفحته الفاصلة وظهرها المطلي وسطره في المحتويات، وتبقى الإعدادات كما هي. واحذف الملاحظة تحت المحتويات أيضًا، لأن الشريط الثالث وأنواعه يحتاجان إلى المساحة.

+:::part{number="III" title="The \\ Saltmarsh" palette="band=#6b4a7a"}
+:::
+
+# Common Shelduck {latin="Tadorna tadorna" size="58–67 cm" status="Resident"}

#دع النوع يقابل الصفحة الفاصلة

من دون الفاصل إلى الصفحة الفردية التالية يبدأ النوع الأول على ظهر الصفحة الفاصلة، فلا تبقى صفحة زوجية فارغة يطليها versoDesign.

-  breakAfter: { parity: 'odd' },

أخطاء شائعة

خطأ شائع

يحتاج parts.versoDesign إلى parts.breakAfter بالزوجية 'odd'

لا يُرسَم ظهر صفحة فاصل الجزء إلا إذا ترك parts.breakAfter { enabled: true, parity: 'odd' } تلك الصفحة الزوجية فارغة. صفحات فواصل الأجزاء →

خطأ شائع

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

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

  • يعيد الجزء تلوين النص بمقارنة القيم: أي لون نص يساوي القيمة الخاصة بالمدخل band يتبدّل مع الجزء، حتى لو كان مرتبطًا بمدخل آخر أو غير مرتبط بأي مدخل. خصّص تلك القيمة الست عشرية للمدخل band وحده.
  • يطبع اللسان {partNumber}، وهو فارغ خارج الأجزاء، فتأخذ صفحة المتن الواقعة قبل أول :::part لسانًا أردوازيًا فارغًا. أبقِ كل صفحة متن داخل جزء.
  • تحتفظ الصور وعيّنات الألوان داخل النص بالألوان المكتوبة فيها. وتأخذ اللوحات هنا ألوان موطنها من HABITAT في الشيفرة، لذلك يجب أن يُكتب اللون الجديد في :::part هناك أيضًا.

الحقوق

الوصفة
Ignacio Ferro
النص
نص أصلي, CC BY 4.0
الصور
  • The cover: a curlew on the estuary mud, reeds in front · Generated With Diffusion Models · أصلي
  • The contents strip: a curlew and a redshank on the mud, the reedbed beyond · Generated With Diffusion Models · أصلي
  • Plate 1: Eurasian curlew · Generated With Diffusion Models · أصلي
  • Plate 2: common redshank · Generated With Diffusion Models · أصلي
  • Plate 3: bearded reedling · Generated With Diffusion Models · أصلي
  • Plate 4: common reed warbler · Generated With Diffusion Models · أصلي
الخطوط
Alegreya (SIL OFL 1.1) · Zilla Slab (SIL OFL 1.1) · Barlow Condensed (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
Sandbox