Saltar al contingut principal
Recepta número 198

Receptari · Capítol 10 · Sortida i integració

Un volum de col·lecció, amb la sèrie a les guardes

El volum XI d'una col·lecció de dotze en tapa dura: dos ISBN al costat del codi de barres, una tapa comuna a tots i la col·lecció sencera a les guardes.

En aquesta pàgina
Sortida
Canvas · PDF
Nivell
Avançat
Postext
Provada amb Postext 1.92.0
Requereix ≥ 1.92.0 · postext-pdf ≥ 1.92.0
Llicència
Actualitzada el 23 de nov. del 2026
Codi MIT · Text CC BY 4.0
  • Mostra en castellà: encara no hi ha edició en català
  • Format 120 × 185 mm
  • 1 columna
  • Crimson Pro 11/15,2
  • Cormorant Garamond
  • Josefin Sans
  • 29 pàgines
  • Nivell
  • Postext 1.92.0
  • Compost en 123 ms
  • 238 línies de codi

En poques paraules

Un llibre de tapa dura d'una sèrie de dotze, amb els plecs per a la impremta: la tapa amb els colors de la col·lecció i el número del volum, i les dues guardes de dins, amb les cobertes i els títols dels dotze llibres.

Què compondràs

El casamiento engañoso, l'onzena de les dotze Novelas ejemplares de Cervantes, com a volum XI d'una col·lecció que publica una novel·la a cada volum de tapa dura. Les 26 pàgines van en Crimson Pro de 11/15,2 sobre una pàgina de 120 × 185 mm. Amb elles, buildCover fa tres plecs per a l'enquadernador: la tapa impresa, en el granat de la col·lecció, amb un marc daurat al voltant de la pintura i el número en un anell d'or, i les guardes davantera i del darrere, que es reparteixen la col·lecció: els volums I a VI obren el llibre i els VII a XII el tanquen, cada meitat en pintures a la contraguarda i en llista numerada al full volant. Al costat del codi de barres, que porta l'ISBN del volum, la tapa imprimeix l'ISBN de l'obra completa.

Aquesta recepta respon a

  • Com imprimeixo un volum d'una col·lecció amb l'ISBN de l'obra completa i els altres títols a les guardes?

La resposta curta

script.js · línies 30–58al codi complet
// 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' }],
};

Ingredients

Tipografia
Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1)
Recursos
  • 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, original)
  • The cover painting of volume 1, The Little Gipsy Girl, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 2, The Generous Lover, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 3, Rinconete and Cortadillo, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 4, The Spanish-English Lady, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 5, The Licentiate Vidriera, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 6, The Force of Blood, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 7, The Jealous Estremaduran, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 8, The Illustrious Scullery-Maid, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 9, The Two Damsels, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 10, The Lady Cornelia, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 11, The Deceitful Marriage, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)
  • The cover painting of volume 12, The Dialogue of the Dogs, on the endpapers, painted to match the front cover (Generated With Diffusion Models, original)

Elaboració

#1 · La col·lecció és una dada del llibre

El codi és la resposta curta de dalt. production.collection desa la sèrie: el nom, l'ISBN, un catalogue amb un identificador, un títol i una imatge per a cada volum, i volume, l'identificador de l'entrada que és aquest llibre. L'isbn de la col·lecció és el que Postext imprimeix al costat del codi de barres: una línia en negre de 6,5 pt damunt de les barres, «ISBN obra completa», en la llengua del llibre. Si la versió declara un workIsbn propi, s'imprimeix aquest. Els dos ISBN són números de mostra del bloc 978-84-0000, que no corresponen a cap llibre. Les comprovacions de la configuració avisen d'un volume que no és al catàleg i d'un ISBN de col·lecció amb el dígit de control equivocat.

#2 · Un mateix disseny per a tots els volums

script.js · línies 63–80al codi complet
// 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'),
];

El disseny de la tapa és el mateix objecte a tots els volums de la col·lecció; només canvien VOLUME, la pintura i els textos. Cada element es col·loca respecte a la zona on és, de manera que, si un altre volum té més pàgines i un llom més gruixut, la coberta es desplaça amb el seu panell. Al llom, basis anota els 10 mm de llom sobre els quals es van dibuixar les bandes: amb un llom de 8,3 mm o de 14 mm les bandes s'ajusten a l'amplada i l'anell continua a l'eix. La línia damunt del codi de barres va en negre, i per això el codi descansa sobre una etiqueta clara.

#3 · Cada guarda té el seu propi disseny

script.js · línies 84–99al codi complet
// 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 dona a un plec un disseny que substitueix el de la coberta: aquí endpaperFront i endpaperBack, cadascun amb el seu fons, la contraguarda del color de la tapa, i un element catalogue. L'element és una caixa en una zona que el motor omple amb les imatges dels títols de first a last, en columns columnes separades gap mm, cada imatge cobrint la seva cel·la. El títol l'identificador del qual és collection.volume es perfila amb el stroke de l'element; en aquestes guardes és el marc daurat del volum XI. El disseny de la tapa no arriba a les guardes, perquè cada plec dibuixa només el seu. En obrir el llibre per davant, la contraguarda és la pàgina esquerra, i al final és la dreta, de manera que les pintures queden sempre damunt del cartró.

Els títols surten del Markdown de coberta, que serveix per a tots els plecs. Un marc que anomena els seus plecs només va en aquests:

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

::catalogue se substitueix pels títols del catàleg, un paràgraf cadascun: el lloc en l'estil de numeració que indica numbers, un espai de mitja quadratí i el títol. Les línies porten l'estil de paràgraf cover-catalogue, i la d'aquest volum, cover-catalogue-current; el codi redefineix tots dos, centrats en Crimson Pro, l'actual en vermell fosc. El marc de la contracoberta anomena case jacket, així que les guardes el deixen fora.

#4 · Tres plecs d'un mateix llibre

script.js · línies 447–458al codi complet
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')];

La mateixa crida amb sheet: 'cover', 'endpaperFront' i 'endpaperBack' fa la tapa i les dues guardes, cadascuna un document d'una pàgina a la seva mida. Les 26 pàgines s'arrodoneixen a dos quaderns de 16, 16 fulls de 240 µm; amb mig mil·límetre de marge el bloc fa 4,3 mm i el llom de la tapa 8,3 mm, en sumar-hi dos cartrons de 2 mm. El rètol es comprova contra el llom de la tapa, que supera el mínim de 6 mm. El PDF porta les 26 pàgines i després la tapa i les guardes.

La recepta completa

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 = 'es'; // @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'),

L'script.js compost funciona tal com és: enganxa'l com a script de mòdul en qualsevol pàgina o obre la recepta a CodePen. Carpeta de la recepta a GitHub ↗ (s'obre en una pestanya nova)

Variants

#Vesteix la tapa amb una sobrecoberta

En una tapa dura, flaps hi afegeix la sobrecoberta, un quart plec amb les seves solapes. El codi de barres i l'ISBN de l'obra completa passen a la seva contracoberta, i amb ells el text de presentació, el marc del qual anomena 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 }],

#Compon el volum següent

Per al volum XII el disseny no canvia: VOLUME anomena l'entrada del catàleg a collection.volume, i l'anell, el marc daurat de les guardes i el títol destacat la segueixen. El Markdown de coberta, la pintura i l'ISBN són els d'aquest volum.

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

Errors freqüents

  • Els plecs van darrere de les pàgines del llibre a la llista capturada: la tapa és la pàgina 27, el nombre de pàgines del llibre més u. Un canvi que afegeixi una pàgina al llibre els desplaça.
  • La comprovació contentInConfig del Receptari pren la línia que buildCover imprimeix damunt del codi de barres per text desat en un disseny. El codi la declara a checks.contentInConfig.allow, amb la redacció de workIsbnCaption, la funció que fa servir el motor.
  • Un element catalogue dibuixa només les imatges. La llista de títols és el ::catalogue del Markdown, així que un plec sense aquesta línia mostra les pintures sense cap nom a sota.
  • Les xifres del codi de barres demanen OCR-B, que no serveix cap servidor de fonts. Carrega el codi de barres amb el font-family d'una font que ja carregues, o el PDF falla.

Crèdits

Text
  • The Deceitful Marriage, translated by Walter K. Kelly, from The Exemplary Novels of Cervantes (London, Bohn’s Standard Library, 1846; 1881 reprint), Project Gutenberg eBook #14420 · Miguel de Cervantes · domini públic
  • El casamiento engañoso, from the Novelas ejemplares in the 1825 edition as transcribed on Wikisource · Miguel de Cervantes · domini públic
Imatges
  • The front cover: a pale ensign leaning on his sword at the gate of the hospital of Valladolid, in oils · Generated With Diffusion Models · original
  • The cover painting of volume 1, The Little Gipsy Girl, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 2, The Generous Lover, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 3, Rinconete and Cortadillo, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 4, The Spanish-English Lady, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 5, The Licentiate Vidriera, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 6, The Force of Blood, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 7, The Jealous Estremaduran, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 8, The Illustrious Scullery-Maid, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 9, The Two Damsels, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 10, The Lady Cornelia, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 11, The Deceitful Marriage, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
  • The cover painting of volume 12, The Dialogue of the Dogs, on the endpapers, painted to match the front cover · Generated With Diffusion Models · original
Fonts
Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Josefin Sans (SIL OFL 1.1)
SandboxPDF