Zum Hauptinhalt springen
Rezept Nummer 156

Rezepte · Kapitel 12 · Schulbücher

Eine Schulbuch-Einheit für Kinder in zehn Sprachen

Neun Seiten einer Einheit der 3. Klasse in zehn Sprachen, auch Arabisch und senkrecht: Doppelseiten auf Farbgrund, wachsende Kästen, beschriftete Karte.

Auf dieser Seite

S. 6–7 von 9

  • Endformat 210 × 280 mm
  • 1 Spalte
  • Nunito 12/17,5
  • Fredoka
  • 9 Seiten
  • Stufe
  • Postext 1.65.0
  • In 51 ms gesetzt
  • 296 Zeilen Code

Kurz gesagt

Eine Schulbuch-Einheit über einen Fluss, neun Seiten lang. Jedes Thema ist eine Doppelseite auf Farbgrund mit Titeletikett, Text, Bildern und Kästen. Auf der Karte ist kein Wort gemalt: Ihre Namen kommen aus dem Text.

Was Sie setzen

Neun Seiten von Unser Fluss, Einheit 4 eines erfundenen Sachkundebuchs für die 3. Klasse, auf einer Seite von 210 × 280 mm, in zehn Sprachen: Spanisch, Katalanisch, Englisch, Portugiesisch, Französisch, Deutsch, Italienisch, Arabisch, Chinesisch und Japanisch. Ein gemaltes Tal eröffnet die Einheit, eine Inhaltsseite führt zwei Teile auf, dann folgen drei Themen als Doppelseiten, jedes auf eigenem Grund: Wasserblau, Feldgrün, Sonnensand. Jedes Thema hat ein Etikett mit Nummer und Titel, Text in zwei Spalten und Kästen mit Etikett, die mit ihrem Text wachsen. Das zweite Thema ist eine einzige gemalte Karte über beide Seiten, auf der Fluss, Dörfer und die drei Flussläufe aus dem Markdown benannt sind, und von jedem Kasten eines Flusslaufs führt eine Linie zu seinem Abschnitt des Flusses. Was sich wiederholt, wird einmal gezeichnet: Die Vorlage legt eine Bildkarte, einen Kasten für einen Flusslauf und einen Kasten mit Bild so oft an, wie das Markdown verlangt, und die drei Fragen vor der Einheit sind drei Verwendungen eines einzigen Moduls. Die Texte sind um ein Fünftel oder mehr verschieden lang und passen in dieselben Vorlagen: Ein Kasten nimmt die Höhe, die seine Wörter brauchen, und schiebt den nächsten nach unten, und die Karte wird etwas kleiner gesetzt, bevor irgendein Text es wird. Das arabische Buch läuft von rechts nach links, das chinesische und das japanische laufen die Seite hinab; alle drei sind rechts gebunden und werden in jeder Doppelseite von der rechten zur linken Seite gelesen.

Dieses Rezept beantwortet

  • Wie setze ich eine Schulbuch-Einheit in drei Sprachen mit denselben Seitenvorlagen, wenn der Text jeder Sprache anders lang ist?
  • Wie lasse ich die Kästen einer Seite mit ihrem Text wachsen, sodass sie die Kästen darunter nach unten schieben?
  • Wie setze ich die Namen einer Karte aus dem Text, damit eine Übersetzung die Wörter ändert und nicht die Zeichnung?

Die kurze Antwort

script.js · Zeilen 90–122im vollständigen Code
// Ground, tab and number are decoration anchored to the title frame; the number,
// `{headingNumber}`, stands over the padding before its words. A topic extends the base.
const ground = () => ({ kind: 'box', id: 'ground',
  placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: 'fill' } },
  style: { backgroundColor: col('tema-ground') } });
const titleTab = () => ({ kind: 'box', id: 'tab', placement: { ...at('#titulo',
  'top-left'), size: { width: { to: '#titulo', edge: 'right' }, height: { to: '#titulo',
    edge: 'bottom' } } }, style: { backgroundColor: col('tema'), borderRadius: mm(4) } });
const badge = () => ({ kind: 'text', id: 'number', content: '{headingNumber}',
  fontFamily: DISPLAY, fontSize: pt(22), fontWeight: fw(700), color: col('tema'), align: 'center',
  box: { backgroundColor: col('paper'), borderRadius: mm(6) }, placement: { ...at('#titulo',
    corner('top'), inward(CJK ? 2.6 : 5), CJK ? 5 : 2.4), size: { width: mm(12), height: mm(12) } },
});
const title = { name: 'titulo', takes: 'h1', style: 'titulo', width: mm(MEASURE),
  placement: at('container', 'top-left') };

const base = {
  id: 'tema', spread: true, gutter: mm(12),
  decoration: { elements: [ground(), titleTab(), badge()] },
  frames: [title, { name: 'texto', flow: true, columns: 2, columnGap: mm(CJK ? 16 : 7), // 段
    width: mm(MEASURE), fit: { minScale: 0.9 } }],
  groups: [{ name: 'izquierda', kind: 'stack', gap: mm(6), frames: ['titulo', 'texto'] }],
};
const topic = (id, f, more) => ({ id, extends: 'tema', palette: swap(f), ...more });
const box = (name, style, minHeight, more) => ({ name, style, width: mm(MEASURE),
  minHeight: mm(minHeight), ...more });
const answer = (name, lines) => ({ name, optional: true, style: 'respuesta', width: mm(MEASURE),
  height: mm(LINE * lines), minHeight: mm(LINE * lines),
  rules: { every: mm(LINE), color: col('rule'), width: pt(0.75) } });
const PIC = CJK ? 30 : 56; // a picture at the end of a box's first lines pushes the text aside
const withPic = (name, style, minHeight, more) => [box(name, style, minHeight,
  { padding: { right: mm(PIC + 8) }, ...more }), { name: `${name}-foto`, layer: 2, width: mm(PIC),
  exclude: 'push', placement: at(`#${name}`, 'top-right', -5, 8) }];

Zutaten

Schrift
Nunito, Fredoka, Noto Naskh Arabic, Baloo Bhaijaan 2, Klee One, Zen Maru Gothic, Noto Serif SC, ZCOOL KuaiLe (SIL OFL 1.1)
Dateien
  • arroyo-720.jpg
  • cascada-720.jpg
  • limpieza-720.jpg
  • mapa-1900-rtl.jpg
  • mapa-1900.jpg
  • molino-720.jpg
  • nacimiento-720.jpg
  • piraguas-720.jpg
  • portada-1400.jpg
  • riego-720.jpg
  • The valley of the River Aldara, painted from the mountains to the sea, with two children watching the water. (Generated With Diffusion Models, eigener Text)
  • The painted map of the valley, from the spring to the port, with no lettering: the names are labels set from the Markdown. (Generated With Diffusion Models, eigener Text)
  • The same painted map mirrored, the mountains on the right, for the books bound on the right (Arabic, Chinese, Japanese). (Generated With Diffusion Models, eigener Text)
  • A spring between mossy rocks. (Generated With Diffusion Models, eigener Text)
  • A mountain stream over round stones. (Generated With Diffusion Models, eigener Text)
  • A small waterfall into a green pool. (Generated With Diffusion Models, eigener Text)
  • A farmer opening the gate of an irrigation canal. (Generated With Diffusion Models, eigener Text)
  • An old stone watermill with its wheel. (Generated With Diffusion Models, eigener Text)
  • Children paddling canoes on a calm river. (Generated With Diffusion Models, eigener Text)
  • Children and a teacher picking up litter on a river bank. (Generated With Diffusion Models, eigener Text)

Zubereitung

#1 · Wissen, auf welcher Seite jede Sprache beginnt

script.js · Zeilen 33–44im vollständigen Code
// Arabic runs right to left, Chinese and Japanese down the page, all bound on the right. Frames
// stand in the flow (x along the lines, mirrored in Arabic, down the page when vertical).
const AR = LANG === 'ar', CJK = LANG === 'zh' || LANG === 'ja';
const RIGHT_BOUND = AR || CJK, LATIN = !RIGHT_BOUND; // italics, capitals, tracking, hyphens
const [TEXT, DISPLAY] = { ar: ['Noto Naskh Arabic', 'Baloo Bhaijaan 2'], ja: ['Klee One',
  'Zen Maru Gothic'], zh: ['Noto Serif SC', 'ZCOOL KuaiLe'] }[LANG] ?? ['Nunito', 'Fredoka'];
const START = RIGHT_BOUND ? 'right' : 'left'; // the side a page starts reading from
const corner = (v) => `${v}-${START}`, inward = (x) => (RIGHT_BOUND ? -x : x);
const [SLANT, CAPS] = LATIN ? ['italic', 'uppercase'] : ['normal', 'none'];
const LEAD = AR ? 20 : CJK ? 21 : 17.5, track = (v) => (LATIN ? v : 0); // Naskh, ruby need room
const fw = (w) => ({ 'ZCOOL KuaiLe': 400, 'Zen Maru Gothic': w > 550 ? 700 : 500 })[DISPLAY] ?? w;
const BOLD = TEXT === 'Klee One' ? 600 : 700; // and the weights the faces have

Die Rahmen einer Vorlage stehen im Bezugssystem des Seitenflusses, in dem x entlang der Zeilen läuft. Mit locale: 'ar' spiegelt die Engine dieses Bezugssystem, sodass das arabische Buch die lateinischen Rahmen unverändert nutzt: Der Titel steht zuerst auf der rechten Seite, die drei Fotos und die drei Kästen der Flussläufe laufen von rechts nach links, und Etiketten, Streifen und Innenabstände der Kästen folgen den Zeilen. Mit layout.writingMode: 'vertical-rl' läuft x die Seite hinab und y von rechts nach links: Die width eines Rahmens ist eine Länge nach unten, ein Stapel wächst nach links, columns: 2 ergibt zwei Stufen (段) zu 27 Zeichen, und ein Rahmen, der below eines anderen steht, steht links davon. Die Dekoration (die Gründe, das Titeletikett, die Nummer, die Kolumnentitel und die Seitenzahlen) steht auf dem Blatt selbst und wird daher von START aus gesetzt, der Seite, an der das Lesen einer Seite beginnt. Jede Schrift hat eine Textschrift und eine gerundete Auszeichnungsschrift, und die arabische, die chinesische und die japanische Ausgabe haben weder Kursive noch Versalien noch Sperrung.

#2 · Die Kästen mit extends bauen

script.js · Zeilen 59–86im vollständigen Code
// Two steps of `extends`: the box (shape, type, tab), then the kind. The colours are `tema`
// entries, so one style serves the three topics; paddings, stripes and tabs are in the flow.
const tab = (f) => ({ position: 'top-left', background: col(f), color: col('paper'),
  fontFamily: DISPLAY, fontSize: pt(12), fontWeight: fw(600), height: mm(7), paddingX: mm(3.2),
  offset: mm(7), inset: mm(5), rule: { enabled: false, color: col(f) } });
const boxText = { fontFamily: TEXT, fontSize: pt(12), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('ink'), italicColor: col('ink'), boldFontWeight: BOLD, firstLineIndent: pt(0),
  textAlign: CJK ? 'justify' : 'left', paragraphSpacing: true };
const calloutStyles = [
  { id: 'caja', backgroundEnabled: true, background: col('paper'), borderRadius: mm(3),
    border: { enabled: false }, padding: { top: mm(3.4), right: mm(5), bottom: mm(4), left: mm(5) },
    body: boxText, lists: { color: col('ink'), gap: mm(2), itemSpacing: mm(1.6) } },
  { id: 'caja-tema', extends: 'caja', label: tab('tema'), lists: { color: col('tema') } },
  { id: 'dato', extends: 'caja-tema', background: col('tema-tint') },
  { id: 'palabras', extends: 'caja-tema', border: { enabled: true, color: col('tema'),
    width: pt(1.4) } }, { id: 'actividad', extends: 'caja-tema',
    stripe: { enabled: true, side: 'left', width: pt(4), color: col('tema') } },
  { id: 'titulo', extends: 'caja', backgroundEnabled: false,
    padding: { top: mm(2.6), right: mm(6), bottom: mm(3.2), left: mm(TAB) } },
  { id: 'titulo-plano', extends: 'titulo', padding: { left: mm(8) } },
  { id: 'portada', extends: 'caja', background: col('agua'), borderRadius: mm(4),
    padding: { top: mm(2.6), right: mm(8), bottom: mm(3.6), left: mm(8) } },
  { id: 'foto', extends: 'caja', borderRadius: mm(2),
    padding: { top: mm(1.8), right: mm(1.8), bottom: mm(2.2), left: mm(1.8) } },
  { id: 'respuesta', extends: 'caja', padding: NONE }, { id: 'colofon', extends: 'caja',
    backgroundEnabled: false, padding: NONE,
    body: { ...boxText, fontSize: pt(8), lineHeight: pt(AR ? 13 : 11), color: col('muted') } },
];

Ein Kastenstil entsteht in drei Schritten. caja hält Form, Schrift und die Geometrie des Etiketts; caja-tema legt die Farbe des Themas auf Etikett und Aufzählungszeichen; dato, palabras und actividad bestimmen die Art: getönter Kasten, umrandeter oder mit Streifen. Ihre Farben sind Einträge der Palette (tema, tema-tint): Jeder Stil wird einmal geschrieben, und die Vorlage eines Themas färbt ihn ein.

#3 · Jedes Thema eine Basisvorlage erweitern lassen

script.js · Zeilen 90–122im vollständigen Code
// Ground, tab and number are decoration anchored to the title frame; the number,
// `{headingNumber}`, stands over the padding before its words. A topic extends the base.
const ground = () => ({ kind: 'box', id: 'ground',
  placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: 'fill' } },
  style: { backgroundColor: col('tema-ground') } });
const titleTab = () => ({ kind: 'box', id: 'tab', placement: { ...at('#titulo',
  'top-left'), size: { width: { to: '#titulo', edge: 'right' }, height: { to: '#titulo',
    edge: 'bottom' } } }, style: { backgroundColor: col('tema'), borderRadius: mm(4) } });
const badge = () => ({ kind: 'text', id: 'number', content: '{headingNumber}',
  fontFamily: DISPLAY, fontSize: pt(22), fontWeight: fw(700), color: col('tema'), align: 'center',
  box: { backgroundColor: col('paper'), borderRadius: mm(6) }, placement: { ...at('#titulo',
    corner('top'), inward(CJK ? 2.6 : 5), CJK ? 5 : 2.4), size: { width: mm(12), height: mm(12) } },
});
const title = { name: 'titulo', takes: 'h1', style: 'titulo', width: mm(MEASURE),
  placement: at('container', 'top-left') };

const base = {
  id: 'tema', spread: true, gutter: mm(12),
  decoration: { elements: [ground(), titleTab(), badge()] },
  frames: [title, { name: 'texto', flow: true, columns: 2, columnGap: mm(CJK ? 16 : 7), // 段
    width: mm(MEASURE), fit: { minScale: 0.9 } }],
  groups: [{ name: 'izquierda', kind: 'stack', gap: mm(6), frames: ['titulo', 'texto'] }],
};
const topic = (id, f, more) => ({ id, extends: 'tema', palette: swap(f), ...more });
const box = (name, style, minHeight, more) => ({ name, style, width: mm(MEASURE),
  minHeight: mm(minHeight), ...more });
const answer = (name, lines) => ({ name, optional: true, style: 'respuesta', width: mm(MEASURE),
  height: mm(LINE * lines), minHeight: mm(LINE * lines),
  rules: { every: mm(LINE), color: col('rule'), width: pt(0.75) } });
const PIC = CJK ? 30 : 56; // a picture at the end of a box's first lines pushes the text aside
const withPic = (name, style, minHeight, more) => [box(name, style, minHeight,
  { padding: { right: mm(PIC + 8) }, ...more }), { name: `${name}-foto`, layer: 2, width: mm(PIC),
  exclude: 'push', placement: at(`#${name}`, 'top-right', -5, 8) }];

Die Basis ist eine Doppelseite: ein Grund bis zum Anschnitt, ein Titeletikett mit Nummer und ein Text in zwei Spalten. Ein Thema erweitert sie (extends: 'tema'), setzt seine palette (die drei tema-Einträge nehmen die Farben der Familie an, und Grund, Etikett, Nummer und alle Kästen wechseln gemeinsam) und fügt eigene Rahmen hinzu. Etikett und Nummer sind am Titelrahmen verankerte Dekoration: Das Etikett ist so hoch wie der Titel, den die Sprache braucht. Die Nummer ist {headingNumber}, der Zähler der Überschrift, die der Rahmen übernommen hat, gemalt über den Innenabstand des Rahmens vor seinen Wörtern: Kein Seitenblock wiederholt sie, und ein Klick darauf trifft die Nummer, nicht den Rahmen.

#4 · Einmal zeichnen, was sich wiederholt

script.js · Zeilen 126–131im vollständigen Code
const grid = (name, frames, columns, placement, more, width = MEASURE) => ({ name, kind: 'grid',
  columns, columnGap: mm(5), rowGap: mm(CJK ? 8 : 12), repeat: { frames },
  placement: { ...placement, size: { width: mm(width), height: 'fill' } }, ...more });
const question = { id: 'pregunta', role: 'module', // a question and the lines to answer it on
  frames: [box('caja', 'dato', CJK ? 22 : 14, { width: 'fill' }), { ...answer('lineas',
    CJK ? 2 : 3), width: 'fill', placement: at('#caja', 'below', 0, CJK ? 4 : 7) }] };

Eine Rastergruppe wiederholt einen Satz von Rahmen einmal für jedes Element der Seite. Der Bildstreifen ist grid('fotos', ['foto'], 3, …): Drei :::figure{slot="foto"}-Blöcke ergeben drei Bildkarten mit den Namen #foto[1] bis #foto[3], und der Kasten Probier es aus hängt unter #foto[1]. Die Kästen des Sonnenthemas sind ein Raster aus einer Spalte, dessen Satz ein Kasten und sein Bild ist (['uso', 'uso-foto']): Jedes :::frame{slot="uso"} enthält seine Wörter und darin das :::figure{slot="uso-foto"}, das zu ihnen gehört. Die Fragenseite stapelt ein Modul: pregunta ist eine Vorlage mit role: 'module', einem getönten Kasten und den Linien für die Antwort, und die Gruppe preguntas der Seite (modules: true) legt eines für jedes :::module{template="pregunta"} im Markdown an. Ein Rahmen ist so hoch wie seine Wörter, nie niedriger als sein minHeight; ein längerer spanischer Text schiebt also die Reihen unter sich nach unten, und wird eine Seite knapp, setzt die Anpassungsleiter Karte und Bilder vor dem Text kleiner, bis auf 90 %.

Die Kästen der Flussläufe bilden ein Raster aus drei unter der Karte (grid('cursos', ['curso'], 3, …)), ein Kasten für jeden :::frame{slot="curso"}. Die Karte benennt dieselben drei Abschnitte mit Beschriftungen im Stil curso, auf dem Grün der Kastenreiter, sodass man den Abschnitt jedes Kastens an Name und Farbe erkennt. Auf einer senkrechten Seite stehen die Flussläufe in einer Spalte neben der Karte.

#5 · Die Namen der Karte aus dem Text setzen

script.js · Zeilen 250–290im vollständigen Code
// An anchor is a point of the painting (fractions of its width and height) and a label style;
// every language's ::label lines use the same anchors. A right-bound book shows the painting
// mirrored, the mountains on the right, so the river runs the way its pages are read: x comes
// from the other edge and a turn goes the other way. `start` is a label's own start, so the
// spring's label keeps it in Arabic and takes `end` in a label set left to right.
const halo = { color: col('paper'), width: pt(1.8) };
const labelStyles = [
  { id: 'sierra', fontFamily: DISPLAY, fontSize: pt(13), fontWeight: fw(600), color: col('ink'),
    textTransform: CAPS, letterSpacing: track(0.14), halo },
  { id: 'agua', fontFamily: TEXT, fontSize: pt(11), fontWeight: BOLD, fontStyle: SLANT,
    color: { hex: '#0b3a5c', model: 'hex' }, halo, // a name set away draws a leader to its point
    leader: { width: pt(1), endCap: 'dot', capSize: mm(1.6) } },
  { id: 'mar', fontFamily: TEXT, fontSize: pt(12), fontWeight: BOLD, fontStyle: SLANT,
    color: col('paper'), halo: { color: { hex: '#0b3a5c', model: 'hex' }, width: pt(1.8) } },
  { id: 'pueblo', fontFamily: DISPLAY, fontSize: pt(12), fontWeight: fw(600), color: col('ink'),
    halo },
  { id: 'curso', fontFamily: DISPLAY, fontSize: pt(10.5), fontWeight: fw(600), color: col('paper'),
    textTransform: CAPS, letterSpacing: track(0.08), background: col('campo'),
    padding: mm(1.6) },
];
const ANCHORS = [
  { id: 'sierra', x: 0.21, y: 0.055, style: 'sierra' },
  // The spring and the dam: the point is the place, `labelAt` where its name stands.
  { id: 'nacimiento', x: 0.049, y: 0.098, labelAt: { x: 0.075, y: 0.115 }, style: 'agua',
    align: 'start' },
  { id: 'fontalba', x: 0.135, y: 0.255, style: 'pueblo', verticalAlign: 'top' },
  { id: 'embalse', x: 0.293, y: 0.275, labelAt: { x: 0.31, y: 0.155 }, style: 'agua',
    width: 0.12 },
  { id: 'molinar', x: 0.505, y: 0.35, style: 'pueblo', verticalAlign: 'bottom' },
  { id: 'aldamar', x: 0.845, y: 0.505, style: 'pueblo', verticalAlign: 'bottom' },
  { id: 'mar', x: 0.965, y: 0.28, style: 'mar' },
  { id: 'rio', x: 0.61, y: 0.715, style: 'agua', rotate: -3 },
  { id: 'alto', x: 0.17, y: 0.45, style: 'curso' },
  { id: 'medio', x: 0.4, y: 0.77, style: 'curso' },
  { id: 'bajo', x: 0.74, y: 0.865, style: 'curso' },
];
const flip = (x) => Math.round((1 - x) * 1000) / 1000;
const flipped = (a) => ({ ...a, x: flip(a.x), ...(a.labelAt && { labelAt: { ...a.labelAt,
    x: flip(a.labelAt.x) } }),
  ...(a.rotate && { rotate: -a.rotate }), ...(a.align && !AR && { align: 'end' }) });
const anchors = RIGHT_BOUND ? ANCHORS.map(flipped) : ANCHORS;

Die Karte ist ein Gemälde ohne einen Buchstaben. Jeder Ort ist ein Anker des Bildes, ein Punkt in Bruchteilen von Breite und Höhe mit einem Beschriftungsstil, und jede Ausgabe schreibt ihre eigenen ::label-Zeilen an diese Anker. Penalta Reservoir, Pantà de Penyalta und Embalse de Peñalta stehen an derselben Stelle, und ein längerer Name bricht innerhalb der width des Ankers um. Ein rechts gebundenes Buch zeigt dasselbe Gemälde gespiegelt (mapa-1900-rtl.jpg), sodass der Fluss von den Bergen rechts zum Meer links läuft, in der Richtung, in der seine Seiten gelesen werden; flipped bringt jeden Anker und die Stelle, an der seine Beschriftung steht, auf die andere Seite und kehrt die Richtung einer Drehung um. Quelle und Stausee Peñalta stehen mit labelAt abseits ihres Ortes, und der leader des Stils agua zieht eine Linie mit einem Punkt vom Namen zur Quelle und zur Staumauer.

#6 · Jeden Teil des Inhaltsverzeichnisses zusammenhalten

script.js · Zeilen 227–246im vollständigen Code
const partAt = (x) => (CJK ? at('container', 'left', x) : at('container', START, inward(x)));
const toc = {
  levels: [{ level: 1, fontFamily: DISPLAY, fontSize: pt(15), lineHeight: pt(22),
    fontWeight: fw(500), color: col('ink'), numberFontWeight: fw(600), numberColor: col('agua'),
    numberWidth: mm(9), marginTop: pt(4) }, { level: 2, fontFamily: TEXT, fontSize: pt(11.5),
    lineHeight: pt(18), indent: mm(9), color: col('ink') }],
  pageNumber: { fontFamily: DISPLAY, fontWeight: fw(500), width: mm(9), color: col('agua') },
  leader: { char: CJK ? '…' : '.', gap: mm(1.5) },
  parts: { height: pt(34), marginTop: pt(12), marginBottom: pt(4), design: { elements: [
    { kind: 'box', id: 'band',
      placement: { ...at('container', 'top-left'), size: { width: 'fill', height: 'fill' } },
      style: { backgroundColor: col('paper'), borderRadius: mm(3) } },
    { kind: 'text', id: 'letter', content: '{number}', fontFamily: DISPLAY, fontSize: pt(16),
      fontWeight: fw(700), color: col('paper'), align: 'center',
      box: { backgroundColor: col('agua'), borderRadius: mm(4) },
      placement: { ...partAt(2), size: { width: mm(8), height: mm(8) } } },
    { kind: 'text', id: 'name', content: '{titleText}', fontFamily: DISPLAY, fontSize: pt(13),
      fontWeight: fw(600), color: col('agua'), align: START, placement: partAt(14) },
  ] } },
};

:::toc{keep="part" levels="1-2"} listet die Themen und ihre Abschnitte auf und hält jede Teilzeile bei ihren Einträgen. Ein :::part-Block mit parts.page: false ist nur eine Zeile des Verzeichnisses und ein Abschnitt für die Kolumnentitel: Er fügt keine Trennseite hinzu. Das Verzeichnis ist eine zusammengesetzte Seite: Ihre Vorlage hat einen Rahmen mit takes: "toc", der das :::toc aufnimmt und nach den Regeln des Verzeichnisses setzt, sodass Teilzeilen, Füllpunkte und keep wie im Fließtext wirken und der helle Grund die Dekoration der Vorlage ist.

Das ganze Rezept

Sandbox
// ═══ Postext Cookbook · Nº 156 · A children's textbook unit in ten languages ═════
// https://postext.dev/en/cookbook/children-textbook-pages
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Nunito, Fredoka and three pairs for Arabic, Chinese, Japanese · Needs postext ≥ 1.65.0
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
  loadVerticalAlternates,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'de'; // @lang: the language of the unit (es en ca pt fr de it ar zh ja)
const RECIPE = 'children-textbook-pages';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// One ink and three families (accent, box tint, page ground); a topic swaps the `tema` entries.
const FAMILIES = {
  agua: { main: '#1b6aa0', tint: '#e1f0fa', ground: '#d3e8f6' },
  campo: { main: '#336f27', tint: '#e5f1dc', ground: '#d9ebcb' },
  sol: { main: '#9a5209', tint: '#fcefd2', ground: '#f8e6b8' },
};
const palette = { ink: '#1d2f3f', muted: '#4f6272', rule: '#7e98ab', paper: '#ffffff',
  agua: FAMILIES.agua.main, campo: FAMILIES.campo.main, // the blue of the folios and the contents
  tema: FAMILIES.agua.main, 'tema-tint': FAMILIES.agua.tint, 'tema-ground': FAMILIES.agua.ground };
const swap = (f) => `tema=${FAMILIES[f].main}, tema-tint=${FAMILIES[f].tint}, `
  + `tema-ground=${FAMILIES[f].ground}`;
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' } })),
  { id: 'main-color', name: 'water (defaults)', value: { hex: palette.agua, model: 'hex' } },
];

// #region editions: how each language runs and is bound, and the two faces of its script
// Arabic runs right to left, Chinese and Japanese down the page, all bound on the right. Frames
// stand in the flow (x along the lines, mirrored in Arabic, down the page when vertical).
const AR = LANG === 'ar', CJK = LANG === 'zh' || LANG === 'ja';
const RIGHT_BOUND = AR || CJK, LATIN = !RIGHT_BOUND; // italics, capitals, tracking, hyphens
const [TEXT, DISPLAY] = { ar: ['Noto Naskh Arabic', 'Baloo Bhaijaan 2'], ja: ['Klee One',
  'Zen Maru Gothic'], zh: ['Noto Serif SC', 'ZCOOL KuaiLe'] }[LANG] ?? ['Nunito', 'Fredoka'];
const START = RIGHT_BOUND ? 'right' : 'left'; // the side a page starts reading from
const corner = (v) => `${v}-${START}`, inward = (x) => (RIGHT_BOUND ? -x : x);
const [SLANT, CAPS] = LATIN ? ['italic', 'uppercase'] : ['normal', 'none'];
const LEAD = AR ? 20 : CJK ? 21 : 17.5, track = (v) => (LATIN ? v : 0); // Naskh, ruby need room
const fw = (w) => ({ 'ZCOOL KuaiLe': 400, 'Zen Maru Gothic': w > 550 ? 700 : 500 })[DISPLAY] ?? w;
const BOLD = TEXT === 'Klee One' ? 600 : 700; // and the weights the faces have
// #endregion

const PAGE = { w: 210, h: 280, top: 18, bottom: 18, inner: 14, outer: 12 }; // mm, mirrored
const HALF = PAGE.w - PAGE.inner - PAGE.outer, TALL = PAGE.h - PAGE.top - PAGE.bottom; // 184, 244

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

#Eine vierte Familie hinzufügen

Ein Thema über das Meer ist ein vierter Eintrag in FAMILIES und eine Vorlage aus topic('tema-mar', 'mar', { frames }). swap('mar') schreibt seine Palette, und Kästen und Grund folgen ihr.

-  sol: { main: '#9a5209', tint: '#fcefd2', ground: '#f8e6b8' },
+  sol: { main: '#9a5209', tint: '#fcefd2', ground: '#f8e6b8' },
+  mar: { main: '#0f5a6b', tint: '#dcf0f2', ground: '#cbe6ea' },

#Den Text in seiner Größe lassen

Ein Rahmen, der seinen Text nicht verkleinern darf, bekommt fit: { shrinkText: false }. Ein längerer Text drückt dann stärker auf die Rahmen ringsum, und die Einpassstufen erreichen die Bilder früher.

   frames: [title, { name: 'texto', flow: true, columns: 2, columnGap: mm(CJK ? 16 : 7), // 段
-    width: mm(MEASURE), fit: { minScale: 0.9 } }],
+    width: mm(MEASURE), fit: { shrinkText: false } }],

Häufige Fehler

  • Ein ins Bild gemalter Name könnte sich nicht mit der Sprache ändern: Auf der Karte steht kein Wort, und jeder Name ist eine Beschriftung.
  • Die Palette eines Themas ändert nur die tema-Einträge. Die Seitenzahlen und das Inhaltsverzeichnis nutzen agua, das dasselbe Blau hat; sie bleiben auf den grünen und sandfarbenen Seiten blau. Verknüpfen Sie sie mit tema, dann folgen sie dem Thema.
  • Eine arabisch-indische Ziffer neben einem Mittelpunkt liest sich als zwei Ziffern: ١ · ماء sieht aus wie ٠١ ماء, weil die arabische Null ein Punkt ist. Die arabische Ausgabe schreibt ١- ماء للحقول und schreibt die Nummer der Einheit aus.
  • Ein Dekorationselement steht auf dem Blatt, nicht im Fluss: Ein Badge, das top-left an einem Rahmen sitzt, bleibt im Arabischen links. corner('top') und inward(x) setzen es von der Seite aus, an der das Lesen der Seite beginnt.
  • In einem Raster ist jedes Element ein eigener Block: Das Bild eines Kastens gehört nur dann zu dessen Satz, wenn sein :::figure innerhalb des :::frame des Kastens steht. Steht es dahinter, ist das Bild ein eigenes Element und bekommt eine eigene Zelle.
  • Zwei Abbildungen, die dieselbe Ressource belegen, übernehmen die Worte der ersten: Die kleine Karte auf der Inhaltsseite ist dieselbe Datei unter einer eigenen Ressource, rio, ohne Anker.

Nachweise

Text
  • Our river, a children's textbook unit written for this recipe in Spanish and set in ten languages · Postext Cookbook · CC BY 4.0
Bilder
  • The valley of the River Aldara, painted from the mountains to the sea, with two children watching the water. · Generated With Diffusion Models · eigener Text
  • The painted map of the valley, from the spring to the port, with no lettering: the names are labels set from the Markdown. · Generated With Diffusion Models · eigener Text
  • The same painted map mirrored, the mountains on the right, for the books bound on the right (Arabic, Chinese, Japanese). · Generated With Diffusion Models · eigener Text
  • A spring between mossy rocks. · Generated With Diffusion Models · eigener Text
  • A mountain stream over round stones. · Generated With Diffusion Models · eigener Text
  • A small waterfall into a green pool. · Generated With Diffusion Models · eigener Text
  • A farmer opening the gate of an irrigation canal. · Generated With Diffusion Models · eigener Text
  • An old stone watermill with its wheel. · Generated With Diffusion Models · eigener Text
  • Children paddling canoes on a calm river. · Generated With Diffusion Models · eigener Text
  • Children and a teacher picking up litter on a river bank. · Generated With Diffusion Models · eigener Text
Schriften
Nunito (SIL OFL 1.1) · Fredoka (SIL OFL 1.1) · Noto Naskh Arabic (SIL OFL 1.1) · Baloo Bhaijaan 2 (SIL OFL 1.1) · Klee One (SIL OFL 1.1) · Zen Maru Gothic (SIL OFL 1.1) · Noto Serif SC (SIL OFL 1.1) · ZCOOL KuaiLe (SIL OFL 1.1)
SandboxPDF