Kurz gesagt
Eine vierseitige Geschichtsprüfung mit Deckblatt, Antwortkreisen und linierten Seiten zum Schreiben. Sie zeigt, wie man Fragen und Teilfragen nummeriert und die Punkte für jede angibt.
Was Sie setzen
Teil 2 einer Probeprüfung in Geschichte zum Amerikanischen Bürgerkrieg, gesetzt als vierseitiges Heft auf US Letter. Das Deckblatt ist ein karminrotes Band mit der Jahreszahl 1863 als Kontur, über den Feldern für die Prüflinge, den Anweisungen in zwei Spalten und einem Raster aus Buchstabenkreisen für Section A. Seite 2 enthält zehn Multiple-Choice-Fragen, jede gefolgt von ihren vier Antworten, und jede Antwort beginnt mit einem Buchstabenkreis wie im Raster. Seite 3 setzt die Gettysburg Address als „Source A“ und nummeriert die Fragen dazu mit 11, a), i), die Punkte für jeden Teil in einem Chip am rechten Rand. Seite 4 ist für die Antworten liniert, eine Linie alle zwei Textzeilen, und jede Liniengruppe beginnt mit der Nummer ihres Teils. Jede Seite nach dem Deckblatt hat eine Pagina und einen linierten Rand für die Prüfenden, und auf der einzigen rechten Seite darunter steht „Turn over“.
Dieses Rezept beantwortet
- Wie baue ich eine Arbeitsblattseite: Schreiblinien, Antwortkästen, Wortspeicher, Checklisten?
- Wie passe ich Listen an: Aufzählungszeichen je Ebene, Nummerierung (a)/(i), Aufgaben-Kontrollkästchen, Abstände, die im Raster bleiben?
- Wie erstelle ich Inline-Chips: Tastaturtasten, Schlagwörter, Wortspeicher für Übungen?
- Wie gestalte ich mehrere Tabellen in einem Dokument unterschiedlich (Füllungen, Zebrastreifen, abgerundete Rahmen)?
- Wie blende ich Kolumnentitel auf Auftakten und Vakatseiten aus oder färbe eine leere linke Seite in der Teilfarbe?
Die kurze Antwort
// 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: '' }]) });
Zutaten
- Funktionen
- Nummerierte ListenInline-ChipsTabulatoren und FüllzeichenBenannte TabellenformateTabellen aus DatenEigene RessourcentypenAbbildungen genau hierZellfüllungenFormat der BildunterschriftSeiten- und SpaltenumbrücheKopfzeilen nach SeitenrolleKolumnentitel und SeitenzahlenÜberschriftenformateAbschnittsgeometrieGestaltete AuftakteÜberschriftenattributeBilder in SeitengestaltungenKästenSpalten in einem Kasten oder im TextAbsatzformate
- Schrift
- PT Serif, Inter Tight (SIL OFL 1.1)
- Dateien
- Keine: Jedes Bild wird im Code gezeichnet
Zubereitung
#1 · Fragen nummerieren und ihre Antworten einhängen
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: '' }] });
Jede Ebene von orderedLists wählt ihr eigenes numberFormat und ihren separator, und separatorColor färbt Punkt und Klammern in der Akzentfarbe, während die Nummer schwarz bleibt (nummerierte Listen). Mit numberWidth: 'level' werden die Nummern an der breitesten ihrer Tiefe rechtsbündig ausgerichtet, sodass der Text jeder Frage 23 pt eingerückt beginnt: die 17 pt von „10.“ plus GAP. Die vier Antworten sind ein Aufzählungspunkt mit leerem bulletChar, auf derselben Tiefe wie die Fragen statt darunter verschachtelt. Sein Text beginnt beim indent der Liste, also „10.“ in der Schrift der Nummern gemessen plus GAP, sodass die Antworten in jeder Schrift unter dem ersten Buchstaben der Frage stehen; der Kasten mit den Anweisungen setzt indent: pt(0), weil die Listen in einem Kasten den Einzug des Dokuments übernehmen. Zwischen zwei Einträgen derselben Tiefe gilt das itemSpacing des ersten: 5 pt nach einem nummerierten Eintrag, 15 pt nach einer Zeile mit Antworten. Wäre die Antwortzeile unter ihrer Frage verschachtelt, bekäme sie auf beiden Seiten die 5 pt der Fragenliste.
#2 · Kreise und Punkte aus Chips bauen
// 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) })];
Ein Chip ist ein Kästchen in der Zeile, und ein Zeilenumbruch fällt nie hinein (Inline-Chips). Mit einem Versal darin macht paddingX: em(0.3) das Kästchen etwa so breit wie hoch: 4,5 bis 4,8 mm breit im Raster bei 4,7 mm Höhe. borderRadius: em(1) ist mehr als die Hälfte des Kästchens, und der Radius eines Chips wird auf die Hälfte seiner kürzeren Seite begrenzt, sodass die Enden ganz rund sind. Ein Chip ohne style nimmt den ersten Eintrag von chipStyles, daher sind die achtzig Kreise, vierzig im Raster und vierzig bei den Antworten, schlichte Chips wie :chip[A]; nur das ausgefüllte Beispiel in den Anweisungen und die Punkte geben einen Stil an. Die Punkte stehen rechtsbündig: Jeder Teil endet mit :tab vor seinem Chip, und der einzige Tabstopp des Textes, am Ende der Satzbreite mit align: 'end', lässt den Chip dort enden (Tabulatoren und Tabstopps). Die Listeneinträge der Fragen übernehmen die Tabstopps des Textes, sodass die Chips von a) und von i) an derselben Stelle enden. Ein Teil, dessen letzte Zeile keinen Platz mehr für seinen Chip hat, nimmt sein letztes Wort mit in die nächste Zeile.
#3 · Jedem Formular einen eigenen Tabellenstil geben
// 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
Die Felder für die Prüflinge, das Kreisraster und die Antwortlinien sind drei tableStyles, pro Tabelle mit styleId gewählt (benannte Tabellenstile). Die Antwortlinien unter Die kurze Antwort verwenden rules: 'horizontal' und einen Innenabstand, der jede Zeile zwei Textzeilen tief macht, sodass jede Linie 30 pt (10,6 mm) unter der vorigen liegt, auf jeder zweiten Zeile des 15-pt-Rasters des Textes. Die leere mittlere Zeile der Zelle MARK enthält ein geschütztes Leerzeichen, denn eine Zellenzeile, die leer ist oder nur gewöhnliche Leerzeichen enthält, trägt nichts bei: Diese Zelle ist drei Zeilen tief und setzt die ganze Zeile auf 14,4 mm, gegenüber 10,8 mm mit zwei Zeilen. Das Raster zeichnet keine Linien, sodass der Farbton jeder Zelle an den der Nachbarzelle stößt und das Raster als eine Fläche wirkt. Sein Titel ist eine Legende 1,6 mm darüber (Legendenstil). Eine Überschrift stünde mindestens eine Textzeile (5,3 mm) höher, weil jede „here“ platzierte Tabelle so viel Raum über sich hält. Der Typ form hat ein leeres captionPrefix, sodass keine Bezeichnung „Form 1.“ vor dem Titel steht.
#4 · Das Deckblatt aus den Attributen der Überschrift zeichnen
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))] } } };
Das Deckblatt ist eine Überschrift, # History {style="cover" …}, und ihr Stil zeichnet ein Band, die Jahreszahl und vier Textzeilen, gefüllt aus den Attributen der Überschrift. Mit span: 'page' zählt die Seite als Auftakt, sodass Randlinie, Pagina und „Turn over“ der Textseiten draußen bleiben und der Hinweis an ihrem Fuß erscheint. Ohne die Einstellung ist das Deckblatt eine Textseite wie die übrigen. Die margins des Stils verbreitern die Spalte des Deckblatts für die Formulare auf die vollen 168 mm, und die nächste Überschrift, eine Ebene 1 ohne Stil, bringt die Textseiten auf die Satzbreite von 134 mm zurück.
#5 · Pagina und „Turn over“ vom Deckblatt fernhalten
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' })] };
Jedes laufende Element der Textseiten hat pages: 'body', sodass das Deckblatt, ein Auftakt, nur seinen eigenen Hinweis zeigt (pages: 'opener'). Die Abschnitte beginnen deshalb mit :::pagebreak und einer Überschrift ohne breakBefore. Eine Überschrift, die die Seite umbricht, macht ihre Seite zum Auftakt, und die Seiten 2 und 3 verlören Pagina, Kolumnentitel und Rand. parity: 'odd' hält „Turn over“ auf der rechten Seite, da eine linke Seite der folgenden ohnehin gegenübersteht.
Das ganze Rezept
// ═══ 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
Das zusammengesetzte script.js läuft unverändert: Fügen Sie es in das Modulskript einer beliebigen Seite ein, oder öffnen Sie das Rezept auf CodePen. Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)
Varianten
#Auf A4 drucken
Band, Jahreszahl, Randlinie und Hinweis nehmen ihre Maße aus PAGE, daher ist A4 eine einzeilige Änderung. Die Blöcke des Deckblatts behalten ihre Plätze, und das Weiß unter dem Raster wächst in beiden Sprachausgaben um 17,6 mm.
-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#Eine Wortbank oder eine Checkliste hinzufügen
Wortbänke, Lücken und auszumalende Kreise sind ebenfalls Chips: das Arbeitsblatt mit Antwortkästen und Wortspeicher setzt eine Bank gelber Chips in einen verschachtelten Kasten und eine Checkliste, die jede Zeile mit einem leeren Kreis beginnt.
Häufige Fehler
Häufiger Fehler
Ein einzelnes $ eröffnet Mathematik: \$ schreiben
Ein Dollarzeichen eröffnet Mathematik im Text, sodass ein Preis wie $40 eine Formel beginnt. Schreiben Sie \$40. Maskierung und wörtliche Zeichen →
- Antwortlinien zwischen den Teilen einer Frage teilen ihre Liste: Die Liste nach der Tabelle beginnt eine neue Folge, und eine Folge richtet ihre Nummern an ihrer eigenen breitesten aus, sodass der Text von ii) 1 mm rechts vom Text von i) begänne. Hier stehen die Antworten auf einer eigenen Seite, und jeder Teil bleibt in einer Liste.
Nachweise
- Rezept
- Ignacio Ferro
- Text
- The Gettysburg Address (19 November 1863), text of the Bliss copy · Abraham Lincoln · gemeinfrei
- The questions, the instructions and the Spanish translation of Source A · Ignacio Ferro · CC BY 4.0
- Schriften
- PT Serif (SIL OFL 1.1) · Inter Tight (SIL OFL 1.1)
- Code
- MIT, wie Postext
Diesen Text bearbeiten ↗ (öffnet sich in einem neuen Tab)Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)


