かんたんな説明
山の一日を6枚の写真で見せる横長の写真集です。ページの端まで写真で埋める方法と、1枚の写真を向かい合う2ページにまたがせる方法を示します。
できあがり
『Sierra』は280 × 210 mmのページに組んだ横長の写真集です。花崗岩の山並みの一日を、夜明けから初雪の翌朝まで6枚の図版で追います。どの図版もページを仕上がりまで埋め、左下の隅に小さなローマ数字と時刻だけを載せます。最初の図版には題名も入り、72 ptのSyneで組んだSIERRAを夜明けの空に白抜きで置きます。嵐は4ページと5ページののどをまたいで1枚の画像になります。3つの短い文章は、のど寄りの100 mmの段に組み、それぞれのあとに続く図版と向かい合います。嵐の文章は、その下にフロートで置いた小さめの夕暮れの図版で終わり、そのローマ数字はキャプションに入ります。最後の図版は、2枚目と同じカールを同じ岩から写した雪景色です。図版は拡散モデルで生成した写真で、雪の図版は正午の図版を編集して作ったので、2つの眺めは一致します。
このレシピが答える質問
- 章ごとに異なる写真、色、章扉のバリエーションを与えるには?
- 意図的に白ページを入れたり、節を新しい見開きから始めたりするには?
- 章扉や白ページで柱を隠したり、空白の偶数ページを部の色で塗ったりするには?
- 番号のないアートワーク(オーナメント、カット、ロゴ)を組むには?
手短な答え
// '{attr.art}' is filled in per heading, so a plain plate names its picture on its line:
// # Noon {style="lamina" art="mediodia" …}. Only the cover and the last plate draw extras.
const PLATES = [ // the style id, its picture, the ink of its caption, anything extra it draws
{ id: 'alba', art: 'alba', extra: (colour) => cover(colour) }, // an arrow: cover() is below
{ id: 'lamina', art: '{attr.art}' }, // any plate on a page of its own
{ id: 'pliego', art: '{attr.art}', half: 'verso' }, // one picture across a spread:
{ id: 'pliego-recto', art: '{attr.art}', half: 'recto' }, // the left half, then the right
{ id: 'nieve', art: 'nieve', ink: 'ink', extra: (colour) => colophon(colour) },
];
const plate = ({ id, art, half, ink = 'white', extra = () => [] }) => ({
id, span: 'page', // an opener: a span heading always starts a page of its own
// The left half opens on an even page, a verso, so the right half faces it across the
// gutter (gotcha: parity-page1-recto).
...(half === 'verso' && { breakBefore: { enabled: true, parity: 'even' } }),
// The picture is as deep as the page, more than the column holds: the plate claims the
// whole page, and what follows starts on the next one.
advancedDesign: { enabled: true, slot: { elements: [
{ kind: 'image', id: 'picture', resourceId: art, // the recto half is the same picture,
placement: at('page', 'top-left', half === 'recto' ? -PAGE.width : 0, 0, // moved left
{ width: mm(half ? 2 * PAGE.width : PAGE.width), height: mm(PAGE.height) }) },
...(half === 'recto' ? [] : caption(col(ink))), ...extra(col(ink)),
] } },
});
材料
- 機能
- ページデザインの画像見出しスタイルデザインした章扉デザイン要素の基準位置節ごとのページ構成見出しの属性奇数ページから始まる章ページの役割ごとの柱図を配置する参照独自のリソースの種類キャプションのスタイル表紙、扉、奥付用紙の色見開きの余白ページデザインのテキスト・罫・ボックスハイフネーションと文書の言語セマンティックカラーパレットリソースとしての図と表キャンバス上のページ
- 種類
- Andada Pro, Syne, Syne Mono (SIL OFL 1.1)
- 素材
alba-1600.jpgatardecer-2000.jpgmediodia-1600.jpgnieve-1600.jpgnoche-1600.jpgtormenta-2400.jpg- Plate I, dawn: ridges fading into a peach haze under a dark blue sky (Generated With Diffusion Models, オリジナル)
- Plate II, noon: a granite cirque and its lake (Generated With Diffusion Models, オリジナル)
- Plate III, storm: rain, lightning and a break of sun across a spread (Generated With Diffusion Models, オリジナル)
- Plate IV, dusk: the crest lit orange under a violet sky (Generated With Diffusion Models, オリジナル)
- Plate V, night: stars over the ridges and a lit refuge (Generated With Diffusion Models, オリジナル)
- Plate VI, snow: the cirque of plate II the morning after (Generated With Diffusion Models, オリジナル)
作り方
#1 · 図版ごとの見出しスタイルをリストから作る
コードは前の手短な答えにあります。plate()はPLATESの各行から見出しスタイルを作り、Markdownは図版ごとに1行、# Night {style="lamina" art="noche" n="V" hora="22:10"}のように書いてエッセイの順番を決めます。画像要素のresourceIdは'{attr.art}'で、テキストと同じくプレースホルダーです。そのため装飾のない図版はすべてlaminaスタイルを共有し、見出しの行で自分の画像を指定します。追加の要素を描く表紙と最後の図版だけが専用のスタイルを使います(画像要素)。span: 'page'で、どの図版もそれ自身のページから始まります。画像の高さはページと同じ210 mmで、デザインは画像の下端までを確保します。これは文章ページの段の158 mmより高いので、図版がページ全体を取り、あとに続くものは次のページから始まります。minHeightも専用の余白も要りません。
見開きの2つのスタイル、pliegoとpliego-rectoは、同じ560 mmの画像(ここではart="tormenta")を描きます。偶数ページの半分はページの左端に、奇数ページの半分は280 mm左にずらして置くので、各ページが自分の半分を見せ、残りはCanvasが仕上がりで切り取ります。parity: 'even'で、2つの半分は向かい合ったままになります。この指定がないと、Markdownから正午の図版を外したとき、左半分が奇数ページの3ページに、右半分がその裏の4ページに来てしまいます。指定があれば3ページは白ページのままで、嵐は4ページと5ページを埋めます。
#2 · ローマ数字と時刻は見出しの行から
const NUMERAL = { x: 16, y: PAGE.height - 21, size: 13 }; // mm from the top left; size in pt
// A design text's baseline sits 0.8 of its line box below its top: set a smaller label beside
// a larger one this much lower and the two share a baseline.
const dropTo = (big, small, lineHeight = 1.2) => (0.8 * lineHeight * (big - small) * 25.4) / 72;
const caption = (colour) => [
{ kind: 'text', id: 'numeral', content: '{attr.n}', fontFamily: 'Syne', fontWeight: 700,
fontSize: pt(NUMERAL.size), color: colour, align: 'left',
placement: at('page', 'top-left', NUMERAL.x, NUMERAL.y) },
{ kind: 'text', id: 'hour', content: '· {attr.hora}', fontFamily: 'Syne Mono', fontSize: pt(8),
letterSpacing: pt(0.8), color: colour, align: 'left', // the dot: a lone I reads as a bar
placement: at('#numeral', 'right-of', 1.6, dropTo(NUMERAL.size, 8)) },
];
ローマ数字と時刻は見出しの属性なので、内容はMarkdownに残り、1つのデザインですべての図版に対応できます。時刻はローマ数字のright-ofに置かれ、上端がそろいます。デザインのテキストのベースラインは要素の上端から行ボックスの0.8の位置にあり、行ボックスは初期設定で文字サイズの1.2倍です。そのためdropTo(13, 8)は時刻を0.8 × 1.2 × (13 − 8) pt下げ、8 ptの時刻を13 ptのローマ数字のベースライン、ページの上端から193.4 mmの位置に置きます。図版IVのキャプションと同じく、時刻は中黒で始めます。SyneのIはただの縦棒なので、時刻の横に単独で置くと罫に見えるからです。嵐の右半分はキャプションを描きません。雪の図版は手前が白いので、キャプションを墨で組みます。
#3 · 図版そのものに載せる題名と奥付
const cover = (colour) => [
{ kind: 'text', id: 'title', content: '{title}', fontFamily: 'Syne', fontWeight: 800,
fontSize: pt(72), lineHeight: 1, letterSpacing: pt(6), textTransform: 'uppercase',
color: colour, align: 'left', placement: at('page', 'top-left', 22, 26) },
{ kind: 'text', id: 'subtitle', content: '{subtitle}', fontFamily: 'Syne Mono',
fontSize: pt(10), letterSpacing: pt(2), textTransform: 'uppercase', color: colour,
align: 'left', placement: at('#title', 'below', 1.5, 3) },
];
// The colophon: one element per line, 10.5 pt apart, so the break falls after the licence, and
// the second line on the baseline of the plate's numeral.
const COLOPHON = { y: NUMERAL.y + dropTo(NUMERAL.size, 7.5), leading: (10.5 * 25.4) / 72 };
const colophon = (colour) => ['colofon', 'tipos'].map((key, line) => ({ kind: 'text', id: key,
content: `{attr.${key}}`, fontFamily: 'Syne Mono', fontSize: pt(7.5), letterSpacing: pt(0.2),
color: colour, align: 'right',
placement: at('page', 'top-right', -16, COLOPHON.y - (1 - line) * COLOPHON.leading) }));
最初の図版は表紙です。{title}と{subtitle}はフロントマターから値を取り、PLATESのextraがその図版のデザインに両方の要素を、キャプションと同じ色で加えます。奥付も同じ方法で最後の図版に、雪の上に墨で載せます。7.5 ptの要素を1行に1つずつ、計2つ置いてcolofon属性とtipos属性から取り、右そろえにして、2つ目をローマ数字のベースラインに置きます。1つの要素を折り返すと、幅が尽きたところで改行してしまいます。1行に1要素なら、改行はライセンスのあとに来ます。
#4 · 文章は改ページせずに図版に続く
const textOpener = { enabled: true, slot: { elements: [
{ kind: 'text', id: 'hours', content: '{attr.hora}', fontFamily: 'Syne Mono', fontSize: pt(8),
letterSpacing: pt(0.8), color: col('accent'), align: 'left',
placement: at('container', 'top-left', 0, 0) },
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: 'Syne', fontWeight: 700,
fontSize: pt(28), lineHeight: 1.05, // a multiple of the size
color: col('ink'), align: 'left', overflow: 'wrap',
placement: at('#hours', 'below', 0, 2.5, { width: 'fill' }) },
] } };
// The folio and the book's title under the text block, flush with its left edge, on the
// baseline of the plates' numerals. Not on the plates: a span heading opens their pages, so
// they are opener pages, and 'body' leaves them out.
const foot = (id, content, extra) => ({ kind: 'text', id, content, pages: 'body',
fontFamily: 'Syne Mono', fontSize: pt(7.5), letterSpacing: pt(0.8), color: col('muted'),
align: 'left', ...extra });
const FOOT = NUMERAL.y + dropTo(NUMERAL.size, 7.5) - (PAGE.height - MARGIN.bottom); // from the foot
const footer = { elements: [
foot('folio', '{pageNumber}', { color: col('ink'),
placement: at('container', 'top-left', 0, FOOT) }),
foot('book', '{title}', { textTransform: 'uppercase', placement: at('#folio', 'right-of', 5) }),
] };
文章の前の図版がそのページを埋めるので、文章は自分で改ページしなくても次のページから始まります。改ページを指定した見出しが最初のブロックになるページは章扉になり、ノンブルのpages: 'body'はそのページを除きます。改ページがなければ文章ページはノンブルを保ち、ページ幅の見出しで始まる図版にはノンブルが付きません。breakBefore: { enabled: false }は、レベル1見出しが既定で持つ奇数ページへの改ページを切ります。この改ページがあると、文章のページは章扉の扱いになり、ノンブルが付きません。FOOTはノンブルを図版のローマ数字のベースライン、ページの上端から193.4 mmに置くので、文章のノンブルと、向かいの図版のローマ数字が1本の線にそろいます。
#5 · 図版はすべて宣言し、引用はフロートする1枚だけ
// Plate IV is the one plate that floats, so a counter of its type would number it 1. The type
// prints no number (no caption prefix, an empty template) and the caption carries the numeral.
// The text names the plate with :ref's text, since a bare :ref prints 'lámina' and nothing else.
const lamina = { id: 'lamina', name: t({ en: 'Plate', es: 'Lámina' }),
shortLabel: t({ en: 'plate', es: 'lámina' }), numberingTemplate: '',
resetOn: 'never', counterFormat: 'decimal', captionPrefix: '' };
// JPEGs in assets/, cut to the page's shape: 1600 × 1200 px for 280 × 210 mm (145 dpi).
const picture = (id, [w, h], alt, extra = {}) => ({ id, typeId: 'lamina', kind: 'bitmap',
bitmap: { fileId: `${id}-${w}.jpg`, format: 'jpeg', width: w, height: h },
createdAt: 0, updatedAt: 0, altText: t(alt), ...extra });
const resources = [ // the five the heading styles draw, never cited, and plate IV
picture('alba', [1600, 1200], { en: 'Eight ridges fading into a peach dawn haze.',
es: 'Ocho crestas que se pierden en la bruma del alba.' }),
picture('mediodia', [1600, 1200], { en: 'A granite cirque and its lake under a pale noon sky.',
es: 'Un circo de granito y su laguna bajo el cielo pálido del mediodía.' }),
picture('tormenta', [2400, 900], { en: 'A storm over the range: rain on the left, lightning '
+ 'and a break of sun on the right.', es: 'Una tormenta sobre la sierra: lluvia a la '
+ 'izquierda; un rayo y un claro de sol a la derecha.' }),
picture('noche', [1600, 1200], { en: 'Stars over dark ridges and two lit windows at a refuge.',
es: 'Estrellas sobre crestas oscuras y dos ventanas encendidas en un refugio.' }),
picture('nieve', [1600, 1200], { en: 'The cirque the morning after, white with new snow.',
es: 'El circo a la mañana siguiente, blanco de nieve nueva.' }),
// 2000 px, 339 mm at the layout's 150 dpi, which the float fits to the 100 mm measure.
picture('atardecer', [2000, 800], { en: 'A crest lit orange under strips of cloud, violet sky.',
es: 'Una cresta encendida de naranja bajo franjas de nube, en un cielo violeta.' },
{ caption: t({ en: 'IV · Dusk · 19:41', es: 'IV · Atardecer · 19:41' }) }),
];
デザインの画像要素は宣言済みのリソースを描くので、6枚の画像はすべてresourcesに入っています。レシピのassets/にあるJPEGで、それぞれ埋めるページまたは見開きの形に切り、ピクセルサイズで宣言します。レイアウトが使うのはそのサイズだけです。loadImage()は組版の前に各ファイルを登録します。:refで引用するのは図版IVだけで、フロートするのもこの1枚だけです。引用のあとの最初の空き位置、つまり文章のページで、最後の段落の1行下に置かれます。番号付きのタイプなら、そのタイプでフロートするリソースはこれだけなので、キャプションはPlate 1になります。代わりにlaminaはnumberingTemplateとcaptionPrefixを空にしてあるのでPlate.は刷られず、キャプション自体がIVで始まります。文中では:refのtextが図版の名前を示します。:refだけではplateという語しか刷られないからです。
レシピの全体
// ═══ Postext Cookbook · Nº 068 · Photo essay with full-bleed plates ═══════════════
// https://postext.dev/en/cookbook/photo-essay-full-bleed
// Code: MIT · Text: original (CC BY 4.0) · Plates: diffusion models
// Fonts: Andada Pro, Syne, Syne Mono (SIL OFL 1.1) · Needs postext ≥ 1.42.1
// Sierra, a landscape photobook: one day in a mountain range in six plates, each on a page of
// its own and one across the gutter of a spread, with three short texts between them.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
const LANG = 'es'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'photo-essay-full-bleed';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: the paper between the plates, the ink and one rust for the labels
const palette = {
ink: '#1c1f27', // text: the blue-black of the night plate
paper: '#f3f0ea', // every page's ground: a pale stone, seen only between the plates
accent: '#94462e', // the times over each text: the dusk plate's rust, dark enough for 8 pt
muted: '#5f646d', // the running foot and the caption of the small plate
white: '#fbfaf7', // type set on the plates
};
// col() links a colour to its palette entry; the hex is the value the entry holds.
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' } }));
// #endregion
const PAGE = { width: 280, height: 210 }; // a landscape photobook, in mm
const MARGIN = { top: 28, bottom: 24, inner: 40, outer: 140 }; // text pages: a 100 mm measure
const LEAD = 15; // body leading in pt
const at = (to, edge, x = 0, y = 0, size) => ({ anchor: { to, edge },
offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });
// #region answer: the plates' heading styles, generated from a list
// '{attr.art}' is filled in per heading, so a plain plate names its picture on its line:
// # Noon {style="lamina" art="mediodia" …}. Only the cover and the last plate draw extras.
const PLATES = [ // the style id, its picture, the ink of its caption, anything extra it draws
{ id: 'alba', art: 'alba', extra: (colour) => cover(colour) }, // an arrow: cover() is below
{ id: 'lamina', art: '{attr.art}' }, // any plate on a page of its own
{ id: 'pliego', art: '{attr.art}', half: 'verso' }, // one picture across a spread:
{ id: 'pliego-recto', art: '{attr.art}', half: 'recto' }, // the left half, then the right
{ id: 'nieve', art: 'nieve', ink: 'ink', extra: (colour) => colophon(colour) },
];
const plate = ({ id, art, half, ink = 'white', extra = () => [] }) => ({
id, span: 'page', // an opener: a span heading always starts a page of its own
// The left half opens on an even page, a verso, so the right half faces it across the
// gutter (gotcha: parity-page1-recto).
...(half === 'verso' && { breakBefore: { enabled: true, parity: 'even' } }),
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#図版を項目の向かいにフロートさせる
カタログの項目と向かい合う奇数ページへ図版をフロートさせ、図の幅をその縦横比から決める例は、図版と向かい合う作品解説の図録を参照してください。
#裁ち落としの写真で記事を始める
記事の頭に写真を裁ち落としで置き、見出しとリードをその上に載せる例は、雑誌の特集記事を参照してください。
よくあるつまずき
つまずき
1ページは奇数ページ。ページは物理的な番号で計画する
1ページは右ページで、2ページが最初の偶数ページです。見開きは物理的なページ番号で計画してください。偶数ページの章扉は、その次の奇数ページと向かい合います。 改ページと改段 →
つまずき
SVGの図に<marker>やフィルターを使わない(ラスターにフォールバックする)
SVGの図がPDFでベクターのまま残るのは、<marker>、フィルター、マスクを使っていない場合だけです。使っているとラスターにフォールバックし、深く入れ子にしたフィルターはChromeで図を真っ白にすることがあります。矢じりはパスで描いてください。 リソースとしての図と表 →
- デザインが描く図版はけっして引用しないでください。引用すると、図としてもフロートします。最初の文章で正午の図版を
:refで引用すると、3ページにもう1枚置かれ、嵐は白ページを1つはさんで2ページ先へ移ります。 - 夕暮れの図版はページの地ではなく、文章の1行下に置かれます。文章の最後のページでは、本文より下にあるフロートが本文のところまで上がり(
layout.hugClosingFloats、既定でオン)、そこではposition: 'bottom'も効きません。 - どの文章も、両方の版で1ページに収まるよう調整してあります。最初の文章が3ページまで続くと、正午の図版は4ページへ、嵐は白い5ページのあとの6・7ページへ移ります。
- 嵐の右半分は2つ目の
# Storm見出しです。ページにその題名は刷られませんが、見出しから作る:::tocには、嵐が4ページと5ページの2回載ります。 - 図版は仕上がり、つまりCanvasの端で止まります。
page.cutLinesをオンにするとCanvasは仕上がりの外へ広がり、各図版のまわりの塗り足しに紙の色が見えます。印刷用には図版を'bleed'に固定し、それぞれを四辺とも塗り足しのぶんだけ大きくしてください。
クレジット
- 本文
- The three texts, the captions and the colophon, in Spanish and English, and the six plates, drawn in code · Postext Cookbook · CC BY 4.0
- 画像
- Plate I, dawn: ridges fading into a peach haze under a dark blue sky · Generated With Diffusion Models · オリジナル
- Plate II, noon: a granite cirque and its lake · Generated With Diffusion Models · オリジナル
- Plate III, storm: rain, lightning and a break of sun across a spread · Generated With Diffusion Models · オリジナル
- Plate IV, dusk: the crest lit orange under a violet sky · Generated With Diffusion Models · オリジナル
- Plate V, night: stars over the ridges and a lit refuge · Generated With Diffusion Models · オリジナル
- Plate VI, snow: the cirque of plate II the morning after · Generated With Diffusion Models · オリジナル
- フォント
- Andada Pro (SIL OFL 1.1) · Syne (SIL OFL 1.1) · Syne Mono (SIL OFL 1.1)


