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

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

مختارات بأسماء الكتّاب

ثلاث مقالات عن المشي في عناوينها الكاتب والسنة والمجلة: تطبعها صفحة الافتتاح كلها، وتطبع الترويسات الزوجية والمحتويات اسم الكاتب.

في هذه الصفحة
  • نموذج باللغة الإنجليزية: لا توجد طبعة عربية بعد
  • مقاس القص 135 × 180 مم
  • عمود واحد
  • Spectral 10/14
  • Gloock
  • Hanken Grotesk
  • 9 صفحات
  • المستوى
  • Postext 1.57.1
  • أُخرجت في 64 ms
  • أسطر الشيفرة: 175

باختصار

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

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

تسع صفحات من Afoot، مختارات جيب من ثلاث مقالات عن المشي كتبها هازلت (1822) وثورو (1862) وستيفنسون (1876). يملأ الغلاف لوحةٌ لأرض بور عند الغسق، صورة JPEG مولَّدة بنماذج الانتشار. وفي المحتويات لكل مقالة رقم بلون الصدأ، وعنوان بخط Gloock، ونقاط إرشادية متباعدة إلى صفحتها، واسم الكاتب بمائل بلون الخلنج تحته. وتفتتح كل مقالة برقمها وعنوانها، ثم سطر باسم الكاتب بحروف كبيرة متباعدة، ثم سطر تاريخ فيه المجلة وسنة النشر الأول. على الصفحات الزوجية اسم الكاتب، وعلى الفردية عنوان المقالة. وتُكتب في عنوان كل مقالة سماتٌ هي كاتبها وسنتها ومصدرها، ومن هناك تطبعها صفحة الافتتاح والترويسات والمحتويات، فلا تحتاج مقالة رابعة إلى أي تغيير في الإعداد.

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

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

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

script.js · الأسطر 44–64في الشيفرة الكاملة
// Each essay's heading carries its credits, and every {attr.…} below reads them:
//   # Walking {author="Henry David Thoreau" year="1862" source="The Atlantic Monthly"}
// (a value cannot hold { or }, and one with " goes in single quotes; gotcha: attr-values)
// 1 · The opener: inside a heading's design, {attr.author} is that heading's attribute.
const byline = [
  text('byline', '{attr.author}', { ...label, fontSize: pt(8), letterSpacing: pt(1.6),
    color: col('heather') }, below('title', 5)),
  text('dateline', '{attr.source}, {attr.year}', { fontFamily: 'Spectral', italic: true,
    fontSize: pt(9.5), color: col('muted'), align: 'left' }, below('byline', 1.2)),
];
// 2 · The verso running head (head() is in the running-heads region): in the page header,
//     {attr.author} is the attribute of the essay the page belongs to.
const versoAuthor = head('verso-author', '{attr.author}', 'even',
  at('page', 'top-left', MARGIN.outer + HEAD.gap, HEAD.y));
// 3 · The contents: toc.subtitle prints the attribute it names as a line under each title.
//     'author' and italic are the defaults; attr is written out so it can become 'source'.
const authorLine = { enabled: true, attr: 'author', fontFamily: 'Spectral', fontSize: pt(10),
  color: col('heather') };
// Hooked up below: byline → the opener, versoAuthor → header, authorLine → toc.subtitle.
// A heading without author="…" gets an empty byline and running head and no line in the
// contents, and the build gives no warning: check every heading.

المكونات

الخطوط
Spectral, Gloock, Hanken Grotesk (SIL OFL 1.1)
الأصول
  • cover-1200.jpg
  • The cover: a heath and hills at dusk, a painting (Generated With Diffusion Models, أصلي)

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

#1 · رقّم المقالات وأنزل نصّها

script.js · الأسطر 68–85في الشيفرة الكاملة
const opener = { enabled: true,
  // The hairline ends 7 mm above the foot of this reserve, so the text starts on the same grid
  // line under every opener whose title fits on one line (SINK = 14 holds a two-line title).
  minHeight: pt(SINK * LEAD),
  slot: { elements: [
    // {number} prints the essay's number as numberingTemplate '{1:I}' writes it: I, II, III.
    text('number', '{number}', { ...gloock, fontSize: pt(34), lineHeight: 1, color: col('rust') },
      at('container', 'top-left', 0, 8)),
    text('title', '{titleText}', { ...gloock, fontSize: pt(26), lineHeight: 1.08,
      color: col('ink') }, below('number', 3, { width: 'fill' })),
    ...byline,
    { kind: 'rule', id: 'rule', thickness: pt(0.5), color: col('rule'),
      placement: below('dateline', 6) }, // a horizontal rule runs to the column's edge
  ] } };
const essays = { level: 1, numberingTemplate: '{1:I}', advancedDesign: opener,
  marginBottom: pt(0), // the heading's default margin would add to minHeight
  // The cover and contents styles inherit this break (gotcha: style-inherits-break).
  breakBefore: { enabled: true, parity: 'any' } }; // 'any': each piece opens on the next page

يرقّم numberingTemplate: '{1:I}' في المستوى المقالاتِ I وII وIII، ويطبع {number} الرقم فوق العنوان (الامتداد والتصميم المتقدم). يحجز minHeight اثني عشر سطرًا من 14 pt، وينتهي الخط الشعري قبل نهاية هذا الحجز بـ7 مم، فيبدأ النص تحت عنوان من سطر واحد على بعد 79 مم من الحافة العليا في كل صفحة افتتاح. يضيف سطر ثانٍ من عنوان بحجم 26 pt مقدار 9.9 مم ويدفع النص خطًّا واحدًا من الشبكة إلى الأسفل؛ ومع SINK = 14 تبدأ العناوين ذات السطر والسطرين نصّها على السطر نفسه. ويمنع marginBottom: pt(0) الهامشَ الافتراضي للعنوان من أن يُضاف إلى الحجز.

#2 · دع المحتويات تملأ نفسها

script.js · الأسطر 89–99في الشيفرة الكاملة
const ENTRY = 15; // pt: the essay titles in the contents
const contents = { // passed to the config as `toc`
  // An entry's numeral takes the title's face and size and stands on its baseline.
  levels: [{ level: 1, fontFamily: 'Gloock', fontSize: pt(ENTRY), color: col('ink'),
    numberFontWeight: 400, // Gloock has one weight
    numberColor: col('rust'), numberWidth: mm(8), numberGap: mm(3), marginBottom: pt(LEAD) }],
  pageNumber: { fontFamily: 'Hanken Grotesk', fontSize: pt(8.5), fontWeight: 600,
    color: col('muted'), width: mm(6) }, // the leader dots take this face and colour too
  leader: { char: '. ', gap: mm(2) }, // spaced dots, right-aligned so they line up
  subtitle: authorLine,
};

يطبع :::toc في Markdown مدخلًا لكل عنوان مُدرج: الرقم، والعنوان، والنقاط الإرشادية، ورقم الصفحة، واسم الكاتب عبر subtitle. يعيد buildDocument إخراج الكتاب حتى تكف أرقام الصفحات عن التغيّر، فإذا غيّرت اسم مقالة أو أطلتها تحدّثت المحتويات (جدول المحتويات). ويأخذ رقم المدخل خط العنوان وحجمه ما لم يحدّد numberFontFamily أو numberFontSize غير ذلك، ويقف على خط أساس السطر الأول من العنوان أيًّا كان حجمه. والكتاب الذي فيه أجزاء يأخذ أيضًا صفًّا لكل :::part، يرسمه toc.parts.design، كما في أجزاء بالألوان.

#3 · الكاتب على الزوجية والمقالة على الفردية

script.js · الأسطر 103–119في الشيفرة الكاملة
// Each head: the label face, the pages of its parity, never an opener (pages: 'body'), where
// the byline names the author. A function declaration, so the answer above can call it.
function head(id, content, parity, placement, look = {}) {
  return { ...text(id, content, { ...label, fontSize: pt(7.5), letterSpacing: pt(1.3),
    color: col('muted'), ...look }, placement), parity, pages: 'body' };
}
const folio = { color: col('ink') };
const header = { elements: [
  head('verso-folio', '{pageNumber}', 'even', at('page', 'top-left', MARGIN.outer, HEAD.y), folio),
  versoAuthor,
  head('recto-title', '{chapterTitle}', 'odd',
    at('page', 'top-right', -(MARGIN.outer + HEAD.gap), HEAD.y), { align: 'right' }),
  head('recto-folio', '{pageNumber}', 'odd', at('page', 'top-right', -MARGIN.outer, HEAD.y),
    { ...folio, align: 'right' }),
] };
const footer = { elements: [{ ...head('drop-folio', '{pageNumber}', 'all', // an opener's folio
  at('container', 'top', 0, 9), { ...folio, align: 'center' }), pages: 'opener' }] };

كل ترويسة مربوطة بالصفحة، على بعد 11 مم من الحافة العليا، ويختار parity الجانب: يصطف رقم الصفحة مع الحافة الخارجية للنص، ويقع الاسم أو العنوان أبعد منه إلى الداخل بـ 7 مم. يُبعد pages: 'body' في head() الترويسات عن صفحات الافتتاح، حيث يذكر سطر الكاتب اسمه أصلًا، ويطبع pages: 'opener' في التذييل رقم صفحة منخفضًا هناك بدلًا منها (العناصر النصية). ويطبع {chapterTitle} عنوان المقالة بلا رقمها.

#4 · أخرج الغلاف والمحتويات من العدّ

script.js · الأسطر 123–146في الشيفرة الكاملة
// Unnumbered, so the first essay is I; unlisted; and with no running heads or folio. They
// inherit the level's page break, 'any' (gotcha: style-inherits-break).
const bare = { numbered: false, toc: false, header: { elements: [] }, footer: { elements: [] } };
const cover = { enabled: true, slot: { elements: [
  { kind: 'image', id: 'art', resourceId: 'cover',
    placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: 'fill' } } },
  text('title', '{titleText}', { ...gloock, fontSize: pt(80), lineHeight: 1, color: col('ink') },
    at('page', 'top-left', MARGIN.inner, 22)), // page 1 is a recto: the inner margin is left
  text('subtitle', '{subtitle}', { fontFamily: 'Spectral', italic: true, fontSize: pt(14),
    color: col('ink'), align: 'left' }, below('title', 1)),
  text('authors', '{attr.authors}', { ...label, fontSize: pt(8.5), letterSpacing: pt(2),
    color: col('heather') }, below('subtitle', 5)),
  text('imprint', '{attr.imprint}', { ...label, fontSize: pt(7.5), letterSpacing: pt(1.8),
    color: col('paper') }, at('page', 'bottom-left', MARGIN.inner, -12)),
] } };
// span: 'page' in a one-column book: a design kept in its column is cut at the column's foot,
// which would leave a band of paper under the dusk.
const coverStyle = { id: 'cover', ...bare, span: 'page', advancedDesign: cover };
const contentsOpener = { enabled: true, slot: { elements: [ // {title}, {subtitle}: frontmatter
  text('kicker', '{title} · {subtitle}', { ...label, fontSize: pt(8), letterSpacing: pt(1.6),
    color: col('heather') }, at('container', 'top-left', 0, 8)),
  text('title', '{titleText}', { ...gloock, fontSize: pt(26), color: col('ink') },
    below('kicker', 2.5)),
] } };

مع numbered: false لا يزيد الغلاف ولا المحتويات العدّاد، فتكون مقالة هازلت I، ويُبعدهما toc: false عن القائمة (أنماط العناوين). يرث النمطان breakBefore من المستوى، بزوجية 'any'، ولهذا تأتي المحتويات بعد الغلاف في الصفحة 2 بلا :::pagebreak. ويمتد نمط الغلاف عبر الصفحة في كتاب ذي عمود واحد، لأن التصميم الذي يبقى داخل العمود يُقص عند أسفل العمود، فيترك 22 مم من الورق تحت المنظر.

#5 · اكتب كل لون صراحة مع رابطه في لوحة الألوان

script.js · الأسطر 14–28في الشيفرة الكاملة
const palette = {
  ink: '#241f26', // text: a plum-tinted near-black
  paper: '#f7f2e8', // the page
  heather: '#6b4468', // the bylines and the authors in the contents
  rust: '#a4502a', // the essay numbers
  rule: '#d5cabd', // hairlines
  muted: '#6d6570', // running heads, datelines, page numbers in the contents
};
// col() links a colour to its palette entry; the hex is the value the entry holds.
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' } },
];

تكتب col() القيمة الست عشرية لكل لون بجانب paletteId الخاص به، والمحرّك يتبع هذا الرابط: أسطر الكتّاب والترويسات والغلاف تأخذ اللون المحفوظ في colorPalette تحت ذلك المعرّف، فإذا بدّلت لوحة الألوان بأخرى لها المعرّفات نفسها تغيّر لون الكتاب كله. وتوجيه main-color إلى لون الحبر يغطي كل قيمة افتراضية لا يعيد الإعداد ذكرها، وكانت ستُطبع لولا ذلك بأزرق المحرّك، #295AA3.

الوصفة كاملة

Sandbox
// ═══ Postext Cookbook · Nº 030 · Anthology with bylines ═══════════════════════════════
// https://postext.dev/en/cookbook/anthology-with-bylines
// Code: MIT · Text: Hazlitt, Thoreau, Stevenson (public domain) · Cover: diffusion models
// Fonts: Spectral, Gloock, Hanken Grotesk (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 = 'anthology-with-bylines';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: heather for the credits, rust for the numbers, plum ink on warm paper
const palette = {
  ink: '#241f26', // text: a plum-tinted near-black
  paper: '#f7f2e8', // the page
  heather: '#6b4468', // the bylines and the authors in the contents
  rust: '#a4502a', // the essay numbers
  rule: '#d5cabd', // hairlines
  muted: '#6d6570', // running heads, datelines, page numbers in the contents
};
// col() links a colour to its palette entry; the hex is the value the entry holds.
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: 135, height: 180 }; // a pocket book, 3 : 4
const MARGIN = { top: 20, bottom: 22, inner: 19, outer: 15 }; // mirrored
const LEAD = 14; // body leading in pt: the baseline grid
const SINK = 12; // grid lines an essay opener reserves above its first line of text
const HEAD = { y: 11, gap: 7 }; // running heads: mm from the top edge, folio to words
const label = { fontFamily: 'Hanken Grotesk', fontWeight: 600, textTransform: 'uppercase',
  align: 'left' }; // design text is centred by default
// One weight, no italic; 'wrap' breaks a long title onto a second line.
const gloock = { fontFamily: 'Gloock', overflow: 'wrap', align: 'left' };
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const below = (id, y, size) => ({ ...at(`#${id}`, 'below', 0, y), ...(size && { size }) });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, ...look, placement });

// #region answer: one set of heading attributes, read in three places
// Each essay's heading carries its credits, and every {attr.…} below reads them:
//   # Walking {author="Henry David Thoreau" year="1862" source="The Atlantic Monthly"}
// (a value cannot hold { or }, and one with " goes in single quotes; gotcha: attr-values)
// 1 · The opener: inside a heading's design, {attr.author} is that heading's attribute.
const byline = [

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

تنويعات

#اذكر أين نُشرت كل مقالة أول مرة

يطبع toc.subtitle أي سمة من سمات العنوان، فيستطيع Markdown نفسه أن يذكر تحت عنوان كل مقالة المجلة التي نشرتها أولًا.

-const authorLine = { enabled: true, attr: 'author', fontFamily: 'Spectral', fontSize: pt(10),
+const authorLine = { enabled: true, attr: 'source', fontFamily: 'Spectral', fontSize: pt(10),

#ضع عنوان الكتاب على الصفحة الزوجية

كثير من الكتب تضع عنوانها على الصفحة الزوجية وعنوان الفصل على الفردية؛ يقرأ {title} العنوان من البيانات التمهيدية لملف Markdown ويطبع AFOOT.

-const versoAuthor = head('verso-author', '{attr.author}', 'even',
+const versoAuthor = head('verso-author', '{title}', 'even',

#افتتح كل مقالة على صفحة فردية

مع الزوجية 'odd' تنتقل مقالة ستيفنسون إلى الصفحة 9 بعد صفحة 8 فارغة. وعندها يحتاج نمطا الصفحات التمهيدية إلى 'any' خاص بهما، وإلا ورثت المحتويات 'odd' وافتُتحت في الصفحة 3 بعد صفحة زوجية فارغة.

-  breakBefore: { enabled: true, parity: 'any' } }; // 'any': each piece opens on the next page
+  breakBefore: { enabled: true, parity: 'odd' } };
-const bare = { numbered: false, toc: false, header: { elements: [] }, footer: { elements: [] } };
+const bare = { numbered: false, toc: false, breakBefore: { enabled: true, parity: 'any' },
+  header: { elements: [] }, footer: { elements: [] } };

أخطاء شائعة

خطأ شائع

قيم السمات: لا { ولا }؛ ضع القيمة التي فيها " بين علامتي اقتباس مفردتين

تنتهي قيمة السمة عند القوس المعقوف الختامي، فلا يمكن أن تحتوي { أو }. القيمة التي فيها علامة اقتباس مزدوجة توضع بين علامتي اقتباس مفردتين؛ أما علامة الدولار فلا مشكلة فيها. سمات العنوان →

خطأ شائع

يرث نمط العنوان فاصل الصفحة من مستواه

يأخذ مُدخل headingStyles كل حقل يتركه من مستوى عنوانه، بما فيه breakBefore. فصفحة المحتويات أو صفحة بيانات النشر المنسّقة على H1 بعد :::pagebreak ترث الزوجية 'odd' وتقع بعد صفحة فارغة. أعطِ هذا النمط breakBefore: { enabled: false }. أنماط العناوين →

  • يقتبس هازلت شعرًا في وسط جمله. والأبيات توضع في كتلة :::verse{style="verse" align=start}، كل سطر من Markdown بيت مزاح 8 مم، والجملة التي تُستأنف بعده تأخذ نمط runon بلا إزاحة. أما الاقتباس الكتلي في Markdown فلا يصلح هنا: تتصل أسطره كما تتصل أسطر الفقرة، فتُطبع الأبيات متتابعة كالنثر.
  • السمة التي يخلو منها العنوان لا تطبع شيئًا ولا تُطلق أي تحذير. فبلا author="…" يخرج سطر كاتب المقالة وترويستها الزوجية فارغين، ويختفي سطرها تحت العنوان من المحتويات.

الحقوق

الوصفة
Ignacio Ferro
النص
الصور
  • The cover: a heath and hills at dusk, a painting · Generated With Diffusion Models · أصلي
الخطوط
Spectral (SIL OFL 1.1) · Gloock (SIL OFL 1.1) · Hanken Grotesk (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
Sandbox