باختصار
ورقة عمل مدرسية في العلوم عن صنع ساعة شمسية. تعرض إطارات تنقسم بين عمودين، أو تنتقل إلى أعلى الصفحة التالية، أو تبقى ثابتة في أسفل الصفحة.
ما الذي ستنضده
أربع صفحات من Taller de ciencias، كرّاسة مختبر مدرسية إسبانية: Práctica 4، «Construye un reloj de sol» (اصنع ساعة شمسية). في الصفحة 42 يبقى تحذير السلامة قطعة واحدة، أما الخطوات الأربع عشرة، على تعبئة صفراء وفي زاويتها شارة بوصلة، فتبدأ في أسفل العمود الأيسر وتتواصل في رأس العمود الأيمن، بالعرض نفسه وبلا عنوانها. وتغادر ورقة بيانات مدريد التدفق في تلك الصفحة وتتصدّر الصفحة 43 فوق النص. وتُثبَّت شارة رمادية فحمية «Autoevaluación · 10 min» في أسفل الصفحة الأخيرة، وبجوارها يد مشيرة في الهامش. وفي صفحة الافتتاح شريط بلون أصفر الشمس عليه رسم لظلال عصا من الظهر إلى الخامسة مساءً على خط عرض مدريد، ويسرد إطار المواد في ثلاثة أعمدة عبر الصفحة.
تجيب هذه الوصفة عن
- كيف أسمح لإطار طويل بأن ينقسم عبر الأعمدة والصفحات، أو أبقي إطارًا قصيرًا متماسكًا؟
- كيف أجعل إطارًا يطفو إلى أعلى الصفحة أو أسفلها بينما يواصل النص تدفقه؟
- كيف أثبّت شارة أو ملصقًا في موضع ثابت من الصفحة؟
- كيف أنضد إطارًا بعرض العمودين في منتصف الصفحة، مثل لوحة «بالأرقام» من ثلاث خانات؟
الجواب المختصر
const HAND = 6, GAP = 2, RULE = 0.75 * PT; // mm: the badge's hand, its gap, the hand's rule
const calloutStyles = [
// Kept whole: keepTogether defaults to true, so a box that does not fit the rest of a
// column moves on in one piece; only a box taller than a whole column splits anyway.
box('seguridad', bar('charcoal', 'aviso')),
// Split: the procedure fits a column, so it takes keepTogether: false to break where it
// falls instead of moving on whole: between steps, or inside one (splitMinLines, default
// 2, keeps at least two lines of the step on each side of the cut). The rest goes on in
// the next column or page without the title or the icon; a corner icon takes no room
// from the text, where an inline one would keep its column in both parts.
box('pasos', { keepTogether: false, background: col('light'),
icon: icon('compas', 7, { position: 'corner', cornerSide: 'outer' }) }),
// Floated: its fence adds placement="top", so the box leaves the flow where the fence
// stands and heads the next page, while the text after it fills this one.
box('datos', { span: 'page', background: col('tint') }),
// Pinned: 'fixed' sets the box on the page where its fence falls, at the bottom-left corner
// of the text block unless fixed.anchor says otherwise, and the column text keeps out of it.
// width: 'auto' shrink-wraps the title, so an empty fence prints a badge.
box('autoevaluacion', { placement: 'fixed', width: 'auto',
// Hang the hand and its rule in the margin (the outer one on this verso), so the badge
// itself lines up with the text: [hand][rule][GAP][badge].
fixed: { offset: { x: mm(-(HAND + RULE + GAP)) } },
marker: { ...icon('mano', HAND), gap: mm(GAP),
rule: { enabled: true, color: col('charcoal'), width: mm(RULE) } },
background: col('charcoal'), borderRadius: mm(3.2),
padding: { top: mm(1.6), right: mm(3.4), bottom: mm(1.6), left: mm(3.4) },
titleStyle: { ...TITLE, color: col('paper') } }),
// Across the page, in the flow: the text above it is cut level and resumes under it.
box('resumen', { span: 'page', backgroundEnabled: false,
stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('charcoal') } }),
];
المكونات
- الميزات
- إطارات تنقسم أو تبقى كاملةإطارات عائمةإطارات وشارات مثبّتةعمود العلامة بجانب الإطارإطارات بعرض الصفحةأعمدة داخل الإطار أو النصأيقونات الإطارات وشارات الزواياإطارات التنبيهمسافة عمودية صريحةاستشهادات تضع الأشكالموضع الأشكالموازنة الأعمدةجداول من البياناتأنماط الجداول المسمّاة«شكل» و«جدول» بلغتكالعناوين المرقّمةصفحات افتتاح مصمَّمةسمات العنوانالترويسات وأرقام الصفحاتالتحذيرات والتشخيص
- تستخدم أيضًا
- أشكال في هذا الموضع بالضبطشريط فصل بعرض الصفحةالترويسات بحسب دور الصفحةأنماط الفقراتالأشكال والجداول بوصفها موارد
- الخطوط
- Host Grotesk, Commit Mono (SIL OFL 1.1)
- الأصول
- The shadow chart, the dial in profile and the icons, drawn in code in the page's palette (Ignacio Ferro, CC BY 4.0)
طريقة التحضير
#1 · نمط أساسي واحد لكل الإطارات
const TITLE = { fontFamily: LABEL, fontSize: pt(8), color: col('charcoal'),
textTransform: 'uppercase', letterSpacing: pt(1.2) }; // bold by default
const BOX_TYPE = { fontSize: pt(8.8), lineHeight: pt(12.4) }; // colours inherit bodyText
const box = (id, device) => ({ id, // margins: the defaults, snapped to whole grid lines
padding: { top: mm(3), right: mm(3.6), bottom: mm(3.4), left: mm(3.6) },
titleStyle: { ...TITLE, gap: mm(2) }, body: BOX_TYPE,
lists: { gap: mm(2), itemSpacing: pt(3) }, ...device });
const icon = (id, size, extra) => ({ kind: 'resource', resourceId: id, size: mm(size),
...extra });
// A side bar with its icon centred on it, 1.4 mm narrower than the bar.
const bar = (hue, id, width = 5.6) => ({ backgroundEnabled: false,
stripe: { enabled: true, side: 'left', width: mm(width), color: col(hue) },
icon: icon(id, width - 1.4) });
كل نمط يبدأ من box(): العنوان بخط أحادي المسافة، وحروف بحجم 8.8 نقطة مقابل 9.4 نقطة للنص، والحشو. ثم يضيف كلٌّ منها أداة واحدة: شريط رمادي فحمي لتحذير السلامة، وتعبئة صفراء للخطوات، ولون ورقي لورقة البيانات، وخط علوي للملخّص، وكبسولة رمادية فحمية للشارة. يميّز الطالب الإطارات بتلك الأداة قبل أن يقرأ عنوانًا. وفي إطار الخطوات تدل التعبئة أيضًا على التواصل: الجزء الذي في رأس العمود الأيمن بلا عنوان، فلا يربطه بالخطوات من 1 إلى 4 في أسفل العمود الأيسر إلا الأصفر.
#2 · أبقِ، اقسم، عوّم، ثبّت
الشيفرة هي الجواب المختصر أعلاه. يبلغ ارتفاع إطار الخطوات 192 مم ويتسع العمود لـ211، فلو أُبقي الإطار كاملًا لقفز إلى رأس العمود الأيمن وترك 43 مم فارغة في أسفل الأيسر. يتركه keepTogether: false يبدأ حيث يقع ويتواصل في العمود التالي، أو في الصفحة التالية كما يُظهر التنويع الثاني (الحاوية :::callout). الجزء المتواصل يُسقط العنوان والأيقونة. والأيقونة ضمن السطر كانت ستأخذ من الخطوات عمودًا خاصًا بها في الجزأين، لذا تجلس البوصلة على الزاوية الخارجية للإطار، حيث لا تأخذ عرضًا. في سطر فتح ورقة البيانات placement="top"، فيغادر الإطار التدفق في الصفحة 42 ويتصدّر الصفحة التالية. والشارة fixed، وقيمة سالبة لـoffset.x تنقل اليد وخطها إلى الهامش الخارجي، فتحاذي الحافة اليسرى للشارة النص.
#3 · اعبر الصفحة بلوحة من ثلاثة أعمدة
const materials = box('material', { span: 'page', background: col('sun'),
marginBottom: pt(LEAD), // one more grid line of air before the text resumes
padding: { top: mm(3.6), right: mm(4.4), bottom: mm(3.8), left: mm(4.4) },
columnGap: mm(GUTTER), // the page's gutter: the panel's columns sit as far apart as the text's
body: { ...BOX_TYPE, paragraphSpacing: false },
lists: { color: col('ink'), gap: mm(1.8), itemSpacing: pt(1) } });
مع span: 'page' يعبر إطار المواد العمودين. تُقطع المقدمة فوقه بحافة مستوية، ويستأنف النص في عمودين تحته (الصفحة 41). وداخل الكتلة يحدد :::columns{count=3 breaks="5,9"} أين يبدأ كل عمود بدل موازنة الأعمدة. يعدّ breaks الكتل الفرعية، وكل بند في القائمة كتلة، فيبدأ العمودان الثاني والثالث عند الكتلتين الخامسة والتاسعة، أي التسميات العريضة. وcolumnGap هو فاصل الصفحة البالغ 7 مم، فتتباعد أعمدة الإطار بقدر تباعد أعمدة النص.
:::callout{type="material" title="Necesitarás"}
:::columns{count=3 breaks="5,9"}
**Para la esfera**
- Cartón pluma de 20 × 30 cm
- La plantilla de la esfera
- Pegamento y rotulador
**Para el gnomon y la base**
…
:::
:::#4 · أصفر واحد للمساحات، وأفتح منه للإطار الطويل
const palette = {
ink: '#1b2430', // text
charcoal: '#2b2d42', // the safety bar, the summary's rule, the table head, the badge, titles
sun: '#f2b705', // the opener band and the materials panel: fields, never type
light: '#fad65a', // the procedure
tint: '#fff6d6', // the data sheet
rule: '#d7dde3', // hairlines
muted: '#5d6b78', // running heads, notes
paper: '#ffffff',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// The engine's defaults link to 'main-color': point it at charcoal, so nothing prints blue.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.charcoal })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
يُحفظ أصفر الشمس لمساحات اللون، أي الشريط وإطار المواد، حيث يُقرأ الرمادي الفحمي والحبر بتباين 7.4:1 و8.6:1. أما لونًا للحروف على الأبيض فلن يبلغ إلا 1.8:1، لذا لا تُكتب عليه حروف أبدًا. يأخذ إطار الخطوات light، أصفر أشحب: يُقرأ الحبر عليه بتباين 11:1، ويظل الانقسام ظاهرًا في الصورة المصغّرة في المعرض. وتأخذ ورقة البيانات tint، الأقرب إلى لون الورق، كي لا تُحسب إطار الخطوات، الإطار المعبّأ الآخر في الصفحتين المتقابلتين. ويشير main-color إلى الرمادي الفحمي، فتُطبع القيم الافتراضية التي لا يتجاوزها الإعداد بالرمادي الفحمي بدل أزرق المحرّك.
#5 · افتتح بشريط أصفر
const BAND = 100; // mm from the trim to the foot of the band
const ART_W = 80; // mm: the width of the band's drawing, at the fore-edge
const AIR = 8; // mm between the band and the first line of text
const [TITLE_W, LEAD_W] = [104, 88]; // mm: the title's and the lead's measure
const onBand = { color: col('charcoal'), align: 'left' }; // a long title or lead wraps
const below = (id, y, width) => ({ anchor: { to: `#${id}`, edge: 'below' },
offset: { y: mm(y) }, size: { width: mm(width) } });
const opener = { enabled: true, minHeight: mm(BAND - TOP + AIR), slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('sun') },
placement: { anchor: { to: 'page', edge: 'top-left' }, size: { height: mm(BAND) } } },
{ kind: 'image', id: 'art', resourceId: 'sombras', placement: { anchor: { to: 'page',
edge: 'top-right' }, size: { width: mm(ART_W), height: mm(BAND) } } },
{ kind: 'text', id: 'kicker', content: '{attr.kicker}', ...onBand, fontFamily: LABEL,
fontSize: pt(8.5), fontWeight: 700, letterSpacing: pt(1.7), textTransform: 'uppercase',
placement: { anchor: { to: 'container', edge: 'top-left' }, offset: { y: mm(4) } } },
{ kind: 'text', id: 'title', content: '{titleText}', ...onBand, fontFamily: TEXT,
fontSize: pt(44), fontWeight: 800, lineHeight: 0.98, placement: below('kicker', 3, TITLE_W) },
{ kind: 'text', id: 'lead', content: '{attr.lead}', ...onBand, fontFamily: TEXT,
fontSize: pt(10.5), lineHeight: 1.4, placement: below('title', 5, LEAD_W) },
{ kind: 'text', id: 'meta', content: '{attr.meta}', ...onBand, fontFamily: LABEL,
fontSize: pt(7.4), fontWeight: 700, letterSpacing: pt(1.1), textTransform: 'uppercase',
placement: below('lead', 4, LEAD_W) },
] } };
الشريط عنصر صندوق مربوط بالصفحة، والرسم عنصر صورة عند الحافة الخارجية؛ أما العنوان التمهيدي والمقدمة وسطر الحصة فتأتي من سمات على سطر العنوان. ولأن الشريط مربوط بالصفحة، تحجز صفحة الافتتاح ارتفاعه أصلًا حتى أسفل الشريط، وكان النص سيبدأ تحته بـ3.6 مم. يطلب minHeight: BAND - TOP + AIR مسافة 8 مم؛ ويلتصق الحجز بخط الشبكة التالي، فيبدأ النص تحت الشريط بـ8.4 مم.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 021 · Boxes that split, float and pin ══════════════════
// https://postext.dev/en/cookbook/boxes-split-float-pin
// Code: MIT · Text: original (CC BY 4.0) · Drawings: generated in code (CC BY 4.0)
// Fonts: Host Grotesk, Commit Mono (SIL OFL 1.1) · Needs postext ≥ 1.25.0
// Four pages of a school lab workbook in Spanish, and five ways a box can sit on them.
import {
buildDocumentWithFonts, prepareFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
const LANG = 'es'; // @lang: the language of the sample document (this recipe is Spanish only)
const RECIPE = 'boxes-split-float-pin';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: one yellow for fields, paler ones for two boxes, near-blacks for type and bars
const palette = {
ink: '#1b2430', // text
charcoal: '#2b2d42', // the safety bar, the summary's rule, the table head, the badge, titles
sun: '#f2b705', // the opener band and the materials panel: fields, never type
light: '#fad65a', // the procedure
tint: '#fff6d6', // the data sheet
rule: '#d7dde3', // hairlines
muted: '#5d6b78', // running heads, notes
paper: '#ffffff',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// The engine's defaults link to 'main-color': point it at charcoal, so nothing prints blue.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.charcoal })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const TEXT = 'Host Grotesk'; // text and display
const LABEL = 'Commit Mono'; // labels: kickers, box titles, step numbers, heads, the table
const LEAD = 13.6; // pt: the body leading, the pitch of the baseline grid
const LINES = 44; // grid lines in a full column
const [TRIM_W, TRIM_H, TOP, INNER, OUTER, GUTTER] = [195, 255, 22, 18, 14, 7]; // mm
const PT = 25.4 / 72; // mm in a point
// #region look: the base of every box (a mono title, smaller type), then one device each
const TITLE = { fontFamily: LABEL, fontSize: pt(8), color: col('charcoal'),
textTransform: 'uppercase', letterSpacing: pt(1.2) }; // bold by default
const BOX_TYPE = { fontSize: pt(8.8), lineHeight: pt(12.4) }; // colours inherit bodyText
const box = (id, device) => ({ id, // margins: the defaults, snapped to whole grid lines
padding: { top: mm(3), right: mm(3.6), bottom: mm(3.4), left: mm(3.6) },
titleStyle: { ...TITLE, gap: mm(2) }, body: BOX_TYPE,
lists: { gap: mm(2), itemSpacing: pt(3) }, ...device });
const icon = (id, size, extra) => ({ kind: 'resource', resourceId: id, size: mm(size),
...extra });
// A side bar with its icon centred on it, 1.4 mm narrower than the bar.
const bar = (hue, id, width = 5.6) => ({ backgroundEnabled: false,
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#أبقِ إطار الخطوات قطعة واحدة
بلا هذا الإعداد ينتقل إطار الخطوات، وهو يتسع في عمود، كاملًا إلى رأس العمود الأيمن ويترك 43 مم فارغة في أسفل الأيسر.
- box('pasos', { keepTogether: false, background: col('light'),
+ box('pasos', { background: col('light'),#عوّم ورقة البيانات إلى أسفل الصفحة
مع placement="bottom" في content.es.md تأخذ ورقة البيانات أسفل الصفحة 42، حيث تقع كتلتها. ويبدأ إطار الخطوات الذي تزيحه في رأس العمود الأيمن وينقسم عند قلب الصفحة، فينتهي في رأس الصفحة 43.
-:::callout{type="datos" placement="top" title="Hoja de datos · Madrid, 40,4° N · 3,7° O"}
+:::callout{type="datos" placement="bottom" title="Hoja de datos · Madrid, 40,4° N · 3,7° O"}أخطاء شائعة
خطأ شائع
العنصر العائم 'top' يذهب إلى الصفحة التالية لإحالته ما لم يُسمح له بتصدر صفحة الإحالة
افتراضيًا لا يصعد العنصر العائم أبدًا فوق الإحالة إليه، فالعنصر العائم 'top' الممتد بعرض الصفحة والمُحال إليه في الصفحة N يفتتح الصفحة N+1. اضبط placement.citingPage: true على المورد أو على defaultPlacement لنوعه (أو layout.floatsAtCitingPage للكتاب كله، منذ postext 1.25) فيتصدر الصفحة N بدلًا من ذلك، وينزل النص الذي فوق الإحالة تحته، إذا اتسع له المكان في حدود layout.maxTopFraction وبقي سطر الإحالة في تلك الصفحة. ولا يتصدر أبدًا الصفحة الأولى من فصل ولا صفحة بعد فاصل قسري: فهناك يظل يفتتح الصفحة التالية، ويمكن للموضع 'auto' أو 'bottom' أن يشغل أسفل صفحة الإحالة. موضع الأشكال →
خطأ شائع
الصفحة 1 فردية: خطّط الصفحات بأرقامها الفعلية
الصفحة 1 صفحة يمنى والصفحة 2 أول صفحة زوجية، فخطّط الصفحتين المتقابلتين بأرقام الصفحات الفعلية: الافتتاحية في صفحة زوجية تقابل الصفحة الفردية التي تليها. فواصل الصفحات والأعمدة →
تحذير الإخراج · calloutOverflow
إطار يتجاوز عموده
السبب. إطار لا يمكن لأي قطع أن يقسمه (فيه شكل أو جدول أو إطار متداخل أطول من العمود، أو قيمة splitMinLines مرتفعة جدًّا) وُضع متجاوزًا عموده؛ يسجّله المحرّك في doc.warnings ويعرضه Sandbox في قائمته. وكذلك يتجاوز عمودَه إطارُ span: 'side' الأطول من عمود جانبي فارغ.
الحل. قصّر الإطار، أو اسمح بتقسيمه بـkeepTogether: false، أو اخفض splitMinLines، أو اختر له امتدادًا آخر. التوثيق →
- الإطار الأطول من عمود كامل ينقسم أيًّا كانت قيمة
keepTogether. لا يقرر الإعداد إلا للإطارات التي يتسع لها عمود، كإطار الخطوات هذا بارتفاع 192 مم في عمود من 211 مم. splitMinLines(2 افتراضيًّا) هو أقل عدد من الأسطر يتركه القطع على كل جانب، محسوبًا في الخطوة التي يقطعها، فلا تترك خطوةٌ سطرًا وحده. وقد ضُبط النص الذي يسبق إطار الخطوات كي يقع القطع بين الخطوتين 4 و5. وأي تعديل في النص فوق إطار منقسم قد ينقل القطع، فانظر أين يقع بعد كل تعديل.- الأيقونة ضمن السطر تأخذ عمودًا خاصًا بها، والجزء المتواصل يحتفظ به فارغًا: فتخسر الخطوات عرض الأيقونة في الجزأين. أيقونة في الزاوية، أو شريط جانبي تجلس عليه الأيقونة، يتركان لها العرض كله.
- الإطار العائم بـ
placement="top"يتصدّر الصفحة التي تلي الصفحة التي تقع فيها كتلته، لذا توضع الكتلة في الصفحة السابقة لتلك التي ينبغي أن يتصدّرها الإطار. وهو هنا قبل إطار الخطوات مباشرة، في الصفحة 42.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- The solar-noon table: computed for Madrid with NOAA's solar equations · NOAA Global Monitoring Laboratory · ملك عام
- الصور
- The shadow chart, the dial in profile and the icons, drawn in code in the page's palette · Ignacio Ferro · CC BY 4.0
- الخطوط
- Host Grotesk (SIL OFL 1.1) · Commit Mono (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


