باختصار
دعوة من مجلس بلدي لتقديم تصاميم تحوّل سوقًا قديمة للسمك إلى مكتبة. عناوين الأقسام في هامش أيسر عريض، على مستوى السطر الأول من النص الذي بجانبها.
ما الذي ستنضده
خمس صفحات A4 من كرّاسة شروط مسابقة معمارية، يدعو فيها مجلس Puerto Lince، وهو ميناء إسباني متخيَّل، إلى تقديم تصاميم تحوّل سوق السمك التي بُنيت عام 1931 إلى مكتبة البلدة. الإخراج يتبع التقارير البلدية السويسرية. قناة عرضها 50 mm تجري على يسار كل صفحة، وكل قسم يبدأ برقم أحمر وخط أسود على كتلة النص كلها. يقف عنوان القسم في القناة بخط Noto Serif Display، على مستوى السطر الأول من النص. أرقام الأقسام الفرعية معلّقة في الفاصل بخط DM Mono الأحمر، فيحتفظ كل عنوان فرعي بالحافة اليسرى للنص. معايير التحكيم في القسم 4 تبدأ بمصطلحات عريضة بالأحمر. تنضّد الصفحة 1 عنوانًا بحجم 58 pt فوق مخطط الموقع، ويقف مخطط قطعة الأرض في القناة في الصفحة 2، وتفتتح واجهةُ الرصيف البحري الصفحة 3.
تجيب هذه الوصفة عن
- كيف أرقّم العناوين (1، 1.1، 1.1.1) وأنسّق كل مستوى بطريقة مختلفة؟
- كيف أصمم تخطيط عمود ونصف، فيه عمود نص عريض وعمود جانبي ضيق؟
- كيف أتحكم في موضع الشكل: أعلى الصفحة، أو بعرض العمودين، أو هنا تمامًا، أو في الهامش؟
- كيف ألوّن المصطلحات الرئيسية (العريضة أو المائلة) في المتن أو داخل الإطارات؟
الجواب المختصر
// The heading stays in the flow and keeps its number, but its design has no {titleText}:
// it prints the number in the channel and a rule from there to the column's right edge,
// both reserve: false, or the box below would keep a float gap under them (a line lower).
const [NUMBER, RULE] = [8.5, 0.75]; // pt: the DM Mono number, whose figures are 0.7 em tall
// Centre the rule on the figures: their baseline is 0.8 of the line down, less 0.35 em.
const RULE_Y = pt(NUMBER * (0.8 - 0.7 / 2) - RULE / 2);
const h2 = { level: 2, numberingTemplate: '{2}', lineHeight: pt(LEAD), // one grid line
marginTop: pt(2 * LEAD), marginBottom: pt(0), advancedDesign: { enabled: true, slot: {
elements: [
{ kind: 'text', id: 'number', content: '{number}', fontFamily: LABEL, fontWeight: 500,
fontSize: pt(NUMBER), lineHeight: 1, color: col('signal'), reserve: false,
placement: at('container', 'top-left', mm(-HANG)) },
{ kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(RULE), reserve: false,
color: col('ink'), placement: { ...at('#number', 'right-of', mm(2), RULE_Y),
size: { width: 'fill' } } },
] } } };
// The title goes in a box fenced right after the heading: span="side" stands it in the
// channel on the grid line where the text resumes (gotcha: side-box-starts-at-fence).
// Attributes at the end of the line stay with the heading.
const sideHeads = (md) => md.replace(/^## (.+?)(\s*\{[^}]*\})?$/gm,
(line, title) => `${line}\n\n:::callout{type="sidehead" span="side"}\n${title}\n:::`);
// The box has no background and no padding, and it takes the text's leading, so each
// line of the title sits on a baseline of the text beside it.
const sidehead = { id: 'sidehead', backgroundEnabled: false,
padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
body: { fontFamily: DISPLAY, fontSize: pt(13.5), lineHeight: pt(LEAD) } };
المكونات
- الميزات
- ملاحظات الهامشصفحات افتتاح مصمَّمةعمود ونصفعمود هامشي للعناصر العائمةالعناوين المرقّمةسمات العنوانالنصوص والخطوط والمربعات في تصاميم الصفحةتثبيت عناصر التصميمالصور في تصاميم الصفحةاستشهادات تضع الأشكالموضع الأشكالإطارات التنبيهالغامق والمائل وألوانهماالترويسات وأرقام الصفحاتنمط الجدولأنماط الأرقامنمط التعليق«شكل» و«جدول» بلغتكتعليقات جانبيةأشكال في هذا الموضع بالضبط
- تستخدم أيضًا
- موازنة الأعمدةشريط فصل بعرض الصفحةلون الورقأنماط الفقراتأنواع موارد مخصّصةالأشكال والجداول بوصفها مواردأنماط الجداول المسمّاة
- الخطوط
- Mona Sans, Noto Serif Display, DM Mono (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#1 · اطبع عنوان القسم من صندوق في القناة
الشيفرة في الجواب المختصر أعلاه. يحجز العنوان مساحة حتى أدنى عنصر في تصميمه، فلو رُسم العنوان في القناة على مستوى السطر الأول من القسم لدفع النص سطرًا إلى الأسفل، وسطرين لعنوان من سطرين. لذلك لا يرسم تصميم العنوان إلا الرقم والخط، وتنسخ sideHeads() نص كل ## Title إلى كتلة :::callout مباشرة بعد العنوان. مع span="side" يغادر ذلك الإطار التدفق ويقف في القناة على خط الشبكة الذي يُستأنف عنده النص (أنماط الإطارات). وللرقم والخط reserve: false: وإلا ترك الإطار في القناة فجوةَ عائمٍ بمقدار سطر تحت عناصر العنوان القائمة فيها، فينزل العنوان إلى السطر الثاني من النص. الإطارات ونص المتن كلاهما يضع خط أساس السطر عند 0.8 من ارتفاع السطر نزولًا، فالإطار الذي على تباعد أسطر النص البالغ 14 pt يضع كل سطر من عنوان ذي سطرين على خط أساس من الفقرة التي بجانبه. يبقى ملف Markdown عنوانًا بسيطًا ## Schedule of accommodation. ولأن تصميم العنوان لا يطبع {titleText}، يسرد Sandbox التحذير نص العنوان غير مُشار إليه، مع أن الإطار يطبع العنوان.

#2 · خصّص القناة للعناوين والأشكال
const layout = {
layoutType: 'oneAndHalf',
sideColumnPercent: (SIDE / CONTENT) * 100, // 50 of the 178 mm between the margins
sideColumnSide: 'left', // on every page: the brief is printed on one side of the sheet
sideColumnRole: 'floats', // no text in the channel: what span: 'side' sends, side captions
gutterWidth: mm(GUTTER),
};
يُبقي sideColumnRole: 'floats' النص خارج القناة (أنواع الإخراج). بعد تصميم الافتتاح ليس في القناة إلا عناوين الأقسام الستة ومخطط قطعة الأرض، وكلاهما يُرسل إليها بـspan: 'side'، وتعليقا الجدولين 1 و2. القيمة الافتراضية للعمود الجانبي 'right'، والكرّاسة المطبوعة على وجه واحد من الورقة تُبقيه في الجهة نفسها من كل صفحة. ويضعه sideColumnSide: 'left' على اليسار، حيث يُقرأ عنوان كل قسم قبل نصه.
#3 · علّق الأرقام وادمج أصغر العناوين في السطر
// The title keeps the text's left edge; the number, right-aligned in a 12 mm box, ends
// 2 mm short of it. The box needs that fixed width: an 'auto' width is clamped to the
// column and would shrink to nothing out here.
const H3 = { size: 10.5, number: 9 }; // pt; two boxes one grid line tall share a baseline
const h3 = { level: 3, numberingTemplate: '{2}.{3}', fontSize: pt(H3.size),
lineHeight: pt(LEAD), marginTop: pt(LEAD), marginBottom: pt(0),
advancedDesign: { enabled: true, slot: { elements: [
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: TEXT, fontWeight: 600,
fontSize: pt(H3.size), lineHeight: LEAD / H3.size, color: col('ink'), align: 'left',
overflow: 'wrap', placement: { ...at('container', 'top-left'), size: { width: 'fill' } } },
{ kind: 'text', id: 'number', content: '{number}', fontFamily: LABEL, fontWeight: 500,
fontSize: pt(H3.number), lineHeight: LEAD / H3.number, color: col('signal'),
align: 'right', placement: { ...at('#title', 'left-of', mm(-2)),
size: { width: mm(12) } } },
] } } };
// Level 4 is not a heading: '**Accessibility.** A wheelchair user…' opens its paragraph.
// No other paragraph has bold; table cells keep tableStyle's ink, so Total stays black.
const runIn = { boldColor: col('signal') }; // spread into bodyText
عنوان القسم الفرعي يبدأ عند الحافة اليسرى للعمود. ورقمه مربوط 'left-of' العنوان، بمحاذاة يمنى في مستطيل عرضه 12 mm ينتهي قبل النص بـ2 mm، فتتعلّق أرقام مثل 2.1 و3.3 في الفاصل ويصطف كل عنوان مع النص تحته (تموضع العناصر). المستطيل يحتاج إلى عرض ثابت. العرض 'auto' يُقيَّد بالعمود. وفي الفاصل، خارج العمود، لا يبقى له أي عرض، فلا يُرسم الرقم. يطبع المستوى 2 القيمة '{2}' والمستوى 3 القيمة '{2}.{3}'، لأنه مع {1} كان كل رقم سيبدأ بالرقم 1 الخاص بعنوان H1 الوحيد في الكرّاسة. المعايير في القسم 4 مستوى رابع منضّد من غير عنوان. كل فقرة تبدأ بمصطلح عريض، ويطبعه bodyText.boldColor بالأحمر (نص المتن). لا فقرة أخرى فيها عريض، وخلايا الجداول تأخذ لونها من tableStyle، فيبقى صف Total العريض في الجدول 1 أسود.
#4 · أعطِ كل شكل وجدول تموضعه الخاص
// The plot plan stands in the channel; the elevation crosses channel and column at the
// head of the next page; the table of areas floats to the head of the text column, with
// its caption beside it in the channel; the timetable sits where ::resource puts it, and
// its caption takes the channel too (captionSide serves an inline embed from 1.28).
const PLAN_W = 44; // mm: the plot plan, 88 m wide at 1:2000
const resource = (id, typeId, rest) => ({ id, typeId, createdAt: 0, updatedAt: 0, ...rest });
const drawing = (id, width, height, rest) => resource(id, 'figure', { kind: 'svg',
svg: { fileId: `${id}.svg`, width, height }, ...rest });
const resources = [
drawing('parcela', PLAN_W * 10, 400, {
placement: { span: 'side', width: PLAN_W / SIDE }, // 44 mm of the channel's 50
caption: t({ en: 'The plot, 1:2000. Market hall and weighbridge hut in grey; six tamarisks '
+ 'along the north edge. Red arrows: possible entrances; grey arrow: service.',
es: 'La parcela, 1:2000. Lonja y caseta de básculas, en gris; seis tamarindos en el '
+ 'borde norte. Flechas rojas: accesos posibles; flecha gris: servicio.' }),
altText: t({ en: 'Plan of the plot with the hall, the hut, six trees and three entrances.',
es: 'Planta de la parcela con la lonja, la caseta, seis árboles y tres accesos.' }) }),
drawing('fachada', 1780, 300, { placement: { position: 'top', span: 'page' },
caption: t({ en: 'Quay front, 1:300. In red, the four frames at the east end, where the '
+ 'reinforcement has corroded.',
es: 'Fachada al muelle, 1:300. En rojo, los cuatro pórticos del extremo este, con '
+ 'las armaduras corroídas.' }),
altText: t({ en: 'Elevation of the hall: thirteen vaults, eleven arches, four frames in red.',
es: 'Alzado de la lonja: trece bóvedas, once arcos y cuatro pórticos en rojo.' }) }),
resource('programa', 'table', { kind: 'table', table: { ...programme, styleId: 'figures' },
placement: { position: 'top', captionSide: true }, caption: t({
en: 'Schedule of net floor areas.', es: 'Programa de superficies útiles por zonas.' }) }),
resource('calendario', 'table', { kind: 'table', table: calendar,
placement: { position: 'here', captionSide: true },
caption: t({ en: 'Competition timetable.', es: 'Calendario del concurso.' }) }),
// No :ref cites the site plan: only the opener's image element draws it.
drawing('situacion', MAP.w * 10, MAP.h * 10, { altText: t({
en: 'Site plan of the Poniente quay with the market hall’s plot in red.',
es: 'Plano de situación del muelle de Poniente con la parcela de la lonja en rojo.' }) }),
];
يذهب مخطط قطعة الأرض إلى القناة بـspan: 'side' ويتكدّس تحت العنوان الجانبي للقسم 2 (التموضع). يجعل width: PLAN_W / SIDE عرضه 44 mm، فتصير أمتاره الثمانية والثمانون بمقياس 1:2000 بالضبط. واجهة المبنى عنصر عائم 'top' على عرض الصفحة. يُستشهد بها في الصفحة 2 وتفتتح الصفحة 3، لأن العنصر العائم لا يوضع أبدًا فوق الإحالة إليه. جدول البرنامج، المستشهَد به في الصفحة 2 أيضًا، يطفو إلى رأس عمود النص في الصفحة 3، تحت الواجهة. ويُقيم captionSide: true تعليقه في القناة، على مستوى أعلى الجدول. أما جدول المواعيد فيقع حيث يضعه ::resource، في نهاية الكرّاسة، ويُقيم captionSide: true تعليقه في القناة كذلك، بجوار البند 6.3. يرسم خط Mona Sans أرقامًا تناسبية افتراضيًا، فلا تقع أرقام 120 و560 بعضها تحت بعض في عمود محاذى إلى اليمين. ويفعّل نمط جدول مسمّى، tableStyles: [{ id: 'figures', figureStyle: 'tabular' }]، يختاره الجدول 1 بـstyleId: 'figures'، ميزة tnum في الخط: أرقامه الجدولية بصفر مشطوب، قريبة من الأرقام بخط DM Mono. أما تواريخ الجدول الزمني فتبقى بأرقام الخط نفسه (أنماط الأرقام).
#5 · افتتح الكرّاسة بمخطط الموقع
const MAP = { y: 68.5, w: CONTENT, h: 52 }; // mm: from the top of the text block
const display = { fontFamily: DISPLAY, fontWeight: 300, color: col('ink'), align: 'left',
overflow: 'wrap' };
const opener = { enabled: true,
// The plan's foot falls between two grid lines. A floor on the next one leaves the rule
// of section 1 as far from its text as the rule of every later section.
minHeight: mm(GRID * Math.ceil((MAP.y + MAP.h) / GRID)),
slot: { elements: [
{ kind: 'text', id: 'kicker', content: '{attr.kicker}', ...label, color: col('signal'),
placement: at('container', 'top-left', mm(HANG)) },
{ kind: 'text', id: 'series', content: '{subtitle}', ...label,
placement: { ...at('container', 'top-left'), size: { width: mm(SIDE) } } },
{ kind: 'text', id: 'title', content: '{titleText}', ...display, fontSize: pt(58),
lineHeight: 0.96, placement: { ...at('#kicker', 'below', mm(0), mm(4.5)),
size: { width: mm(MAIN) } } },
{ kind: 'text', id: 'lead', content: '{attr.lead}', ...display, italic: true,
fontSize: pt(14), lineHeight: 1.3, placement: { ...at('#title', 'below', mm(0), mm(5)),
size: { width: mm(MAIN) } } },
{ kind: 'text', id: 'legend', content: '{attr.map}', fontFamily: TEXT, fontSize: pt(7.5),
lineHeight: 1.4, color: col('muted'), align: 'left', overflow: 'wrap',
placement: { ...at('#lead', 'align-top', mm(-HANG), pt(2)),
size: { width: mm(SIDE - 6) } } },
{ kind: 'image', id: 'map', resourceId: 'situacion', // across the channel and the column
placement: { ...at('container', 'top-left', mm(0), mm(MAP.y)),
size: { width: mm(MAP.w) } } },
] } };
مع span: 'page' يصير حاوي تصميم الافتتاح كتلة النص كلها، بما فيها القناة (الامتداد والتصميم المتقدم). يوضع العنوان التمهيدي والعنوان على بعد 57 mm إلى الداخل، عند الحافة اليسرى لعمود النص، ويمتد المخطط على القناة والعمود. من دونه يكون الحاوي عمود النص، فينتقل كل عنصر 57 mm إلى اليمين، ويتجاوز العنوان والمقدمة والمخطط الحافة اليمنى للصفحة. يحجز التصميم مساحة حتى أسفل المخطط، وهو يقع بين خطين من الشبكة. وقيمة minHeight المقرَّبة صعودًا إلى الخط التالي تُبقي خط القسم 1 بعيدًا عن نصه بقدر بُعد خط كل قسم لاحق. والعنوان التمهيدي والمقدمة ومفتاح الخريطة سمات في سطر # Competition brief.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 045 · Side heads, hanging numbers and run-in heads ═══════
// https://postext.dev/en/cookbook/side-heads-hanging-numbers
// Code: MIT · Text: original (CC BY 4.0) · Drawings: made in code (MIT)
// Fonts: Mona Sans, Noto Serif Display, DM Mono (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, defaultResourceTypes,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'side-heads-hanging-numbers';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { // a Swiss municipal report: black, white and one signal red
ink: '#17171a', // text and rules
signal: '#d42a1f', // section numbers, run-in heads, the plot on the plans (5.1:1)
tint: '#f9dcd7', // the plot's ground on the plans
sea: '#d8e2e8', // water on the plans
stone: '#cacad0', // built ground on the plans
rule: '#c3c3ca', // hairlines under the running head and in tables
muted: '#5e5e67', // running heads, legends, the colophon (6.4:1)
paper: '#ffffff',
};
// Every colour is linked to its palette entry by id.
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.signal })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [TEXT, DISPLAY, LABEL] = ['Mona Sans', 'Noto Serif Display', 'DM Mono'];
const TRIM = { width: 210, height: 297 }; // mm: A4, like every document of the competition
const [TOP, LEFT, RIGHT] = [26, 16, 16]; // mm; not mirrored: the brief prints one-sided
const LEAD = 14; // pt: the body leading, the pitch of the baseline grid
const LINES = 50; // grid lines in the text block
const PT = 25.4 / 72; // mm in a point
const GRID = LEAD * PT; // mm: one line of the grid
const CONTENT = TRIM.width - LEFT - RIGHT; // 178 mm
const [SIDE, GUTTER] = [50, 7]; // mm: the margin channel on the left, and the gap after it
const MAIN = CONTENT - SIDE - GUTTER; // 121 mm: the text column
const HANG = SIDE + GUTTER; // mm from the channel's left edge to the text's left edge
const at = (to, edge, x = mm(0), y = mm(0)) => ({ anchor: { to, edge }, offset: { x, y } });
// Kickers, running heads and folios: tracked capitals in the mono.
const LABEL_PT = 7.5;
const label = { fontFamily: LABEL, fontWeight: 500, fontSize: pt(LABEL_PT), lineHeight: 1.35,
letterSpacing: pt(1.2), textTransform: 'uppercase', color: col('muted'), align: 'left' };
// #region channel: one text column, and on its left a channel for boxes and figures only
const layout = {
layoutType: 'oneAndHalf',
sideColumnPercent: (SIDE / CONTENT) * 100, // 50 of the 178 mm between the margins
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#خطّ عمود النص وحده
اربط الخط بمستطيل العنوان نفسه بدل الرقم، فيمتد من الحافة اليسرى للنص إلى الحافة اليمنى للعمود، ولا يبقى في القناة إلا الرقم والعنوان.
- color: col('ink'), placement: { ...at('#number', 'right-of', mm(2), RULE_Y),
+ color: col('ink'), placement: { ...at('container', 'top-left', mm(0), RULE_Y),أخطاء شائعة
خطأ شائع
يبدأ الإطار الجانبي بمحاذاة الكتلة التي تلي سياجه
في postext 1.4.1 يقف الإطار span: 'side' في العمود الجانبي على الارتفاع الذي بلغه النص عند سياجه، على سطر الشبكة التالي، وتحت أي إطار موجود هناك. ضع سياج الحاشية الجانبية قبل الفقرة التي تشرحها مباشرةً: إذا وضعته بعدها، بدأت الحاشية بجانب الفقرة التالية. والإطار الذي يتجاوز أسفل العمود ينزلق صعودًا حتى يستقر أسفله على أسفل العمود، بقدر ما يسمح الإطار الذي فوقه؛ وما لا يتسع بعد ذلك ينتظر العمود الجانبي في الصفحة التالية. ملاحظات الهامش →
خطأ شائع
العنصر العائم 'top' يذهب إلى الصفحة التالية لإحالته ما لم يُسمح له بتصدر صفحة الإحالة
افتراضيًا لا يصعد العنصر العائم أبدًا فوق الإحالة إليه، فالعنصر العائم 'top' الممتد بعرض الصفحة والمُحال إليه في الصفحة N يفتتح الصفحة N+1. اضبط placement.citingPage: true على المورد أو على defaultPlacement لنوعه (أو layout.floatsAtCitingPage للكتاب كله، منذ postext 1.25) فيتصدر الصفحة N بدلًا من ذلك، وينزل النص الذي فوق الإحالة تحته، إذا اتسع له المكان في حدود layout.maxTopFraction وبقي سطر الإحالة في تلك الصفحة. ولا يتصدر أبدًا الصفحة الأولى من فصل ولا صفحة بعد فاصل قسري: فهناك يظل يفتتح الصفحة التالية، ويمكن للموضع 'auto' أو 'bottom' أن يشغل أسفل صفحة الإحالة. موضع الأشكال →
فحص Sandbox · headingAdvancedWithoutTitleText
نص العنوان لا يُطبع
السبب. تصميم متقدم ليس فيه عنصر يطبع {titleText}، فلا تظهر كلمات العنوان نفسه أبدًا.
الحل. أضف عنصرًا نصيًّا فيه {titleText}، إلا إذا كان العنوان مقصودًا أن يكون غير مرئي. التوثيق →
- الشكل الجانبي يأخذ رأس القناة في الصفحة التي تستشهد به، والعنوان الجانبي المكتوب بعده يتكدّس تحت الشكل، أدنى من بداية قسمه. استشهد بالأشكال الجانبية بعد عنوان القسم في صفحتها، كما يستشهد القسم 2 بمخطط قطعة الأرض.
- المُدرَج في موضعه (
position: 'here') يقبلcaptionSideمنذ postext 1.28: يقف تعليق جدول المواعيد في القناة في الصفحة 5، كما يقف تعليق جدول البرنامج في الصفحة 3. ويحتاج التعليق إلى أن تكون القناة خالية بجوار الجدول. وحيث يقف عنوان جانبي أو شكل جانبي يبقى التعليق تحت الجدول.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- نص أصلي, CC BY 4.0
- الخطوط
- Mona Sans (SIL OFL 1.1) · Noto Serif Display (SIL OFL 1.1) · DM Mono (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


