かんたんな説明
縦組みで印刷した町内会の会報。日本語で数を書くいくつもの書き方と、縦組みでも日付を読みやすく保つ方法を示します。
できあがり
町内会の会報『東若葉台だより』第百二十号の縦組み4ページを、右綴じのB5判で組みます。内容は夏祭りのお知らせ、8月のカレンダー、会費と寄付の領収書、町会の短い歩みです。町会は架空ですが、数は日本の編集者が書くとおりに書きます。号数、祭りの第三十二回、来場した二千四百人は十・百・千を使って数えます。年は二〇二六年、一九六〇年のように1桁ずつ書きます。領収書の金額は、画を書き足して改ざんすることのできない大字で壱萬弐阡と書きます。時刻と日付は算用数字で、22は縦中横で1字分に正立させます。リストは一、→(一)→イ→あと下り、カレンダーが裏表紙になります。
このレシピが答える質問
- 章番号を第一章のように漢数字で振ったり、リストの項目をあいう、イロハで振ったりするには?
- 日本語のテキストが中国語の規則で組まれる(ラベルが图、小書きのかなが行頭に来る、漢字が中国の字形)のはなぜですか?
手短な答え
// formatNumeral is the counter the engine numbers pages, lists and headings with.
const ISSUE = 120;
const kan = (n) => formatNumeral(n, 'japanese-informal'); // 120 → 百二十: counted
const pos = (n) => formatNumeral(n, 'cjk-decimal'); // 2026 → 二〇二六: digit by digit
const daiji = (n) => formatNumeral(n, 'japanese-formal'); // 12000 → 壱萬弐阡: on money
// {{daiji:12000}} in the text: the amount of a receipt in the hard-to-alter daiji.
const withDaiji = (md) => md.replace(/\{\{daiji:(\d+)\}\}/g, (_, n) => daiji(Number(n)));
const cjk = {
grid: { enabled: true, charsPerLine: CHARS, linesPerPage: LINES },
uprightDigits: 2, // 8月22日: one or two Arabic digits stand in one cell (the default)
};
// Sections 一、二、三、, items (一)(二), then イ ロ ハ and あ い う beneath them.
const sectionLevel = { level: 2, numberingTemplate: '{2:一}、', numberSeparator: '',
fontFamily: GOTHIC, fontWeight: 700, fontSize: pt(12), color: col('leaf'), lineSpan: 2 }; // 二行取り
const level = (n, numberFormat, prefix, separator) => ({ level: n, numberFormat, prefix,
separator }); // each level starts where the text of the one above starts
const orderedLists = {
fontFamily: GOTHIC, color: col('leaf'), fontWeight: 700, gap: em(0.5),
marginTop: pt(0), marginBottom: pt(0), itemSpacing: pt(0),
levels: [level(1, 'japanese-informal', '(', ')'), level(2, 'katakana-iroha', '', ''),
level(3, 'hiragana', '', '、')],
};
材料
- 機能
- 漢数字と仮名の番号縦組みの中の正立した数字番号付きリスト縦組み右綴じの本文字グリッド仮名、漢字、ローマ字中国語・日本語・韓国語のフォント日本語の約物のアキ行取りの見出し番号付き見出しデザインした章扉見出しスタイル段落スタイル囲み名前付きの表スタイル独自のリソースの種類用紙の色セマンティックカラーパレットPDFの書き出し
- 種類
- Noto Serif JP, Noto Sans JP, Zen Maru Gothic (SIL OFL 1.1)
- 素材
- なし:画像はすべてコードで描画
作り方
#1 · 数の置かれる場所で表記を選ぶ
コードは上の手短な答えにあります。formatNumeralは、エンジンがページ、リスト、見出しの番号付けに使うカウンターで、サンプルは自分で組み立てる数にもこれを呼びます。japanese-informalは数える書き方(120 → 百二十。十・百・千の前に一を付けません)、cjk-decimalは1桁ずつの書き方(2026 → 二〇二六)、japanese-formalは金額の大字(12000 → 壱萬弐阡)です。本文の{{daiji:12000}}が領収書の金額になるので、金額は算用数字で1回入力するだけです。同じスタイル名で番号も指定します。節は{2:一}、で、orderedLists.levelsは(一)、次にkatakana-iroha(イ ロ ハ)、次に「、」を付けたhiragana(あ、い、う)を設定します。cjk.uprightDigits: 2はマークアップなしで8月22日と23日を縦中横にし、「雨が降ったら中止!?」の!?は1字分に収まります。どちらも日本語の既定の動作です(縦組みの数字)。

#2 · 題字を右端に沿った帯にする
const BAND = 46; // mm from the right trim edge
const at = (x, y, extra = {}) => ({ anchor: { to: 'page', edge: 'top-left' },
offset: { x: mm(x), y: mm(y) }, ...extra }); // x down the sheet, y leftward from its right
const onBand = { color: col('paper'), overflow: 'wrap', align: 'left' };
// The date of issue, composed from kan() and pos() as the issue number is: design text the
// contentInConfig check allows, since spelling it is what the recipe shows (#849).
const ISSUED = `${pos(2026)}年(令和${kan(8)}年)${kan(8)}月${kan(1)}日発行`;
const masthead = {
id: 'masthead', numbered: false, toc: false, runningChapter: false,
breakBefore: { enabled: true, parity: 'any' },
advancedDesign: { enabled: true, minHeight: mm(BAND - 15), slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('leaf') },
placement: { anchor: { to: 'bleed', edge: 'top-left' }, size: { height: mm(BAND) } } },
{ kind: 'text', id: 'title', content: '{titleText}', ...onBand, fontFamily: ROUND,
fontWeight: 700, fontSize: pt(36), lineHeight: 1.1, letterSpacing: pt(3),
placement: at(HEAD, 9) },
{ kind: 'text', id: 'issue', content: `第${kan(ISSUE)}号`, ...onBand, fontFamily: GOTHIC,
fontWeight: 700, fontSize: pt(12), letterSpacing: pt(2), placement: at(HEAD, 26) },
{ kind: 'text', id: 'date', content: ISSUED,
...onBand, fontFamily: GOTHIC, fontSize: pt(10), align: 'right',
placement: at(HEAD, 26, { size: { width: mm(LINE) } }) },
{ kind: 'text', id: 'publisher', content: '{author}', ...onBand, fontFamily: GOTHIC,
fontSize: pt(10), align: 'right', placement: at(HEAD, 33, { size: { width: mm(LINE) } }) },
{ kind: 'text', id: 'latin', content: '{attr.latin}', ...onBand, fontFamily: GOTHIC,
fontSize: pt(7.5), placement: at(HEAD, 40) },
] } },
};
縦組みのページでは、流れの上端が紙の右端になります。そのため塗り足しの上端に固定した見出しデザインは、その端に沿って縦に走る帯になり、size.heightは紙の上での帯の幅になります。号数と日付はkan()とpos()で組み立てたデザインのテキストで、日付はalign: 'right'によって版面の下端で終わります。
#3 · カレンダーに1ページを与える
const DAYS = { 2: '訓練', 9: '清掃', 13: 'お盆', 18: '練習会', 19: '練習会',
22: '夏祭り', 23: '夏祭り', 30: '役員会' };
const day = (d) => (d ? { content: `**${d}**\n${DAYS[d] ?? '\u00a0'}`, align: 'center',
...(DAYS[d] ? { background: col(d === 22 || d === 23 ? 'blush' : 'tint') } : {}) }
: { content: '' });
const weeks = []; // 1 August 2026 is a Saturday
for (let d = -5; d <= 31; d += 7) weeks.push([0, 1, 2, 3, 4, 5, 6].map((k) => day(d + k > 0
&& d + k <= 31 ? d + k : 0)));
const calendar = { id: 'calendar', typeId: 'table', kind: 'table', createdAt: 0, updatedAt: 0,
// An upright table takes every line of the vertical page it stands on (gap:
// vertical-tables): the calendar is the back page, cited at the end of the text.
placement: { position: 'top', span: 'page' },
caption: '八月の行事。13日から16日まではごみの収集がありません。',
table: { model: { headerRowCount: 1, rows: [[...'日月火水木金土'].map((c) => ({ content: c,
isHeader: true, align: 'center' })), ...weeks] } } };
const resourceTypes = [{ id: 'table', name: '表', shortLabel: '表', captionPrefix: '表',
numberingTemplate: '{n}', counterFormat: '一', resetOn: 'never' }]; // 表一, 表二…
縦組みのページでも表は正立し、日本の本が表を印刷するときと同じく横に読みます。表は置かれたページの行をすべて占めます。カレンダーは最後の段落の後でページ幅のフロートとして参照するので裏表紙になり、その前の本文はそれまでのページを埋めます。resourceTypesはトークン一で番号を付け(表一)、jaの文書はラベル「表一 」を自動で組みます。ラベルと番号の間はアキなしで、後ろに全角スペースを置きます。
#4 · 声ごとに、組む文字でフォントを読み込む
const heads = (markdown.match(/^#+ .*$/gm) ?? []).join('');
const gothicText = `${heads}${markdown}第号年月日発行令和${kan(ISSUE)}${pos(2026)}${
calendar.caption}日月火水木金土${Object.values(DAYS).join('')}領収証(記入例)表一`;
本文はNoto Serif JP、見出し、リスト、カレンダー、領収書のラベルはNoto Sans JPで組み、Zen Maru Gothicは題字だけに使います。どの書体も、自分が組む文字とサンプルが組み立てる数を含むFontsourceのファイルを読み込みます。
レシピの全体
// ═══ Postext Cookbook · Nº 129 · Kanji numerals, counters and dates in vertical text ═══
// https://postext.dev/en/cookbook/kanji-numerals-and-dates
// Code: MIT · Text: written for the recipe (CC BY 4.0)
// Fonts: Noto Serif JP, Noto Sans JP, Zen Maru Gothic (SIL OFL 1.1) · Needs postext ≥ 1.34.0
// A neighbourhood newsletter set vertically: every way Japanese writes a number.
import {
buildDocument, withLoadedFonts, renderPageToCanvas, loadVerticalAlternates, formatNumeral,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the frame; the newsletter is Japanese in both
const RECIPE = 'kanji-numerals-and-dates';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: ink, the green of young leaves, its tint, a festival red and its blush
const palette = {
ink: '#1f2420', // the text
leaf: '#2f6b3f', // masthead band, section numbers (6.4:1 on the paper)
tint: '#e4efdf', // the calendar's marked days, the receipt
red: '#b4362b', // the receipt's amount
blush: '#f4d4cc', // the festival days in the calendar
muted: '#5f665f', // folios, the colophon
paper: '#fdfdf9',
};
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: 'leaf (defaults)', value: { hex: palette.leaf, model: 'hex' } },
];
// #endregion
const MINCHO = 'Noto Serif JP'; // the text
const GOTHIC = 'Noto Sans JP'; // section heads, labels, the calendar
const ROUND = 'Zen Maru Gothic'; // the masthead's title
const [BODY, LEAD] = [11, 20]; // pt: large print for every age on the street
const [CHARS, LINES] = [44, 20];
const PT = 25.4 / 72; // mm in a point
const TRIM = { w: 182, h: 257 }; // mm, B5
const LINE = CHARS * BODY * PT; // mm: 170.7, the length of a line
const HEAD = 30 + (TRIM.h - 30 - 24 - LINE) / 2; // mm: the head of the type area
// #region answer: one number, four spellings, chosen by where it stands
// formatNumeral is the counter the engine numbers pages, lists and headings with.
const ISSUE = 120;
const kan = (n) => formatNumeral(n, 'japanese-informal'); // 120 → 百二十: counted
const pos = (n) => formatNumeral(n, 'cjk-decimal'); // 2026 → 二〇二六: digit by digit
const daiji = (n) => formatNumeral(n, 'japanese-formal'); // 12000 → 壱萬弐阡: on money
// {{daiji:12000}} in the text: the amount of a receipt in the hard-to-alter daiji.
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#年をすべて数える書き方にする
本文では二〇二六年より二千二十六年を好む書き手もいます。posのスタイルを変えます。
-const pos = (n) => formatNumeral(n, 'cjk-decimal'); // 2026 → 二〇二六: digit by digit
+const pos = (n) => formatNumeral(n, 'japanese-informal'); // 2026 → 二千二十六#3桁を縦中横にする
3にすると、本文の100や365も1字分に収まります。
- uprightDigits: 2, // 8月22日: one or two Arabic digits stand in one cell (the default)
+ uprightDigits: 3,よくあるつまずき
つまずき
日本語のテキストのタグは'ja'。zh-HansやLANGにしない
レシピの版はenとesですが、日本語のサンプルはどちらの版でも日本語です。`locale: LANG`では英語やスペイン語とタグ付けされ、中国語のタグでは中国語の規則で組まれます(開明式の約物、小書きの仮名が行頭に来てもよい、図の代わりに图、PDFでは中国の字形)。postext 1.30以降、このタグはテキストを組む言語(計測、描画、埋め込みに使う言語)でもあるので、'ja'以外のタグでは日本語の字形ではなく別の字形(中国語のタグでは中国の字形)になり、改行の位置も変わります。'ja'と書いてください。日本の地域(JLReqの改行と約物、ゴマの圏点、ルビの間隔、図と表の表示名)が選ばれ、ハイフネーションが切られます。リントは、zhやkoのタグで仮名を含むテキストをエラーにします。 日本語の改行(禁則処理) →
つまずき
日本語は日本語の書体で組む
Noto Serif SCとTCは仮名を持っていますが、漢字は中国の字形(直、骨、角が異なります)で、仮名も中国のデザインで描きます。本文はNoto Serif JPかShippori Mincho B1、見出しはNoto Sans JPで組み、loadCjkFontsで読み込んでください。Fontsourceの日本語ファイルには変体仮名などの古い仮名(U+1B000–1B16F)がないため、loadCjkFontsはそこで失敗し、PDFには四角が印字されます。現代の仮名で書くか、それを持つ書体をレシピのassetsに同梱してください。Shippori Minchoにはマクロン付きの母音ōとūもないので、ローマ字はラテン文字の書体で組んでください。 仮名、漢字、ローマ字 →
つまずき
中国語の書体はcjkブロックを通じてスライス単位で読み込む
Fontsourceは中国語、日本語、韓国語のファミリーを、ウェイトごとに約100個のファイルとして配信し、各ファイルが文字の範囲を受け持ちます。loadFontsが取得するのはlatinファイルだけなので、画面では漢字がシステムの書体で出て計測が狂い、fontsourceProviderはPDFにそのlatinファイルを渡すため、漢字が空の四角で印字されます。キットのcjkブロックを挙げ、loadFontsのあとにloadCjkFonts(FONTS, markdown)を呼び(本で複数のCJK書体を使うときは、それぞれの書体で組むテキストを渡して書体ごとに1回)、renderToPdfにfontProvider: cjkPdfProviderを渡してください。どちらもテキストの文字を含むファイルを取得します。 中国語・日本語・韓国語のフォント →
- カレンダーが1ページを占めるのは、正立した表が縦組みのページの行をすべて使うからです(既知の制限:縦組みの中の表)。本文とページを分け合う表には、横組みのページか、見出しデザインで配置するSVG図版が必要です。
- 中国語では同じカウンターが一百二十、一千零一と書き、日本語では百二十、千一と書きます。
locale: 'ja'を書かないと、トークン一は中国語のスタイルを選びます。中国語の読者向けのレシピ縦組みの中で日付と略語を正立させるも、同じuprightDigitsで日付を組みます。
クレジット
- 本文
- The newsletter of a fictional neighbourhood association, written in Japanese for this recipe · Postext Cookbook · CC BY 4.0
- フォント
- Noto Serif JP (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1) · Zen Maru Gothic (SIL OFL 1.1)


