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

レシピ集 · 第1章 · ページとグリッド

版本の丁:四周双辺、界線、版心

朱熹の『論語集註』を版本の刷りのとおりに組みます。見開きに1丁、四周双辺の匡郭、行と行のあいだの界線、折り目に来る版心です。

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

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

  • 英語の見本:日本語版はまだありません
  • 仕上がり120.8 × 213.1 mm
  • 1段
  • Noto Serif TC 20/29
  • LXGW WenKai TC
  • 7ページ
  • レベル
  • Postext 1.65.0
  • 組版時間65 ms
  • コード178行

かんたんな説明

中国の古典を、昔の木版本の見た目どおりに組みます。各ページは二重の枠で囲まれ、行のあいだに細い線が入り、注は行の中に小さな文字で入ります。

できあがり

朱熹の『論語』の注釈書『論語集註』から、巻頭の「學而」の3丁を、見返しの後に版本の刷りのとおりに組みます。各ページは121 × 213 mmの半丁で、見開きひとつが1丁全体にあたり、右から読みます。半丁ごとに20ptのNoto Serif TCで1行17字の行が9行、二重の枠(四周双辺)、行と行のあいだにはすべて細線が入り、折り目には書名、黒い魚尾、巻、丁付を入れた版心が来ます。朱熹の注は、説明する語の後に、10ptの文字の2行割りで行の中に入ります。天の余白は地の2倍です。

このレシピが答える質問

  • 二重の枠、行間の罫線、版心を備えた木版本の丁をレイアウトするには?
  • 版面を字数で設定し、1行の字数と1ページの行数を決めるには?
  • 中国語の本を縦組み・右綴じで組むには?

手短な答え

script.js · 46〜64行コード全体で見る
// A block printed both halves of a leaf (葉) at once, the centre strip between them. Each
// page here is a half-leaf. Page 1, the title, is a recto: in a book bound on the right it
// stands alone left of the spine, and every spread after it is one leaf, read from the
// right. The grid sets the block's 9 columns of 17 characters; the text has no
// punctuation, so every column ends on its 17th character.
const page = {
  sizePreset: 'custom', width: pt(W), height: pt(H), dpi: 150,
  backgroundColor: col('paper'),
  // left is the inner margin, the half of the centre strip on this side of the fold
  margins: { top: pt(TOP), bottom: pt(BOTTOM), left: pt(HALF), right: pt(OUTER), mirror: true },
};
const layout = { layoutType: 'single', writingMode: 'vertical-rl' }; // bound on the right
const cjk = { grid: { enabled: true, charsPerLine: CHARS, linesPerPage: LINES } };
// Postext numbers pages, not leaves. Each leaf opens with a hidden level-1 heading, which
// prints nothing and starts a right-hand page; the centre strip prints their count.
const leaf = {
  level: 1, hidden: true, numberingTemplate: '{1:一}', // 一, 二, 三
  breakBefore: { enabled: true, parity: 'even' }, // even pages lie on the right in this binding
};

材料

種類
Noto Serif TC, LXGW WenKai TC (SIL OFL 1.1)
素材
なし:画像はすべてコードで描画

作り方

#1 · 1ページに半丁、見開きに1丁

コードは上の手短な答えにあります。版木は1丁(葉)全体を一度に刷り、その2つの半分は版心の両側に分かれます。刷り手は紙を刷った面を外にして版心で折り、開いた側を綴じたので、版心が本の小口になりました。このレシピのページは、版木から刷り上がったときの丁のままに並んでいます。各ページが半丁です。右綴じの本では、1ページは背の左に1ページだけで置かれ、それ以降の見開きは右の偶数ページとその次の奇数ページの組になります。そのため見返しを1ページに置けば、どの見開きにも1丁が収まります。文字グリッドが版木の行款、つまり9行17字を決め、グリッドが残す余白はきっちりした値になります。内側の余白は版心の半分です。

Postextが番号を振るのはページで、丁ではありません。各丁は非表示のレベル1の見出しで始まります。この見出しは何も印字せず場所も取りませんが、parity: 'even'のbreakBeforeで右ページを始めます。numberingTemplate: '{1:一}'による番号「一」「二」「三」は、版心用の{chapterNumber}になります。

#2 · 各丁の終わりで本文を区切る

版木を彫る職人のために本文を書き写した筆耕は、丁ごとに本文を版木に合わせました。Markdownでも同じことをします。丁の見出しは、前の丁の左半分の9行目が終わる位置に置きます。文の途中でも、注の途中でもかまいません。そこで切れた注はいったん閉じてからまた開きます。各行は注のうち自分の分を2行に割るので、割注の行は元のとおりになります。

子曰巧言令色鮮矣仁:warichu[巧好令善也好其言善其色致飾於]
 
# 學而
 
:warichu[外務以悦人則人欲肆而本心之德亡矣…]

版木には句読点がないので、禁則処理で文字が動くことはなく、どの行も17字目で終わります。丁の区切りは一度数えれば動きません。朱熹の注は既定の半分の大きさの:warichu[…]で、割注の1行に小さな文字が34字入り、版木と同じく読みと語釈のあいだに○を置きます。

#3 · 版木はグリッドの数値から描く

script.js · 68〜113行コード全体で見る
// Header elements are placed on the sheet, pt from the page's top left corner. Both halves
// read right to left: a right-hand page (even) from the outer frame to the fold, a
// left-hand page (odd) from the fold to the outer frame.
const at = (x, y) => ({ anchor: { to: 'page', edge: 'top-left' }, offset: { x: pt(x), y: pt(y) } });
// A column of characters stands in the middle of its pitch, so the rules between columns
// fall on whole pitches. The k-th, counted from the right edge of the type area:
const line = (parity, k) =>
  (parity === 'even' ? HALF + LINES * PITCH : W - HALF) - k * PITCH;
const [Y0, Y1] = [TOP - GAP, TOP + CHARS * BODY + GAP]; // the inner frame's top and foot
// A rule is drawn from its x, a box's border inside the box: each is set so that the line
// is centred where it belongs.
const rule = (id, x, parity) => ({ kind: 'rule', id, parity, direction: 'vertical',
  thickness: pt(0.6), color: col('rule'),
  placement: { ...at(x - 0.3, Y0), size: { height: pt(Y1 - Y0) } } });
const frame = (id, [x0, x1], parity) => [[RULES, 1.8], [0, 0.6]].map(([out, t], i) => ({
  kind: 'box', id: `${id}-${i}`, parity, style: { borderColor: col('rule'), borderWidth: pt(t) },
  placement: { ...at(x0 - out - t / 2, Y0 - out - t / 2),
    size: { width: pt(x1 - x0 + 2 * out + t), height: pt(Y1 - Y0 + 2 * out + t) } } }));
// The middle of the strip, where its text stands: the fold, halfway between its two rules.
// Both pages draw the text whole, and each shows its half.
const mid = (parity) => (parity === 'even' ? 0 : W);
const strip = (id, content, parity, y) => ({ kind: 'text', id: `${id}-${parity}`, parity,
  content, writingMode: 'vertical-rl', fontFamily: SONG, fontSize: pt(11), color: col('ink'),
  align: 'left', overflow: 'clip',
  placement: { ...at(mid(parity) - HALF, TOP + y),
    size: { width: pt(2 * HALF), height: pt(CHARS * BODY - y) } } });
// The fish tail (魚尾): a black band with a notch, from one side of the strip to the other.
const FISH = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 18">
  <path d="M0 0H32V13L16 6L0 13Z" fill="${palette.rule}"/></svg>`;
const resources = [{ id: 'fish', typeId: 'figure', kind: 'svg', createdAt: 0, updatedAt: 0,
  svg: { fileId: 'fish.svg', width: 32, height: 18 } }];
const fish = (parity) => ({ kind: 'image', id: `fish-${parity}`, parity, resourceId: 'fish',
  decorative: true, placement: { ...at(mid(parity) - HALF + 0.3, TOP + 3.4 * BODY),
    size: { width: pt(2 * HALF - 0.6), height: 'auto' } } });
const furniture = (parity) => [
  // The frame runs 40 pt past the fold, where the other half of the leaf takes it on.
  ...frame(`frame-${parity}`, parity === 'even' ? [-40, line(parity, 0)]
    : [line(parity, LINES), W + 40], parity),
  // Nine rules: eight between the columns (界行) and the side of the strip.
  ...Array.from({ length: LINES }, (_, i) =>
    rule(`rule-${i}-${parity}`, line(parity, parity === 'even' ? i + 1 : i), parity)),
  strip('book', '{title}', parity, 0.7 * BODY), // 書名, above the fish tail
  fish(parity),
  strip('juan', '卷一', parity, 5.2 * BODY), // 卷次, under it
  strip('leaf', '{chapterNumber}', parity, 11.5 * BODY), // 葉碼, the leaf's number
];

ヘッダーは紙面全体に組まれるので、枠、界線、版心は、グリッドを決めた数値を使い、ページの隅からのポイントで配置します。版面には29ptごとに罫要素を置き、細い線には本文を4.5ptの間隔で囲む囲み要素、太い線にはさらに4.5pt外側にもうひとつの囲み要素を使います。文字の各行は行送りの中央に立つので、界線は行と行のちょうど中間に来ます。版心の文字は縦組みのテキスト要素でページの下へ組み、魚尾はSVGの画像要素で、どちらも版心の2本の線の中央、折り目の上に置きます。各ページに見えるのは版心の17pt分です。各ページは版心の文字と魚尾を丸ごと描いて自分の側の部分だけを見せるので、2ページを並べると両方の部分がつながります。枠が折り目を越えて伸びているのも同じ理由です。

#4 · 見返しには専用のスタイルを

script.js · 117〜143行コード全体で見る
// A heading style of its own: hidden and unnumbered, so the leaves still count from 一, and
// its header replaces the leaves' furniture on its page. Its attributes hold the byline,
// this edition's note in red and the colophon, the one line that changes with the language.
const CELLS = [0, 2, LINES - 2, LINES]; // the byline, title and note, in pitches from the right
const cell = (i) => [CELLS[i], CELLS[i + 1]];
const column = (id, content, [k0, k1], style) => ({ kind: 'text', id, content,
  writingMode: 'vertical-rl', color: col('ink'), overflow: 'clip', verticalAlign: 'middle',
  placement: { ...at(line('odd', k1), TOP),
    size: { width: pt((k1 - k0) * PITCH), height: pt(CHARS * BODY) } }, ...style });
const titlePage = {
  id: 'title', numbered: false, hidden: true, breakBefore: { enabled: true, parity: 'any' },
  footer: { elements: [] },
  header: { elements: [
    ...frame('title-frame', [line('odd', LINES), line('odd', 0)]),
    rule('title-rule-1', line('odd', CELLS[1])), rule('title-rule-2', line('odd', CELLS[2])),
    column('byline', '{attr.byline}', cell(0), { fontFamily: SONG, fontSize: pt(14),
      align: 'left' }),
    column('book', '{title}', cell(1), { fontFamily: KAI, fontSize: pt(60),
      letterSpacing: pt(20), align: 'center' }),
    column('note', '{attr.note}', cell(2), { fontFamily: KAI, fontSize: pt(11),
      lineHeight: pt(0.6 * PITCH), color: col('vermilion'), align: 'right' }), // 3 in 2 pitches
    { kind: 'text', id: 'colophon', content: '{attr.colophon}', fontFamily: SONG,
      fontSize: pt(6.5), lineHeight: 1.4, color: col('muted'), align: 'left', overflow: 'wrap',
      placement: { ...at(line('odd', LINES) - RULES - 0.9, Y1 + RULES + 16),
        size: { width: pt(LINES * PITCH) } } },
  ] },
};

見返し(內封)は、非表示で番号のない見出しスタイルを付けたレベル1の見出しなので、丁は「一」から数えたままです。スタイルはその節のページを受け持ち、そこではheaderが文書のものを置き換えます。見返しには、半丁の付き物の代わりに、3つの行に分けた閉じた枠が入ります。著者表示、赤い楷書によるこの版の注記、刊記は見出しの属性から取ります。刊記は、版の言語によって変わるただ1行です。属性の中の\nで次の行に移ります。

#5 · 書体ごとに、組む字だけを読み込む

script.js · 200〜205行コード全体で見る
// Song sets the leaves, the strip and its leaf numbers; Kai only the title page's title
// and note (gotcha: cjk-fonts-slices). No punctuation: no vertical forms to load.
const note = markdown.match(/note="([^"]*)"/)?.[1].replaceAll('\\n', '') ?? '';
await loadFonts(FONTS, markdown); // their Latin files: the colophon
await loadCjkFonts({ [SONG]: FONTS[SONG] }, `${markdown}論語集註卷一二三四五六七八九十`);
await loadCjkFonts({ [KAI]: FONTS[KAI] }, `論語集註${note}`);

Fontsourceは中国語の各書体を、ウェイトごとに約100のファイルに分けて配信しています。宋体は丁の本文、版心、丁付を組むので、その呼び出しには見本の本文とそれらの字を渡します。楷書体が組むのは書名と注記だけです。版木には句読点がないので、どちらの書体にもloadCjkFonts(…, { vertical: true })の縦組み用字形は要りません。

#6 · 温かみのある紙に一色の墨

script.js · 19〜30行コード全体で見る
const palette = {
  ink: '#1f1b17', // the text, as the block printed it
  rule: '#1f1b17', // the frame, the column rules and the fish tail: the same block, same ink
  vermilion: '#a3301f', // 朱: this edition's note, on the title page; 5.9 : 1 on the paper
  muted: '#6d6358', // the colophon
  paper: '#f2ead8',
};
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.ink, model: 'hex' } },
];

本文と版木の線は、紙に対して14 : 1のコントラストの温かみのある黒一色で刷ります。それでもパレットではinkとruleの2項目に分けてあるので、本文を変えずに線の色だけを変えられます。赤は、この版が加えたものに取っておきます。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 085 · A woodblock leaf: double frame, rules and centre strip ═══
// https://postext.dev/en/cookbook/woodblock-leaf
// Code: MIT · Text: 論語集註 卷一, 四庫全書 copy, zh.wikisource (CC BY-SA 4.0) · Pictures: none
// Fonts: Noto Serif TC, LXGW WenKai TC (SIL OFL 1.1) · Needs postext ≥ 1.25.0
// A title page and three leaves of Zhu Xi's commentary on the Analects, set as a woodblock
// printed them: each spread is one leaf, its two halves either side of the centre strip
// (版心), the text in a double frame with a rule between every two columns, the commentary
// folded into two small rows inside the column.
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the colophon; the leaves are Chinese in both
const RECIPE = 'woodblock-leaf';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: one ink on a warm paper, and a red for the editor's note
const palette = {
  ink: '#1f1b17', // the text, as the block printed it
  rule: '#1f1b17', // the frame, the column rules and the fish tail: the same block, same ink
  vermilion: '#a3301f', // 朱: this edition's note, on the title page; 5.9 : 1 on the paper
  muted: '#6d6358', // the colophon
  paper: '#f2ead8',
};
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.ink, model: 'hex' } },
];
// #endregion
const [SONG, KAI] = ['Noto Serif TC', 'LXGW WenKai TC']; // 宋: the block's face; 楷: the title
// The leaf in points: 半葉九行,行十七字, a 20 pt character on a column pitch of 29 pt.
const [BODY, PITCH, CHARS, LINES] = [20, 29, 17, 9];
const HALF = 17; // half the centre strip, from the fold to the column rule beside it
const GAP = 4.5; // the text to the inner frame line, as a character to a column rule
const RULES = 4.5; // the thin inner frame line to the heavy outer one (文武線)
const [HEAD, FOOT, SIDE] = [164, 82, 60]; // paper outside the frame: 天頭 twice 地腳
const TOP = HEAD + RULES + GAP; // the page's margins
const BOTTOM = FOOT + RULES + GAP;
const OUTER = SIDE + RULES;
const W = HALF + LINES * PITCH + OUTER; // a half-leaf, 121 × 213 mm
const H = TOP + CHARS * BODY + BOTTOM;

// #region answer: a half-leaf to a page, so that every spread is one whole leaf
// A block printed both halves of a leaf (葉) at once, the centre strip between them. Each
// page here is a half-leaf. Page 1, the title, is a recto: in a book bound on the right it
// stands alone left of the spine, and every spread after it is one leaf, read from the

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

アレンジ

#界線を赤で引く

四庫全書のために作られた写本は、赤い罫を引いた紙(朱絲欄)に書かれていました。罫の色を変えると、魚尾もそれに従います。

-  rule: '#1f1b17', // the frame, the column rules and the fish tail: the same block, same ink
+  rule: '#b3412e', // 朱絲欄: red rules under black text

#別の版木を彫る

版木の行款はさまざまで、半葉十行,行二十字はもっともよく見られるもののひとつです。枠、版心、見返しの3つの区画、著者表示の字下げはすべてこれらの数値から算出するので、自動的に追従します。Markdownの中の丁の区切りは数え直す必要があります。

-const [BODY, PITCH, CHARS, LINES] = [20, 29, 17, 9];
+const [BODY, PITCH, CHARS, LINES] = [17, 24.5, 20, 10];

#欧文のグリッドのページと比べる

ベースライングリッドに組む本のページは、この丁が行と字数から版面を組むように、行数から版面を組みます。修了証は、ここでの見返しと同じく、見出しスタイルのヘッダーに縁取りを描いています。

よくあるつまずき

つまずき

文書のタグはLANGではなくzh-Hansかzh-Hantにする

レシピの版はenとesですが、中国語のサンプルはどちらの版でも中国語です。`locale: LANG`では英語やスペイン語とタグ付けされ、ラテン文字の語がハイフネーションされ、図にFigureやFiguraの表示名が付き、PDFの言語も誤ります。postext 1.30以降、このタグはテキストを組む言語(計測、描画、埋め込みに使う言語)でもあるので、英語やスペイン語のタグでは、中国語のフォントの数字と、ラテン文字のテキストと共通の約物が別の字形になり、改行の位置も変わります。タグは自分で書いてください。'zh-Hans'(中国本土の慣習:GBの改行規則、開明式の約物)または'zh-Hant'(台湾:全角で中央に置く約物)、香港なら'zh-HK'です。単なる'zh'は簡体字、本土として読まれます。日本語のサンプルには'ja'を使います(つまずき「ja-locale-tag」)。 中国語の改行 →

つまずき

中国語の書体は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]と指定します。 右綴じの本 →

つまずき

繁体字の翻刻には簡体字が紛れ込んでいることがある

Wikisourceなどのウェブ版から写した繁体字の本のテキストには、簡体字の字形が交じっていることがあります(『三國演義』第1回の、顒に対する颙)。Noto Serif TCのようなTCの書体にはその字がない場合があります。loadCjkFontsはその文字をメッセージに示してサンプルの実行を止めます。ページ上では代替の書体で印字されることになります。サンプルでは繁体字の字形に戻し、そのことをクレジットに書いてください。 中国語・日本語・韓国語のフォント →

  • 丁の区切りはMarkdownの中にあります。本文、大きさ、行款を変えると、あふれた丁が次の見出しを1ページ先へ押し出し、見開きと丁が合わなくなります。足りない丁は、折り目の手前に空の行を残します。すべての左ページの最終行を確かめてください。
  • 四庫全書の翻刻は、已も己も同じく巳と入力しています。この見本では、それぞれを文脈から読み分けています。それでもこのテキストは影印と照らし合わせた校正を必要としており、それが表に出ています。張敬夫の言葉は必開其政となっていますが、彼が引く『論語』では必聞其政です。また2字は字形の画像になっています。見本では聞、傳、邦と組んでいます。組む前に、一節を別の版と照合してください。
  • 同じ翻刻には、Noto Serif TCにグリフのない字形(廹 徳 絶 逺 専 内)が含まれます。そのうち5字はFontsourceのいずれかのファイルの範囲に入るので、loadCjkFontsは通してしまい、Canvasはシステムの書体で描き、postext-pdfは空の四角を印字して警告を出します。廹はどのファイルの範囲にも入らないので、loadCjkFontsはエラーで止まります。見本では迫 德 絕 遠 專 內と組んでいます。

クレジット

レシピ
Ignacio Ferro
本文
  • 論語集註 (Collected Commentaries on the Analects), juan 1, the book 學而 from its opening to the end of its tenth section, in the copy made for the 四庫全書 (Siku quanshu, 1773–1782); Wikisource transcription, revision 523110. 巳 is read as 已 or 己 by its sentence; 開 in 張敬夫's 必開其政 is corrected to 聞, as in the words of the Analects he repeats and in Wikisource's other edition (論語集注卷一, revision 2598582); the two characters the transcription gives as glyph images are set as 傳 (以忠信為傳習之本) and 邦 (夫子至於是邦也); and six variant forms Noto Serif TC does not draw (廹 徳 絶 逺 専 内) are set in their standard forms · Zhu Xi (1130–1200); transcription by Wikisource editors · CC BY-SA 4.0
  • The title page, the division into leaves and the note on this edition (據四庫全書本錄文…) · Ignacio Ferro · CC BY 4.0
フォント
Noto Serif TC (SIL OFL 1.1) · LXGW WenKai TC (SIL OFL 1.1)
SandboxPDF