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

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

固有名詞の傍線と書名の波線を縦組みと横組みで

:nameと:bookの印を付けた「項羽本紀」を、右綴じの縦組みのページと横組みのページに組みます。線は縦組みでは名前の左、横組みでは下に付きます。

このページの内容
ジャンル
教科書
出力
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/3

  • 英語の見本:日本語版はまだありません
  • 仕上がり140 × 203 mm
  • 1段
  • Noto Serif TC 10.5/18
  • LXGW WenKai TC
  • Noto Sans TC
  • 3ページ
  • レベル
  • Postext 1.65.0
  • 組版時間76 ms
  • コード168行

かんたんな説明

中国の古典的な歴史書の見本ページです。人名などの固有名詞に赤い直線を、書名に波線を付ける方法を、縦組みと横組みの両方で示します。

できあがり

『史記』の読本のための見本ページ3枚を、中国の大32開の本の仕上がり寸法、140 × 203 mmで組みます。本文は「項羽本紀」の冒頭で、古典の校訂本の全式標点を施しています。人物、地名、国、王朝のすべてに直線を、書名と篇名のすべてに波線を付け、どちらも朱で刷ります。1ページ目は前書きと編者の凡例を楷書体で組みます。2ページ目と3ページ目は同じMarkdownを縦組みと横組みで2度組むので、見開きで印の位置の違いがわかります。縦組みでは名前の左、横組みでは名前の下です。本は右綴じで、藍色の帯がそれぞれのタイトルを載せます。No. 044、1645年版の本文による『Lycidas』では、名前をヨーロッパの流儀でイタリックにして区別しています。

このレシピが答える質問

  • 中国語の固有名詞と書名に、直線と波線の傍線を付けるには?
  • 中国語の強調がイタリックで印字されるのはなぜですか?代わりに何を使えばいいですか?
  • 中国語の本を縦組み・右綴じで組むには?

手短な答え

script.js · 45〜62行コード全体で見る
// :name[項梁] draws the proper-name line, :book[史記] the book-title mark, :dots[…] dots.
const cjk = {
  bookTitleMark: 'wavy', // zh-Hant's default; mainland editions of the classics use it too
  annotationColor: col('mark'), // unset, the marks print in the colour of the text
  grid: { enabled: true, charsPerLine: CHARS, linesPerPage: LINES },
};
// The book runs down the page, bound on the right: the lines stand left of the names.
const layout = { layoutType: 'single', writingMode: 'vertical-rl' };
// # 項羽本紀 {style="across"} sets the same Markdown across the page, 28 characters to
// the line: the lines run under the names. Its margins set its grid; the book's grid
// counts down the page.
const MEASURE = 28 * SIZE * PT; // mm
const across = {
  id: 'across',
  layout: { layoutType: 'single', writingMode: 'horizontal-tb' },
  margins: { top: mm(SIDE), bottom: mm(H - SIDE - 25 * LEAD * PT), // 25 lines
    left: mm((W - MEASURE) / 2), right: mm((W - MEASURE) / 2) },
};

材料

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

作り方

#1 · 印はマークアップが付け、位置は組み方向が決める

コードは前出の手短な答えにあります。:name[項梁]と:book[史記]は文字をテキストに残したまま、その横に印を付けます(中国語の記号、ルビ、割注)。そのため検索、コピーしたテキスト、PDFでは項梁と史記として読めます。印の側は組み方向だけで決まります。layout.writingMode: 'vertical-rl'は線を文字の左に置き、レイアウトが'horizontal-tb'の見出しスタイルacrossは線を下に置きます。bookTitleMark: 'wavy'はzh-Hantの文書の既定値ですが、明示しています。zh-Hansに切り替えたときに書名が《》で刷られないようにするためです。東漢班固や史記項羽本紀のように同じ種類の印が2つ接する場合は、接する側の端をそれぞれ8分の1 emずつ詰めるので、線は2つの名前として読めます。

#2 · 印の場所を確保した行送り

script.js · 32〜41行コード全体で見る
const [SONG, HEI, KAI] = ['Noto Serif TC', 'Noto Sans TC', 'LXGW WenKai TC']; // 宋, 黑, 楷
const PT = 25.4 / 72; // mm in a point
const [W, H] = [140, 203]; // mm: 大32開
const SIZE = 10.5; // pt: 五號
// A gap of 7.5 pt (0.71 em) between lines: a line of marks needs half an em of it, dots on
// one side and lines on the other five eighths. At 15 pt the build reports every marked
// paragraph (cjkMarksExceedLeading: gap 0.43 em).
const LEAD = 18; // pt
const [CHARS, LINES] = [42, 17]; // the vertical grid: characters down a line, lines across
const SIDE = (W - LINES * LEAD * PT) / 2; // mm: the side margins of a vertical page

印は行と行の間に置かれ、行送りを変えることはありません(圏点と傍線、ルビ、割注)。10.5 ptの文字を18 ptの行送りで組むと行間は0.71 emで、1ページ目の5つ目の凡例のように、ある行の名前の線と隣の行の点の両方が収まります。グリッドはページを字数で数えます。1行42字、17行です。版面がちょうどその大きさになるよう余白を動かし、天に25.7 mm、地に21.7 mmの余白を取ります(文字グリッド)。

#3 · ページとともに向きを変えるひとつの章扉

script.js · 66〜89行コード全体で見る
// The grid centres the text between the minimum margins; the band stops at its foot.
const FOOT = 20 + (H - 24 - 20 - CHARS * SIZE * PT) / 2; // mm, with minimums of 24 and 20
const BAND = SIDE + 3.5 * LEAD * PT; // mm from the trim, which is the right edge down the page
const onBand = { align: 'left', overflow: 'wrap' }; // design text centres and cuts by default
const next = (id, y) => ({ anchor: { to: `#${id}`, edge: 'below' }, offset: { y: mm(y) } });
const opener = {
  enabled: true,
  minHeight: pt(4 * LEAD), // the text starts on the fifth line, half a line clear of the band
  slot: { elements: [
    // Across the page the band's length runs past the trim; down it, it ends at the text's
    // foot, clear of the folio.
    { kind: 'box', id: 'band', style: { backgroundColor: col('band') },
      placement: { anchor: { to: 'bleed', edge: 'top-left' },
        size: { width: mm(H - FOOT), height: mm(BAND) } } },
    { kind: 'text', id: 'kicker', content: '{attr.kicker}', ...onBand, fontFamily: HEI,
      fontWeight: 700, fontSize: pt(8), letterSpacing: pt(1.6), color: col('tint'),
      placement: { anchor: { to: 'container', edge: 'top-left' }, offset: { y: mm(6 - SIDE) } } },
    { kind: 'text', id: 'title', content: '{titleText}', ...onBand, fontFamily: SONG,
      fontWeight: 700, fontSize: pt(46), lineHeight: 1, letterSpacing: pt(3),
      color: col('paper'), placement: next('kicker', 2) },
    { kind: 'text', id: 'byline', content: '{attr.byline}', ...onBand, fontFamily: KAI,
      fontSize: pt(10), color: col('tint'), placement: next('title', 2) },
  ] },
};

見出しのデザインはそのページの流れに沿って組まれるので、ひとそろいの要素で両方の組み方向に対応できます(縦組み)。塗り足しの左上に固定した帯は、横組みのページでは天を横切り、縦組みのページでは読み始めの右端を縦に走ります。キッカー、タイトル、著者名も流れに沿って積み重なります。横組みでは上から下へ、縦組みでは右から左へ並びます。帯の長さは流れの方向に測ります。181.3 mmにすると、縦組みでは本文の地で止まってノンブルにかからず、横組みのページでは仕上がり線を越えて伸びます。

#4 · 右綴じの本のノンブル

script.js · 93〜102行コード全体で見る
const foot = (id, content, parity, edge, x, extra) => ({ kind: 'text', id, content, parity,
  fontFamily: HEI, fontSize: pt(7), color: col('muted'), ...extra,
  placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(-11) } } });
const folio = { fontFamily: SONG, fontSize: pt(9) };
// Bound on the right, a recto (odd) lies left of the spine: its outer edge is its left one.
const footer = { elements: [
  foot('folio-odd', '{pageNumber}', 'odd', 'bottom-left', SIDE, folio),
  foot('folio-even', '{pageNumber}', 'even', 'bottom-right', -SIDE, folio),
  foot('slug', '{attr.slug}', 'all', 'bottom', 0, { letterSpacing: pt(0.4) }),
] };

縦組みの本は右綴じになります(綴じ)。1ページ目は背の左にあり、奇数ページの小口は左側です。奇数ページのノンブルは左下、偶数ページのノンブルは右下で、欧文の本とは逆になります。pageNumbering.format: 'trad-chinese-informal'で、一、二、三と刷ります。その間に入るスラグの行は、各見出しの属性slug="…"から取ります。奥付とこのスラグが、英語版とスペイン語版で変わる部分のすべてです。

#5 · 2色目のインク

script.js · 17〜29行コード全体で見る
const palette = {
  ink: '#221e1b', // the text
  band: '#23394b', // the opener band and the small heads
  mark: '#b5412c', // the name, title and emphasis marks: the second ink
  tint: '#c7d2da', // kickers and bylines on the band
  muted: '#6f6a64', // folios, slug lines, 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' } })),
  { id: 'main-color', name: 'band (defaults)', value: { hex: palette.band, model: 'hex' } },
];

古典の校訂本では、印を本文と同じインキで刷ります。学生向けの読本なら、2色目で刷って文字の画と区別できます。annotationColorは印をパレットのmark、つまり朱で書き入れた注釈の朱色にリンクします。この項目をひとつ変えるだけで、本のすべての線と点の色が変わります。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 077 · Proper-name and book-title marks, across and down ═════
// https://postext.dev/en/cookbook/proper-name-marks
// Code: MIT · Text: Sima Qian, Shiji 7 (PD) · Punctuation, headnote, conventions: CC BY 4.0
// Fonts: Noto Serif TC, Noto Sans TC, LXGW WenKai TC (SIL OFL 1.1) · Needs postext ≥ 1.25.0
// Specimen pages for a classical reader: the opening of the Basic Annals of Xiang Yu with
// its proper-name lines and wavy title lines, set down the page and then across it.
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 slug lines and the colophon ('en' | 'es')
const RECIPE = 'proper-name-marks';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: the indigo of a thread-bound cover, vermilion for the marks
const palette = {
  ink: '#221e1b', // the text
  band: '#23394b', // the opener band and the small heads
  mark: '#b5412c', // the name, title and emphasis marks: the second ink
  tint: '#c7d2da', // kickers and bylines on the band
  muted: '#6f6a64', // folios, slug lines, 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' } })),
  { id: 'main-color', name: 'band (defaults)', value: { hex: palette.band, model: 'hex' } },
];
// #endregion
// #region type: 五號 on 18 pt, 42 characters by 17 lines down the page
const [SONG, HEI, KAI] = ['Noto Serif TC', 'Noto Sans TC', 'LXGW WenKai TC']; // 宋, 黑, 楷
const PT = 25.4 / 72; // mm in a point
const [W, H] = [140, 203]; // mm: 大32開
const SIZE = 10.5; // pt: 五號
// A gap of 7.5 pt (0.71 em) between lines: a line of marks needs half an em of it, dots on
// one side and lines on the other five eighths. At 15 pt the build reports every marked
// paragraph (cjkMarksExceedLeading: gap 0.43 em).
const LEAD = 18; // pt
const [CHARS, LINES] = [42, 17]; // the vertical grid: characters down a line, lines across
const SIDE = (W - LINES * LEAD * PT) / 2; // mm: the side margins of a vertical page
// #endregion

// #region answer: marks by the markup, their side by the writing mode
// :name[項梁] draws the proper-name line, :book[史記] the book-title mark, :dots[…] dots.
const cjk = {
  bookTitleMark: 'wavy', // zh-Hant's default; mainland editions of the classics use it too
  annotationColor: col('mark'), // unset, the marks print in the colour of the text

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

アレンジ

#書名を《》で刷る

古典以外の中国大陸の本では、書名を括弧でくくります。Markdownはそのままで、括弧は本文の約物として刷られます。

-  bookTitleMark: 'wavy', // zh-Hant's default; mainland editions of the classics use it too
+  bookTitleMark: 'brackets', // 《史記》《項羽本紀》

#印を本文のインクで刷る

annotationColorを指定しなければ、各印はそれが付くブロックの色になります。

-  annotationColor: col('mark'), // unset, the marks print in the colour of the text

よくあるつまずき

つまずき

文書のタグは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]と指定します。 右綴じの本 →

つまずき

中国語にはイタリックがない

CJKのファミリーにはイタリックがなく、中国語の組版では強調を傾きではなく、文字の横の圏点で示します。中国語とタグ付けした文書では、*…*は中に含む漢字に圏点を付け、ラテン文字の語にはイタリックを使います(cjk.emphasis: 'dots'、中国語の既定)。:dots[…]はどこでも圏点を付けます。cjk.emphasis: 'italic'の場合や、enやesとタグ付けした文書では、*…*によってCanvasが立体のグリフを傾けます。中国語の組版では使わない擬似斜体です(PDFでは立体にフォールバックします)。中国語のタグを保つか、段落スタイルやチップスタイルで強調を太字や楷書体(LXGW WenKai)にしてください。 中国語・日本語・韓国語のフォント →

レイアウト警告 · cjkMarksExceedLeading

圏点・傍線が次の行に接触

原因. 圏点、または専名線・書名線のある段落の行間が0.5em未満です(両側に印がある場合は5/8em未満)。印は行間に置かれ、行間の高さは印のために変わらないため、次の行に接してしまいます。

対処. 行送りの大きい段落スタイルをその段落に与えるか、`bodyText.lineHeight`を大きくしてください。 ドキュメント →

  • デザインで描く見出しはタイトルをデザインを通して刷り、デザイン要素のテキストは印を落とします。# :book[項羽本紀]と書いても、帯には波線が出ません。柱、キャプション、表のセルも、テキストを印なしで刷ります。
  • PostextはcjkMarksExceedLeadingで止まりません。ビルドはdoc.contentWarningsにこれを挙げ、Sandboxの「検査」パネルにも表示されますが、ページはそのまま刷られ、印が次の行に食い込みます。行送りを変えたらこの一覧を確かめてください。15 ptにすると、これらのページの印の付いた段落がすべて一覧に入ります。

クレジット

レシピ
Ignacio Ferro
本文
  • The opening of the Basic Annals of Xiang Yu (項羽本紀), Records of the Grand Historian (史記), chapter 7; characters from the zh.wikisource transcription · Sima Qian (司馬遷) · パブリックドメイン
  • The punctuation, the paragraphs and the marks of the passage, the headnote (題解), the conventions (凡例), the slug lines and the colophon · Ignacio Ferro · CC BY 4.0
フォント
Noto Serif TC (SIL OFL 1.1) · Noto Sans TC (SIL OFL 1.1) · LXGW WenKai TC (SIL OFL 1.1)
SandboxPDF