かんたんな説明
テンプレートから組む四ページの雑誌記事。文章はひとりでに次の段へ、さらに新しいページへ流れ、引用と写真の輪郭をよけて組まれます。
できあがり
架空の都市生活季刊誌『Patio』の46〜49ページ。三十年勤めた印刷所の屋上で十四箱の蜜蜂を飼う、引退した植字工の特集です。巻頭見開きの左ページは写真で、見出しは屋上の砂利の上に、数字を並べた色付きの囲みは空に置きます。右ページにはリードと最初の二段。段間には引用がまたがり、背景を切り抜いた麦わらの巣箱が立っていて、二段目の行はそのドームの形に沿って組まれます。そのあと記事は必要なだけページを使い、一ページ三段で、終わるところで終わります。スペイン語、英語、ドイツ語の版は同じテンプレートに別の言葉を入れたもので、ドイツ語は長い複合語を60mmの段に通します。
このレシピが答える質問
- 雑誌の記事を、つないだ枠に流して何ページにもわたって続けるには?
- 雑誌をセクションに分けて組み、各記事を見開きで始めて向かいのページにリード写真を置くには?
- Postextは3段以上の段組みや、画像の周りへの回り込みに対応していますか?
手短な答え
const opening = {
id: 'apertura',
spread: true,
header: false,
frames: [
{ name: 'titulo', takes: 'h1', layer: 2, width: mm(150),
placement: at('container', 'bottom-left', 4, -14) },
{ name: 'datos', style: 'datos', layer: 2, width: mm(64),
placement: at('container', 'top-left', 4, 6) },
{ name: 'entradilla', width: mm(2 * COLUMN + GAP),
placement: at('container', 'top-left', RECTO) },
// The story names no slot, so it goes to the flow frame, then on down the chain.
{ name: 'col-1', flow: true, next: 'col-2', width: mm(COLUMN), height: 'fill',
placement: at('#entradilla', 'below', 0, 7) },
// What the last column cannot hold goes on to a page added after the spread.
{ name: 'col-2', width: mm(COLUMN), height: 'fill',
placement: at('#col-1', 'right-of', GAP),
overflow: { continueIn: 'template:seguido' } },
...pushers,
],
decoration: { elements: [
{ kind: 'image', id: 'foto', resourceId: '{attr.foto}',
fit: 'cover',
placement: { ...at('bleed', 'top-left'), size: { width: mm(W), height: 'fill' } } },
{ kind: 'text', id: 'seccion', content: '{attr.seccion}', fontFamily: SANS, fontSize: pt(9),
fontWeight: 700, letterSpacing: pt(2), textTransform: 'uppercase', color: col('paper'),
placement: at('#titulo', 'above', 0, -3) },
] },
};
材料
- 機能
- 連結したテキスト枠テキストを押しのける枠(矩形または輪郭)テンプレートページ見開きの余白ページデザインの画像ハイフネーションと文書の言語柱とノンブル段落スタイル章扉のドロップキャップ囲みセマンティックカラーパレットリソースとしての図と表キャンバス上のページPDFの書き出し
- 種類
- Literata, Fraunces, Instrument Sans (SIL OFL 1.1)
- 素材
rooftop-1400.jpgskep-720.png- Painted hives on a factory roof at sunrise (the opening spread) (Generated With Diffusion Models, オリジナル)
- A straw bee skep on a transparent ground (the cut-out the text runs round) (Generated With Diffusion Models, オリジナル)
作り方
#1 · 一つのテンプレートに一つの記事
コードは上の手短な答えにあります。特集全体が1つの::::page{template="apertura" spread}ブロックです。見出しはtakes: 'h1'の枠へ、数字とリードはそれぞれのスロットへ、スロットを指定しないそれ以外の内容はすべて流し込み枠col-1へ入ります。col-1がいっぱいになると文章はcol-2に続き、その幅で改めて行分けされます。col-2に収まらない分は、切れたところに Continúa の文字を置いてから、見開きの後ろに追加されるページへ続きます(overflow.continueIn: 'template:seguido')。文章は段もページも指定しません。段落を一つ削れば、後ろの行がすべて前へ戻ります。
#2 · 記事が追加するページ
// The third column continues into this same template: the story goes on in the frame its
// chain starts in, so every added page fills all three columns.
const seguido = {
id: 'seguido',
frames: [
{ name: 'seguido-1', flow: true, next: 'seguido-2', height: 'fill', width: mm(60.3) },
{ name: 'seguido-2', next: 'seguido-3', height: 'fill', width: mm(60.3),
placement: at('#seguido-1', 'right-of', 5) },
{ name: 'seguido-3', height: 'fill', width: mm(60.3),
placement: at('#seguido-2', 'right-of', 5),
overflow: { continueIn: 'template:seguido' } },
],
};
追加ページはどれも、幅60.3mmの段を三つつないだもので、テンプレートはすべてのページで一つです。三段目は同じテンプレートへ続き、記事は連鎖の先頭の枠seguido-1から再開します。何ページ要っても、各ページで三段すべてが埋まります。文字サイズを固定する設定も要りません。別のページへ続ける枠は、文字を縮める前に続きへ送るので、五行あふれた記事は最後のページで92.5%に縮むのではなく、新しいページを得ます。
#3 · 段を押しのける二つの枠
const pushers = [
// The pull quote straddles the gutter: each column loses the side it covers.
{ name: 'cita', style: 'cita', exclude: 'push', width: mm(62),
placement: at('#entradilla', 'below', COLUMN - 27.5, 82) },
// The skep's frame pushes with the shape of its picture, read from the PNG's alpha.
{ name: 'recorte', exclude: 'push', wrap: 'contour', layer: 2, width: mm(58),
placement: at('container', 'bottom-right', 9, -8) },
];
どちらの枠も記事の一部ではなく、重なった段の行を押しのけるだけです。引用はリードから82mm下に固定されて段間にまたがるので、一段目は右側を、二段目は左側を削られます。巣箱の枠にはwrap: 'contour'が付いています。その横の行は、その高さでの画像の幅に2.5mmの間隔を足した分だけ短く組まれるので、二段目はドームに沿って流れ、底より下ではまた全幅に戻ります。
#4 · 画像といっしょに運ばれる輪郭
const photo = { id: 'azotea', typeId: 'foto', kind: 'bitmap', createdAt: 0, updatedAt: 0,
caption: '', altText: t({
es: 'Seis colmenas de colores en la azotea de una fábrica, con la ciudad al amanecer',
en: 'Six painted hives on a factory roof, with the city behind them at sunrise',
de: 'Sechs bunte Bienenkästen auf einem Fabrikdach, dahinter die Stadt im Morgenlicht' }),
bitmap: { fileId: 'rooftop-1400.jpg', format: 'jpeg', width: 1400, height: 1848 } };
let skep = { id: 'cesto', typeId: 'foto', kind: 'bitmap', createdAt: 0, updatedAt: 0,
caption: '', altText: t({ es: 'Un cesto de paja para abejas', en: 'A straw bee skep',
de: 'Ein Bienenkorb aus Stroh' }),
contour: { threshold: 0.5, margin: mm(2.5) },
bitmap: { fileId: 'skep-720.png', format: 'png', width: 720, height: 828 } };
await loadImage('rooftop-1400.jpg', asset('rooftop-1400.jpg'));
await loadImage('skep-720.png', asset('skep-720.png'));
// The layout reads pictures by size, never by pixels: the outline travels as a trace.
const trace = await traceResourceContour(skep, imageBytes('skep-720.png'), 'image/png');
skep = withContourTrace(skep, trace);
const resources = [photo, skep];
レイアウトが使うのは画像の大きさだけで、ピクセルは見ません。そのため輪郭はtraceResourceContourでPNGのアルファチャンネルから一度だけ取り出し、contour.tracedとしてリソースに持たせます。巣箱は720px、200色、背景透明のPNG(225KB)です。左ページの写真は装飾の画像resourceId: '{attr.foto}'で、どの写真にするかはページブロックが、どこに置くかはテンプレートが決めます。fit: 'cover'を付けてあるので、写真の縦横比にかかわらず左ページを埋め、枠からはみ出した部分は切り取られます。
#5 · フェンスから読む柱
const head = (id, content, parity, edge, x, extra = {}) => ({
kind: 'text', id, content, parity, fontFamily: SANS, fontSize: pt(7.5), fontWeight: 600,
letterSpacing: pt(1.2), textTransform: 'uppercase', color: col('muted'),
placement: at('page', edge, x, 11), ...extra,
});
const folio = { fontWeight: 700, color: col('honey') };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUT, folio),
head('verso-title', '{title}', 'even', 'top-left', OUT + 9),
head('recto-title', '{attr.seccion}', 'odd', 'top-right', -(OUT + 9)),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUT, folio),
] };
巻頭の見開きには柱を出しません(header: false)。追加ページでは左ページに誌名、右ページにセクション名が入ります。セクション名はページブロックのseccion="Ciudad"から来ていて、{attr.seccion}は記事が追加したページでも見開きと同じ値を参照します。
レシピの全体
// ═══ Postext Cookbook · Nº 160 · A magazine feature threaded through frames ═════
// https://postext.dev/en/cookbook/magazine-threaded-frames
// Code: MIT · Text: original (CC BY 4.0) · Pictures: Generated With Diffusion Models
// Fonts: Literata, Fraunces, Instrument Sans (SIL OFL 1.1) · Needs postext ≥ 1.65.0
//
// A six-page feature of an invented city magazine, set as one composed page: an opening
// spread whose frames are drawn in the config, and pages the text adds as it runs on.
// Every word, the photo's id and the section name are in content.<lang>.md.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
traceResourceContour, withContourTrace,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'es'; // @lang: the language of the sample document ('es' | 'en' | 'de')
const RECIPE = 'magazine-threaded-frames';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: honey on warm paper, every colour linked by id
const palette = {
ink: '#211c18', // text
honey: '#a65a12', // the accent: kickers, rules, the drop cap, the pull quote
tint: '#f5ecdc', // the fact box
rule: '#d8c6a6', // hairlines
muted: '#6b6158', // running heads, credits
paper: '#ffffff',
shade: '#1a1612', // the plate under the headline on the photo
};
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: 'honey (defaults)', value: { hex: palette.honey, model: 'hex' } },
];
// #endregion
const SERIF = 'Literata';
const DISPLAY = 'Fraunces';
const SANS = 'Instrument Sans';
const W = 225; // trim width in mm; the spread's sheet is twice as wide
const IN = 16; // inner margin
const OUT = 18; // outer margin
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
// The spread's content area runs from the verso's outer margin to the recto's: a frame
// on the recto starts RECTO mm in from its left edge.
const RECTO = W - OUT + IN;
const COLUMN = 92; // the two columns of the recto
const GAP = 7;
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#巣箱を矩形で回り込ませる
wrap: 'contour'を外すと枠は矩形で押しのけ、ドームの横の行はまっすぐな縁で止まります。
- { name: 'recorte', exclude: 'push', wrap: 'contour', layer: 2, width: mm(58),
+ { name: 'recorte', exclude: 'push', layer: 2, width: mm(58),#継続マーカーを外す
mark: falseにすると、切れた部分は Continúa を置かずに最後の行で終わり、その段に一行多く入ります。
- overflow: { continueIn: 'template:seguido' } },
+ overflow: { continueIn: 'template:seguido', mark: false } },よくあるつまずき
- テンプレートが独立した枠へ送る見出しは、テキストの枠ではドロップキャップを開きません。特集の最初の段落は
:::paragraphs{style="inicio"}で包み、dropCapはそのスタイルに持たせます。
クレジット
- 本文
- 書き下ろしの文章, CC BY 4.0
- 画像
- Painted hives on a factory roof at sunrise (the opening spread) · Generated With Diffusion Models · オリジナル
- A straw bee skep on a transparent ground (the cut-out the text runs round) · Generated With Diffusion Models · オリジナル
- フォント
- Literata (SIL OFL 1.1) · Fraunces (SIL OFL 1.1) · Instrument Sans (SIL OFL 1.1)


