かんたんな説明
1912年の中国語の文書2編を、上から下へ読む縦の行で印刷した例です。日付や数字、ラテン文字を縦組みの文章の中で読みやすく組む方法を示します。
できあがり
中華民国の建国期の文書2編を収めた7ページの読本です。1912年1月1日の就任にあたって孫文が発した宣言書と、3月11日の臨時約法の第1章・第2章を、右綴じの184 × 260 mmのページに縦組みで組みます。文書そのものは漢数字のまま、民國元年三月十一日と書きます。楷書体の解題と注は、西暦の日付、数量、号数をアラビア数字で示しており、このレシピが組むのはその数字です。10月10日は1字分に数字1つずつ正立し、1912とSun Yat-senは横倒しになり、民國115年は3桁を1字分に収め、ROCは文字を縦に積みます。二重罫に囲まれた朱色の表紙、各文書の冒頭の朱色の帯、漢数字のノンブルを伴う小口側の柱が本文を囲みます。
このレシピが答える質問
- 縦組みの中で、日付や数字を正立させるには?
- 中国語の本を縦組み・右綴じで組むには?
- 版面を字数で設定し、1行の字数と1ページの行数を決めるには?
手短な答え
const layout = { layoutType: 'single', writingMode: 'vertical-rl' }; // binding 'auto': right
const cjk = {
// 10月10日: each number of up to two digits stands upright in one cell (tate-chu-yoko);
// 1912 and Sun Yat-sen stay on their side, as clreq sets long numbers and Latin words.
uprightDigits: 2,
// The type area in characters: 44 down each line, 19 lines to the page.
grid: { enabled: true, charsPerLine: CHARS, linesPerPage: 19 },
};
// By hand, in the Markdown: 民國:tcy[115]年 puts three digits in one cell, :upright[ROC]
// stands each letter of an acronym upright, :sideways[…] turns any run with the line.
材料
- 機能
- 縦組みの中の正立した数字縦組み右綴じの本文字グリッド中国語の漢数字中国語・日本語・韓国語のフォント中国語の約物の幅中国語の改行デザインした章扉見出しスタイル見出しの属性段落スタイル柱とノンブルページデザインのテキスト・罫・ボックス用紙の色セマンティックカラーパレットPDFの書き出しPDFに埋め込むフォント
- 種類
- Noto Serif TC, Noto Sans TC, LXGW WenKai TC (SIL OFL 1.1)
- 素材
- なし:画像はすべてコードで描画
作り方
#1 · 短い数字は設定に任せる
コードは上の手短な答えにあります。cjk.uprightDigits: 2にすると、縦組みの中の1桁か2桁の数字の並びはすべて1字(1 em)分の枠に正立し、2桁なら横に並びます。10月10日、第35號、7章56條にマークアップは要りません。それより長い数字はラテン文字の語と同じく全体が横倒しになります。clreqも4桁の数字をそう組むので、1912や1644は90°回って行に沿って読まれます。正立させたい3桁の数字には印を付けます。民國:tcy[115]年は115を1字分に詰めます。:upright[ROC]は文字を1字ずつそれぞれの枠に縦に立て、その中では行を分割しません(縦組みの数字)。

1912年の本文は刊行当時のままです。編者の注は台湾の数字表記の規則、2004年の行政院による公文書橫式書寫數字使用原則に従います。日付、番号、数量はアラビア数字(1912年3月8日、第35號、7章56條)、固有名詞、成句、概数は漢数字(東三省、四萬萬、四億)で、旧暦の日付、辛亥年八月十九日も漢数字です。注が文書の見出しや用語を引くときは、第一章や二十二行省のように元の形を保ちます。これらの規則は横組みの文書のために書かれたものです。縦に組むと、その数字こそがレシピで正立させなければならないものになります。
#2 · 各文書を右側の帯で始める
// The margins are minimums: the grid centres the 44 characters (186.3 mm) between them,
// so the type area starts HEAD mm down the sheet. The band's title starts there too.
const HEAD = MARGIN.top + (TRIM.h - MARGIN.top - MARGIN.bottom - LINE) / 2;
const BAND = 42; // mm from the right trim edge: where a reader of vertical text starts
const onBand = { color: col('paper'), overflow: 'wrap' };
// In the flow of a vertical page x runs down the sheet and y leftward from its right edge.
const at = (x, y, extra = {}) => ({ anchor: { to: 'page', edge: 'top-left' },
offset: { x: mm(x), y: mm(y) }, ...extra });
const opener = {
enabled: true,
minHeight: mm(BAND - 15), // past the side margin (21.6 mm), 6 mm of paper before the text
slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('seal') },
placement: { anchor: { to: 'bleed', edge: 'top-left' }, size: { height: mm(BAND) } } },
{ kind: 'text', id: 'title', content: '{titleText}', ...onBand, fontFamily: HEI,
fontWeight: 700, fontSize: pt(34), lineHeight: 1.2, letterSpacing: pt(4), align: 'left',
placement: at(HEAD, 8) },
{ kind: 'text', id: 'latin', content: '{attr.latin}', ...onBand, fontFamily: HEI,
fontSize: pt(9), lineHeight: 1.6, align: 'left', placement: at(HEAD, 25) },
// The date ends where the lines of text end: align 'right' is the foot of a vertical line.
{ kind: 'text', id: 'date', content: '{attr.date}', ...onBand, fontFamily: HEI,
fontWeight: 500, fontSize: pt(13), lineHeight: 1.2, align: 'right',
placement: at(HEAD, 24, { size: { width: mm(LINE) } }) },
] },
};
縦の流れでは、ページの上は紙面の右端、つまり読み始めの位置です。そのため塗り足しの上端に固定した見出しデザインは右端を縦に走る帯になり、size.heightが紙面上での帯の幅になります。オフセットも流れとともに回り、xは紙面の下方向へ、yは左方向へ測ります。グリッドは版面を余白の間の中央に置き、HEADがその和を繰り返すので、題はすべての行の1字目と同じ高さから始まります。align: 'right'は日付を行の地側、本文の行が終わる位置に置きます。cjk.uprightDigitsはデザインの文字にも効くので、3月11日の11は本文と同じく1字分に正立します。帯は裁ち落としの帯を敷いた章扉のものを90°回したものです。
見出しデザインには奇数・偶数の区別がないので、帯はつねに紙面の右端を走ります。右ページである2ページ目ではその端は小口ですが、右綴じの本の左ページである5ページ目では背になり、題は折り目から8 mm、21.6 mmののどの余白の内側から始まります。ホチキス留めの読本ならそれでも十分に開きます。糸綴じや無線綴じの本では、breakBefore.parity: 'even'で各文書を右ページから始めてください。その場合5ページ目は白ページになります。

#3 · 柱を小口側に置く
const foreEdge = (id, content, edge, y) => ({
kind: 'text', id, content, writingMode: 'vertical-rl', pages: 'body', align: 'left',
fontFamily: HEI, fontSize: pt(9.6), color: col('muted'), overflow: 'clip',
placement: { anchor: { to: 'outer', edge }, offset: { y: em(y) } },
});
const header = { elements: [
foreEdge('head', '{chapterTitle}', 'top', 4), // four characters below the type area
foreEdge('folio', '{pageNumber}', 'bottom', -5), // ends five characters above its foot
] };
anchor.to: 'outer'は背から遠い側の余白を指します。右綴じの本では、柱は奇数ページの左端と偶数ページの右端を縦に走ります。書名は版面の頭から4字下がって始まり、ノンブルは版面の地から5字上で終わります。どちらも本文サイズの80 %で縦に組みます(縦組みのテキスト要素)。pageNumbering.format: 'trad-chinese-informal'でノンブルは三、四、六、七と刷られ、pages: 'body'で2つの章扉には入りません。
#4 · ページ幅のデザインで表紙を裁ち落としまで塗る
const frame = (id, inset, width) => ({ kind: 'box', id,
style: { borderColor: col('tint'), borderWidth: pt(width) },
placement: at(inset, inset, { size: { width: mm(TRIM.h - 2 * inset),
height: mm(TRIM.w - 2 * inset) } }) });
const coverLine = (id, content, y, align) => ({ kind: 'text', id, content, ...onBand,
fontFamily: HEI, fontWeight: 500, fontSize: pt(18), lineHeight: 1.2, align,
placement: at(HEAD, y, { size: { width: mm(LINE) } }) });
const cover = {
id: 'cover', numbered: false, toc: false, runningChapter: false,
span: 'page', // a page-wide design is not cut at the foot of the column: the field bleeds
header: { elements: [] }, footer: { elements: [] },
advancedDesign: { enabled: true, slot: { elements: [
{ kind: 'box', id: 'field', style: { backgroundColor: col('seal') },
placement: { anchor: { to: 'bleed', edge: 'top-left' }, size: { height: mm(TRIM.w) } } },
frame('rule-outer', 11, 1.6), frame('rule-inner', 13, 0.5), // 文武線: thick, then thin
{ kind: 'text', id: 'title', content: '{titleText}', ...onBand, fontFamily: HEI,
fontWeight: 700, fontSize: pt(56), lineHeight: 1.1, letterSpacing: pt(5.6), align: 'left',
placement: at(HEAD, 26) },
{ kind: 'text', id: 'latin', content: '{attr.latin}', ...onBand, fontFamily: HEI,
fontSize: pt(11), lineHeight: 1.4, align: 'left', placement: at(HEAD, 51) },
coverLine('first', '臨時大總統宣言書', 104, 'left'),
coverLine('first-date', '1912年1月1日', 104, 'right'),
coverLine('second', '中華民國臨時約法', 118, 'left'),
coverLine('second-date', '1912年3月11日', 118, 'right'),
] } },
};
段の中の見出しデザインは段の地で切られます。縦組みのページではその地は左の余白なので、塗り足しに固定した地色は左の仕上がり線の21.6 mm手前で止まっていました。span: 'page'にすると見出しはページ幅の帯として組まれ、切られないので、地色は両端に届きます。2つの枠は中国の刊本の太細の二重罫を描き、太さは1.6 ptと0.5 pt、間隔は2 mmです。
#5 · 声ごとに、その声が組む文字でフォントを読み込む
const voice = (styles) => (markdown.match(
new RegExp(`:::paragraphs\\{style="(?:${styles})"\\}[\\s\\S]*?:::`, 'g')) ?? []).join('');
const kaiText = voice('headnote|note');
// Hei: headings and their attributes, seals, colophon, the cover's lines, folios 一 to 十.
const heiText = (markdown.match(/^#.*$/gm) ?? []).join('') + voice('seal|colophon')
+ '臨時大總統宣言書1912年1月1日中華民國臨時約法1912年3月11日一二三四五六七八九十';
Fontsourceはこれらの書体のウェイトごとに、文字の範囲を分担する約100個のファイルを配信しており、loadCjkFontsはテキストが触れるファイルを読み込みます。見出し、印記、奥付、表紙の行、ノンブルだけを渡すと、Noto Sans TCは各ウェイトで10ファイルを読み込みます。見本全体を渡すと35ファイルになり、それがウェイト3つ分です。LXGW WenKai TCには解題と注を渡し、16ファイルを読み込みます。渡したテキストが足りない書体があると、キャプチャーは失敗し(C12)、フォールバックの書体から借りなければならなかった文字を挙げます。
レシピの全体
// ═══ Postext Cookbook · Nº 081 · Dates and acronyms upright in vertical text ═══════
// https://postext.dev/en/cookbook/chinese-dates-upright
// Code: MIT · Text: 1912 documents, zh.wikisource (CC BY-SA 4.0); notes (CC BY 4.0)
// Fonts: Noto Serif TC, Noto Sans TC, LXGW WenKai TC (SIL OFL 1.1) · Needs postext ≥ 1.25.0
// Two founding documents of the Republic of China, 1912, set vertically as a reader.
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 sample document ('en' | 'es')
const RECIPE = 'chinese-dates-upright';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: ink, the vermilion of a seal, and the paper of a gazette
const palette = {
ink: '#1e1a17', // text: a warm near-black
seal: '#b1291f', // the one accent: the bands, the seal notes, the chapter heads
tint: '#f6dccf', // the cover's double rule, a pale vermilion
muted: '#6d645b', // fore-edge heads, the colophon
paper: '#fffdf8',
};
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: 'seal (defaults)', value: { hex: palette.seal, model: 'hex' } },
];
// #endregion
const SONG = 'Noto Serif TC'; // 宋/明: the documents
const HEI = 'Noto Sans TC'; // 黑: titles, heads, labels
const KAI = 'LXGW WenKai TC'; // 楷: the editor's headnotes and notes
const BODY = 12; // pt, 小四
const LEAD = 21; // pt: a line gap of 0.75 em
const CHARS = 44; // characters to a line
const LINE = (CHARS * BODY * 25.4) / 72; // mm: the length of a line, 186.3
const TRIM = { w: 184, h: 260 }; // mm, 16开
const MARGIN = { top: 30, bottom: 22, side: 20 }; // mm, minimums: 天头 deeper than 地脚
// #region answer: vertical text where numbers of one or two digits stand upright
const layout = { layoutType: 'single', writingMode: 'vertical-rl' }; // binding 'auto': right
const cjk = {
// 10月10日: each number of up to two digits stands upright in one cell (tate-chu-yoko);
// 1912 and Sun Yat-sen stay on their side, as clreq sets long numbers and Latin words.
uprightDigits: 2,
// The type area in characters: 44 down each line, 19 lines to the page.
grid: { enabled: true, charsPerLine: CHARS, linesPerPage: 19 },
};
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
よくあるつまずき
つまずき
中国語の書体はcjkブロックを通じてスライス単位で読み込む
Fontsourceは中国語、日本語、韓国語のファミリーを、ウェイトごとに約100個のファイルとして配信し、各ファイルが文字の範囲を受け持ちます。loadFontsが取得するのはlatinファイルだけなので、画面では漢字がシステムの書体で出て計測が狂い、fontsourceProviderはPDFにそのlatinファイルを渡すため、漢字が空の四角で印字されます。キットのcjkブロックを挙げ、loadFontsのあとにloadCjkFonts(FONTS, markdown)を呼び(本で複数のCJK書体を使うときは、それぞれの書体で組むテキストを渡して書体ごとに1回)、renderToPdfにfontProvider: cjkPdfProviderを渡してください。どちらもテキストの文字を含むファイルを取得します。 中国語・日本語・韓国語のフォント →
つまずき
文書のタグは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」)。 中国語の改行 →
つまずき
右綴じの本の見開きはshowBookで表示する
右綴じの本(アラビア語、ヘブライ語、ペルシア語のテキスト、縦組みの中国語、またはpage.binding 'right')でも1ページは奇数ページですが、背の左側に来て、見開きは[3 | 2]と並びます。showPagesはどの本も左綴じとして並べます。bookブロックのshowBook(cjkブロックにも同じ関数があります)はdoc.bindingを読み、見開きを左右反転します。capture.heroでは、見開きは引き続き読む順の[偶数ページ, 奇数ページ]、つまり[2, 3]と指定します。 右綴じの本 →
- Fontsourceが配信するNoto Serif TCには爲と敎がありません。スタイルシートには両方が載っていますが、そのグリフを含むファイルがありません。1912年刊の約法は、為と教をこの爲と敎の形で書いています。Canvasは敎をシステムの書体で描き、PDFにはそのグリフがなく、キャプチャーがそれを報告しました(C25)。この読本は為と教で組み、それに合わせて靑と决も青と決にそろえ、そのことを解題に記しています。
- Fontsourceが配信するLXGW WenKai TCは、即、為、青、教を古い字形の卽、爲、靑、敎で描くため、宋体の本文にある同じ字と並ぶと違和感があります。注はこの4字を使わない文言にしてあり、約法の旧字形を列挙する解題だけがそれを必要とします。自分の注の楷書体のテキストは原寸で読んで確かめてください。
- 横倒しにした数字は、ラテン文字の語と同じく隣の中国語との間に左右4分の1 emずつのアキを取ります(
cjk.latinSpacing)。そのため解題は1912 年のように見えます。1字分に収めた数字は漢字と同じくアキを取りません。
クレジット
- 本文
- Sun Wen (Sun Yat-sen), proclamation on taking office as Provisional President, 1 January 1912, from the original in the Guangzhou Museum · Sun Wen; transcription and punctuation by Wikisource editors · CC BY-SA 4.0
- Provisional Constitution of the Republic of China, 11 March 1912 (Linshi zhengfu gongbao no. 35), chapters 1 and 2, with its promulgation order; four old character forms set in their current forms · Provisional Senate, Nanjing; transcription by Wikisource editors · CC BY-SA 4.0
- The headnotes and notes in Chinese, written for this recipe · Postext Cookbook · 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)


