かんたんな説明
歴史の教科書の向かい合う二ページを一枚のように組みます。色の帯が本の真ん中を横切り、画像の付いた六枚のカードがそこからつり下がります。テンプレートに描くのは、日付がいくつあってもカード一枚と線一本です。
できあがり
中学校の歴史の教科書の48・49ページ、「紙がたどった道」です。蔡倫の工房からケラーの砥石まで、紙すきの千年をたどります。左ページは題名と二つの段落で始まり、右ページは手すき紙の作り方を説明する囲みで始まります。真ん中を年表が横切ります。アジアは藍色の帯、ヨーロッパは赤茶の帯で、赤茶の帯は左ページから始まってのどをまたぎます。その下に、画像の付いたカードが六枚、輪と線で帯からつり下がっています。テンプレートにあるのは、アジアのカード一枚、ヨーロッパのカード一枚、帯ごとのコネクタ一本だけです。グリッドがMarkdownの日付ごとにカードを置き、コネクタはグリッドが置いたカードをすべて見つけます。文字はすべてMarkdownにあり、スペイン語、英語、日本語の三版があります。このページは日本語版です。
このレシピが答える質問
- のどをまたぐ帯と左右のページのカードで、見開きの年表を組むには?
- 横に並んだ囲みで幅を分け合い、文章のいちばん長い囲みを広くするには?
手短な答え
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')] },
}];
材料
- 機能
- 見開きのテンプレート枠を繰り返すグリッド枠をつなぐコネクターテンプレートページグループの中で伸びる枠枠に固定した飾り番号付きの囲みのタブ囲みデザイン要素の基準位置柱とノンブル見開きの余白番号付きリスト中国語・日本語・韓国語のフォントセマンティックカラーパレットキャンバス上のページPDFの書き出し
- 種類
- Literata, Archivo, Noto Serif JP, Noto Sans JP (SIL OFL 1.1)
- 素材
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, オリジナル)
- A monk shows two Japanese courtiers how to hold a papermaking mould. (Generated With Diffusion Models, オリジナル)
- Papermakers by a canal in Samarkand, sheets drying on a wall. (Generated With Diffusion Models, オリジナル)
- A paper workshop below the castle of Xàtiva. (Generated With Diffusion Models, オリジナル)
- A Fabriano mill with its water wheel; a sheet held up to the light. (Generated With Diffusion Models, オリジナル)
- A craftsman grinds a spruce log against a stone into wood pulp. (Generated With Diffusion Models, オリジナル)
- Two hands lift a papermaker's mould from a vat of pulp. (Generated With Diffusion Models, オリジナル)
作り方
#1 · 二ページで一枚のシート
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でテンプレートは二ページ分の幅の一枚のシートになり、ページのブロックもspreadで同じことを示します。見開きは左ページから始まるので、ビルドにcontinuation: { pageIndexOffset: 1, pageNumbering: { startAt: 48 } }を渡します。この抜粋の1ページ目は本の48ページ、左ページになり、前に白ページは入りません。グリッドは一ページに一列で、列の間はのど側の余白の二倍です。のどに近づくのは帯だけです。二本目の帯はcrossGutterと左の36mmの余白を取ります。色は一本目の帯の端から続いてのどをまたぎ、文字は右ページから始まります。文字が読まれるのも右ページです。
#2 · グリッドが繰り返す一枚のカード
// 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] } });
kind: 'grid'にrepeat: { frames: ['asia'] }を指定したグループは、ページにある:::frame{slot="asia"}の数だけasiaの枠を置きます。一行に三枚、テンプレートのグリッドのcol: 1のセル、6行目から12行目までです。複製の名前は#asia[1]、#asia[2]、#asia[3]で、それぞれ自分のブロックのlabel、つまりタブの年を受け取ります。カードの高さは最低minHeightで、それより上はautoです。スペイン語版と日本語版の1844年のように文章が長くなると、その行が高くなり、同じ行のほかのカードも同じ高さまで伸びます(rowAlignの既定値は'stretch'です)。Markdownに四つ目の日付を足すと一行目の下に二行目ができ、テンプレートは変わりません。
#3 · 帯ごとに一本のコネクタ
// `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) };
}
線は、テンプレートの装飾(decoration)に帯ごとに一本ずつ置いたconnectorです。routing: 'tree'は一つの親を多くの子につなぎます。trunk: 0では自分の横棒を描かず、帯の下端から各カードの上端の中央へまっすぐ線を下ろすだけです。startCap: 'ring'は各線の頭、帯の2.4mm下(gap)に輪を置きます。輪は線の太さで描いた中の空いた点で、外側の差し渡しは3.6mm(capSize)です。線は輪の外周で止まるので、輪の中にはクリーム色の地が見えます。#asia[*]はグリッドがそのページに置いたすべてのカードを指すので、Markdownで日付を足したり消したりすると、その線も増えたり減ったりします。コネクタは枠を置いたあとに配置されるので、行が高くなっても線はカードに届きます。クリーム色の地も装飾で、塗り足しの下端に固定した箱です。高さは#band-1の下端まで届くので(size: { height: { to: '#band-1', edge: 'bottom' } })、帯に付いて動きます。
#4 · 印刷の大きさで置く絵
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] } };
}));
挿絵は幅1,000px、550ppiで、ページ上では46mmです。画像は拡大されません。グリッドの三つの等幅の列は各ページで56.3mmなので、どの画像もカードの3.5mmの余白の内側にそのままの大きさで収まり、残りは文章に使われます。
レシピの全体
// ═══ 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 = 'ja'; // @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
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#一行に四枚並べる
columns: 4にすると、帯ごとに四つの日付が横に並びます。カードが狭くなって文章の行数が増え、行は下へ伸びます。
-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),#輪の代わりに矢印を付ける
endCap: 'arrow'で各線がカードに届くところに矢じりが付き、startCap: 'none'で輪が消えます。
よくあるつまずき
- グリッドは項目ごとにセルを一つ置き、項目とは一つずつ独立した
:::frame{slot="asia"}ブロックです。二枚分の文章を一つのブロックに入れると、カードは一枚になります。 [*]の付かない#asiaはグリッドの箱で、カードではありません。そこへつないだコネクタは、行の中央へ線を一本下ろすだけです。- 別の箱の端まで届く大きさは、要素自身の固定点から数えます。クリーム色の地は塗り足しの下端に固定し、上へ
#band-1まで伸びます。固定点の後ろにある端は、高さ0になります。
クレジット
- 本文
- The paper road, a double-page timeline written for this recipe in Spanish, English and Japanese · Postext Cookbook · CC BY 4.0
- 画像
- A Han court official watches a craftsman lift a bamboo mould from a vat. · Generated With Diffusion Models · オリジナル
- A monk shows two Japanese courtiers how to hold a papermaking mould. · Generated With Diffusion Models · オリジナル
- Papermakers by a canal in Samarkand, sheets drying on a wall. · Generated With Diffusion Models · オリジナル
- A paper workshop below the castle of Xàtiva. · Generated With Diffusion Models · オリジナル
- A Fabriano mill with its water wheel; a sheet held up to the light. · Generated With Diffusion Models · オリジナル
- A craftsman grinds a spruce log against a stone into wood pulp. · Generated With Diffusion Models · オリジナル
- Two hands lift a papermaker's mould from a vat of pulp. · Generated With Diffusion Models · オリジナル
- フォント
- Literata (SIL OFL 1.1) · Archivo (SIL OFL 1.1) · Noto Serif JP (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1)


