In short
A Japanese neighbourhood newsletter printed in top-to-bottom lines. It shows the different ways Japanese writes numbers, and how dates stay readable in vertical text.
What you'll build
Four vertical pages of a neighbourhood newsletter, 東若葉台だより, issue 第百二十号, on a B5 page bound on the right: the summer festival notice, the August calendar, the dues and a donation receipt, and a short history of the association. The association is invented; its numbers are written the way a Japanese editor writes them. The issue, the festival's 第三十二回 and the 二千四百人 who came are counted with 十 百 千; the years are written digit by digit, 二〇二六年 and 一九六〇年; the receipt's amount is in daiji (大字), 壱萬弐阡, which cannot be altered with a stroke; the times and dates are Arabic, and 22 stands upright in one cell. Lists run 一、 → (一) → イ → あ, and the calendar is the back page.
This recipe answers
- How do I number chapters 第一章 in kanji numerals, or list items あ い う and イ ロ ハ?
- Why does my Japanese text come out with Chinese rules: 图 labels, small kana starting lines, kanji in Chinese forms?
The short answer
// 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', '', '、')],
};
One number, four spellings, chosen by where it stands
Ingredients
- Features
- Japanese numerals and kana countersNumbers upright in vertical textNumbered listsVertical textBooks bound on the rightCharacter gridKana, kanji and rōmajiChinese, Japanese and Korean fontsJapanese punctuation spacing (yakumono)Headings over body lines (gyōdori)Numbered headingsDesigned openersHeading stylesParagraph stylesCallout boxesNamed table stylesCustom resource typesPaper colourSemantic colour palettePDF export
- Also uses
- Bibliographies and glossariesChinese line breakingHeading attributesFigures exactly hereHeads by page roleFonts embedded in the PDFRoman front matterUnnumbered chapters
- Type
- Noto Serif JP, Noto Sans JP, Zen Maru Gothic (SIL OFL 1.1)
- Assets
- None: every picture is drawn in code
Method
#1 · Choose the spelling by where the number stands
The code is the short answer above. formatNumeral is the counter the engine numbers pages, lists and headings with, and the pen calls it for the numbers it composes itself: japanese-informal counts (120 → 百二十, with no 一 before 十 百 千), cjk-decimal writes digit by digit (2026 → 二〇二六) and japanese-formal gives the daiji of a sum (12000 → 壱萬弐阡). A {{daiji:12000}} in the text becomes the receipt's amount, so the figure is typed once, in digits. The same styles name the counters: the sections are {2:一}、, and orderedLists.levels sets (一), then katakana-iroha (イ ロ ハ), then hiragana with 、 (あ、い、う). cjk.uprightDigits: 2 stands 8月22日 and 23日 upright without markup, and the !? of 「雨が降ったら中止!?」 shares one cell, a Japanese default (numbers in vertical text).

#2 · Put the masthead in a band down the right edge
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) },
] } },
};
On a vertical page the top of the flow is the sheet's right edge, so a heading design anchored to the top of the bleed is a band down that edge, and its size.height is its width on the sheet. The issue number and the date are design text built from kan() and pos(), and the date ends at the foot of the type area with align: 'right'.
#3 · Give the calendar a page of its own
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' }]; // 表一, 表二…
A table stands upright on a vertical page and reads across, as Japanese books print their tables; it takes every line of the page it stands on. The calendar is cited after the last paragraph, as a page-wide float, so it becomes the back page and the text before it fills its pages. resourceTypes numbers it with the token 一 (表一), and a ja document sets the label 表一 by itself: label and number solid, an ideographic space after.
#4 · Load each voice with the text it sets
const heads = (markdown.match(/^#+ .*$/gm) ?? []).join('');
const gothicText = `${heads}${markdown}第号年月日発行令和${kan(ISSUE)}${pos(2026)}${
calendar.caption}日月火水木金土${Object.values(DAYS).join('')}領収証(記入例)表一`;
Noto Serif JP sets the text, Noto Sans JP the heads, lists, calendar and receipt label, and Zen Maru Gothic only the title. Each loads the Fontsource files of its own characters, plus the numbers the pen composes.
The whole recipe
// ═══ 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.
The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)
Variations
#Write every year as a count
Some writers prefer 二千二十六年 to 二〇二六年 in running text; change the style of pos.
-const pos = (n) => formatNumeral(n, 'cjk-decimal'); // 2026 → 二〇二六: digit by digit
+const pos = (n) => formatNumeral(n, 'japanese-informal'); // 2026 → 二千二十六#Stand three digits upright
With 3, a 100 or a 365 in the text takes one cell too.
- uprightDigits: 2, // 8月22日: one or two Arabic digits stand in one cell (the default)
+ uprightDigits: 3,Pitfalls
Pitfall
Tag a Japanese text 'ja', never zh-Hans or LANG
A recipe's editions are en and es, but a Japanese sample is Japanese in both: `locale: LANG` would tag it English or Spanish, and a Chinese tag would set it by the Chinese rules (Kaiming punctuation, small kana free to start a line, 图 for 図, Chinese glyph forms in the PDF). From postext 1.30 the tag is also the language the text is shaped in (measured, painted and embedded), so any tag but 'ja' gives other glyph forms than the Japanese ones (the Chinese ones under a Chinese tag) and other line breaks. Write 'ja': it picks the Japan region (JLReq line breaking and punctuation, sesame emphasis marks, furigana spacing, 図 and 表 labels) and turns hyphenation off. The lint fails a text with kana under a zh or ko tag. Japanese line breaking (kinsoku) →
Pitfall
Set Japanese in a Japanese face
Noto Serif SC and TC have kana, but they draw the kanji in Chinese forms (直, 骨 and 角 differ) and the kana in a Chinese design. Set the text in Noto Serif JP or Shippori Mincho B1 and the heads in Noto Sans JP, loaded with loadCjkFonts. Fontsource's Japanese files hold no hentaigana or other historic kana (U+1B000–1B16F): loadCjkFonts fails on them and the PDF prints boxes, so write the modern kana or ship a face that has them in the recipe's assets. Shippori Mincho also lacks the macron vowels ō and ū: set rōmaji in a Latin face. Kana, kanji and rōmaji →
Pitfall
Chinese faces load by slices, through the cjk block
Fontsource serves a Chinese, Japanese or Korean family as about a hundred files per weight, each covering a range of characters. loadFonts fetches only the latin file, so on screen the Han characters come from a system face and measure wrong, and fontsourceProvider hands the PDF that latin file, which prints them as empty boxes. List the cjk kit block, call loadCjkFonts(FONTS, markdown) after loadFonts (once per voice, with the text it sets, when the book uses several CJK faces) and give renderToPdf fontProvider: cjkPdfProvider: both take the files that hold the text's characters. Chinese, Japanese and Korean fonts →
- The calendar is a page because an upright table takes all the lines of a vertical page (gap: tables set in vertical text). A table that should share its page with text needs a horizontal page, or an SVG drawing placed by a heading design.
- In Chinese the same counter writes 一百二十 and 一千零一; in Japanese 百二十 and 千一. Write
locale: 'ja'or the token 一 picks the Chinese style. The Chinese reader Dates and acronyms upright in vertical text sets its dates with the sameuprightDigits.
Credits
- Recipe
- Ignacio Ferro
- Text
- The newsletter of a fictional neighbourhood association, written in Japanese for this recipe · Postext Cookbook · CC BY 4.0
- Fonts
- Noto Serif JP (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1) · Zen Maru Gothic (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


