本文へスキップ
レシピ番号43

レシピ集 · 第2章 · 文字と本文

対訳の詩を連ごとにそろえる

詩を1篇ずつ枠のない2段の囲みに組みます。固定の段区切りで英語を題から始め、:::spaceで各連を原詩の連と同じ高さにそろえます。

このページの内容
ジャンル
詩歌
出力
Canvas
レベル
中級
Postext
Postext 1.65.0で検証済み
1.34.0以上が必要
ライセンス
2026年10月16日更新
コードMIT · 本文CC BY 4.0

2〜3ページ(全5ページ)

  • スペイン語の見本:日本語版はまだありません
  • 仕上がり156 × 234 mm
  • 1段
  • Castoro 10.5/14.5
  • Castoro Titling
  • Tenor Sans
  • 5ページ
  • レベル
  • Postext 1.57.1
  • 組版時間64 ms
  • コード164行

かんたんな説明

スペイン語の詩と、その英訳を横に並べた小さな詩集です。訳詩の連は、どれも原詩の連と同じ高さから始まります。

できあがり

スペイン南部の塩田をうたった5篇の詩を収めた、156 × 234mmの対訳詩集です。左にスペイン語、右に詩人自身による英語版を1行ずつ並べます。フラミンゴを描いた扉と著者の覚え書きが先に来て、詩は朝日の中のピンクの池、塩の山、フラミンゴを描いた水彩画の下から始まります。詩はそれぞれ枠のない囲みに収め、Castoro Titlingの茜色の数字の下に、スペイン語を一方の段、英語をもう一方の段に組みます。英語はスペイン語と同じ行から始まり、どの連も原詩の連と同じ高さから始まります。英語の行が段に収まらないときは、残りが2em下がって次の行に折り返し、向かいのスペイン語の連の終わりに空行が1行加わります。

このレシピが答える質問

  • 囲みの中を2段にするには(本文の段と図の段を並べる)?
  • 詩を組むには(1行に1詩行、連の間のアキ、折り返した行のぶら下げインデント、ハイフネーションなし)?
  • 空行を入れても効かないとき、2つのブロックの間に縦のスペースを追加するには?
  • スペイン語・フランス語・ドイツ語のテキストで、きれいな両端そろえとハイフネーションを得るには?

手短な答え

script.js · 28〜52行コード全体で見る
// Each poem is a box titled with its numeral, holding one two-column group. breaks="5"
// opens the second column at the group's 5th block, since the Spanish title and its three
// stanzas come before it. A :::space is not a block, so the gaps leave the count alone:
//   :::callout{type="poem" title="I"}
//   :::columns{count=2 breaks="5"}
//   Spanish title, :::space{lines=0.5}, its stanzas in :::verse blocks
//   English title, :::space{lines=0.5}, its stanzas in :::verse blocks
//   :::
//   :::
// Both columns open on the same line, so matching :::space gaps keep the stanzas level.
// keepTogether: false lets a poem that does not fit go on overleaf. A group with breaks is
// cut stream by stream (flow="parallel"): each language goes on in its own column, level.
const poem = {
  id: 'poem',
  backgroundEnabled: false, // no fill, border or stripe
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  columnGap: mm(GAP),
  titleStyle: { fontFamily: 'Castoro Titling', fontSize: pt(22), fontWeight: 400,
    color: col('madder'), gap: pt(4) },
  // A box starts on the first grid line at least two lines down, under the picture as under
  // a poem (12.3 mm there: its box ends off the grid). The default marginBottom (0.75 em)
  // would add to marginTop and open 17.4 mm between poems.
  marginTop: pt(LEAD * 2), marginBottom: pt(0),
  keepTogether: false, // a long poem goes on overleaf instead of moving whole
};

材料

種類
Castoro, Castoro Titling, Tenor Sans (SIL OFL 1.1)
素材
  • flamingo-680.jpg
  • salina-1560.jpg
  • The salt pans at sunrise over the poems, a watercolour (Generated With Diffusion Models, オリジナル)
  • The flamingo on the title page, a watercolour (Generated With Diffusion Models, オリジナル)

作り方

#1 · 詩は固定の段区切りを持つ囲み

コードは上の手短な答えにあります。詩はどれも、:::columnsのグループを入れた囲みとして書きます。そのスタイルは塗りと内側余白を外し、開始行のtitle、つまり数字を印刷します(:::columns)。breaksがなければ、グループは2つの段の高さがそろう位置で切られます。ここではどの詩も前半と後半の高さが同じなので、切れ目はいずれにせよ英語の題に落ちます。しかし「The Rake」の2行を折り返すまで長くすると、切れ目は1ブロック下へずれ、THE RAKEがスペイン語の段の末尾に残ります。breaks="5"は第2段を始めるブロックを指定するので、前後半の高さにかかわらず英語の題が第2段の頭に立ちます。

#2 · 段ごとに:::verseブロック1つ、連の区切りに空行1つ

script.js · 56〜64行コード全体で見る
// Each half of a poem is a :::verse block, a line of verse a line of Markdown and a blank line
// between stanzas. A line too long for its 55 mm column turns over 2 em in, where it cannot
// pass for the next line; the Spanish half then ends that stanza's block and a
// :::space{lines=2} before the next keeps the stanzas level across the gutter.
const verse = { id: 'verse', hangingIndent: em(2) };
// Castoro Titling draws capitals only. A :::space{lines=0.5} in the Markdown sets each title
// off its poem.
const poemTitle = { id: 'poem-title', fontFamily: 'Castoro Titling', fontSize: pt(9.5),
  color: col('madder'), firstLineIndent: pt(0) };

詩の前半と後半はそれぞれ1つの:::verseブロックです。Markdownの1行が詩の1行で、左そろえ(行末不ぞろい)、ハイフネーションなしで組み、連と連のあいだの空行は段に空行を1行残します(:::verse)。各連が1つのブロックなので、breaksが数えるのは行ではなく連です。英語の「each one standing on its own reflection.」は55mmの段には長すぎるため、2em下がって折り返します。スペイン語の側は向かいの連の後でブロックを閉じ、次の連の前に:::space{lines=2}を置くので、次の連は同じ行から始まります。:::spaceはブロックではないので、breaksの数には入りません(:::space)。

3ページの詩I。英語ではreflection.が折り返し、スペイン語の連は空行1行ではなく2行で終わっています。

#3 · 覚え書きはそれぞれの言語でハイフネーションする

script.js · 68〜82行コード全体で見る
const LOCALE = t({ en: 'en-us', es: 'es' }); // the patterns of the edition's language
const bodyText = {
  fontFamily: 'Castoro', fontSize: pt(10.5), lineHeight: pt(LEAD), color: col('ink'),
  italicColor: col('ink'), firstLineIndent: mm(4.5), indentAfterHeading: false,
  minWordSpacing: 0.8, maxWordSpacing: 1.35, // word spaces from 0.8 to 1.35 of normal
  // No bold on these pages: ink keeps a **bold** or a :ref added later off the default blue
  // (#295AA3). References take boldColor while referenceColor is unset.
  boldColor: col('ink'),
};
// The heading prints its title 36 mm down the text block, and the note starts under it.
const notePage = { id: 'note', advancedDesign: { enabled: true, slot: {
  elements: [{ kind: 'text', id: 'title', content: '{titleText}', align: 'left',
    fontFamily: 'Castoro Titling', fontSize: pt(13), color: col('madder'), overflow: 'wrap',
    placement: { anchor: { to: 'container', edge: 'top-left' }, offset: { y: mm(36) } } }],
} } };

localeがハイフネーションのパターンを選びます。'es'にすると、スペイン語の覚え書きはori-ginalとDuna-liellaで分割されます。英語のパターンでは両語とも分割されずに次の行へ送られ、どちらのパターンでも分割されるのはarras-trabaだけです(対応するロケール)。語間は通常の幅の0.8倍まで縮み、1.35倍まで伸びることができ、どちらの覚え書きでも、それを超えて伸びる両端そろえの行はありません。覚え書きの見出しはデザインで、その唯一の要素である題を版面の上端から36mm下に置くので、覚え書きはページの上端から73mmの位置で始まります。

#4 · 扉と水彩画は見出し

script.js · 86〜114行コード全体で見る
const onPage = (y) => ({ anchor: { to: 'page', edge: 'top' }, offset: { y: mm(y) } });
const face = (id, content, font, size, y, extra = {}) => ({ kind: 'text', id, content,
  fontFamily: font, fontSize: pt(size), color: col('ink'), align: 'center', overflow: 'wrap',
  placement: onPage(y), ...extra });
const tracked = { letterSpacing: pt(2), textTransform: 'uppercase' };
const image = (id, placement) => ({ kind: 'image', id, resourceId: id, placement });
const titlePage = {
  id: 'title-page',
  header: { elements: [] }, footer: { elements: [] }, // no running head, no folio
  advancedDesign: { enabled: true, slot: { elements: [
    face('author', '{author}', 'Tenor Sans', 9, 44, { ...tracked, color: col('muted') }),
    face('title', '{titleText}', 'Castoro Titling', 34, 58, { lineHeight: 1 }),
    face('other', '{attr.other}', 'Castoro', 16, 76, { italic: true, color: col('madder') }),
    image('flamingo', { ...onPage(96), size: { width: mm(34) } }),
    face('edition', '{attr.edition}', 'Tenor Sans', 8.5, 170, tracked),
    face('version', '{attr.version}', 'Castoro', 10.5, 176, { italic: true }),
    face('press', '{attr.press}', 'Tenor Sans', 8, 206, { ...tracked, color: col('muted') }),
  ] } },
};
// The picture of the salt pans runs 84 mm down from the top edge of the page, and the heading
// reserves down to its foot. No margin under it: the poem's own marginTop sets the gap.
const poemsOpener = {
  id: 'poems', marginBottom: pt(0),
  advancedDesign: { enabled: true, slot: { elements: [
    image('salina', { anchor: { to: 'page', edge: 'top-left' }, size: { width: 'fill' } }),
    face('title', '{titleText}', 'Castoro Titling', 38, 17, { lineHeight: 1 }),
    face('other', '{attr.other}', 'Castoro', 15, 33, { italic: true, color: col('madder') }),
  ] } },
};

どちらもレベル1の見出しで、それぞれ専用のスタイルを使います(見出しスタイル)。扉のデザインは{author}をフロントマターから取り、両方のデザインが{attr.other}を見出しの属性から取ります。水彩画はページの上端、つまり版面より上に固定してあり、見出しはその下端、ページの上から84mmの位置までを確保します。スタイルはmarginBottom: pt(0)を指定するので、画像の下のアキは詩自身の上のアキ2行分になり、詩Iは画像から2行以上下にある最初のグリッド線から始まります。

#5 · 柱に両方の言語の題を入れる

script.js · 118〜132行コード全体で見る
const edgeAt = (edge, x, y) => ({ anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(y) } });
const head = (id, content, parity, placement, extra = {}) => ({ kind: 'text', id, content,
  parity, pages: 'body', fontFamily: 'Tenor Sans', fontSize: pt(7.5), color: col('muted'),
  ...tracked, letterSpacing: pt(1.5), placement, ...extra });
const folio = { color: col('ink'), letterSpacing: pt(0) };
const TITLES = ['Sal de agosto', 'August Salt']; // the book's title in its two languages
const header = { elements: [
  head('verso-folio', '{pageNumber}', 'even', edgeAt('top-left', OUTER, 12), folio),
  head('verso-title', TITLES[0], 'even', edgeAt('top-left', OUTER + 8, 12)),
  head('recto-title', TITLES[1], 'odd', edgeAt('top-right', -(OUTER + 8), 12)),
  head('recto-folio', '{pageNumber}', 'odd', edgeAt('top-right', -OUTER, 12), folio),
] };
// The note and the picture open their pages ('opener'): a folio at the foot instead.
const footer = { elements: [head('drop-folio', '{pageNumber}', 'all', edgeAt('bottom', 0, -12),
  { ...folio, pages: 'opener' })] };

段の順序に合わせて、偶数ページにはスペイン語の題、奇数ページには英語の題を入れます。pages: 'body'は、見出しで始まる3つのページから柱を外します。覚え書きと水彩画のページには代わりに地にノンブルが入り、扉のスタイルはヘッダーとフッターを空にします(テキスト要素)。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 043 · Facing translation, stanza by stanza ═══════════════════
// https://postext.dev/en/cookbook/bilingual-facing-verse
// Code: MIT · Text: original (CC BY 4.0) · Salt pans and flamingo: diffusion models
// Fonts: Castoro, Castoro Titling, Tenor Sans (SIL OFL 1.1) · Needs postext ≥ 1.34.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';

const LANG = 'es'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'bilingual-facing-verse';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { // every colour in the config links to one of these
  ink: '#1f2430', // the text: a blue-black
  madder: '#9a3c52', // the one accent: numerals, poem titles, the other language's title
  muted: '#6a6770', // running heads, folios, the author's name, 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' } }));
const TRIM_W = 156, TRIM_H = 234; // mm
const TOP = 22, OUTER = 18, INNER = 20; // mm: the text block is 118 mm wide
const LEAD = 14.5; // pt: the leading of the note and of every line of verse
const GAP = 8; // mm between the original and the translation: each column is 55 mm wide

// #region answer: a poem and its translation: a box with two columns and a fixed break
// Each poem is a box titled with its numeral, holding one two-column group. breaks="5"
// opens the second column at the group's 5th block, since the Spanish title and its three
// stanzas come before it. A :::space is not a block, so the gaps leave the count alone:
//   :::callout{type="poem" title="I"}
//   :::columns{count=2 breaks="5"}
//   Spanish title, :::space{lines=0.5}, its stanzas in :::verse blocks
//   English title, :::space{lines=0.5}, its stanzas in :::verse blocks
//   :::
//   :::
// Both columns open on the same line, so matching :::space gaps keep the stanzas level.
// keepTogether: false lets a poem that does not fit go on overleaf. A group with breaks is
// cut stream by stream (flow="parallel"): each language goes on in its own column, level.
const poem = {
  id: 'poem',
  backgroundEnabled: false, // no fill, border or stripe
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  columnGap: mm(GAP),
  titleStyle: { fontFamily: 'Castoro Titling', fontSize: pt(22), fontWeight: 400,
    color: col('madder'), gap: pt(4) },
  // A box starts on the first grid line at least two lines down, under the picture as under
  // a poem (12.3 mm there: its box ends off the grid). The default marginBottom (0.75 em)

組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)

アレンジ

#段間を広げる

12mmにすると段は53mmに狭まり、詩IIIの「Los turistas paran y hacen fotos:」が折り返すので、その第2連は英語より1行下から始まります。その連の後で英語のブロックを閉じ、次の連の前に:::space{lines=2}を置けば高さがそろいます。

-const GAP = 8; // mm between the original and the translation: each column is 55 mm wide
+const GAP = 12; // mm between the original and the translation: each column is 53 mm wide

#折り返しを深く下げる

3emにすると、3ページのreflection.は1em深く下がって始まります。

-const verse = { id: 'verse', hangingIndent: em(2) };
+const verse = { id: 'verse', hangingIndent: em(3) };

よくあるつまずき

  • 英語の題の前に置いた:::spaceは消えます。第2段はbreaksが指定するブロックから始まり、アキは切れ目に落ちるからです。ここで各段の題の下に置いた:::space{lines=0.5}のように、題のあとに置いてください。
  • breaksはスペイン語の題から数えます。題と3つの連なら、英語の題はブロック5です。各連がブロックなので、スペイン語の連を1つ増やすと英語の題はブロック6に移り、breaksもそれに合わせて増やす必要があります。連の中で1行増えても何も動きません。

クレジット

レシピ
Ignacio Ferro
本文
  • The poem cycle Sal de agosto and its English version, August Salt, with the author’s note, written for this recipe; the poet Adela Membrives is fictional · Postext Cookbook · CC BY 4.0
画像
  • The salt pans at sunrise over the poems, a watercolour · Generated With Diffusion Models · オリジナル
  • The flamingo on the title page, a watercolour · Generated With Diffusion Models · オリジナル
フォント
Castoro (SIL OFL 1.1) · Castoro Titling (SIL OFL 1.1) · Tenor Sans (SIL OFL 1.1)
Sandbox