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

دليل الوصفات · الفصل 9 · منشورات كاملة

تقرير سنوي بأعمدة تنتهي على سطر واحد

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

في هذه الصفحة
  • نموذج باللغة الإنجليزية: لا توجد طبعة عربية بعد
  • مقاس القص 210 × 280 مم
  • عمودان, فاصل 7 مم بين الأعمدة
  • Brygada 1918 9.4/13.4
  • Epilogue
  • Spline Sans Mono
  • 5 صفحات
  • المستوى
  • Postext 1.65.0
  • أُخرجت في 169 ms
  • أسطر الشيفرة: 250

باختصار

التقرير السنوي لجمعية صغيرة للطاقة يملكها أهل المنطقة، في عمودين. يبيّن كيف تجعل عمودي النص ينتهيان على الارتفاع نفسه تمامًا.

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

التقرير السنوي لعام 2025 لتعاونية Tidewell Community Energy، وهي تعاونية متخيَّلة تملك توربيني رياح وحقلًا شمسيًا وألواحًا على 21 سطحًا. خمس صفحات بقياس 210 × 280 مم. على الغلاف يجري إنتاج العام من الرياح والشمس شريطين تحت «2025» بحجم 150 pt. تليه رسالة رئيسة المجلس وتقرير التشغيل وحسابات أمينة الصندوق في عمودين مضبوطين بخط Brygada 1918 على شبكة من 50 سطرًا. الأعمدة الممتلئة تنتهي على آخر سطر في الشبكة، والقصيرة تنتهي على مستوى جاراتها. إطار من ثلاثة أرقام رئيسية يعبر صفحة الرئيسة والرسالة مقطوعة فوقه على مستوى واحد، وملاحظة عن العدّادات تطفو إلى رأس الصفحة 4. وفي الصفحة الختامية يتوقف العمودان على سطر واحد فوق قائمة الدخل. وسمة لوحة ألوان تحوّل صفحات التشغيل إلى الأخضر المزرق وصفحة المالية إلى أحمر الطوب.

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

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

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

script.js · الأسطر 41–58في الشيفرة الكاملة
// The text block is LINES lines of LEAD deep (MARGIN.bottom is derived from them) and every
// heading takes whole lines, so a column the break rules leave short is short by whole lines.
// Balancing (on by default) stretches it back to its foot with its levers, in this order: a
// box that closes the column moves down to it; a picture with a safe area grows; lines above
// the headings, two each at most (maxLinesBeforeLoose); one line where a list ends; one under
// a display formula or a box, then under a float at the column head; a paragraph set one line
// longer and looser, with up to maxTracking of tracking; last, the lines a heading may still
// take, up to maxLinesPerHeading. A closing band whose columns differ by more than a line is
// cut level instead (trailing), and so is the band a page-wide box leaves when it has to move
// on to the next page (beforeSpan).
const balancing = { maxLinesPerHeading: 1 }; // one line per heading; the next lever takes more
const flowText = { // justification, hyphenation and Knuth–Plass stay at their defaults (on)
  fontFamily: 'Brygada 1918', fontSize: pt(9.4), lineHeight: pt(LEAD),
  firstLineIndent: mm(4), indentAfterHeading: false,
  minWordSpacing: 0.7, maxWordSpacing: 1.8, // word spaces 0.7–1.8 of normal (defaults 0.6–2)
};
const onGrid = { lineHeight: pt(LEAD), marginTop: pt(LEAD), marginBottom: pt(0) }; // one line
// hook-up: headings: { balancing, levels: [..., { level: 2, ...onGrid }] }, bodyText: flowText

المكونات

الخطوط
Brygada 1918, Epilogue, Spline Sans Mono, Mrs Saint Delafield (SIL OFL 1.1)
الأصول
لا شيء: كل صورة مرسومة بالشيفرة

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

#1 · أبقِ كل سطر على الشبكة ودع الأدوات تسدّ الفجوات

الشيفرة في الجواب المختصر أعلاه. كتلة النص 50 سطرًا بالضبط، ارتفاع كل منها 13.4 pt، والهامش السفلي (21.6 مم) مشتق من هذا العمق. العنوان الفرعي الداخلي يأخذ سطرًا من الشبكة فوقه وسطرًا لنفسه، فالعمود الذي ينتهي قصيرًا يقصر بأسطر كاملة، والأسطر الكاملة هي ما تضيفه موازنة الأعمدة. في الصفحة 3 تنتقل فقرة البَرَد ذات الأسطر الثلاثة كاملة إلى الصفحة 4 بحكم avoidOrphans، وهو اسم القاعدة في Postext التي تمنع السطر الأخير من الفقرة من الوقوف وحده في رأس عمود، فينتهي العمود الأيمن قصيرًا بسطرين. يخصّص maxLinesPerHeading: 1 أحد هذين السطرين للمسافة فوق The Saltings and the roofs ويترك الآخر للأداة التالية، فتضيفه بعد قائمة الأسطح. وفي الوضع الافتراضي يأخذ العنوان سطرين على الأكثر قبل تجربة الأدوات التي تليه (maxLinesBeforeLoose)، وحتى أربعة أسطر حين لا يبقى لديها ما تعطيه، فيذهب السطران كلاهما فوق العنوان.

#2 · اقطع النص على مستوى واحد فوق إطار يعبر الصفحة

script.js · الأسطر 101–109في الشيفرة الكاملة
// In the Markdown: :::callout{type="figures" span="page"} around :::columns{count=3 breaks="3,5"},
// each number a :::paragraphs{style="figure"} of **8.47 GWh**, then its line of text.
const figures = { id: 'figures', background: col('ink'), columnGap: mm(GUTTER),
  padding: { top: mm(5), right: mm(5), bottom: mm(5), left: mm(5) },
  marginTop: pt(LEAD), marginBottom: pt(LEAD), titleStyle: { ...boxTitle, color: col('sun') },
  body: { fontFamily: 'Epilogue', fontSize: pt(9), lineHeight: pt(12), color: col('paper'),
    ...boxText } };
const bigNumber = { id: 'figure', fontFamily: 'Epilogue', fontSize: pt(26), lineHeight: pt(31),
  color: col('paper'), boldColor: col('sun'), ...boxText };

الإطار الذي له span="page" يقسم الصفحة ذات العمودين إلى أشرطة. في الصفحة 2 تتوقف رسالة الرئيسة عند ثمانية أسطر في كل عمود فوق الإطار، وتكمل في العمودين تحته. داخل الإطار، يفتح :::columns{count=3 breaks="3,5"} العمودين الثاني والثالث عند الرقمين الثاني والثالث (الكتلتين الثالثة والخامسة في المجموعة) بدل أن يقطع المجرى حيث تتساوى الأعمدة أفضل تساوٍ. ونمط الفقرة figure يضبط هذه الأرقام بحجم 26 pt، ويطبعها boldColor الخاص به بالأصفر.

#3 · عوّم إطارًا إلى رأس الصفحة التالية

script.js · الأسطر 113–122في الشيفرة الكاملة
// In the Markdown: :::callout{type="aside" span="page" placement="top"}. It leaves the flow
// where it stands and takes the head of the next page the flow opens; the text goes on
// filling this one. It has a stripe in the section's colour and no fill. The padding under
// the text drops the floats below the box by a grid line, so they stand clear of it.
const aside = { id: 'aside', backgroundEnabled: false, columnGap: mm(GUTTER),
  stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('band') },
  padding: { top: mm(3.5), right: pt(0), bottom: mm(3.5), left: pt(0) },
  titleStyle: { ...boxTitle, color: col('band') },
  body: { fontFamily: 'Epilogue', fontSize: pt(8.6), lineHeight: pt(12.2), color: col('ink'),
    ...boxText } };

في Markdown تأتي الملاحظة عن العدّادات بعد الفقرة الأولى عن Harrow Down، في الصفحة 3؛ ويخرجها placement="top" من المجرى ويضعها في رأس الصفحة التالية. يملأ التقرير بقية الصفحة 3، وتنفتح الصفحة 4 بالإطار عبر العمودين. وتحته يتصدر جدول المواقع والمخطط الحلقي، وكلاهما position: 'top'، عمودًا لكل منهما، أدنى بسطر من الشبكة مما لو لم تكن للإطار حشوة سفلية قدرها 3.5 مم.

#4 · أعطِ كل قسم لونه دون صفحة فاصلة

script.js · الأسطر 14–27في الشيفرة الكاملة
const palette = {
  ink: '#14202b', // text: a blue-black
  band: '#0b5d7a', // sea, overridden by palette="band=#…" on the :::part fences
  wind: '#3aa6a0', sun: '#f2b134', coral: '#e2674b', // the data colours of the charts
  tint: '#eef3f5', // subtotal rows
  rule: '#c9d3d9', // hairlines
  muted: '#566370', // captions' notes and the running feet
  mist: '#9fb1bd', // small print on the ink cover
  paper: '#ffffff',
};
// Every colour is linked to its palette entry, so a :::part recolours it by paletteId.
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' } }));

مع parts: { page: false } لا تفتح كتلة مثل :::part{number="02" title="Operations" palette="band=#1c6e67"} صفحة جديدة، بل تحدّد اسم القسم لشريط الافتتاح ولتذييلات الصفحات، وتبدّل band في كل صفحة حتى الجزء التالي. الأشرطة والعناوين الفرعية الداخلية والنقاط وتسميات التعليقات وخط الإطار الجانبي كلها تأخذ band، فتُطبع صفحات التشغيل بالأخضر المزرق وصفحة المالية بأحمر الطوب، بينما تحتفظ رسالة الرئيسة بأزرق البحر الأساسي (ألوان لكل جزء).

#5 · ابنِ الجداول من البيانات، واختم الصفحة الأخيرة على مستوى واحد

script.js · الأسطر 170–219في الشيفرة الكاملة
const DATA = {
  // Output in MWh at the export meter, January to December 2025.
  wind: [560, 520, 450, 330, 270, 210, 190, 150, 300, 420, 480, 540], // Harrow Down
  sun: [90, 160, 300, 440, 560, 600, 580, 500, 380, 250, 120, 70], // the Saltings + 21 roofs
  // The turbines' year, % of the hours of both machines: [label, share, palette colour].
  hours: [['generating', 78.0, 'wind'], ['waiting for wind', 16.8, 'rule'], ['bearing repair', 2.6,
    'coral'], ['servicing and grid', 1.8, 'sun'], ['stopped for bats', 0.8, 'ink']],
  // Output by site in MWh: [site, source, capacity in MW, 2025, 2024].
  sites: [['Harrow Down', 'wind', 1.8, 4420, 4560], ['The Saltings', 'solar', 3.2, 3190, 2640],
    ['21 roofs', 'solar', 0.9, 860, 790]],
  // £ thousand, [label, 2025, 2024]; a label alone opens a group, '=' prints the running sum.
  accounts: [['Income'], ['Electricity sold under the power purchase agreement', 760, 722],
    ['Electricity sold to roof hosts', 92, 85], ['Feed-in tariff', 236, 229], ['=Total income'],
    ['Operating costs'], ['Operation and maintenance', -231, -198],
    ['Rent, rates and insurance', -158, -151], ['Staff and administration', -121, -112],
    ['Depreciation', -286, -286], ['=Operating surplus'],
    ['Interest on the Harrow Down loan', -54, -66], ['Interest on members’ shares at 3.5%', -113,
      -107], ['Grants to the Tidewell Fund', -84, -70], ['Corporation tax', -5, -7],
    ['=Surplus for the year']],
};
const fill = { background: col('tint') }; // totals sit on a tint between two hairlines
const right = (content, extra) => ({ content, align: 'right', ...extra });
const figure = (n, digits = 0) => n.toLocaleString('en-GB', { minimumFractionDigits: digits });
const head = (c, i) => (i ? right(c, { isHeader: true }) : { content: c, isHeader: true });
const siteTable = (rows) => ({ headerRowCount: 1, columnWidths: [3, 1, 1.3, 1.3], rows: [
  ['Site', 'MW', '2025', '2024'].map(head),
  ...rows.map(([site, source, mw, ...n]) => [{ content: `${site} *(${source})*` },
    right(figure(mw, 1)), ...n.map((v) => right(figure(v)))]),
  [{ content: '**All sites**', ...fill }, ...[2, 3, 4].map((i, k) => right(`**${figure(rows
    .reduce((sum, row) => sum + row[i], 0), k ? 0 : 1)}**`, fill))]] }); // the totals, summed
// Accounting style: losses in brackets, and gains followed by a no-break space, as wide as a
// bracket in a monospaced face, so the digits line up.
const pad = '\u00a0';
const money = (n) => (n < 0 ? `(${figure(-n)})` : `${figure(n)}${pad}`);
function statement(rows) {
  const sum = [0, 0];
  const cells = [['£ thousand', `2025${pad}`, `2024${pad}`].map(head)];
  for (const [label, ...years] of rows) {
    years.forEach((n, i) => { sum[i] += n; });
    const sub = label.startsWith('='); // a subtotal: the running sum, in bold
    cells.push(sub ? [{ content: `**${label.slice(1)}**`, ...fill },
      ...sum.map((n) => right(`**${money(n)}**`, fill))]
      : [{ content: years.length ? label : `*${label}*` }, // a label alone heads a group
        ...[0, 1].map((i) => right(years.length ? money(years[i]) : ''))]);
  }
  // mergeCells writes the cells a spanning group head hides (gotcha: merged-cells-hiddenby)
  return cells.reduce((model, row, r) => (r && !row[1].content ? mergeCells(model,
    { start: { row: r, col: 0 }, end: { row: r, col: 2 } }) : model),
  { rows: cells, headerRowCount: 1, columnWidths: [5, 1, 1] });
}

تحوّل statement() البيانات DATA.accounts إلى قائمة الدخل صفًا صفًا. التسمية التي تبدأ بـ= تطبع المجموع الجاري لكل سنة بالخط العريض على الخلفية الفاتحة؛ والتكاليف سالبة في البيانات، فيخرج Operating surplus من ذلك المجموع دون أن يُكتب أي إجمالي باليد. والتسمية التي لا أرقام معها، Income أو Operating costs، تصير خلية واحدة مائلة بعرض الجدول، مدموجة بـmergeCells، التي تكتب أيضًا الخلايا البديلة التي يحتاجها الدمج. في الصفحة 5 تطفو القائمة عبر أسفل الصفحة، تحت تقرير أمينة الصندوق الذي يختم المستند. لولا الموازنة لبلغ العمود الأيسر 12 سطرًا والأيمن 9؛ والقطع الختامي يجعل كليهما 11، وتضيف أداة العناوين السطر الذي ما زال العمود الأيمن ينقصه فوق Cash and reserves.

الوصفة كاملة

Sandbox
// ═══ Postext Cookbook · Nº 037 · Annual report with flush columns ═══════════════════════
// https://postext.dev/en/cookbook/annual-report-flush-columns
// Code: MIT · Text: original (CC BY 4.0) · Art: drawn in code · Typefaces: SIL OFL 1.1
// Fonts: Brygada 1918, Epilogue, Spline Sans Mono, Mrs Saint Delafield · Needs postext ≥ 1.28.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, mergeCells, inlineSvgFonts,
} from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'annual-report-flush-columns';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: 'band' is the first section's colour; each later :::part brings its own
const palette = {
  ink: '#14202b', // text: a blue-black
  band: '#0b5d7a', // sea, overridden by palette="band=#…" on the :::part fences
  wind: '#3aa6a0', sun: '#f2b134', coral: '#e2674b', // the data colours of the charts
  tint: '#eef3f5', // subtotal rows
  rule: '#c9d3d9', // hairlines
  muted: '#566370', // captions' notes and the running feet
  mist: '#9fb1bd', // small print on the ink cover
  paper: '#ffffff',
};
// Every colour is linked to its palette entry, so a :::part recolours it by paletteId.
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' } }));
// #endregion
const TRIM = { width: 210, height: 280 };
const LEAD = 13.4; // body leading in pt: one line of the baseline grid
const LINES = 50; // grid lines in a full column
const MARGIN = { top: 22, inner: 18, outer: 16 }; // mm, mirrored
MARGIN.bottom = TRIM.height - MARGIN.top - (LINES * LEAD * 25.4) / 72; // 21.6 mm: 50 lines exactly
const GUTTER = 7; // mm between the columns, and between the columns inside the boxes
const mono = { fontFamily: 'Spline Sans Mono', fontWeight: 500, textTransform: 'uppercase' };
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, placement,
  align: 'left', ...look });

// #region answer: flush columns: whole grid lines everywhere, and the balancing levers
// The text block is LINES lines of LEAD deep (MARGIN.bottom is derived from them) and every
// heading takes whole lines, so a column the break rules leave short is short by whole lines.
// Balancing (on by default) stretches it back to its foot with its levers, in this order: a
// box that closes the column moves down to it; a picture with a safe area grows; lines above
// the headings, two each at most (maxLinesBeforeLoose); one line where a list ends; one under
// a display formula or a box, then under a float at the column head; a paragraph set one line
// longer and looser, with up to maxTracking of tracking; last, the lines a heading may still
// take, up to maxLinesPerHeading. A closing band whose columns differ by more than a line is

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

تنويعات

#دع العناوين تأخذ الفجوة كلها

يذهب عندئذ السطران الفارغان في الصفحة 3 كلاهما فوق The Saltings and the roofs، ولا يذهب شيء بعد القائمة.

-const balancing = { maxLinesPerHeading: 1 }; // one line per heading; the next lever takes more
+const balancing = {}; // the default: two lines above a heading, then the other levers

#أوقف الموازنة

ينتهي العمود الأيمن في الصفحة 3 عندئذ قصيرًا بسطرين. وفي الصفحة 5 يبلغ العمود الأيسر 12 سطرًا والأيمن 9، وتبدأ القائمة أدنى بسطر.

-const balancing = { maxLinesPerHeading: 1 }; // one line per heading; the next lever takes more
+const balancing = { enabled: false };

أخطاء شائعة

خطأ شائع

avoidWidows يحرس أسفل العمود، وavoidOrphans أعلاه

يسمّي Postext السطرين المنفردين على طريقته: avoidWidows (widowMinLines وwidowPenalty) يمنع السطر الأول من الفقرة من أن يقف وحده في أسفل العمود، وavoidOrphans (orphanMinLines وorphanPenalty) يمنع سطرها الأخير من أن يقف وحده في أعلى العمود التالي. كثير من أدلة الأسلوب تعطي الاسمين بالعكس، فاختر الإعداد بحسب الموضع الذي يعمل فيه. كلاهما مفعَّل افتراضيًا، إلا على شبكة المحارف (cjk.grid): فهناك يكون avoidWidows معطَّلًا، وكذلك avoidOrphans في منطقة اليابان، كي تحمل الصفحة الأسطر التي تعدّها شبكتها (منذ postext 1.28). ويعمل كلٌّ منهما عقوبةً: يوازن الإخراج كلًّا منهما بالأسطر الفارغة التي يتركها الالتزام به. الأسطر الأرامل والأسطر اليتيمة والكلمات المعزولة →

خطأ شائع

الخلايا المدمجة تحتاج إلى خلايا نائبة hiddenBy: استخدم mergeCells

تُوزَّع الخلايا بحسب موضعها في مصفوفة الصف، فالخلية المدمجة تحتاج إلى خلايا نائبة معلَّمة بـ hiddenBy حيث تمتد؛ وحذفها، كما يفعل HTML، يزيح كل الأعمدة التالية. ابنِ الدمج بـ mergeCells. ومنذ postext 1.5 يُبلَّغ عن الجدول غير المنتظم الشبكة في doc.contentWarnings تحت raggedTableGrid، ويعلّم parseTSV(text, { headerRows }) صفوف الترويسة. جداول من البيانات →

  • إذا اختلف عمودا الصفحة الختامية بسطر واحد بقيا على حالهما، والعمود الأيسر أطول بسطر، كما كان المنضّد سينضّدهما؛ فالقطع الختامي لا يعمل إلا على فرق من سطرين أو أكثر. لتنهي العمودين معًا، أطِل النص أو قصّره بسطر.
  • تضع قائمة الدخل التكاليف بين قوسين. لمحاذاة الأرقام الموجبة معها، ينهي مثال CodePen كل رقم موجب بمسافة غير قابلة للكسر، وعرضها في الخط الثابت العرض كعرض قوس الإغلاق؛ وتحتفظ خلية الجدول بهذه المسافة في آخر نصها.

الحقوق

الوصفة
Ignacio Ferro
النص
نص أصلي, CC BY 4.0
الخطوط
Brygada 1918 (SIL OFL 1.1) · Epilogue (SIL OFL 1.1) · Spline Sans Mono (SIL OFL 1.1) · Mrs Saint Delafield (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
Sandbox