باختصار
امتحان تاريخ من أربع صفحات فيه غلاف ودوائر للإجابة وصفحات مسطّرة للكتابة. يبيّن كيف ترقّم الأسئلة وأجزاءها وكيف تُظهر درجة كل سؤال.
ما الذي ستنضده
الورقة الثانية من امتحان تجريبي في التاريخ عن الحرب الأهلية الأمريكية، منضّدة كتيّبًا من أربع صفحات على مقاس US Letter. الغلاف شريط قرمزي فيه السنة 1863 مرسومة بخط محيطي، فوق خانات المترشح والتعليمات في عمودين وشبكة من الدوائر ذات الأحرف للقسم A. في الصفحة 2 عشرة أسئلة اختيار من متعدد، يتبع كلًّا منها خياراته الأربعة، ويبدأ كل خيار بدائرة فيها حرف مثل دوائر الشبكة. وتضع الصفحة 3 خطبة غيتيسبرغ بوصفها Source A، وترقّم الأسئلة عنها 11 وa) وi)، مع درجات كل جزء في شارة عند الهامش الأيمن. والصفحة 4 مسطّرة للإجابات، خط كل سطرين من النص، وتبدأ كل مجموعة من الخطوط برقم جزئها. في كل صفحة بعد الغلاف رقم صفحة وهامش مسطّر للمصحّح، والصفحة اليمنى الوحيدة بينها مكتوب عليها Turn over.
تجيب هذه الوصفة عن
- كيف أبني صفحة ورقة عمل: أسطر للتعبئة، وإطارات إجابات، وبنوك كلمات، وقوائم تحقق؟
- كيف أخصّص القوائم: نقاط لكل مستوى، وترقيم (a)/(i)، ومربعات اختيار للمهام، وتباعد يبقى على الشبكة؟
- كيف أصنع شارات مضمّنة: مفاتيح لوحة المفاتيح، ووسوم، وبنوك كلمات للتمارين؟
- كيف أنسّق عدة جداول تنسيقات مختلفة (تعبئة، خلايا مخططة بالتناوب، أطر مستديرة) في مستند واحد؟
- كيف أخفي الترويسات في صفحات الافتتاح والصفحات الفارغة، أو ألوّن صفحة زوجية فارغة بلون الجزء؟
الجواب المختصر
// A table row is one line (the table's size × the body's leading ratio) plus cellPadding above
// and below: at the body size, (ROW − LEAD) / 2 of padding makes every row ROW deep, so the
// rules keep to the text's 15 pt grid, 10.6 mm apart: room for handwriting.
const ROW = 2 * LEAD; // pt
const lines = { id: 'lines', rules: 'horizontal', // a rule on the top and foot of every row
borderColor: col('rule'), borderWidth: pt(0.5), bodyFontFamily: LABEL, bodyFontSize: pt(BODY),
bodyColor: col('crimson'), cellPadding: pt((ROW - LEAD) / 2) };
// Every table in this paper is set 'here': where its ::resource directive stands in the text.
const table = (id, styleId, model) => ({ id, typeId: 'form', kind: 'table', createdAt: 0,
updatedAt: 0, placement: { position: 'here' }, table: { styleId, model } });
// One table per answer, the part's number in its first margin cell.
const answerLines = (id, part, rows) => table(id, 'lines', { columnWidths: [1, 5], rows: Array
.from({ length: rows }, (_, i) => [{ content: i ? '' : `**${part}**` }, { content: '' }]) });
المكونات
- الميزات
- القوائم المرقّمةالشارات داخل السطرمواضع الجدولة ونقاط التوجيهأنماط الجداول المسمّاةجداول من البياناتأنواع موارد مخصّصةأشكال في هذا الموضع بالضبطتعبئة الخلايانمط التعليقفواصل الصفحات والأعمدةالترويسات بحسب دور الصفحةالترويسات وأرقام الصفحاتأنماط العناوينهندسة القسمصفحات افتتاح مصمَّمةسمات العنوانالصور في تصاميم الصفحةإطارات التنبيهأعمدة داخل الإطار أو النصأنماط الفقرات
- تستخدم أيضًا
- الأشكال والجداول بوصفها مواردمسافة عمودية صريحة
- الخطوط
- PT Serif, Inter Tight (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#1 · رقّم الأسئلة وعلّق خياراتها
const [NUMBER, GAP] = [12.5, 6]; // pt: the question numbers' size; number to text
const orderedLists = { fontFamily: LABEL, color: col('ink'), // bold, by default
separatorColor: col('crimson'), gap: pt(GAP), marginTop: pt(LEAD / 2), marginBottom: pt(0),
itemSpacing: pt(5), numberWidth: 'level', // 5 pt to the options or next part; text after '10.'
levels: [{ level: 1, fontSize: pt(NUMBER) }, // 'arabic' and '.', the defaults
{ level: 2, numberFormat: 'lower-alpha', separator: ')' },
{ level: 3, numberFormat: 'lower-roman', separator: ')' }] };
// Options: a bulletless item at the questions' depth, '10.' plus GAP in (boxes set their own).
const width = (s) => { const ctx = new OffscreenCanvas(1, 1).getContext('2d');
ctx.font = `700 ${NUMBER}pt "${LABEL}"`; return ctx.measureText(s).width * 0.75; }; // pt
const unorderedLists = () => ({ gap: pt(0), marginTop: pt(0), marginBottom: pt(0),
itemSpacing: pt(LEAD), // after the options: a line before the next question
indent: pt(width('10') + width('.') + GAP), levels: [{ level: 1, bulletChar: '' }] });
يختار كل مستوى من orderedLists قيمتي numberFormat وseparator الخاصتين به، ويلوّن separatorColor النقطة والأقواس بلون التمييز بينما يبقى الرقم بلون الحبر (القوائم المرقّمة). مع numberWidth: 'level' تُحاذى الأرقام إلى اليمين على أعرضها في مستواها، لذا يبدأ نص كل سؤال على بُعد 23 نقطة: النقاط السبع عشرة التي يشغلها '10.' مضافًا إليها GAP. الخيارات الأربعة بند نقطي واحد قيمة bulletChar فيه فارغة، في مستوى الأسئلة نفسه لا متداخلًا تحتها. يبدأ نصه عند indent القائمة، وهو عرض '10.' مقيسًا بخط الأرقام مضافًا إليه GAP، فتصطف الخيارات تحت الحرف الأول من السؤال أيًّا كان الخط؛ ويضبط إطار التعليمات indent: pt(0) لأن القوائم داخل الإطار تأخذ إزاحة المستند. وبين بندين من مستوى واحد يكون التباعد هو itemSpacing الخاص بالأول: 5 نقاط بعد بند مرقّم، و15 نقطة بعد سطر خيارات. ولو تداخل سطر الخيارات تحت سؤاله لأخذ نقاط قائمة الأسئلة الخمس على جانبيه.
#2 · اصنع الدوائر والدرجات من الشارات
// A chip is 0.8 em above the baseline and 0.25 em below, plus paddingY and the border on each
// side: 1.29 em and two borders. One capital is 0.63–0.72 em wide, so paddingX 0.3 em (and the
// same two borders) squares the box; a radius over half its smaller side is clamped to that half.
const chip = (id, look) => ({ id, fontFamily: LABEL, fontSize: em(0.8), bold: true,
paddingY: em(0.12), ...look });
const bubble = (id, fill, ink, edge = 'crimson') => chip(id, { color: col(ink), paddingX: em(0.3),
background: col(fill), borderColor: col(edge), borderWidth: pt(0.7), borderRadius: em(1) });
const chipStyles = [bubble('bubble', 'paper', 'crimson'), // first: a bare :chip[A] takes it
bubble('filled', 'ink', 'paper', 'ink'), chip('marks', { color: col('crimson'),
background: col('blush'), borderWidth: pt(0), paddingX: em(0.45), gap: em(0.5) })];
الشارة (chip) إطار داخل السطر، ولا يقع فاصل سطر داخلها أبدًا (الشارات داخل السطر). مع حرف كبير واحد في داخلها، يجعل paddingX: em(0.3) الإطار بعرض ارتفاعه تقريبًا: من 4.5 إلى 4.8 مم عرضًا في الشبكة، لارتفاع 4.7 مم. وborderRadius: em(1) أكبر من نصف الإطار، ونصف قطر زاوية الشارة يُقيَّد بنصف ضلعها الأقصر، فيأتي طرفاها مستديرين تمامًا. الشارة التي لا style لها تأخذ أول مدخل في chipStyles، لذا فالدوائر الثمانون، أربعون في الشبكة وأربعون بين الخيارات، شارات مجردة مثل :chip[A]؛ ولا يحدّد نمطًا إلا المثال المظلَّل في التعليمات والدرجات. تقف الدرجات ملاصقة للحافة اليمنى: ينتهي كل جزء بـ:tab قبل شارته، وموضع الجدولة الوحيد في المتن، عند نهاية عرض السطر مع align: 'end'، يُنهي الشارة هناك (الجدولة ومواضع الجدولة). وعناصر قوائم الأسئلة تأخذ مواضع المتن، فتنتهي شارتا a) وi) في المكان نفسه. والجزء الذي لا يبقى في سطره الأخير مكان لشارته يأخذ كلمته الأخيرة معها إلى السطر التالي.
#3 · أعطِ كل استمارة نمط جدول خاصًا بها
// No table has a header row; the flag keeps the default grey fill off one added later.
const form = { bodyFontFamily: LABEL, borderRadius: mm(2), headerBackgroundEnabled: false };
const tableStyles = [lines,
{ ...form, id: 'candidate', rules: 'grid', borderColor: col('rule'), borderWidth: pt(0.75),
bodyFontSize: pt(7.5), bodyColor: col('crimson'), cellPadding: mm(1.8) },
// No rules: the tint of each cell meets its neighbours' and the grid reads as one panel.
{ ...form, id: 'grid', rules: 'none', bodyBackgroundEnabled: true,
bodyBackground: col('tint'), bodyFontSize: pt(11.5), cellPadding: mm(1.4) }];
const cell = (content, extra) => ({ content, align: 'center', verticalAlign: 'middle', ...extra });
// The MARK cell sets the row's depth: three lines, the blank one a no-break space.
const candidate = table('candidate', 'candidate', { columnWidths: [4.2, 1.2, 2, 1.3], rows: [[
...t({ en: ['NAME', 'CLASS', 'CANDIDATE NUMBER'], es: ['NOMBRE Y APELLIDOS', 'GRUPO',
'N.º DE EXAMEN'] }).map((l) => cell(`**${l}**`, { align: 'left', verticalAlign: 'top' })),
cell(`**${t({ en: 'MARK', es: 'NOTA' })}**\n\u00A0\n**/ ${t({ en: '25', es: '10' })}**`,
{ align: 'right', background: col('tint') })]] });
const GROUP = ['A', 'B', 'C', 'D'].map((l) => cell(`:chip[${l}]`)), num = (n) => cell(`**${n}**`);
const grid = { ...table('grid', 'grid', { columnWidths: [0.7, 1, 1, 1, 1, 1.4, 0.7, 1, 1, 1, 1],
rows: [1, 2, 3, 4, 5].map((n) => [num(n), ...GROUP, cell(''), num(n + 5), ...GROUP]) }),
caption: t({ en: '**Section A answer grid**', es: '**Parte A: plantilla de respuestas**' }) };
// The grid's title is its caption: a heading would stand a body line off any 'here' table.
const captionStyle = { fontFamily: LABEL, fontSize: pt(9.4), color: col('crimson'),
position: 'above', gap: mm(1.6) }; // the rubric's size
خانات المترشح وشبكة الدوائر وأسطر الإجابة ثلاثة أنماط من tableStyles، يُختار أحدها لكل جدول بواسطة styleId (أنماط الجداول المسمّاة). تستخدم أسطر الإجابة في الجواب المختصر rules: 'horizontal' وحشوةً تجعل عمق كل صف سطرين من سطور المتن، فيقع كل خط على بعد 30 نقطة (10.6 مم) تحت الذي قبله، على كل سطر ثانٍ من شبكة النص ذات 15 نقطة. في السطر الأوسط الفارغ من خلية MARK مسافة غير فاصلة، لأن سطر الخلية الفارغ أو الذي ليس فيه إلا مسافات عادية لا يضيف شيئًا: تلك الخلية بعمق ثلاثة أسطر وتجعل ارتفاع الصف كله 14.4 مم، مقابل 10.8 مم مع سطرين. لا ترسم الشبكة خطوطًا: يتصل لون كل خلية بلون جارتها فتُقرأ الشبكة لوحةً واحدة. وعنوانها تعليق يُنضَّد على بعد 1.6 مم فوقها (نمط التعليق). ولو استُعمل عنوان (heading) بدلًا منه لوقف أعلى بسطر متن واحد على الأقل (5.3 مم)، لأن كل جدول موضوع 'here' يحتفظ بهذه المساحة فوقه. ولنوع form قيمة captionPrefix فارغة، فلا تسبق العنوانَ عبارةُ 'Form 1.'.
#4 · ارسم الغلاف من سمات العنوان
const BAND = 116; // mm: the crimson band, bled off the top and both sides
const YEAR = { cap: 62, cut: 12, pad: 2 }; // mm: the digits' cap height; the band cuts 12 off
// span 'page' makes the cover an opener page, which the body pages' furniture skips.
const cover = { id: 'cover', span: 'page', margins: { right: mm(LEFT) }, // forms full width
advancedDesign: { enabled: true, slot: { elements: [ // the date line sets the height
{ kind: 'box', id: 'band', style: { backgroundColor: col('crimson') },
placement: at(0, 0, { width: mm(PAGE.w), height: mm(BAND) }) },
// Design text has no outline, so the year is an image, cut off by the band's foot.
{ kind: 'image', id: 'year', resourceId: 'year', placement: at(0, BAND - YEAR.cap
+ YEAR.cut - YEAR.pad, { width: mm(PAGE.w), height: mm(YEAR.cap - YEAR.cut + YEAR.pad) }) },
text('session', '{attr.session}', LABEL, 8.5, 600, 'blush', at(LEFT, 14), tag),
// 0.9 mm to the left: the H's side bearing at 64 pt (84 of 2048 units), so its stem aligns.
text('title', '{titleText}', LABEL, 64, 800, 'paper', at(LEFT - 0.9, 19), { lineHeight: 1 }),
text('paper', '{attr.paper}', LABEL, 15, 700, 'paper', at(LEFT, 44)),
text('topic', '{attr.topic}', TEXT, 15, 400, 'blush', at(LEFT, 52), { italic: true }),
text('date', '{attr.date}', LABEL, 9.5, 700, 'ink', at(LEFT, BAND + 6))] } } };
الغلاف عنوان واحد، # History {style="cover" …}، ويرسم نمطه شريطًا والسنة وأربعة أسطر من النص تُملأ من سمات العنوان. مع span: 'page' تُعدّ الصفحة صفحة افتتاح، فلا يظهر عليها خط الهامش ولا رقم الصفحة ولا «Turn over» التي تظهر في صفحات المتن، ويُطبع التنبيه في أسفلها. ومن دونه يكون الغلاف صفحة متن كغيره. توسّع margins في النمط عمود الغلاف إلى 168 مم كاملة من أجل الاستمارات، ويعيد العنوان التالي، وهو عنوان من المستوى 1 بلا نمط، صفحات المتن إلى عرض 134 مم.
#5 · أبعد أرقام الصفحات وعبارة Turn over عن الغلاف
const [MARGIN, FOOT] = [LEFT + MEASURE + 7, -13]; // mm: the margin rule, 7 off the text; the foot
const body = { pages: 'body', ...tag }; // body pages only: never the cover
const NOTE = t({ en: 'Do not write in this margin', es: 'No escribas en este margen' });
const header = { elements: [
text('running', '{title} · {chapterTitle}', LABEL, 7.5, 600, 'muted', at(LEFT, 12), body),
{ kind: 'rule', id: 'margin', direction: 'vertical', pages: 'body', color: col('rule'),
thickness: pt(0.75), placement: at(MARGIN, TOP, { height: mm(PAGE.h - TOP - BOTTOM) }) },
text('note', NOTE, LABEL, 7.5, 600, 'muted', at(MARGIN + 3, TOP, { width: mm(28) }),
{ ...body, lineHeight: 1.3 })] };
const footer = { elements: [
text('notice', '{attr.notice}', LABEL, 8.5, 700, 'crimson', at(0, FOOT, { width: mm(PAGE.w) },
'bottom-left'), { pages: 'opener', align: 'center', ...tag }), // from the cover's H1
text('folio', '{pageNumber}', LABEL, 9, 700, 'ink', at(LEFT, FOOT, { width: mm(MEASURE) },
'bottom-left'), { ...body, align: 'center' }), // centred under the text
text('turn', t({ en: 'Turn over ›', es: 'Pasa la página ›' }), LABEL, 9, 700, 'ink', // rectos
at(-RIGHT, FOOT, null, 'bottom-right'), { ...body, parity: 'odd', align: 'right' })] };
لكل عنصر متكرر في صفحات المتن pages: 'body'، فلا يظهر على الغلاف، وهو صفحة افتتاح، إلا تنبيهه الخاص (pages: 'opener'). لذلك تبدأ الأقسام بـ:::pagebreak وبعنوان بلا breakBefore. فالعنوان الذي يكسر الصفحة يجعل صفحته صفحة افتتاح، وكانت الصفحتان 2 و3 ستفقدان رقم الصفحة والترويسة والهامش. ويُبقي parity: 'odd' عبارة Turn over على الصفحة الفردية، لأن الصفحة الزوجية تقابل أصلًا الصفحة التي تليها.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 049 · Exam paper with an answer sheet ═════════════════
// https://postext.dev/en/cookbook/exam-paper
// Code: MIT · Text: Lincoln (PD); questions, Spanish translation (CC BY 4.0) · Art: in code
// Fonts: PT Serif, Inter Tight (SIL OFL 1.1) · Needs postext ≥ 1.34.0
import {
buildDocumentWithFonts, prepareFonts, renderPageToCanvas, registerResourceImage, inlineSvgFonts,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'exam-paper';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { ink: '#1b1a1f', paper: '#ffffff', muted: '#6b6466', // heads, credits: 5.8:1
crimson: '#9b1c31', // the one accent: cover, numbering, bubbles, marks (8.1:1 on white)
blush: '#f3cdd4', tint: '#fbeff1', // type on the band, marks chips; the grid, the rubric box
rule: '#b9aeb0' }; // answer lines and hairlines
// col(id): a colour linked to its palette entry, with the entry's hex beside the id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// The engine's defaults are linked to 'main-color': point it at the accent.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.crimson })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [TEXT, LABEL, PAGE] = ['PT Serif', 'Inter Tight', { w: 215.9, h: 279.4 }]; // US Letter
const [TOP, BOTTOM, LEFT, MEASURE] = [22, 24, 24, 134]; // mm; 134 mm: about 75 characters
const RIGHT = PAGE.w - LEFT - MEASURE; // 57.9 mm: the examiner's margin, never mirrored
const [BODY, LEAD] = [11, 15]; // pt: text size and leading, the grid every line keeps to
const at = (x, y, size, edge = 'top-left') => ({ anchor: { to: 'page', edge },
offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });
const text = (id, content, family, size, weight, color, placement, extra) => ({ kind: 'text',
id, content, fontFamily: family, fontSize: pt(size), fontWeight: weight, color: col(color),
align: 'left', overflow: 'wrap', placement, ...extra });
const tag = { textTransform: 'uppercase', letterSpacing: pt(1.4) }; // 0.16–0.19 em
const small = { fontFamily: LABEL, fontSize: pt(7.5), lineHeight: pt(10), color: col('muted') };
// #region answer: ruled answer lines: a table whose rows are two body lines deep
// A table row is one line (the table's size × the body's leading ratio) plus cellPadding above
// and below: at the body size, (ROW − LEAD) / 2 of padding makes every row ROW deep, so the
// rules keep to the text's 15 pt grid, 10.6 mm apart: room for handwriting.
const ROW = 2 * LEAD; // pt
const lines = { id: 'lines', rules: 'horizontal', // a rule on the top and foot of every row
borderColor: col('rule'), borderWidth: pt(0.5), bodyFontFamily: LABEL, bodyFontSize: pt(BODY),
bodyColor: col('crimson'), cellPadding: pt((ROW - LEAD) / 2) };
// Every table in this paper is set 'here': where its ::resource directive stands in the text.
const table = (id, styleId, model) => ({ id, typeId: 'form', kind: 'table', createdAt: 0,
updatedAt: 0, placement: { position: 'here' }, table: { styleId, model } });
// One table per answer, the part's number in its first margin cell.
const answerLines = (id, part, rows) => table(id, 'lines', { columnWidths: [1, 5], rows: Array
.from({ length: rows }, (_, i) => [{ content: i ? '' : `**${part}**` }, { content: '' }]) });
// #endregion
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#اطبعها على A4
يأخذ الشريط والسنة وخط الهامش والتنبيه مقاساتها من PAGE، لذا فالتحويل إلى A4 تغيير في سطر واحد. تحتفظ كتل الغلاف بأماكنها، ويزداد البياض تحت الشبكة بمقدار 17.6 مم في الطبعتين.
-const [TEXT, LABEL, PAGE] = ['PT Serif', 'Inter Tight', { w: 215.9, h: 279.4 }]; // US Letter
+const [TEXT, LABEL, PAGE] = ['PT Serif', 'Inter Tight', { w: 210, h: 297 }]; // A4#أضف بنك كلمات أو قائمة تحقّق
بنوك الكلمات والفراغات والدوائر التي تُلوَّن شارات أيضًا: تضع ورقة العمل ذات خانات الإجابة وبنك الكلمات بنكًا من الشارات الصفراء في إطار متداخل، وقائمة تحقّق يبدأ كل سطر منها بدائرة فارغة.
أخطاء شائعة
خطأ شائع
علامة $ المجرّدة تفتح الرياضيات: اكتب \$
علامة الدولار تفتح رياضيات داخل السطر، فسعرٌ مثل $40 يبدأ صيغة. اكتب \$40. الهروب والمحارف الحرفية →
- أسطر الإجابة الموضوعة بين أجزاء السؤال تقسم قائمته: القائمة التي تلي الجدول تبدأ سلسلة جديدة، وكل سلسلة تحاذي أرقامها إلى اليمين على أعرضها هي، فيبدأ نص ii) أبعد إلى اليمين بمقدار 1 مم من نص i). هنا تقع الإجابات على صفحة خاصة بها، وتبقى الأجزاء كلها في قائمة واحدة.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- The Gettysburg Address (19 November 1863), text of the Bliss copy · Abraham Lincoln · ملك عام
- The questions, the instructions and the Spanish translation of Source A · Ignacio Ferro · CC BY 4.0
- الخطوط
- PT Serif (SIL OFL 1.1) · Inter Tight (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


