# Τρέχουσες κεφαλίδες κατά μονή και ζυγή σε βιβλίο δοκιμίων

> Κεφαλίδες κατά μονή ή ζυγή και ρόλο σελίδας: τίτλος βιβλίου αριστερά, τίτλος δοκιμίου κομμένος δεξιά, γλωττίδες αριθμού στο περιθώριο, χαμηλός αριθμός αρχής.

- Έκδοση HTML: https://postext.dev/el/cookbook/running-heads-by-parity
- Συνταγή Αρ. 005 · Τρέχουσες κεφαλίδες και αριθμοί σελίδων · Επίπεδο 2 (Μεσαίο) · Έξοδοι: Canvas
- Είδη: Πεζογραφία, θέατρο και λογοτεχνικός λόγος
- Απαιτεί postext ≥ 1.57.0 · δοκιμασμένη με 1.65.0 στις 2026-10-31
- Σελίδες: [29](https://postext.dev/cookbook/running-heads-by-parity/en/p01.webp?v=1dd3ea0d), [30](https://postext.dev/cookbook/running-heads-by-parity/en/p02.webp?v=1dd3ea0d), [31](https://postext.dev/cookbook/running-heads-by-parity/en/p03.webp?v=1dd3ea0d), [32](https://postext.dev/cookbook/running-heads-by-parity/en/p04.webp?v=1dd3ea0d), [33](https://postext.dev/cookbook/running-heads-by-parity/en/p05.webp?v=1dd3ea0d)
- Άνοιγμα στο Sandbox: https://postext.dev/el/sandbox#recipe=running-heads-by-parity&lang=en (.postext: https://postext.dev/cookbook/running-heads-by-parity/en/running-heads-by-parity.postext)
- Τελευταία ενημέρωση: 2026-10-22
- Άλλες γλώσσες: [en](https://postext.dev/en/cookbook/running-heads-by-parity.md), [es](https://postext.dev/es/cookbook/running-heads-by-parity.md), [ca](https://postext.dev/ca/cookbook/running-heads-by-parity.md), [de](https://postext.dev/de/cookbook/running-heads-by-parity.md), [fr](https://postext.dev/fr/cookbook/running-heads-by-parity.md), [it](https://postext.dev/it/cookbook/running-heads-by-parity.md), [pt](https://postext.dev/pt/cookbook/running-heads-by-parity.md), [zh](https://postext.dev/zh/cookbook/running-heads-by-parity.md), [ja](https://postext.dev/ja/cookbook/running-heads-by-parity.md), [ar](https://postext.dev/ar/cookbook/running-heads-by-parity.md)

## Με λίγα λόγια

Πέντε σελίδες από ένα μικρό βιβλίο δοκιμίων. Δείχνει πώς τυπώνεται ο τίτλος του βιβλίου στην κορυφή των αριστερών σελίδων και ο τίτλος του δοκιμίου στις δεξιές.

## Τι θα στοιχειοθετήσετε

Οι σελίδες 29 ως 33 μιας έκδοσης τσέπης των *Δοκιμίων* του Μονταίνιου στα αγγλικά του Charles Cotton: ολόκληρο το κεφάλαιο IV και η αρχή του κεφαλαίου V. Οι αριστερές σελίδες φέρουν τον τίτλο του βιβλίου σε αραιωμένα κεφαλαία. Οι δεξιές σελίδες φέρουν τον τίτλο του δοκιμίου σε πλάγια, κομμένο με αποσιωπητικά, αφού ο τίτλος του κεφαλαίου IV φτάνει τους 81 χαρακτήρες. Κάθε αριθμός σελίδας κάθεται σε μια γλωττίδα σέπια στο εξωτερικό περιθώριο, 3 mm από μια γραμμή των 0,5 pt στην άκρη της επιφάνειας στοιχειοθεσίας. Μια εναρκτήρια σελίδα δεν έχει κεφαλίδα, μόνο αριθμό σελίδας στο κάτω μέρος. Το κείμενο είναι σε Baskervville σε μια ζεστή υπόλευκη σελίδα, οι τίτλοι σε Libre Caslon Display, οι αριθμοί σελίδας και ο τίτλος του βιβλίου σε Alegreya SC. Κάθε κεφαλίδα ορίζεται στη διαμόρφωση, οπότε η ενσωματωμένη κεφαλίδα της μηχανής, μπλε Open Sans στα 8 pt, δεν τυπώνεται ποτέ.

**Αυτή η συνταγή απαντά:**

- Πώς βάζω τον τίτλο του βιβλίου στις αριστερές σελίδες, το κεφάλαιο στις δεξιές και τον αριθμό σελίδας έξω;
- Πώς κρύβω τις τρέχουσες κεφαλίδες στις εναρκτήριες και στις κενές σελίδες, ή χρωματίζω μια κενή αριστερή σελίδα με το χρώμα του μέρους;
- Πώς εμποδίζω τις επικεφαλίδες, τις έντονες λέξεις και τις κουκκίδες να βγαίνουν μπλε;

## Η σύντομη απάντηση

```js
// script.js, γραμμές 67–95
const GAP = 3; // mm from the tab to the divider, which lands on the text block's edge
const HEAD = 12; // mm from the top edge of the page to the top of the tab
const CAP = t({ en: 60.5, es: 66.8 }); // mm: the head's widest line, set per edition so
// essay IV's is cut after 'false' and 'objetos'; a short running title suits any title
const page = (edge) => ({ to: 'page', edge }); // the trim box (gotcha: negative-offsets)
const header = { elements: [
  // Verso (even): tab | divider | THE BOOK'S TITLE from the frontmatter
  folio({ id: 'folio-even', parity: 'even', pages: 'body', anchor: page('top-left'),
    x: OUTER - GAP - TAB, y: HEAD }),
  divider({ id: 'rule-even', parity: 'even', from: 'folio-even', edge: 'right-of', x: GAP }),
  { kind: 'text', id: 'book', content: '{title}', parity: 'even', pages: 'body',
    fontFamily: 'Alegreya SC', fontSize: pt(FOLIO_PT), lineHeight: LINE / FOLIO_PT,
    color: col('muted'), textTransform: 'uppercase', letterSpacing: pt(1.3),
    placement: { anchor: { to: '#rule-even', edge: 'right-of' }, // top: the tab's top
      offset: { x: mm(2.5), y: pt(PAD.top) } } }, // PAD.top down: on the folio's baseline
  // Recto (odd): the essay's title, cut short with an ellipsis | divider | tab.
  folio({ id: 'folio-odd', parity: 'odd', pages: 'body', anchor: page('top-right'),
    x: -(OUTER - GAP - TAB), y: HEAD }), // from the right edge, a negative x runs inwards
  divider({ id: 'rule-odd', parity: 'odd', from: 'folio-odd', edge: 'left-of', x: -GAP }),
  { kind: 'text', id: 'essay', content: '{chapterTitle}', parity: 'odd', pages: 'body',
    fontFamily: 'Baskervville', italic: true, fontSize: pt(TITLE_PT),
    lineHeight: LINE / TITLE_PT, color: col('muted'),
    overflow: 'ellipsis-end', // stated, though a running head's default
    placement: { anchor: { to: '#rule-odd', edge: 'left-of' },
      offset: { x: mm(-2.5), y: pt(PAD.top) }, size: { maxWidth: mm(CAP) } } },
] };
// Openers: no head, only a drop folio HEAD above the page's foot, centred under the text block.
const footer = { elements: [folio({ id: 'drop-folio', parity: 'all', pages: 'opener',
  anchor: { to: 'container', edge: 'bottom' }, y: -HEAD })] };
```

## Υλικά

**Διδάσκει**

- [Τρέχουσες κεφαλίδες και αριθμοί σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα): Θέσεις κεφαλίδας και υποσέλιδου με σύμβολα κράτησης θέσης ({pageNumber}, {chapterTitle}, {title}…), που ορίζονται χωριστά για δεξιά και αριστερή σελίδα, με τους μεγάλους τίτλους να περικόπτονται ή να αναδιπλώνονται.
- [Κεφαλίδες ανά ρόλο σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-κειμένου): Εμφάνιση ενός στοιχείου σχεδίασης μόνο σε σελίδες κυρίως κειμένου, εναρκτήριες σελίδες, σελίδες μέρους ή κενές σελίδες, και σε μονές ή ζυγές σελίδες.

**Χρησιμοποιεί επίσης**

- [Αγκύρωση στοιχείων σχεδίασης](https://postext.dev/el/docs/configuration-headers-footers.md#τοποθέτηση-στοιχείων)
- [Κείμενο, γραμμές και πλαίσια στις σχεδιάσεις σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα)
- [Σχεδιασμένες εναρκτήριες σελίδες](https://postext.dev/el/docs/configuration-headings.md#πλάτος-και-προηγμένη-σχεδίαση)
- [Ιδιότητες επικεφαλίδων](https://postext.dev/el/docs/document-format.md#χαρακτηριστικά-επικεφαλίδων)
- [Αλλαγές γραμμής στους τίτλους](https://postext.dev/el/docs/document-format-directives.md#αλλαγές-γραμμής-σε-τίτλους)
- [Κεφάλαια που ανοίγουν σε δεξιά σελίδα](https://postext.dev/el/docs/configuration-headings.md#αλλαγή-σελίδας-πριν-από-επικεφαλίδα)
- [Συμμετρικά περιθώρια](https://postext.dev/el/docs/configuration-page-layout.md#κατοπτρικά-περιθώρια)
- [Διάσταση σελίδας](https://postext.dev/el/docs/configuration-page-layout.md#προκαθορισμένα-μεγέθη-σελίδας)
- [Χρώμα χαρτιού](https://postext.dev/el/docs/configuration-page-layout.md#σελίδα)
- [Μεταδεδομένα εγγράφου](https://postext.dev/el/docs/document-format.md#μεταδεδομένα-frontmatter)
- [Έντονα, πλάγια και τα χρώματά τους](https://postext.dev/el/docs/configuration-text.md#κυρίως-κείμενο)
- [Σημασιολογική χρωματική παλέτα](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παλέτα-χρωμάτων)
- [Πλαίσια σημειώσεων](https://postext.dev/el/docs/configuration-callouts.md#στιλ-πλαισίων)
- [Στιλ παραγράφων](https://postext.dev/el/docs/configuration-styles.md#στιλ-παραγράφων)
- [Χήρες, ορφανές και κοντές τελευταίες γραμμές](https://postext.dev/el/docs/configuration-page-flow.md#ορφανές-χήρες-κοντές-τελευταίες-γραμμές-και-κανόνες-διατήρησης-μαζί)
- [Σελίδες σε καμβά](https://postext.dev/el/docs/configuration-programmatic-usage.md#απόδοση-σελίδας-σε-bitmap)
- [Βιβλία φτιαγμένα κεφάλαιο προς κεφάλαιο](https://postext.dev/el/docs/configuration-bundles.md#σελιδοποίηση-και-απόδοση-πακέτου)
- [Ταινία κεφαλαίου πλήρους πλάτους](https://postext.dev/el/docs/configuration-headings.md#πλάτος-και-προηγμένη-σχεδίαση)

**Η διαμόρφωση με μια ματιά**

- [`bodyText`](https://postext.dev/el/docs/configuration-text.md#κυρίως-κείμενο), [`calloutStyles`](https://postext.dev/el/docs/configuration-callouts.md#στιλ-πλαισίων), [`colorPalette`](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παλέτα-χρωμάτων), [`footer`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`header`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`headings`](https://postext.dev/el/docs/configuration-headings.md#επικεφαλίδες), [`layout`](https://postext.dev/el/docs/configuration-page-layout.md#διάταξη), [`locale`](https://postext.dev/el/docs/configuration-language.md#συλλαβισμός), [`page`](https://postext.dev/el/docs/configuration-page-layout.md#σελίδα), [`paragraphStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-παραγράφων)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/el/docs/configuration-programmatic-usage.md#φόρτωση-γραμματοσειρών-πριν-από-τη-σελιδοποίηση), [`renderPageToCanvas`](https://postext.dev/el/docs/configuration-programmatic-usage.md#απόδοση-σελίδας-σε-bitmap)

**Γραμματοσειρές**

- Baskervville (OFL-1.1), Libre Caslon Display (OFL-1.1), Alegreya SC (OFL-1.1)

## Προετοιμασία

### 1 · Αντικαταστήστε την ενσωματωμένη μπλε κεφαλίδα

```js
// script.js, γραμμές 14–26
const palette = {
  ink: '#1f1b16', // text: a warm near-black, never #000
  sepia: '#8a5a2b', // the one accent: folio tabs, dividers, opener plates (5.3:1 on paper)
  muted: '#6f6558', // running heads, verse glosses, the colophon (5.2:1 on paper)
  paper: '#f8f4ec', // a warm off-white page; also the type reversed out of the sepia
};
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' } })),
  // Text-style defaults (headings, bold, italic, lists, boxes) link to 'main-color':
  // pointed at the sepia, none of them prints in the engine's blue.
  { id: 'main-color', name: 'sepia (defaults)', value: { hex: palette.sepia, model: 'hex' } },
];
```

Κάθε χρώμα της διαμόρφωσης συνδέεται με μία από αυτές τις καταχωρίσεις. Αν αφήσετε το `header` χωρίς ορισμό, η μηχανή σχεδιάζει την ενσωματωμένη κεφαλίδα της: `{title}` στις δεξιές σελίδες και `{chapterTitle}` στις αριστερές πάνω από μια γραμμή του 1 pt, σε Open Sans 600 στα 8 pt και μπλε `#295AA3` ([κεφαλίδες και υποσέλιδα](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα)). Αν δείξετε το `main-color` στη σέπια, ξαναχρωματίζονται οι προεπιλογές του κειμένου και μαζί τους εκείνη η κεφαλίδα, αλλά η γραμματοσειρά της, η γραμμή της και η πλευρά όπου τυπώνεται κάθε τίτλος μένουν της μηχανής. Γι' αυτό κάθε κεφαλίδα εδώ γράφεται ολόκληρη, με κάθε χρώμα συνδεδεμένο με μια καταχώριση της παλέτας. Τα έντονα, τα πλάγια και οι παραπομπές έχουν επίσης ως προεπιλογή το `main-color`, και το `bodyText` τα επαναφέρει στο μελάνι.

### 2 · Φτιάξτε κάθε κεφαλίδα από μία γλωττίδα

```js
// script.js, γραμμές 31–48
const FOLIO_PT = 7.5; // pt: the folio, and the book's title in capitals beside it
const TITLE_PT = 8.8; // pt: the essay's title, whose italic lowercase reads small at 7.5
const LINE = FOLIO_PT * 1.2; // pt: the folio and both titles share this line box and baseline
const PAD = { top: 1, bottom: 1.4 }; // pt: 0.4 pt more below for the descending 3, 5, 7, 9
const TAB = 7.5; // mm: the tab's width
const TAB_H = LINE + PAD.top + PAD.bottom; // pt: the tab's height, which the divider matches
const folio = ({ id, parity, pages, anchor, x = 0, y }) => ({
  kind: 'text', id, content: '{pageNumber}', parity, pages, fontFamily: 'Alegreya SC',
  fontSize: pt(FOLIO_PT), fontWeight: 700, lineHeight: LINE / FOLIO_PT, color: col('paper'),
  box: { backgroundColor: col('sepia'), borderRadius: mm(2), // a pill; the number is centred
    padding: { top: pt(PAD.top), bottom: pt(PAD.bottom) } }, // by default in both directions
  placement: { anchor, offset: { x: mm(x), y: mm(y) }, size: { width: mm(TAB) } },
});
const divider = ({ id, parity, from, edge, x }) => ({
  kind: 'rule', id, parity, pages: 'body', direction: 'vertical', thickness: pt(0.5),
  color: col('sepia'), placement: { anchor: { to: `#${from}`, edge }, offset: { x: mm(x) },
    size: { height: pt(TAB_H) } },
});
```

Η σύντομη απάντηση αγκυρώνει τη γλωττίδα κάθε κεφαλίδας στο `'page'`, οπότε οι μετατοπίσεις της μετριούνται από το κομμένο μέγεθος. Από τη γωνία `top-right` ένα θετικό `x` βγαίνει έξω από τη σελίδα, γι' αυτό η γλωττίδα της δεξιάς σελίδας παίρνει αρνητικό. Το διαχωριστικό κρέμεται από τη γλωττίδα και ο τίτλος από το διαχωριστικό ([τοποθέτηση στοιχείων](https://postext.dev/el/docs/configuration-headers-footers.md#τοποθέτηση-στοιχείων)). Τα μεγέθη της γλωττίδας είναι ονομασμένες σταθερές επειδή τα άλλα κομμάτια μετριούνται από αυτά. Το διαχωριστικό έχει ύψος `TAB_H`. Ο αριθμός σελίδας και οι δύο τίτλοι μοιράζονται ένα κουτί γραμμής των 9 pt, και η γραμμή βάσης ενός κειμένου σχεδίασης κάθεται στο 80% του ύψους του κουτιού γραμμής του, έτσι και τα τρία στέκονται σε μία γραμμή βάσης σε οποιοδήποτε μέγεθος στοιχείων.

![Page 30.](https://postext.dev/cookbook/running-heads-by-parity/en/p02.webp?v=1dd3ea0d)

*Σελίδα 30, μια αριστερή: γλωττίδα, διαχωριστικό και ο τίτλος του βιβλίου, διαβασμένα προς τα μέσα από το εξωτερικό περιθώριο.*

![Page 31.](https://postext.dev/cookbook/running-heads-by-parity/en/p03.webp?v=1dd3ea0d)

*Σελίδα 31, μια δεξιά: ο τίτλος του δοκιμίου, κομμένος πριν από το διαχωριστικό και τη γλωττίδα στο εξωτερικό περιθώριο.*

### 3 · Καθρεφτίστε τα περιθώρια και μετρήστε ακέραιες γραμμές

```js
// script.js, γραμμές 52–63
const TRIM = { width: 132, height: 198 }; // mm
const TOP = 22; // mm: the top margin, which holds the heads (gotcha: header-paints-over-text)
const INNER = 15; // mm
const OUTER = 21; // mm: the outer margin, where the folio tabs hang
const LINES = 31; // whole lines of LEAD in the text block, so full pages end level
const MEASURE = TRIM.width - INNER - OUTER; // the text block's width: 96 mm
const geometry = { // left is the inner margin on a recto; mirror swaps it on the versos
  width: mm(TRIM.width), height: mm(TRIM.height), dpi: 150, // 150 dpi is for the screen
  backgroundColor: col('paper'),
  margins: { top: mm(TOP), bottom: mm(TRIM.height - TOP - (LINES * LEAD * 25.4) / 72),
    left: mm(INNER), right: mm(OUTER), mirror: true },
};
```

Με `mirror: true`, το περιθώριο `right` είναι το εξωτερικό σε μια δεξιά σελίδα και μετακινείται αριστερά σε μια αριστερή, οπότε το `OUTER` είναι πάντα το περιθώριο της μπροστινής άκρης, όπου κρέμονται οι γλωττίδες. Το κάτω περιθώριο προκύπτει από το κομμένο μέγεθος, το πάνω περιθώριο και το `LINES`, πράγμα που κρατά την επιφάνεια στοιχειοθεσίας σε ακριβώς `LINES` γραμμές του `LEAD` (31 × 14 pt εδώ) όποιο κομμένο μέγεθος ή πάνω περιθώριο κι αν ορίσετε. Κάθε γεμάτη σελίδα τελειώνει στην 31η γραμμή, έτσι αντικριστές σελίδες όπως οι [30 και 31](https://postext.dev/cookbook/running-heads-by-parity/en/p02.webp?v=1dd3ea0d) τελειώνουν στο ίδιο ύψος.

### 4 · Αφήστε την εναρκτήρια να δείχνει ολόκληρο τον τίτλο

```js
// script.js, γραμμές 99–121
const PLATE = 26; // mm: a square plate at the head of the text block
const opener = {
  enabled: true,
  minHeight: mm(58), // the text of every essay starts on the same line
  slot: { elements: [
    { kind: 'box', id: 'plate', style: { backgroundColor: col('sepia') },
      placement: { anchor: { to: 'container', edge: 'top-left' },
        size: { width: mm(PLATE), height: mm(PLATE) } } },
    { kind: 'text', id: 'numeral', content: '{attr.num}', fontFamily: 'Libre Caslon Display',
      fontSize: pt(48), lineHeight: 1, color: col('paper'),
      placement: { anchor: { to: '#plate', edge: 'align-top' }, // the plate's own box, where
        size: { width: mm(PLATE), height: mm(PLATE) } } }, // the text centres by default
    { kind: 'text', id: 'book', content: '{subtitle}', fontFamily: 'Alegreya SC',
      fontSize: pt(8.5), letterSpacing: pt(1.4), color: col('sepia'), align: 'left',
      placement: { anchor: { to: 'container', edge: 'top-left' },
        offset: { x: mm(PLATE + 4.5), y: mm(PLATE - 2.9) } } }, // its baseline on the plate's foot
    { kind: 'text', id: 'title', content: '{titleText}', fontFamily: 'Libre Caslon Display',
      fontSize: pt(20), lineHeight: 1.12, color: col('ink'), align: 'left',
      overflow: 'wrap', // an opener shows the whole title; the running head cuts it
      placement: { anchor: { to: '#plate', edge: 'below' }, offset: { y: mm(6) },
        size: { width: mm(MEASURE) } } },
  ] },
};
```

Η εναρκτήρια στοιχειοθετεί τον τίτλο ολόκληρο με `overflow: 'wrap'` και τον σπάει σε κάθε `\\` της γραμμής της επικεφαλίδας. Μόνο μια εναρκτήρια σε πλάτος σελίδας σέβεται αυτές τις αλλαγές, οπότε το επίπεδο έχει `span: 'page'` ([αλλαγές γραμμής σε τίτλους](https://postext.dev/el/docs/document-format-directives.md#αλλαγές-γραμμής-σε-τίτλους)). Στην τρέχουσα κεφαλίδα, το `{chapterTitle}` δίνει πάντα τον τίτλο σε μία γραμμή, και τα αποσιωπητικά κόβουν αυτή τη γραμμή. Ο λατινικός αριθμός προέρχεται από την ιδιότητα `{num="IV"}` της επικεφαλίδας και τα μικρά κεφαλαία δίπλα στην πλάκα από το `subtitle` του frontmatter.

### 5 · Ανοίξτε κάθε δοκίμιο σε δεξιά σελίδα

```js
// script.js, γραμμές 139–147
  headings: { // 400, the face's only weight: the default 700 would ask for one that is missing
    fontFamily: 'Libre Caslon Display', fontWeight: 400, color: col('ink'),
    levels: [
      // 'odd' puts every opener on a recto, adding a blank verso when one is needed;
      // span: 'page' makes the design an opener, where a \\ in the title breaks the line.
      { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'odd' },
        marginTop: pt(0), marginBottom: pt(0), advancedDesign: opener },
    ],
  },
```

Με `'odd'`, ένα δοκίμιο που τελειώνει σε δεξιά σελίδα ακολουθείται από μια κενή αριστερή. Η ισπανική έκδοση έχει μία, επειδή το κεφάλαιο IV της τελειώνει στη σελίδα 31· εδώ το κεφάλαιο IV τελειώνει στη σελίδα 32, μια αριστερή, και το κεφάλαιο V ανοίγει στη σελίδα 33. Το `pages: 'body'` των κεφαλίδων τις κρατά έξω από τις κενές σελίδες και τις εναρκτήριες (τις σελίδες των οποίων το πρώτο μπλοκ είναι αυτή η επικεφαλίδα). Το `pages: 'opener'` του υποσέλιδου τυπώνει τον κατεβασμένο αριθμό σελίδας μόνο στις εναρκτήριες ([στοιχεία κειμένου](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-κειμένου)).

### 6 · Αρχίστε τους αριθμούς σελίδας από το 29

```js
// script.js, γραμμές 251–255
// 28 pages come before this one, so recto and verso, the mirrored margins and the odd/even
// heads follow the book page (gotcha: parity-page1-recto); the folios start at 29.
const continuation = { pageIndexOffset: 28, pageNumbering: { startAt: 29 } };
const doc = await buildDocumentWithFonts({ markdown, continuation }, config(), kitFonts(FONTS));
showPages(doc, { title: t({ en: 'Running heads by parity', es: 'Cabeceras según la paridad' }) });
```

Το `parity` ακολουθεί τη θέση της σελίδας στο βιβλίο και αγνοεί τον αριθμό της. Το `pageIndexOffset: 28` προσθέτει 28 στον δείκτη κάθε σελίδας, έτσι η δεξιά και η αριστερή σελίδα, τα καθρεφτισμένα περιθώρια και οι κεφαλίδες μονών και ζυγών σελίδων ακολουθούν τη σελίδα του βιβλίου. Το `pageNumbering.startAt` αριθμεί έπειτα αυτές τις σελίδες από 29 ως 33. Χωρίς τη μετατόπιση η πρώτη σελίδα της κατασκευής είναι δεξιά όποιον αριθμό κι αν τυπώνει. Αυτό τυχαίνει να ταιριάζει στη σελίδα 29, αλλά με `startAt: 30` ο τίτλος του βιβλίου θα έπεφτε στη σελίδα 31 και του δοκιμίου στη σελίδα 32, ο καθένας στη λάθος πλευρά του δισέλιδου.

## Η πλήρης συνταγή

Ένα αρχείο, συντεθειμένο από τον φάκελο της συνταγής με το δείγμα κειμένου και το κοινό κιτ του Συνταγολογίου ενσωματωμένα· φτιάχνει τη δική του σελίδα. Για να το εκτελέσετε, βάλτε το σε ένα `<script type="module">` σε μια κενή σελίδα, ή επικολλήστε το στο πάνελ JS ενός νέου CodePen (ως module). Εισάγει το postext από το esm.sh, οπότε δεν χρειάζεται εγκατάσταση ούτε build.

- Φάκελος πηγής: https://github.com/drnachio/postext/tree/main/cookbook/running-heads-by-parity

### script.js

```js
// ═══ Postext Cookbook · Nº 005 · Running heads by parity ═══════════════════════════════
// https://postext.dev/en/cookbook/running-heads-by-parity
// Code: MIT · Text: Montaigne, tr. Cotton (PD, Gutenberg #3600); es: new translation (MIT)
// Fonts: Baskervville, Libre Caslon Display, Alegreya SC (SIL OFL 1.1) · Needs postext ≥ 1.57.0
// Pages 29 to 33 of a pocket Montaigne. Versos carry the book's title and rectos the essay's,
// the folios sit in tabs in the outer margin, and an opener prints only a folio at the foot.
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'running-heads-by-parity';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: four colours with semantic ids; main-color points at the sepia
const palette = {
  ink: '#1f1b16', // text: a warm near-black, never #000
  sepia: '#8a5a2b', // the one accent: folio tabs, dividers, opener plates (5.3:1 on paper)
  muted: '#6f6558', // running heads, verse glosses, the colophon (5.2:1 on paper)
  paper: '#f8f4ec', // a warm off-white page; also the type reversed out of the sepia
};
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' } })),
  // Text-style defaults (headings, bold, italic, lists, boxes) link to 'main-color':
  // pointed at the sepia, none of them prints in the engine's blue.
  { id: 'main-color', name: 'sepia (defaults)', value: { hex: palette.sepia, model: 'hex' } },
];
// #endregion
const LEAD = 14; // pt: the body leading, the pitch of the baseline grid

// #region tab: the folio tab and its divider, the two pieces every head is built from
const FOLIO_PT = 7.5; // pt: the folio, and the book's title in capitals beside it
const TITLE_PT = 8.8; // pt: the essay's title, whose italic lowercase reads small at 7.5
const LINE = FOLIO_PT * 1.2; // pt: the folio and both titles share this line box and baseline
const PAD = { top: 1, bottom: 1.4 }; // pt: 0.4 pt more below for the descending 3, 5, 7, 9
const TAB = 7.5; // mm: the tab's width
const TAB_H = LINE + PAD.top + PAD.bottom; // pt: the tab's height, which the divider matches
const folio = ({ id, parity, pages, anchor, x = 0, y }) => ({
  kind: 'text', id, content: '{pageNumber}', parity, pages, fontFamily: 'Alegreya SC',
  fontSize: pt(FOLIO_PT), fontWeight: 700, lineHeight: LINE / FOLIO_PT, color: col('paper'),
  box: { backgroundColor: col('sepia'), borderRadius: mm(2), // a pill; the number is centred
    padding: { top: pt(PAD.top), bottom: pt(PAD.bottom) } }, // by default in both directions
  placement: { anchor, offset: { x: mm(x), y: mm(y) }, size: { width: mm(TAB) } },
});
const divider = ({ id, parity, from, edge, x }) => ({
  kind: 'rule', id, parity, pages: 'body', direction: 'vertical', thickness: pt(0.5),
  color: col('sepia'), placement: { anchor: { to: `#${from}`, edge }, offset: { x: mm(x) },
    size: { height: pt(TAB_H) } },
});
// #endregion

// #region page: a pocket trim; the margins mirror, the text block holds 31 whole lines
const TRIM = { width: 132, height: 198 }; // mm
const TOP = 22; // mm: the top margin, which holds the heads (gotcha: header-paints-over-text)
const INNER = 15; // mm
const OUTER = 21; // mm: the outer margin, where the folio tabs hang
const LINES = 31; // whole lines of LEAD in the text block, so full pages end level
const MEASURE = TRIM.width - INNER - OUTER; // the text block's width: 96 mm
const geometry = { // left is the inner margin on a recto; mirror swaps it on the versos
  width: mm(TRIM.width), height: mm(TRIM.height), dpi: 150, // 150 dpi is for the screen
  backgroundColor: col('paper'),
  margins: { top: mm(TOP), bottom: mm(TRIM.height - TOP - (LINES * LEAD * 25.4) / 72),
    left: mm(INNER), right: mm(OUTER), mirror: true },
};
// #endregion

// #region answer: running heads by parity: book on the verso, essay on the recto, folios outside
const GAP = 3; // mm from the tab to the divider, which lands on the text block's edge
const HEAD = 12; // mm from the top edge of the page to the top of the tab
const CAP = t({ en: 60.5, es: 66.8 }); // mm: the head's widest line, set per edition so
// essay IV's is cut after 'false' and 'objetos'; a short running title suits any title
const page = (edge) => ({ to: 'page', edge }); // the trim box (gotcha: negative-offsets)
const header = { elements: [
  // Verso (even): tab | divider | THE BOOK'S TITLE from the frontmatter
  folio({ id: 'folio-even', parity: 'even', pages: 'body', anchor: page('top-left'),
    x: OUTER - GAP - TAB, y: HEAD }),
  divider({ id: 'rule-even', parity: 'even', from: 'folio-even', edge: 'right-of', x: GAP }),
  { kind: 'text', id: 'book', content: '{title}', parity: 'even', pages: 'body',
    fontFamily: 'Alegreya SC', fontSize: pt(FOLIO_PT), lineHeight: LINE / FOLIO_PT,
    color: col('muted'), textTransform: 'uppercase', letterSpacing: pt(1.3),
    placement: { anchor: { to: '#rule-even', edge: 'right-of' }, // top: the tab's top
      offset: { x: mm(2.5), y: pt(PAD.top) } } }, // PAD.top down: on the folio's baseline
  // Recto (odd): the essay's title, cut short with an ellipsis | divider | tab.
  folio({ id: 'folio-odd', parity: 'odd', pages: 'body', anchor: page('top-right'),
    x: -(OUTER - GAP - TAB), y: HEAD }), // from the right edge, a negative x runs inwards
  divider({ id: 'rule-odd', parity: 'odd', from: 'folio-odd', edge: 'left-of', x: -GAP }),
  { kind: 'text', id: 'essay', content: '{chapterTitle}', parity: 'odd', pages: 'body',
    fontFamily: 'Baskervville', italic: true, fontSize: pt(TITLE_PT),
    lineHeight: LINE / TITLE_PT, color: col('muted'),
    overflow: 'ellipsis-end', // stated, though a running head's default
    placement: { anchor: { to: '#rule-odd', edge: 'left-of' },
      offset: { x: mm(-2.5), y: pt(PAD.top) }, size: { maxWidth: mm(CAP) } } },
] };
// Openers: no head, only a drop folio HEAD above the page's foot, centred under the text block.
const footer = { elements: [folio({ id: 'drop-folio', parity: 'all', pages: 'opener',
  anchor: { to: 'container', edge: 'bottom' }, y: -HEAD })] };
// #endregion

// #region opener: the essay's numeral on a sepia plate; the title below it, set in full
const PLATE = 26; // mm: a square plate at the head of the text block
const opener = {
  enabled: true,
  minHeight: mm(58), // the text of every essay starts on the same line
  slot: { elements: [
    { kind: 'box', id: 'plate', style: { backgroundColor: col('sepia') },
      placement: { anchor: { to: 'container', edge: 'top-left' },
        size: { width: mm(PLATE), height: mm(PLATE) } } },
    { kind: 'text', id: 'numeral', content: '{attr.num}', fontFamily: 'Libre Caslon Display',
      fontSize: pt(48), lineHeight: 1, color: col('paper'),
      placement: { anchor: { to: '#plate', edge: 'align-top' }, // the plate's own box, where
        size: { width: mm(PLATE), height: mm(PLATE) } } }, // the text centres by default
    { kind: 'text', id: 'book', content: '{subtitle}', fontFamily: 'Alegreya SC',
      fontSize: pt(8.5), letterSpacing: pt(1.4), color: col('sepia'), align: 'left',
      placement: { anchor: { to: 'container', edge: 'top-left' },
        offset: { x: mm(PLATE + 4.5), y: mm(PLATE - 2.9) } } }, // its baseline on the plate's foot
    { kind: 'text', id: 'title', content: '{titleText}', fontFamily: 'Libre Caslon Display',
      fontSize: pt(20), lineHeight: 1.12, color: col('ink'), align: 'left',
      overflow: 'wrap', // an opener shows the whole title; the running head cuts it
      placement: { anchor: { to: '#plate', edge: 'below' }, offset: { y: mm(6) },
        size: { width: mm(MEASURE) } } },
  ] },
};
// #endregion

const config = () => ({
  locale: t({ en: 'en-us', es: 'es' }), // the language of the hyphenation patterns
  colorPalette,
  page: geometry,
  layout: { layoutType: 'single' },
  bodyText: { // bold, italic and references default to main-color (the sepia): set to the ink
    fontFamily: 'Baskervville', fontSize: pt(10.2), lineHeight: pt(LEAD), color: col('ink'),
    boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
    textAlign: 'justify', firstLineIndent: mm(4), indentAfterHeading: false,
    // Hyphenation, optimal breaking and widow, orphan and runt control are on by default; a band
    // of 0.7–1.65 (default 0.6–2) evens the grey from line to line. At the default runt length,
    // 20 space widths, English essay IV ends on 'minds.' alone; at 16 it ends on 'our minds.'.
    minWordSpacing: 0.7, maxWordSpacing: 1.65, runtMinCharacters: 16,
  },
  // #region levels: every essay opens on a recto; the heading draws the opener
  headings: { // 400, the face's only weight: the default 700 would ask for one that is missing
    fontFamily: 'Libre Caslon Display', fontWeight: 400, color: col('ink'),
    levels: [
      // 'odd' puts every opener on a recto, adding a blank verso when one is needed;
      // span: 'page' makes the design an opener, where a \\ in the title breaks the line.
      { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'odd' },
        marginTop: pt(0), marginBottom: pt(0), advancedDesign: opener },
    ],
  },
  // #endregion
  // Montaigne's quotations: a box with no fill keeps verse and gloss together. Its two 10.5 pt
  // margins and a two-line gloss (2 × 10.5 pt) make three whole lines, so the grid adds no space.
  calloutStyles: [{ id: 'quote', backgroundEnabled: false,
    padding: { top: pt(0), right: mm(8), bottom: pt(0), left: mm(8) },
    marginTop: pt(LEAD * 0.75), marginBottom: pt(LEAD * 0.75) }],
  paragraphStyles: [
    { id: 'verse', fontSize: pt(9.6), textAlign: 'center', firstLineIndent: pt(0) },
    { id: 'gloss', fontSize: pt(7.6), lineHeight: pt(LEAD * 0.75), color: col('muted'),
      textAlign: 'center', firstLineIndent: pt(0) },
    // Markdown has no horizontal rule (--- prints as text; gap: markdown-extras), so the rule
    // over the colophon is eight em dashes of Alegreya SC that overlap into a 0.5 pt line.
    { id: 'end', fontFamily: 'Alegreya SC', fontSize: pt(8), color: col('sepia'),
      textAlign: 'left', firstLineIndent: pt(0), marginTop: pt(LEAD) },
    { id: 'colophon', fontSize: pt(7), lineHeight: pt(9.5), color: col('muted'),
      textAlign: 'left', firstLineIndent: pt(0) },
  ],
  header,
  footer,
});

// ─── 2 · Content ────────────────────────────────────────────────────────────
const markdown = String.raw`---
title: "The Essays of Montaigne"
subtitle: "Book the First"
author: "Michel de Montaigne"
---

# That the soul expends its passions \\ upon false objects, \\ where the true are wanting {num="IV"}

A gentleman of my country, marvellously tormented with the gout, being importuned by his physicians totally to abstain from all manner of salt meats, was wont pleasantly to reply, that in the extremity of his fits he must needs have something to quarrel with, and that railing at and cursing, one while the Bologna sausages, and another the dried tongues and the hams, was some mitigation to his pain. But, in good earnest, as the arm when it is advanced to strike, if it miss the blow, and goes by the wind, it pains us; and as also, that, to make a pleasant prospect, the sight should not be lost and dilated in vague air, but have some bound and object to limit and circumscribe it at a reasonable distance.

:::callout{type="quote"}
:::paragraphs{style="verse"}
*Ventus ut amittit vires, nisi robore densae*

*Occurrant sylvae, spatio diffusus inani.*
:::

:::paragraphs{style="gloss"}
As the wind loses its force diffused in void space, unless it in its strength encounters the thick wood. — Lucan, III, 362
:::
:::

So it seems that the soul, being transported and discomposed, turns its violence upon itself, if not supplied with something to oppose it, and therefore always requires an object at which to aim, and whereon to act. Plutarch says of those who are delighted with little dogs and monkeys, that the amorous part that is in us, for want of a legitimate object, rather than lie idle, does after that manner forge and create one false and frivolous. And we see that the soul, in its passions, inclines rather to deceive itself, by creating a false and fantastical subject, even contrary to its own belief, than not to have something to work upon. After this manner brute beasts direct their fury to fall upon the stone or weapon that has hurt them, and with their teeth even execute revenge upon themselves for the injury they have received from another:

:::callout{type="quote"}
:::paragraphs{style="verse"}
*Pannonis haud aliter, post ictum saevior ursa,*

*Cui jaculum parva Lybis amentavit habena,*

*Se rotat in vulnus, telumque irata receptum*

*Impetit, et secum fugientem circuit hastam.*
:::

:::paragraphs{style="gloss"}
So the she-bear, fiercer for the Libyan’s dart, turns upon the wound and, attacking the spear, twists it as she flies. — Lucan, VI, 220
:::
:::

What causes of the misadventures that befall us do we not invent? what is it that we do not lay the fault to, right or wrong, that we may have something to quarrel with? It is not those beautiful tresses you tear, nor is it the white bosom that in your anger you so unmercifully beat, that with an unlucky bullet have slain your beloved brother; quarrel with something else. Livy, speaking of the Roman army in Spain, says that for the loss of the two brothers, their great captains, *flere omnes repente, et offensare capita*, “all at once wept and tore their hair.”

’Tis a common practice. And the philosopher Bion said pleasantly of the king, who by handfuls pulled his hair off his head for sorrow, “Does this man think that baldness is a remedy for grief?” Who has not seen peevish gamesters chew and swallow the cards, and swallow the dice, in revenge for the loss of their money? Xerxes whipped the sea, and wrote a challenge to Mount Athos; Cyrus employed a whole army several days at work, to revenge himself of the river Gyndas, for the fright it had put him into in passing over it; and Caligula demolished a very beautiful palace for the pleasure his mother had once enjoyed there.

I remember there was a story current, when I was a boy, that one of our neighbouring kings, having received a blow from the hand of God, swore he would be revenged, and in order to it, made proclamation that for ten years to come no one should pray to Him, or so much as mention Him throughout his dominions, or, so far as his authority went, believe in Him; by which they meant to paint not so much the folly as the vainglory of the nation of which this tale was told. They are vices that always go together, but in truth such actions as these have in them still more of presumption than want of wit. Augustus Caesar, having been tossed with a tempest at sea, fell to defying Neptune, and in the pomp of the Circensian games, to be revenged, deposed his statue from the place it had amongst the other deities. Wherein he was still less excusable than the former, and less than he was afterwards when, having lost a battle under Quintilius Varus in Germany, in rage and despair he went running his head against the wall, crying out, “O Varus! give me back my legions!” for these exceed all folly, forasmuch as impiety is joined therewith, invading God Himself, or at least Fortune, as if she had ears that were subject to our batteries; like the Thracians, who when it thunders or lightens, fall to shooting against heaven with Titanian vengeance, as if by flights of arrows they intended to bring God to reason. Though the ancient poet in Plutarch tells us:

:::callout{type="quote"}
:::paragraphs{style="verse"}
*Point ne se faut couroucer aux affaires,*

*Il ne leur chault de toutes nos choleres.*
:::

:::paragraphs{style="gloss"}
We must not trouble the gods with our affairs; they take no heed of our angers and disputes. — Plutarch
:::
:::

But we can never enough decry the disorderly sallies of our minds.

# Whether the governor of a place \\ besieged ought himself \\ to go out to parley {num="V"}

Quintus Marcius, the Roman legate in the war against Perseus, King of Macedon, to gain time wherein to reinforce his army, set on foot some overtures of accommodation, with which the king being lulled asleep, concluded a truce for some days, by this means giving his enemy opportunity and leisure to recruit his forces, which was afterwards the occasion of the king’s final ruin. Yet the elder senators, mindful of their forefathers’ manners, condemned this proceeding as degenerating from their ancient practice, which, they said, was to fight by valour, and not by artifice, surprises, and night-encounters; neither by pretended flight nor unexpected rallies to overcome their enemies; never making war till having first proclaimed it, and very often assigned both the hour and place of battle.

:::paragraphs{style="end"}
————————
:::

:::paragraphs{style="colophon"}
Chapters IV and V of Book the First of Montaigne’s essays, in Charles Cotton’s translation as revised by W. C. Hazlitt (1877), Project Gutenberg eBook #3600; notes shortened or omitted, misprints corrected. Set in Baskervville, Libre Caslon Display and Alegreya SC (SIL Open Font License).
:::
`; // content.<lang>.md, inlined by the Cookbook

// ─── 3 · Fonts ──────────────────────────────────────────────────────────────
// Every face the design uses, loaded before the first build.
const FONTS = { // text, display and label faces (Libre Caslon Display has no italic)
  Baskervville: ['400', '400i'], 'Libre Caslon Display': ['400'], 'Alegreya SC': ['400', '700'],
};

// ─── 4 · Build & show ───────────────────────────────────────────────────────
// #region build: pages 29 to 33 of the book
// 28 pages come before this one, so recto and verso, the mirrored margins and the odd/even
// heads follow the book page (gotcha: parity-page1-recto); the folios start at 29.
const continuation = { pageIndexOffset: 28, pageNumbering: { startAt: 29 } };
const doc = await buildDocumentWithFonts({ markdown, continuation }, config(), kitFonts(FONTS));
showPages(doc, { title: t({ en: 'Running heads by parity', es: 'Cabeceras según la paridad' }) });
// #endregion

// ─── Kit ── helpers shared by every Cookbook recipe · postext.dev/cookbook ─────

// ─── Kit · core v1 ── the same in every recipe · postext.dev/cookbook
function mm(value) { return { value, unit: 'mm' }; }
function pt(value) { return { value, unit: 'pt' }; }
function em(value) { return { value, unit: 'em' }; }
/** The sample language's string: t({ en: 'Figure', es: 'Figura' }). */
function t(strings) { return strings[LANG] ?? Object.values(strings)[0]; }
/** A file in this recipe's assets folder, served from the Postext repo by jsDelivr. */
function asset(file) { return `https://cdn.jsdelivr.net/gh/drnachio/postext@main/cookbook/${RECIPE}/assets/${file}`; }

// ─── Kit · fonts v3 ── the same in every recipe · postext.dev/cookbook
// Postext loads the faces a config asks for before layout and asks the kit
// for Fontsource's files, the ones the PDF embeds too.

/** buildDocumentWithFonts' options: the resolver, and FONTS' faces loaded
 *  with the config's. FONTS = { 'Family Name': ['400', '400i', '700'] }. */
function kitFonts(FONTS = {}) {
  const faces = Object.entries(FONTS).flatMap(([family, specs]) => specs.map((spec) =>
    ({ family, weight: parseInt(spec, 10), style: spec.endsWith('i') ? 'italic' : 'normal' })));
  return { resolve: fontsourceResolver, faces };
}

/** A face's files with their ranges: latin, then latin-ext and greek when
 *  `text` needs them (kitSubsetsFor). Null for a face Fontsource lacks. */
async function fontsourceResolver(family, weight, style, { text = '' } = {}) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  if (meta && !(await fontsourceWeights(family, style)).includes(weight)) return null;
  kitStatus('Loading fonts…');
  const at = await fontsourceAt(id);
  return ['latin', ...kitSubsetsFor(text, meta)].map((subset) => ({
    source: `${at}files/${id}-${subset}-${weight}-${style}.woff2`,
    unicodeRange: kitRanges()[subset],
  }));
}

/** Each file's unicode-range (a function: the kit runs after the pen's code). */
function kitRanges() {
  return {
    latin: 'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,'
      + 'U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD',
    'latin-ext': 'U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,'
      + 'U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF',
    greek: 'U+0370-03FF',
  };
}

/** For the cjk, arabic and comics blocks: loads `faces` (as FONTS) for the
 *  sample `text`; `optional` skips a face Fontsource lacks. Files are added in
 *  the order asked, the last winning a shared character. Resolves to the count. */
async function loadFonts(faces, text = '', { optional = false } = {}) {
  kitStatus('Loading fonts…');
  const ranges = kitRanges();
  const jobs = [];
  for (const [family, specs] of Object.entries(faces)) {
    const id = fontsourceId(family);
    const todo = [...new Set(specs)].map((spec) => [parseInt(spec, 10), spec.endsWith('i') ? 'italic' : 'normal'])
      .filter(([weight, style]) => !hasFace(family, weight, style)); // before any await
    const at = fontsourceAt(id);
    const meta = optional || /[^\0-ÿ]/u.test(text) ? await fontsourceMeta(family) : null;
    const subsets = ['latin', ...kitSubsetsFor(text, meta)];
    for (const [weight, style] of todo) {
      if (optional && !(meta && (await fontsourceWeights(family, style)).includes(weight))) continue;
      for (const subset of subsets) {
        const url = `${await at}files/${id}-${subset}-${weight}-${style}.woff2`;
        const face = new FontFace(family, `url(${url}) format('woff2')`,
          { weight: String(weight), style, unicodeRange: ranges[subset] });
        jobs.push(face.load().catch(() => {
          if (subset === 'latin' && !optional) throw new Error(`Fontsource has no ${family} ${weight} ${style}`);
        }));
      }
    }
  }
  const ready = await Promise.all(jobs).catch((error) => { kitFail(error); throw error; });
  return ready.filter((face) => face && document.fonts.add(face)).length;
}

/** A loaded FontFace covers this face (fonts.check() says yes to any family). */
function hasFace(family, weight, style) {
  for (const face of document.fonts) {
    if (face.status !== 'loaded' || face.style !== style) continue;
    if (face.family.replace(/^["']|["']$/g, '') !== family) continue;
    const [low, high = low] = face.weight.split(' ').map(Number);
    if (weight >= low && weight <= high) return true;
  }
  return false;
}

/** The files beyond latin `text` needs that `meta`'s family ships. */
function kitSubsetsFor(text, meta) {
  return [[/[Ā-˿ᴀ-ᶿḀ-ỿ†ℓⱠ-Ɀ꜠-ꟿ]/u, 'latin-ext'], [/[Ͱ-Ͽ]/u, 'greek']]
    .filter(([re, x]) => re.test(text) && meta?.subsets?.includes(x)).map(([, x]) => x);
}

/** Fontsource's id for a family: 'Source Serif 4' → 'source-serif-4'. */
function fontsourceId(family) { return family.toLowerCase().replace(/\s+/g, '-'); }

/** A package's folder at the one version @5 names now (#766). */
function fontsourceAt(id, u = `https://cdn.jsdelivr.net/npm/@fontsource/${id}@`) {
  return (fontsourceAt.c ??= {})[id] ??= fetch(u + '5/package.json').then((r) => r.json())
    .then((p) => p.version || 5, () => 5).then((v) => `${u}${v}/`);
}

/** The family's Fontsource metadata (weights, styles, subsets), or null. */
function fontsourceMeta(family, id = fontsourceId(family)) {
  return (fontsourceMeta.c ??= {})[id] ??= fetch(`https://api.fontsource.org/v1/fonts/${id}`)
    .then((res) => (res.ok ? res.json() : null), () => null);
}

/** The weights the package ships in `style`: the API pairs none (no Libre
 *  Caslon 700 italic file), so italics are read from latin-italic.css. */
function fontsourceWeights(family, style, id = fontsourceId(family)) {
  return (fontsourceWeights.c ??= {})[id + style] ??= fontsourceMeta(family).then(async (m) => {
    if (!m?.styles.includes(style)) return m ? [] : [400, 700];
    const css = style === 'italic' ? await fetch(`${await fontsourceAt(id)}latin-italic.css`).then((r) => (r.ok ? r.text() : ''), () => '') : '';
    const w = [...css.matchAll(/weight: (\d+)/g)].map((x) => +x[1]);
    return w.length ? w : m.weights;
  });
}

// ─── Kit · viewer v2 ── the same in every recipe · postext.dev/cookbook
/** The pages as spreads on a dark desk, page 1 alone, then verso | recto,
 *  each painted when it scrolls near. Other options go to renderPageToCanvas. */
function showPages(docs, { title, width = 460, ...render } = {}) {
  const root = viewer(title);
  const pages = [docs].flat().flatMap((doc) =>
    doc.pages.map((page) => ({ doc, page, n: (doc.pageIndexOffset ?? 0) + page.index })));
  const spreads = [];
  let verso = null;
  for (const p of pages) {
    if (p.n % 2 === 1) { if (verso) spreads.push([verso, null]); verso = p; }
    else { spreads.push([verso, p]); verso = null; }
  }
  if (verso) spreads.push([verso, null]);
  const density = Math.min(window.devicePixelRatio || 1, 2);
  showPages.painter?.disconnect();
  const painter = new IntersectionObserver((entries) => {
    for (const { isIntersecting, target } of entries) {
      if (!isIntersecting) continue;
      painter.unobserve(target);
      const { doc, page } = target.postext;
      renderPageToCanvas(page, doc, target, { ...render, scale: (width * density) / page.width });
    }
  }, { rootMargin: '800px' });
  showPages.painter = painter;
  root.replaceChildren(...spreads.map((pair) => {
    const spread = document.createElement('div');
    spread.className = 'pt-spread';
    for (const p of pair) {
      const figure = document.createElement('figure');
      if (p) {
        const label = p.page.pageLabel || String(p.n + 1);
        const canvas = document.createElement('canvas');
        canvas.postext = p;
        canvas.style.aspectRatio = `${p.page.width} / ${p.page.height}`;
        canvas.setAttribute('role', 'img');
        canvas.setAttribute('aria-label', `Page ${label}`);
        const folio = document.createElement('figcaption');
        folio.textContent = label;
        figure.append(canvas, folio);
        painter.observe(canvas);
      } else figure.className = 'pt-blank';
      spread.append(figure);
    }
    return spread;
  }));
  kitStatus(`${pages.length} ${pages.length === 1 ? 'page' : 'pages'}`);
  document.documentElement.dataset.postext = 'ready';
  return pages.length;
}

/** The desk, the bar and the error reporting, created once. */
function viewer(title) {
  if (!document.getElementById('pt-kit')) {
    document.head.insertAdjacentHTML('beforeend', `<style id="pt-kit">
      :root { color-scheme: dark; }
      body { margin: 0; background: #0e1014; color: #b9bcc4; font: 13px/1.45 system-ui, sans-serif; }
      #pt-bar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center;
        gap: 6px 16px; padding: 10px 16px; background: rgb(14 16 20 / .92); backdrop-filter: blur(6px);
        border-bottom: 1px solid #23262d; }
      #pt-bar strong { color: #f4f1ea; font-weight: 600; }
      #pt-actions { display: flex; gap: 12px; margin-left: auto; }
      #pt-actions a, #pt-actions button { color: #d8a21a; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
      #pages { display: grid; justify-items: center; gap: 48px; padding: 32px 16px 72px; }
      .pt-spread { display: flex; }
      .pt-spread figure { margin: 0; width: min(460px, 44vw); }
      .pt-spread canvas { display: block; width: 100%; background: #fff;
        box-shadow: 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figure:first-child canvas { box-shadow: inset -14px 0 14px -14px rgb(0 0 0 / .18), 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figcaption { margin-top: 10px; text-align: center; font: 600 10px/1 system-ui, sans-serif;
        letter-spacing: .18em; text-transform: uppercase; color: #6c7079; }
      .pt-blank { visibility: hidden; }
      @media (max-width: 760px) {
        .pt-spread { flex-direction: column; gap: 32px; }
        .pt-spread figure { width: min(460px, 92vw); }
        .pt-blank { display: none; }
      }
    </style>`);
    document.body.insertAdjacentHTML('afterbegin',
      '<header id="pt-bar"><strong id="pt-title"></strong><span id="pt-status" role="status"></span><span id="pt-actions"></span></header>');
    document.getElementById('pt-title').textContent = document.title || 'Postext';
    addEventListener('error', (event) => kitFail(event.error ?? event.message));
    addEventListener('unhandledrejection', (event) => kitFail(event.reason));
  }
  if (title) document.getElementById('pt-title').textContent = title;
  return document.getElementById('pages')
    ?? document.body.appendChild(Object.assign(document.createElement('main'), { id: 'pages' }));
}

function kitStatus(text) {
  viewer();
  document.getElementById('pt-status').textContent = text;
}

function kitFail(error) {
  document.documentElement.dataset.postext = 'error';
  kitStatus(`Error: ${error?.message ?? error}`);
}

// ─── /Kit ───────────────────────────────────────────────────────────────────────
```

## Παραλλαγές

### Δώστε στους μακριούς τίτλους έναν σύντομο τρέχοντα τίτλο

Γράψτε τον τρέχοντα τίτλο στη γραμμή της επικεφαλίδας, `{num="IV" short="Of false objects"}`, και τυπώστε την ιδιότητα αντί για ολόκληρο τον τίτλο· ένα κεφάλαιο χωρίς `short` δεν τυπώνει τίποτα εκεί.

```diff
-  { kind: 'text', id: 'essay', content: '{chapterTitle}', parity: 'odd', pages: 'body',
+  { kind: 'text', id: 'essay', content: '{attr.short}', parity: 'odd', pages: 'body',
```

### Αφήστε τα δοκίμια να ανοίγουν σε οποιαδήποτε πλευρά

Με `'any'` ένα δοκίμιο αρχίζει στην επόμενη σελίδα, δεξιά ή αριστερή, και δεν προστίθεται ποτέ κενή σελίδα. Η πλάκα κρέμεται από την πάνω αριστερή γωνία της επιφάνειας στοιχειοθεσίας και ο κατεβασμένος αριθμός σελίδας κεντράρεται κάτω της, έτσι και τα δύο κάθονται με τον ίδιο τρόπο σε μια αριστερή όπως σε μια δεξιά σελίδα.

```diff
-      { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'odd' },
+      { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'any' },
```

### Βάψτε την κενή αριστερή σελίδα στο χρώμα έμφασης

Ένα πλαίσιο με `pages: 'blank'` τυπώνεται μόνο στις σελίδες που προσθέτει η αλλαγή σε δεξιά σελίδα: στην ισπανική έκδοση γεμίζει τη σελίδα 32 με σέπια, και η αγγλική έκδοση, που δεν έχει κενή σελίδα, μένει ίδια.

```diff
 const footer = { elements: [folio({ id: 'drop-folio', parity: 'all', pages: 'opener',
-  anchor: { to: 'container', edge: 'bottom' }, y: -HEAD })] };
+  anchor: { to: 'container', edge: 'bottom' }, y: -HEAD }),
+  { kind: 'box', id: 'blank-leaf', pages: 'blank', style: { backgroundColor: col('sepia') },
+    placement: { anchor: page('top-left'),
+      size: { width: mm(TRIM.width), height: mm(TRIM.height) } } }] };
```

## Συνήθη λάθη

- **Οι αρνητικές μετατοπίσεις ως προς τον περιέκτη δεν αποδίδουν τίποτα.** Το κείμενο σχεδίασης με αυτόματο πλάτος περιορίζεται στον περιέκτη του, οπότε μια αρνητική μετατόπιση από τον περιέκτη το σπρώχνει έξω και δεν αποδίδεται τίποτα. Αγκυρώστε τέτοια στοιχεία στη σελίδα ή στο bleed με ρητές μετατοπίσεις σε mm, ή δώστε τους σταθερό πλάτος.
- **Τα στοιχεία κεφαλίδας και υποσέλιδου ζωγραφίζονται πάνω από το κείμενο.** Τα στοιχεία κεφαλίδας και υποσέλιδου ζωγραφίζονται πάνω στη σελίδα και η επιφάνεια στοιχειοθεσίας δεν τους αφήνει χώρο. Κρατήστε τα μέσα στα περιθώρια, που είναι αυτά που δεσμεύουν τον χώρο τους.
- **Η σελίδα 1 είναι δεξιά: σχεδιάστε τις σελίδες με φυσικούς αριθμούς.** Η σελίδα 1 είναι δεξιά (μονή) σελίδα και η σελίδα 2 η πρώτη αριστερή (ζυγή), οπότε σχεδιάστε τα δισέλιδα με φυσικούς αριθμούς σελίδων: μια εναρκτήρια σελίδα σε ζυγή σελίδα βλέπει τη μονή σελίδα που ακολουθεί.
- **Προειδοποίηση σελιδοποίησης: Κείμενο σχεδίασης που κόπηκε** (`designTextTruncated`). Ένα στοιχείο κειμένου μιας σχεδίασης (τρέχουσα κεφαλίδα, αριθμός σελίδας, εναρκτήρια σελίδα κεφαλαίου, σελίδα μέρους, γραμμή μέρους στα περιεχόμενα) ήταν πλατύτερο από τον χώρο του και έχασε μέρος μιας γραμμής: κόπηκε με αποσιωπητικά, όπως ζητά το overflow του, ή περικόπηκε με μελάνι πέρα από το κουτί του με overflow: 'clip'. Οι τρέχουσες κεφαλίδες, οι αριθμοί σελίδας και οι γραμμές μερών στα περιεχόμενα τελειώνουν με αποσιωπητικά από προεπιλογή· οι σχεδιάσεις επικεφαλίδων και μερών αναδιπλώνονται εκτός αν το στοιχείο ορίζει κάτι άλλο. Μια τρέχουσα κεφαλίδα κομμένη σε κάθε σελίδα ενός κεφαλαίου αναφέρεται μία φορά. Διόρθωση: Ορίστε overflow: 'wrap' στο στοιχείο για να σπάσει το κείμενο σε περισσότερες γραμμές, δώστε του περισσότερο χώρο (πλατύτερο size.width ή maxWidth, μικρότερο fontSize, πιο σφιχτό letterSpacing) ή συντομεύστε το κείμενο. Κρατήστε τα αποσιωπητικά όπου η σχεδίαση είναι μία γραμμή, όπως σε μια τρέχουσα κεφαλίδα· τότε η προειδοποίηση απλώς επιβεβαιώνει τι κόπηκε. ([Τεκμηρίωση](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-κειμένου))
- **Προειδοποίηση σελιδοποίησης: Άγνωστο σύμβολο κράτησης θέσης** (`headerFooterUnknownPlaceholder`). Ένα κείμενο σχεδίασης χρησιμοποιεί ένα σύμβολο κράτησης θέσης {name} που δεν υπάρχει, γι' αυτό τυπώνεται κατά λέξη. Διόρθωση: Χρησιμοποιήστε ένα υποστηριζόμενο σύμβολο κράτησης θέσης ({pageNumber}, {chapterTitle}, {title}, {attr.x}…) ή γράψτε {{ και }} για κυριολεκτικά άγκιστρα. ([Τεκμηρίωση](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-κειμένου))
- **Προειδοποίηση σελιδοποίησης: Λείπουν μεταδεδομένα συμβόλου κράτησης θέσης** (`headerFooterMetadataMissing`). Ένα σύμβολο κράτησης θέσης όπως {author} ή {title} δεν έχει τιμή στα μεταδεδομένα του εγγράφου, γι' αυτό τυπώνεται κενό. Διόρθωση: Προσθέστε την τιμή στο frontmatter, μέσα σε εισαγωγικά, ή αφαιρέστε το σύμβολο κράτησης θέσης. ([Τεκμηρίωση](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-κειμένου))

- Το `CAP` ορίζεται σε κάθε έκδοση για τον τίτλο του δοκιμίου IV, τον μόνο που δείχνει εδώ μια τρέχουσα κεφαλίδα. Τα αποσιωπητικά ακολουθούν την τελευταία ολόκληρη λέξη που χωρά, και αυτή η λέξη μπορεί να είναι πρόθεση: στα 64 mm η ισπανική κεφαλίδα θα τελείωνε σε «…sus pasiones sobre…». Ένα βιβλίο με μακριούς τίτλους χρειάζεται τον σύντομο τρέχοντα τίτλο από τις Παραλλαγές.
- Στην αγγλική έκδοση, αν ανεβάσετε το `minWordSpacing` από 0,7 σε 0,75, η πρώτη γραμμή του δοκιμίου V («Quintus Marcius, the Roman legate…») μένει χωρίς σημείο αλλαγής μέσα στη ζώνη, και τα διαστήματα λέξεων της τεντώνονται στο 2,4 του κανονικού τους πλάτους. Η ισπανική έκδοση δεν έχει τέτοια γραμμή. Μετά από κάθε αλλαγή, ελέγξτε τις πιο αραιές γραμμές που απαριθμεί η λήψη.

## Ευχαριστίες

- Συνταγή: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Κείμενο: Essays, Book I, chapters IV and V, in Charles Cotton’s translation edited by William Carew Hazlitt (1877): Michel de Montaigne; Charles Cotton; William Carew Hazlitt ([πηγή](https://www.gutenberg.org/ebooks/3600)), κοινό κτήμα
- Κείμενο: Essais, livre I, chapitres IV et V: the 1595 French text in the Général Michaud edition (Firmin-Didot, 1907): Michel de Montaigne ([πηγή](https://www.gutenberg.org/ebooks/48529)), κοινό κτήμα
- Κείμενο: Spanish translation, with its verse glosses: Postext Cookbook, πρωτότυπο
- Γραμματοσειρές: Baskervville (OFL-1.1), Libre Caslon Display (OFL-1.1), Alegreya SC (OFL-1.1)
- Κώδικας: MIT · Δείγμα περιεχομένου: MIT

## Σχετικές συνταγές

- [Αρ. 047 · Οδηγός περιπάτων με δείκτες αντίχειρα](https://postext.dev/el/cookbook/walking-guide-thumb-tabs.md): Οδηγός τσέπης με ένα στιλ επικεφαλίδας ανά περίπατο: η παλέτα του βάφει τον δείκτη στο άκρο, τους αριθμούς στάσεων, το πλαίσιο και την κενή αριστερή πριν. · Επίπεδο 3 (Προχωρημένο) · Εγχειρίδια, οδηγοί και έργα αναφοράς
- [Αρ. 007 · Ένα βιβλίο από χωριστά κεφάλαια](https://postext.dev/el/cookbook/book-from-chapters.md): Η buildBundle στήνει πέντε αρχεία Markdown ως ένα βιβλίο: κάθε κεφάλαιο ανοίγει σε δεξιά σελίδα, και οι αριθμοί σελίδων, κεφαλαίων και εικόνων συνεχίζουν. · Επίπεδο 3 (Προχωρημένο) · Εγχειρίδια, οδηγοί και έργα αναφοράς
- [Αρ. 003 · Εναρκτήρια σελίδα κεφαλαίου σε ταινία ως την αιμορραγία](https://postext.dev/el/cookbook/chapter-opener-bleed-band.md): Εναρκτήρια σελίδα advancedDesign στην επικεφαλίδα επιπέδου 1: ταινία ως την αιμορραγία, ο αριθμός στη βάση της, υπέρτιτλος και εισαγωγή από την επικεφαλίδα. · Επίπεδο 3 (Προχωρημένο) · Σχολικά βιβλία
