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

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

IECの規則でハイフネーションしたカタルーニャ語の中編小説

ナルシス・ウリェーの『El transplantat』全編を32ページの文庫判に。カタルーニャ語の音節はIECの規則で分け、l·lはil- | lusióと分割し、各章に版画を置きます。

このページの内容
出力
Canvas · PDF
レベル
中級
Postext
Postext 1.65.0で検証済み
1.57.0以上が必要 · postext-pdf ≥ 1.57.0
ライセンス
2026年10月22日更新
コードMIT · 本文MIT

2〜3ページ(全32ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり120 × 185 mm
  • 1段
  • Gentium Book Plus 9.8/14
  • Cormorant Garamond
  • Cormorant SC
  • 32ページ
  • レベル
  • Postext 1.57.1
  • 組版時間162 ms
  • コード180行

かんたんな説明

カタルーニャ語の短い小説1冊を小さなペーパーバックに組みます。行末での単語の分け方はカタルーニャ語の表記ガイドに従い、中点の付いた二重のlも正しく分けます。

できあがり

ナルシス・ウリェーの『El transplantat』を、『Obres completes』(バルセロナ、1928年)の本文で全編、12 × 18.5 cmの32ページの文庫本に組みます。4つの章の前に、前扉、窯の前に立つパン屋の口絵、赤いイタリックのCormorant Garamondで組んだ本扉、版についての注記が入ります。各章は12行分の深さの版画の下で始まり、ローマ数字は赤です。本文は9.85 ptのGentium Book Plusで、Institut d’Estudis Catalansが求めるとおりカタルーニャ語の音節で改行します。分割の両側に最低2文字を残し、母音分立の母音のあいだでは分けず、アポストロフィの直後でも分けません。titil·lavenはtitil- | lavenと分け、ハイフンが中点の代わりになります。会話はemダッシュで、引用は«cometes baixes»で組みます。

このレシピが答える質問

  • スペイン語・フランス語・ドイツ語のテキストで、きれいな両端そろえとハイフネーションを得るには?
  • 章ごとに異なる写真、色、章扉のバリエーションを与えるには?
  • 番号のないアートワーク(オーナメント、カット、ロゴ)を組むには?
  • 会話のダッシュ、段落頭の年号、価格、記号そのものを、Markdownに誤読させずに書くには?

手短な答え

script.js · 49〜64行コード全体で見る
const LOCALE = 'ca'; // the exact bundled code: 'ca-ES' resolves to it too (postext ≥ 1.14)
const bodyText = { // config().bodyText
  fontFamily: TEXT, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
  firstLineIndent: mm(4.5), indentAfterHeading: false,
  // The defaults justify, hyphenate in config().locale and break by Knuth–Plass. With 'ca'
  // the dictionary follows the IEC: two letters on each side (ter-ra, cai-xa), no split in
  // a hiatus (cièn-cia) or after an apostrophe (s’ha-via), l·l broken with the hyphen for the
  // dot. From 1.30 the face is asked for its Catalan forms too: this one has a single dot.
  // compounds: false divides arrossegar-se only at its own hyphen (Llibre d’estil, VI 2.5).
  hyphenation: { compounds: false },
  // Spaces from 0.7× to 1.6×, then up to 10‰ of tracking; a last line under 22 characters is
  // a runt. A line that must keep d’inaugurar-se whole still opens to 1.94× on page 7.
  maxWordSpacing: 1.6, minWordSpacing: 0.7, maxJustifyTracking: 10, runtMinCharacters: 22,
  hyphenateAcrossColumns: false, // no page ends on a divided word
};

材料

種類
Gentium Book Plus, Cormorant Garamond, Cormorant SC (SIL OFL 1.1)
素材
  • cap1-1200.jpg
  • cap2-1200.jpg
  • cap3-1200.jpg
  • cap4-1200.jpg
  • frontis-1000.jpg
  • Engraving, frontispiece: the baker at his oven's door (Generated With Diffusion Models, オリジナル)
  • Engraving, chapter I: the night train into Barcelona (Generated With Diffusion Models, オリジナル)
  • Engraving, chapter II: the village street in autumn (Generated With Diffusion Models, オリジナル)
  • Engraving, chapter III: the Rambla at dawn (Generated With Diffusion Models, オリジナル)
  • Engraving, chapter IV: the old man by the railway (Generated With Diffusion Models, オリジナル)

作り方

#1 · カタルーニャ語をコードで指定する

コードは前出の手短な答えにあります。locale: 'ca'でカタルーニャ語のパターンが選ばれ、postext 1.14以降、それはIECの『Llibre d’estil』に従います(対応するロケール)。パターンはTeXと同じもので、npmパッケージが同梱する3文字ではなく、分割の両側に最低2文字を残すため、ter-ra、cai-xa、plu-jaも分割できます。母音分立の母音は離さず(cièn-cia、ca-mions)、母音にはさまれたiは次の音節の頭になります(fe-ia)。ela geminadaは2つのlのあいだで分けます。行はtitil-で終わり、次の行はlavenで始まり、どちらにも中点は残りません。Knuth–Plassも中点を除いて行を測ります。

27ページ。行末のtitil·lavenはtitil- | lavenと組まれます。この32ページで行末に来るl·lはこの1か所だけです。

compounds: falseは、動詞と代名詞を、そのあいだのハイフン以外では分けません(arrossegar- | se)。IECが好む分け方です(ハイフネーション)。代償はゆるい行1つです。7ページでは、maxJustifyTracking: 10がほかの行で余りを吸収しても、d’inaugurar-seの前の行は語間が1.88倍に広がります。

#2 · 行がきっちり収まる文庫のページ

script.js · 38〜45行コード全体で見る
const TRIM = { width: 120, height: 185 }; // mm
const [TOP, INNER, OUTER, LINES] = [18, 16, 15, 29];
const MEASURE = TRIM.width - INNER - OUTER; // 89 mm: about 63 characters of Gentium Book Plus
const page = {
  width: mm(TRIM.width), height: mm(TRIM.height), dpi: 150, backgroundColor: col('paper'),
  margins: { top: mm(TOP), bottom: mm(TRIM.height - TOP - LINES * LINE),
    left: mm(INNER), right: mm(OUTER), mirror: true }, // left is the inner margin on a recto
};

地の余白は仕上がりサイズ、天の余白、LINESから決まるので、版面には14 ptの行が29行入り、すべての満ページが同じベースラインで終わります。89 mmの行長にはGentium Book Plusでおよそ63字が入ります。mirror: trueで、見開きのどちらのページでも16 mmの余白がのど側に来ます(見開きの余白)。

#3 · 4つの章に1つの章扉

script.js · 68〜83行コード全体で見る
// # II {style="capitol" art="cap2"}: the art attribute names the picture's resource.
const PICTURE = { width: MEASURE, height: 12 * LINE }; // 89 × 59.3 mm: twelve lines, 3:2
const chapter = { id: 'capitol',
  breakBefore: { enabled: true, parity: 'any' }, // a chapter opens on the next page, either side
  marginBottom: pt(0), // the opener's own height already ends on a line
  advancedDesign: { enabled: true, minHeight: pt(16 * LEAD), slot: { elements: [
    { kind: 'image', id: 'art', resourceId: '{attr.art}',
      placement: at('container', 'top', 0, 0,
        { width: mm(PICTURE.width), height: mm(PICTURE.height) }) },
    // The numeral and its rule hang from the container's top, a fixed drop under the picture.
    text('numeral', '{titleText}', DISPLAY, 21, at('container', 'top', 0, PICTURE.height + 4),
      { fontWeight: 600, color: col('vermell'), lineHeight: 1 }),
    { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.5), color: col('vermell'),
      placement: { ...at('container', 'top', 0, PICTURE.height + 13), size: { width: mm(8) } } },
  ] } },
};

resourceId: '{attr.art}'は見出しが指定した画像を描くので、# II {style="capitol" art="cap2"}は第II章を、ほかの章と同じスタイルのまま専用の版画の下で始めます(見出しの属性)。minHeightで16行を確保します。画像に12行、数字とその罫に4行で、本文はどの章でもページの17行目から始まります。

#4 · 第I章の前の4ページ

script.js · 87〜116行コード全体で見る
const front = (id, elements, { minHeight, ...extra } = {}) => ({ id,
  breakBefore: { enabled: true, parity: 'any' }, marginBottom: pt(0),
  header: { elements: [] }, footer: { elements: [] }, ...extra,
  advancedDesign: { enabled: true, ...(minHeight && { minHeight }), slot: { elements } } });
const FRONTIS = { width: MEASURE, height: MEASURE * 1.5 }; // mm: the engraving is 2:3
const headingStyles = [
  front('avantportada', [text('title', '{titleText}', DISPLAY, 19,
    at('container', 'top', 0, 9 * LINE), { italic: true, fontWeight: 500, lineHeight: 1 })]),
  front('frontis', [
    { kind: 'image', id: 'art', resourceId: '{attr.art}',
      placement: at('container', 'top', 0, 0,
        { width: mm(FRONTIS.width), height: mm(FRONTIS.height) }) },
    text('legend', '{titleText}', LABEL, 8.5, at('container', 'top', 0, FRONTIS.height + 5),
      { ...caps(8.5, 1.4, 'muted') }),
  ]),
  front('portada', [
    text('author', '{author}', LABEL, 10, at('container', 'top', 0, 5 * LINE),
      caps(10, 2.2, 'ink')),
    text('title', '{titleText}', DISPLAY, 34, at('container', 'top', 0, 8 * LINE),
      { italic: true, fontWeight: 500, color: col('vermell'), lineHeight: 1 }),
    text('subtitle', '{subtitle}', DISPLAY, 13, at('container', 'top', 0, 8 * LINE + 17),
      { italic: true, fontWeight: 500 }),
    { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.5), color: col('vermell'),
      placement: { ...at('container', 'top', 0, 8 * LINE + 29), size: { width: mm(14) } } },
  ]),
  // The note sits low on the verso behind the title, its label a line above it.
  front('nota', [text('label', '{titleText}', LABEL, 8.5, at('container', 'top', 0, 13 * LINE),
    caps(8.5, 1.4))], { minHeight: pt(15 * LEAD) }),
  chapter,
];

前付けの各部分は、それぞれ専用のスタイルを付けたレベル1の見出しです。# El transplantat {style="portada"}はフロントマターの著者と副題を印刷し、見出しを表題として印刷します。スタイルはレベルの改ページを継承するため、どのスタイルでも改ページを書き直し、ヘッダーとフッターを空にします。そのためこれらのページには柱もノンブルもありません。口絵は偶数ページの2ページに来るので、見開きで本扉と向き合います。

#5 · 偶数ページに著者、奇数ページに表題

script.js · 120〜134行コード全体で見る
const SHIFT = (INNER - OUTER) / 2; // mm: the text block's centre is off the page's centre
const head = (id, content, parity, edge, x, y = 10, pages = 'body') => ({
  kind: 'text', id, content, parity, pages, ...caps(8, 1.3, 'muted'),
  placement: at('page', edge, x, y),
});
const folio = { fontFamily: TEXT, fontWeight: 400, letterSpacing: pt(0), color: col('ink') };
const header = { elements: [
  { ...head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER), ...folio },
  head('verso-author', '{author}', 'even', 'top', -SHIFT),
  head('recto-title', '{title}', 'odd', 'top', SHIFT),
  { ...head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER), ...folio },
] };
const drop = (parity, x) => ({ ...head(`drop-${parity}`, '{pageNumber}', parity, 'bottom', x,
  -11, 'opener'), ...folio });
const footer = { elements: [drop('odd', SHIFT), drop('even', -SHIFT)] };

parityで偶数ページに著者を、奇数ページに表題を置きます。pages: 'body'で章扉にはどちらも出さず、章扉ではpages: 'opener'を指定した地のノンブルが代わりに入ります。SHIFTは各柱を版面の中央に移します。2つの余白の幅が違うので、版面の中央はページの中央から0.5 mmずれています。

#6 · ラベルのない5点の版画

script.js · 138〜154行コード全体で見る
const resourceTypes = [{ id: 'gravat', name: 'Gravat', namePlural: 'Gravats', shortLabel: 'Gravat',
  captionPrefix: '', numberingTemplate: '{n}', resetOn: 'never', counterFormat: 'decimal' }];
const PICTURES = { // id: [file, width, height, alt text in the book's language]
  frontis: ['frontis-1000.jpg', 1000, 1500, 'Un carrer de poble al capvespre. A la porta del forn, '
    + 'on cremen les flames, el forner, gras i somrient, amb davantal blanc i els braços creuats.'],
  cap1: ['cap1-1200.jpg', 1200, 800, 'De nit, el tren baixa cap a Barcelona: rengleres de fanals, '
    + 'la muntanya de Montjuïc i la lluna sobre el mar. Un pagès treu el cap per la finestreta.'],
  cap2: ['cap2-1200.jpg', 1200, 800, 'Un carrer de poble buit en una nit de tardor. Per la porta '
    + 'baixa de la ferreria, el manyà pica l’enclusa enmig d’una estrella d’espurnes.'],
  cap3: ['cap3-1200.jpg', 1200, 800, 'La Rambla a trenc d’alba des d’un balcó. Un fanaler apaga '
    + 'el gas amb la perxa; al fons, els pals dels vaixells del port.'],
  cap4: ['cap4-1200.jpg', 1200, 800, 'Capvespre als afores. Un vell de cabells blancs, assegut '
    + 'al caire del desmunt, mira la via del tren, que es perd recta fins a l’horitzó.'],
};
const resources = Object.entries(PICTURES).map(([id, [fileId, w, h, altText]]) => ({
  id, typeId: 'gravat', kind: 'bitmap', createdAt: 0, updatedAt: 0, altText,
  bitmap: { fileId, format: 'jpeg', width: w, height: h } }));

画像はcaptionPrefixが空のリソース種別に属するので、番号もラベルも付きません。それぞれピクセル寸法で宣言し、組版の前にファイルIDで読み込みます。保存する前に白をページのクリーム色に、黒をインキの色に置き換えてあるので、上に貼った写真ではなく、ページの一部として印刷されます。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 104 · A Catalan novella, hyphenated by the IEC rules ═══════
// https://postext.dev/en/cookbook/catalan-pocket-novella
// Code: MIT · Text: N. Oller, El transplantat, 1928 (PD, Viquitexts) · Pictures: diffusion models
// Fonts: Gentium Book Plus, Cormorant Garamond, Cormorant SC (OFL) · Needs postext ≥ 1.57.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the sample document (the sample is Catalan in both)
const RECIPE = 'catalan-pocket-novella';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = {
  ink: '#2a2320', // text: a warm near-black, the pictures' ink too
  vermell: '#953222', // the one accent: chapter numerals, rules, the title page's title
  muted: '#6e6359', // running heads, the edition's note, the colophon
  paper: '#f5efe1', // a cream book paper, the pictures' white
};
// Each colour names its palette entry and carries its hex.
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: 'vermell (defaults)', value: { hex: palette.vermell, model: 'hex' } },
];
const [TEXT, DISPLAY, LABEL] = ['Gentium Book Plus', 'Cormorant Garamond', 'Cormorant SC'];
const [BODY, LEAD] = [9.85, 14]; // pt: body and leading, the pitch of every vertical measure
const LINE = (LEAD * 25.4) / 72; // mm: one line, 4.94
const at = (to, edge, x = 0, y = 0, size) => ({ anchor: { to, edge },
  offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });
const text = (id, content, fontFamily, size, placement, extra = {}) => ({ kind: 'text', id,
  content, fontFamily, fontSize: pt(size), color: col('ink'), align: 'center',
  overflow: 'wrap', placement, ...extra }); // a long title takes a second line
const caps = (size, tracking, color = 'vermell') => ({ fontFamily: LABEL, fontSize: pt(size),
  fontWeight: 600, letterSpacing: pt(tracking), color: col(color) });

// #region page: a 12 × 18.5 cm pocket book; the text block holds 29 whole lines
const TRIM = { width: 120, height: 185 }; // mm
const [TOP, INNER, OUTER, LINES] = [18, 16, 15, 29];
const MEASURE = TRIM.width - INNER - OUTER; // 89 mm: about 63 characters of Gentium Book Plus
const page = {
  width: mm(TRIM.width), height: mm(TRIM.height), dpi: 150, backgroundColor: col('paper'),
  margins: { top: mm(TOP), bottom: mm(TRIM.height - TOP - LINES * LINE),
    left: mm(INNER), right: mm(OUTER), mirror: true }, // left is the inner margin on a recto
};
// #endregion

// #region answer: Catalan by its own code: l·l breaks as il- | lusió, no word splits its hiatus

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

アレンジ

#代名詞の部分でも分割させる

既定のcompounds: trueでは、d’inaugurar-seが動詞の中でd’i- | naugurar-seと分かれ、7ページのゆるい行がなくなります。語間が1.6倍を超える行は1つも残りません。titil- | lavenの分割は27ページのままです。その代わり、行末のアポストロフィのあとにiが1文字だけ残ります。

-  hyphenation: { compounds: false },
+  hyphenation: { compounds: true },

#どの章も奇数ページで始める

parity: 'odd'は、偶数ページで始まるはずの章の前に白ページを入れます。余裕のある版の組み方です。26ページで始まる第IV章は、白ページのあとの27ページに移ります。

-  breakBefore: { enabled: true, parity: 'any' }, // a chapter opens on the next page, either side
+  breakBefore: { enabled: true, parity: 'odd' },

よくあるつまずき

つまずき

見出しスタイルはその階層の改ページを受け継ぐ

headingStylesの項目は、指定しなかったフィールドをすべて見出しの階層から受け継ぎ、breakBeforeも例外ではありません。:::pagebreakのあとのH1に付けた目次や奥付のスタイルはparity 'odd'を受け継ぎ、白ページの後ろに置かれます。こうしたスタイルにはbreakBefore: { enabled: false }を指定してください。 見出しスタイル →

つまずき

属性値には{も}も書けない。"を含む値は一重引用符で囲む

属性値は閉じ波かっこで終わるため、{や}を含められません。二重引用符を含む値は一重引用符で囲みます。ドル記号は問題ありません。 見出しの属性 →

  • 本文の書体を決める前に、その書体がl·lをどう組むかを確かめてください。postext 1.30以降、文書のlocaleはテキストを組む言語でもあり(1.29までは本を表示しているページの言語でした)、カタルーニャ語への応じ方は書体ごとに違います。Gentium Book Plusの中点はどの言語でも1つだけで、2つのlのあいだは0.17 emです。1.29までこの本を組んでいたCrimson Proは、カタルーニャ語では中点を0.59 emに広げ、intel·ligentに隙間をあけます。AlegreyaとLiterataは、2つのlがひと続きの文字列として届いたときにだけ詰まった中点を描くので、il·lustratsはイタリックを含む段落とイタリックのない段落とで別の形になります。
  • 本文はViquitextsからイタリックごとコピーしてください。ウリェーはtentu、Ensanxe、palacioを口語またはスペイン語としてイタリックで示していますが、プレーンテキストで書き出すとそれが消えます。疑わしい語は1928年版のスキャン画像と照合してください。動詞がtornarである箇所(tomà、tomaré、tomar)で、翻刻がtom-となっているところが6か所、jornがjomとなっているところが1か所あります。
  • 6,800語あるため、5つの本文ファイルとキットを合わせると、組み上がったスクリプトは約69 KBになります。1冊まるごとがCodePenのサンプルに載せられる最大の見本で、それより長い作品は.postextバンドルにします。

クレジット

レシピ
Ignacio Ferro
本文
  • El transplantat, complete, from the Obres completes, vol. VI (Barcelona, 1928), with misprints corrected, no opening ¿ ¡ and today’s dialogue dashes · Narcís Oller · パブリックドメイン
  • The note to the edition · Postext Cookbook · オリジナル
画像
  • Engraving, frontispiece: the baker at his oven's door · Generated With Diffusion Models · オリジナル
  • Engraving, chapter I: the night train into Barcelona · Generated With Diffusion Models · オリジナル
  • Engraving, chapter II: the village street in autumn · Generated With Diffusion Models · オリジナル
  • Engraving, chapter III: the Rambla at dawn · Generated With Diffusion Models · オリジナル
  • Engraving, chapter IV: the old man by the railway · Generated With Diffusion Models · オリジナル
フォント
Gentium Book Plus (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Cormorant SC (SIL OFL 1.1)
SandboxPDF