Kurz gesagt
Ein kleines Buch mit drei Essays über das Gehen. Autor und Jahr jedes Essays werden einmal eingetippt und erscheinen dann überall, wo das Buch sie braucht, etwa im Inhaltsverzeichnis.
Was Sie setzen
Neun Seiten aus Afoot, einer Taschenanthologie mit drei Essays über das Gehen von Hazlitt (1822), Thoreau (1862) und Stevenson (1876). Das Gemälde einer Heide in der Abenddämmerung füllt den Umschlag, ein mit Diffusionsmodellen erzeugtes JPEG. Das Inhaltsverzeichnis gibt jedem Essay eine rostrote Ziffer, einen Titel in Gloock, gesperrte Füllpunkte zu seiner Seite und darunter den Namen des Autors in heidefarbener Kursive. Jeder Essay beginnt mit Ziffer und Titel, einer Autorenzeile in gesperrten Versalien und einer Herkunftszeile mit Zeitschrift und Jahr des Erstdrucks. Auf den linken Seiten steht der Name des Autors, auf den rechten der Titel des Essays. Die Überschrift jedes Essays gibt Autor, Jahr und Quelle als Attribute an, und Auftakt, Kolumnentitel und Inhaltsverzeichnis übernehmen sie von dort; ein vierter Essay verlangt also keine Änderung an der Konfiguration.
Dieses Rezept beantwortet
- Wie füge ich ein Inhaltsverzeichnis hinzu, das sich selbst aktualisiert (Führungspunkte, Seitenzahlen, Autoren, Teilzeilen)?
- Wie füge ich einem Auftakt eine Autorenzeile, einen Vorspann oder einen Einstieg mit Initiale hinzu?
- Wie setze ich Kolumnentitel: Buchtitel auf der linken Seite, Kapiteltitel auf der rechten, Seitenzahl außen?
Die kurze Antwort
// Each essay's heading carries its credits, and every {attr.…} below reads them:
// # Walking {author="Henry David Thoreau" year="1862" source="The Atlantic Monthly"}
// (a value cannot hold { or }, and one with " goes in single quotes; gotcha: attr-values)
// 1 · The opener: inside a heading's design, {attr.author} is that heading's attribute.
const byline = [
text('byline', '{attr.author}', { ...label, fontSize: pt(8), letterSpacing: pt(1.6),
color: col('heather') }, below('title', 5)),
text('dateline', '{attr.source}, {attr.year}', { fontFamily: 'Spectral', italic: true,
fontSize: pt(9.5), color: col('muted'), align: 'left' }, below('byline', 1.2)),
];
// 2 · The verso running head (head() is in the running-heads region): in the page header,
// {attr.author} is the attribute of the essay the page belongs to.
const versoAuthor = head('verso-author', '{attr.author}', 'even',
at('page', 'top-left', MARGIN.outer + HEAD.gap, HEAD.y));
// 3 · The contents: toc.subtitle prints the attribute it names as a line under each title.
// 'author' and italic are the defaults; attr is written out so it can become 'source'.
const authorLine = { enabled: true, attr: 'author', fontFamily: 'Spectral', fontSize: pt(10),
color: col('heather') };
// Hooked up below: byline → the opener, versoAuthor → header, authorLine → toc.subtitle.
// A heading without author="…" gets an empty byline and running head and no line in the
// contents, and the build gives no warning: check every heading.
Zutaten
- Funktionen
- InhaltsverzeichnisÜberschriftenattributeKolumnentitel und SeitenzahlenGestaltete AuftakteNummerierte ÜberschriftenÜberschriftenformateKapitel ohne NummerUmschläge, Titelseiten und ImpressumBilder in SeitengestaltungenGestaltungselemente verankernVerse Zeile für ZeileGespiegelte RänderAbsatzformateFixierte Kästen und PlakettenKästenExpliziter vertikaler AbstandDokument-MetadatenSemantische FarbpaletteAbbildungen und Tabellen als RessourcenSeiten auf einem Canvas
- Schrift
- Spectral, Gloock, Hanken Grotesk (SIL OFL 1.1)
- Dateien
cover-1200.jpg- The cover: a heath and hills at dusk, a painting (Generated With Diffusion Models, eigener Text)
Zubereitung
#1 · Die Essays nummerieren und ihren Text absenken
const opener = { enabled: true,
// The hairline ends 7 mm above the foot of this reserve, so the text starts on the same grid
// line under every opener whose title fits on one line (SINK = 14 holds a two-line title).
minHeight: pt(SINK * LEAD),
slot: { elements: [
// {number} prints the essay's number as numberingTemplate '{1:I}' writes it: I, II, III.
text('number', '{number}', { ...gloock, fontSize: pt(34), lineHeight: 1, color: col('rust') },
at('container', 'top-left', 0, 8)),
text('title', '{titleText}', { ...gloock, fontSize: pt(26), lineHeight: 1.08,
color: col('ink') }, below('number', 3, { width: 'fill' })),
...byline,
{ kind: 'rule', id: 'rule', thickness: pt(0.5), color: col('rule'),
placement: below('dateline', 6) }, // a horizontal rule runs to the column's edge
] } };
const essays = { level: 1, numberingTemplate: '{1:I}', advancedDesign: opener,
marginBottom: pt(0), // the heading's default margin would add to minHeight
// The cover and contents styles inherit this break (gotcha: style-inherits-break).
breakBefore: { enabled: true, parity: 'any' } }; // 'any': each piece opens on the next page
numberingTemplate: '{1:I}' der Ebene nummeriert die Essays mit I, II und III, und {number} setzt die Ziffer über den Titel (Span und erweiterte Gestaltung). minHeight reserviert 12 Zeilen zu 14 pt, und die Haarlinie endet 7 mm darüber; unter einem einzeiligen Titel beginnt der Text daher auf jedem Auftakt 79 mm unter der Oberkante. Eine zweite Titelzeile in 26 pt fügt 9,9 mm hinzu und schiebt den Text eine Rasterzeile tiefer; mit SINK = 14 beginnen ein- und zweizeilige Titel ihren Text auf derselben Zeile. marginBottom: pt(0) verhindert, dass der Standardabstand der Überschrift zur Reserve hinzukommt.
#2 · Das Inhaltsverzeichnis sich selbst füllen lassen
const ENTRY = 15; // pt: the essay titles in the contents
const contents = { // passed to the config as `toc`
// An entry's numeral takes the title's face and size and stands on its baseline.
levels: [{ level: 1, fontFamily: 'Gloock', fontSize: pt(ENTRY), color: col('ink'),
numberFontWeight: 400, // Gloock has one weight
numberColor: col('rust'), numberWidth: mm(8), numberGap: mm(3), marginBottom: pt(LEAD) }],
pageNumber: { fontFamily: 'Hanken Grotesk', fontSize: pt(8.5), fontWeight: 600,
color: col('muted'), width: mm(6) }, // the leader dots take this face and colour too
leader: { char: '. ', gap: mm(2) }, // spaced dots, right-aligned so they line up
subtitle: authorLine,
};
:::toc im Markdown gibt einen Eintrag pro aufgeführter Überschrift aus: Nummer, Titel, Füllpunkte, Seitenbezeichnung und über subtitle den Autor. buildDocument setzt das Buch erneut, bis sich die Seitenbezeichnungen nicht mehr ändern, sodass ein umbenannter oder verlängerter Essay das Inhaltsverzeichnis aktualisiert (Inhaltsverzeichnis). Die Ziffer eines Eintrags übernimmt Schrift und Größe des Titels, sofern numberFontFamily oder numberFontSize nichts anderes angeben, und sie steht in jeder Größe auf der Grundlinie der ersten Titelzeile. Ein Buch mit Teilen erhält außerdem eine Zeile für jeden :::part, gezeichnet von toc.parts.design, wie in Teile in Farbe.
#3 · Autor links, Essay rechts
// Each head: the label face, the pages of its parity, never an opener (pages: 'body'), where
// the byline names the author. A function declaration, so the answer above can call it.
function head(id, content, parity, placement, look = {}) {
return { ...text(id, content, { ...label, fontSize: pt(7.5), letterSpacing: pt(1.3),
color: col('muted'), ...look }, placement), parity, pages: 'body' };
}
const folio = { color: col('ink') };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', at('page', 'top-left', MARGIN.outer, HEAD.y), folio),
versoAuthor,
head('recto-title', '{chapterTitle}', 'odd',
at('page', 'top-right', -(MARGIN.outer + HEAD.gap), HEAD.y), { align: 'right' }),
head('recto-folio', '{pageNumber}', 'odd', at('page', 'top-right', -MARGIN.outer, HEAD.y),
{ ...folio, align: 'right' }),
] };
const footer = { elements: [{ ...head('drop-folio', '{pageNumber}', 'all', // an opener's folio
at('container', 'top', 0, 9), { ...folio, align: 'center' }), pages: 'opener' }] };
Jeder Kolumnentitel ist an der Seite verankert, 11 mm unter der Oberkante, und parity wählt die Seite: Die Pagina fluchtet mit der Außenkante des Textes, Name oder Titel stehen 7 mm weiter innen. pages: 'body' in head() hält die Kolumnentitel von den Auftakten fern, wo die Autorenzeile den Autor bereits nennt, und pages: 'opener' der Fußzeile setzt dort stattdessen eine Pagina an den Fuß (Textelemente). {chapterTitle} gibt den Titel des Essays ohne seine Ziffer aus.
#4 · Umschlag und Inhaltsverzeichnis aus der Zählung nehmen
// Unnumbered, so the first essay is I; unlisted; and with no running heads or folio. They
// inherit the level's page break, 'any' (gotcha: style-inherits-break).
const bare = { numbered: false, toc: false, header: { elements: [] }, footer: { elements: [] } };
const cover = { enabled: true, slot: { elements: [
{ kind: 'image', id: 'art', resourceId: 'cover',
placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: 'fill' } } },
text('title', '{titleText}', { ...gloock, fontSize: pt(80), lineHeight: 1, color: col('ink') },
at('page', 'top-left', MARGIN.inner, 22)), // page 1 is a recto: the inner margin is left
text('subtitle', '{subtitle}', { fontFamily: 'Spectral', italic: true, fontSize: pt(14),
color: col('ink'), align: 'left' }, below('title', 1)),
text('authors', '{attr.authors}', { ...label, fontSize: pt(8.5), letterSpacing: pt(2),
color: col('heather') }, below('subtitle', 5)),
text('imprint', '{attr.imprint}', { ...label, fontSize: pt(7.5), letterSpacing: pt(1.8),
color: col('paper') }, at('page', 'bottom-left', MARGIN.inner, -12)),
] } };
// span: 'page' in a one-column book: a design kept in its column is cut at the column's foot,
// which would leave a band of paper under the dusk.
const coverStyle = { id: 'cover', ...bare, span: 'page', advancedDesign: cover };
const contentsOpener = { enabled: true, slot: { elements: [ // {title}, {subtitle}: frontmatter
text('kicker', '{title} · {subtitle}', { ...label, fontSize: pt(8), letterSpacing: pt(1.6),
color: col('heather') }, at('container', 'top-left', 0, 8)),
text('title', '{titleText}', { ...gloock, fontSize: pt(26), color: col('ink') },
below('kicker', 2.5)),
] } };
Mit numbered: false erhöhen Umschlag und Inhaltsverzeichnis den Zähler nicht, Hazlitt ist also I, und toc: false hält beide aus der Liste (Überschriftenformate). Beide Stile erben breakBefore der Ebene mit der Parität 'any'; deshalb folgt das Inhaltsverzeichnis dem Umschlag auf Seite 2 ohne :::pagebreak. Der Stil des Umschlags reicht in einem einspaltigen Buch über die ganze Seite, denn eine Gestaltung, die in ihrer Spalte bleibt, wird am Fuß der Spalte abgeschnitten, und das ließe 22 mm Papier unter der Landschaft.
#5 · Jede Farbe mit ihrer Palettenverknüpfung ausschreiben
const palette = {
ink: '#241f26', // text: a plum-tinted near-black
paper: '#f7f2e8', // the page
heather: '#6b4468', // the bylines and the authors in the contents
rust: '#a4502a', // the essay numbers
rule: '#d5cabd', // hairlines
muted: '#6d6570', // running heads, datelines, page numbers in the contents
};
// col() links a colour to its palette entry; the hex is the value the entry holds.
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' } })),
// The engine's defaults link to 'main-color': point it at the ink, so nothing prints blue.
{ id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
col() schreibt den Hexwert jeder Farbe neben ihre paletteId, und die Engine folgt dieser Verknüpfung: Autorenzeilen, Kolumnentitel und Umschlag nehmen, was colorPalette unter der ID hält, sodass eine zweite Palette mit denselben IDs das ganze Buch umfärbt. Wenn main-color auf die Druckfarbe zeigt, sind alle Standardwerte abgedeckt, die die Konfiguration nicht neu angibt; sie erschienen sonst im Blau der Engine, #295AA3.
Das ganze Rezept
// ═══ Postext Cookbook · Nº 030 · Anthology with bylines ═══════════════════════════════
// https://postext.dev/en/cookbook/anthology-with-bylines
// Code: MIT · Text: Hazlitt, Thoreau, Stevenson (public domain) · Cover: diffusion models
// Fonts: Spectral, Gloock, Hanken Grotesk (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'anthology-with-bylines';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: heather for the credits, rust for the numbers, plum ink on warm paper
const palette = {
ink: '#241f26', // text: a plum-tinted near-black
paper: '#f7f2e8', // the page
heather: '#6b4468', // the bylines and the authors in the contents
rust: '#a4502a', // the essay numbers
rule: '#d5cabd', // hairlines
muted: '#6d6570', // running heads, datelines, page numbers in the contents
};
// col() links a colour to its palette entry; the hex is the value the entry holds.
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' } })),
// The engine's defaults link to 'main-color': point it at the ink, so nothing prints blue.
{ id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
// #endregion
const TRIM = { width: 135, height: 180 }; // a pocket book, 3 : 4
const MARGIN = { top: 20, bottom: 22, inner: 19, outer: 15 }; // mirrored
const LEAD = 14; // body leading in pt: the baseline grid
const SINK = 12; // grid lines an essay opener reserves above its first line of text
const HEAD = { y: 11, gap: 7 }; // running heads: mm from the top edge, folio to words
const label = { fontFamily: 'Hanken Grotesk', fontWeight: 600, textTransform: 'uppercase',
align: 'left' }; // design text is centred by default
// One weight, no italic; 'wrap' breaks a long title onto a second line.
const gloock = { fontFamily: 'Gloock', overflow: 'wrap', align: 'left' };
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const below = (id, y, size) => ({ ...at(`#${id}`, 'below', 0, y), ...(size && { size }) });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, ...look, placement });
// #region answer: one set of heading attributes, read in three places
// Each essay's heading carries its credits, and every {attr.…} below reads them:
// # Walking {author="Henry David Thoreau" year="1862" source="The Atlantic Monthly"}
// (a value cannot hold { or }, and one with " goes in single quotes; gotcha: attr-values)
// 1 · The opener: inside a heading's design, {attr.author} is that heading's attribute.
const byline = [
Das zusammengesetzte script.js läuft unverändert: Fügen Sie es in das Modulskript einer beliebigen Seite ein, oder öffnen Sie das Rezept auf CodePen. Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)
Varianten
#Angeben, wo jeder Essay zuerst erschien
toc.subtitle gibt jedes Attribut der Überschrift aus, sodass dasselbe Markdown unter jedem Titel die Zeitschrift des Erstdrucks aufführen kann.
-const authorLine = { enabled: true, attr: 'author', fontFamily: 'Spectral', fontSize: pt(10),
+const authorLine = { enabled: true, attr: 'source', fontFamily: 'Spectral', fontSize: pt(10),#Den Buchtitel auf die linke Seite setzen
Viele Bücher setzen ihren eigenen Titel auf die linke Seite und den des Kapitels auf die rechte; {title} übernimmt ihn aus dem Frontmatter des Markdowns und gibt AFOOT aus.
-const versoAuthor = head('verso-author', '{attr.author}', 'even',
+const versoAuthor = head('verso-author', '{title}', 'even',#Jeden Essay auf einer rechten Seite beginnen
Mit der Parität 'odd' rückt Stevenson hinter eine Vakatseite 8 auf Seite 9. Die beiden Stile der Titelei brauchen dann ein eigenes 'any', sonst erbt das Inhaltsverzeichnis 'odd' und beginnt auf Seite 3 hinter einer leeren linken Seite.
- breakBefore: { enabled: true, parity: 'any' } }; // 'any': each piece opens on the next page
+ breakBefore: { enabled: true, parity: 'odd' } };
-const bare = { numbered: false, toc: false, header: { elements: [] }, footer: { elements: [] } };
+const bare = { numbered: false, toc: false, breakBefore: { enabled: true, parity: 'any' },
+ header: { elements: [] }, footer: { elements: [] } };Häufige Fehler
Häufiger Fehler
Attributwerte: kein { oder }; einen Wert mit " in einfache Anführungszeichen setzen
Ein Attributwert endet an der schließenden geschweiften Klammer, kann also kein { oder } enthalten. Ein Wert, der ein doppeltes Anführungszeichen enthält, kommt in einfache Anführungszeichen; ein Dollarzeichen ist unproblematisch. Überschriftenattribute →
Häufiger Fehler
Ein Überschriftenformat erbt den Seitenumbruch seiner Ebene
Ein Eintrag in headingStyles übernimmt jedes Feld, das er auslässt, von seiner Überschriftenebene, breakBefore eingeschlossen. Ein Inhaltsverzeichnis oder Impressum, das nach einem :::pagebreak über eine H1 gestaltet wird, erbt die Parität 'odd' und landet hinter einer Vakatseite. Geben Sie einem solchen Format breakBefore: { enabled: false }. Überschriftenformate →
- Hazlitt zitiert Verse mitten in seinen Sätzen. Die Verszeilen gehören in einen Block
:::verse{style="verse" align=start}, eine Markdown-Zeile pro Verszeile, um 8 mm eingezogen, und der Satz, der danach weiterläuft, in ein Absatzformatrunonohne Einzug. Ein Markdown-Blockzitat taugt nicht dafür: Seine Zeilen werden wie die eines Absatzes zusammengefügt, und die Verse liefen als Prosa weiter. - Ein Attribut, das einer Überschrift fehlt, gibt nichts aus und löst keine Warnung aus. Ohne
author="…"bleiben Autorenzeile und linker Kolumnentitel eines Essays leer, und seine Zeile unter dem Titel verschwindet aus dem Inhaltsverzeichnis.
Nachweise
- Rezept
- Ignacio Ferro
- Text
- “On Going a Journey” (1822), from its first line to “I sing for joy”, in Table Talk: Essays on Men and Manners · William Hazlitt · gemeinfrei
- “Walking” (1862), its first five paragraphs · Henry David Thoreau · gemeinfrei
- “Walking Tours” (1876), the opening of its first paragraph and the whole of its second, in Virginibus Puerisque · Robert Louis Stevenson · gemeinfrei
- The note on the texts and the colophon · Ignacio Ferro · CC BY 4.0
- Bilder
- The cover: a heath and hills at dusk, a painting · Generated With Diffusion Models · eigener Text
- Schriften
- Spectral (SIL OFL 1.1) · Gloock (SIL OFL 1.1) · Hanken Grotesk (SIL OFL 1.1)
- Code
- MIT, wie Postext
Diesen Text bearbeiten ↗ (öffnet sich in einem neuen Tab)Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)


