In breve
Due pagine affiancate di un libro di storia fatte come una sola: una fascia colorata attraversa il centro del libro, sei schede illustrate vi sono appese, e il modello disegna una sola scheda e una sola linea, quante che siano le date.
Che cosa comporrai
Le pagine 48 e 49 di un libro di storia per la scuola media: La via della carta, mille anni di mestiere dalla bottega di Cai Lun alla mola di Keller. La pagina di sinistra apre con il titolo e due paragrafi, quella di destra con un riquadro che racconta come si faceva un foglio a mano. Al centro corre la linea del tempo: una fascia indaco per l’Asia e una color terracotta per l’Europa, che parte dalla pagina di sinistra e attraversa il dorso. Sotto, sei schede con il loro disegno, appese alla fascia con un anello e un tratto. Il modello disegna una scheda asiatica, una europea e un connettore per fascia: una griglia colloca una scheda per ogni data del Markdown e il connettore trova tutte le schede che la griglia ha collocato. Tutte le parole sono nel Markdown, in spagnolo, inglese e giapponese; questa pagina mostra l’edizione inglese.
Questa ricetta risponde a
- Come impagino una linea del tempo su una doppia pagina, con una fascia che attraversa il dorso e schede su entrambe le pagine?
- Come faccio a far dividere la larghezza a una fila di riquadri, così che quello col testo più lungo si allarghi?
La risposta breve
const pageTemplates = [{
id: 'timeline',
spread: true, // two facing pages laid as one sheet; it opens on a verso
gutter: mm(10), // the band round the spine that frames keep off
grid: { columns: 2, rows: ROWS, columnGap: mm(2 * PAGE.inner), rowGap: mm(ROW_GAP) },
frames: [
{ name: 'title', takes: 'h1' },
{ name: 'lead', flow: true, fit: { minScale: 0.8 } },
{ name: 'box', style: 'box', grid: { col: 2, row: 1, rows: 4 }, height: 'fill',
padding: { right: mm(66) }, fit: { minScale: 0.85 } },
{ name: 'box-picture', layer: 2, width: mm(56), placement: at('#box', 'top-right', -5, 10) },
{ name: 'band-1', style: 'band-asia', grid: { col: 1, row: 5 }, height: mm(BAND) },
{ name: 'band-2', style: 'band-europe', crossGutter: true, width: 'fill', height: mm(BAND),
padding: { left: mm(2 * PAGE.inner + 4) }, // the colour crosses the fold, the words do not
placement: at('#band-1', 'right-of') },
card('asia', 'card-asia'), card('europe', 'card-europe'),
{ name: 'colophon', style: 'colophon', optional: true, width: mm(170),
placement: at('page', 'bottom-right', -PAGE.outer, -7) },
],
groups: [
{ name: 'opening', kind: 'stack', grid: { col: 1, row: 1, rows: 4 }, gap: mm(4),
frames: ['title', 'lead'] },
// A row of cards under each band, as many as the Markdown has: a longer text makes its
// row taller, and the other cards of the row stretch to the same height.
row('asia', 1), row('europe', 2),
],
decoration: { elements: [ground(), ticks('band-1', 'asia'), ticks('band-2', 'europe')] },
}];
Ingredienti
- Funzionalità
- Modelli su doppia paginaGriglie che ripetono corniciConnettori tra corniciPagine composteRiquadri che crescono in un gruppoDecorazione ancorata alle corniciLinguette numerate dei riquadriRiquadriAncoraggio degli elementi del progettoTestatine e folioMargini speculariElenchi numeratiFont cinesi, giapponesi e coreaniTavolozza di colori semanticaPagine su un canvasEsportazione in PDF
- Usa anche
- Figure proprio quiFont incorporati nel PDFTipi di risorsa personalizzatiFigure e tabelle come risorse
- Tipo
- Literata, Archivo, Noto Serif JP, Noto Sans JP (SIL OFL 1.1)
- Risorse
forma-800.jpgv105-1000.jpgv1150-1000.jpgv1282-1000.jpgv1844-1000.jpgv610-1000.jpgv751-1000.jpg- A Han court official watches a craftsman lift a bamboo mould from a vat. (Generated With Diffusion Models, originale)
- A monk shows two Japanese courtiers how to hold a papermaking mould. (Generated With Diffusion Models, originale)
- Papermakers by a canal in Samarkand, sheets drying on a wall. (Generated With Diffusion Models, originale)
- A paper workshop below the castle of Xàtiva. (Generated With Diffusion Models, originale)
- A Fabriano mill with its water wheel; a sheet held up to the light. (Generated With Diffusion Models, originale)
- A craftsman grinds a spruce log against a stone into wood pulp. (Generated With Diffusion Models, originale)
- Two hands lift a papermaker's mould from a vat of pulp. (Generated With Diffusion Models, originale)
Preparazione
#1 · Un foglio per due pagine
const pageTemplates = [{
id: 'timeline',
spread: true, // two facing pages laid as one sheet; it opens on a verso
gutter: mm(10), // the band round the spine that frames keep off
grid: { columns: 2, rows: ROWS, columnGap: mm(2 * PAGE.inner), rowGap: mm(ROW_GAP) },
frames: [
{ name: 'title', takes: 'h1' },
{ name: 'lead', flow: true, fit: { minScale: 0.8 } },
{ name: 'box', style: 'box', grid: { col: 2, row: 1, rows: 4 }, height: 'fill',
padding: { right: mm(66) }, fit: { minScale: 0.85 } },
{ name: 'box-picture', layer: 2, width: mm(56), placement: at('#box', 'top-right', -5, 10) },
{ name: 'band-1', style: 'band-asia', grid: { col: 1, row: 5 }, height: mm(BAND) },
{ name: 'band-2', style: 'band-europe', crossGutter: true, width: 'fill', height: mm(BAND),
padding: { left: mm(2 * PAGE.inner + 4) }, // the colour crosses the fold, the words do not
placement: at('#band-1', 'right-of') },
card('asia', 'card-asia'), card('europe', 'card-europe'),
{ name: 'colophon', style: 'colophon', optional: true, width: mm(170),
placement: at('page', 'bottom-right', -PAGE.outer, -7) },
],
groups: [
{ name: 'opening', kind: 'stack', grid: { col: 1, row: 1, rows: 4 }, gap: mm(4),
frames: ['title', 'lead'] },
// A row of cards under each band, as many as the Markdown has: a longer text makes its
// row taller, and the other cards of the row stretch to the same height.
row('asia', 1), row('europe', 2),
],
decoration: { elements: [ground(), ticks('band-1', 'asia'), ticks('band-2', 'europe')] },
}];
spread: true fa del modello un solo foglio largo come le due pagine, e il blocco di pagina lo indica con spread. Una doppia pagina comincia su una pagina pari, perciò la composizione riceve continuation: { pageIndexOffset: 1, pageNumbering: { startAt: 48 } }: la pagina 1 di questo estratto è la 48 del libro, una pagina di sinistra, e non serve una pagina bianca davanti. La griglia ha una colonna per pagina, separate dal doppio del margine interno, così solo la fascia arriva vicino alla piega. La seconda fascia ha crossGutter e 36 mm di spaziatura a sinistra: il suo colore parte dalla fine della prima e attraversa il dorso, le sue parole cominciano sulla pagina di destra, dove l’impaginazione le legge.
#2 · Una scheda, ripetuta da una griglia
// Each `:::frame{slot="asia"}` of the page is an item of the `asia` grid: the grid lays the
// card frame once per item, three to a row, and names the copies `#asia[1]`, `#asia[2]`…
const card = (name, style) => ({ name, style, minHeight: mm(CARD) }); // auto above that height
const row = (name, col) => ({ name: `${name}-row`, kind: 'grid', columns: 3, columnGap: mm(5),
grid: { col, row: 6, rows: ROWS - 5 }, repeat: { frames: [name] } });
Un gruppo kind: 'grid' con repeat: { frames: ['asia'] } colloca la cornice asia una volta per ogni :::frame{slot="asia"} della pagina, tre per fila, nella cella col: 1 della griglia del modello, righe da 6 a 12. Le copie si chiamano #asia[1], #asia[2] e #asia[3], e ognuna prende il label del proprio blocco, la data della sua linguetta. Una scheda è alta almeno minHeight e sopra quella è auto: quando un testo si allunga, come quello del 1844 in spagnolo e in giapponese, la sua fila cresce e le altre schede della fila si allungano fino alla stessa altezza (rowAlign vale 'stretch' se non si indica altro). Una quarta data nel Markdown apre una seconda fila sotto la prima, senza toccare il modello.
#3 · Un connettore per fascia
// `routing: 'tree'` with `trunk: 0` draws no bar of its own: each drop hangs from the band's
// foot straight down to the middle of a card's top, and `#asia[*]` names every card laid.
function ticks(band, cards) {
return { kind: 'connector', id: `${cards}-ticks`, routing: 'tree', trunk: 0,
from: { to: `#${band}`, side: 'bottom', gap: mm(2.4) }, to: { to: `#${cards}[*]`, side: 'top' },
color: col(cards), width: pt(1), startCap: 'ring', capSize: mm(3.6) };
}
I tratti sono un connector per fascia nella decorazione (decoration) del modello. routing: 'tree' unisce un genitore a molti figli; con trunk: 0 non disegna una barra propria, solo un tratto dritto dal piede della fascia al centro del bordo superiore di ogni scheda, e startCap: 'ring' mette un anello in testa a ogni tratto, 2,4 mm sotto la fascia (gap). L’anello è un punto vuoto tracciato nello spessore della linea, largo 3,6 mm da bordo a bordo (capSize), e il tratto si ferma al suo bordo: nel foro si vede il fondo crema. #asia[*] indica tutte le schede che la griglia ha collocato sulla pagina, quindi una data aggiunta o tolta nel Markdown aggiunge o toglie il suo tratto. I connettori si collocano dopo le cornici: quando una fila cresce, i tratti arrivano comunque alle schede. Anche il fondo crema è decorazione, un riquadro ancorato al piede dell’abbondanza la cui altezza arriva fino al piede di #band-1 (size: { height: { to: '#band-1', edge: 'bottom' } }): segue la fascia.
#4 · Disegni alla misura di stampa
const ART = {
v105: t({ es: 'Un funcionario de la corte Han mira cómo un artesano saca de la tina un molde '
+ 'de bambú lleno de pasta, junto a corteza, trapos y redes viejas.',
en: 'A Han court official watches a craftsman lift a bamboo mould full of pulp from a vat, '
+ 'beside bark, rags and old nets.',
ja: '漢の役人が見守るなか、職人が竹のすき枠を漉き舟から引き上げる。そばに樹皮、ぼろ布、古い網。' }),
v610: t({ es: 'Un monje enseña a dos cortesanos japoneses a sostener el molde sobre una tina, '
+ 'con ramas de kozo en una estera.',
en: 'A monk shows two Japanese courtiers how to hold the mould over a tub, with kozo '
+ 'branches on a mat.',
ja: '僧が二人の宮廷人に、桶の上ですき枠を持つ手つきを見せる。むしろの上に楮の枝。' }),
v751: t({ es: 'Papeleros de Samarcanda junto a un canal; las hojas se secan al sol contra un '
+ 'muro de adobe.',
en: 'Samarkand papermakers by a canal; the sheets dry in the sun against a mud-brick wall.',
ja: '水路のそばで働くサマルカンドの紙すき職人。日干しれんがの壁に紙が張られて乾いている。' }),
v1150: t({ es: 'Un taller de Xàtiva bajo el castillo: un operario golpea trapos en una pila '
+ 'de piedra y las hojas cuelgan de cuerdas.',
en: 'A workshop in Xàtiva below the castle: a worker pounds rags in a stone trough and the '
+ 'sheets hang on ropes.',
ja: '城の下のシャティバの工房。職人が石の槽でぼろ布をたたき、紙が綱につるされている。' }),
v1282: t({ es: 'Un molino de Fabriano con su rueda hidráulica y sus mazos; un papelero mira '
+ 'una filigrana al trasluz.',
en: 'A Fabriano mill with its water wheel and hammers; a papermaker holds a watermark up '
+ 'to the light.',
ja: '水車と木づちのあるファブリアーノの製紙場。職人が紙を光にかざして透かしを見ている。' }),
v1844: t({ es: 'Un artesano aprieta un tronco de abeto contra una muela que gira; debajo se '
+ 'amontonan las fibras.',
en: 'A craftsman presses a spruce log against a turning grindstone; the fibres pile up '
+ 'below.',
ja: '職人がトウヒの丸太を回る砥石に押し当て、その下に木の繊維が積もっていく。' }),
forma: t({ es: 'Dos manos sacan de la tina el molde con una capa fina de fibras.',
en: 'Two hands lift the mould from the vat with a thin layer of fibres on it.',
ja: '両手ですき枠を引き上げる。網の上に繊維の薄い層ができている。' }),
};
const SIZE = { forma: [800, 800, 363] }; // pixels and ppi: 56 mm wide; the cards' are 46 mm
const resources = await Promise.all(Object.entries(ART).map(async ([id, altText]) => {
const px = SIZE[id] ?? [1000, 667, 550];
const fileId = `${id}-${px[0]}.jpg`;
await loadImage(fileId, asset(fileId));
return { id, typeId: 'picture', kind: 'bitmap', caption: '', altText, createdAt: 0,
updatedAt: 0,
bitmap: { fileId, format: 'jpeg', width: px[0], height: px[1], resolution: px[2] } };
}));
Le vignette sono larghe 1.000 px a 550 ppi, 46 mm sulla pagina, e un’immagine non viene mai ingrandita. Le tre colonne uguali della griglia sono larghe 56,3 mm su ogni pagina, così ogni disegno entra alla sua misura nei 3,5 mm di spaziatura interna della sua scheda e il resto della scheda è testo.
La ricetta completa
// ═══ Postext Cookbook · Nº 158 · An illustrated timeline across a double page ═══════
// https://postext.dev/en/cookbook/illustrated-timeline-spread
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Literata, Archivo, Noto Serif JP, Noto Sans JP (SIL OFL 1.1) · Needs postext ≥ 1.49.0
import {
buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the sample document ('es' | 'en' | 'ja')
const RECIPE = 'illustrated-timeline-spread';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: one ink, an accent for each half of the timeline, a pale ground
const palette = {
ink: '#22201d', // text
asia: '#2f4f7a', // indigo: the Asian half of the timeline
europe: '#a2412a', // terracotta: the European half
ground: '#f1ebdf', // the cream under the cards
rule: '#c9bfae', // hairlines and the card borders
muted: '#6b6359', // running heads and the colophon
paper: '#ffffff',
};
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: 'europe (defaults)', value: { hex: palette.europe, model: 'hex' } },
];
// #endregion
const JA = LANG === 'ja';
const SERIF = JA ? 'Noto Serif JP' : 'Literata';
const SANS = JA ? 'Noto Sans JP' : 'Archivo';
// A Western textbook page is 210 × 280 mm; a Japanese one is AB判, 210 × 257 mm.
const PAGE = { w: 210, h: JA ? 257 : 280, top: 22, bottom: 20, inner: 16, outer: 15 };
const ROWS = 12;
const ROW_GAP = 3;
const ROW = (PAGE.h - PAGE.top - PAGE.bottom - (ROWS - 1) * ROW_GAP) / ROWS; // one grid row, mm
const BAND = 9; // the timeline band, in grid row 5
const CARD_TOP = 5 * (ROW + ROW_GAP); // grid row 6
// The drawn height of a card; 16 mm of the area stay free for a longer text.
const CARD = PAGE.h - PAGE.top - PAGE.bottom - CARD_TOP - 16;
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
// #region cards: one card frame per row, repeated by a grid once for each card of the Markdown
// Each `:::frame{slot="asia"}` of the page is an item of the `asia` grid: the grid lays the
// card frame once per item, three to a row, and names the copies `#asia[1]`, `#asia[2]`…
const card = (name, style) => ({ name, style, minHeight: mm(CARD) }); // auto above that height
Lo script.js composto funziona così com’è: incollalo nello script modulo di qualsiasi pagina, oppure apri la ricetta su CodePen. Cartella della ricetta su GitHub ↗ (si apre in una nuova scheda)
Varianti
#Quattro schede per fila
Con columns: 4 ogni fascia porta quattro date una accanto all’altra; le schede sono più strette, i loro testi occupano più righe e le file crescono verso il basso.
-const row = (name, col) => ({ name: `${name}-row`, kind: 'grid', columns: 3, columnGap: mm(5),
+const row = (name, col) => ({ name: `${name}-row`, kind: 'grid', columns: 4, columnGap: mm(5),#Frecce al posto degli anelli
endCap: 'arrow' mette una punta di freccia dove ogni tratto arriva alla sua scheda, e startCap: 'none' toglie gli anelli.
Errori frequenti
- Una griglia colloca una cella per elemento, e un elemento è un blocco
:::frame{slot="asia"}a sé: i testi di due schede dentro lo stesso blocco fanno una sola scheda. #asiasenza[*]è il riquadro della griglia, non le sue schede: un connettore verso di esso disegna un solo tratto fino al centro della fila.- Una misura che arriva fino al bordo di un altro riquadro si conta dal punto di ancoraggio dell’elemento: il fondo è ancorato al piede dell’abbondanza e cresce verso l’alto fino a
#band-1. Un bordo dietro il punto di ancoraggio dà un’altezza di 0.
Crediti
- Ricetta
- Ignacio Ferro
- Testo
- The paper road, a double-page timeline written for this recipe in Spanish, English and Japanese · Postext Cookbook · CC BY 4.0
- Immagini
- A Han court official watches a craftsman lift a bamboo mould from a vat. · Generated With Diffusion Models · originale
- A monk shows two Japanese courtiers how to hold a papermaking mould. · Generated With Diffusion Models · originale
- Papermakers by a canal in Samarkand, sheets drying on a wall. · Generated With Diffusion Models · originale
- A paper workshop below the castle of Xàtiva. · Generated With Diffusion Models · originale
- A Fabriano mill with its water wheel; a sheet held up to the light. · Generated With Diffusion Models · originale
- A craftsman grinds a spruce log against a stone into wood pulp. · Generated With Diffusion Models · originale
- Two hands lift a papermaker's mould from a vat of pulp. · Generated With Diffusion Models · originale
- Font
- Literata (SIL OFL 1.1) · Archivo (SIL OFL 1.1) · Noto Serif JP (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1)
- Codice
- MIT, come Postext
Modifica questo testo ↗ (si apre in una nuova scheda)Cartella della ricetta su GitHub ↗ (si apre in una nuova scheda)


