In short
Two short stories as a Japanese collected works prints them: the text runs down the page in two stacked bands, each story opens on a left-hand page with its title running the whole height, and its last page is not evened out.
What you'll build
Seven pages from a volume of collected works (全集) on an A5 page bound on the right: Akutagawa Ryūnosuke's The Spider's Thread and Bisei's Faith, set in two tiers (二段組) of 25 characters down the page and 21 lines across, Noto Serif JP at 9 pt with a hairline between the tiers. Each story opens on an odd page, the left-hand one, with its title in 20 pt running down through both tiers and the author's name near the foot; the folios count on from page 211. The sections 一 二 三 take three lines of their tier. When a story ends, its last page is left as the text falls, the Japanese 成り行き (nariyuki): on page 214 the story ends in the upper tier with its date, one line before the tier is full, and the lower tier stays empty. The Chinese newspaper in vertical tiers is Nº 084, and a chapter title across two horizontal columns is Nº 017.
This recipe answers
- How do I set a chapter title across the page while the body runs in two columns below?
- How do I force a page or column break, and start every chapter on a right-hand page?
- How do I set the type area in characters, so many to the line and so many lines to the page?
The short answer
// On a vertical page two columns are two tiers (段), filled from the upper right: the
// gutter is the gap between them and the column rule a hairline across the page. The grid
// counts characters down one tier, so each tier is exactly 25 em long and the gutter 2 em.
const layout = {
layoutType: 'double', writingMode: 'vertical-rl', // binding 'auto' becomes 'right'
gutterWidth: pt(2 * BODY),
columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.4) },
};
const cjk = { grid: { enabled: true, charsPerLine: CHARS, linesPerPage: LINES } };
// 成り行き (nariyuki): the text fills the upper tier across the whole page before the
// lower one, and a work's last page is not levelled: its lower tier ends where the text
// does. trailing: false is that choice (vertical tiers are not balanced by default either).
const balancing = { trailing: false };
// Each work opens on an odd page, the left-hand one in a book bound on the right, with a
// blank page before it when the last work ended on an odd page.
const work = { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'odd' } };
// 一 二 三 take three lines of their tier (3行取り), eight characters down.
const section = { level: 2, fontSize: pt(11), fontWeight: 600, lineSpan: 3, indent: em(8) };
Two tiers of 25 characters, the last page of a work left as it falls
Ingredients
- Features
- One or two columnsVertical textColumn balancingBooks bound on the rightChapters that open on a rectoHeadings over body lines (gyōdori)Character gridColumn ruleJapanese line breaking (kinsoku)Japanese punctuation spacing (yakumono)Furigana: kana readings over kanjiAozora Bunko importChinese, Japanese and Korean fontsRunning heads and foliosHeads by page roleHeading stylesDesigned openersParagraph stylesSemantic colour palettePDF export
- Also uses
- Chinese line breakingHeading attributesFull-width chapter bandPaper colourFonts embedded in the PDFRoman front matterRuby: pinyin and zhuyin readingsRunning heads per sectionExplicit vertical space
- Type
- Noto Serif JP, Noto Sans JP (SIL OFL 1.1)
- Assets
- None: every picture is drawn in code
Method
#1 · Two columns turned a quarter turn are two tiers
The code is the short answer above. On a page with writingMode: 'vertical-rl', layoutType: 'double' stacks the two columns: the first fills the upper tier from the right, then the lower one, and the gutter is the band between them (Vertical writing). The character grid counts characters down one tier, so each tier is 25 characters of 9 pt and the gutter is rounded to a whole two characters; the 21 lines of 15.75 pt across fit 116.7 mm of the 148 mm page. The rule between the tiers runs across the page, 0.4 pt in a warm grey.
Postext's balancer would end both tiers of a story's last page at the same line, which is how Chinese newspapers and most European two-column books close a chapter. A Japanese book in tiers lets the text fall: the upper tier runs the whole page before the lower one starts. balancing.trailing: false is that choice, and vertical tiers are not balanced at all unless enabled: true turns the balancer on (Column balancing).
#2 · Run the work's title down both tiers
// A page-span heading is laid out across the whole height of the page, both tiers and the
// gutter, in the flow frame: x runs down the page, y across it leftwards from the right
// edge of the type area. The design reserves seven lines (七行取り); the tiers start after it.
const at = (down, across) => ({ anchor: { to: 'container', edge: 'top-left' },
offset: { x: pt(down), y: pt(across) } });
const TITLE = 20; // pt
const opener = { enabled: true, minHeight: lines(7), slot: { elements: [
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: MINCHO, fontWeight: 600,
fontSize: pt(TITLE), lineHeight: 1, letterSpacing: pt(TITLE / 2), color: col('ink'),
placement: at(5 * BODY, 2.5 * LEAD - TITLE / 2) },
{ kind: 'text', id: 'author', content: '{author}', fontFamily: MINCHO, fontSize: pt(10.5),
letterSpacing: pt(3), color: col('ink'),
placement: at(HEIGHT - 5 * 10.5 - 4 * 3 - 3 * BODY, 4.5 * LEAD - 10.5 / 2) },
] } };
A heading level with span: 'page' is laid out across the whole height of the page, both tiers and the gutter, at the head of the flow, the right of a vertical page; the tiers start after the seven lines its design reserves. Such a heading always opens a page, and breakBefore.parity: 'odd' makes it the left-hand one: The Spider's Thread ends on page 214, an even page, so Bisei's Faith opens on 215 with no blank page between them (Span and advanced design). In the design x runs down the page and y across it from the right edge of the type area; the author's name is placed from the foot of the lower tier, three characters up.
#3 · Number the sections in three lines of their tier
The second level, lineSpan: 3 with indent: em(8), sets 一 二 三 eight characters down a tier in a band of three lines, as the Aozora text marks them (八字下げ, 中見出し), so the text after a section number stays on the lines of the tier beside it (Per-level overrides). The dates that close the stories, (大正七年四月十六日), are raised one character from the foot of their tier (地から一字上げ) with :::paragraphs{align=end endIndent=1}; the Aozora converter writes them as an aozora-end1 style that sets them flush with the foot, and the fence attributes add the one-character raise.
#4 · Put the volume and the work down the fore-edge
// anchor 'outer' is the fore-edge: the left margin of an odd page and the right one of an
// even page in a book bound on the right. The volume's name on the right-hand page, the
// work on the left; the folios count on from the volume's page 211.
const foreEdge = (id, content, parity, edge, y, extra = {}) => ({
kind: 'text', id, content, parity, pages: 'body', writingMode: 'vertical-rl',
fontFamily: GOTHIC, fontSize: pt(7), letterSpacing: pt(1), color: col('muted'),
overflow: 'clip', placement: { anchor: { to: 'outer', edge }, offset: { y: em(y) } },
...extra,
});
const header = { elements: [
foreEdge('volume', '{title}', 'even', 'top', 2),
foreEdge('work', '{chapterTitle}', 'odd', 'top', 2),
// The folio in Arabic digits, set across the margin: down the fore-edge they would lie
// on their side.
foreEdge('folio', '{pageNumber}', 'all', 'bottom', -1, { pages: 'all', writingMode: undefined,
letterSpacing: pt(0.5) }),
] };
const none = { elements: [] };
// The first work's opening page carries the colophon across the foot, in the edition's
// language (a style's footer serves every page of its section: gotcha style-header-whole-section).
const first = { id: 'first', footer: { elements: [{ kind: 'text', id: 'colophon', pages: 'opener',
content: '{attr.colophon}', fontFamily: GOTHIC, fontSize: pt(5.5), lineHeight: 1.45,
color: col('muted'), overflow: 'wrap', align: 'center',
placement: { anchor: { to: 'page', edge: 'bottom' }, offset: { y: mm(-6) },
size: { width: mm(118) } } }] } };
anchor.to: 'outer' sets the hashira in the fore-edge margin, the volume's name 芥川龍之介集 on the right-hand pages and the work's title on the left-hand ones, and pages: 'body' keeps both off the pages where a work opens (Vertical text elements). The folio is set across the margin in Arabic digits, as many collected works print it: down the fore-edge three digits would lie on their side. pageNumbering.startAt: 211 numbers the pages as the volume does. The first work's heading style carries the colophon with pages: 'opener', because a style's footer serves every page of its section.
The whole recipe
// ═══ Postext Cookbook · Nº 118 · A Japanese story in two tiers, its title across both ═══
// https://postext.dev/en/cookbook/two-tier-tankobon
// Code: MIT · Text: 芥川龍之介『蜘蛛の糸』『尾生の信』, Aozora Bunko 92, 24 (PD) · Pictures: none
// Fonts: Noto Serif JP, Noto Sans JP (SIL OFL 1.1) · Needs postext ≥ 1.25.0
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 colophon; the stories are Japanese in both
const RECIPE = 'two-tier-tankobon';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: ink, one deep indigo, a warm book paper
const palette = {
ink: '#1d1b19', // the text
indigo: '#2f3d63', // 藍: the cloth of the case; the engine's defaults
rule: '#8c857b', // the hairline between the two tiers
muted: '#655e56', // the hashira and the folios
paper: '#fcfaf4',
};
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.indigo, model: 'hex' } },
];
// #endregion
const [MINCHO, GOTHIC] = ['Noto Serif JP', 'Noto Sans JP'];
const [BODY, LEAD, CHARS, LINES] = [9, 15.75, 25, 21]; // pt, pt: 2 段 × 25字 × 21行
const HEIGHT = 2 * CHARS * BODY + 2 * BODY; // pt: two tiers and a gutter of two characters
const lines = (n) => pt(n * LEAD); // n lines across the page
// #region answer: two tiers of 25 characters, the last page of a work left as it falls
// On a vertical page two columns are two tiers (段), filled from the upper right: the
// gutter is the gap between them and the column rule a hairline across the page. The grid
// counts characters down one tier, so each tier is exactly 25 em long and the gutter 2 em.
const layout = {
layoutType: 'double', writingMode: 'vertical-rl', // binding 'auto' becomes 'right'
gutterWidth: pt(2 * BODY),
columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.4) },
};
const cjk = { grid: { enabled: true, charsPerLine: CHARS, linesPerPage: LINES } };
// 成り行き (nariyuki): the text fills the upper tier across the whole page before the
// lower one, and a work's last page is not levelled: its lower tier ends where the text
// does. trailing: false is that choice (vertical tiers are not balanced by default either).
const balancing = { trailing: false };
// Each work opens on an odd page, the left-hand one in a book bound on the right, with a
// blank page before it when the last work ended on an odd page.
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
#Level the last page
Turn balancing on and the last page of each work is cut level: page 214 ends with 10 lines in the upper tier and 10 in the lower, the closing a Chinese or European book in columns uses. On the character grid the balancer adds only whole lines, so every character keeps its cell.
-const balancing = { trailing: false };
+const balancing = { enabled: true }; // the closing band is cut level#Open each work on the next page
parity: 'any' starts a work on whichever page comes next, as magazines and anthologies of very short pieces do.
-const work = { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'odd' } };
+const work = { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'any' } };#Set the story in one tier
Novels and bunko set their text in one tier, with no gutter; Nº 117 sets a bunko that way.
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
A page-span heading always opens a new page
A heading whose level or style sets span: 'page' is laid out as an opener at the head of a page, whether or not it has a breakBefore. Placed after other text, or after another opener on the same page, it moves to the next page and leaves the rest of the current one empty. A banner headline across both columns (or both tiers of a vertical page) under a masthead goes into the opener's own design, next to the masthead, or into a :::callout{span="page"} box as a heading without span, as newspaper-front-page sets its banners. Designed openers →
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 →
Pitfall
A right-bound book shows its spreads with showBook
In a book bound on the right (Arabic, Hebrew or Persian text, vertical Chinese, or page.binding 'right') page 1 is still the recto, but it lies on the left of the spine, and the pairs read [3 | 2]. showPages lays every book out left-bound; showBook from the book block (the cjk block carries the same function) reads doc.binding and mirrors the pairs. capture.hero still names a spread in reading order, [verso, recto]: [2, 3]. Books bound on the right →
Credits
- Recipe
- Ignacio Ferro
- Text
- 芥川龍之介「蜘蛛の糸」 (The Spider’s Thread, 1918); Aozora Bunko card 92, from 「芥川龍之介全集2」 (Chikuma Bunko, 1986), input 平山誠 and 野口英司, proofreading もりみつじゅんじ, converted with aozora.py · Akutagawa Ryūnosuke; Aozora Bunko volunteers · public domain
- 芥川龍之介「尾生の信」 (Bisei’s Faith, 1920); Aozora Bunko card 24, from 「芥川龍之介全集3」 (Chikuma Bunko, 1986), input j.utiyama, proofreading かとうかおり, converted with aozora.py; the rule before the coda shortened to fit a tier · Akutagawa Ryūnosuke; Aozora Bunko volunteers · public domain
- Fonts
- Noto Serif JP (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


