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

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

俳句と短歌の縦組み

紀行文の中の芭蕉の句と、啄木の三行書きの短歌11首を四六判に縦組みで組みます。1行に1句、天から下げて置き、署名は地に付けます。

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

二〜三ページ · 2〜3/8

  • 英語の見本:日本語版はまだありません
  • 仕上がり127 × 188 mm
  • 1段
  • Shippori Mincho 10/19
  • Noto Sans JP
  • 8ページ
  • レベル
  • Postext 1.65.0
  • 組版時間91 ms
  • コード155行

かんたんな説明

日本の詩歌の小さな本です。芭蕉の紀行文では俳句をそれぞれ独立した行に置き、啄木の短い歌は3行ずつ、ページをめくる位置で分かれないように組みます。

できあがり

127 × 188 mmの四六判、右綴じの小さな詩歌集を8ページ作ります。第1部は芭蕉の『おくのほそ道』から7つの段を選び、紀行文と俳句を収めます。第2部は石川啄木の『一握の砂』から短歌11首を、啄木が書いたとおりの3行で収めます。散文は上から下へ1行36字、Shippori Minchoの10 ptで、1.9 emのゆったりした行送りで組みます。俳句は3字下げ、短歌は2字下げの独立した行に置き、曾良の句には行の地寄りに曾良と署名を入れます。短歌はページをまたいで分かれることがなく、歌群のあいだは柿色の*で区切ります。欧文の詩集はNo. 015、縦組み中国語の唐詩はNo. 083にあります。

このレシピが答える質問

  • 詩を組むには(1行に1詩行、連の間のアキ、折り返した行のぶら下げインデント、ハイフネーションなし)?
  • 画面とPDFで、漢字を日本の字形で表示して日本語を組めるフォントは?

手短な答え

script.js · 33〜48行コード全体で見る
// A haiku is a paragraph of one line, so a style sets where it starts: three characters down
// from the head of the line. Takuboku's tanka keep his three lines in a :::verse block, two
// down; 曾良 signs his haiku raised five characters from the foot (地から五字上げ).
const paragraphStyles = [
  { id: 'haiku', indent: em(3), firstLineIndent: em(0), marginTop: pt(0), marginBottom: pt(0) },
  // A poem's style gives its indent and the space under the poem: one blank line.
  { id: 'tanka', indent: em(2), marginTop: pt(0), marginBottom: pt(LEAD) },
  { id: 'by', textAlign: 'end', endIndent: em(5), firstLineIndent: em(0) },
  // The ornament between groups of poems, in the middle of its line, with a blank line after
  // it to match the one the group before it leaves.
  { id: 'ornament', textAlign: 'center', firstLineIndent: em(0), color: col('persimmon'),
    marginBottom: pt(LEAD) },
];
//   :::paragraphs{style="haiku"}       :::paragraphs{style="by"}
//   夏草や兵どもが夢の跡                   曾良
//   :::                                :::

材料

種類
Shippori Mincho, Noto Sans JP (SIL OFL 1.1)
素材
なし:画像はすべてコードで描画

作り方

#1 · 詩の1行は1つの段落で、その書き出し位置はスタイルが決める

コードは上の手短な答えにあります。俳句は1行なので、:::paragraphsのブロックの中の独立した段落にし、字下げはそのブロックのスタイルが決めます。indent: em(3)は俳句を行頭から3字下げて置きます(青空文庫のテキストは2字下げですが、3字下げると句のまわりに余裕が生まれます)。firstLineIndent: em(0)は、本文の1字下げがそこに加わらないようにします。俳句の17字前後は36字の行にいつでも収まるので、折り返すことはありません。署名は独立した段落です。textAlign: 'end'で行の地に付け(地付き)、endIndent: em(5)でそこから5字上げます(地から五字上げ)。このテキストの底本と同じ組み方です(段落スタイル)。

#2 · 短歌を1ページに収める

script.js · 52〜63行コード全体で見る
// The tanka of a group are one :::verse block, each a stanza of three lines with a blank
// line between: a line of verse a line of Markdown, one blank line of the grid between two
// tanka. keepStanzas=3 keeps a stanza of three lines whole, so a tanka is never cut at the
// foot of a page: it moves on to the next.
//   :::verse{style="tanka" keepStanzas=3}
//   東海の小島の磯の白砂に
//   われ泣きぬれて
//   蟹とたはむる
//
//   頬につたふ
//   …
//   :::

啄木の短歌は1つの:::verseブロックで、1首が1つの連です。3行はMarkdownの3行で、原稿で歌と歌のあいだに置いた空行が、歌のあいだにグリッド1行分の空き行を作ります。詩のスタイルが2字の字下げと群のあとの1行を決め、各行はほかの列と同じく天から下がります。keepStanzas=3は3行の連を分けずに保ちます。5ページでは3首目が部の題と最初の2首の下に収まらないので、最初の1行だけを残すことはせず、6ページの先頭にまるごと移ります。群と群のあいだの装飾は次の群を導くので、ページの地にひとつだけ残らず、その最初の歌と一緒に移ります(:::verse)。

#3 · 地名を同じ幅に字取りする

script.js · 67〜72行コード全体で見る
// The place names over the prose take two lines (2行取り), four characters down, and a
// two-character name is spaced out to three (字取り: 平泉 → 平 泉), so they all end level.
const place = {
  level: 2, fontFamily: MINCHO, fontWeight: 700, fontSize: pt(11),
  lineSpan: 2, indent: em(4), jidori: 3,
};

芭蕉の旅の段の名は、本文2行分の高さを取る第2階層の見出し(2行取り)です。そのため後に続く紀行文と俳句も行のグリッドからずれません。jidori: 3は短い名前を自身の文字3字分の幅に広げます(字取り)。平泉は平 泉と1字分空けて印刷され、どの名前も立石寺や最上川と同じ高さで終わります。すでに3字の名前はそのままです(レベルごとの上書き)。

#4 · 各部を新しいページで始める

script.js · 76〜97行コード全体で見る
// A design on a vertical page is laid out in the flow frame: x runs down the column from
// the head of the type area, y across the page leftwards from its right edge.
const at = (down, across) => ({ anchor: { to: 'container', edge: 'top-left' },
  offset: { x: pt(down), y: pt(across) } });
const TITLE = 18; // pt
const part = {
  level: 1, breakBefore: { enabled: true, parity: 'any' }, // the next page, either side
  advancedDesign: { enabled: true, minHeight: lines(5), slot: { elements: [
    { kind: 'text', id: 'title', content: '{titleText}', fontFamily: MINCHO, fontWeight: 700,
      fontSize: pt(TITLE), lineHeight: 1, letterSpacing: pt(4), color: col('ink'),
      placement: at(3 * BODY, 1.5 * LEAD - TITLE / 2) },
    { kind: 'text', id: 'abridged', content: '(抄)', fontFamily: MINCHO, fontSize: pt(9),
      color: col('ink'), placement: { anchor: { to: '#title', edge: 'right-of' },
        offset: { x: pt(6), y: pt((TITLE - 9) / 2) } } },
    { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.6),
      color: col('persimmon'), placement: { ...at(3 * BODY, 2.5 * LEAD),
        size: { width: pt(4 * TITLE) } } },
    { kind: 'text', id: 'poet', content: '{attr.author}', fontFamily: MINCHO, fontSize: pt(11),
      letterSpacing: pt(3), color: col('ink'),
      placement: at(CHARS * BODY - 4 * 11 - 3 * 3 - 2 * BODY, 3.5 * LEAD - 11 / 2) },
  ] } },
};

各部は第1階層の見出しで、そのデザインが題、anchor.to: '#title'で題のすぐ後に置く小さな(抄)(「抜粋」の意)、題の横の短い柿色の罫、そして行の地寄りに置く作者名を描きます。デザインは5行分を確保し、本文はそのあと同じグリッドの上で始まります。

#5 · 古い記号を持つ書体を選ぶ

script.js · 279〜285行コード全体で見る
const title = markdown.match(/^title: "(.*)"$/m)[1];
const heads = markdown.match(/^#+ [^{\n]*/gm).join('');
await loadFonts(FONTS, markdown); // the Latin files: the colophon
await loadCjkFonts({ [MINCHO]: ['400'] }, markdown, { vertical: true });
await loadCjkFonts({ [MINCHO]: ['700'] }, heads);
await loadCjkFonts({ [GOTHIC]: ['400'] },
  `${title}${heads}${markdown.match(/colophon="([^"]*)"/)[1]}一二三四五六七八九十`, { vertical: true });

芭蕉の散文は繰り返しの語を古い踊り字〻で書き(日〻、人〻)、さらに古いテキストでは長いくの字点〳〵も使います。Zen Old Minchoにはどちらもないので、Canvasはシステムの書体から借りて描き、PDFは空の四角を描いてしまいます。Shippori Mincho、Noto Serif JP、Shippori Mincho B1はどちらも備えているので、詩歌はShippori Minchoで組みます(中国語・日本語・韓国語のフォント)。青空文庫のテキストには旧仮名遣いについての編者の注記とら{え|(へ)}ても残っており、芭蕉の書いた仮名の横に読みとして期待される仮名を印刷します。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 119 · Haiku and tanka set vertically ═══════════════════
// https://postext.dev/en/cookbook/haiku-and-tanka
// Code: MIT · Text: 芭蕉『おくのほそ道』, 啄木『一握の砂』, Aozora Bunko (PD) · Pictures: none
// Fonts: Shippori Mincho, Noto Sans JP (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, loadVerticalAlternates,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the colophon; the poems are Japanese in both
const RECIPE = 'haiku-and-tanka';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: ink, one persimmon, a soft poetry stock
const palette = {
  ink: '#22201d', // the poems
  persimmon: '#b5512c', // 柿: the part titles' rule and the ornaments
  muted: '#6a645c', // the hashira, the folios, the colophon
  paper: '#fbf8f1',
};
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: 'defaults', value: { hex: palette.persimmon, model: 'hex' } },
];
// #endregion
// Shippori Mincho: it has the 〻 of 日〻 and 人〻, which Zen Old Mincho lacks.
const [MINCHO, GOTHIC] = ['Shippori Mincho', 'Noto Sans JP'];
const [BODY, LEAD, CHARS, LINES] = [10, 19, 36, 14]; // pt, pt: 36字 × 14行, a 1.9 em pitch
const lines = (n) => pt(n * LEAD);

// #region answer: a haiku on one line three characters down, a tanka in three, 地付き names
// A haiku is a paragraph of one line, so a style sets where it starts: three characters down
// from the head of the line. Takuboku's tanka keep his three lines in a :::verse block, two
// down; 曾良 signs his haiku raised five characters from the foot (地から五字上げ).
const paragraphStyles = [
  { id: 'haiku', indent: em(3), firstLineIndent: em(0), marginTop: pt(0), marginBottom: pt(0) },
  // A poem's style gives its indent and the space under the poem: one blank line.
  { id: 'tanka', indent: em(2), marginTop: pt(0), marginBottom: pt(LEAD) },
  { id: 'by', textAlign: 'end', endIndent: em(5), firstLineIndent: em(0) },
  // The ornament between groups of poems, in the middle of its line, with a blank line after
  // it to match the one the group before it leaves.
  { id: 'ornament', textAlign: 'center', firstLineIndent: em(0), color: col('persimmon'),
    marginBottom: pt(LEAD) },
];
//   :::paragraphs{style="haiku"}       :::paragraphs{style="by"}
//   夏草や兵どもが夢の跡                   曾良
//   :::                                :::

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

アレンジ

#俳句の3つの句切れに空きを入れる

学校向けのアンソロジーでは、形を学ぶ読者のために5音、7音、5音のあいだに全角スペースを入れることがあります。このスペースはテキストの文字です。

-{夏草|なつくさ}や{兵|つはもの}どもが夢の跡
+{夏草|なつくさ}や {兵|つはもの}どもが 夢の跡

#長い短歌の分割を許す

keepStanzasを指定しなければ、短歌はページの地近くで始まり、ウィドウ・オーファンの規則に従って次のページへ続くことができます。千首を収める詰まったアンソロジーならそう組むところです。

-:::verse{style="tanka" keepStanzas=3}
+:::verse{style="tanka"}

よくあるつまずき

つまずき

日本語のテキストのタグは'ja'。zh-HansやLANGにしない

レシピの版はenとesですが、日本語のサンプルはどちらの版でも日本語です。`locale: LANG`では英語やスペイン語とタグ付けされ、中国語のタグでは中国語の規則で組まれます(開明式の約物、小書きの仮名が行頭に来てもよい、図の代わりに图、PDFでは中国の字形)。postext 1.30以降、このタグはテキストを組む言語(計測、描画、埋め込みに使う言語)でもあるので、'ja'以外のタグでは日本語の字形ではなく別の字形(中国語のタグでは中国の字形)になり、改行の位置も変わります。'ja'と書いてください。日本の地域(JLReqの改行と約物、ゴマの圏点、ルビの間隔、図と表の表示名)が選ばれ、ハイフネーションが切られます。リントは、zhやkoのタグで仮名を含むテキストをエラーにします。 日本語の改行(禁則処理) →

つまずき

中国語の書体はcjkブロックを通じてスライス単位で読み込む

Fontsourceは中国語、日本語、韓国語のファミリーを、ウェイトごとに約100個のファイルとして配信し、各ファイルが文字の範囲を受け持ちます。loadFontsが取得するのはlatinファイルだけなので、画面では漢字がシステムの書体で出て計測が狂い、fontsourceProviderはPDFにそのlatinファイルを渡すため、漢字が空の四角で印字されます。キットのcjkブロックを挙げ、loadFontsのあとにloadCjkFonts(FONTS, markdown)を呼び(本で複数のCJK書体を使うときは、それぞれの書体で組むテキストを渡して書体ごとに1回)、renderToPdfにfontProvider: cjkPdfProviderを渡してください。どちらもテキストの文字を含むファイルを取得します。 中国語・日本語・韓国語のフォント →

つまずき

右綴じの本の見開きはshowBookで表示する

右綴じの本(アラビア語、ヘブライ語、ペルシア語のテキスト、縦組みの中国語、またはpage.binding 'right')でも1ページは奇数ページですが、背の左側に来て、見開きは[3 | 2]と並びます。showPagesはどの本も左綴じとして並べます。bookブロックのshowBook(cjkブロックにも同じ関数があります)はdoc.bindingを読み、見開きを左右反転します。capture.heroでは、見開きは引き続き読む順の[偶数ページ, 奇数ページ]、つまり[2, 3]と指定します。 右綴じの本 →

つまずき

Fontsourceの範囲は、ファイルにない文字を含むことがある

Fontsourceは各ファイルにunicode-rangeを与え、loadCjkFontsはサンプルを範囲で覆うファイルを読み込みますが、範囲はファイルの実際の中身より多くを主張することがあります。Zen Old MinchoのU+3028–303Fの断片には〻も長い繰り返し記号〳〴〵もなく、この書体にはマクロン付きの母音ō ū āもありません。Shippori Mincho B1のlatin-extファイルにはわずかな文字しかなく、ō、ū、āはどれも含まれません。サンプルの実行中は何も失敗しません。画面ではこれらの文字がシステムの書体で出てその書体で計測され、PDFにはフォントの.notdefの四角が印字されます。それを報告するのは、あとで行うC25の検査だけです。珍しい記号やローマ字の語は、書体を選ぶ前にフォントで確認し(Fontsourceのファイルに対してfontToolsを使う)、それを持つ書体で組んでください。Shippori Mincho B1とNoto Serif JPには〻と〳〴〵があり、Noto Serif JPとNoto Sans JPにはマクロン付きの母音があります。 中国語・日本語・韓国語のフォント →

クレジット

レシピ
Ignacio Ferro
本文
フォント
Shippori Mincho (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1)
SandboxPDF