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

レシピ集 · 第10章 · 出力と組み込み

叢書の一冊、見返しにシリーズの全点を

全12巻の上製叢書の第11巻。バーコードの横に2つのISBN、全巻共通の表紙デザイン、そして見返しにはシリーズ全点を並べる。

このページの内容
出力
Canvas · PDF
レベル
上級
Postext
Postext 1.92.0で検証済み
1.92.0以上が必要 · postext-pdf ≥ 1.92.0
ライセンス
2026年11月23日更新
コードMIT · 本文CC BY 4.0
  • 英語の見本:日本語版はまだありません
  • 仕上がり120 × 185 mm
  • 1段
  • Crimson Pro 11/15.2
  • Cormorant Garamond
  • Josefin Sans
  • 29ページ
  • レベル
  • Postext 1.92.0
  • 組版時間110 ms
  • コード238行

かんたんな説明

12冊シリーズのうちの上製本1冊と、印刷所に渡す用紙一式。叢書の色と巻数を載せた表紙と、表紙の内側に貼る2枚の見返しで、見返しには12冊すべての表紙と書名が並びます。

できあがり

セルバンテスの『模範小説集』12編の11番目『偽りの結婚』を、1編を1冊の上製本にする叢書の第11巻として組みます。本文26ページは120 × 185 mmのページにCrimson Pro 11/15.2で組みます。そこから buildCover が製本所向けの用紙を3枚作ります。叢書のえんじ色に刷った表紙(絵のまわりに金の枠、巻数は金の輪の中)と、前後の見返しです。見返しは叢書を半分ずつ受け持ち、第1〜6巻が本の前、第7〜12巻が後ろに入り、どちらも効き紙に絵、遊び紙に番号付きの書名一覧を載せます。巻のISBNを載せたバーコードの横には、全巻のISBNが刷られます。

このレシピが答える質問

  • シリーズの1冊を、セットISBNと見返しの既刊案内付きで刷るには?

手短な答え

script.js · 30〜58行コード全体で見る
// The collection is data of the book, beside its versions. The volume's barcode carries its
// own ISBN, and the collection's `isbn` prints as a line above the bars. `catalogue` lists
// the twelve titles with their cover pictures, and `volume` names the one this book is: the
// endpapers set the list and the pictures from it (section 4), this volume marked in both.
const collection = {
  name: t({ en: 'Exemplary Novels', es: 'Novelas ejemplares' }),
  isbn: '978-84-0000-200-8',
  catalogue: [
    work('The Little Gipsy Girl', 'La gitanilla', 'gitanilla'),
    work('The Generous Lover', 'El amante liberal', 'amante'),
    work('Rinconete and Cortadillo', 'Rinconete y Cortadillo', 'rinconete'),
    work('The Spanish-English Lady', 'La española inglesa', 'espanola'),
    work('The Licentiate Vidriera', 'El licenciado Vidriera', 'vidriera'),
    work('The Force of Blood', 'La fuerza de la sangre', 'fuerza'),
    work('The Jealous Estremaduran', 'El celoso extremeño', 'celoso'),
    work('The Illustrious Scullery-Maid', 'La ilustre fregona', 'fregona'),
    work('The Two Damsels', 'Las dos doncellas', 'doncellas'),
    work('The Lady Cornelia', 'La señora Cornelia', 'cornelia'),
    work('The Deceitful Marriage', 'El casamiento engañoso', 'casamiento'),
    work('The Dialogue of the Dogs', 'El coloquio de los perros', 'coloquio'),
  ],
};
collection.volume = collection.catalogue[VOLUME - 1].id;
const production = {
  collection,
  // A printed case with a flat spine: the case sheet and two endpapers, no jacket.
  versions: [{ id: 'hardcover', name: t({ en: 'Hardcover', es: 'Tapa dura' }),
    binding: 'case-flat', isbn: '978-84-0000-198-8', isbnAddOn: '90000' }],
};

材料

種類
Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1)
素材
  • amante-320.jpg
  • casamiento-1000.jpg
  • casamiento-320.jpg
  • celoso-320.jpg
  • coloquio-320.jpg
  • cornelia-320.jpg
  • doncellas-320.jpg
  • espanola-320.jpg
  • fregona-320.jpg
  • fuerza-320.jpg
  • gitanilla-320.jpg
  • rinconete-320.jpg
  • vidriera-320.jpg
  • The front cover: a pale ensign leaning on his sword at the gate of the hospital of Valladolid, in oils (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 1, The Little Gipsy Girl, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 2, The Generous Lover, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 3, Rinconete and Cortadillo, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 4, The Spanish-English Lady, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 5, The Licentiate Vidriera, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 6, The Force of Blood, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 7, The Jealous Estremaduran, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 8, The Illustrious Scullery-Maid, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 9, The Two Damsels, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 10, The Lady Cornelia, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 11, The Deceitful Marriage, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)
  • The cover painting of volume 12, The Dialogue of the Dogs, on the endpapers, painted to match the front cover (Generated With Diffusion Models, オリジナル)

作り方

#1 · 叢書は本のデータ

コードは上の手短な答えです。production.collection に叢書の名前、ISBN、各巻のID・書名・画像を並べた catalogue、そしてこの本にあたる目録項目のIDを示す volume を持たせます。Postextがバーコードの横に刷るのは叢書の isbn で、バーの上に6.5ポイントの黒い1行「全巻ISBN」が本の言語で入ります。版が自前の workIsbn を持つときはそちらが刷られます。2つのISBNはどちらも978-84-0000ブロックの見本番号で、どの本にも割り当てられていません。設定のチェックは、目録にない volume と、チェックディジットの合わない叢書ISBNを報告します。

#2 · 全巻に同じ装丁

script.js · 63〜80行コード全体で見る
// Every position is in mm from the top-left corner of its zone (the case's front is
// 116 × 191 mm: the 120 × 185 trim, set back 7 mm at the joint, 3 mm square round it).
const box = (id, zone, x, y, width, height, color, extra) => ({ id, kind: 'box', zone, x, y,
  width, height, color: col(color), ...extra });
const picture = (id, zone, x, y, width, height, resourceId, extra) => ({ id, kind: 'image', zone,
  x, y, width, height, resourceId, fit: 'cover', ...extra });
// `basis`: the spine drawn on; a thicker book stretches the bands and keeps the badge centred.
const spine = { basis: { width: 10, height: 191 } };
const livery = [
  box('frame', 'front', 11.2, 59.2, 93.6, 105.6, 'gold'),
  picture('art', 'front', 12, 60, 92, 104, 'cover-art'),
  picture('badge', 'front', 51.5, 169, 13, 13, 'badge', { fit: 'contain' }),
  box('head-band', 'spine', 0, 13, 10, 0.8, 'gold', spine),
  box('foot-band', 'spine', 0, 160, 10, 0.8, 'gold', spine),
  picture('spine-badge', 'spine', 1, 167, 8, 8, 'badge', { fit: 'contain', ...spine }),
  // A paper label for the barcode, whose caption is set in black.
  box('label', 'back', 53, 147, 61, 40, 'bone'),
];

表紙のデザインは叢書のどの巻でも同じオブジェクトで、変わるのは VOLUME、絵、文字だけです。各要素は置かれたゾーンを基準に配置されるので、ページ数が多く背の厚い巻では表表紙がその面と一緒に動きます。背では basis が帯を描いたときの10 mmの背幅を記録し、背が8.3 mmでも14 mmでも帯は幅に合わせて伸縮し、輪は中心線に残ります。バーコードの上の行は黒で刷られるので、バーコードは淡いラベルの上に置きます。

#3 · 見返しごとに専用のデザイン

script.js · 84〜99行コード全体で見る
// The case takes the livery; each endpaper names a design in `sheets`. At the front the
// pastedown is the left page, at the back the right one: volumes I–VI open the book,
// VII–XII close it, the pictures always on the pastedown, in the case's colour. A catalogue
// element grids the titles' pictures in its box; `stroke` outlines this volume's.
const shelf = (first, last) => ({ id: `shelf-${first}`, kind: 'catalogue', zone: 'pastedown',
  x: 26.5, y: 18, width: 67, height: 149, columns: 2, gap: 7, first, last,
  stroke: { color: col('gold'), width: 0.8 } });
const endpaper = (first, last) => ({ background: col('endpaper'),
  zones: { pastedown: col('case') }, elements: [shelf(first, last)],
  verticalAlign: { flyleaf: 'middle' } });
const cover = {
  background: col('case'),
  elements: livery,
  verticalAlign: { back: 'top' },
  sheets: { endpaperFront: endpaper(1, 6), endpaperBack: endpaper(7, 12) },
};

cover.sheets は、ある用紙に表紙のデザインに代わる専用のデザインを与えます。ここでは endpaperFront と endpaperBack で、それぞれ地色(効き紙は表紙の色)と catalogue 要素を持ちます。この要素はゾーンの中の箱で、エンジンが目録の first から last までの書名の画像を columns 列、間隔 gap mmで並べ、各画像がそのセルを覆います。IDが collection.volume と一致する巻は要素の stroke で囲まれ、この見返しでは第11巻の金の枠になります。用紙はそれぞれ自分のデザインしか描かないので、表紙の装丁は見返しに出ません。本の前を開くと効き紙は左ページ、後ろでは右ページなので、絵はいつも板紙の上に来ます。

書名は表紙用Markdownから取られ、このMarkdownはすべての用紙に使われます。用紙を指定した枠は、その用紙にだけ入ります。

:::frame{slot="flyleaf" sheet="endpaperBack"}
:::paragraphs{style="ad-head"}
Exemplary Novels
:::
 
::catalogue{numbers="I" first=7 last=12}
:::

::catalogue は目録の書名に置き換わり、1巻につき1段落になります。numbers が指定する番号スタイルでの順番、半角幅のスペース(en space)、書名の順です。各行は段落スタイル cover-catalogue、この巻の行は cover-catalogue-current を使います。コードは両方を定義し直し、Crimson Proの中央揃えにして、この巻を濃い赤にしています。裏表紙の枠は case jacket を指定しているので、見返しには入りません。

#4 · 1冊の本から3枚の用紙

script.js · 421〜432行コード全体で見る
const sheet = async (kind) => {
  const built = buildCover({ config, version: 'hardcover', pages: book.pages,
    markdown: coverText, metadata: book.metadata, resources, sheet: kind });
  if (!('config' in built)) throw new Error(built.issues.map((i) => i.kind).join(', '));
  // The barcode's digits name OCR-B, which no font server has: the label face sets them.
  for (const [id, bytes] of Object.entries(built.files)) {
    await loadSvg(id, new TextDecoder().decode(bytes)
      .replace(/font-family="[^"]*"/g, 'font-family="Josefin Sans"'));
  }
  return { built, doc: await buildDocumentWithFonts(built.content, built.config, kitFonts(FONTS)) };
};
const sheets = [await sheet('cover'), await sheet('endpaperFront'), await sheet('endpaperBack')];

同じ呼び出しに sheet: 'cover'、'endpaperFront'、'endpaperBack' を渡すと、表紙と2枚の見返しができ、それぞれ固有の寸法の1ページ文書になります。26ページは16ページの折丁2つに切り上げられ、240 µmの紙16枚。0.5 mmの余裕を加えて本文は4.3 mm、2 mmの板紙2枚を足して表紙の背は8.3 mmです。背文字のチェックは表紙の背の幅で行われ、最小値6 mmを超えています。PDFは本文26ページのあとに表紙と見返しが続きます。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 198 · A volume of a collection, its endpapers the series ═══
// https://postext.dev/en/cookbook/collection-volume-endpapers
// Code: MIT · Text: Cervantes, tr. W. K. Kelly (public domain) · Art: diffusion models
// Fonts: Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1) · Needs postext ≥ 1.92.0
//
// Volume XI of the twelve Exemplary Novels, one novella per hardcover: the series livery on
// the case, two ISBNs by the barcode, the twelve titles of the collection on the endpapers.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, inlineSvgFonts,
} from 'https://esm.sh/postext';
import { buildCover, workIsbnCaption } from 'https://esm.sh/postext/production';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'collection-volume-endpapers';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { ink: '#2a211c', accent: '#7a2a22', muted: '#6c6258', paper: '#fbf7ee',
  case: '#5e1c1a', gold: '#d2ae6a', bone: '#f1e8d4', endpaper: '#ece0c6' };
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: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
const VOLUME = 11; // this book's place in the collection
const roman = (n) => 'I II III IV V VI VII VIII IX X XI XII'.split(' ')[n - 1];
const work = (en, es, id) => ({ id, title: t({ en, es }), resource: `cat-${id}` });

// #region answer: the volume and its collection: two ISBNs and the series' catalogue
// The collection is data of the book, beside its versions. The volume's barcode carries its
// own ISBN, and the collection's `isbn` prints as a line above the bars. `catalogue` lists
// the twelve titles with their cover pictures, and `volume` names the one this book is: the
// endpapers set the list and the pictures from it (section 4), this volume marked in both.
const collection = {
  name: t({ en: 'Exemplary Novels', es: 'Novelas ejemplares' }),
  isbn: '978-84-0000-200-8',
  catalogue: [
    work('The Little Gipsy Girl', 'La gitanilla', 'gitanilla'),
    work('The Generous Lover', 'El amante liberal', 'amante'),
    work('Rinconete and Cortadillo', 'Rinconete y Cortadillo', 'rinconete'),
    work('The Spanish-English Lady', 'La española inglesa', 'espanola'),
    work('The Licentiate Vidriera', 'El licenciado Vidriera', 'vidriera'),
    work('The Force of Blood', 'La fuerza de la sangre', 'fuerza'),
    work('The Jealous Estremaduran', 'El celoso extremeño', 'celoso'),
    work('The Illustrious Scullery-Maid', 'La ilustre fregona', 'fregona'),
    work('The Two Damsels', 'Las dos doncellas', 'doncellas'),
    work('The Lady Cornelia', 'La señora Cornelia', 'cornelia'),
    work('The Deceitful Marriage', 'El casamiento engañoso', 'casamiento'),

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

アレンジ

#表紙にカバーを掛ける

上製本では flaps でカバーが加わります。自前の袖を持つ4枚目の用紙です。バーコードと全巻ISBNはその裏表紙に移り、枠に jacket を指定した紹介文も一緒に移ります。

   versions: [{ id: 'hardcover', name: t({ en: 'Hardcover', es: 'Tapa dura' }),
-    binding: 'case-flat', isbn: '978-84-0000-198-8', isbnAddOn: '90000' }],
+    binding: 'case-flat', isbn: '978-84-0000-198-8', isbnAddOn: '90000', flaps: true }],

#次の巻を組む

第12巻ではデザインはそのままです。VOLUME が collection.volume で目録のどの項目かを決め、巻数の輪、見返しの金の枠、強調される書名がそれに従います。表紙用Markdown、絵、ISBNはその巻のものにします。

-const VOLUME = 11; // this book's place in the collection
+const VOLUME = 12; // this book's place in the collection

よくあるつまずき

  • キャプチャされる一覧では、用紙は本のページのあとに来ます。表紙は27ページ目、つまり本のページ数に1を足した位置です。本に1ページ増える変更をすると、用紙の位置もずれます。
  • レシピ集の contentInConfig チェックは、buildCover がバーコードの上に刷る行をデザインに置いた文字と見なします。コードはそれを checks.contentInConfig.allow に、エンジンが使う関数 workIsbnCaption の文言で登録します。
  • catalogue 要素が描くのは画像だけです。書名一覧はMarkdownの ::catalogue なので、その行がない用紙では絵の下に書名が出ません。
  • バーコードの数字はOCR-Bを指定しますが、どのフォントサーバーにもありません。コードがすでに読み込んでいる font-family に置き換えてバーコードを読み込まないと、PDFが失敗します。

クレジット

レシピ
Ignacio Ferro
本文
画像
  • The front cover: a pale ensign leaning on his sword at the gate of the hospital of Valladolid, in oils · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 1, The Little Gipsy Girl, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 2, The Generous Lover, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 3, Rinconete and Cortadillo, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 4, The Spanish-English Lady, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 5, The Licentiate Vidriera, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 6, The Force of Blood, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 7, The Jealous Estremaduran, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 8, The Illustrious Scullery-Maid, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 9, The Two Damsels, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 10, The Lady Cornelia, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 11, The Deceitful Marriage, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
  • The cover painting of volume 12, The Dialogue of the Dogs, on the endpapers, painted to match the front cover · Generated With Diffusion Models · オリジナル
フォント
Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Josefin Sans (SIL OFL 1.1)
SandboxPDF